@skyux/text-editor 5.6.2 → 6.0.0-beta.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/documentation.json +2 -2
- package/esm2020/index.mjs +15 -0
- package/esm2020/lib/modules/rich-text-display/rich-text-display.component.mjs +36 -0
- package/esm2020/lib/modules/rich-text-display/rich-text-display.module.mjs +18 -0
- package/esm2020/lib/modules/shared/forms-utility.mjs +10 -0
- package/esm2020/lib/modules/shared/sky-text-editor-resources.module.mjs +106 -0
- package/esm2020/lib/modules/text-editor/defaults/font-list-defaults.mjs +42 -0
- package/esm2020/lib/modules/text-editor/defaults/font-size-list-defaults.mjs +7 -0
- package/esm2020/lib/modules/text-editor/defaults/menu-defaults.mjs +5 -0
- package/esm2020/lib/modules/text-editor/defaults/style-state-defaults.mjs +15 -0
- package/esm2020/lib/modules/text-editor/defaults/toolbar-action-defaults.mjs +12 -0
- package/esm2020/lib/modules/text-editor/menubar/text-editor-menubar.component.mjs +191 -0
- package/esm2020/lib/modules/text-editor/services/text-editor-adapter.service.mjs +477 -0
- package/esm2020/lib/modules/text-editor/services/text-editor-selection.service.mjs +80 -0
- package/esm2020/lib/modules/text-editor/services/text-editor.service.mjs +61 -0
- package/esm2020/lib/modules/text-editor/services/text-sanitization.service.mjs +38 -0
- package/esm2020/lib/modules/text-editor/text-editor.component.mjs +322 -0
- package/esm2020/lib/modules/text-editor/text-editor.module.mjs +98 -0
- package/esm2020/lib/modules/text-editor/toolbar/text-editor-toolbar.component.mjs +179 -0
- package/esm2020/lib/modules/text-editor/types/editor-command.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/editor-setting.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/font-state.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/menu-type.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/style-state.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/text-editor-merge-field.mjs +2 -0
- package/esm2020/lib/modules/text-editor/types/toolbar-action-type.mjs +2 -0
- package/esm2020/lib/modules/text-editor/url-modal/text-editor-url-modal-context.mjs +6 -0
- package/esm2020/lib/modules/text-editor/url-modal/text-editor-url-modal-result.mjs +2 -0
- package/esm2020/lib/modules/text-editor/url-modal/text-editor-url-modal.component.mjs +117 -0
- package/esm2020/lib/modules/text-editor/url-modal/text-editor-url-target.mjs +9 -0
- package/esm2020/skyux-text-editor.mjs +5 -0
- package/fesm2015/{skyux-text-editor.js → skyux-text-editor.mjs} +46 -70
- package/fesm2015/skyux-text-editor.mjs.map +1 -0
- package/fesm2020/skyux-text-editor.mjs +1743 -0
- package/fesm2020/skyux-text-editor.mjs.map +1 -0
- package/lib/modules/shared/sky-text-editor-resources.module.d.ts +1 -1
- package/package.json +34 -21
- package/bundles/skyux-text-editor.umd.js +0 -2195
- package/esm2015/index.js +0 -15
- package/esm2015/index.js.map +0 -1
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js +0 -39
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js.map +0 -1
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js +0 -18
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js.map +0 -1
- package/esm2015/lib/modules/shared/forms-utility.js +0 -10
- package/esm2015/lib/modules/shared/forms-utility.js.map +0 -1
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js +0 -106
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js.map +0 -1
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js +0 -42
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js.map +0 -1
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js +0 -7
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js.map +0 -1
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js +0 -5
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js.map +0 -1
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js +0 -15
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js.map +0 -1
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js +0 -12
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js.map +0 -1
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js +0 -196
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js.map +0 -1
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js +0 -474
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js.map +0 -1
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js +0 -80
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js.map +0 -1
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js +0 -61
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js.map +0 -1
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js +0 -38
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js.map +0 -1
- package/esm2015/lib/modules/text-editor/text-editor.component.js +0 -322
- package/esm2015/lib/modules/text-editor/text-editor.component.js.map +0 -1
- package/esm2015/lib/modules/text-editor/text-editor.module.js +0 -99
- package/esm2015/lib/modules/text-editor/text-editor.module.js.map +0 -1
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js +0 -175
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/editor-command.js +0 -2
- package/esm2015/lib/modules/text-editor/types/editor-command.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/editor-setting.js +0 -2
- package/esm2015/lib/modules/text-editor/types/editor-setting.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/font-state.js +0 -2
- package/esm2015/lib/modules/text-editor/types/font-state.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/menu-type.js +0 -2
- package/esm2015/lib/modules/text-editor/types/menu-type.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/style-state.js +0 -2
- package/esm2015/lib/modules/text-editor/types/style-state.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js +0 -2
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js.map +0 -1
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js +0 -2
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js.map +0 -1
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js +0 -6
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js.map +0 -1
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js +0 -2
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js.map +0 -1
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js +0 -121
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js.map +0 -1
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js +0 -9
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js.map +0 -1
- package/esm2015/skyux-text-editor.js +0 -5
- package/esm2015/skyux-text-editor.js.map +0 -1
- package/fesm2015/skyux-text-editor.js.map +0 -1
|
@@ -0,0 +1,1743 @@
|
|
|
1
|
+
import * as i5 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Injectable, Component, Input, NgModule, ChangeDetectionStrategy, ViewEncapsulation, ViewChild } from '@angular/core';
|
|
5
|
+
import * as i1 from '@angular/platform-browser';
|
|
6
|
+
import createDOMPurify from 'dompurify';
|
|
7
|
+
import * as i5$1 from '@angular/forms';
|
|
8
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import * as i6$1 from '@skyux/colorpicker';
|
|
10
|
+
import { SkyColorpickerMessageType, SkyColorpickerModule } from '@skyux/colorpicker';
|
|
11
|
+
import * as i3 from '@skyux/core';
|
|
12
|
+
import { SkyCoreAdapterModule, SkyIdModule } from '@skyux/core';
|
|
13
|
+
import * as i4$1 from '@skyux/forms';
|
|
14
|
+
import { SkyInputBoxModule, SkyCheckboxModule } from '@skyux/forms';
|
|
15
|
+
import * as i2 from '@skyux/i18n';
|
|
16
|
+
import { getLibStringForLocale, SkyI18nModule, SKY_LIB_RESOURCES_PROVIDERS } from '@skyux/i18n';
|
|
17
|
+
import * as i7 from '@skyux/indicators';
|
|
18
|
+
import { SkyIconModule } from '@skyux/indicators';
|
|
19
|
+
import * as i3$1 from '@skyux/layout';
|
|
20
|
+
import { SkyToolbarModule } from '@skyux/layout';
|
|
21
|
+
import * as i1$1 from '@skyux/modals';
|
|
22
|
+
import { SkyModalModule } from '@skyux/modals';
|
|
23
|
+
import * as i4 from '@skyux/popovers';
|
|
24
|
+
import { SkyDropdownMessageType, SkyDropdownModule } from '@skyux/popovers';
|
|
25
|
+
import * as i3$2 from '@skyux/tabs';
|
|
26
|
+
import { SkyTabsModule } from '@skyux/tabs';
|
|
27
|
+
import * as i6 from '@skyux/theme';
|
|
28
|
+
import { SkyThemeModule } from '@skyux/theme';
|
|
29
|
+
import { Subject, forkJoin } from 'rxjs';
|
|
30
|
+
import { takeUntil, take } from 'rxjs/operators';
|
|
31
|
+
import { SkyValidation } from '@skyux/validation';
|
|
32
|
+
|
|
33
|
+
const domPurify = createDOMPurify(window);
|
|
34
|
+
domPurify.addHook('afterSanitizeAttributes', (node) => {
|
|
35
|
+
// Set all elements owning target to target=_blank
|
|
36
|
+
// so we only allow the target attribute with that value.
|
|
37
|
+
if (node.getAttribute('target')) {
|
|
38
|
+
node.setAttribute('target', '_blank');
|
|
39
|
+
node.setAttribute('rel', 'noopener noreferrer');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* The `SkyTextSanitizationService` user the `DOMPurify` library to sanitize strings for use
|
|
44
|
+
* in the DOM. `DOMPurify` allows more customization than Angular's internal `DomSanitizer` so we
|
|
45
|
+
* can preserve `<style>` tags and allow `target` attributes for new tab links.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
class SkyTextSanitizationService {
|
|
49
|
+
constructor() {
|
|
50
|
+
this.allowedAttributes = ['target'];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns a sanitized string, allowing target attribute for new tab links.
|
|
54
|
+
*/
|
|
55
|
+
sanitize(htmlString) {
|
|
56
|
+
return domPurify.sanitize(htmlString, { ADD_ATTR: this.allowedAttributes });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
SkyTextSanitizationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextSanitizationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
60
|
+
SkyTextSanitizationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextSanitizationService, providedIn: 'root' });
|
|
61
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextSanitizationService, decorators: [{
|
|
62
|
+
type: Injectable,
|
|
63
|
+
args: [{
|
|
64
|
+
providedIn: 'root',
|
|
65
|
+
}]
|
|
66
|
+
}] });
|
|
67
|
+
|
|
68
|
+
class SkyRichTextDisplayComponent {
|
|
69
|
+
constructor(sanitizer, sanitizationService) {
|
|
70
|
+
this.sanitizer = sanitizer;
|
|
71
|
+
this.sanitizationService = sanitizationService;
|
|
72
|
+
this.sanitizedText = '';
|
|
73
|
+
this._richText = '';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Specifies the rich text to display.
|
|
77
|
+
*/
|
|
78
|
+
set richText(value) {
|
|
79
|
+
const cleaned = this.sanitizationService.sanitize(value);
|
|
80
|
+
/* istanbul ignore else */
|
|
81
|
+
if (cleaned !== this._richText) {
|
|
82
|
+
this._richText = cleaned;
|
|
83
|
+
// Text has already been sanitized with DOMPurifier.
|
|
84
|
+
// Tell Angular to bypass its own internal sanitization.
|
|
85
|
+
this.sanitizedText = this.sanitizer.bypassSecurityTrustHtml(cleaned);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
SkyRichTextDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayComponent, deps: [{ token: i1.DomSanitizer }, { token: SkyTextSanitizationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
90
|
+
SkyRichTextDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyRichTextDisplayComponent, selector: "sky-rich-text-display", inputs: { richText: "richText" }, ngImport: i0, template: "<span class=\"sky-rich-text-display-text\" [innerHTML]=\"sanitizedText\"> </span>\n" });
|
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayComponent, decorators: [{
|
|
92
|
+
type: Component,
|
|
93
|
+
args: [{ selector: 'sky-rich-text-display', template: "<span class=\"sky-rich-text-display-text\" [innerHTML]=\"sanitizedText\"> </span>\n" }]
|
|
94
|
+
}], ctorParameters: function () { return [{ type: i1.DomSanitizer }, { type: SkyTextSanitizationService }]; }, propDecorators: { richText: [{
|
|
95
|
+
type: Input
|
|
96
|
+
}] } });
|
|
97
|
+
|
|
98
|
+
class SkyRichTextDisplayModule {
|
|
99
|
+
}
|
|
100
|
+
SkyRichTextDisplayModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
101
|
+
SkyRichTextDisplayModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayModule, declarations: [SkyRichTextDisplayComponent], imports: [CommonModule], exports: [SkyRichTextDisplayComponent] });
|
|
102
|
+
SkyRichTextDisplayModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayModule, imports: [[CommonModule]] });
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyRichTextDisplayModule, decorators: [{
|
|
104
|
+
type: NgModule,
|
|
105
|
+
args: [{
|
|
106
|
+
imports: [CommonModule],
|
|
107
|
+
exports: [SkyRichTextDisplayComponent],
|
|
108
|
+
declarations: [SkyRichTextDisplayComponent],
|
|
109
|
+
}]
|
|
110
|
+
}] });
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* NOTICE: DO NOT MODIFY THIS FILE!
|
|
114
|
+
* The contents of this file were automatically generated by
|
|
115
|
+
* the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-text-editor' schematic.
|
|
116
|
+
* To update this file, simply rerun the command.
|
|
117
|
+
*/
|
|
118
|
+
const RESOURCES = {
|
|
119
|
+
'EN-US': {
|
|
120
|
+
skyux_text_editor_format_menu_action_bold_label: { message: 'Bold' },
|
|
121
|
+
skyux_text_editor_format_menu_action_bold_key_shortcut: {
|
|
122
|
+
message: 'Ctrl+B',
|
|
123
|
+
},
|
|
124
|
+
skyux_text_editor_format_menu_action_italic_label: { message: 'Italic' },
|
|
125
|
+
skyux_text_editor_format_menu_action_italic_key_shortcut: {
|
|
126
|
+
message: 'Ctrl+I',
|
|
127
|
+
},
|
|
128
|
+
skyux_text_editor_format_menu_action_underline_label: {
|
|
129
|
+
message: 'Underline',
|
|
130
|
+
},
|
|
131
|
+
skyux_text_editor_format_menu_action_underline_key_shortcut: {
|
|
132
|
+
message: 'Ctrl+U',
|
|
133
|
+
},
|
|
134
|
+
skyux_text_editor_format_menu_action_strikethrough_label: {
|
|
135
|
+
message: 'Strikethrough',
|
|
136
|
+
},
|
|
137
|
+
skyux_text_editor_format_menu_action_clear_formatting_label: {
|
|
138
|
+
message: 'Clear formatting',
|
|
139
|
+
},
|
|
140
|
+
skyux_text_editor_edit_menu_action_undo_label: { message: 'Undo' },
|
|
141
|
+
skyux_text_editor_edit_menu_action_undo_key_shortcut: { message: 'Ctrl+Z' },
|
|
142
|
+
skyux_text_editor_edit_menu_action_redo_label: { message: 'Redo' },
|
|
143
|
+
skyux_text_editor_edit_menu_action_redo_key_shortcut: { message: 'Ctrl+Y' },
|
|
144
|
+
skyux_text_editor_edit_menu_action_cut_label: { message: 'Cut' },
|
|
145
|
+
skyux_text_editor_edit_menu_action_cut_key_shortcut: { message: 'Ctrl+X' },
|
|
146
|
+
skyux_text_editor_edit_menu_action_copy_label: { message: 'Copy' },
|
|
147
|
+
skyux_text_editor_edit_menu_action_copy_key_shortcut: { message: 'Ctrl+C' },
|
|
148
|
+
skyux_text_editor_edit_menu_action_paste_label: { message: 'Paste' },
|
|
149
|
+
skyux_text_editor_edit_menu_action_paste_key_shortcut: {
|
|
150
|
+
message: 'Ctrl+V',
|
|
151
|
+
},
|
|
152
|
+
skyux_text_editor_edit_menu_action_select_all_label: {
|
|
153
|
+
message: 'Select all',
|
|
154
|
+
},
|
|
155
|
+
skyux_text_editor_edit_menu_action_select_all_key_shortcut: {
|
|
156
|
+
message: 'Ctrl+A',
|
|
157
|
+
},
|
|
158
|
+
skyux_text_editor_menubar_dropdown_button_edit_label: { message: 'Edit' },
|
|
159
|
+
skyux_text_editor_menubar_dropdown_button_format_label: {
|
|
160
|
+
message: 'Format',
|
|
161
|
+
},
|
|
162
|
+
skyux_text_editor_menubar_dropdown_button_insert_label: {
|
|
163
|
+
message: 'Insert merge field',
|
|
164
|
+
},
|
|
165
|
+
skyux_text_editor_url_modal_header_label: { message: 'Create link' },
|
|
166
|
+
skyux_text_editor_url_modal_url_label: {
|
|
167
|
+
message: 'Enter a URL to link to:',
|
|
168
|
+
},
|
|
169
|
+
skyux_text_editor_url_modal_open_label: {
|
|
170
|
+
message: 'Where should it open?',
|
|
171
|
+
},
|
|
172
|
+
skyux_text_editor_url_modal_current_option_label: {
|
|
173
|
+
message: 'Current window',
|
|
174
|
+
},
|
|
175
|
+
skyux_text_editor_url_modal_new_option_label: { message: 'New window' },
|
|
176
|
+
skyux_text_editor_url_modal_email_label: { message: 'Email address' },
|
|
177
|
+
skyux_text_editor_url_modal_subject_label: { message: 'Subject line' },
|
|
178
|
+
skyux_text_editor_url_modal_save_button_label: { message: 'Save' },
|
|
179
|
+
skyux_text_editor_url_modal_cancel_button_label: { message: 'Cancel' },
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
class SkyTextEditorResourcesProvider {
|
|
183
|
+
getString(localeInfo, name) {
|
|
184
|
+
return getLibStringForLocale(RESOURCES, localeInfo.locale, name);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Import into any component library module that needs to use resource strings.
|
|
189
|
+
*/
|
|
190
|
+
class SkyTextEditorResourcesModule {
|
|
191
|
+
}
|
|
192
|
+
SkyTextEditorResourcesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorResourcesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
193
|
+
SkyTextEditorResourcesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorResourcesModule, exports: [SkyI18nModule] });
|
|
194
|
+
SkyTextEditorResourcesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorResourcesModule, providers: [
|
|
195
|
+
{
|
|
196
|
+
provide: SKY_LIB_RESOURCES_PROVIDERS,
|
|
197
|
+
useClass: SkyTextEditorResourcesProvider,
|
|
198
|
+
multi: true,
|
|
199
|
+
},
|
|
200
|
+
], imports: [SkyI18nModule] });
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorResourcesModule, decorators: [{
|
|
202
|
+
type: NgModule,
|
|
203
|
+
args: [{
|
|
204
|
+
exports: [SkyI18nModule],
|
|
205
|
+
providers: [
|
|
206
|
+
{
|
|
207
|
+
provide: SKY_LIB_RESOURCES_PROVIDERS,
|
|
208
|
+
useClass: SkyTextEditorResourcesProvider,
|
|
209
|
+
multi: true,
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}]
|
|
213
|
+
}] });
|
|
214
|
+
|
|
215
|
+
// Need to add the following to classes which contain static methods.
|
|
216
|
+
// See: https://github.com/ng-packagr/ng-packagr/issues/641
|
|
217
|
+
// @dynamic
|
|
218
|
+
class SkyFormsUtility {
|
|
219
|
+
/** Coerces a data-bound value (typically a string) to a boolean. */
|
|
220
|
+
static coerceBooleanProperty(value) {
|
|
221
|
+
return value !== undefined && `${value}` !== 'false';
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
const FONT_LIST_DEFAULTS = [
|
|
229
|
+
{
|
|
230
|
+
name: 'Blackbaud Sans',
|
|
231
|
+
value: '"Blackbaud Sans", Arial, sans-serif',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: 'Arial',
|
|
235
|
+
value: 'Arial',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'Arial Black',
|
|
239
|
+
value: '"Arial Black"',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'Courier New',
|
|
243
|
+
value: '"Courier New"',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'Georgia',
|
|
247
|
+
value: 'Georgia, serif',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'Tahoma',
|
|
251
|
+
value: 'Tahoma, Geneva, sans-serif',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'Times New Roman',
|
|
255
|
+
value: '"Times New Roman"',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'Trebuchet MS',
|
|
259
|
+
value: '"Trebuchet MS", sans-serif',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'Verdana',
|
|
263
|
+
value: 'Verdana, Geneva, sans-serif',
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
const STYLE_STATE_DEFAULTS = {
|
|
271
|
+
backColor: 'rgba(0, 0, 0, 0)',
|
|
272
|
+
fontColor: '#000',
|
|
273
|
+
fontSize: 14,
|
|
274
|
+
font: FONT_LIST_DEFAULTS[0].value,
|
|
275
|
+
boldState: false,
|
|
276
|
+
italicState: false,
|
|
277
|
+
underlineState: false,
|
|
278
|
+
linkState: false,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @internal
|
|
283
|
+
*/
|
|
284
|
+
var UrlTarget;
|
|
285
|
+
(function (UrlTarget) {
|
|
286
|
+
UrlTarget[UrlTarget["None"] = 0] = "None";
|
|
287
|
+
UrlTarget[UrlTarget["NewWindow"] = 1] = "NewWindow";
|
|
288
|
+
})(UrlTarget || (UrlTarget = {}));
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
class SkyTextEditorSelectionService {
|
|
294
|
+
isElementSelected(documentEl, element) {
|
|
295
|
+
const selectedNode = this.getCurrentSelection(documentEl)
|
|
296
|
+
.anchorNode;
|
|
297
|
+
/* istanbul ignore next */
|
|
298
|
+
return (selectedNode &&
|
|
299
|
+
(element.contains(selectedNode) ||
|
|
300
|
+
(selectedNode.parentNode && element.contains(selectedNode.parentNode))));
|
|
301
|
+
}
|
|
302
|
+
getCurrentSelection(documentEl) {
|
|
303
|
+
return documentEl.getSelection();
|
|
304
|
+
}
|
|
305
|
+
getCurrentSelectionParentElement(documentEl) {
|
|
306
|
+
const selection = this.getCurrentSelection(documentEl);
|
|
307
|
+
let selectedEl;
|
|
308
|
+
/* istanbul ignore else */
|
|
309
|
+
if (selection &&
|
|
310
|
+
selection.getRangeAt &&
|
|
311
|
+
selection.getRangeAt(0).commonAncestorContainer) {
|
|
312
|
+
selectedEl = selection.getRangeAt(0).commonAncestorContainer;
|
|
313
|
+
selectedEl =
|
|
314
|
+
selectedEl.nodeType !== 1 ? selectedEl.parentElement : selectedEl;
|
|
315
|
+
}
|
|
316
|
+
else if (selection && selection.type !== 'Control') {
|
|
317
|
+
selectedEl = selection.createRange().parentElement();
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
return selectedEl;
|
|
323
|
+
}
|
|
324
|
+
getCurrentSelectionRange(documentEl, windowEl) {
|
|
325
|
+
/* istanbul ignore else */
|
|
326
|
+
if (windowEl.getSelection) {
|
|
327
|
+
const sel = windowEl.getSelection();
|
|
328
|
+
/* istanbul ignore else */
|
|
329
|
+
if (sel.getRangeAt && sel.rangeCount) {
|
|
330
|
+
return sel.getRangeAt(0);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else if (documentEl.getSelection() &&
|
|
334
|
+
documentEl.getSelection().getRangeAt) {
|
|
335
|
+
return documentEl.getSelection().getRangeAt(0);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
selectElement(documentEl, windowEl, element) {
|
|
339
|
+
/* istanbul ignore else */
|
|
340
|
+
if (element) {
|
|
341
|
+
/* istanbul ignore else */
|
|
342
|
+
if (windowEl.getSelection) {
|
|
343
|
+
const sel = windowEl.getSelection();
|
|
344
|
+
sel.removeAllRanges();
|
|
345
|
+
const range = documentEl.createRange();
|
|
346
|
+
range.selectNodeContents(element);
|
|
347
|
+
sel.addRange(range);
|
|
348
|
+
}
|
|
349
|
+
else if (documentEl.getSelection) {
|
|
350
|
+
const sel = documentEl.getSelection();
|
|
351
|
+
sel.removeAllRanges();
|
|
352
|
+
const range = documentEl.createRange();
|
|
353
|
+
range.selectNodeContents(element);
|
|
354
|
+
sel.addRange(range);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
SkyTextEditorSelectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorSelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
360
|
+
SkyTextEditorSelectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorSelectionService, providedIn: 'root' });
|
|
361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorSelectionService, decorators: [{
|
|
362
|
+
type: Injectable,
|
|
363
|
+
args: [{
|
|
364
|
+
providedIn: 'root',
|
|
365
|
+
}]
|
|
366
|
+
}] });
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @internal
|
|
370
|
+
*/
|
|
371
|
+
class SkyTextEditorService {
|
|
372
|
+
constructor() {
|
|
373
|
+
/**
|
|
374
|
+
* A dictionary representing all active text editors and their settings.
|
|
375
|
+
*/
|
|
376
|
+
this.editors = {};
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Returns the blur observable from the editor with the corresponding id.
|
|
380
|
+
*/
|
|
381
|
+
blurListener(id) {
|
|
382
|
+
return this.editors[id].blurObservable;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Returns the click observable from the editor with the corresponding id.
|
|
386
|
+
*/
|
|
387
|
+
clickListener(id) {
|
|
388
|
+
return this.editors[id].clickObservable;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Returns the command change observable from the editor with the corresponding id.
|
|
392
|
+
*/
|
|
393
|
+
commandChangeListener(id) {
|
|
394
|
+
return this.editors[id].commandChangeObservable;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Returns the input change observable from the editor with the corresponding id.
|
|
398
|
+
*/
|
|
399
|
+
inputListener(id) {
|
|
400
|
+
return this.editors[id].inputObservable;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Removes editor from the `editors` index by id.
|
|
404
|
+
*/
|
|
405
|
+
removeEditor(id) {
|
|
406
|
+
/* istanbul ignore else */
|
|
407
|
+
if (id in this.editors) {
|
|
408
|
+
delete this.editors[id];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Returns the selection change observable from the editor with the corresponding id.
|
|
413
|
+
*/
|
|
414
|
+
selectionChangeListener(id) {
|
|
415
|
+
return this.editors[id].selectionChangeObservable;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
SkyTextEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
419
|
+
SkyTextEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorService, providedIn: 'root' });
|
|
420
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorService, decorators: [{
|
|
421
|
+
type: Injectable,
|
|
422
|
+
args: [{
|
|
423
|
+
providedIn: 'root',
|
|
424
|
+
}]
|
|
425
|
+
}] });
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @internal
|
|
429
|
+
*/
|
|
430
|
+
class SkyTextEditorAdapterService {
|
|
431
|
+
constructor(selectionService, textEditorService, windowService) {
|
|
432
|
+
this.selectionService = selectionService;
|
|
433
|
+
this.textEditorService = textEditorService;
|
|
434
|
+
this.windowService = windowService;
|
|
435
|
+
}
|
|
436
|
+
get editors() {
|
|
437
|
+
return this.textEditorService.editors;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a text editor inside the supplied iframe element.
|
|
441
|
+
*/
|
|
442
|
+
addEditor(id, iframeElement, styleState, placeholder) {
|
|
443
|
+
/* istanbul ignore else */
|
|
444
|
+
if (!(id in this.editors)) {
|
|
445
|
+
this.editors[id] = this.createObservers(id, iframeElement);
|
|
446
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
447
|
+
const styleEl = documentEl.createElement('style');
|
|
448
|
+
styleEl.innerHTML = `.editor:empty:before {
|
|
449
|
+
content: attr(data-placeholder);
|
|
450
|
+
font-family: "Blackbaud Sans", Arial, sans-serif;
|
|
451
|
+
color: #686c73;
|
|
452
|
+
font-weight: 400;
|
|
453
|
+
font-size: 15px;
|
|
454
|
+
font-style: italic;
|
|
455
|
+
}`;
|
|
456
|
+
documentEl.head.appendChild(styleEl);
|
|
457
|
+
const style = {
|
|
458
|
+
...STYLE_STATE_DEFAULTS,
|
|
459
|
+
...styleState,
|
|
460
|
+
};
|
|
461
|
+
const bodyStyle = `background-color: ${style.backColor};
|
|
462
|
+
color: ${style.fontColor};
|
|
463
|
+
font-family: ${style.font};
|
|
464
|
+
font-size: ${style.fontSize}px`;
|
|
465
|
+
documentEl.querySelector('html').setAttribute('lang', 'en');
|
|
466
|
+
documentEl.body.setAttribute('contenteditable', 'true');
|
|
467
|
+
documentEl.body.setAttribute('id', id);
|
|
468
|
+
documentEl.body.setAttribute('role', 'main');
|
|
469
|
+
documentEl.body.setAttribute('class', 'editor');
|
|
470
|
+
documentEl.body.setAttribute('style', bodyStyle);
|
|
471
|
+
documentEl.body.setAttribute('data-placeholder', placeholder || '');
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
disableEditor(id, focusableChildren, textEditorNativeElement) {
|
|
475
|
+
this.setEditorDisabled(id, focusableChildren, textEditorNativeElement, true);
|
|
476
|
+
}
|
|
477
|
+
enableEditor(id, focusableChildren, textEditorNativeElement) {
|
|
478
|
+
this.setEditorDisabled(id, focusableChildren, textEditorNativeElement, false);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Executes a command on the text editor with the corresponding id.
|
|
482
|
+
*/
|
|
483
|
+
execCommand(id, editorCommand) {
|
|
484
|
+
/* istanbul ignore else */
|
|
485
|
+
if (id in this.editors) {
|
|
486
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
487
|
+
/* istanbul ignore else */
|
|
488
|
+
if (this.editorSelected(id)) {
|
|
489
|
+
const commandIsSupportedAndEnabled = documentEl.execCommand(editorCommand.command, false, editorCommand.value);
|
|
490
|
+
// IE11 doesn't support insertHTML
|
|
491
|
+
/* istanbul ignore next */
|
|
492
|
+
if (editorCommand.command.toLowerCase() === 'inserthtml' &&
|
|
493
|
+
!commandIsSupportedAndEnabled) {
|
|
494
|
+
this.insertHtmlInIE11(id, editorCommand.value);
|
|
495
|
+
}
|
|
496
|
+
this.focusEditor(id);
|
|
497
|
+
this.editors[id].commandChangeObservable.next();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
getCurrentSelection(id) {
|
|
502
|
+
return this.selectionService.getCurrentSelection(this.getIframeDocumentEl(id));
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Returns a data URI using the provided text string.
|
|
506
|
+
* Used to display a merge field inside a string of text.
|
|
507
|
+
*/
|
|
508
|
+
getMergeFieldDataURI(text) {
|
|
509
|
+
const documentEl = this.windowService.nativeWindow.document;
|
|
510
|
+
let textToUse = text;
|
|
511
|
+
if (text.length > 18) {
|
|
512
|
+
textToUse = text.substr(0, 15) + '...';
|
|
513
|
+
}
|
|
514
|
+
const canvasElement = documentEl.createElement('canvas');
|
|
515
|
+
canvasElement.setAttribute('height', '20');
|
|
516
|
+
canvasElement.setAttribute('width', '100');
|
|
517
|
+
canvasElement.style.backgroundColor = 'tan';
|
|
518
|
+
canvasElement.style.border = '1px solid #000000';
|
|
519
|
+
canvasElement.style.borderRadius = '5px';
|
|
520
|
+
const context = canvasElement.getContext('2d');
|
|
521
|
+
context.font = '12px Arial';
|
|
522
|
+
context.textAlign = 'center';
|
|
523
|
+
context.fillText(textToUse, 50, 15);
|
|
524
|
+
context.globalCompositeOperation = 'destination-over';
|
|
525
|
+
context.fillStyle = '#00FFFF';
|
|
526
|
+
context.fillRect(0, 0, 100, 20);
|
|
527
|
+
context.globalCompositeOperation = 'source-over';
|
|
528
|
+
context.lineWidth = 2;
|
|
529
|
+
context.strokeStyle = '#FF0000';
|
|
530
|
+
context.strokeRect(0, 0, 100, 20);
|
|
531
|
+
const result = canvasElement.toDataURL('image/png', 1.0);
|
|
532
|
+
return result;
|
|
533
|
+
}
|
|
534
|
+
getStyleState(id) {
|
|
535
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
536
|
+
/* istanbul ignore else */
|
|
537
|
+
if (this.editorSelected(id)) {
|
|
538
|
+
return {
|
|
539
|
+
backColor: this.getColor(documentEl, 'BackColor'),
|
|
540
|
+
fontColor: this.getColor(documentEl, 'ForeColor'),
|
|
541
|
+
fontSize: parseInt(this.getFontSize(id), undefined),
|
|
542
|
+
font: documentEl.queryCommandValue('fontname'),
|
|
543
|
+
boldState: documentEl.queryCommandState('Bold'),
|
|
544
|
+
italicState: documentEl.queryCommandState('Italic'),
|
|
545
|
+
underlineState: documentEl.queryCommandState('Underline'),
|
|
546
|
+
linkState: this.hasLink(id),
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
/* istanbul ignore next */
|
|
550
|
+
return {};
|
|
551
|
+
}
|
|
552
|
+
getEditorInnerHtml(id) {
|
|
553
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
554
|
+
if (documentEl) {
|
|
555
|
+
return this.replaceHtmlCodes(documentEl.body.innerHTML);
|
|
556
|
+
}
|
|
557
|
+
return '';
|
|
558
|
+
}
|
|
559
|
+
setEditorInnerHtml(id, value) {
|
|
560
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
561
|
+
const editorContent = documentEl.body;
|
|
562
|
+
/* istanbul ignore else */
|
|
563
|
+
if (editorContent.innerHTML !== value) {
|
|
564
|
+
editorContent.innerHTML = value;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
focusEditor(id) {
|
|
568
|
+
/* istanbul ignore else */
|
|
569
|
+
if (id in this.editors) {
|
|
570
|
+
const windowEl = this.getContentWindowEl(id);
|
|
571
|
+
const iframeDocumentEl = this.getIframeDocumentEl(id);
|
|
572
|
+
const currentSelection = this.selectionService.getCurrentSelectionRange(iframeDocumentEl, windowEl);
|
|
573
|
+
const cursorIsNotActiveAndHasReset = currentSelection &&
|
|
574
|
+
currentSelection.startOffset === 0 &&
|
|
575
|
+
currentSelection.endOffset === 0;
|
|
576
|
+
if (!this.editorSelected(id) || cursorIsNotActiveAndHasReset) {
|
|
577
|
+
// focus the end of the editor
|
|
578
|
+
const documentEl = this.windowService.nativeWindow.document;
|
|
579
|
+
const editor = iframeDocumentEl.body;
|
|
580
|
+
const range = documentEl.createRange();
|
|
581
|
+
this.editors[id].iframeElementRef.focus();
|
|
582
|
+
editor.focus();
|
|
583
|
+
/* istanbul ignore else */
|
|
584
|
+
if (windowEl.getSelection && documentEl.createRange) {
|
|
585
|
+
range.selectNodeContents(editor);
|
|
586
|
+
range.collapse(false);
|
|
587
|
+
const sel = windowEl.getSelection();
|
|
588
|
+
sel.removeAllRanges();
|
|
589
|
+
sel.addRange(range);
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
// IE only
|
|
593
|
+
const textRange = editor.createTextRange();
|
|
594
|
+
textRange.moveToElementText(editor);
|
|
595
|
+
textRange.collapse(false);
|
|
596
|
+
textRange.select();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
// Cursor may not be active, restore it
|
|
601
|
+
this.editors[id].iframeElementRef.focus();
|
|
602
|
+
iframeDocumentEl.body.focus();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
getLink(editorId) {
|
|
607
|
+
let link = undefined;
|
|
608
|
+
const anchorEl = this.getSelectedAnchorTag(editorId);
|
|
609
|
+
if (anchorEl && anchorEl.href) {
|
|
610
|
+
link = {
|
|
611
|
+
target: anchorEl.getAttribute('target') === '_blank'
|
|
612
|
+
? UrlTarget.NewWindow
|
|
613
|
+
: UrlTarget.None,
|
|
614
|
+
url: anchorEl.href,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
return link;
|
|
618
|
+
}
|
|
619
|
+
getSelectedAnchorTag(editorId) {
|
|
620
|
+
const selectedEl = this.getCurrentSelectionParentElement(editorId);
|
|
621
|
+
return this.getParent(selectedEl, 'a');
|
|
622
|
+
}
|
|
623
|
+
saveSelection(id) {
|
|
624
|
+
return this.selectionService.getCurrentSelectionRange(this.getIframeDocumentEl(id), this.getContentWindowEl(id));
|
|
625
|
+
}
|
|
626
|
+
selectElement(id, element) {
|
|
627
|
+
this.selectionService.selectElement(this.getIframeDocumentEl(id), this.getContentWindowEl(id), element);
|
|
628
|
+
}
|
|
629
|
+
setPlaceholder(id, placeholder) {
|
|
630
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
631
|
+
documentEl.body.setAttribute('data-placeholder', placeholder || '');
|
|
632
|
+
}
|
|
633
|
+
setFontSize(id, fontSize) {
|
|
634
|
+
const doc = this.getIframeDocumentEl(id);
|
|
635
|
+
this.execCommand(id, { command: 'fontSize', value: 1 });
|
|
636
|
+
const fontElements = Array.from(doc.querySelectorAll('font[size="1"]'));
|
|
637
|
+
for (const element of fontElements) {
|
|
638
|
+
element.removeAttribute('size');
|
|
639
|
+
element.style.fontSize = fontSize + 'px';
|
|
640
|
+
}
|
|
641
|
+
this.cleanUpBlankStyleTags(doc);
|
|
642
|
+
this.focusEditor(id);
|
|
643
|
+
this.editors[id].commandChangeObservable.next();
|
|
644
|
+
}
|
|
645
|
+
removeObservers(setting) {
|
|
646
|
+
/* istanbul ignore next */
|
|
647
|
+
const documentEl = setting.iframeElementRef.contentWindow
|
|
648
|
+
? setting.iframeElementRef.contentWindow.document
|
|
649
|
+
: setting.iframeElementRef.contentDocument;
|
|
650
|
+
setting.selectionChangeObservable.complete();
|
|
651
|
+
setting.clickObservable.complete();
|
|
652
|
+
setting.commandChangeObservable.complete();
|
|
653
|
+
documentEl.removeEventListener('selectionchange', setting.selectionListener);
|
|
654
|
+
documentEl.removeEventListener('input', setting.selectionListener);
|
|
655
|
+
documentEl.removeEventListener('mousedown', setting.clickListener);
|
|
656
|
+
documentEl.body.removeEventListener('paste', setting.pasteListener);
|
|
657
|
+
}
|
|
658
|
+
getContentWindowEl(id) {
|
|
659
|
+
return this.editors[id].iframeElementRef.contentWindow;
|
|
660
|
+
}
|
|
661
|
+
getChildSelectedAnchorTags(editorId) {
|
|
662
|
+
const selectedRange = this.getCurrentSelection(editorId).getRangeAt(0);
|
|
663
|
+
if (selectedRange.toString().length <= 0) {
|
|
664
|
+
return [];
|
|
665
|
+
}
|
|
666
|
+
const parentElement = this.getCurrentSelectionParentElement(editorId);
|
|
667
|
+
let childElements = [];
|
|
668
|
+
/* istanbul ignore else */
|
|
669
|
+
if (parentElement) {
|
|
670
|
+
childElements = Array.from(parentElement.querySelectorAll('a'));
|
|
671
|
+
}
|
|
672
|
+
/* istanbul ignore next */
|
|
673
|
+
return childElements.filter((element) => {
|
|
674
|
+
// IE specific
|
|
675
|
+
if (!selectedRange.intersectsNode) {
|
|
676
|
+
if (!element || !element.href) {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
const tempRange = document.createRange();
|
|
680
|
+
tempRange.selectNodeContents(element);
|
|
681
|
+
return ((selectedRange.compareBoundaryPoints(Range.START_TO_START, tempRange) !== -1 &&
|
|
682
|
+
selectedRange.compareBoundaryPoints(Range.START_TO_END, tempRange) !== 1) ||
|
|
683
|
+
(selectedRange.compareBoundaryPoints(Range.END_TO_START, tempRange) !== -1 &&
|
|
684
|
+
selectedRange.compareBoundaryPoints(Range.END_TO_END, tempRange) !==
|
|
685
|
+
1));
|
|
686
|
+
}
|
|
687
|
+
// Normal non-IE
|
|
688
|
+
return (!!element && !!element.href && selectedRange.intersectsNode(element));
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
getIframeDocumentEl(id) {
|
|
692
|
+
/* istanbul ignore next */
|
|
693
|
+
if (!(id in this.editors)) {
|
|
694
|
+
return undefined;
|
|
695
|
+
}
|
|
696
|
+
const contentWindowEl = this.getContentWindowEl(id);
|
|
697
|
+
/* istanbul ignore else */
|
|
698
|
+
if (contentWindowEl) {
|
|
699
|
+
return contentWindowEl.document;
|
|
700
|
+
}
|
|
701
|
+
/* istanbul ignore next */
|
|
702
|
+
return this.editors[id].iframeElementRef.contentDocument;
|
|
703
|
+
}
|
|
704
|
+
getFontSize(id) {
|
|
705
|
+
let fontSize = STYLE_STATE_DEFAULTS.fontSize.toString();
|
|
706
|
+
const selection = this.getCurrentSelection(id);
|
|
707
|
+
/* istanbul ignore else */
|
|
708
|
+
if (selection &&
|
|
709
|
+
selection.anchorNode &&
|
|
710
|
+
selection.anchorNode.parentElement) {
|
|
711
|
+
let element = selection.anchorNode;
|
|
712
|
+
if (element.nodeType !== 1) {
|
|
713
|
+
element = element.parentElement;
|
|
714
|
+
}
|
|
715
|
+
const computedStyle = window.getComputedStyle(element);
|
|
716
|
+
/* istanbul ignore else */
|
|
717
|
+
if (computedStyle) {
|
|
718
|
+
fontSize = computedStyle.getPropertyValue('font-size');
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return fontSize;
|
|
722
|
+
}
|
|
723
|
+
createObservers(id, element) {
|
|
724
|
+
/* istanbul ignore next */
|
|
725
|
+
const documentEl = element.contentWindow
|
|
726
|
+
? element.contentWindow.document
|
|
727
|
+
: element.contentDocument;
|
|
728
|
+
// Firefox bug where we need to open/close to cancel load so it doesn't overwrite attrs
|
|
729
|
+
documentEl.open();
|
|
730
|
+
documentEl.close();
|
|
731
|
+
const selectionObservable = new Subject();
|
|
732
|
+
const selectionListener = () => selectionObservable.next();
|
|
733
|
+
const clickObservable = new Subject();
|
|
734
|
+
const clickListener = () => clickObservable.next();
|
|
735
|
+
const pasteListener = this.getPasteOverride(id);
|
|
736
|
+
const blurObservable = new Subject();
|
|
737
|
+
const blurListener = () => blurObservable.next();
|
|
738
|
+
const inputObservable = new Subject();
|
|
739
|
+
const inputListener = () => inputObservable.next();
|
|
740
|
+
documentEl.addEventListener('selectionchange', selectionListener);
|
|
741
|
+
documentEl.addEventListener('input', inputListener);
|
|
742
|
+
documentEl.addEventListener('mousedown', clickListener);
|
|
743
|
+
documentEl.body.addEventListener('paste', pasteListener);
|
|
744
|
+
documentEl.body.addEventListener('blur', blurListener);
|
|
745
|
+
return {
|
|
746
|
+
blurObservable: blurObservable,
|
|
747
|
+
clickObservable: clickObservable,
|
|
748
|
+
commandChangeObservable: new Subject(),
|
|
749
|
+
iframeElementRef: element,
|
|
750
|
+
inputObservable: inputObservable,
|
|
751
|
+
selectionChangeObservable: selectionObservable,
|
|
752
|
+
blurListener: blurListener,
|
|
753
|
+
clickListener: clickListener,
|
|
754
|
+
inputListener: inputListener,
|
|
755
|
+
pasteListener: pasteListener,
|
|
756
|
+
selectionListener: selectionListener,
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
/* istanbul ignore next */
|
|
760
|
+
getPasteOverride(id) {
|
|
761
|
+
return (e) => {
|
|
762
|
+
e.preventDefault();
|
|
763
|
+
const text = e.clipboardData.getData('text/plain');
|
|
764
|
+
this.execCommand(id, { command: 'insertHTML', value: text });
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
getCurrentSelectionParentElement(id) {
|
|
768
|
+
return this.selectionService.getCurrentSelectionParentElement(this.getIframeDocumentEl(id));
|
|
769
|
+
}
|
|
770
|
+
getColor(documentEl, selector) {
|
|
771
|
+
const commandValue = documentEl.queryCommandValue(selector);
|
|
772
|
+
// Edge is weird and returns numbers
|
|
773
|
+
/* istanbul ignore if */
|
|
774
|
+
if (typeof commandValue === 'number') {
|
|
775
|
+
/* istanbul ignore next */
|
|
776
|
+
// tslint:disable-next-line: no-bitwise
|
|
777
|
+
return ('rgb(' +
|
|
778
|
+
(commandValue & 0xff) +
|
|
779
|
+
', ' +
|
|
780
|
+
// tslint:disable-next-line: no-bitwise
|
|
781
|
+
((commandValue & 0xff00) >> 8) +
|
|
782
|
+
', ' +
|
|
783
|
+
// tslint:disable-next-line: no-bitwise
|
|
784
|
+
((commandValue & 0xff0000) >> 16) +
|
|
785
|
+
')');
|
|
786
|
+
}
|
|
787
|
+
// Firefox uses 'Transparent' instead of a color value
|
|
788
|
+
/* istanbul ignore next */
|
|
789
|
+
if (commandValue.toString().toLowerCase() === 'transparent') {
|
|
790
|
+
return STYLE_STATE_DEFAULTS.backColor;
|
|
791
|
+
}
|
|
792
|
+
return commandValue;
|
|
793
|
+
}
|
|
794
|
+
hasLink(editorId) {
|
|
795
|
+
const anchorEl = this.getSelectedAnchorTag(editorId);
|
|
796
|
+
const childAnchorEls = this.getChildSelectedAnchorTags(editorId);
|
|
797
|
+
/* istanbul ignore next */
|
|
798
|
+
return childAnchorEls.length > 0 || (!!anchorEl && !!anchorEl.href);
|
|
799
|
+
}
|
|
800
|
+
getParent(element, tag) {
|
|
801
|
+
let currentNode = element;
|
|
802
|
+
while (currentNode && currentNode.tagName.toUpperCase() !== 'BODY') {
|
|
803
|
+
if (currentNode.tagName.toUpperCase() === tag.toUpperCase()) {
|
|
804
|
+
return currentNode;
|
|
805
|
+
}
|
|
806
|
+
currentNode = currentNode.parentElement;
|
|
807
|
+
}
|
|
808
|
+
return undefined;
|
|
809
|
+
}
|
|
810
|
+
editorSelected(id) {
|
|
811
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
812
|
+
return this.selectionService.isElementSelected(documentEl, documentEl.body);
|
|
813
|
+
}
|
|
814
|
+
/* istanbul ignore next */
|
|
815
|
+
insertHtmlInIE11(id, html) {
|
|
816
|
+
const documentEl = this.getIframeDocumentEl(id);
|
|
817
|
+
const windowEl = this.getContentWindowEl(id);
|
|
818
|
+
const sel = windowEl.getSelection();
|
|
819
|
+
if (sel.getRangeAt && sel.rangeCount) {
|
|
820
|
+
let range = sel.getRangeAt(0);
|
|
821
|
+
range.deleteContents();
|
|
822
|
+
const el = documentEl.createElement('div');
|
|
823
|
+
el.innerHTML = html;
|
|
824
|
+
const frag = documentEl.createDocumentFragment();
|
|
825
|
+
let node, lastNode;
|
|
826
|
+
while (el.firstChild) {
|
|
827
|
+
node = el.firstChild;
|
|
828
|
+
lastNode = frag.appendChild(node);
|
|
829
|
+
}
|
|
830
|
+
range.insertNode(frag);
|
|
831
|
+
// Preserve the selection
|
|
832
|
+
if (lastNode) {
|
|
833
|
+
range = range.cloneRange();
|
|
834
|
+
range.setStartAfter(lastNode);
|
|
835
|
+
range.collapse(true);
|
|
836
|
+
sel.removeAllRanges();
|
|
837
|
+
sel.addRange(range);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
cleanUpBlankStyleTags(doc) {
|
|
842
|
+
const orphanElements = Array.from(doc.querySelectorAll('font,span,*[style=""]'));
|
|
843
|
+
for (const element of orphanElements) {
|
|
844
|
+
if (!element.getAttribute('style')) {
|
|
845
|
+
element.removeAttribute('style');
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
const removableElements = orphanElements.filter((element) => {
|
|
849
|
+
const tagName = element.tagName.toUpperCase();
|
|
850
|
+
return ((tagName === 'FONT' || tagName === 'SPAN') &&
|
|
851
|
+
(element.attributes.length === 0 || !element.hasChildNodes));
|
|
852
|
+
});
|
|
853
|
+
for (const element of removableElements) {
|
|
854
|
+
const parent = element.parentNode;
|
|
855
|
+
/* istanbul ignore else */
|
|
856
|
+
if (parent) {
|
|
857
|
+
while (element.firstChild) {
|
|
858
|
+
parent.insertBefore(element.firstChild, element);
|
|
859
|
+
}
|
|
860
|
+
parent.removeChild(element);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
// Certain values are encoded in html and need to be decoded
|
|
865
|
+
replaceHtmlCodes(str) {
|
|
866
|
+
return str
|
|
867
|
+
.replace(/ /, String.fromCharCode(160))
|
|
868
|
+
.replace(/</g, '<')
|
|
869
|
+
.replace(/>/g, '>')
|
|
870
|
+
.replace(/&/g, '&');
|
|
871
|
+
}
|
|
872
|
+
setEditorDisabled(id, focusableChildren, textEditorNativeElement, disabled) {
|
|
873
|
+
textEditorNativeElement.style.pointerEvents = disabled ? 'none' : 'auto';
|
|
874
|
+
textEditorNativeElement.setAttribute('aria-disabled', disabled ? 'true' : 'false');
|
|
875
|
+
/* istanbul ignore else */
|
|
876
|
+
if (focusableChildren.length > 0) {
|
|
877
|
+
focusableChildren.forEach((aFocusableChild) => {
|
|
878
|
+
aFocusableChild.tabIndex = disabled ? -1 : 0;
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
this.getIframeDocumentEl(id).body.setAttribute('contenteditable', disabled ? 'false' : 'true');
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
SkyTextEditorAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorAdapterService, deps: [{ token: SkyTextEditorSelectionService }, { token: SkyTextEditorService }, { token: i3.SkyAppWindowRef }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
885
|
+
SkyTextEditorAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorAdapterService, providedIn: 'root' });
|
|
886
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorAdapterService, decorators: [{
|
|
887
|
+
type: Injectable,
|
|
888
|
+
args: [{
|
|
889
|
+
providedIn: 'root',
|
|
890
|
+
}]
|
|
891
|
+
}], ctorParameters: function () { return [{ type: SkyTextEditorSelectionService }, { type: SkyTextEditorService }, { type: i3.SkyAppWindowRef }]; } });
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* @internal
|
|
895
|
+
*/
|
|
896
|
+
class SkyTextEditorMenubarComponent {
|
|
897
|
+
constructor(adapterService, changeDetector, resources) {
|
|
898
|
+
this.adapterService = adapterService;
|
|
899
|
+
this.changeDetector = changeDetector;
|
|
900
|
+
this.resources = resources;
|
|
901
|
+
this.editorFocusStream = new Subject();
|
|
902
|
+
this.menus = [];
|
|
903
|
+
this.mergeFields = [];
|
|
904
|
+
this._disabled = false;
|
|
905
|
+
this.editDropdownStream = new Subject();
|
|
906
|
+
this.formatDropdownStream = new Subject();
|
|
907
|
+
this.mergeFieldDropdownStream = new Subject();
|
|
908
|
+
this.ngUnsubscribe = new Subject();
|
|
909
|
+
}
|
|
910
|
+
set disabled(value) {
|
|
911
|
+
const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);
|
|
912
|
+
if (coercedValue !== this.disabled) {
|
|
913
|
+
this._disabled = coercedValue;
|
|
914
|
+
this.changeDetector.markForCheck();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
get disabled() {
|
|
918
|
+
return this._disabled;
|
|
919
|
+
}
|
|
920
|
+
ngOnInit() {
|
|
921
|
+
this.editorFocusStream.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {
|
|
922
|
+
this.closeDropdowns();
|
|
923
|
+
});
|
|
924
|
+
forkJoin([
|
|
925
|
+
// Format menu strings.
|
|
926
|
+
this.resources.getString('skyux_text_editor_format_menu_action_bold_label'),
|
|
927
|
+
this.resources.getString('skyux_text_editor_format_menu_action_bold_key_shortcut'),
|
|
928
|
+
this.resources.getString('skyux_text_editor_format_menu_action_italic_label'),
|
|
929
|
+
this.resources.getString('skyux_text_editor_format_menu_action_italic_key_shortcut'),
|
|
930
|
+
this.resources.getString('skyux_text_editor_format_menu_action_underline_label'),
|
|
931
|
+
this.resources.getString('skyux_text_editor_format_menu_action_underline_key_shortcut'),
|
|
932
|
+
this.resources.getString('skyux_text_editor_format_menu_action_strikethrough_label'),
|
|
933
|
+
this.resources.getString('skyux_text_editor_format_menu_action_clear_formatting_label'),
|
|
934
|
+
// Edit menu string - start at index 8.
|
|
935
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_undo_label'),
|
|
936
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_undo_key_shortcut'),
|
|
937
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_redo_label'),
|
|
938
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_redo_key_shortcut'),
|
|
939
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_cut_label'),
|
|
940
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_cut_key_shortcut'),
|
|
941
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_copy_label'),
|
|
942
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_copy_key_shortcut'),
|
|
943
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_paste_label'),
|
|
944
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_paste_key_shortcut'),
|
|
945
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_select_all_label'),
|
|
946
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_select_all_key_shortcut'),
|
|
947
|
+
])
|
|
948
|
+
.pipe(take(1))
|
|
949
|
+
.subscribe((resources) => {
|
|
950
|
+
this.formatItems = [
|
|
951
|
+
{
|
|
952
|
+
function: () => this.execCommand('bold'),
|
|
953
|
+
label: resources[0],
|
|
954
|
+
keyShortcut: resources[1],
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
function: () => this.execCommand('italic'),
|
|
958
|
+
label: resources[2],
|
|
959
|
+
keyShortcut: resources[3],
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
function: () => this.execCommand('underline'),
|
|
963
|
+
label: resources[4],
|
|
964
|
+
keyShortcut: resources[5],
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
function: () => this.execCommand('strikethrough'),
|
|
968
|
+
label: resources[6],
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
isDivider: true,
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
function: () => this.clearFormat(),
|
|
975
|
+
label: resources[7],
|
|
976
|
+
},
|
|
977
|
+
];
|
|
978
|
+
this.editItems = [
|
|
979
|
+
{
|
|
980
|
+
function: () => this.execCommand('undo'),
|
|
981
|
+
label: resources[8],
|
|
982
|
+
keyShortcut: resources[9],
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
function: () => this.execCommand('redo'),
|
|
986
|
+
label: resources[10],
|
|
987
|
+
keyShortcut: resources[11],
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
isDivider: true,
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
function: () => this.execCommand('cut'),
|
|
994
|
+
label: resources[12],
|
|
995
|
+
keyShortcut: resources[13],
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
function: () => this.execCommand('copy'),
|
|
999
|
+
label: resources[14],
|
|
1000
|
+
keyShortcut: resources[15],
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
function: () => this.execCommand('paste'),
|
|
1004
|
+
label: resources[16],
|
|
1005
|
+
keyShortcut: resources[17],
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
isDivider: true,
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
function: () => this.execCommand('selectAll'),
|
|
1012
|
+
label: resources[18],
|
|
1013
|
+
keyShortcut: resources[19],
|
|
1014
|
+
},
|
|
1015
|
+
];
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
ngOnDestroy() {
|
|
1019
|
+
this.ngUnsubscribe.next();
|
|
1020
|
+
this.ngUnsubscribe.complete();
|
|
1021
|
+
}
|
|
1022
|
+
execCommand(command, value = '') {
|
|
1023
|
+
this.adapterService.execCommand(this.editorId, {
|
|
1024
|
+
command: command,
|
|
1025
|
+
value: value,
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
insertMergeField(field) {
|
|
1029
|
+
this.execCommand('insertHTML', '<img style="display: inline; cursor: grab;" data-fieldid="' +
|
|
1030
|
+
field.id +
|
|
1031
|
+
'" data-fielddisplay="' +
|
|
1032
|
+
field.name +
|
|
1033
|
+
'" src="' +
|
|
1034
|
+
(field.previewImageUrl ||
|
|
1035
|
+
this.adapterService.getMergeFieldDataURI(field.name)) +
|
|
1036
|
+
'">');
|
|
1037
|
+
}
|
|
1038
|
+
closeDropdowns() {
|
|
1039
|
+
this.editDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
1040
|
+
this.formatDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
1041
|
+
this.mergeFieldDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
1042
|
+
}
|
|
1043
|
+
clearFormat() {
|
|
1044
|
+
const currentSelection = this.adapterService.getCurrentSelection(this.editorId);
|
|
1045
|
+
/* istanbul ignore else */
|
|
1046
|
+
if (currentSelection.rangeCount > 0 &&
|
|
1047
|
+
currentSelection.getRangeAt(0).toString().length <= 0) {
|
|
1048
|
+
this.execCommand('selectAll');
|
|
1049
|
+
}
|
|
1050
|
+
this.execCommand('removeFormat');
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
SkyTextEditorMenubarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorMenubarComponent, deps: [{ token: SkyTextEditorAdapterService }, { token: i0.ChangeDetectorRef }, { token: i2.SkyLibResourcesService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1054
|
+
SkyTextEditorMenubarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyTextEditorMenubarComponent, selector: "sky-text-editor-menubar", inputs: { editorFocusStream: "editorFocusStream", editorId: "editorId", menus: "menus", mergeFields: "mergeFields", disabled: "disabled" }, ngImport: i0, template: "<sky-toolbar-item\n *ngFor=\"let menu of menus\"\n class=\"sky-text-editor-menu\"\n [ngClass]=\"'sky-text-editor-menu-' + menu\"\n>\n <ng-container [ngSwitch]=\"menu\">\n <ng-container *ngSwitchCase=\"'edit'\">\n <sky-dropdown\n label=\"Edit menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"editDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_edit_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let editItem of editItems\">\n <button\n *ngIf=\"!editItem.isDivider\"\n type=\"button\"\n (click)=\"editItem.function()\"\n >\n {{ editItem.label }}\n <div\n *ngIf=\"editItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ editItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"editItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'format'\">\n <sky-dropdown\n label=\"Format menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"formatDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_format_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let formatItem of formatItems\">\n <button\n *ngIf=\"!formatItem.isDivider\"\n type=\"button\"\n (click)=\"formatItem.function()\"\n >\n {{ formatItem.label }}\n <div\n *ngIf=\"formatItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ formatItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"formatItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'merge-field'\">\n <sky-dropdown\n *ngIf=\"mergeFields && mergeFields.length > 0\"\n label=\"Insert merge field\"\n [disabled]=\"disabled\"\n [messageStream]=\"mergeFieldDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_insert_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let mergeField of mergeFields\">\n <button type=\"button\" (click)=\"insertMergeField(mergeField)\">\n {{ mergeField.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n", styles: [".sky-text-editor-dropdown-item-divider{border:0;padding:0;height:1px;margin:9px 1px;overflow:hidden;background:transparent;border-bottom:1px solid rgba(0,0,0,.1);cursor:default;filter:none}.sky-text-editor-menu-key-shortcut{float:right;margin-left:15px}\n"], components: [{ type: i3$1.λ39, selector: "sky-toolbar-item" }, { type: i4.λ3, selector: "sky-dropdown", inputs: ["buttonStyle", "buttonType", "disabled", "dismissOnBlur", "label", "horizontalAlignment", "messageStream", "title", "trigger"] }, { type: i4.λ2, selector: "sky-dropdown-button" }, { type: i4.λ4, selector: "sky-dropdown-menu", inputs: ["ariaLabelledBy", "ariaRole", "useNativeFocus"], outputs: ["menuChanges"] }, { type: i4.λ1, selector: "sky-dropdown-item", inputs: ["ariaRole"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }], pipes: { "skyLibResources": i2.SkyLibResourcesPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1055
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorMenubarComponent, decorators: [{
|
|
1056
|
+
type: Component,
|
|
1057
|
+
args: [{ selector: 'sky-text-editor-menubar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<sky-toolbar-item\n *ngFor=\"let menu of menus\"\n class=\"sky-text-editor-menu\"\n [ngClass]=\"'sky-text-editor-menu-' + menu\"\n>\n <ng-container [ngSwitch]=\"menu\">\n <ng-container *ngSwitchCase=\"'edit'\">\n <sky-dropdown\n label=\"Edit menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"editDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_edit_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let editItem of editItems\">\n <button\n *ngIf=\"!editItem.isDivider\"\n type=\"button\"\n (click)=\"editItem.function()\"\n >\n {{ editItem.label }}\n <div\n *ngIf=\"editItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ editItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"editItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'format'\">\n <sky-dropdown\n label=\"Format menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"formatDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_format_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let formatItem of formatItems\">\n <button\n *ngIf=\"!formatItem.isDivider\"\n type=\"button\"\n (click)=\"formatItem.function()\"\n >\n {{ formatItem.label }}\n <div\n *ngIf=\"formatItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ formatItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"formatItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'merge-field'\">\n <sky-dropdown\n *ngIf=\"mergeFields && mergeFields.length > 0\"\n label=\"Insert merge field\"\n [disabled]=\"disabled\"\n [messageStream]=\"mergeFieldDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_insert_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let mergeField of mergeFields\">\n <button type=\"button\" (click)=\"insertMergeField(mergeField)\">\n {{ mergeField.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n", styles: [".sky-text-editor-dropdown-item-divider{border:0;padding:0;height:1px;margin:9px 1px;overflow:hidden;background:transparent;border-bottom:1px solid rgba(0,0,0,.1);cursor:default;filter:none}.sky-text-editor-menu-key-shortcut{float:right;margin-left:15px}\n"] }]
|
|
1058
|
+
}], ctorParameters: function () { return [{ type: SkyTextEditorAdapterService }, { type: i0.ChangeDetectorRef }, { type: i2.SkyLibResourcesService }]; }, propDecorators: { editorFocusStream: [{
|
|
1059
|
+
type: Input
|
|
1060
|
+
}], editorId: [{
|
|
1061
|
+
type: Input
|
|
1062
|
+
}], menus: [{
|
|
1063
|
+
type: Input
|
|
1064
|
+
}], mergeFields: [{
|
|
1065
|
+
type: Input
|
|
1066
|
+
}], disabled: [{
|
|
1067
|
+
type: Input
|
|
1068
|
+
}] } });
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* @internal
|
|
1072
|
+
*/
|
|
1073
|
+
const FONT_SIZE_LIST_DEFAULTS = [
|
|
1074
|
+
6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 36, 48,
|
|
1075
|
+
];
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* @internal
|
|
1079
|
+
*/
|
|
1080
|
+
const MENU_DEFAULTS = ['edit', 'format'];
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* @internal
|
|
1084
|
+
*/
|
|
1085
|
+
const TOOLBAR_ACTION_DEFAULTS = [
|
|
1086
|
+
'font-family',
|
|
1087
|
+
'font-size',
|
|
1088
|
+
'font-style',
|
|
1089
|
+
'color',
|
|
1090
|
+
'list',
|
|
1091
|
+
'link',
|
|
1092
|
+
];
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* @internal
|
|
1096
|
+
*/
|
|
1097
|
+
class SkyUrlModalContext {
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
const emailKey = 'mailto:';
|
|
1101
|
+
const queryStringParamKey = '?Subject=';
|
|
1102
|
+
/**
|
|
1103
|
+
* @internal
|
|
1104
|
+
*/
|
|
1105
|
+
class SkyTextEditorUrlModalComponent {
|
|
1106
|
+
constructor(modalInstance, modalContext) {
|
|
1107
|
+
this.modalInstance = modalInstance;
|
|
1108
|
+
this.emailAddressValid = false;
|
|
1109
|
+
this.subject = '';
|
|
1110
|
+
this.target = 0;
|
|
1111
|
+
this.valid = false;
|
|
1112
|
+
this._activeTab = 0;
|
|
1113
|
+
this._emailAddress = '';
|
|
1114
|
+
this._url = 'https://';
|
|
1115
|
+
if (modalContext.urlResult) {
|
|
1116
|
+
if (modalContext.urlResult.url.startsWith(emailKey)) {
|
|
1117
|
+
this.emailAddress = modalContext.urlResult.url.replace(emailKey, '');
|
|
1118
|
+
let queryStringIndex = this.emailAddress.indexOf(queryStringParamKey);
|
|
1119
|
+
queryStringIndex =
|
|
1120
|
+
queryStringIndex > -1
|
|
1121
|
+
? queryStringIndex
|
|
1122
|
+
: this.emailAddress.indexOf(queryStringParamKey.toLowerCase());
|
|
1123
|
+
/* istanbul ignore else */
|
|
1124
|
+
if (queryStringIndex > -1) {
|
|
1125
|
+
this.subject = decodeURI(this.emailAddress).slice(queryStringIndex + queryStringParamKey.length);
|
|
1126
|
+
this.emailAddress = this.emailAddress.slice(0, queryStringIndex);
|
|
1127
|
+
}
|
|
1128
|
+
// Set active tab to email
|
|
1129
|
+
this.activeTab = 1;
|
|
1130
|
+
}
|
|
1131
|
+
else {
|
|
1132
|
+
(this.url = modalContext.urlResult.url),
|
|
1133
|
+
(this.target = modalContext.urlResult.target);
|
|
1134
|
+
// set active tab to web page
|
|
1135
|
+
this.activeTab = 0;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
set activeTab(value) {
|
|
1140
|
+
this._activeTab = value;
|
|
1141
|
+
this.valid = this.isValid();
|
|
1142
|
+
}
|
|
1143
|
+
get activeTab() {
|
|
1144
|
+
return this._activeTab;
|
|
1145
|
+
}
|
|
1146
|
+
set emailAddress(value) {
|
|
1147
|
+
this._emailAddress = value;
|
|
1148
|
+
this.valid = this.isValid();
|
|
1149
|
+
}
|
|
1150
|
+
get emailAddress() {
|
|
1151
|
+
return this._emailAddress;
|
|
1152
|
+
}
|
|
1153
|
+
set url(value) {
|
|
1154
|
+
this._url = value;
|
|
1155
|
+
this.valid = this.isValid();
|
|
1156
|
+
}
|
|
1157
|
+
get url() {
|
|
1158
|
+
return this._url;
|
|
1159
|
+
}
|
|
1160
|
+
activeTabChanged(value) {
|
|
1161
|
+
this.activeTab = value;
|
|
1162
|
+
}
|
|
1163
|
+
save() {
|
|
1164
|
+
/* istanbul ignore else */
|
|
1165
|
+
if (this.isValid()) {
|
|
1166
|
+
if (this.activeTab === 0) {
|
|
1167
|
+
this.modalInstance.save({
|
|
1168
|
+
url: this.url,
|
|
1169
|
+
target: this.target
|
|
1170
|
+
? parseInt(this.target, undefined)
|
|
1171
|
+
: UrlTarget.None,
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
this.modalInstance.save({
|
|
1176
|
+
url: this.getEmailUrl(),
|
|
1177
|
+
target: UrlTarget.None,
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
cancel() {
|
|
1183
|
+
this.modalInstance.cancel();
|
|
1184
|
+
}
|
|
1185
|
+
getEmailUrl() {
|
|
1186
|
+
return (emailKey +
|
|
1187
|
+
this.emailAddress +
|
|
1188
|
+
(this.subject ? '?Subject=' + encodeURI(this.subject) : ''));
|
|
1189
|
+
}
|
|
1190
|
+
isValid() {
|
|
1191
|
+
if (this.activeTab === 0) {
|
|
1192
|
+
return !!this.url && SkyValidation.isUrl(this.url);
|
|
1193
|
+
}
|
|
1194
|
+
return !!this.emailAddress && SkyValidation.isEmail(this.emailAddress);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
SkyTextEditorUrlModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorUrlModalComponent, deps: [{ token: i1$1.SkyModalInstance }, { token: SkyUrlModalContext }], target: i0.ɵɵFactoryTarget.Component });
|
|
1198
|
+
SkyTextEditorUrlModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyTextEditorUrlModalComponent, selector: "sky-text-editor-url-modal", ngImport: i0, template: "<sky-modal>\n <sky-modal-header>\n {{ 'skyux_text_editor_url_modal_header_label' | skyLibResources }}\n </sky-modal-header>\n <sky-modal-content>\n <sky-tabset\n data-sky-id=\"test-tabset\"\n [active]=\"activeTab\"\n (activeChange)=\"activeTabChanged($event)\"\n >\n <sky-tab tabHeading=\"Web page\">\n <div class=\"sky-form-group sky-text-editor-url-modal-first-field\">\n <sky-input-box>\n <label\n class=\"sky-control-label sky-control-label-required\"\n [for]=\"urlInput.id\"\n >\n {{ 'skyux_text_editor_url_modal_url_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"url\"\n skyId\n #urlInput=\"skyId\"\n />\n </sky-input-box>\n </div>\n <sky-input-box class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"targetInput.id\">\n {{ 'skyux_text_editor_url_modal_open_label' | skyLibResources }}\n </label>\n <select\n class=\"sky-form-control\"\n [(ngModel)]=\"target\"\n skyId\n #targetInput=\"skyId\"\n >\n <option value=\"0\">\n {{\n 'skyux_text_editor_url_modal_current_option_label'\n | skyLibResources\n }}\n </option>\n <option value=\"1\">\n {{\n 'skyux_text_editor_url_modal_new_option_label' | skyLibResources\n }}\n </option>\n </select>\n </sky-input-box>\n </sky-tab>\n <sky-tab tabHeading=\"Email address\">\n <div class=\"sky-form-group first-field\">\n <sky-input-box>\n <label\n class=\"sky-control-label sky-control-label-required\"\n [for]=\"emailAddressInput.id\"\n >\n {{ 'skyux_text_editor_url_modal_email_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"emailAddress\"\n skyId\n #emailAddressInput=\"skyId\"\n />\n </sky-input-box>\n </div>\n <sky-input-box class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"subjectInput.id\">\n {{ 'skyux_text_editor_url_modal_subject_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"subject\"\n skyId\n #subjectInput=\"skyId\"\n />\n </sky-input-box>\n </sky-tab>\n </sky-tabset>\n </sky-modal-content>\n <sky-modal-footer>\n <button\n type=\"submit\"\n class=\"sky-btn sky-btn-primary\"\n [disabled]=\"!valid\"\n (click)=\"save()\"\n >\n {{ 'skyux_text_editor_url_modal_save_button_label' | skyLibResources }}\n </button>\n <button type=\"button\" class=\"sky-btn sky-btn-link\" (click)=\"cancel()\">\n {{ 'skyux_text_editor_url_modal_cancel_button_label' | skyLibResources }}\n </button>\n </sky-modal-footer>\n</sky-modal>\n", styles: [".sky-text-editor-url-modal-first-field{margin-top:15px}\n"], components: [{ type: i1$1.λ5, selector: "sky-modal", inputs: ["ariaRole", "tiledBody"] }, { type: i1$1.λ4, selector: "sky-modal-header" }, { type: i1$1.λ2, selector: "sky-modal-content" }, { type: i3$2.λ2, selector: "sky-tabset", inputs: ["active", "ariaLabel", "ariaLabelledBy", "permalinkId", "tabStyle"], outputs: ["activeChange", "newTab", "openTab", "tabIndexesChange"] }, { type: i3$2.λ1, selector: "sky-tab", inputs: ["active", "disabled", "permalinkValue", "tabHeaderCount", "tabHeading", "tabIndex"], outputs: ["close"] }, { type: i4$1.λ10, selector: "sky-input-box", inputs: ["hasErrors", "disabled"] }, { type: i1$1.λ3, selector: "sky-modal-footer" }], directives: [{ type: i5$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3.λ2, selector: "[skyId]", exportAs: ["skyId"] }, { type: i5$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i5$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i5$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], pipes: { "skyLibResources": i2.SkyLibResourcesPipe } });
|
|
1199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorUrlModalComponent, decorators: [{
|
|
1200
|
+
type: Component,
|
|
1201
|
+
args: [{ selector: 'sky-text-editor-url-modal', template: "<sky-modal>\n <sky-modal-header>\n {{ 'skyux_text_editor_url_modal_header_label' | skyLibResources }}\n </sky-modal-header>\n <sky-modal-content>\n <sky-tabset\n data-sky-id=\"test-tabset\"\n [active]=\"activeTab\"\n (activeChange)=\"activeTabChanged($event)\"\n >\n <sky-tab tabHeading=\"Web page\">\n <div class=\"sky-form-group sky-text-editor-url-modal-first-field\">\n <sky-input-box>\n <label\n class=\"sky-control-label sky-control-label-required\"\n [for]=\"urlInput.id\"\n >\n {{ 'skyux_text_editor_url_modal_url_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"url\"\n skyId\n #urlInput=\"skyId\"\n />\n </sky-input-box>\n </div>\n <sky-input-box class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"targetInput.id\">\n {{ 'skyux_text_editor_url_modal_open_label' | skyLibResources }}\n </label>\n <select\n class=\"sky-form-control\"\n [(ngModel)]=\"target\"\n skyId\n #targetInput=\"skyId\"\n >\n <option value=\"0\">\n {{\n 'skyux_text_editor_url_modal_current_option_label'\n | skyLibResources\n }}\n </option>\n <option value=\"1\">\n {{\n 'skyux_text_editor_url_modal_new_option_label' | skyLibResources\n }}\n </option>\n </select>\n </sky-input-box>\n </sky-tab>\n <sky-tab tabHeading=\"Email address\">\n <div class=\"sky-form-group first-field\">\n <sky-input-box>\n <label\n class=\"sky-control-label sky-control-label-required\"\n [for]=\"emailAddressInput.id\"\n >\n {{ 'skyux_text_editor_url_modal_email_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"emailAddress\"\n skyId\n #emailAddressInput=\"skyId\"\n />\n </sky-input-box>\n </div>\n <sky-input-box class=\"sky-form-group\">\n <label class=\"sky-control-label\" [for]=\"subjectInput.id\">\n {{ 'skyux_text_editor_url_modal_subject_label' | skyLibResources }}\n </label>\n <input\n class=\"sky-form-control\"\n type=\"text\"\n [(ngModel)]=\"subject\"\n skyId\n #subjectInput=\"skyId\"\n />\n </sky-input-box>\n </sky-tab>\n </sky-tabset>\n </sky-modal-content>\n <sky-modal-footer>\n <button\n type=\"submit\"\n class=\"sky-btn sky-btn-primary\"\n [disabled]=\"!valid\"\n (click)=\"save()\"\n >\n {{ 'skyux_text_editor_url_modal_save_button_label' | skyLibResources }}\n </button>\n <button type=\"button\" class=\"sky-btn sky-btn-link\" (click)=\"cancel()\">\n {{ 'skyux_text_editor_url_modal_cancel_button_label' | skyLibResources }}\n </button>\n </sky-modal-footer>\n</sky-modal>\n", styles: [".sky-text-editor-url-modal-first-field{margin-top:15px}\n"] }]
|
|
1202
|
+
}], ctorParameters: function () { return [{ type: i1$1.SkyModalInstance }, { type: SkyUrlModalContext }]; } });
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* @internal
|
|
1206
|
+
*/
|
|
1207
|
+
class SkyTextEditorToolbarComponent {
|
|
1208
|
+
constructor(adapterService, changeDetector, modalService) {
|
|
1209
|
+
this.adapterService = adapterService;
|
|
1210
|
+
this.changeDetector = changeDetector;
|
|
1211
|
+
this.modalService = modalService;
|
|
1212
|
+
this.editorFocusStream = new Subject();
|
|
1213
|
+
this.backColorpickerStream = new Subject();
|
|
1214
|
+
this.colorpickerStream = new Subject();
|
|
1215
|
+
this.fontPickerStream = new Subject();
|
|
1216
|
+
this.fontSizeStream = new Subject();
|
|
1217
|
+
this._disabled = false;
|
|
1218
|
+
this._styleState = STYLE_STATE_DEFAULTS;
|
|
1219
|
+
}
|
|
1220
|
+
get styleState() {
|
|
1221
|
+
return this._styleState;
|
|
1222
|
+
}
|
|
1223
|
+
set styleState(value) {
|
|
1224
|
+
this._styleState = value;
|
|
1225
|
+
if (value.font !== this.styleStateFontName) {
|
|
1226
|
+
if (value.font === '"Blackbaud Sans", Arial, sans-serif') {
|
|
1227
|
+
this.styleStateFontName = this.getFontName('Blackbaud Sans');
|
|
1228
|
+
}
|
|
1229
|
+
else {
|
|
1230
|
+
this.styleStateFontName = this.getFontName(value.font);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
set disabled(value) {
|
|
1235
|
+
const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);
|
|
1236
|
+
if (coercedValue !== this.disabled) {
|
|
1237
|
+
this._disabled = coercedValue;
|
|
1238
|
+
this.changeDetector.markForCheck();
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
get disabled() {
|
|
1242
|
+
return this._disabled;
|
|
1243
|
+
}
|
|
1244
|
+
ngOnInit() {
|
|
1245
|
+
this.editorFocusStream.subscribe(() => {
|
|
1246
|
+
this.styleState = {
|
|
1247
|
+
...this._styleState,
|
|
1248
|
+
...this.adapterService.getStyleState(this.editorId),
|
|
1249
|
+
};
|
|
1250
|
+
this.closeDropdowns();
|
|
1251
|
+
this.changeDetector.detectChanges();
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
execCommand(command, value = '') {
|
|
1255
|
+
this.adapterService.execCommand(this.editorId, {
|
|
1256
|
+
command: command,
|
|
1257
|
+
value: value,
|
|
1258
|
+
});
|
|
1259
|
+
this.styleState = {
|
|
1260
|
+
...this.styleState,
|
|
1261
|
+
...this.adapterService.getStyleState(this.editorId),
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
toggleFontStyle(currentState, newState, command) {
|
|
1265
|
+
if (currentState !== newState) {
|
|
1266
|
+
this.execCommand(command);
|
|
1267
|
+
}
|
|
1268
|
+
// Force sky-checkbox to show changes on user's initial click.
|
|
1269
|
+
this.changeDetector.detectChanges();
|
|
1270
|
+
}
|
|
1271
|
+
link() {
|
|
1272
|
+
const priorSelection = this.adapterService.saveSelection(this.editorId);
|
|
1273
|
+
const currentLink = this.adapterService.getLink(this.editorId);
|
|
1274
|
+
const inputModal = this.modalService.open(SkyTextEditorUrlModalComponent, [
|
|
1275
|
+
{
|
|
1276
|
+
provide: SkyUrlModalContext,
|
|
1277
|
+
useValue: { urlResult: currentLink },
|
|
1278
|
+
},
|
|
1279
|
+
]);
|
|
1280
|
+
inputModal.closed.subscribe((result) => {
|
|
1281
|
+
if (result.reason === 'save' && priorSelection) {
|
|
1282
|
+
if (currentLink) {
|
|
1283
|
+
const anchor = this.adapterService.getSelectedAnchorTag(this.editorId);
|
|
1284
|
+
this.adapterService.selectElement(this.editorId, anchor);
|
|
1285
|
+
}
|
|
1286
|
+
this.execCommand('unlink');
|
|
1287
|
+
if (result.data.target === UrlTarget.None) {
|
|
1288
|
+
// Current window
|
|
1289
|
+
this.execCommand('createLink', result.data.url);
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
// New Window
|
|
1293
|
+
const sText = this.adapterService.getCurrentSelection(this.editorId);
|
|
1294
|
+
this.execCommand('insertHTML', '<a href="' +
|
|
1295
|
+
result.data.url +
|
|
1296
|
+
'" rel="noopener noreferrer" target="_blank">' +
|
|
1297
|
+
sText +
|
|
1298
|
+
'</a>');
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
unlink() {
|
|
1304
|
+
const currentSelectionRange = this.adapterService
|
|
1305
|
+
.getCurrentSelection(this.editorId)
|
|
1306
|
+
.getRangeAt(0);
|
|
1307
|
+
if (currentSelectionRange.toString().length <= 0) {
|
|
1308
|
+
const anchorTag = this.adapterService.getSelectedAnchorTag(this.editorId);
|
|
1309
|
+
this.adapterService.selectElement(this.editorId, anchorTag);
|
|
1310
|
+
}
|
|
1311
|
+
this.execCommand('unlink');
|
|
1312
|
+
}
|
|
1313
|
+
changeFontSize(size) {
|
|
1314
|
+
this.adapterService.setFontSize(this.editorId, size);
|
|
1315
|
+
this.styleState = {
|
|
1316
|
+
...this.styleState,
|
|
1317
|
+
...this.adapterService.getStyleState(this.editorId),
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
onColorpickerColorChanged(color, isBackground = false) {
|
|
1321
|
+
this.execCommand(isBackground ? 'backColor' : 'foreColor', color.hex);
|
|
1322
|
+
}
|
|
1323
|
+
closeDropdowns() {
|
|
1324
|
+
const message = {
|
|
1325
|
+
type: SkyColorpickerMessageType.Close,
|
|
1326
|
+
};
|
|
1327
|
+
this.colorpickerStream.next(message);
|
|
1328
|
+
this.backColorpickerStream.next(message);
|
|
1329
|
+
this.fontPickerStream.next({ type: SkyDropdownMessageType.Close });
|
|
1330
|
+
this.fontSizeStream.next({ type: SkyDropdownMessageType.Close });
|
|
1331
|
+
}
|
|
1332
|
+
getFontName(fontName) {
|
|
1333
|
+
for (let i = 0; i < this.fontList.length; i++) {
|
|
1334
|
+
if (fontName.replace(/['"]+/g, '') === this.fontList[i].name) {
|
|
1335
|
+
return this.fontList[i].name;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
SkyTextEditorToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorToolbarComponent, deps: [{ token: SkyTextEditorAdapterService }, { token: i0.ChangeDetectorRef }, { token: i1$1.SkyModalService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1341
|
+
SkyTextEditorToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyTextEditorToolbarComponent, selector: "sky-text-editor-toolbar", inputs: { editorFocusStream: "editorFocusStream", editorId: "editorId", fontList: "fontList", fontSizeList: "fontSizeList", toolbarActions: "toolbarActions", styleState: "styleState", disabled: "disabled" }, ngImport: i0, template: "<sky-toolbar-item\n *ngFor=\"let action of toolbarActions\"\n class=\"sky-text-editor-toolbar-action\"\n [ngClass]=\"'sky-text-editor-toolbar-action-' + action\"\n>\n <ng-container [ngSwitch]=\"action\">\n <ng-container *ngSwitchCase=\"'font-family'\">\n <sky-dropdown\n class=\"sky-text-editor-font-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font: ' + styleStateFontName\"\n [messageStream]=\"fontPickerStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.font\n }\"\n >\n {{ styleStateFontName }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let fontModel of fontList\">\n <button\n type=\"button\"\n [ngStyle]=\"{\n 'font-family': fontModel.value\n }\"\n (click)=\"execCommand('fontname', fontModel.name)\"\n >\n {{ fontModel.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'font-size'\">\n <sky-dropdown\n class=\"sky-text-editor-font-size-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font size: ' + styleState.fontSize + 'px'\"\n [messageStream]=\"fontSizeStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.fontSize\n }\"\n >\n {{ styleState.fontSize + 'px' }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let size of fontSizeList\">\n <button type=\"button\" (click)=\"changeFontSize(size)\">\n {{ size + 'px' }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'font-style'\">\n <div class=\"sky-switch-icon-group sky-text-editor-font-style-picker\">\n <sky-checkbox\n icon=\"bold\"\n label=\"Bold\"\n title=\"Bold\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.boldState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.boldState, $event, 'bold')\n \"\n >\n </sky-checkbox>\n <sky-checkbox\n icon=\"italic\"\n label=\"Italicized\"\n title=\"Italicized\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.italicState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.italicState, $event, 'italic')\n \"\n >\n </sky-checkbox>\n <sky-checkbox\n icon=\"underline\"\n label=\"Underline\"\n title=\"Underline\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.underlineState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.underlineState, $event, 'underline')\n \"\n >\n </sky-checkbox>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'color'\">\n <div class=\"sky-text-editor-colorpicker-group\">\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n class=\"sky-text-editor-font-color-picker\"\n label=\"Font color\"\n [messageStream]=\"colorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event)\"\n #colorPicker\n >\n <input\n outputFormat=\"hex\"\n type=\"text\"\n [allowTransparency]=\"false\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.fontColor\"\n [skyColorpickerInput]=\"colorPicker\"\n />\n </sky-colorpicker>\n </div>\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n class=\"sky-text-editor-background-color-picker\"\n label=\"Background color\"\n [messageStream]=\"backColorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event, true)\"\n #backColorPicker\n >\n <input\n outputFormat=\"rgba\"\n type=\"text\"\n [allowTransparency]=\"true\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.backColor\"\n [skyColorpickerInput]=\"backColorPicker\"\n />\n </sky-colorpicker>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'list'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Bulleted list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Bulleted list\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertUnorderedList')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"list-ul\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"bullet-list-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Numbered list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Numbered list\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertOrderedList')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"list-ol\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"number-list-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'alignment'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Align left\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align left\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyLeft')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-left\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"align-left-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Align center\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align center\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyCenter')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-center\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"center-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Align right\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align right\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyRight')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-right\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"align-right-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'indentation'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Outdent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Outdent\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('outdent')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"outdent\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"outdent-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Indent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Indent\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('indent')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"indent\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"indent-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'undo-redo'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Undo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Undo\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('undo')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"undo\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"undo-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Redo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Redo\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('redo')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"repeat\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"redo-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'link'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Link\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Link\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'icon-btn-active': styleState.linkState\n }\"\n (click)=\"link()\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"link\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"link-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Unlink\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Unlink\"\n [disabled]=\"!styleState.linkState || disabled\"\n (click)=\"unlink()\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"unlink\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"unlink-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n", styles: [".sky-text-editor-toolbar-action .sky-toolbar-item{margin-right:15px}.sky-text-editor-toolbar-action .sky-text-editor-font-picker ::ng-deep .sky-dropdown-button-content-container{width:140px;height:20px;text-align:left}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group{display:flex}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{position:relative;top:3px;margin:0 10px 0 0}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child{margin-right:0}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn{margin-left:0;margin-right:0;border-radius:0;border-right:none}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:first-of-type{border-top-left-radius:3px;border-bottom-left-radius:3px}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border-top-right-radius:3px;border-bottom-right-radius:3px;border-right:1px solid #cdcfd2}:host-context(.sky-theme-modern) .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{top:-2px;margin:0}:host-context(.sky-theme-modern) .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child ::ng-deep sky-colorpicker .sky-colorpicker-button{margin-right:0}:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn{margin:inherit;border-radius:6px}:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn:first-of-type,:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn:last-of-type{border-radius:6px}:host-context(.sky-theme-modern) .sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border:none}.sky-theme-modern .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{top:-2px;margin:0}.sky-theme-modern .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child ::ng-deep sky-colorpicker .sky-colorpicker-button{margin-right:0}.sky-theme-modern .sky-switch-icon-group .sky-btn{margin:inherit;border-radius:6px}.sky-theme-modern .sky-switch-icon-group .sky-btn:first-of-type,.sky-theme-modern .sky-switch-icon-group .sky-btn:last-of-type{border-radius:6px}.sky-theme-modern .sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border:none}\n"], components: [{ type: i3$1.λ39, selector: "sky-toolbar-item" }, { type: i4.λ3, selector: "sky-dropdown", inputs: ["buttonStyle", "buttonType", "disabled", "dismissOnBlur", "label", "horizontalAlignment", "messageStream", "title", "trigger"] }, { type: i4.λ2, selector: "sky-dropdown-button" }, { type: i4.λ4, selector: "sky-dropdown-menu", inputs: ["ariaLabelledBy", "ariaRole", "useNativeFocus"], outputs: ["menuChanges"] }, { type: i4.λ1, selector: "sky-dropdown-item", inputs: ["ariaRole"] }, { type: i4$1.λ3, selector: "sky-checkbox", inputs: ["label", "labelledBy", "id", "disabled", "tabindex", "name", "icon", "checkboxType", "checked", "required"], outputs: ["change", "checkedChange", "disabledChange"] }, { type: i6$1.λ1, selector: "sky-colorpicker", inputs: ["pickerButtonIcon", "pickerButtonIconType", "label", "labelledBy", "messageStream", "showResetButton"], outputs: ["selectedColorChanged", "selectedColorApplied"] }, { type: i7.λ4, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i5.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i5$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i5$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i6$1.λ2, selector: "[skyColorpickerInput]", inputs: ["skyColorpickerInput", "initialColor", "returnFormat", "outputFormat", "presetColors", "alphaChannel", "allowTransparency"] }, { type: i6.λ3, selector: "[skyThemeIf]", inputs: ["skyThemeIf"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorToolbarComponent, decorators: [{
|
|
1343
|
+
type: Component,
|
|
1344
|
+
args: [{ selector: 'sky-text-editor-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<sky-toolbar-item\n *ngFor=\"let action of toolbarActions\"\n class=\"sky-text-editor-toolbar-action\"\n [ngClass]=\"'sky-text-editor-toolbar-action-' + action\"\n>\n <ng-container [ngSwitch]=\"action\">\n <ng-container *ngSwitchCase=\"'font-family'\">\n <sky-dropdown\n class=\"sky-text-editor-font-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font: ' + styleStateFontName\"\n [messageStream]=\"fontPickerStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.font\n }\"\n >\n {{ styleStateFontName }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let fontModel of fontList\">\n <button\n type=\"button\"\n [ngStyle]=\"{\n 'font-family': fontModel.value\n }\"\n (click)=\"execCommand('fontname', fontModel.name)\"\n >\n {{ fontModel.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'font-size'\">\n <sky-dropdown\n class=\"sky-text-editor-font-size-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font size: ' + styleState.fontSize + 'px'\"\n [messageStream]=\"fontSizeStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.fontSize\n }\"\n >\n {{ styleState.fontSize + 'px' }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let size of fontSizeList\">\n <button type=\"button\" (click)=\"changeFontSize(size)\">\n {{ size + 'px' }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'font-style'\">\n <div class=\"sky-switch-icon-group sky-text-editor-font-style-picker\">\n <sky-checkbox\n icon=\"bold\"\n label=\"Bold\"\n title=\"Bold\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.boldState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.boldState, $event, 'bold')\n \"\n >\n </sky-checkbox>\n <sky-checkbox\n icon=\"italic\"\n label=\"Italicized\"\n title=\"Italicized\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.italicState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.italicState, $event, 'italic')\n \"\n >\n </sky-checkbox>\n <sky-checkbox\n icon=\"underline\"\n label=\"Underline\"\n title=\"Underline\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.underlineState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.underlineState, $event, 'underline')\n \"\n >\n </sky-checkbox>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'color'\">\n <div class=\"sky-text-editor-colorpicker-group\">\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n class=\"sky-text-editor-font-color-picker\"\n label=\"Font color\"\n [messageStream]=\"colorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event)\"\n #colorPicker\n >\n <input\n outputFormat=\"hex\"\n type=\"text\"\n [allowTransparency]=\"false\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.fontColor\"\n [skyColorpickerInput]=\"colorPicker\"\n />\n </sky-colorpicker>\n </div>\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n class=\"sky-text-editor-background-color-picker\"\n label=\"Background color\"\n [messageStream]=\"backColorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event, true)\"\n #backColorPicker\n >\n <input\n outputFormat=\"rgba\"\n type=\"text\"\n [allowTransparency]=\"true\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.backColor\"\n [skyColorpickerInput]=\"backColorPicker\"\n />\n </sky-colorpicker>\n </div>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'list'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Bulleted list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Bulleted list\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertUnorderedList')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"list-ul\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"bullet-list-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Numbered list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Numbered list\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertOrderedList')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"list-ol\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"number-list-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'alignment'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Align left\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align left\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyLeft')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-left\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"align-left-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Align center\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align center\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyCenter')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-center\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"center-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n <button\n aria-label=\"Align right\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align right\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyRight')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"align-right\"> </sky-icon>\n <sky-icon\n *skyThemeIf=\"'modern'\"\n icon=\"align-right-text-line\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'indentation'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Outdent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Outdent\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('outdent')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"outdent\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"outdent-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Indent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Indent\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('indent')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"indent\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"indent-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'undo-redo'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Undo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Undo\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('undo')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"undo\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"undo-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Redo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Redo\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('redo')\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"repeat\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"redo-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase=\"'link'\">\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Link\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Link\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'icon-btn-active': styleState.linkState\n }\"\n (click)=\"link()\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"link\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"link-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n <button\n aria-label=\"Unlink\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Unlink\"\n [disabled]=\"!styleState.linkState || disabled\"\n (click)=\"unlink()\"\n >\n <sky-icon *skyThemeIf=\"'default'\" icon=\"unlink\"> </sky-icon>\n <sky-icon *skyThemeIf=\"'modern'\" icon=\"unlink-line\" iconType=\"skyux\">\n </sky-icon>\n </button>\n </div>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n", styles: [".sky-text-editor-toolbar-action .sky-toolbar-item{margin-right:15px}.sky-text-editor-toolbar-action .sky-text-editor-font-picker ::ng-deep .sky-dropdown-button-content-container{width:140px;height:20px;text-align:left}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group{display:flex}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{position:relative;top:3px;margin:0 10px 0 0}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child{margin-right:0}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn{margin-left:0;margin-right:0;border-radius:0;border-right:none}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:first-of-type{border-top-left-radius:3px;border-bottom-left-radius:3px}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border-top-right-radius:3px;border-bottom-right-radius:3px;border-right:1px solid #cdcfd2}:host-context(.sky-theme-modern) .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{top:-2px;margin:0}:host-context(.sky-theme-modern) .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child ::ng-deep sky-colorpicker .sky-colorpicker-button{margin-right:0}:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn{margin:inherit;border-radius:6px}:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn:first-of-type,:host-context(.sky-theme-modern) .sky-switch-icon-group .sky-btn:last-of-type{border-radius:6px}:host-context(.sky-theme-modern) .sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border:none}.sky-theme-modern .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{top:-2px;margin:0}.sky-theme-modern .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child ::ng-deep sky-colorpicker .sky-colorpicker-button{margin-right:0}.sky-theme-modern .sky-switch-icon-group .sky-btn{margin:inherit;border-radius:6px}.sky-theme-modern .sky-switch-icon-group .sky-btn:first-of-type,.sky-theme-modern .sky-switch-icon-group .sky-btn:last-of-type{border-radius:6px}.sky-theme-modern .sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border:none}\n"] }]
|
|
1345
|
+
}], ctorParameters: function () { return [{ type: SkyTextEditorAdapterService }, { type: i0.ChangeDetectorRef }, { type: i1$1.SkyModalService }]; }, propDecorators: { editorFocusStream: [{
|
|
1346
|
+
type: Input
|
|
1347
|
+
}], editorId: [{
|
|
1348
|
+
type: Input
|
|
1349
|
+
}], fontList: [{
|
|
1350
|
+
type: Input
|
|
1351
|
+
}], fontSizeList: [{
|
|
1352
|
+
type: Input
|
|
1353
|
+
}], toolbarActions: [{
|
|
1354
|
+
type: Input
|
|
1355
|
+
}], styleState: [{
|
|
1356
|
+
type: Input
|
|
1357
|
+
}], disabled: [{
|
|
1358
|
+
type: Input
|
|
1359
|
+
}] } });
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Auto-incrementing integer used to generate unique ids for radio components.
|
|
1363
|
+
*/
|
|
1364
|
+
let nextUniqueId = 0;
|
|
1365
|
+
/**
|
|
1366
|
+
* The text editor component lets users format and manipulate text.
|
|
1367
|
+
*/
|
|
1368
|
+
class SkyTextEditorComponent {
|
|
1369
|
+
constructor(changeDetector, coreAdapterService, adapterService, editorService, sanitizationService, ngControl, zone) {
|
|
1370
|
+
this.changeDetector = changeDetector;
|
|
1371
|
+
this.coreAdapterService = coreAdapterService;
|
|
1372
|
+
this.adapterService = adapterService;
|
|
1373
|
+
this.editorService = editorService;
|
|
1374
|
+
this.sanitizationService = sanitizationService;
|
|
1375
|
+
this.ngControl = ngControl;
|
|
1376
|
+
this.zone = zone;
|
|
1377
|
+
/**
|
|
1378
|
+
* Indicates whether to put focus on the editor after it renders.
|
|
1379
|
+
*/
|
|
1380
|
+
this.autofocus = false;
|
|
1381
|
+
this.editorFocusStream = new Subject();
|
|
1382
|
+
/**
|
|
1383
|
+
* Specifies the fonts to include in the font picker.
|
|
1384
|
+
* @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'}]
|
|
1385
|
+
*/
|
|
1386
|
+
this.fontList = FONT_LIST_DEFAULTS;
|
|
1387
|
+
/**
|
|
1388
|
+
* Specifies the font sizes to include in the font size picker.
|
|
1389
|
+
* @default [6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 36, 48]
|
|
1390
|
+
*/
|
|
1391
|
+
this.fontSizeList = FONT_SIZE_LIST_DEFAULTS;
|
|
1392
|
+
/**
|
|
1393
|
+
* Specifies a unique ID attribute for the text editor.
|
|
1394
|
+
* By default, the component generates a random ID.
|
|
1395
|
+
*/
|
|
1396
|
+
this.id = `sky-text-editor-${++nextUniqueId}`;
|
|
1397
|
+
/**
|
|
1398
|
+
* Specifies the menus to include in the menu bar.
|
|
1399
|
+
* @default [ 'edit', 'format' ]
|
|
1400
|
+
*/
|
|
1401
|
+
this.menus = MENU_DEFAULTS;
|
|
1402
|
+
/**
|
|
1403
|
+
* Specifies the merge fields to include in the merge field menu.
|
|
1404
|
+
*/
|
|
1405
|
+
this.mergeFields = [];
|
|
1406
|
+
/**
|
|
1407
|
+
* Specifies the actions to include in the toolbar and determines their order.
|
|
1408
|
+
* @default [ 'font-family', 'font-size', 'font-style', 'color', 'list', 'link ]
|
|
1409
|
+
*/
|
|
1410
|
+
this.toolbarActions = TOOLBAR_ACTION_DEFAULTS;
|
|
1411
|
+
this.focusInitialized = false;
|
|
1412
|
+
this.initialized = false;
|
|
1413
|
+
this.ngUnsubscribe = new Subject();
|
|
1414
|
+
this._disabled = false;
|
|
1415
|
+
this._initialStyleState = Object.assign({}, STYLE_STATE_DEFAULTS);
|
|
1416
|
+
this._placeholder = '';
|
|
1417
|
+
this._value = '<p></p>';
|
|
1418
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1419
|
+
this._onTouched = () => { };
|
|
1420
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1421
|
+
this._onChange = () => { };
|
|
1422
|
+
this.ngControl.valueAccessor = this;
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Indicates whether to disable the text editor.
|
|
1426
|
+
* @default false
|
|
1427
|
+
*/
|
|
1428
|
+
set disabled(value) {
|
|
1429
|
+
const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);
|
|
1430
|
+
if (coercedValue !== this.disabled) {
|
|
1431
|
+
this._disabled = coercedValue;
|
|
1432
|
+
// Update focusableChildren inside the iframe.
|
|
1433
|
+
let focusableChildren;
|
|
1434
|
+
/* istanbul ignore else */
|
|
1435
|
+
if (this.iframeRef) {
|
|
1436
|
+
focusableChildren = this.coreAdapterService.getFocusableChildren(this.iframeRef.nativeElement.contentDocument.body, {
|
|
1437
|
+
ignoreVisibility: true,
|
|
1438
|
+
ignoreTabIndex: true,
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
if (this._disabled) {
|
|
1442
|
+
this.adapterService.disableEditor(this.id, focusableChildren, this.iframeRef.nativeElement);
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
this.adapterService.enableEditor(this.id, focusableChildren, this.iframeRef.nativeElement);
|
|
1446
|
+
}
|
|
1447
|
+
this.changeDetector.markForCheck();
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
get disabled() {
|
|
1451
|
+
return this._disabled;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Specifies the initial styles for all content, including background color, font size, and link state.
|
|
1455
|
+
*/
|
|
1456
|
+
set initialStyleState(state) {
|
|
1457
|
+
// Do not update the state after initialization has taken place
|
|
1458
|
+
/* istanbul ignore else */
|
|
1459
|
+
if (!this.initialized) {
|
|
1460
|
+
this._initialStyleState = {
|
|
1461
|
+
...STYLE_STATE_DEFAULTS,
|
|
1462
|
+
...state,
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
get initialStyleState() {
|
|
1467
|
+
return this._initialStyleState;
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Specifies placeholder text to display when the text entry area is empty.
|
|
1471
|
+
*/
|
|
1472
|
+
set placeholder(value) {
|
|
1473
|
+
/* istanbul ignore else */
|
|
1474
|
+
if (value !== this._placeholder) {
|
|
1475
|
+
this._placeholder = value;
|
|
1476
|
+
if (this.initialized) {
|
|
1477
|
+
this.adapterService.setPlaceholder(this.id, value);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
get placeholder() {
|
|
1482
|
+
return this._placeholder;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* The internal value of the control.
|
|
1486
|
+
*/
|
|
1487
|
+
set value(value) {
|
|
1488
|
+
// Normalize value and set any empty state to an empty string.
|
|
1489
|
+
let normalizedValue = value;
|
|
1490
|
+
if (!value ||
|
|
1491
|
+
value.trim() === '<p></p>' ||
|
|
1492
|
+
value.trim() === '<br>' ||
|
|
1493
|
+
value.trim() === '<p><br></p>') {
|
|
1494
|
+
normalizedValue = '';
|
|
1495
|
+
}
|
|
1496
|
+
normalizedValue = this.sanitizationService.sanitize(normalizedValue).trim();
|
|
1497
|
+
if (this._value !== normalizedValue) {
|
|
1498
|
+
this._value = normalizedValue;
|
|
1499
|
+
// Update angular form control if model has been normalized.
|
|
1500
|
+
/* istanbul ignore else */
|
|
1501
|
+
if (this.ngControl && this.ngControl.control) {
|
|
1502
|
+
/* istanbul ignore else */
|
|
1503
|
+
if (normalizedValue !== this.ngControl.control.value) {
|
|
1504
|
+
this.ngControl.control.setValue(normalizedValue, {
|
|
1505
|
+
emitModelToViewChange: false,
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
// Autofocus isn't testable in Firefox and IE.
|
|
1510
|
+
/* istanbul ignore next */
|
|
1511
|
+
if (this.autofocus && !this.focusInitialized) {
|
|
1512
|
+
this.adapterService.focusEditor(this.id);
|
|
1513
|
+
this.focusInitialized = true;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
get value() {
|
|
1518
|
+
return this._value;
|
|
1519
|
+
}
|
|
1520
|
+
ngAfterViewInit() {
|
|
1521
|
+
this.initIframe();
|
|
1522
|
+
}
|
|
1523
|
+
ngOnDestroy() {
|
|
1524
|
+
this.adapterService.removeObservers(this.editorService.editors[this.id]);
|
|
1525
|
+
this.editorService.removeEditor(this.id);
|
|
1526
|
+
this.ngUnsubscribe.next();
|
|
1527
|
+
this.ngUnsubscribe.complete();
|
|
1528
|
+
}
|
|
1529
|
+
onIframeLoad() {
|
|
1530
|
+
// Remove editor if it already exists to cover situations where the text editor might have been moved in the DOM.
|
|
1531
|
+
/* istanbul ignore else */
|
|
1532
|
+
if (this.editorService.editors[this.id]) {
|
|
1533
|
+
this.editorService.removeEditor(this.id);
|
|
1534
|
+
this.initIframe();
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Implemented as part of ControlValueAccessor.
|
|
1539
|
+
*/
|
|
1540
|
+
writeValue(value) {
|
|
1541
|
+
this.value = value;
|
|
1542
|
+
// Update HTML if necessary.
|
|
1543
|
+
const editorValue = this.adapterService.getEditorInnerHtml(this.id);
|
|
1544
|
+
if (this.initialized && editorValue !== this._value) {
|
|
1545
|
+
this.adapterService.setEditorInnerHtml(this.id, this._value);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Implemented as part of ControlValueAccessor.
|
|
1550
|
+
*/
|
|
1551
|
+
registerOnChange(fn) {
|
|
1552
|
+
this._onChange = fn;
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Implemented as part of ControlValueAccessor.
|
|
1556
|
+
*/
|
|
1557
|
+
registerOnTouched(fn) {
|
|
1558
|
+
this._onTouched = fn;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Implemented as part of ControlValueAccessor.
|
|
1562
|
+
*/
|
|
1563
|
+
setDisabledState(isDisabled) {
|
|
1564
|
+
this.disabled = isDisabled;
|
|
1565
|
+
}
|
|
1566
|
+
updateStyle() {
|
|
1567
|
+
this._initialStyleState = {
|
|
1568
|
+
...this._initialStyleState,
|
|
1569
|
+
...this.adapterService.getStyleState(this.id),
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
initIframe() {
|
|
1573
|
+
this.adapterService.addEditor(this.id, this.iframeRef.nativeElement, this.initialStyleState, this.placeholder);
|
|
1574
|
+
this.editorService
|
|
1575
|
+
.inputListener(this.id)
|
|
1576
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1577
|
+
.subscribe(() => {
|
|
1578
|
+
// Angular doesn't run change detection for changes originating inside an iframe,
|
|
1579
|
+
// so we have to call the onChange() event inside NgZone to force change propigation to consuming components.
|
|
1580
|
+
this.zone.run(() => {
|
|
1581
|
+
this.ViewToModelUpdate();
|
|
1582
|
+
});
|
|
1583
|
+
});
|
|
1584
|
+
this.editorService
|
|
1585
|
+
.selectionChangeListener(this.id)
|
|
1586
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1587
|
+
.subscribe(() => {
|
|
1588
|
+
this.updateStyle();
|
|
1589
|
+
this.editorFocusStream.next();
|
|
1590
|
+
});
|
|
1591
|
+
this.editorService
|
|
1592
|
+
.clickListener(this.id)
|
|
1593
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1594
|
+
.subscribe(() => {
|
|
1595
|
+
this.editorFocusStream.next();
|
|
1596
|
+
});
|
|
1597
|
+
this.editorService
|
|
1598
|
+
.blurListener(this.id)
|
|
1599
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1600
|
+
.subscribe(() => {
|
|
1601
|
+
// Angular doesn't run change detection for changes originating inside an iframe,
|
|
1602
|
+
// so we have to run markForCheck() inside the NgZone to force change propigation to consuming components.
|
|
1603
|
+
this.zone.run(() => {
|
|
1604
|
+
this._onTouched();
|
|
1605
|
+
});
|
|
1606
|
+
});
|
|
1607
|
+
this.editorService
|
|
1608
|
+
.commandChangeListener(this.id)
|
|
1609
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
1610
|
+
.subscribe(() => {
|
|
1611
|
+
this.updateStyle();
|
|
1612
|
+
this.ViewToModelUpdate();
|
|
1613
|
+
});
|
|
1614
|
+
this.adapterService.setEditorInnerHtml(this.id, this._value);
|
|
1615
|
+
/* istanbul ignore next */
|
|
1616
|
+
if (this.autofocus) {
|
|
1617
|
+
this.adapterService.focusEditor(this.id);
|
|
1618
|
+
}
|
|
1619
|
+
this.initialized = true;
|
|
1620
|
+
}
|
|
1621
|
+
ViewToModelUpdate(emitChange = true) {
|
|
1622
|
+
this.value = this.adapterService.getEditorInnerHtml(this.id);
|
|
1623
|
+
/* istanbul ignore else */
|
|
1624
|
+
if (emitChange) {
|
|
1625
|
+
this._onChange(this._value);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
SkyTextEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i3.SkyCoreAdapterService }, { token: SkyTextEditorAdapterService }, { token: SkyTextEditorService }, { token: SkyTextSanitizationService }, { token: i5$1.NgControl }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
1630
|
+
SkyTextEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", 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: i3$1.λ37, selector: "sky-toolbar" }, { type: i3$1.λ38, selector: "sky-toolbar-section" }, { type: SkyTextEditorMenubarComponent, selector: "sky-text-editor-menubar", inputs: ["editorFocusStream", "editorId", "menus", "mergeFields", "disabled"] }, { type: SkyTextEditorToolbarComponent, selector: "sky-text-editor-toolbar", inputs: ["editorFocusStream", "editorId", "fontList", "fontSizeList", "toolbarActions", "styleState", "disabled"] }], directives: [{ type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1631
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorComponent, decorators: [{
|
|
1632
|
+
type: Component,
|
|
1633
|
+
args: [{ selector: 'sky-text-editor', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, 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"] }]
|
|
1634
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i3.SkyCoreAdapterService }, { type: SkyTextEditorAdapterService }, { type: SkyTextEditorService }, { type: SkyTextSanitizationService }, { type: i5$1.NgControl }, { type: i0.NgZone }]; }, propDecorators: { autofocus: [{
|
|
1635
|
+
type: Input
|
|
1636
|
+
}], disabled: [{
|
|
1637
|
+
type: Input
|
|
1638
|
+
}], fontList: [{
|
|
1639
|
+
type: Input
|
|
1640
|
+
}], fontSizeList: [{
|
|
1641
|
+
type: Input
|
|
1642
|
+
}], id: [{
|
|
1643
|
+
type: Input
|
|
1644
|
+
}], initialStyleState: [{
|
|
1645
|
+
type: Input
|
|
1646
|
+
}], menus: [{
|
|
1647
|
+
type: Input
|
|
1648
|
+
}], mergeFields: [{
|
|
1649
|
+
type: Input
|
|
1650
|
+
}], placeholder: [{
|
|
1651
|
+
type: Input
|
|
1652
|
+
}], toolbarActions: [{
|
|
1653
|
+
type: Input
|
|
1654
|
+
}], iframeRef: [{
|
|
1655
|
+
type: ViewChild,
|
|
1656
|
+
args: ['iframe']
|
|
1657
|
+
}] } });
|
|
1658
|
+
|
|
1659
|
+
class SkyTextEditorModule {
|
|
1660
|
+
}
|
|
1661
|
+
SkyTextEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1662
|
+
SkyTextEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorModule, declarations: [SkyTextEditorComponent,
|
|
1663
|
+
SkyTextEditorUrlModalComponent,
|
|
1664
|
+
SkyTextEditorToolbarComponent,
|
|
1665
|
+
SkyTextEditorMenubarComponent], imports: [CommonModule,
|
|
1666
|
+
FormsModule,
|
|
1667
|
+
ReactiveFormsModule,
|
|
1668
|
+
SkyCoreAdapterModule,
|
|
1669
|
+
SkyTextEditorResourcesModule,
|
|
1670
|
+
SkyI18nModule,
|
|
1671
|
+
SkyIconModule,
|
|
1672
|
+
SkyIdModule,
|
|
1673
|
+
SkyInputBoxModule,
|
|
1674
|
+
SkyColorpickerModule,
|
|
1675
|
+
SkyCheckboxModule,
|
|
1676
|
+
SkyDropdownModule,
|
|
1677
|
+
SkyModalModule,
|
|
1678
|
+
SkyTabsModule,
|
|
1679
|
+
SkyThemeModule,
|
|
1680
|
+
SkyToolbarModule], exports: [SkyTextEditorComponent,
|
|
1681
|
+
SkyTextEditorUrlModalComponent,
|
|
1682
|
+
SkyTextEditorToolbarComponent,
|
|
1683
|
+
SkyTextEditorMenubarComponent] });
|
|
1684
|
+
SkyTextEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorModule, imports: [[
|
|
1685
|
+
CommonModule,
|
|
1686
|
+
FormsModule,
|
|
1687
|
+
ReactiveFormsModule,
|
|
1688
|
+
SkyCoreAdapterModule,
|
|
1689
|
+
SkyTextEditorResourcesModule,
|
|
1690
|
+
SkyI18nModule,
|
|
1691
|
+
SkyIconModule,
|
|
1692
|
+
SkyIdModule,
|
|
1693
|
+
SkyInputBoxModule,
|
|
1694
|
+
SkyColorpickerModule,
|
|
1695
|
+
SkyCheckboxModule,
|
|
1696
|
+
SkyDropdownModule,
|
|
1697
|
+
SkyModalModule,
|
|
1698
|
+
SkyTabsModule,
|
|
1699
|
+
SkyThemeModule,
|
|
1700
|
+
SkyToolbarModule,
|
|
1701
|
+
]] });
|
|
1702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyTextEditorModule, decorators: [{
|
|
1703
|
+
type: NgModule,
|
|
1704
|
+
args: [{
|
|
1705
|
+
imports: [
|
|
1706
|
+
CommonModule,
|
|
1707
|
+
FormsModule,
|
|
1708
|
+
ReactiveFormsModule,
|
|
1709
|
+
SkyCoreAdapterModule,
|
|
1710
|
+
SkyTextEditorResourcesModule,
|
|
1711
|
+
SkyI18nModule,
|
|
1712
|
+
SkyIconModule,
|
|
1713
|
+
SkyIdModule,
|
|
1714
|
+
SkyInputBoxModule,
|
|
1715
|
+
SkyColorpickerModule,
|
|
1716
|
+
SkyCheckboxModule,
|
|
1717
|
+
SkyDropdownModule,
|
|
1718
|
+
SkyModalModule,
|
|
1719
|
+
SkyTabsModule,
|
|
1720
|
+
SkyThemeModule,
|
|
1721
|
+
SkyToolbarModule,
|
|
1722
|
+
],
|
|
1723
|
+
exports: [
|
|
1724
|
+
SkyTextEditorComponent,
|
|
1725
|
+
SkyTextEditorUrlModalComponent,
|
|
1726
|
+
SkyTextEditorToolbarComponent,
|
|
1727
|
+
SkyTextEditorMenubarComponent,
|
|
1728
|
+
],
|
|
1729
|
+
declarations: [
|
|
1730
|
+
SkyTextEditorComponent,
|
|
1731
|
+
SkyTextEditorUrlModalComponent,
|
|
1732
|
+
SkyTextEditorToolbarComponent,
|
|
1733
|
+
SkyTextEditorMenubarComponent,
|
|
1734
|
+
],
|
|
1735
|
+
}]
|
|
1736
|
+
}] });
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Generated bundle index. Do not edit.
|
|
1740
|
+
*/
|
|
1741
|
+
|
|
1742
|
+
export { SkyRichTextDisplayModule, SkyTextEditorModule, SkyRichTextDisplayComponent as λ1, SkyTextEditorMenubarComponent as λ2, SkyTextEditorUrlModalComponent as λ3, SkyTextEditorToolbarComponent as λ4, SkyTextEditorComponent as λ5 };
|
|
1743
|
+
//# sourceMappingURL=skyux-text-editor.mjs.map
|