@firestitch/html-editor 9.5.9 → 12.0.2

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