UNPKG

ngx-editor-plus

Version:

WYSIWYG Editor for Angular Applications

67 lines (57 loc) 1.62 kB
/** * enable or disable toolbar based on configuration * * @param value toolbar item * @param toolbar toolbar configuration object */ export function canEnableToolbarOptions(value: string, toolbar: any): boolean { if (value) { if (toolbar['length'] === 0) { return true; } else { const found = toolbar.filter(array => { return array.indexOf(value) !== -1; }); return found.length ? true : false; } } else { return false; } } /** * set editor configuration * * @param value configuration via [config] property * @param ngxEditorConfig default editor configuration * @param input direct configuration inputs via directives */ export function getEditorConfiguration(value: any, ngxEditorConfig: any, input: any): any { for (const i in ngxEditorConfig) { if (i) { if (input[i]) { value[i] = input[i]; } if (!value.hasOwnProperty(i)) { value[i] = ngxEditorConfig[i]; } } } return value; } /** * return vertical if the element is the resizer property is set to basic * * @param resizer type of resizer, either basic or stack */ export function canResize(resizer: string): any { if (resizer === 'basic') { return 'vertical'; } return false; } export function encodeHTML(html:string): string{ return encodeURI(html); } export function decodeHTML(html:string): string{ return decodeURI(html); }