@skyux/text-editor 5.0.3 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/bundles/skyux-text-editor.umd.js +39 -39
- package/documentation.json +61 -14
- package/esm2015/index.js +15 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js +39 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js.map +1 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js +18 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js.map +1 -0
- package/esm2015/lib/modules/shared/forms-utility.js +10 -0
- package/esm2015/lib/modules/shared/forms-utility.js.map +1 -0
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js +106 -0
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js +42 -0
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js +7 -0
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js +5 -0
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js +15 -0
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js +12 -0
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js +196 -0
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js +473 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js +80 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js +61 -0
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js +38 -0
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/text-editor.component.js +322 -0
- package/esm2015/lib/modules/text-editor/text-editor.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/text-editor.module.js +99 -0
- package/esm2015/lib/modules/text-editor/text-editor.module.js.map +1 -0
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js +175 -0
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/editor-command.js +2 -0
- package/esm2015/lib/modules/text-editor/types/editor-command.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/editor-setting.js +2 -0
- package/esm2015/lib/modules/text-editor/types/editor-setting.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/font-state.js +2 -0
- package/esm2015/lib/modules/text-editor/types/font-state.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/menu-type.js +2 -0
- package/esm2015/lib/modules/text-editor/types/menu-type.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/style-state.js +2 -0
- package/esm2015/lib/modules/text-editor/types/style-state.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js +2 -0
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js +2 -0
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js +6 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js +2 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js +121 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js +9 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js.map +1 -0
- package/esm2015/skyux-text-editor.js +2 -2
- package/esm2015/skyux-text-editor.js.map +1 -0
- package/fesm2015/skyux-text-editor.js +105 -105
- package/fesm2015/skyux-text-editor.js.map +1 -1
- package/index.d.ts +12 -0
- package/{modules → lib/modules}/rich-text-display/rich-text-display.component.d.ts +0 -0
- package/{modules → lib/modules}/rich-text-display/rich-text-display.module.d.ts +0 -0
- package/{modules → lib/modules}/shared/forms-utility.d.ts +0 -0
- package/{modules → lib/modules}/shared/sky-text-editor-resources.module.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/font-list-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/font-size-list-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/menu-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/style-state-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/toolbar-action-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/menubar/text-editor-menubar.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor-selection.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-sanitization.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/text-editor.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/text-editor.module.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/toolbar/text-editor-toolbar.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/editor-command.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/editor-setting.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/font-state.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/menu-type.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/style-state.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/text-editor-merge-field.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/toolbar-action-type.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal-context.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal-result.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-target.d.ts +0 -0
- package/package.json +27 -13
- package/skyux-text-editor.d.ts +1 -1
- package/LICENSE +0 -21
- package/bundles/skyux-text-editor.umd.js.map +0 -1
- package/esm2015/modules/rich-text-display/rich-text-display.component.js +0 -37
- package/esm2015/modules/rich-text-display/rich-text-display.module.js +0 -18
- package/esm2015/modules/shared/forms-utility.js +0 -10
- package/esm2015/modules/shared/sky-text-editor-resources.module.js +0 -106
- package/esm2015/modules/text-editor/defaults/font-list-defaults.js +0 -42
- package/esm2015/modules/text-editor/defaults/font-size-list-defaults.js +0 -7
- package/esm2015/modules/text-editor/defaults/menu-defaults.js +0 -5
- package/esm2015/modules/text-editor/defaults/style-state-defaults.js +0 -15
- package/esm2015/modules/text-editor/defaults/toolbar-action-defaults.js +0 -12
- package/esm2015/modules/text-editor/menubar/text-editor-menubar.component.js +0 -194
- package/esm2015/modules/text-editor/services/text-editor-adapter.service.js +0 -470
- package/esm2015/modules/text-editor/services/text-editor-selection.service.js +0 -80
- package/esm2015/modules/text-editor/services/text-editor.service.js +0 -61
- package/esm2015/modules/text-editor/services/text-sanitization.service.js +0 -38
- package/esm2015/modules/text-editor/text-editor.component.js +0 -317
- package/esm2015/modules/text-editor/text-editor.module.js +0 -99
- package/esm2015/modules/text-editor/toolbar/text-editor-toolbar.component.js +0 -173
- package/esm2015/modules/text-editor/types/editor-command.js +0 -2
- package/esm2015/modules/text-editor/types/editor-setting.js +0 -2
- package/esm2015/modules/text-editor/types/font-state.js +0 -2
- package/esm2015/modules/text-editor/types/menu-type.js +0 -2
- package/esm2015/modules/text-editor/types/style-state.js +0 -2
- package/esm2015/modules/text-editor/types/text-editor-merge-field.js +0 -2
- package/esm2015/modules/text-editor/types/toolbar-action-type.js +0 -2
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal-context.js +0 -6
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal-result.js +0 -2
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal.component.js +0 -119
- package/esm2015/modules/text-editor/url-modal/text-editor-url-target.js +0 -9
- package/esm2015/public-api.js +0 -15
- package/public-api.d.ts +0 -12
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export class SkyTextEditorService {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* A dictionary representing all active text editors and their settings.
|
|
10
|
+
*/
|
|
11
|
+
this.editors = {};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns the blur observable from the editor with the corresponding id.
|
|
15
|
+
*/
|
|
16
|
+
blurListener(id) {
|
|
17
|
+
return this.editors[id].blurObservable;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns the click observable from the editor with the corresponding id.
|
|
21
|
+
*/
|
|
22
|
+
clickListener(id) {
|
|
23
|
+
return this.editors[id].clickObservable;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the command change observable from the editor with the corresponding id.
|
|
27
|
+
*/
|
|
28
|
+
commandChangeListener(id) {
|
|
29
|
+
return this.editors[id].commandChangeObservable;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the input change observable from the editor with the corresponding id.
|
|
33
|
+
*/
|
|
34
|
+
inputListener(id) {
|
|
35
|
+
return this.editors[id].inputObservable;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Removes editor from the `editors` index by id.
|
|
39
|
+
*/
|
|
40
|
+
removeEditor(id) {
|
|
41
|
+
/* istanbul ignore else */
|
|
42
|
+
if (id in this.editors) {
|
|
43
|
+
delete this.editors[id];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the selection change observable from the editor with the corresponding id.
|
|
48
|
+
*/
|
|
49
|
+
selectionChangeListener(id) {
|
|
50
|
+
return this.editors[id].selectionChangeObservable;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
SkyTextEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
54
|
+
SkyTextEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorService, providedIn: 'root' });
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorService, decorators: [{
|
|
56
|
+
type: Injectable,
|
|
57
|
+
args: [{
|
|
58
|
+
providedIn: 'root',
|
|
59
|
+
}]
|
|
60
|
+
}] });
|
|
61
|
+
//# sourceMappingURL=text-editor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor.service.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/services/text-editor.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAM3C;;GAEG;AAIH,MAAM,OAAO,oBAAoB;IAHjC;QAIE;;WAEG;QACI,YAAO,GAAqC,EAAE,CAAC;KA8CvD;IA5CC;;OAEG;IACI,YAAY,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,EAAU;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,EAAU;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,uBAAuB,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,EAAU;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,EAAU;QAC5B,0BAA0B;QAC1B,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SACzB;IACH,CAAC;IAED;;OAEG;IACI,uBAAuB,CAAC,EAAU;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,yBAAyB,CAAC;IACpD,CAAC;;kHAjDU,oBAAoB;sHAApB,oBAAoB,cAFnB,MAAM;4FAEP,oBAAoB;kBAHhC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { Observable } from 'rxjs';\n\nimport { EditorSetting } from '../types/editor-setting';\n\n/**\n * @internal\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyTextEditorService {\n /**\n * A dictionary representing all active text editors and their settings.\n */\n public editors: { [key: string]: EditorSetting } = {};\n\n /**\n * Returns the blur observable from the editor with the corresponding id.\n */\n public blurListener(id: string): Observable<unknown> {\n return this.editors[id].blurObservable;\n }\n\n /**\n * Returns the click observable from the editor with the corresponding id.\n */\n public clickListener(id: string): Observable<unknown> {\n return this.editors[id].clickObservable;\n }\n\n /**\n * Returns the command change observable from the editor with the corresponding id.\n */\n public commandChangeListener(id: string): Observable<unknown> {\n return this.editors[id].commandChangeObservable;\n }\n\n /**\n * Returns the input change observable from the editor with the corresponding id.\n */\n public inputListener(id: string): Observable<unknown> {\n return this.editors[id].inputObservable;\n }\n\n /**\n * Removes editor from the `editors` index by id.\n */\n public removeEditor(id: string): void {\n /* istanbul ignore else */\n if (id in this.editors) {\n delete this.editors[id];\n }\n }\n\n /**\n * Returns the selection change observable from the editor with the corresponding id.\n */\n public selectionChangeListener(id: string): Observable<unknown> {\n return this.editors[id].selectionChangeObservable;\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import createDOMPurify from 'dompurify';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
const domPurify = createDOMPurify(window);
|
|
5
|
+
domPurify.addHook('afterSanitizeAttributes', (node) => {
|
|
6
|
+
// Set all elements owning target to target=_blank
|
|
7
|
+
// so we only allow the target attribute with that value.
|
|
8
|
+
if (!!node.getAttribute('target')) {
|
|
9
|
+
node.setAttribute('target', '_blank');
|
|
10
|
+
node.setAttribute('rel', 'noopener noreferrer');
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* The `SkyTextSanitizationService` user the `DOMPurify` library to sanitize strings for use
|
|
15
|
+
* in the DOM. `DOMPurify` allows more customization than Angular's internal `DomSanitizer` so we
|
|
16
|
+
* can preserve `<style>` tags and allow `target` attributes for new tab links.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export class SkyTextSanitizationService {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.allowedAttributes = ['target'];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a sanitized string, allowing target attribute for new tab links.
|
|
25
|
+
*/
|
|
26
|
+
sanitize(htmlString) {
|
|
27
|
+
return domPurify.sanitize(htmlString, { ADD_ATTR: this.allowedAttributes });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
SkyTextSanitizationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextSanitizationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
31
|
+
SkyTextSanitizationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextSanitizationService, providedIn: 'root' });
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextSanitizationService, decorators: [{
|
|
33
|
+
type: Injectable,
|
|
34
|
+
args: [{
|
|
35
|
+
providedIn: 'root',
|
|
36
|
+
}]
|
|
37
|
+
}] });
|
|
38
|
+
//# sourceMappingURL=text-sanitization.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-sanitization.service.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/services/text-sanitization.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,eAAe,MAAM,WAAW,CAAC;;AACxC,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE1C,SAAS,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,IAAa,EAAE,EAAE;IAC7D,kDAAkD;IAClD,yDAAyD;IACzD,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;QACjC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;KACjD;AACH,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AAIH,MAAM,OAAO,0BAA0B;IAHvC;QAIU,sBAAiB,GAAa,CAAC,QAAQ,CAAC,CAAC;KAQlD;IANC;;OAEG;IACI,QAAQ,CAAC,UAAkB;QAChC,OAAO,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC9E,CAAC;;wHARU,0BAA0B;4HAA1B,0BAA0B,cAFzB,MAAM;4FAEP,0BAA0B;kBAHtC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { Injectable } from '@angular/core';\n\nimport createDOMPurify from 'dompurify';\nconst domPurify = createDOMPurify(window);\n\ndomPurify.addHook('afterSanitizeAttributes', (node: Element) => {\n // Set all elements owning target to target=_blank\n // so we only allow the target attribute with that value.\n if (!!node.getAttribute('target')) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener noreferrer');\n }\n});\n\n/**\n * The `SkyTextSanitizationService` user the `DOMPurify` library to sanitize strings for use\n * in the DOM. `DOMPurify` allows more customization than Angular's internal `DomSanitizer` so we\n * can preserve `<style>` tags and allow `target` attributes for new tab links.\n * @internal\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyTextSanitizationService {\n private allowedAttributes: string[] = ['target'];\n\n /**\n * Returns a sanitized string, allowing target attribute for new tab links.\n */\n public sanitize(htmlString: string): string {\n return domPurify.sanitize(htmlString, { ADD_ATTR: this.allowedAttributes });\n }\n}\n"]}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { ChangeDetectorRef, ChangeDetectionStrategy, Component, ElementRef, Input, NgZone, ViewChild, ViewEncapsulation, } from '@angular/core';
|
|
2
|
+
import { NgControl } from '@angular/forms';
|
|
3
|
+
import { takeUntil } from 'rxjs/operators';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
import { SkyCoreAdapterService } from '@skyux/core';
|
|
6
|
+
import { MENU_DEFAULTS } from './defaults/menu-defaults';
|
|
7
|
+
import { STYLE_STATE_DEFAULTS } from './defaults/style-state-defaults';
|
|
8
|
+
import { TOOLBAR_ACTION_DEFAULTS } from './defaults/toolbar-action-defaults';
|
|
9
|
+
import { SkyTextEditorAdapterService } from './services/text-editor-adapter.service';
|
|
10
|
+
import { SkyTextEditorService } from './services/text-editor.service';
|
|
11
|
+
import { SkyTextSanitizationService } from './services/text-sanitization.service';
|
|
12
|
+
import { FONT_LIST_DEFAULTS } from './defaults/font-list-defaults';
|
|
13
|
+
import { FONT_SIZE_LIST_DEFAULTS } from './defaults/font-size-list-defaults';
|
|
14
|
+
import { SkyFormsUtility } from '../shared/forms-utility';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
import * as i1 from "@skyux/core";
|
|
17
|
+
import * as i2 from "./services/text-editor-adapter.service";
|
|
18
|
+
import * as i3 from "./services/text-editor.service";
|
|
19
|
+
import * as i4 from "./services/text-sanitization.service";
|
|
20
|
+
import * as i5 from "@angular/forms";
|
|
21
|
+
import * as i6 from "@skyux/layout";
|
|
22
|
+
import * as i7 from "./menubar/text-editor-menubar.component";
|
|
23
|
+
import * as i8 from "./toolbar/text-editor-toolbar.component";
|
|
24
|
+
import * as i9 from "@angular/common";
|
|
25
|
+
/**
|
|
26
|
+
* Auto-incrementing integer used to generate unique ids for radio components.
|
|
27
|
+
*/
|
|
28
|
+
let nextUniqueId = 0;
|
|
29
|
+
/**
|
|
30
|
+
* The text editor component lets users format and manipulate text.
|
|
31
|
+
*/
|
|
32
|
+
export class SkyTextEditorComponent {
|
|
33
|
+
constructor(changeDetector, coreAdapterService, adapterService, editorService, sanitizationService, ngControl, zone) {
|
|
34
|
+
this.changeDetector = changeDetector;
|
|
35
|
+
this.coreAdapterService = coreAdapterService;
|
|
36
|
+
this.adapterService = adapterService;
|
|
37
|
+
this.editorService = editorService;
|
|
38
|
+
this.sanitizationService = sanitizationService;
|
|
39
|
+
this.ngControl = ngControl;
|
|
40
|
+
this.zone = zone;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates whether to put focus on the editor after it renders.
|
|
43
|
+
*/
|
|
44
|
+
this.autofocus = false;
|
|
45
|
+
this.editorFocusStream = new Subject();
|
|
46
|
+
/**
|
|
47
|
+
* Specifies the fonts to include in the font picker.
|
|
48
|
+
* @default [{name: 'Blackbaud Sans', value: '"Blackbaud Sans", Arial, sans-serif'}, {name: 'Arial', value: 'Arial'}, {name: 'Arial Black', value: '"Arial Black"'}, {name: 'Courier New', value: '"Courier New"'}, {name: 'Georgia', value: 'Georgia, serif'}, {name: 'Tahoma', value: 'Tahoma, Geneva, sans-serif'}, {name: 'Times New Roman', value: '"Times New Roman"'}, {name: 'Trebuchet MS', value: '"Trebuchet MS", sans-serif'}, {name: 'Verdana', value: 'Verdana, Geneva, sans-serif'}]
|
|
49
|
+
*/
|
|
50
|
+
this.fontList = FONT_LIST_DEFAULTS;
|
|
51
|
+
/**
|
|
52
|
+
* Specifies the font sizes to include in the font size picker.
|
|
53
|
+
* @default [6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 36, 48]
|
|
54
|
+
*/
|
|
55
|
+
this.fontSizeList = FONT_SIZE_LIST_DEFAULTS;
|
|
56
|
+
/**
|
|
57
|
+
* Specifies a unique ID attribute for the text editor.
|
|
58
|
+
* By default, the component generates a random ID.
|
|
59
|
+
*/
|
|
60
|
+
this.id = `sky-text-editor-${++nextUniqueId}`;
|
|
61
|
+
/**
|
|
62
|
+
* Specifies the menus to include in the menu bar.
|
|
63
|
+
* @default [ 'edit', 'format' ]
|
|
64
|
+
*/
|
|
65
|
+
this.menus = MENU_DEFAULTS;
|
|
66
|
+
/**
|
|
67
|
+
* Specifies the merge fields to include in the merge field menu.
|
|
68
|
+
*/
|
|
69
|
+
this.mergeFields = [];
|
|
70
|
+
/**
|
|
71
|
+
* Specifies the actions to include in the toolbar and determines their order.
|
|
72
|
+
* @default [ 'font-family', 'font-size', 'font-style', 'color', 'list', 'link ]
|
|
73
|
+
*/
|
|
74
|
+
this.toolbarActions = TOOLBAR_ACTION_DEFAULTS;
|
|
75
|
+
this.focusInitialized = false;
|
|
76
|
+
this.initialized = false;
|
|
77
|
+
this.ngUnsubscribe = new Subject();
|
|
78
|
+
this._disabled = false;
|
|
79
|
+
this._initialStyleState = Object.assign({}, STYLE_STATE_DEFAULTS);
|
|
80
|
+
this._placeholder = '';
|
|
81
|
+
this._value = '<p></p>';
|
|
82
|
+
/* istanbul ignore next */
|
|
83
|
+
this._onTouched = () => { };
|
|
84
|
+
/* istanbul ignore next */
|
|
85
|
+
this._onChange = () => { };
|
|
86
|
+
this.ngControl.valueAccessor = this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Indicates whether to disable the text editor.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
set disabled(value) {
|
|
93
|
+
const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);
|
|
94
|
+
if (coercedValue !== this.disabled) {
|
|
95
|
+
this._disabled = coercedValue;
|
|
96
|
+
// Update focusableChildren inside the iframe.
|
|
97
|
+
let focusableChildren;
|
|
98
|
+
/* istanbul ignore else */
|
|
99
|
+
if (this.iframeRef) {
|
|
100
|
+
focusableChildren = this.coreAdapterService.getFocusableChildren(this.iframeRef.nativeElement.contentDocument.body, {
|
|
101
|
+
ignoreVisibility: true,
|
|
102
|
+
ignoreTabIndex: true,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (this._disabled) {
|
|
106
|
+
this.adapterService.disableEditor(this.id, focusableChildren, this.iframeRef.nativeElement);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.adapterService.enableEditor(this.id, focusableChildren, this.iframeRef.nativeElement);
|
|
110
|
+
}
|
|
111
|
+
this.changeDetector.markForCheck();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
get disabled() {
|
|
115
|
+
return this._disabled;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Specifies the initial styles for all content, including background color, font size, and link state.
|
|
119
|
+
*/
|
|
120
|
+
set initialStyleState(state) {
|
|
121
|
+
// Do not update the state after initialization has taken place
|
|
122
|
+
/* istanbul ignore else */
|
|
123
|
+
if (!this.initialized) {
|
|
124
|
+
this._initialStyleState = Object.assign(Object.assign({}, STYLE_STATE_DEFAULTS), state);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get initialStyleState() {
|
|
128
|
+
return this._initialStyleState;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Specifies placeholder text to display when the text entry area is empty.
|
|
132
|
+
*/
|
|
133
|
+
set placeholder(value) {
|
|
134
|
+
/* istanbul ignore else */
|
|
135
|
+
if (value !== this._placeholder) {
|
|
136
|
+
this._placeholder = value;
|
|
137
|
+
if (this.initialized) {
|
|
138
|
+
this.adapterService.setPlaceholder(this.id, value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
get placeholder() {
|
|
143
|
+
return this._placeholder;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The internal value of the control.
|
|
147
|
+
*/
|
|
148
|
+
set value(value) {
|
|
149
|
+
// Normalize value and set any empty state to an empty string.
|
|
150
|
+
let normalizedValue = value;
|
|
151
|
+
if (!value ||
|
|
152
|
+
value.trim() === '<p></p>' ||
|
|
153
|
+
value.trim() === '<br>' ||
|
|
154
|
+
value.trim() === '<p><br></p>') {
|
|
155
|
+
normalizedValue = '';
|
|
156
|
+
}
|
|
157
|
+
normalizedValue = this.sanitizationService.sanitize(normalizedValue).trim();
|
|
158
|
+
if (this._value !== normalizedValue) {
|
|
159
|
+
this._value = normalizedValue;
|
|
160
|
+
// Update angular form control if model has been normalized.
|
|
161
|
+
/* istanbul ignore else */
|
|
162
|
+
if (this.ngControl && this.ngControl.control) {
|
|
163
|
+
/* istanbul ignore else */
|
|
164
|
+
if (normalizedValue !== this.ngControl.control.value) {
|
|
165
|
+
this.ngControl.control.setValue(normalizedValue, {
|
|
166
|
+
emitModelToViewChange: false,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Autofocus isn't testable in Firefox and IE.
|
|
171
|
+
/* istanbul ignore next */
|
|
172
|
+
if (this.autofocus && !this.focusInitialized) {
|
|
173
|
+
this.adapterService.focusEditor(this.id);
|
|
174
|
+
this.focusInitialized = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
get value() {
|
|
179
|
+
return this._value;
|
|
180
|
+
}
|
|
181
|
+
ngAfterViewInit() {
|
|
182
|
+
this.initIframe();
|
|
183
|
+
}
|
|
184
|
+
ngOnDestroy() {
|
|
185
|
+
this.adapterService.removeObservers(this.editorService.editors[this.id]);
|
|
186
|
+
this.editorService.removeEditor(this.id);
|
|
187
|
+
this.ngUnsubscribe.next();
|
|
188
|
+
this.ngUnsubscribe.complete();
|
|
189
|
+
}
|
|
190
|
+
onIframeLoad() {
|
|
191
|
+
// Remove editor if it already exists to cover situations where the text editor might have been moved in the DOM.
|
|
192
|
+
/* istanbul ignore else */
|
|
193
|
+
if (this.editorService.editors[this.id]) {
|
|
194
|
+
this.editorService.removeEditor(this.id);
|
|
195
|
+
this.initIframe();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Implemented as part of ControlValueAccessor.
|
|
200
|
+
*/
|
|
201
|
+
writeValue(value) {
|
|
202
|
+
this.value = value;
|
|
203
|
+
// Update HTML if necessary.
|
|
204
|
+
const editorValue = this.adapterService.getEditorInnerHtml(this.id);
|
|
205
|
+
if (this.initialized && editorValue !== this._value) {
|
|
206
|
+
this.adapterService.setEditorInnerHtml(this.id, this._value);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Implemented as part of ControlValueAccessor.
|
|
211
|
+
*/
|
|
212
|
+
registerOnChange(fn) {
|
|
213
|
+
this._onChange = fn;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Implemented as part of ControlValueAccessor.
|
|
217
|
+
*/
|
|
218
|
+
registerOnTouched(fn) {
|
|
219
|
+
this._onTouched = fn;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Implemented as part of ControlValueAccessor.
|
|
223
|
+
*/
|
|
224
|
+
setDisabledState(isDisabled) {
|
|
225
|
+
this.disabled = isDisabled;
|
|
226
|
+
}
|
|
227
|
+
updateStyle() {
|
|
228
|
+
this._initialStyleState = Object.assign(Object.assign({}, this._initialStyleState), this.adapterService.getStyleState(this.id));
|
|
229
|
+
}
|
|
230
|
+
initIframe() {
|
|
231
|
+
this.adapterService.addEditor(this.id, this.iframeRef.nativeElement, this.initialStyleState, this.placeholder);
|
|
232
|
+
this.editorService
|
|
233
|
+
.inputListener(this.id)
|
|
234
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
235
|
+
.subscribe(() => {
|
|
236
|
+
// Angular doesn't run change detection for changes originating inside an iframe,
|
|
237
|
+
// so we have to call the onChange() event inside NgZone to force change propigation to consuming components.
|
|
238
|
+
this.zone.run(() => {
|
|
239
|
+
this.ViewToModelUpdate();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
this.editorService
|
|
243
|
+
.selectionChangeListener(this.id)
|
|
244
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
245
|
+
.subscribe(() => {
|
|
246
|
+
this.updateStyle();
|
|
247
|
+
this.editorFocusStream.next();
|
|
248
|
+
});
|
|
249
|
+
this.editorService
|
|
250
|
+
.clickListener(this.id)
|
|
251
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
252
|
+
.subscribe(() => {
|
|
253
|
+
this.editorFocusStream.next();
|
|
254
|
+
});
|
|
255
|
+
this.editorService
|
|
256
|
+
.blurListener(this.id)
|
|
257
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
258
|
+
.subscribe(() => {
|
|
259
|
+
// Angular doesn't run change detection for changes originating inside an iframe,
|
|
260
|
+
// so we have to run markForCheck() inside the NgZone to force change propigation to consuming components.
|
|
261
|
+
this.zone.run(() => {
|
|
262
|
+
this._onTouched();
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
this.editorService
|
|
266
|
+
.commandChangeListener(this.id)
|
|
267
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
268
|
+
.subscribe(() => {
|
|
269
|
+
this.updateStyle();
|
|
270
|
+
this.ViewToModelUpdate();
|
|
271
|
+
});
|
|
272
|
+
this.adapterService.setEditorInnerHtml(this.id, this._value);
|
|
273
|
+
/* istanbul ignore next */
|
|
274
|
+
if (this.autofocus) {
|
|
275
|
+
this.adapterService.focusEditor(this.id);
|
|
276
|
+
}
|
|
277
|
+
this.initialized = true;
|
|
278
|
+
}
|
|
279
|
+
ViewToModelUpdate(emitChange = true) {
|
|
280
|
+
this.value = this.adapterService.getEditorInnerHtml(this.id);
|
|
281
|
+
/* istanbul ignore else */
|
|
282
|
+
if (emitChange) {
|
|
283
|
+
this._onChange(this._value);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
SkyTextEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.SkyCoreAdapterService }, { token: i2.SkyTextEditorAdapterService }, { token: i3.SkyTextEditorService }, { token: i4.SkyTextSanitizationService }, { token: i5.NgControl }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
288
|
+
SkyTextEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyTextEditorComponent, selector: "sky-text-editor", inputs: { autofocus: "autofocus", disabled: "disabled", fontList: "fontList", fontSizeList: "fontSizeList", id: "id", initialStyleState: "initialStyleState", menus: "menus", mergeFields: "mergeFields", placeholder: "placeholder", toolbarActions: "toolbarActions" }, viewQueries: [{ propertyName: "iframeRef", first: true, predicate: ["iframe"], descendants: true }], ngImport: i0, template: "<div class=\"sky-text-editor\">\n <sky-toolbar class=\"sky-text-editor-toolbar\">\n <sky-toolbar-section\n aria-label=\"Text formatting\"\n class=\"menubar\"\n role=\"toolbar\"\n >\n <sky-text-editor-menubar\n [disabled]=\"disabled\"\n [editorFocusStream]=\"editorFocusStream\"\n [editorId]=\"id\"\n [menus]=\"menus\"\n [mergeFields]=\"mergeFields\"\n >\n </sky-text-editor-menubar>\n </sky-toolbar-section>\n <sky-toolbar-section\n aria-label=\"Text formatting\"\n class=\"toolbar\"\n role=\"toolbar\"\n >\n <sky-text-editor-toolbar\n [disabled]=\"disabled\"\n [editorFocusStream]=\"editorFocusStream\"\n [editorId]=\"id\"\n [fontList]=\"fontList\"\n [fontSizeList]=\"fontSizeList\"\n [toolbarActions]=\"toolbarActions\"\n [styleState]=\"initialStyleState\"\n >\n </sky-text-editor-toolbar>\n </sky-toolbar-section>\n </sky-toolbar>\n <iframe\n class=\"sky-text-editor-wrapper\"\n src=\"about:blank\"\n title=\"Text Editor\"\n [ngClass]=\"{\n 'sky-text-editor-wrapper-disabled': disabled\n }\"\n (load)=\"onIframeLoad()\"\n #iframe\n >\n </iframe>\n</div>\n", styles: [".sky-text-editor .sky-text-editor-wrapper{display:flex;flex-wrap:wrap;background-color:#fff;width:100%;height:300px;padding:1rem;font-size:1.2rem;border:1px solid #c0c0c0;overflow-y:auto;outline:none}.sky-text-editor .sky-text-editor-wrapper.sky-text-editor-wrapper-disabled{background-color:#ededee}.sky-text-editor .sky-text-editor-toolbar .sky-toolbar-section{padding:10px 10px 0}.sky-text-editor .sky-text-editor-toolbar .sky-toolbar-sectioned{border-left:1px solid #cdcfd2!important;border-right:1px solid #cdcfd2!important}.sky-text-editor .sky-text-editor-toolbar .sky-toolbar-item{margin:0 20px 10px 0}.sky-text-editor .sky-text-editor-toolbar .sky-dropdown-button{border:none}.sky-text-editor .sky-text-editor-toolbar sky-text-editor-menubar,.sky-text-editor .sky-text-editor-toolbar sky-text-editor-toolbar{display:flex;flex-wrap:wrap}.sky-theme-modern .sky-text-editor .sky-text-editor-wrapper{border:1px solid #d2d2d2}.sky-theme-modern .sky-text-editor .sky-text-editor-wrapper.sky-text-editor-wrapper-disabled{background-color:#ececed}.sky-theme-modern .sky-text-editor .sky-text-editor-toolbar .sky-toolbar{padding:10px 10px 0}.sky-theme-modern .sky-text-editor .sky-text-editor-toolbar .sky-toolbar-section{padding:10px!important}.sky-theme-modern .sky-text-editor .sky-text-editor-toolbar .sky-toolbar-sectioned{border-top:1px solid #d2d2d2!important;border-left:1px solid #d2d2d2!important;border-right:1px solid #d2d2d2!important}.sky-theme-modern .sky-text-editor .sky-text-editor-toolbar .sky-toolbar-item{margin:0 20px 0 0!important}\n"], components: [{ type: i6.λ37, selector: "sky-toolbar" }, { type: i6.λ38, selector: "sky-toolbar-section" }, { type: i7.SkyTextEditorMenubarComponent, selector: "sky-text-editor-menubar", inputs: ["editorFocusStream", "editorId", "menus", "mergeFields", "disabled"] }, { type: i8.SkyTextEditorToolbarComponent, selector: "sky-text-editor-toolbar", inputs: ["editorFocusStream", "editorId", "fontList", "fontSizeList", "toolbarActions", "styleState", "disabled"] }], directives: [{ type: i9.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
289
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorComponent, decorators: [{
|
|
290
|
+
type: Component,
|
|
291
|
+
args: [{
|
|
292
|
+
selector: 'sky-text-editor',
|
|
293
|
+
templateUrl: './text-editor.component.html',
|
|
294
|
+
styleUrls: ['./text-editor.component.scss'],
|
|
295
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
296
|
+
encapsulation: ViewEncapsulation.None,
|
|
297
|
+
}]
|
|
298
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1.SkyCoreAdapterService }, { type: i2.SkyTextEditorAdapterService }, { type: i3.SkyTextEditorService }, { type: i4.SkyTextSanitizationService }, { type: i5.NgControl }, { type: i0.NgZone }]; }, propDecorators: { autofocus: [{
|
|
299
|
+
type: Input
|
|
300
|
+
}], disabled: [{
|
|
301
|
+
type: Input
|
|
302
|
+
}], fontList: [{
|
|
303
|
+
type: Input
|
|
304
|
+
}], fontSizeList: [{
|
|
305
|
+
type: Input
|
|
306
|
+
}], id: [{
|
|
307
|
+
type: Input
|
|
308
|
+
}], initialStyleState: [{
|
|
309
|
+
type: Input
|
|
310
|
+
}], menus: [{
|
|
311
|
+
type: Input
|
|
312
|
+
}], mergeFields: [{
|
|
313
|
+
type: Input
|
|
314
|
+
}], placeholder: [{
|
|
315
|
+
type: Input
|
|
316
|
+
}], toolbarActions: [{
|
|
317
|
+
type: Input
|
|
318
|
+
}], iframeRef: [{
|
|
319
|
+
type: ViewChild,
|
|
320
|
+
args: ['iframe']
|
|
321
|
+
}] } });
|
|
322
|
+
//# sourceMappingURL=text-editor.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/text-editor.component.ts","../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/text-editor.component.html"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,KAAK,EACL,MAAM,EAEN,SAAS,EACT,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MA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DE,SAAS;sBADhB,SAAS;uBAAC,QAAQ","sourcesContent":["import {\n AfterViewInit,\n ChangeDetectorRef,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n Input,\n NgZone,\n OnDestroy,\n ViewChild,\n ViewEncapsulation,\n} from '@angular/core';\n\nimport { NgControl } from '@angular/forms';\n\nimport { takeUntil } from 'rxjs/operators';\n\nimport { Subject } from 'rxjs';\n\nimport { SkyCoreAdapterService } from '@skyux/core';\n\nimport { MENU_DEFAULTS } from './defaults/menu-defaults';\n\nimport { STYLE_STATE_DEFAULTS } from './defaults/style-state-defaults';\n\nimport { TOOLBAR_ACTION_DEFAULTS } from './defaults/toolbar-action-defaults';\n\nimport { SkyTextEditorAdapterService } from './services/text-editor-adapter.service';\n\nimport { SkyTextEditorService } from './services/text-editor.service';\n\nimport { SkyTextSanitizationService } from './services/text-sanitization.service';\n\nimport { FONT_LIST_DEFAULTS } from './defaults/font-list-defaults';\n\nimport { FONT_SIZE_LIST_DEFAULTS } from './defaults/font-size-list-defaults';\n\nimport { SkyTextEditorFont } from './types/font-state';\n\nimport { SkyTextEditorMenuType } from './types/menu-type';\n\nimport { SkyTextEditorStyleState } from './types/style-state';\n\nimport { SkyTextEditorMergeField } from './types/text-editor-merge-field';\n\nimport { SkyTextEditorToolbarActionType } from './types/toolbar-action-type';\n\nimport { SkyFormsUtility } from '../shared/forms-utility';\n\n/**\n * Auto-incrementing integer used to generate unique ids for radio components.\n */\nlet nextUniqueId = 0;\n\n/**\n * The text editor component lets users format and manipulate text.\n */\n@Component({\n selector: 'sky-text-editor',\n templateUrl: './text-editor.component.html',\n styleUrls: ['./text-editor.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class SkyTextEditorComponent implements AfterViewInit, OnDestroy {\n /**\n * Indicates whether to put focus on the editor after it renders.\n */\n @Input()\n public autofocus: boolean = false;\n\n /**\n * Indicates whether to disable the text editor.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);\n if (coercedValue !== this.disabled) {\n this._disabled = coercedValue;\n\n // Update focusableChildren inside the iframe.\n let focusableChildren: HTMLElement[];\n /* istanbul ignore else */\n if (this.iframeRef) {\n focusableChildren = this.coreAdapterService.getFocusableChildren(\n this.iframeRef.nativeElement.contentDocument.body,\n {\n ignoreVisibility: true,\n ignoreTabIndex: true,\n }\n );\n }\n\n if (this._disabled) {\n this.adapterService.disableEditor(\n this.id,\n focusableChildren,\n this.iframeRef.nativeElement\n );\n } else {\n this.adapterService.enableEditor(\n this.id,\n focusableChildren,\n this.iframeRef.nativeElement\n );\n }\n this.changeDetector.markForCheck();\n }\n }\n\n public get disabled() {\n return this._disabled;\n }\n\n public editorFocusStream = new Subject();\n\n /**\n * Specifies the fonts to include in the font picker.\n * @default [{name: 'Blackbaud Sans', value: '\"Blackbaud Sans\", Arial, sans-serif'}, {name: 'Arial', value: 'Arial'}, {name: 'Arial Black', value: '\"Arial Black\"'}, {name: 'Courier New', value: '\"Courier New\"'}, {name: 'Georgia', value: 'Georgia, serif'}, {name: 'Tahoma', value: 'Tahoma, Geneva, sans-serif'}, {name: 'Times New Roman', value: '\"Times New Roman\"'}, {name: 'Trebuchet MS', value: '\"Trebuchet MS\", sans-serif'}, {name: 'Verdana', value: 'Verdana, Geneva, sans-serif'}]\n */\n @Input()\n public fontList: SkyTextEditorFont[] = FONT_LIST_DEFAULTS;\n\n /**\n * Specifies the font sizes to include in the font size picker.\n * @default [6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 36, 48]\n */\n @Input()\n public fontSizeList: number[] = FONT_SIZE_LIST_DEFAULTS;\n\n /**\n * Specifies a unique ID attribute for the text editor.\n * By default, the component generates a random ID.\n */\n @Input()\n public id = `sky-text-editor-${++nextUniqueId}`;\n\n /**\n * Specifies the initial styles for all content, including background color, font size, and link state.\n */\n @Input()\n public set initialStyleState(state: SkyTextEditorStyleState) {\n // Do not update the state after initialization has taken place\n /* istanbul ignore else */\n if (!this.initialized) {\n this._initialStyleState = {\n ...STYLE_STATE_DEFAULTS,\n ...state,\n };\n }\n }\n\n public get initialStyleState(): SkyTextEditorStyleState {\n return this._initialStyleState;\n }\n\n /**\n * Specifies the menus to include in the menu bar.\n * @default [ 'edit', 'format' ]\n */\n @Input()\n public menus: SkyTextEditorMenuType[] = MENU_DEFAULTS;\n\n /**\n * Specifies the merge fields to include in the merge field menu.\n */\n @Input()\n public mergeFields: SkyTextEditorMergeField[] = [];\n\n /**\n * Specifies placeholder text to display when the text entry area is empty.\n */\n @Input()\n public set placeholder(value: string) {\n /* istanbul ignore else */\n if (value !== this._placeholder) {\n this._placeholder = value;\n if (this.initialized) {\n this.adapterService.setPlaceholder(this.id, value);\n }\n }\n }\n\n public get placeholder(): string {\n return this._placeholder;\n }\n\n /**\n * Specifies the actions to include in the toolbar and determines their order.\n * @default [ 'font-family', 'font-size', 'font-style', 'color', 'list', 'link ]\n */\n @Input()\n public toolbarActions: SkyTextEditorToolbarActionType[] = TOOLBAR_ACTION_DEFAULTS;\n\n /**\n * The internal value of the control.\n */\n public set value(value: string) {\n // Normalize value and set any empty state to an empty string.\n let normalizedValue: string = value;\n if (\n !value ||\n value.trim() === '<p></p>' ||\n value.trim() === '<br>' ||\n value.trim() === '<p><br></p>'\n ) {\n normalizedValue = '';\n }\n normalizedValue = this.sanitizationService.sanitize(normalizedValue).trim();\n\n if (this._value !== normalizedValue) {\n this._value = normalizedValue;\n\n // Update angular form control if model has been normalized.\n /* istanbul ignore else */\n if (this.ngControl && this.ngControl.control) {\n /* istanbul ignore else */\n if (normalizedValue !== this.ngControl.control.value) {\n this.ngControl.control.setValue(normalizedValue, {\n emitModelToViewChange: false,\n });\n }\n }\n\n // Autofocus isn't testable in Firefox and IE.\n /* istanbul ignore next */\n if (this.autofocus && !this.focusInitialized) {\n this.adapterService.focusEditor(this.id);\n this.focusInitialized = true;\n }\n }\n }\n\n public get value(): string {\n return this._value;\n }\n\n private focusInitialized: boolean = false;\n\n @ViewChild('iframe')\n private iframeRef: ElementRef;\n\n private initialized: boolean = false;\n\n private ngUnsubscribe = new Subject<void>();\n\n private _disabled: boolean = false;\n\n private _initialStyleState = Object.assign({}, STYLE_STATE_DEFAULTS);\n\n private _placeholder = '';\n\n private _value: string = '<p></p>';\n\n constructor(\n private changeDetector: ChangeDetectorRef,\n private coreAdapterService: SkyCoreAdapterService,\n private adapterService: SkyTextEditorAdapterService,\n private editorService: SkyTextEditorService,\n private sanitizationService: SkyTextSanitizationService,\n private ngControl: NgControl,\n private zone: NgZone\n ) {\n this.ngControl.valueAccessor = this;\n }\n\n public ngAfterViewInit(): void {\n this.initIframe();\n }\n\n public ngOnDestroy(): void {\n this.adapterService.removeObservers(this.editorService.editors[this.id]);\n this.editorService.removeEditor(this.id);\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n public onIframeLoad(): void {\n // Remove editor if it already exists to cover situations where the text editor might have been moved in the DOM.\n /* istanbul ignore else */\n if (this.editorService.editors[this.id]) {\n this.editorService.removeEditor(this.id);\n this.initIframe();\n }\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public writeValue(value: string): void {\n this.value = value;\n\n // Update HTML if necessary.\n const editorValue = this.adapterService.getEditorInnerHtml(this.id);\n if (this.initialized && editorValue !== this._value) {\n this.adapterService.setEditorInnerHtml(this.id, this._value);\n }\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnChange(fn: (value: any) => void): void {\n this._onChange = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public registerOnTouched(fn: () => void): void {\n this._onTouched = fn;\n }\n\n /**\n * Implemented as part of ControlValueAccessor.\n */\n public setDisabledState(isDisabled: boolean): void {\n this.disabled = isDisabled;\n }\n\n private updateStyle(): void {\n this._initialStyleState = {\n ...this._initialStyleState,\n ...(this.adapterService.getStyleState(this.id) as any),\n };\n }\n\n private initIframe(): void {\n this.adapterService.addEditor(\n this.id,\n this.iframeRef.nativeElement,\n this.initialStyleState,\n this.placeholder\n );\n\n this.editorService\n .inputListener(this.id)\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n // Angular doesn't run change detection for changes originating inside an iframe,\n // so we have to call the onChange() event inside NgZone to force change propigation to consuming components.\n this.zone.run(() => {\n this.ViewToModelUpdate();\n });\n });\n\n this.editorService\n .selectionChangeListener(this.id)\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n this.updateStyle();\n this.editorFocusStream.next();\n });\n\n this.editorService\n .clickListener(this.id)\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n this.editorFocusStream.next();\n });\n\n this.editorService\n .blurListener(this.id)\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n // Angular doesn't run change detection for changes originating inside an iframe,\n // so we have to run markForCheck() inside the NgZone to force change propigation to consuming components.\n this.zone.run(() => {\n this._onTouched();\n });\n });\n\n this.editorService\n .commandChangeListener(this.id)\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n this.updateStyle();\n this.ViewToModelUpdate();\n });\n\n this.adapterService.setEditorInnerHtml(this.id, this._value);\n\n /* istanbul ignore next */\n if (this.autofocus) {\n this.adapterService.focusEditor(this.id);\n }\n\n this.initialized = true;\n }\n\n private ViewToModelUpdate(emitChange: boolean = true): void {\n this.value = this.adapterService.getEditorInnerHtml(this.id);\n /* istanbul ignore else */\n if (emitChange) {\n this._onChange(this._value);\n }\n }\n\n /* istanbul ignore next */\n private _onTouched = () => {};\n\n /* istanbul ignore next */\n private _onChange: (value: any) => void = () => {};\n}\n","<div class=\"sky-text-editor\">\n <sky-toolbar class=\"sky-text-editor-toolbar\">\n <sky-toolbar-section\n aria-label=\"Text formatting\"\n class=\"menubar\"\n role=\"toolbar\"\n >\n <sky-text-editor-menubar\n [disabled]=\"disabled\"\n [editorFocusStream]=\"editorFocusStream\"\n [editorId]=\"id\"\n [menus]=\"menus\"\n [mergeFields]=\"mergeFields\"\n >\n </sky-text-editor-menubar>\n </sky-toolbar-section>\n <sky-toolbar-section\n aria-label=\"Text formatting\"\n class=\"toolbar\"\n role=\"toolbar\"\n >\n <sky-text-editor-toolbar\n [disabled]=\"disabled\"\n [editorFocusStream]=\"editorFocusStream\"\n [editorId]=\"id\"\n [fontList]=\"fontList\"\n [fontSizeList]=\"fontSizeList\"\n [toolbarActions]=\"toolbarActions\"\n [styleState]=\"initialStyleState\"\n >\n </sky-text-editor-toolbar>\n </sky-toolbar-section>\n </sky-toolbar>\n <iframe\n class=\"sky-text-editor-wrapper\"\n src=\"about:blank\"\n title=\"Text Editor\"\n [ngClass]=\"{\n 'sky-text-editor-wrapper-disabled': disabled\n }\"\n (load)=\"onIframeLoad()\"\n #iframe\n >\n </iframe>\n</div>\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { SkyColorpickerModule } from '@skyux/colorpicker';
|
|
5
|
+
import { SkyCoreAdapterModule, SkyIdModule } from '@skyux/core';
|
|
6
|
+
import { SkyCheckboxModule, SkyInputBoxModule } from '@skyux/forms';
|
|
7
|
+
import { SkyModalModule } from '@skyux/modals';
|
|
8
|
+
import { SkyI18nModule } from '@skyux/i18n';
|
|
9
|
+
import { SkyIconModule } from '@skyux/indicators';
|
|
10
|
+
import { SkyToolbarModule } from '@skyux/layout';
|
|
11
|
+
import { SkyDropdownModule } from '@skyux/popovers';
|
|
12
|
+
import { SkyTabsModule } from '@skyux/tabs';
|
|
13
|
+
import { SkyThemeModule } from '@skyux/theme';
|
|
14
|
+
import { SkyTextEditorResourcesModule } from '../../modules/shared/sky-text-editor-resources.module';
|
|
15
|
+
import { SkyTextEditorMenubarComponent } from './menubar/text-editor-menubar.component';
|
|
16
|
+
import { SkyTextEditorToolbarComponent } from './toolbar/text-editor-toolbar.component';
|
|
17
|
+
import { SkyTextEditorUrlModalComponent } from './url-modal/text-editor-url-modal.component';
|
|
18
|
+
import { SkyTextEditorComponent } from './text-editor.component';
|
|
19
|
+
import * as i0 from "@angular/core";
|
|
20
|
+
export class SkyTextEditorModule {
|
|
21
|
+
}
|
|
22
|
+
SkyTextEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
23
|
+
SkyTextEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorModule, declarations: [SkyTextEditorComponent,
|
|
24
|
+
SkyTextEditorUrlModalComponent,
|
|
25
|
+
SkyTextEditorToolbarComponent,
|
|
26
|
+
SkyTextEditorMenubarComponent], imports: [CommonModule,
|
|
27
|
+
FormsModule,
|
|
28
|
+
ReactiveFormsModule,
|
|
29
|
+
SkyCoreAdapterModule,
|
|
30
|
+
SkyTextEditorResourcesModule,
|
|
31
|
+
SkyI18nModule,
|
|
32
|
+
SkyIconModule,
|
|
33
|
+
SkyIdModule,
|
|
34
|
+
SkyInputBoxModule,
|
|
35
|
+
SkyColorpickerModule,
|
|
36
|
+
SkyCheckboxModule,
|
|
37
|
+
SkyDropdownModule,
|
|
38
|
+
SkyModalModule,
|
|
39
|
+
SkyTabsModule,
|
|
40
|
+
SkyThemeModule,
|
|
41
|
+
SkyToolbarModule], exports: [SkyTextEditorComponent,
|
|
42
|
+
SkyTextEditorUrlModalComponent,
|
|
43
|
+
SkyTextEditorToolbarComponent,
|
|
44
|
+
SkyTextEditorMenubarComponent] });
|
|
45
|
+
SkyTextEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorModule, imports: [[
|
|
46
|
+
CommonModule,
|
|
47
|
+
FormsModule,
|
|
48
|
+
ReactiveFormsModule,
|
|
49
|
+
SkyCoreAdapterModule,
|
|
50
|
+
SkyTextEditorResourcesModule,
|
|
51
|
+
SkyI18nModule,
|
|
52
|
+
SkyIconModule,
|
|
53
|
+
SkyIdModule,
|
|
54
|
+
SkyInputBoxModule,
|
|
55
|
+
SkyColorpickerModule,
|
|
56
|
+
SkyCheckboxModule,
|
|
57
|
+
SkyDropdownModule,
|
|
58
|
+
SkyModalModule,
|
|
59
|
+
SkyTabsModule,
|
|
60
|
+
SkyThemeModule,
|
|
61
|
+
SkyToolbarModule,
|
|
62
|
+
]] });
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorModule, decorators: [{
|
|
64
|
+
type: NgModule,
|
|
65
|
+
args: [{
|
|
66
|
+
imports: [
|
|
67
|
+
CommonModule,
|
|
68
|
+
FormsModule,
|
|
69
|
+
ReactiveFormsModule,
|
|
70
|
+
SkyCoreAdapterModule,
|
|
71
|
+
SkyTextEditorResourcesModule,
|
|
72
|
+
SkyI18nModule,
|
|
73
|
+
SkyIconModule,
|
|
74
|
+
SkyIdModule,
|
|
75
|
+
SkyInputBoxModule,
|
|
76
|
+
SkyColorpickerModule,
|
|
77
|
+
SkyCheckboxModule,
|
|
78
|
+
SkyDropdownModule,
|
|
79
|
+
SkyModalModule,
|
|
80
|
+
SkyTabsModule,
|
|
81
|
+
SkyThemeModule,
|
|
82
|
+
SkyToolbarModule,
|
|
83
|
+
],
|
|
84
|
+
exports: [
|
|
85
|
+
SkyTextEditorComponent,
|
|
86
|
+
SkyTextEditorUrlModalComponent,
|
|
87
|
+
SkyTextEditorToolbarComponent,
|
|
88
|
+
SkyTextEditorMenubarComponent,
|
|
89
|
+
],
|
|
90
|
+
declarations: [
|
|
91
|
+
SkyTextEditorComponent,
|
|
92
|
+
SkyTextEditorUrlModalComponent,
|
|
93
|
+
SkyTextEditorToolbarComponent,
|
|
94
|
+
SkyTextEditorMenubarComponent,
|
|
95
|
+
],
|
|
96
|
+
entryComponents: [SkyTextEditorUrlModalComponent],
|
|
97
|
+
}]
|
|
98
|
+
}] });
|
|
99
|
+
//# sourceMappingURL=text-editor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/text-editor.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AAErG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAExF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAExF,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;;AAmCjE,MAAM,OAAO,mBAAmB;;iHAAnB,mBAAmB;kHAAnB,mBAAmB,iBAP5B,sBAAsB;QACtB,8BAA8B;QAC9B,6BAA6B;QAC7B,6BAA6B,aA3B7B,YAAY;QACZ,WAAW;QACX,mBAAmB;QACnB,oBAAoB;QACpB,4BAA4B;QAC5B,aAAa;QACb,aAAa;QACb,WAAW;QACX,iBAAiB;QACjB,oBAAoB;QACpB,iBAAiB;QACjB,iBAAiB;QACjB,cAAc;QACd,aAAa;QACb,cAAc;QACd,gBAAgB,aAGhB,sBAAsB;QACtB,8BAA8B;QAC9B,6BAA6B;QAC7B,6BAA6B;kHAUpB,mBAAmB,YAhCrB;YACP,YAAY;YACZ,WAAW;YACX,mBAAmB;YACnB,oBAAoB;YACpB,4BAA4B;YAC5B,aAAa;YACb,aAAa;YACb,WAAW;YACX,iBAAiB;YACjB,oBAAoB;YACpB,iBAAiB;YACjB,iBAAiB;YACjB,cAAc;YACd,aAAa;YACb,cAAc;YACd,gBAAgB;SACjB;4FAeU,mBAAmB;kBAjC/B,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,YAAY;wBACZ,WAAW;wBACX,mBAAmB;wBACnB,oBAAoB;wBACpB,4BAA4B;wBAC5B,aAAa;wBACb,aAAa;wBACb,WAAW;wBACX,iBAAiB;wBACjB,oBAAoB;wBACpB,iBAAiB;wBACjB,iBAAiB;wBACjB,cAAc;wBACd,aAAa;wBACb,cAAc;wBACd,gBAAgB;qBACjB;oBACD,OAAO,EAAE;wBACP,sBAAsB;wBACtB,8BAA8B;wBAC9B,6BAA6B;wBAC7B,6BAA6B;qBAC9B;oBACD,YAAY,EAAE;wBACZ,sBAAsB;wBACtB,8BAA8B;wBAC9B,6BAA6B;wBAC7B,6BAA6B;qBAC9B;oBACD,eAAe,EAAE,CAAC,8BAA8B,CAAC;iBAClD","sourcesContent":["import { NgModule } from '@angular/core';\n\nimport { CommonModule } from '@angular/common';\n\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\n\nimport { SkyColorpickerModule } from '@skyux/colorpicker';\n\nimport { SkyCoreAdapterModule, SkyIdModule } from '@skyux/core';\n\nimport { SkyCheckboxModule, SkyInputBoxModule } from '@skyux/forms';\n\nimport { SkyModalModule } from '@skyux/modals';\n\nimport { SkyI18nModule } from '@skyux/i18n';\n\nimport { SkyIconModule } from '@skyux/indicators';\n\nimport { SkyToolbarModule } from '@skyux/layout';\n\nimport { SkyDropdownModule } from '@skyux/popovers';\n\nimport { SkyTabsModule } from '@skyux/tabs';\n\nimport { SkyThemeModule } from '@skyux/theme';\n\nimport { SkyTextEditorResourcesModule } from '../../modules/shared/sky-text-editor-resources.module';\n\nimport { SkyTextEditorMenubarComponent } from './menubar/text-editor-menubar.component';\n\nimport { SkyTextEditorToolbarComponent } from './toolbar/text-editor-toolbar.component';\n\nimport { SkyTextEditorUrlModalComponent } from './url-modal/text-editor-url-modal.component';\n\nimport { SkyTextEditorComponent } from './text-editor.component';\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule,\n SkyCoreAdapterModule,\n SkyTextEditorResourcesModule,\n SkyI18nModule,\n SkyIconModule,\n SkyIdModule,\n SkyInputBoxModule,\n SkyColorpickerModule,\n SkyCheckboxModule,\n SkyDropdownModule,\n SkyModalModule,\n SkyTabsModule,\n SkyThemeModule,\n SkyToolbarModule,\n ],\n exports: [\n SkyTextEditorComponent,\n SkyTextEditorUrlModalComponent,\n SkyTextEditorToolbarComponent,\n SkyTextEditorMenubarComponent,\n ],\n declarations: [\n SkyTextEditorComponent,\n SkyTextEditorUrlModalComponent,\n SkyTextEditorToolbarComponent,\n SkyTextEditorMenubarComponent,\n ],\n entryComponents: [SkyTextEditorUrlModalComponent],\n})\nexport class SkyTextEditorModule {}\n"]}
|