@firestitch/html-editor 9.4.5 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/app/classes/plugin.d.ts +7 -7
  2. package/app/components/html-editor/html-editor.component.d.ts +51 -51
  3. package/app/components/html-renderer/html-renderer.component.d.ts +9 -9
  4. package/app/consts/paragraph-buttons.const.d.ts +1 -1
  5. package/app/consts/rich-buttons.const.d.ts +1 -1
  6. package/app/consts/text-buttons.const.d.ts +1 -1
  7. package/app/enums/default-plugin.enum.d.ts +13 -14
  8. package/app/fs-html-editor.module.d.ts +25 -25
  9. package/app/injects/config.inject.d.ts +3 -3
  10. package/app/interfaces/html-editor-config.d.ts +31 -25
  11. package/app/interfaces/plugin-button.d.ts +12 -12
  12. package/app/interfaces/plugin-config.d.ts +5 -5
  13. package/app/plugins/checklist.plugin.d.ts +7 -7
  14. package/app/plugins/code.plugin.d.ts +9 -9
  15. package/app/plugins/configs/mention-plugin.config.d.ts +12 -12
  16. package/app/plugins/configs/screen-record-plugin.config.d.ts +7 -7
  17. package/app/plugins/mention.plugin.d.ts +12 -12
  18. package/app/plugins/screen-record.plugin.d.ts +11 -11
  19. package/app/services/froala-loader.service.d.ts +17 -17
  20. package/app/utils/loader.d.ts +7 -7
  21. package/bundles/firestitch-html-editor.umd.js +1000 -994
  22. package/bundles/firestitch-html-editor.umd.js.map +1 -1
  23. package/bundles/firestitch-html-editor.umd.min.js +2 -2
  24. package/bundles/firestitch-html-editor.umd.min.js.map +1 -1
  25. package/esm2015/app/classes/plugin.js +4 -4
  26. package/esm2015/app/components/html-editor/html-editor.component.js +431 -423
  27. package/esm2015/app/components/html-renderer/html-renderer.component.js +33 -33
  28. package/esm2015/app/consts/paragraph-buttons.const.js +8 -8
  29. package/esm2015/app/consts/rich-buttons.const.js +6 -6
  30. package/esm2015/app/consts/text-buttons.const.js +18 -18
  31. package/esm2015/app/enums/default-plugin.enum.js +1 -1
  32. package/esm2015/app/fs-html-editor.module.js +56 -57
  33. package/esm2015/app/injects/config.inject.js +3 -3
  34. package/esm2015/app/interfaces/html-editor-config.js +1 -1
  35. package/esm2015/app/plugins/checklist.plugin.js +34 -34
  36. package/esm2015/app/plugins/code.plugin.js +62 -62
  37. package/esm2015/app/plugins/mention.plugin.js +72 -72
  38. package/esm2015/app/plugins/screen-record.plugin.js +91 -91
  39. package/esm2015/app/services/froala-loader.service.js +80 -80
  40. package/esm2015/app/utils/loader.js +82 -83
  41. package/esm2015/firestitch-html-editor.js +8 -8
  42. package/esm2015/public_api.js +11 -11
  43. package/esm5/app/classes/plugin.js +8 -8
  44. package/esm5/app/components/html-editor/html-editor.component.js +455 -446
  45. package/esm5/app/components/html-renderer/html-renderer.component.js +38 -38
  46. package/esm5/app/consts/paragraph-buttons.const.js +8 -8
  47. package/esm5/app/consts/rich-buttons.const.js +6 -6
  48. package/esm5/app/consts/text-buttons.const.js +18 -18
  49. package/esm5/app/enums/default-plugin.enum.js +1 -1
  50. package/esm5/app/fs-html-editor.module.js +61 -62
  51. package/esm5/app/injects/config.inject.js +3 -3
  52. package/esm5/app/interfaces/html-editor-config.js +1 -1
  53. package/esm5/app/plugins/checklist.plugin.js +40 -40
  54. package/esm5/app/plugins/code.plugin.js +69 -69
  55. package/esm5/app/plugins/mention.plugin.js +78 -78
  56. package/esm5/app/plugins/screen-record.plugin.js +105 -105
  57. package/esm5/app/services/froala-loader.service.js +95 -95
  58. package/esm5/app/utils/loader.js +82 -83
  59. package/esm5/firestitch-html-editor.js +8 -8
  60. package/esm5/public_api.js +11 -11
  61. package/fesm2015/firestitch-html-editor.js +922 -916
  62. package/fesm2015/firestitch-html-editor.js.map +1 -1
  63. package/fesm5/firestitch-html-editor.js +1000 -993
  64. package/fesm5/firestitch-html-editor.js.map +1 -1
  65. package/firestitch-html-editor.d.ts +9 -9
  66. package/firestitch-html-editor.metadata.json +1 -1
  67. package/package.json +1 -1
  68. package/public_api.d.ts +16 -16
@@ -3,1032 +3,1039 @@ import { InjectionToken, Optional, Inject, ɵɵdefineInjectable, ɵɵinject, Inj
3
3
  import { CommonModule } from '@angular/common';
4
4
  import { FsSkeletonModule } from '@firestitch/skeleton';
5
5
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
6
+ import { FileProcessor, FsFile } from '@firestitch/file';
6
7
  import { Observable, BehaviorSubject, combineLatest, ReplaySubject, Subject } from 'rxjs';
7
- import { shareReplay, map, tap, concatMap, takeUntil, filter, switchMap } from 'rxjs/operators';
8
+ import { shareReplay, map, tap, concatMap, takeUntil, switchMap, filter } from 'rxjs/operators';
8
9
  import { merge, debounce } from 'lodash-es';
9
10
  import { DomSanitizer } from '@angular/platform-browser';
10
11
  import Tribute from 'tributejs';
11
12
 
12
- var RichButtons = [
13
- 'insertTable',
14
- 'insertImage',
15
- 'insertLink',
16
- 'insertVideo',
13
+ var RichButtons = [
14
+ 'insertTable',
15
+ 'insertImage',
16
+ 'insertLink',
17
+ 'insertVideo',
17
18
  ];
18
19
 
19
- var TextButtons = [
20
- 'paragraphFormat',
21
- 'code',
22
- 'bold',
23
- 'italic',
24
- 'underline',
25
- 'strikeThrough',
26
- 'subscript',
27
- 'superscript',
28
- 'fontFamily',
29
- 'fontSize',
30
- 'textColor',
31
- 'backgroundColor',
32
- 'inlineClass',
33
- 'inlineStyle',
34
- 'clearFormatting',
35
- 'quote',
20
+ var TextButtons = [
21
+ 'paragraphFormat',
22
+ 'code',
23
+ 'bold',
24
+ 'italic',
25
+ 'underline',
26
+ 'strikeThrough',
27
+ 'subscript',
28
+ 'superscript',
29
+ 'fontFamily',
30
+ 'fontSize',
31
+ 'textColor',
32
+ 'backgroundColor',
33
+ 'inlineClass',
34
+ 'inlineStyle',
35
+ 'clearFormatting',
36
+ 'quote',
36
37
  ];
37
38
 
38
- var ParagraphButtons = [
39
- 'align',
40
- 'formatOL',
41
- 'formatUL',
42
- 'checklist',
43
- 'indent',
44
- 'outdent',
39
+ var ParagraphButtons = [
40
+ 'align',
41
+ 'formatOL',
42
+ 'formatUL',
43
+ 'checklist',
44
+ 'indent',
45
+ 'outdent',
45
46
  ];
46
47
 
47
- var FS_HTML_EDITOR_DEFAULT_CONFIG = new InjectionToken('fs-html-editor.default-config');
48
+ var FS_HTML_EDITOR_DEFAULT_CONFIG = new InjectionToken('fs-html-editor.default-config');
48
49
  var FS_HTML_EDITOR_CONFIG = new InjectionToken('fs-html-editor.config');
49
50
 
50
- function resourceLoaderFactory() {
51
- var resourceBase = '/assets/js/froala/';
52
- var stylesBase = '/assets/css/';
53
- var head = document.getElementsByTagName('head')[0];
54
- var files = new Map();
55
- var resourcePaths = {
56
- froala: 'froala_editor.min.js',
57
- align: 'plugins/align.min.js',
58
- colors: 'plugins/colors.min.js',
59
- image: 'plugins/image.min.js',
60
- link: 'plugins/link.min.js',
61
- lists: 'plugins/lists.min.js',
62
- paragraph_format: 'plugins/paragraph_format.min.js',
63
- table: 'plugins/table.min.js',
64
- url: 'plugins/url.min.js',
65
- video: 'plugins/video.min.js',
66
- quote: 'plugins/quote.min.js',
67
- draggable: 'plugins/draggable.min.js',
68
- font_size: 'plugins/font_size.min.js',
69
- };
70
- var stylesPaths = {
71
- froala: 'froala_editor.pkgd.min.css',
72
- };
73
- var loadResource = function (scriptPath) {
74
- if (!files.has(scriptPath)) {
75
- var obs$ = new Observable(function (obs) {
76
- var script = document.createElement('script');
77
- script.src = scriptPath;
78
- head.appendChild(script);
79
- script.onload = function () {
80
- obs.next();
81
- obs.complete();
82
- };
83
- script.onerror = function (err) {
84
- obs.error(err);
85
- };
86
- })
87
- .pipe(shareReplay(1));
88
- files.set(scriptPath, obs$);
89
- }
90
- return files.get(scriptPath);
91
- };
92
- var loadStyles = function (stylePath) {
93
- if (!files.has(stylePath)) {
94
- var obs$ = new Observable(function (obs) {
95
- var style = document.createElement('link');
96
- style.id = stylePath;
97
- style.rel = 'stylesheet';
98
- style.href = "" + stylePath;
99
- head.appendChild(style);
100
- style.onload = function () {
101
- obs.next();
102
- obs.complete();
103
- };
104
- style.onerror = function (err) {
105
- obs.error(err);
106
- };
107
- });
108
- files.set(stylePath, obs$);
109
- }
110
- return files.get(stylePath);
111
- };
112
- return {
113
- setResourceBase: function (path) {
114
- resourceBase = path;
115
- },
116
- setStylesBase: function (path) {
117
- stylesBase = path;
118
- },
119
- loadResource: function (resourceName) {
120
- var path = resourcePaths[resourceName] || resourceName;
121
- return loadResource(resourceBase + path);
122
- },
123
- loadStyles: function (resourceName) {
124
- var path = stylesPaths[resourceName] || resourceName;
125
- return loadStyles(stylesBase + path);
126
- }
127
- };
128
- }
51
+ function resourceLoaderFactory() {
52
+ var resourceBase = '/assets/js/froala/';
53
+ var stylesBase = '/assets/css/';
54
+ var head = document.getElementsByTagName('head')[0];
55
+ var files = new Map();
56
+ var resourcePaths = {
57
+ froala: 'froala_editor.min.js',
58
+ align: 'plugins/align.min.js',
59
+ colors: 'plugins/colors.min.js',
60
+ image: 'plugins/image.min.js',
61
+ link: 'plugins/link.min.js',
62
+ lists: 'plugins/lists.min.js',
63
+ paragraph_format: 'plugins/paragraph_format.min.js',
64
+ table: 'plugins/table.min.js',
65
+ url: 'plugins/url.min.js',
66
+ video: 'plugins/video.min.js',
67
+ quote: 'plugins/quote.min.js',
68
+ draggable: 'plugins/draggable.min.js',
69
+ };
70
+ var stylesPaths = {
71
+ froala: 'froala_editor.pkgd.min.css',
72
+ };
73
+ var loadResource = function (scriptPath) {
74
+ if (!files.has(scriptPath)) {
75
+ var obs$ = new Observable(function (obs) {
76
+ var script = document.createElement('script');
77
+ script.src = scriptPath;
78
+ head.appendChild(script);
79
+ script.onload = function () {
80
+ obs.next();
81
+ obs.complete();
82
+ };
83
+ script.onerror = function (err) {
84
+ obs.error(err);
85
+ };
86
+ })
87
+ .pipe(shareReplay(1));
88
+ files.set(scriptPath, obs$);
89
+ }
90
+ return files.get(scriptPath);
91
+ };
92
+ var loadStyles = function (stylePath) {
93
+ if (!files.has(stylePath)) {
94
+ var obs$ = new Observable(function (obs) {
95
+ var style = document.createElement('link');
96
+ style.id = stylePath;
97
+ style.rel = 'stylesheet';
98
+ style.href = "" + stylePath;
99
+ head.appendChild(style);
100
+ style.onload = function () {
101
+ obs.next();
102
+ obs.complete();
103
+ };
104
+ style.onerror = function (err) {
105
+ obs.error(err);
106
+ };
107
+ });
108
+ files.set(stylePath, obs$);
109
+ }
110
+ return files.get(stylePath);
111
+ };
112
+ return {
113
+ setResourceBase: function (path) {
114
+ resourceBase = path;
115
+ },
116
+ setStylesBase: function (path) {
117
+ stylesBase = path;
118
+ },
119
+ loadResource: function (resourceName) {
120
+ var path = resourcePaths[resourceName] || resourceName;
121
+ return loadResource(resourceBase + path);
122
+ },
123
+ loadStyles: function (resourceName) {
124
+ var path = stylesPaths[resourceName] || resourceName;
125
+ return loadStyles(stylesBase + path);
126
+ }
127
+ };
128
+ }
129
129
  var ResourceLoader = resourceLoaderFactory();
130
130
 
131
- var FsFroalaLoaderService = /** @class */ (function () {
132
- function FsFroalaLoaderService(_defaultConfig) {
133
- this._defaultConfig = _defaultConfig;
134
- this._froalaLoaded = new BehaviorSubject(false);
135
- this._defaultPluginsLoaded = new BehaviorSubject(false);
136
- this._ready$ = combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
137
- .pipe(map(function (_a) {
138
- var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
139
- return pluginsRead && FroalaReady;
140
- }), shareReplay(1));
141
- if (this._defaultConfig) {
142
- if (this._defaultConfig.assetsJSPath) {
143
- ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
144
- }
145
- if (this._defaultConfig.assetsCSSPath) {
146
- ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
147
- }
148
- }
149
- this._load();
150
- }
151
- Object.defineProperty(FsFroalaLoaderService.prototype, "ready$", {
152
- get: function () {
153
- return this._ready$;
154
- },
155
- enumerable: true,
156
- configurable: true
157
- });
158
- Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
159
- get: function () {
160
- return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
161
- },
162
- enumerable: true,
163
- configurable: true
164
- });
165
- Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
166
- get: function () {
167
- return this._FroalaEditor;
168
- },
169
- enumerable: true,
170
- configurable: true
171
- });
172
- FsFroalaLoaderService.prototype._load = function () {
173
- var _this = this;
174
- combineLatest([
175
- ResourceLoader.loadResource('froala'),
176
- ResourceLoader.loadStyles('froala')
177
- ])
178
- .pipe(tap(function () {
179
- _this._FroalaEditor = window.FroalaEditor;
180
- _this._froalaDone();
181
- }), concatMap(function () {
182
- return _this._loadPlugins();
183
- }), tap(function () {
184
- _this._defaultPluginsDone();
185
- }))
186
- .subscribe();
187
- };
188
- FsFroalaLoaderService.prototype._loadPlugins = function () {
189
- var imports = this._defaultConfig
190
- .defaultPlugins
191
- .reduce(function (acc, pluginName) {
192
- var import$ = ResourceLoader.loadResource(pluginName);
193
- acc.push(import$);
194
- return acc;
195
- }, []);
196
- return combineLatest(imports);
197
- };
198
- FsFroalaLoaderService.prototype._froalaDone = function () {
199
- this._froalaLoaded.next(true);
200
- };
201
- FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
202
- this._defaultPluginsLoaded.next(true);
203
- };
204
- FsFroalaLoaderService.ctorParameters = function () { return [
205
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
206
- ]; };
207
- FsFroalaLoaderService.ɵprov = ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
208
- FsFroalaLoaderService = __decorate([
209
- Injectable({
210
- providedIn: 'root',
211
- }),
212
- __param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
213
- __metadata("design:paramtypes", [Object])
214
- ], FsFroalaLoaderService);
215
- return FsFroalaLoaderService;
131
+ var FsFroalaLoaderService = /** @class */ (function () {
132
+ function FsFroalaLoaderService(_defaultConfig) {
133
+ this._defaultConfig = _defaultConfig;
134
+ this._froalaLoaded = new BehaviorSubject(false);
135
+ this._defaultPluginsLoaded = new BehaviorSubject(false);
136
+ this._ready$ = combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
137
+ .pipe(map(function (_a) {
138
+ var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
139
+ return pluginsRead && FroalaReady;
140
+ }), shareReplay(1));
141
+ if (this._defaultConfig) {
142
+ if (this._defaultConfig.assetsJSPath) {
143
+ ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
144
+ }
145
+ if (this._defaultConfig.assetsCSSPath) {
146
+ ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
147
+ }
148
+ }
149
+ this._load();
150
+ }
151
+ Object.defineProperty(FsFroalaLoaderService.prototype, "ready$", {
152
+ get: function () {
153
+ return this._ready$;
154
+ },
155
+ enumerable: true,
156
+ configurable: true
157
+ });
158
+ Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
159
+ get: function () {
160
+ return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
161
+ },
162
+ enumerable: true,
163
+ configurable: true
164
+ });
165
+ Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
166
+ get: function () {
167
+ return this._FroalaEditor;
168
+ },
169
+ enumerable: true,
170
+ configurable: true
171
+ });
172
+ FsFroalaLoaderService.prototype._load = function () {
173
+ var _this = this;
174
+ combineLatest([
175
+ ResourceLoader.loadResource('froala'),
176
+ ResourceLoader.loadStyles('froala')
177
+ ])
178
+ .pipe(tap(function () {
179
+ _this._FroalaEditor = window.FroalaEditor;
180
+ _this._froalaDone();
181
+ }), concatMap(function () {
182
+ return _this._loadPlugins();
183
+ }), tap(function () {
184
+ _this._defaultPluginsDone();
185
+ }))
186
+ .subscribe();
187
+ };
188
+ FsFroalaLoaderService.prototype._loadPlugins = function () {
189
+ var imports = this._defaultConfig
190
+ .defaultPlugins
191
+ .reduce(function (acc, pluginName) {
192
+ var import$ = ResourceLoader.loadResource(pluginName);
193
+ acc.push(import$);
194
+ return acc;
195
+ }, []);
196
+ return combineLatest(imports);
197
+ };
198
+ FsFroalaLoaderService.prototype._froalaDone = function () {
199
+ this._froalaLoaded.next(true);
200
+ };
201
+ FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
202
+ this._defaultPluginsLoaded.next(true);
203
+ };
204
+ FsFroalaLoaderService.ctorParameters = function () { return [
205
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
206
+ ]; };
207
+ FsFroalaLoaderService.ɵprov = ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
208
+ FsFroalaLoaderService = __decorate([
209
+ Injectable({
210
+ providedIn: 'root',
211
+ }),
212
+ __param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
213
+ __metadata("design:paramtypes", [Object])
214
+ ], FsFroalaLoaderService);
215
+ return FsFroalaLoaderService;
216
216
  }());
217
217
 
218
- var FsHtmlEditorComponent = /** @class */ (function () {
219
- function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
220
- this._defaultConfig = _defaultConfig;
221
- this._cdRef = _cdRef;
222
- this._fr = _fr;
223
- this.classFocused = false;
224
- this.classDisabled = false;
225
- this.config = {};
226
- this.initialized = false;
227
- this._initialize$ = new ReplaySubject();
228
- this._destroy$ = new Subject();
229
- this.onChange = function (data) { };
230
- this.onTouched = function () { };
231
- }
232
- FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
233
- Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
234
- get: function () {
235
- return this.elRef.nativeElement;
236
- },
237
- enumerable: true,
238
- configurable: true
239
- });
240
- Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
241
- get: function () {
242
- return this._html;
243
- },
244
- enumerable: true,
245
- configurable: true
246
- });
247
- Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
248
- get: function () {
249
- return this._editor;
250
- },
251
- enumerable: true,
252
- configurable: true
253
- });
254
- Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaReady$", {
255
- get: function () {
256
- return this._fr.ready$;
257
- },
258
- enumerable: true,
259
- configurable: true
260
- });
261
- FsHtmlEditorComponent.prototype.ngOnInit = function () {
262
- this.config = this.config || {};
263
- this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
264
- this.initialized = !this.config.initOnClick;
265
- this._listenLazyInit();
266
- };
267
- FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
268
- if (!this.config.initOnClick || !this.hasContent()) {
269
- this.initialized = true;
270
- this._initialize$.next();
271
- }
272
- };
273
- FsHtmlEditorComponent.prototype.hasContent = function () {
274
- var el = document.createElement('div');
275
- if (el.querySelector('img')) {
276
- return true;
277
- }
278
- el.innerHTML = this._html;
279
- return !!el.innerText.length;
280
- };
281
- FsHtmlEditorComponent.prototype.initialize = function (options) {
282
- var _this = this;
283
- if (options === void 0) { options = {}; }
284
- var config = this._createConfig();
285
- this._initPlugins(config);
286
- this.el.innerHTML = this._html;
287
- this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
288
- _this._cdRef.markForCheck();
289
- if (config.disabled) {
290
- _this.disable();
291
- }
292
- if (config.froalaConfig.events) {
293
- if (config.froalaConfig.events.initialized) {
294
- config.froalaConfig.events.initialized();
295
- }
296
- }
297
- _this._editor.events.on('focus', function () {
298
- _this.classFocused = true;
299
- _this._cdRef.markForCheck();
300
- });
301
- _this._editor.events.on('blur', function () {
302
- _this.classFocused = false;
303
- _this._cdRef.markForCheck();
304
- });
305
- _this._editor.events.on('contentChanged', function () {
306
- var editorHTML = _this._editor.html.get();
307
- if (_this.html !== editorHTML) {
308
- _this._change(editorHTML);
309
- }
310
- });
311
- _this._editor.events.on('paste.afterCleanup', function (html) {
312
- var div = document.createElement('div');
313
- div.innerHTML = html;
314
- div.querySelectorAll('*')
315
- .forEach(function (el) {
316
- for (var i = 0; i < el.attributes.length; i++) {
317
- var name_1 = el.attributes[0].name;
318
- if (name_1 !== 'href') {
319
- el.removeAttribute(name_1);
320
- }
321
- }
322
- });
323
- return div.innerHTML;
324
- });
325
- _this._editor.events.on('keydown', function () {
326
- _this.onTouched();
327
- });
328
- if (_this.config.image && _this.config.image.upload) {
329
- _this._editor.events.on('image.beforePasteUpload', function (image) {
330
- fetch(image.getAttribute('src'))
331
- .then(function (res) {
332
- res.blob()
333
- .then(function (blob) {
334
- _this._processImageUpload(blob)
335
- .subscribe(function (url) {
336
- image.setAttribute('src', url);
337
- image.removeAttribute('data-fr-image-pasted');
338
- });
339
- });
340
- });
341
- return false;
342
- });
343
- _this._editor.events.on('image.beforeUpload', function (blobs) {
344
- _this._processImageUpload(blobs[0]).subscribe(function (url) {
345
- _this.editor.image.insert(url, null, null, _this.editor.image.get());
346
- });
347
- return false;
348
- });
349
- }
350
- if (_this.el.querySelector('.fr-second-toolbar')) {
351
- _this.el.querySelector('.fr-second-toolbar').remove();
352
- }
353
- var selection = options.selection;
354
- if (selection) {
355
- var node = Array.from(_this.el.querySelectorAll('.fr-element *')).find(function (node) {
356
- return selection.node === node.textContent;
357
- });
358
- if (node) {
359
- var range = document.createRange();
360
- var sel = window.getSelection();
361
- range.setStart(_this._getTextNode(node), selection.offset);
362
- range.collapse(true);
363
- sel.removeAllRanges();
364
- sel.addRange(range);
365
- }
366
- else if (_this.config.autofocus) {
367
- _this.focus();
368
- }
369
- }
370
- else if (_this.config.autofocus) {
371
- _this.focus();
372
- }
373
- });
374
- };
375
- FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
376
- return this.config.image.upload(blob)
377
- .pipe(takeUntil(this._destroy$));
378
- };
379
- FsHtmlEditorComponent.prototype._getTextNode = function (node) {
380
- if (node) {
381
- if (node.nodeType === Node.TEXT_NODE) {
382
- return node;
383
- }
384
- if (node.childNodes) {
385
- return this._getTextNode(node.childNodes[0]);
386
- }
387
- }
388
- };
389
- FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
390
- if (!event.defaultPrevented) {
391
- var target_1 = event.target;
392
- if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
393
- var targetTarget_1 = target_1.getAttribute('target');
394
- target_1.setAttribute('target', '_blank');
395
- setTimeout(function () {
396
- if (targetTarget_1) {
397
- target_1.setAttribute('target', targetTarget_1);
398
- }
399
- else {
400
- target_1.removeAttribute('target');
401
- }
402
- });
403
- }
404
- else {
405
- if (this.config.initClick) {
406
- this.config.initClick(event);
407
- }
408
- this._initialize$.next();
409
- this.initialized = true;
410
- }
411
- }
412
- };
413
- FsHtmlEditorComponent.prototype.updateSize = function () {
414
- // Hack: To trigger the toolbar button size modes
415
- window.dispatchEvent(new Event('resize'));
416
- };
417
- FsHtmlEditorComponent.prototype.validate = function (control) {
418
- var err = {};
419
- if (this.config.maxLength && this._html) {
420
- var maxLength = this.config.maxLength;
421
- var length_1 = this._html.length;
422
- if (length_1 > maxLength) {
423
- err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
424
- }
425
- }
426
- return Object.keys(err).length ? err : null;
427
- };
428
- FsHtmlEditorComponent.prototype.focus = function (options) {
429
- options = options ? options : {};
430
- if (options.cursorPosition === 'end') {
431
- this.editor.selection.setAtEnd(this.editor.$el.get(0));
432
- }
433
- else {
434
- this.editor.selection.setAtStart(this.editor.$el.get(0));
435
- }
436
- this.editor.selection.restore();
437
- var elSelection = this.editor.selection.element();
438
- if (elSelection) {
439
- elSelection.scrollIntoView({ block: 'center' });
440
- }
441
- };
442
- FsHtmlEditorComponent.prototype.clear = function () {
443
- this.writeValue('');
444
- };
445
- FsHtmlEditorComponent.prototype.disable = function () {
446
- this.classDisabled = true;
447
- };
448
- FsHtmlEditorComponent.prototype.setHtml = function (html) {
449
- this.writeValue(html);
450
- };
451
- FsHtmlEditorComponent.prototype.writeValue = function (html) {
452
- var _this = this;
453
- this._html = html || '';
454
- this._cdRef.markForCheck();
455
- // SP-T2298 timeout needed for the case, when froala was already initated and
456
- // second instance opened in dialog/drawer. In this case init step pass much faster, writeValue trigger
457
- // after init and froala ignore new html. At the same time froala was initied but editor not yet, and next
458
- // code doesn't work without timeout. We've got time range when too late for initiate value, and to early
459
- // for change event.
460
- setTimeout(function () {
461
- if (_this.editor && _this.editor.html) {
462
- try {
463
- _this.editor.html.set(_this._html);
464
- }
465
- catch (e) {
466
- }
467
- }
468
- });
469
- };
470
- FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
471
- this.onChange = fn;
472
- };
473
- FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
474
- this.onTouched = fn;
475
- };
476
- FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
477
- this._initialize$.complete();
478
- this._destroy$.next();
479
- this._destroy$.complete();
480
- this.destroy();
481
- };
482
- FsHtmlEditorComponent.prototype.destroy = function () {
483
- if (this.editor) {
484
- this.editor.destroy();
485
- }
486
- this.initialized = false;
487
- this._cdRef.markForCheck();
488
- this.el.innerHTML = '';
489
- };
490
- FsHtmlEditorComponent.prototype._createConfig = function () {
491
- return merge({ froalaConfig: {} }, this._defaultConfig, this.config);
492
- };
493
- FsHtmlEditorComponent.prototype._change = function (html) {
494
- this._html = html;
495
- this.onChange(html);
496
- };
497
- FsHtmlEditorComponent.prototype._initPlugins = function (config) {
498
- var _this = this;
499
- (config.plugins || []).forEach(function (plugin) {
500
- _this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
501
- plugin.editor = editor;
502
- plugin.initialize();
503
- return plugin;
504
- };
505
- (plugin.config.buttons || []).forEach(function (button) {
506
- _this._fr.FroalaEditor.DefineIcon(button.name, {
507
- NAME: button.name,
508
- PATH: button.svgPath,
509
- });
510
- _this._fr.FroalaEditor.RegisterCommand(button.name, {
511
- icon: button.name,
512
- title: button.tooltip,
513
- undo: button.undo,
514
- focus: button.focus,
515
- showOnMobile: button.showOnMobile,
516
- refreshAfterCallback: button.refreshAfterCallback,
517
- callback: function () {
518
- if (button.click) {
519
- button.click(this);
520
- }
521
- },
522
- refresh: function (button) {
523
- if (button.refresh) {
524
- button.refresh(this, button);
525
- }
526
- }
527
- });
528
- });
529
- });
530
- };
531
- FsHtmlEditorComponent.prototype._createOptions = function () {
532
- var config = this._createConfig();
533
- return merge(
534
- // For some reason editor store somewhere pointer on default config object and dublicate options each time on init
535
- // Extra merge level fixed this problem and allow to init config properly without legacy data
536
- {}, {
537
- key: config.activationKey,
538
- placeholderText: config.placeholder,
539
- linkAlwaysBlank: true,
540
- tabSpaces: 2,
541
- typingTimer: 250,
542
- tooltips: false,
543
- wordPasteModal: false,
544
- imageDefaultWidth: 0,
545
- imageDefaultAlign: 'left',
546
- quickInsertEnabled: false,
547
- paragraphDefaultSelection: 'Format',
548
- videoUpload: false,
549
- paragraphFormat: {
550
- N: 'Normal',
551
- H1: 'Heading 1',
552
- H2: 'Heading 2',
553
- H3: 'Heading 3',
554
- H4: 'Heading 4',
555
- BLOCKQUOTE: 'Quote',
556
- },
557
- paragraphFormatSelection: true,
558
- toolbarButtonsXS: {
559
- moreText: {
560
- buttons: TextButtons,
561
- buttonsVisible: 1,
562
- },
563
- moreParagraph: {
564
- buttons: ParagraphButtons,
565
- buttonsVisible: 2,
566
- },
567
- moreRich: {
568
- buttons: RichButtons,
569
- buttonsVisible: 0,
570
- },
571
- },
572
- toolbarButtons: {
573
- moreText: {
574
- buttons: TextButtons,
575
- buttonsVisible: 3,
576
- },
577
- moreParagraph: {
578
- buttons: ParagraphButtons,
579
- buttonsVisible: 5,
580
- },
581
- moreRich: {
582
- buttons: RichButtons,
583
- buttonsVisible: 3,
584
- },
585
- },
586
- }, config.froalaConfig);
587
- };
588
- FsHtmlEditorComponent.prototype._listenLazyInit = function () {
589
- var _this = this;
590
- this.froalaReady$
591
- .pipe(filter(function (ready) { return ready; }), switchMap(function () { return _this._initialize$; }))
592
- .subscribe(function () {
593
- var selection = window.getSelection();
594
- var options = {};
595
- if (selection.baseNode) {
596
- options.selection = {
597
- node: selection.baseNode.nodeValue,
598
- offset: selection.baseOffset,
599
- };
600
- }
601
- _this.initialize(options);
602
- });
603
- };
604
- var FsHtmlEditorComponent_1;
605
- FsHtmlEditorComponent.ctorParameters = function () { return [
606
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
607
- { type: ChangeDetectorRef },
608
- { type: FsFroalaLoaderService }
609
- ]; };
610
- __decorate([
611
- HostBinding('class.focused'),
612
- __metadata("design:type", Object)
613
- ], FsHtmlEditorComponent.prototype, "classFocused", void 0);
614
- __decorate([
615
- HostBinding('class.disabled'),
616
- __metadata("design:type", Object)
617
- ], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
618
- __decorate([
619
- ViewChild('elRef'),
620
- __metadata("design:type", ElementRef)
621
- ], FsHtmlEditorComponent.prototype, "elRef", void 0);
622
- __decorate([
623
- Input(),
624
- __metadata("design:type", Object)
625
- ], FsHtmlEditorComponent.prototype, "config", void 0);
626
- FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
627
- Component({
628
- selector: 'fs-html-editor',
629
- template: "<div class=\"fs-html-editor-default\">\n <ng-container *ngIf=\"initialized\">\n <ng-container *fsSkeleton=\"(froalaReady$ | async) !== false\">\n </ng-container>\n </ng-container>\n\n <div #elRef></div>\n\n <div class=\"bottom-line\"></div>\n <div class=\"disabled-line\"></div>\n <fs-html-renderer\n *ngIf=\"!initialized\"\n [html]=\"html\"\n (click)=\"uninitializedClick($event)\">\n </fs-html-renderer>\n</div>\n",
630
- providers: [
631
- {
632
- provide: NG_VALUE_ACCESSOR,
633
- useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
634
- multi: true
635
- },
636
- {
637
- provide: NG_VALIDATORS,
638
- useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
639
- multi: true
640
- },
641
- ],
642
- changeDetection: ChangeDetectionStrategy.OnPush,
643
- styles: [":host ::ng-deep .fr-box.fr-basic .fr-wrapper{border:0;border-bottom:1px solid #949494;margin-bottom:1px;background-color:transparent}:host ::ng-deep .fr-box.fr-basic .fr-element{padding:0;font-family:inherit;color:inherit;font-size:inherit;line-height:inherit;min-height:auto}:host ::ng-deep .fr-dropdown-menu .fr-dropdown-wrapper,:host ::ng-deep .fr-dropdown:after,:host ::ng-deep .fr-more-toolbar,:host ::ng-deep .fr-toolbar{transition:none!important}:host ::ng-deep .fr-toolbar{position:-webkit-sticky;position:sticky;z-index:2;border-radius:0;background-color:transparent}:host ::ng-deep .fr-toolbar .fr-btn-grp{margin:0 20px 0 0;position:relative}:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(1):after,:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(2):after{content:\"\";position:absolute;top:9px;height:30px;border-left:1px solid #e5e5e5;margin-left:10px}:host ::ng-deep .fr-toolbar div:first-of-type:before{border:none}:host ::ng-deep .fr-toolbar.fr-toolbar-open .fr-newline{height:auto}:host ::ng-deep .fr-toolbar .fr-btn-grp:first-child{margin-left:0}:host ::ng-deep .fr-toolbar.fr-top{border:0}:host ::ng-deep .fr-toolbar .fr-newline{margin:0}:host ::ng-deep .fr-toolbar .fr-more-toolbar{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown:after{right:3px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown.fr-selection span{margin-right:24px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-open{border-radius:4px;margin:4px 2px}:host ::ng-deep .fr-view ol,:host ::ng-deep .fr-view ul{list-style-position:unset}:host.disabled ::ng-deep .fr-box.fr-basic{opacity:.5;pointer-events:none}:host.disabled ::ng-deep .fr-box.fr-basic .fr-wrapper{border:none}:host.disabled ::ng-deep .disabled-line{display:block}::ng-deep .fr-popup{z-index:1001!important}::ng-deep .fr-video-by-url-layer .fr-checkbox-line{display:none}.disabled-line{display:none;position:absolute;bottom:-1px;z-index:1;background-image:linear-gradient(90deg,rgba(0,0,0,.42) 0,rgba(0,0,0,.42) 33%,transparent 0);background-size:4px 100%;background-repeat:repeat-x;height:1px;width:100%}.bottom-line{opacity:0;transform-origin:50%;transform:scaleX(.5);transition:background-color .3s cubic-bezier(.55,0,.55,.2);width:100%;border-bottom:2px solid #949494;position:absolute;bottom:-1px;z-index:1}:host{position:relative;display:block}:host.focused .bottom-line{opacity:1;display:block;transform:scaleX(1);transition:transform .3s cubic-bezier(.25,.8,.25,1),opacity .1s cubic-bezier(.25,.8,.25,1),background-color .3s cubic-bezier(.25,.8,.25,1)}::ng-deep .fs-html-editor-mention-container{position:absolute;top:0;left:0;height:auto;max-height:300px;max-width:500px;overflow:auto;display:block;z-index:999999;box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12);border-bottom-left-radius:4px;border-bottom-right-radius:4px;background:#fff}::ng-deep .fs-html-editor-mention-container ul{margin:0;padding:0;list-style:none}::ng-deep .fs-html-editor-mention-container li{padding:0 16px;cursor:pointer;line-height:48px}::ng-deep .fs-html-editor-mention-container li.highlight,::ng-deep .fs-html-editor-mention-container li:hover{background:#f5f5f5}::ng-deep .fs-html-editor-mention-container li.no-match{cursor:default}"]
644
- }),
645
- __param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
646
- __metadata("design:paramtypes", [Object, ChangeDetectorRef,
647
- FsFroalaLoaderService])
648
- ], FsHtmlEditorComponent);
649
- return FsHtmlEditorComponent;
218
+ var FsHtmlEditorComponent = /** @class */ (function () {
219
+ function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
220
+ this._defaultConfig = _defaultConfig;
221
+ this._cdRef = _cdRef;
222
+ this._fr = _fr;
223
+ this.classFocused = false;
224
+ this.classDisabled = false;
225
+ this.config = {};
226
+ this.initialized = false;
227
+ this._initialize$ = new ReplaySubject();
228
+ this._destroy$ = new Subject();
229
+ this.onChange = function (data) { };
230
+ this.onTouched = function () { };
231
+ }
232
+ FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
233
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
234
+ get: function () {
235
+ return this.elRef.nativeElement;
236
+ },
237
+ enumerable: true,
238
+ configurable: true
239
+ });
240
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
241
+ get: function () {
242
+ return this._html;
243
+ },
244
+ enumerable: true,
245
+ configurable: true
246
+ });
247
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
248
+ get: function () {
249
+ return this._editor;
250
+ },
251
+ enumerable: true,
252
+ configurable: true
253
+ });
254
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaReady$", {
255
+ get: function () {
256
+ return this._fr.ready$;
257
+ },
258
+ enumerable: true,
259
+ configurable: true
260
+ });
261
+ FsHtmlEditorComponent.prototype.ngOnInit = function () {
262
+ this.config = this.config || {};
263
+ this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
264
+ this.initialized = !this.config.initOnClick;
265
+ this._listenLazyInit();
266
+ };
267
+ FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
268
+ if (!this.config.initOnClick || !this.hasContent()) {
269
+ this.initialized = true;
270
+ this._initialize$.next();
271
+ }
272
+ };
273
+ FsHtmlEditorComponent.prototype.hasContent = function () {
274
+ var el = document.createElement('div');
275
+ if (el.querySelector('img')) {
276
+ return true;
277
+ }
278
+ el.innerHTML = this._html;
279
+ return !!el.innerText.length;
280
+ };
281
+ FsHtmlEditorComponent.prototype.initialize = function (options) {
282
+ var _this = this;
283
+ if (options === void 0) { options = {}; }
284
+ var config = this._createConfig();
285
+ this._initPlugins(config);
286
+ this.el.innerHTML = this._html;
287
+ this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
288
+ _this._cdRef.markForCheck();
289
+ if (config.disabled) {
290
+ _this.disable();
291
+ }
292
+ if (config.froalaConfig.events) {
293
+ if (config.froalaConfig.events.initialized) {
294
+ config.froalaConfig.events.initialized();
295
+ }
296
+ }
297
+ _this._editor.events.on('focus', function () {
298
+ _this.classFocused = true;
299
+ _this._cdRef.markForCheck();
300
+ });
301
+ _this._editor.events.on('blur', function () {
302
+ _this.classFocused = false;
303
+ _this._cdRef.markForCheck();
304
+ });
305
+ _this._editor.events.on('contentChanged', function () {
306
+ var editorHTML = _this._editor.html.get();
307
+ if (_this.html !== editorHTML) {
308
+ _this._change(editorHTML);
309
+ }
310
+ });
311
+ _this._editor.events.on('paste.afterCleanup', function (html) {
312
+ var div = document.createElement('div');
313
+ div.innerHTML = html;
314
+ div.querySelectorAll('*')
315
+ .forEach(function (el) {
316
+ for (var i = 0; i < el.attributes.length; i++) {
317
+ var name_1 = el.attributes[0].name;
318
+ if (name_1 !== 'href') {
319
+ el.removeAttribute(name_1);
320
+ }
321
+ }
322
+ });
323
+ return div.innerHTML;
324
+ });
325
+ _this._editor.events.on('keydown', function () {
326
+ _this.onTouched();
327
+ });
328
+ if (_this.config.image && _this.config.image.upload) {
329
+ _this._editor.events.on('image.beforePasteUpload', function (image) {
330
+ fetch(image.getAttribute('src'))
331
+ .then(function (res) {
332
+ res.blob()
333
+ .then(function (blob) {
334
+ _this._processImageUpload(blob)
335
+ .pipe(takeUntil(_this._destroy$))
336
+ .subscribe(function (url) {
337
+ image.setAttribute('src', url);
338
+ image.removeAttribute('data-fr-image-pasted');
339
+ });
340
+ });
341
+ });
342
+ return false;
343
+ });
344
+ _this._editor.events.on('image.beforeUpload', function (blobs) {
345
+ _this._processImageUpload(blobs[0])
346
+ .pipe(takeUntil(_this._destroy$))
347
+ .subscribe(function (url) {
348
+ _this.editor.image.insert(url, null, null, _this.editor.image.get());
349
+ });
350
+ return false;
351
+ });
352
+ }
353
+ if (_this.el.querySelector('.fr-second-toolbar')) {
354
+ _this.el.querySelector('.fr-second-toolbar').remove();
355
+ }
356
+ var selection = options.selection;
357
+ if (selection) {
358
+ var node = Array.from(_this.el.querySelectorAll('.fr-element *')).find(function (node) {
359
+ return selection.node === node.textContent;
360
+ });
361
+ if (node) {
362
+ var range = document.createRange();
363
+ var sel = window.getSelection();
364
+ range.setStart(_this._getTextNode(node), selection.offset);
365
+ range.collapse(true);
366
+ sel.removeAllRanges();
367
+ sel.addRange(range);
368
+ }
369
+ else if (_this.config.autofocus) {
370
+ _this.focus();
371
+ }
372
+ }
373
+ else if (_this.config.autofocus) {
374
+ _this.focus();
375
+ }
376
+ });
377
+ };
378
+ FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
379
+ var _this = this;
380
+ var processor = new FileProcessor();
381
+ var file = new FsFile(blob);
382
+ return processor.process([file], this.config.image)
383
+ .pipe(switchMap(function (img) {
384
+ return _this.config.image.upload(img.file);
385
+ }));
386
+ };
387
+ FsHtmlEditorComponent.prototype._getTextNode = function (node) {
388
+ if (node) {
389
+ if (node.nodeType === Node.TEXT_NODE) {
390
+ return node;
391
+ }
392
+ if (node.childNodes) {
393
+ return this._getTextNode(node.childNodes[0]);
394
+ }
395
+ }
396
+ };
397
+ FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
398
+ if (!event.defaultPrevented) {
399
+ var target_1 = event.target;
400
+ if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
401
+ var targetTarget_1 = target_1.getAttribute('target');
402
+ target_1.setAttribute('target', '_blank');
403
+ setTimeout(function () {
404
+ if (targetTarget_1) {
405
+ target_1.setAttribute('target', targetTarget_1);
406
+ }
407
+ else {
408
+ target_1.removeAttribute('target');
409
+ }
410
+ });
411
+ }
412
+ else {
413
+ if (this.config.initClick) {
414
+ this.config.initClick(event);
415
+ }
416
+ this._initialize$.next();
417
+ this.initialized = true;
418
+ }
419
+ }
420
+ };
421
+ FsHtmlEditorComponent.prototype.updateSize = function () {
422
+ // Hack: To trigger the toolbar button size modes
423
+ window.dispatchEvent(new Event('resize'));
424
+ };
425
+ FsHtmlEditorComponent.prototype.validate = function (control) {
426
+ var err = {};
427
+ if (this.config.maxLength && this._html) {
428
+ var maxLength = this.config.maxLength;
429
+ var length_1 = this._html.length;
430
+ if (length_1 > maxLength) {
431
+ err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
432
+ }
433
+ }
434
+ return Object.keys(err).length ? err : null;
435
+ };
436
+ FsHtmlEditorComponent.prototype.focus = function (options) {
437
+ options = options ? options : {};
438
+ if (options.cursorPosition === 'end') {
439
+ this.editor.selection.setAtEnd(this.editor.$el.get(0));
440
+ }
441
+ else {
442
+ this.editor.selection.setAtStart(this.editor.$el.get(0));
443
+ }
444
+ this.editor.selection.restore();
445
+ var elSelection = this.editor.selection.element();
446
+ if (elSelection) {
447
+ elSelection.scrollIntoView({ block: 'center' });
448
+ }
449
+ };
450
+ FsHtmlEditorComponent.prototype.clear = function () {
451
+ this.writeValue('');
452
+ };
453
+ FsHtmlEditorComponent.prototype.disable = function () {
454
+ this.classDisabled = true;
455
+ };
456
+ FsHtmlEditorComponent.prototype.setHtml = function (html) {
457
+ this.writeValue(html);
458
+ };
459
+ FsHtmlEditorComponent.prototype.writeValue = function (html) {
460
+ var _this = this;
461
+ this._html = html || '';
462
+ this._cdRef.markForCheck();
463
+ // SP-T2298 timeout needed for the case, when froala was already initated and
464
+ // second instance opened in dialog/drawer. In this case init step pass much faster, writeValue trigger
465
+ // after init and froala ignore new html. At the same time froala was initied but editor not yet, and next
466
+ // code doesn't work without timeout. We've got time range when too late for initiate value, and to early
467
+ // for change event.
468
+ setTimeout(function () {
469
+ if (_this.editor && _this.editor.html) {
470
+ try {
471
+ _this.editor.html.set(_this._html);
472
+ }
473
+ catch (e) {
474
+ }
475
+ }
476
+ });
477
+ };
478
+ FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
479
+ this.onChange = fn;
480
+ };
481
+ FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
482
+ this.onTouched = fn;
483
+ };
484
+ FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
485
+ this._initialize$.complete();
486
+ this._destroy$.next();
487
+ this._destroy$.complete();
488
+ this.destroy();
489
+ };
490
+ FsHtmlEditorComponent.prototype.destroy = function () {
491
+ if (this.editor) {
492
+ this.editor.destroy();
493
+ }
494
+ this.initialized = false;
495
+ this._cdRef.markForCheck();
496
+ this.el.innerHTML = '';
497
+ };
498
+ FsHtmlEditorComponent.prototype._createConfig = function () {
499
+ return merge({ froalaConfig: {} }, this._defaultConfig, this.config);
500
+ };
501
+ FsHtmlEditorComponent.prototype._change = function (html) {
502
+ this._html = html;
503
+ this.onChange(html);
504
+ };
505
+ FsHtmlEditorComponent.prototype._initPlugins = function (config) {
506
+ var _this = this;
507
+ (config.plugins || []).forEach(function (plugin) {
508
+ _this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
509
+ plugin.editor = editor;
510
+ plugin.initialize();
511
+ return plugin;
512
+ };
513
+ (plugin.config.buttons || []).forEach(function (button) {
514
+ _this._fr.FroalaEditor.DefineIcon(button.name, {
515
+ NAME: button.name,
516
+ PATH: button.svgPath,
517
+ });
518
+ _this._fr.FroalaEditor.RegisterCommand(button.name, {
519
+ icon: button.name,
520
+ title: button.tooltip,
521
+ undo: button.undo,
522
+ focus: button.focus,
523
+ showOnMobile: button.showOnMobile,
524
+ refreshAfterCallback: button.refreshAfterCallback,
525
+ callback: function () {
526
+ if (button.click) {
527
+ button.click(this);
528
+ }
529
+ },
530
+ refresh: function (button) {
531
+ if (button.refresh) {
532
+ button.refresh(this, button);
533
+ }
534
+ }
535
+ });
536
+ });
537
+ });
538
+ };
539
+ FsHtmlEditorComponent.prototype._createOptions = function () {
540
+ var config = this._createConfig();
541
+ return merge(
542
+ // For some reason editor store somewhere pointer on default config object and dublicate options each time on init
543
+ // Extra merge level fixed this problem and allow to init config properly without legacy data
544
+ {}, {
545
+ key: config.activationKey,
546
+ placeholderText: config.placeholder,
547
+ linkAlwaysBlank: true,
548
+ tabSpaces: 2,
549
+ typingTimer: 250,
550
+ tooltips: false,
551
+ wordPasteModal: false,
552
+ imageDefaultWidth: 0,
553
+ imageDefaultAlign: 'left',
554
+ quickInsertEnabled: false,
555
+ paragraphDefaultSelection: 'Format',
556
+ videoUpload: false,
557
+ paragraphFormat: {
558
+ N: 'Normal',
559
+ H1: 'Heading 1',
560
+ H2: 'Heading 2',
561
+ H3: 'Heading 3',
562
+ H4: 'Heading 4',
563
+ BLOCKQUOTE: 'Quote',
564
+ },
565
+ paragraphFormatSelection: true,
566
+ toolbarButtonsXS: {
567
+ moreText: {
568
+ buttons: TextButtons,
569
+ buttonsVisible: 1,
570
+ },
571
+ moreParagraph: {
572
+ buttons: ParagraphButtons,
573
+ buttonsVisible: 2,
574
+ },
575
+ moreRich: {
576
+ buttons: RichButtons,
577
+ buttonsVisible: 0,
578
+ },
579
+ },
580
+ toolbarButtons: {
581
+ moreText: {
582
+ buttons: TextButtons,
583
+ buttonsVisible: 3,
584
+ },
585
+ moreParagraph: {
586
+ buttons: ParagraphButtons,
587
+ buttonsVisible: 5,
588
+ },
589
+ moreRich: {
590
+ buttons: RichButtons,
591
+ buttonsVisible: 3,
592
+ },
593
+ },
594
+ }, config.froalaConfig);
595
+ };
596
+ FsHtmlEditorComponent.prototype._listenLazyInit = function () {
597
+ var _this = this;
598
+ this.froalaReady$
599
+ .pipe(filter(function (ready) { return ready; }), switchMap(function () { return _this._initialize$; }))
600
+ .subscribe(function () {
601
+ var selection = window.getSelection();
602
+ var options = {};
603
+ if (selection.baseNode) {
604
+ options.selection = {
605
+ node: selection.baseNode.nodeValue,
606
+ offset: selection.baseOffset,
607
+ };
608
+ }
609
+ _this.initialize(options);
610
+ });
611
+ };
612
+ var FsHtmlEditorComponent_1;
613
+ FsHtmlEditorComponent.ctorParameters = function () { return [
614
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
615
+ { type: ChangeDetectorRef },
616
+ { type: FsFroalaLoaderService }
617
+ ]; };
618
+ __decorate([
619
+ HostBinding('class.focused'),
620
+ __metadata("design:type", Object)
621
+ ], FsHtmlEditorComponent.prototype, "classFocused", void 0);
622
+ __decorate([
623
+ HostBinding('class.disabled'),
624
+ __metadata("design:type", Object)
625
+ ], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
626
+ __decorate([
627
+ ViewChild('elRef'),
628
+ __metadata("design:type", ElementRef)
629
+ ], FsHtmlEditorComponent.prototype, "elRef", void 0);
630
+ __decorate([
631
+ Input(),
632
+ __metadata("design:type", Object)
633
+ ], FsHtmlEditorComponent.prototype, "config", void 0);
634
+ FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
635
+ Component({
636
+ selector: 'fs-html-editor',
637
+ template: "<div class=\"fs-html-editor-default\">\n <ng-container *ngIf=\"initialized\">\n <ng-container *fsSkeleton=\"(froalaReady$ | async) !== false\">\n </ng-container>\n </ng-container>\n\n <div #elRef></div>\n\n <div class=\"bottom-line\"></div>\n <div class=\"disabled-line\"></div>\n <fs-html-renderer\n *ngIf=\"!initialized\"\n [html]=\"html\"\n (click)=\"uninitializedClick($event)\">\n </fs-html-renderer>\n</div>\n",
638
+ providers: [
639
+ {
640
+ provide: NG_VALUE_ACCESSOR,
641
+ useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
642
+ multi: true
643
+ },
644
+ {
645
+ provide: NG_VALIDATORS,
646
+ useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
647
+ multi: true
648
+ },
649
+ ],
650
+ changeDetection: ChangeDetectionStrategy.OnPush,
651
+ styles: [":host ::ng-deep .fr-box.fr-basic .fr-wrapper{border:0;border-bottom:1px solid #949494;margin-bottom:1px;background-color:transparent}:host ::ng-deep .fr-box.fr-basic .fr-element{padding:0;font-family:inherit;color:inherit;font-size:inherit;line-height:inherit;min-height:auto}:host ::ng-deep .fr-dropdown-menu .fr-dropdown-wrapper,:host ::ng-deep .fr-dropdown:after,:host ::ng-deep .fr-more-toolbar,:host ::ng-deep .fr-toolbar{transition:none!important}:host ::ng-deep .fr-toolbar{position:-webkit-sticky;position:sticky;z-index:2;border-radius:0;background-color:transparent}:host ::ng-deep .fr-toolbar .fr-btn-grp{margin:0 20px 0 0;position:relative}:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(1):after,:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(2):after{content:\"\";position:absolute;top:9px;height:30px;border-left:1px solid #e5e5e5;margin-left:10px}:host ::ng-deep .fr-toolbar div:first-of-type:before{border:none}:host ::ng-deep .fr-toolbar.fr-toolbar-open .fr-newline{height:auto}:host ::ng-deep .fr-toolbar .fr-btn-grp:first-child{margin-left:0}:host ::ng-deep .fr-toolbar.fr-top{border:0}:host ::ng-deep .fr-toolbar .fr-newline{margin:0}:host ::ng-deep .fr-toolbar .fr-more-toolbar{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown:after{right:3px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown.fr-selection:after{right:10px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown.fr-selection span{margin-right:24px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-open{border-radius:4px;margin:4px 2px}:host ::ng-deep .fr-view ol,:host ::ng-deep .fr-view ul{list-style-position:unset}:host.disabled ::ng-deep .fr-box.fr-basic{opacity:.5;pointer-events:none}:host.disabled ::ng-deep .fr-box.fr-basic .fr-wrapper{border:none}:host.disabled ::ng-deep .disabled-line{display:block}::ng-deep .fr-popup{z-index:1001!important}::ng-deep .fr-video-by-url-layer .fr-checkbox-line{display:none}.disabled-line{display:none;position:absolute;bottom:-1px;z-index:1;background-image:linear-gradient(90deg,rgba(0,0,0,.42) 0,rgba(0,0,0,.42) 33%,transparent 0);background-size:4px 100%;background-repeat:repeat-x;height:1px;width:100%}.bottom-line{opacity:0;transform-origin:50%;transform:scaleX(.5);transition:background-color .3s cubic-bezier(.55,0,.55,.2);width:100%;border-bottom:2px solid #949494;position:absolute;bottom:-1px;z-index:1}:host{position:relative;display:block}:host.focused .bottom-line{opacity:1;display:block;transform:scaleX(1);transition:transform .3s cubic-bezier(.25,.8,.25,1),opacity .1s cubic-bezier(.25,.8,.25,1),background-color .3s cubic-bezier(.25,.8,.25,1)}::ng-deep .fs-html-editor-mention-container{position:absolute;top:0;left:0;height:auto;max-height:300px;max-width:500px;overflow:auto;display:block;z-index:999999;box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12);border-bottom-left-radius:4px;border-bottom-right-radius:4px;background:#fff}::ng-deep .fs-html-editor-mention-container ul{margin:0;padding:0;list-style:none}::ng-deep .fs-html-editor-mention-container li{padding:0 16px;cursor:pointer;line-height:48px}::ng-deep .fs-html-editor-mention-container li.highlight,::ng-deep .fs-html-editor-mention-container li:hover{background:#f5f5f5}::ng-deep .fs-html-editor-mention-container li.no-match{cursor:default}"]
652
+ }),
653
+ __param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
654
+ __metadata("design:paramtypes", [Object, ChangeDetectorRef,
655
+ FsFroalaLoaderService])
656
+ ], FsHtmlEditorComponent);
657
+ return FsHtmlEditorComponent;
650
658
  }());
651
659
 
652
- var FsHtmlRendererComponent = /** @class */ (function () {
653
- function FsHtmlRendererComponent(sanitized, _cdRef) {
654
- this.sanitized = sanitized;
655
- this._cdRef = _cdRef;
656
- }
657
- Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
658
- set: function (html) {
659
- this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html);
660
- this._cdRef.markForCheck();
661
- },
662
- enumerable: true,
663
- configurable: true
664
- });
665
- FsHtmlRendererComponent.ctorParameters = function () { return [
666
- { type: DomSanitizer },
667
- { type: ChangeDetectorRef }
668
- ]; };
669
- __decorate([
670
- Input('html'),
671
- __metadata("design:type", Object),
672
- __metadata("design:paramtypes", [Object])
673
- ], FsHtmlRendererComponent.prototype, "setHtml", null);
674
- FsHtmlRendererComponent = __decorate([
675
- Component({
676
- selector: 'fs-html-renderer',
677
- template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
678
- changeDetection: ChangeDetectionStrategy.OnPush,
679
- styles: [""]
680
- }),
681
- __metadata("design:paramtypes", [DomSanitizer,
682
- ChangeDetectorRef])
683
- ], FsHtmlRendererComponent);
684
- return FsHtmlRendererComponent;
660
+ var FsHtmlRendererComponent = /** @class */ (function () {
661
+ function FsHtmlRendererComponent(sanitized, _cdRef) {
662
+ this.sanitized = sanitized;
663
+ this._cdRef = _cdRef;
664
+ }
665
+ Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
666
+ set: function (html) {
667
+ this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html);
668
+ this._cdRef.markForCheck();
669
+ },
670
+ enumerable: true,
671
+ configurable: true
672
+ });
673
+ FsHtmlRendererComponent.ctorParameters = function () { return [
674
+ { type: DomSanitizer },
675
+ { type: ChangeDetectorRef }
676
+ ]; };
677
+ __decorate([
678
+ Input('html'),
679
+ __metadata("design:type", Object),
680
+ __metadata("design:paramtypes", [Object])
681
+ ], FsHtmlRendererComponent.prototype, "setHtml", null);
682
+ FsHtmlRendererComponent = __decorate([
683
+ Component({
684
+ selector: 'fs-html-renderer',
685
+ template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
686
+ changeDetection: ChangeDetectionStrategy.OnPush,
687
+ styles: [""]
688
+ }),
689
+ __metadata("design:paramtypes", [DomSanitizer,
690
+ ChangeDetectorRef])
691
+ ], FsHtmlRendererComponent);
692
+ return FsHtmlRendererComponent;
685
693
  }());
686
694
 
687
- var FsHtmlEditorModule = /** @class */ (function () {
688
- function FsHtmlEditorModule() {
689
- }
690
- FsHtmlEditorModule_1 = FsHtmlEditorModule;
691
- FsHtmlEditorModule.forRoot = function (config) {
692
- if (config === void 0) { config = {}; }
693
- return {
694
- ngModule: FsHtmlEditorModule_1,
695
- providers: [
696
- { provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
697
- {
698
- provide: FS_HTML_EDITOR_CONFIG,
699
- useFactory: FsHtmlEditorConfigFactory,
700
- deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
701
- }
702
- ]
703
- };
704
- };
705
- var FsHtmlEditorModule_1;
706
- FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
707
- NgModule({
708
- imports: [
709
- CommonModule,
710
- FsSkeletonModule,
711
- ],
712
- exports: [
713
- FsHtmlEditorComponent,
714
- FsHtmlRendererComponent,
715
- ],
716
- declarations: [
717
- FsHtmlEditorComponent,
718
- FsHtmlRendererComponent,
719
- ],
720
- })
721
- ], FsHtmlEditorModule);
722
- return FsHtmlEditorModule;
723
- }());
724
- function FsHtmlEditorConfigFactory(config) {
725
- return __assign({ defaultPlugins: [
726
- "align" /* Align */,
727
- "colors" /* Colors */,
728
- "image" /* Image */,
729
- "link" /* Link */,
730
- "lists" /* Lists */,
731
- "paragraph_format" /* ParagraphFormat */,
732
- "quote" /* Quote */,
733
- "table" /* Table */,
734
- "url" /* Url */,
735
- "video" /* Video */,
736
- "draggable" /* Draggable */,
737
- "font_size" /* FontSize */,
738
- ] }, config);
695
+ var FsHtmlEditorModule = /** @class */ (function () {
696
+ function FsHtmlEditorModule() {
697
+ }
698
+ FsHtmlEditorModule_1 = FsHtmlEditorModule;
699
+ FsHtmlEditorModule.forRoot = function (config) {
700
+ if (config === void 0) { config = {}; }
701
+ return {
702
+ ngModule: FsHtmlEditorModule_1,
703
+ providers: [
704
+ { provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
705
+ {
706
+ provide: FS_HTML_EDITOR_CONFIG,
707
+ useFactory: FsHtmlEditorConfigFactory,
708
+ deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
709
+ }
710
+ ]
711
+ };
712
+ };
713
+ var FsHtmlEditorModule_1;
714
+ FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
715
+ NgModule({
716
+ imports: [
717
+ CommonModule,
718
+ FsSkeletonModule,
719
+ ],
720
+ exports: [
721
+ FsHtmlEditorComponent,
722
+ FsHtmlRendererComponent,
723
+ ],
724
+ declarations: [
725
+ FsHtmlEditorComponent,
726
+ FsHtmlRendererComponent,
727
+ ],
728
+ })
729
+ ], FsHtmlEditorModule);
730
+ return FsHtmlEditorModule;
731
+ }());
732
+ function FsHtmlEditorConfigFactory(config) {
733
+ return __assign({ defaultPlugins: [
734
+ "align" /* Align */,
735
+ "colors" /* Colors */,
736
+ "image" /* Image */,
737
+ "link" /* Link */,
738
+ "lists" /* Lists */,
739
+ "paragraph_format" /* ParagraphFormat */,
740
+ "quote" /* Quote */,
741
+ "table" /* Table */,
742
+ "url" /* Url */,
743
+ "video" /* Video */,
744
+ "draggable" /* Draggable */,
745
+ ] }, config);
739
746
  }
740
747
 
741
- var Plugin = /** @class */ (function () {
742
- function Plugin() {
743
- }
744
- Plugin.prototype.initialize = function () { };
745
- Plugin.prototype.destroy = function () { };
746
- return Plugin;
748
+ var Plugin = /** @class */ (function () {
749
+ function Plugin() {
750
+ }
751
+ Plugin.prototype.initialize = function () { };
752
+ Plugin.prototype.destroy = function () { };
753
+ return Plugin;
747
754
  }());
748
755
 
749
- var MentionPlugin = /** @class */ (function (_super) {
750
- __extends(MentionPlugin, _super);
751
- function MentionPlugin(config) {
752
- var _this = _super.call(this) || this;
753
- _this.config = config;
754
- _this.config = __assign(__assign({}, config), { buttons: [
755
- {
756
- name: config.name,
757
- tooltip: config.tooltip,
758
- svgPath: config.iconPath,
759
- click: function (editor) {
760
- _this._closeAll();
761
- _this._tribute.showMenuForCollection(editor.el);
762
- }
763
- }
764
- ] });
765
- _this._tribute = new Tribute({
766
- values: debounce(_this._loadValues.bind(_this), 200),
767
- searchOpts: {
768
- pre: '',
769
- post: '',
770
- skip: true
771
- },
772
- containerClass: "fs-html-editor-mention-container " + (_this.config.containerClass || ''),
773
- itemClass: "fs-html-editor-mention-menu-item " + (_this.config.menuItemClass || ''),
774
- trigger: _this.config.trigger,
775
- allowSpaces: true,
776
- menuItemTemplate: function (item) {
777
- return _this.config.menuItemTemplate(item.original);
778
- },
779
- selectTemplate: function (item) {
780
- var template = _this.config.selectedTemplate(item.original);
781
- var p = document.createElement('p');
782
- p.innerHTML = template;
783
- var node = p.firstElementChild;
784
- if (!node) {
785
- node = document.createElement('span');
786
- node.innerHTML = template;
787
- }
788
- node.setAttribute('contenteditable', 'false');
789
- node.classList.add('fr-deletable');
790
- return node.outerHTML;
791
- },
792
- });
793
- MentionPlugin._tributes.push(_this._tribute);
794
- return _this;
795
- }
796
- MentionPlugin.prototype.initialize = function () {
797
- var _this = this;
798
- this._tribute.attach(this.editor.el);
799
- this.editor.events.on('keydown', function (e) {
800
- if (e.key === 'Enter' && _this._tribute.isActive) {
801
- return false;
802
- }
803
- }, true);
804
- };
805
- MentionPlugin.prototype.destroy = function () { };
806
- MentionPlugin.prototype._closeAll = function () {
807
- MentionPlugin._tributes.forEach(function (tribute) {
808
- if (tribute.menu) {
809
- tribute.hideMenu();
810
- }
811
- });
812
- };
813
- MentionPlugin.prototype._loadValues = function (keyword, cb) {
814
- return this.config.fetch(keyword)
815
- .subscribe(function (data) {
816
- cb(data);
817
- });
818
- };
819
- MentionPlugin._tributes = [];
820
- return MentionPlugin;
756
+ var MentionPlugin = /** @class */ (function (_super) {
757
+ __extends(MentionPlugin, _super);
758
+ function MentionPlugin(config) {
759
+ var _this = _super.call(this) || this;
760
+ _this.config = config;
761
+ _this.config = __assign(__assign({}, config), { buttons: [
762
+ {
763
+ name: config.name,
764
+ tooltip: config.tooltip,
765
+ svgPath: config.iconPath,
766
+ click: function (editor) {
767
+ _this._closeAll();
768
+ _this._tribute.showMenuForCollection(editor.el);
769
+ }
770
+ }
771
+ ] });
772
+ _this._tribute = new Tribute({
773
+ values: debounce(_this._loadValues.bind(_this), 200),
774
+ searchOpts: {
775
+ pre: '',
776
+ post: '',
777
+ skip: true
778
+ },
779
+ containerClass: "fs-html-editor-mention-container " + (_this.config.containerClass || ''),
780
+ itemClass: "fs-html-editor-mention-menu-item " + (_this.config.menuItemClass || ''),
781
+ trigger: _this.config.trigger,
782
+ allowSpaces: true,
783
+ menuItemTemplate: function (item) {
784
+ return _this.config.menuItemTemplate(item.original);
785
+ },
786
+ selectTemplate: function (item) {
787
+ var template = _this.config.selectedTemplate(item.original);
788
+ var p = document.createElement('p');
789
+ p.innerHTML = template;
790
+ var node = p.firstElementChild;
791
+ if (!node) {
792
+ node = document.createElement('span');
793
+ node.innerHTML = template;
794
+ }
795
+ node.setAttribute('contenteditable', 'false');
796
+ node.classList.add('fr-deletable');
797
+ return node.outerHTML;
798
+ },
799
+ });
800
+ MentionPlugin._tributes.push(_this._tribute);
801
+ return _this;
802
+ }
803
+ MentionPlugin.prototype.initialize = function () {
804
+ var _this = this;
805
+ this._tribute.attach(this.editor.el);
806
+ this.editor.events.on('keydown', function (e) {
807
+ if (e.key === 'Enter' && _this._tribute.isActive) {
808
+ return false;
809
+ }
810
+ }, true);
811
+ };
812
+ MentionPlugin.prototype.destroy = function () { };
813
+ MentionPlugin.prototype._closeAll = function () {
814
+ MentionPlugin._tributes.forEach(function (tribute) {
815
+ if (tribute.menu) {
816
+ tribute.hideMenu();
817
+ }
818
+ });
819
+ };
820
+ MentionPlugin.prototype._loadValues = function (keyword, cb) {
821
+ return this.config.fetch(keyword)
822
+ .subscribe(function (data) {
823
+ cb(data);
824
+ });
825
+ };
826
+ MentionPlugin._tributes = [];
827
+ return MentionPlugin;
821
828
  }(Plugin));
822
829
 
823
- var ChecklistPlugin = /** @class */ (function (_super) {
824
- __extends(ChecklistPlugin, _super);
825
- function ChecklistPlugin(config) {
826
- if (config === void 0) { config = { name: 'checklist' }; }
827
- var _this = _super.call(this) || this;
828
- _this.config = config;
829
- _this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
830
- {
831
- name: 'checklist',
832
- svgPath: 'M8.4,10.3l-1.2,1.2l4,4L20,6.7l-1.2-1.2l-7.6,7.6L8.4,10.3z M18.2,18.2H5.8V5.8h8.9V4H5.8C4.8,4,4,4.8,4,5.8v12.4c0,1,0.8,1.8,1.8,1.8h12.4c1,0,1.8-0.8,1.8-1.8v-7.1h-1.8V18.2z',
833
- click: function (editor) {
834
- editor.html.insert('<ul class="checklist"><li></li></ul>');
835
- }
836
- }
837
- ] });
838
- return _this;
839
- }
840
- ChecklistPlugin.prototype.initialize = function () {
841
- this.editor.events.on('click', function (e) {
842
- var li = e.target;
843
- if (li.nodeName === 'LI' && e.offsetX < 0) {
844
- var items = __spread([li], li.querySelectorAll('li'));
845
- if (li.classList.contains('checked')) {
846
- items.forEach(function (item) {
847
- item.classList.remove('checked');
848
- });
849
- }
850
- else {
851
- items.forEach(function (item) {
852
- item.classList.add('checked');
853
- });
854
- }
855
- }
856
- }, false);
857
- };
858
- return ChecklistPlugin;
830
+ var ChecklistPlugin = /** @class */ (function (_super) {
831
+ __extends(ChecklistPlugin, _super);
832
+ function ChecklistPlugin(config) {
833
+ if (config === void 0) { config = { name: 'checklist' }; }
834
+ var _this = _super.call(this) || this;
835
+ _this.config = config;
836
+ _this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
837
+ {
838
+ name: 'checklist',
839
+ svgPath: 'M8.4,10.3l-1.2,1.2l4,4L20,6.7l-1.2-1.2l-7.6,7.6L8.4,10.3z M18.2,18.2H5.8V5.8h8.9V4H5.8C4.8,4,4,4.8,4,5.8v12.4c0,1,0.8,1.8,1.8,1.8h12.4c1,0,1.8-0.8,1.8-1.8v-7.1h-1.8V18.2z',
840
+ click: function (editor) {
841
+ editor.html.insert('<ul class="checklist"><li></li></ul>');
842
+ }
843
+ }
844
+ ] });
845
+ return _this;
846
+ }
847
+ ChecklistPlugin.prototype.initialize = function () {
848
+ this.editor.events.on('click', function (e) {
849
+ var li = e.target;
850
+ if (li.nodeName === 'LI' && e.offsetX < 0) {
851
+ var items = __spread([li], li.querySelectorAll('li'));
852
+ if (li.classList.contains('checked')) {
853
+ items.forEach(function (item) {
854
+ item.classList.remove('checked');
855
+ });
856
+ }
857
+ else {
858
+ items.forEach(function (item) {
859
+ item.classList.add('checked');
860
+ });
861
+ }
862
+ }
863
+ }, false);
864
+ };
865
+ return ChecklistPlugin;
859
866
  }(Plugin));
860
867
 
861
- var CodePlugin = /** @class */ (function (_super) {
862
- __extends(CodePlugin, _super);
863
- function CodePlugin(config) {
864
- if (config === void 0) { config = { name: 'code' }; }
865
- var _this = _super.call(this) || this;
866
- _this.config = config;
867
- _this.config = __assign(__assign({}, config), { name: 'code', buttons: [
868
- {
869
- name: 'code',
870
- svgPath: 'M8.9,7.3L4.2,12l4.7,4.7l1.1-1.1L6.4,12L10,8.4L8.9,7.3z M15.1,7.3L14,8.4l3.6,3.6L14,15.6l1.1,1.1l4.7-4.7L15.1,7.3z',
871
- click: function (editor) {
872
- var node = editor.selection.get();
873
- var codeEl = _this._getCodeEl(node.baseNode);
874
- if (codeEl) {
875
- codeEl.classList.remove('code');
876
- }
877
- else {
878
- editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
879
- }
880
- }
881
- }
882
- ] });
883
- return _this;
884
- }
885
- CodePlugin.prototype.initialize = function () {
886
- var _this = this;
887
- this.editor.events.on('keydown', function (e) {
888
- if (e.keyCode === 13) {
889
- var selection = _this.editor.selection.get();
890
- if (selection && _this._getCodeEl(selection.baseNode)) {
891
- e.preventDefault();
892
- e.stopPropagation();
893
- e.stopImmediatePropagation();
894
- var br = '<br>';
895
- var base = selection.baseNode;
896
- if (base.nodeName === '#text' && selection.baseOffset === base.length) {
897
- if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
898
- br += '<br>';
899
- }
900
- }
901
- else {
902
- var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
903
- if (el && el.nodeName !== 'BR') {
904
- br += '<br>';
905
- }
906
- }
907
- _this.editor.html.insert(br);
908
- return false;
909
- }
910
- }
911
- }, true);
912
- };
913
- CodePlugin.prototype.destroy = function () { };
914
- CodePlugin.prototype._getCodeEl = function (el) {
915
- if (el) {
916
- if (el.classList && el.classList.contains('code')) {
917
- return el;
918
- }
919
- if (el.parentElement) {
920
- return this._getCodeEl(el.parentElement);
921
- }
922
- }
923
- return null;
924
- };
925
- return CodePlugin;
868
+ var CodePlugin = /** @class */ (function (_super) {
869
+ __extends(CodePlugin, _super);
870
+ function CodePlugin(config) {
871
+ if (config === void 0) { config = { name: 'code' }; }
872
+ var _this = _super.call(this) || this;
873
+ _this.config = config;
874
+ _this.config = __assign(__assign({}, config), { name: 'code', buttons: [
875
+ {
876
+ name: 'code',
877
+ svgPath: 'M8.9,7.3L4.2,12l4.7,4.7l1.1-1.1L6.4,12L10,8.4L8.9,7.3z M15.1,7.3L14,8.4l3.6,3.6L14,15.6l1.1,1.1l4.7-4.7L15.1,7.3z',
878
+ click: function (editor) {
879
+ var node = editor.selection.get();
880
+ var codeEl = _this._getCodeEl(node.baseNode);
881
+ if (codeEl) {
882
+ codeEl.classList.remove('code');
883
+ }
884
+ else {
885
+ editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
886
+ }
887
+ }
888
+ }
889
+ ] });
890
+ return _this;
891
+ }
892
+ CodePlugin.prototype.initialize = function () {
893
+ var _this = this;
894
+ this.editor.events.on('keydown', function (e) {
895
+ if (e.keyCode === 13) {
896
+ var selection = _this.editor.selection.get();
897
+ if (selection && _this._getCodeEl(selection.baseNode)) {
898
+ e.preventDefault();
899
+ e.stopPropagation();
900
+ e.stopImmediatePropagation();
901
+ var br = '<br>';
902
+ var base = selection.baseNode;
903
+ if (base.nodeName === '#text' && selection.baseOffset === base.length) {
904
+ if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
905
+ br += '<br>';
906
+ }
907
+ }
908
+ else {
909
+ var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
910
+ if (el && el.nodeName !== 'BR') {
911
+ br += '<br>';
912
+ }
913
+ }
914
+ _this.editor.html.insert(br);
915
+ return false;
916
+ }
917
+ }
918
+ }, true);
919
+ };
920
+ CodePlugin.prototype.destroy = function () { };
921
+ CodePlugin.prototype._getCodeEl = function (el) {
922
+ if (el) {
923
+ if (el.classList && el.classList.contains('code')) {
924
+ return el;
925
+ }
926
+ if (el.parentElement) {
927
+ return this._getCodeEl(el.parentElement);
928
+ }
929
+ }
930
+ return null;
931
+ };
932
+ return CodePlugin;
926
933
  }(Plugin));
927
934
 
928
- var ScreenRecordPlugin = /** @class */ (function (_super) {
929
- __extends(ScreenRecordPlugin, _super);
930
- function ScreenRecordPlugin(config) {
931
- if (config === void 0) { config = {}; }
932
- var _this = _super.call(this) || this;
933
- _this.config = config;
934
- _this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
935
- {
936
- name: 'screenRecord',
937
- svgPath: "M14.7,7.7v6.1H7.1V7.7H14.7 M16.3,9.6V6.9c0-0.4-0.3-0.8-0.8-0.8H6.4c-0.4,0-0.8,0.3-0.8,0.8v7.6c0,0.4,0.3,0.8,0.8,0.8h9.1c0.4,0,0.8-0.3,0.8-0.8v-2.7l1.7,1.7c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.5V8.4c0-0.4-0.3-0.8-0.8-0.8\n\tc-0.2,0-0.4,0.1-0.5,0.2L16.3,9.6z M21.5,1.6H2.9c-0.7,0-1.3,0.7-1.3,1.6v14.6c0,0.9,0.6,1.6,1.3,1.6h7.6v1.1l-5,1c-0.2,0-0.4,0.3-0.4,0.6c0,0.3,0.2,0.4,0.4,0.4c0,0,0,0,0.1,0l5.3-1h2.6l5.3,1c0,0,0,0,0.1,0c0.2,0,0.4-0.2,0.4-0.4\n c0-0.3-0.1-0.6-0.4-0.6l-5-1v-1.1h7.6c0.7,0,1.3-0.7,1.3-1.6V3.2C22.9,2.3,22.3,1.6,21.5,1.6z M21.1,17.3H3.3V3.7h17.8L21.1,17.3L21.1,17.3z",
938
- tooltip: 'Screen Record',
939
- click: function (editor) {
940
- navigator.mediaDevices.getDisplayMedia({ video: true })
941
- .then(function (stream) {
942
- var chunks = [];
943
- var options = { mimeType: 'video/webm; codecs=vp9' };
944
- var mediaRecorder = new MediaRecorder(stream, options);
945
- stream.addEventListener('inactive', function (e) {
946
- mediaRecorder.stop();
947
- mediaRecorder = null;
948
- stream.getTracks().forEach(function (track) { return track.stop(); });
949
- stream = null;
950
- var blob = new Blob(chunks, { type: 'video/webm' });
951
- config.upload(blob)
952
- .subscribe(function (url) {
953
- editor.html.insert("<span class=\"fr-screen-record fr-deletable fr-draggable\"><video controls style=\"max-width:" + config.maxWidth + "\"><source src=\"" + url + "\" type=\"video/webm\"></video></span>");
954
- });
955
- });
956
- mediaRecorder.addEventListener('dataavailable', function (event) {
957
- if (event.data && event.data.size > 0) {
958
- chunks.push(event.data);
959
- }
960
- });
961
- mediaRecorder.start(10);
962
- })
963
- .catch(function (e) { });
964
- }
965
- }
966
- ] });
967
- return _this;
968
- }
969
- ScreenRecordPlugin.prototype.initialize = function () {
970
- return __awaiter(this, void 0, void 0, function () {
971
- var FroalaEditor;
972
- var _this = this;
973
- return __generator(this, function (_a) {
974
- switch (_a.label) {
975
- case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
976
- .toPromise()];
977
- case 1:
978
- _a.sent();
979
- FroalaEditor = window.FroalaEditor;
980
- this.editor.events.on('mouseup', function (e) {
981
- var el = _this._getEl(e.target);
982
- if (el) {
983
- _this.editor.popups.hideAll();
984
- _this._activeEl = el;
985
- _this._showPopup(el);
986
- }
987
- });
988
- FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
989
- FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
990
- FroalaEditor.RegisterCommand('popupClose', {
991
- title: 'Remove',
992
- undo: false,
993
- focus: false,
994
- callback: function () {
995
- if (_this._activeEl) {
996
- _this._activeEl.remove();
997
- }
998
- }
999
- });
1000
- return [2 /*return*/];
1001
- }
1002
- });
1003
- });
1004
- };
1005
- ScreenRecordPlugin.prototype._createPopup = function () {
1006
- var template = {
1007
- buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
1008
- };
1009
- return this.editor.popups.create('screenRecordPlugin.popup', template);
1010
- };
1011
- ScreenRecordPlugin.prototype._showPopup = function (el) {
1012
- var $popup = this.editor.popups.get('screenRecordPlugin.popup');
1013
- if (!$popup) {
1014
- $popup = this._createPopup();
1015
- }
1016
- this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
1017
- var left = el.offsetLeft + el.offsetWidth / 2;
1018
- this.editor.popups.show('screenRecordPlugin.popup', left, null);
1019
- };
1020
- ScreenRecordPlugin.prototype._getEl = function (el) {
1021
- if (el && el.classList) {
1022
- if (el.classList.contains('fr-screen-record'))
1023
- return el;
1024
- return this._getEl(el.parentNode);
1025
- }
1026
- };
1027
- return ScreenRecordPlugin;
935
+ var ScreenRecordPlugin = /** @class */ (function (_super) {
936
+ __extends(ScreenRecordPlugin, _super);
937
+ function ScreenRecordPlugin(config) {
938
+ if (config === void 0) { config = {}; }
939
+ var _this = _super.call(this) || this;
940
+ _this.config = config;
941
+ _this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
942
+ {
943
+ name: 'screenRecord',
944
+ svgPath: "M14.7,7.7v6.1H7.1V7.7H14.7 M16.3,9.6V6.9c0-0.4-0.3-0.8-0.8-0.8H6.4c-0.4,0-0.8,0.3-0.8,0.8v7.6c0,0.4,0.3,0.8,0.8,0.8h9.1c0.4,0,0.8-0.3,0.8-0.8v-2.7l1.7,1.7c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.5V8.4c0-0.4-0.3-0.8-0.8-0.8\n\tc-0.2,0-0.4,0.1-0.5,0.2L16.3,9.6z M21.5,1.6H2.9c-0.7,0-1.3,0.7-1.3,1.6v14.6c0,0.9,0.6,1.6,1.3,1.6h7.6v1.1l-5,1c-0.2,0-0.4,0.3-0.4,0.6c0,0.3,0.2,0.4,0.4,0.4c0,0,0,0,0.1,0l5.3-1h2.6l5.3,1c0,0,0,0,0.1,0c0.2,0,0.4-0.2,0.4-0.4\n c0-0.3-0.1-0.6-0.4-0.6l-5-1v-1.1h7.6c0.7,0,1.3-0.7,1.3-1.6V3.2C22.9,2.3,22.3,1.6,21.5,1.6z M21.1,17.3H3.3V3.7h17.8L21.1,17.3L21.1,17.3z",
945
+ tooltip: 'Screen Record',
946
+ click: function (editor) {
947
+ navigator.mediaDevices.getDisplayMedia({ video: true })
948
+ .then(function (stream) {
949
+ var chunks = [];
950
+ var options = { mimeType: 'video/webm; codecs=vp9' };
951
+ var mediaRecorder = new MediaRecorder(stream, options);
952
+ stream.addEventListener('inactive', function (e) {
953
+ mediaRecorder.stop();
954
+ mediaRecorder = null;
955
+ stream.getTracks().forEach(function (track) { return track.stop(); });
956
+ stream = null;
957
+ var blob = new Blob(chunks, { type: 'video/webm' });
958
+ config.upload(blob)
959
+ .subscribe(function (url) {
960
+ editor.html.insert("<span class=\"fr-screen-record fr-deletable fr-draggable\"><video controls style=\"max-width:" + config.maxWidth + "\"><source src=\"" + url + "\" type=\"video/webm\"></video></span>");
961
+ });
962
+ });
963
+ mediaRecorder.addEventListener('dataavailable', function (event) {
964
+ if (event.data && event.data.size > 0) {
965
+ chunks.push(event.data);
966
+ }
967
+ });
968
+ mediaRecorder.start(10);
969
+ })
970
+ .catch(function (e) { });
971
+ }
972
+ }
973
+ ] });
974
+ return _this;
975
+ }
976
+ ScreenRecordPlugin.prototype.initialize = function () {
977
+ return __awaiter(this, void 0, void 0, function () {
978
+ var FroalaEditor;
979
+ var _this = this;
980
+ return __generator(this, function (_a) {
981
+ switch (_a.label) {
982
+ case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
983
+ .toPromise()];
984
+ case 1:
985
+ _a.sent();
986
+ FroalaEditor = window.FroalaEditor;
987
+ this.editor.events.on('mouseup', function (e) {
988
+ var el = _this._getEl(e.target);
989
+ if (el) {
990
+ _this.editor.popups.hideAll();
991
+ _this._activeEl = el;
992
+ _this._showPopup(el);
993
+ }
994
+ });
995
+ FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
996
+ FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
997
+ FroalaEditor.RegisterCommand('popupClose', {
998
+ title: 'Remove',
999
+ undo: false,
1000
+ focus: false,
1001
+ callback: function () {
1002
+ if (_this._activeEl) {
1003
+ _this._activeEl.remove();
1004
+ }
1005
+ }
1006
+ });
1007
+ return [2 /*return*/];
1008
+ }
1009
+ });
1010
+ });
1011
+ };
1012
+ ScreenRecordPlugin.prototype._createPopup = function () {
1013
+ var template = {
1014
+ buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
1015
+ };
1016
+ return this.editor.popups.create('screenRecordPlugin.popup', template);
1017
+ };
1018
+ ScreenRecordPlugin.prototype._showPopup = function (el) {
1019
+ var $popup = this.editor.popups.get('screenRecordPlugin.popup');
1020
+ if (!$popup) {
1021
+ $popup = this._createPopup();
1022
+ }
1023
+ this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
1024
+ var left = el.offsetLeft + el.offsetWidth / 2;
1025
+ this.editor.popups.show('screenRecordPlugin.popup', left, null);
1026
+ };
1027
+ ScreenRecordPlugin.prototype._getEl = function (el) {
1028
+ if (el && el.classList) {
1029
+ if (el.classList.contains('fr-screen-record'))
1030
+ return el;
1031
+ return this._getEl(el.parentNode);
1032
+ }
1033
+ };
1034
+ return ScreenRecordPlugin;
1028
1035
  }(Plugin));
1029
1036
 
1030
- /**
1031
- * Generated bundle index. Do not edit.
1037
+ /**
1038
+ * Generated bundle index. Do not edit.
1032
1039
  */
1033
1040
 
1034
1041
  export { ChecklistPlugin, CodePlugin, FS_HTML_EDITOR_CONFIG, FsHtmlEditorComponent, FsHtmlEditorModule, FsHtmlRendererComponent, MentionPlugin, ParagraphButtons, RichButtons, ScreenRecordPlugin, TextButtons, FsHtmlEditorConfigFactory as ɵa, FS_HTML_EDITOR_DEFAULT_CONFIG as ɵb, FsFroalaLoaderService as ɵc, Plugin as ɵe };