@firestitch/html-editor 9.5.6 → 9.5.9

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 (66) hide show
  1. package/app/classes/plugin.d.ts +7 -7
  2. package/app/components/html-editor/html-editor.component.d.ts +54 -54
  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 +14 -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 -31
  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 +13 -12
  16. package/app/plugins/configs/screen-record-plugin.config.d.ts +7 -7
  17. package/app/plugins/mention.plugin.d.ts +15 -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 +1031 -1018
  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 +444 -444
  27. package/esm2015/app/components/html-renderer/html-renderer.component.js +34 -34
  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/fs-html-editor.module.js +56 -56
  32. package/esm2015/app/injects/config.inject.js +3 -3
  33. package/esm2015/app/plugins/checklist.plugin.js +34 -34
  34. package/esm2015/app/plugins/code.plugin.js +62 -62
  35. package/esm2015/app/plugins/configs/mention-plugin.config.js +1 -1
  36. package/esm2015/app/plugins/mention.plugin.js +87 -73
  37. package/esm2015/app/plugins/screen-record.plugin.js +91 -91
  38. package/esm2015/app/services/froala-loader.service.js +80 -80
  39. package/esm2015/app/utils/loader.js +82 -82
  40. package/esm2015/firestitch-html-editor.js +8 -8
  41. package/esm2015/public_api.js +11 -11
  42. package/esm5/app/classes/plugin.js +8 -8
  43. package/esm5/app/components/html-editor/html-editor.component.js +470 -470
  44. package/esm5/app/components/html-renderer/html-renderer.component.js +39 -39
  45. package/esm5/app/consts/paragraph-buttons.const.js +8 -8
  46. package/esm5/app/consts/rich-buttons.const.js +6 -6
  47. package/esm5/app/consts/text-buttons.const.js +18 -18
  48. package/esm5/app/fs-html-editor.module.js +61 -61
  49. package/esm5/app/injects/config.inject.js +3 -3
  50. package/esm5/app/plugins/checklist.plugin.js +40 -40
  51. package/esm5/app/plugins/code.plugin.js +69 -69
  52. package/esm5/app/plugins/configs/mention-plugin.config.js +1 -1
  53. package/esm5/app/plugins/mention.plugin.js +93 -79
  54. package/esm5/app/plugins/screen-record.plugin.js +105 -105
  55. package/esm5/app/services/froala-loader.service.js +95 -95
  56. package/esm5/app/utils/loader.js +82 -82
  57. package/esm5/firestitch-html-editor.js +8 -8
  58. package/esm5/public_api.js +11 -11
  59. package/fesm2015/firestitch-html-editor.js +950 -936
  60. package/fesm2015/firestitch-html-editor.js.map +1 -1
  61. package/fesm5/firestitch-html-editor.js +1030 -1016
  62. package/fesm5/firestitch-html-editor.js.map +1 -1
  63. package/firestitch-html-editor.d.ts +9 -9
  64. package/firestitch-html-editor.metadata.json +1 -1
  65. package/package.json +1 -1
  66. package/public_api.d.ts +16 -16
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@firestitch/skeleton'), require('@angular/forms'), require('@firestitch/file'), require('rxjs'), require('rxjs/operators'), require('lodash-es'), require('@angular/platform-browser'), require('tributejs')) :
3
- typeof define === 'function' && define.amd ? define('@firestitch/html-editor', ['exports', '@angular/core', '@angular/common', '@firestitch/skeleton', '@angular/forms', '@firestitch/file', 'rxjs', 'rxjs/operators', 'lodash-es', '@angular/platform-browser', 'tributejs'], factory) :
4
- (global = global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch['html-editor'] = {}), global.ng.core, global.ng.common, global.skeleton, global.ng.forms, global.file, global.rxjs, global.rxjs.operators, global.lodashEs, global.ng.platformBrowser, global.Tribute));
5
- }(this, (function (exports, core, common, skeleton, forms, file, rxjs, operators, lodashEs, platformBrowser, Tribute) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@firestitch/skeleton'), require('@angular/forms'), require('@firestitch/file'), require('rxjs'), require('rxjs/operators'), require('lodash-es'), require('@angular/platform-browser'), require('tributejs'), require('@firestitch/common')) :
3
+ typeof define === 'function' && define.amd ? define('@firestitch/html-editor', ['exports', '@angular/core', '@angular/common', '@firestitch/skeleton', '@angular/forms', '@firestitch/file', 'rxjs', 'rxjs/operators', 'lodash-es', '@angular/platform-browser', 'tributejs', '@firestitch/common'], factory) :
4
+ (global = global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch['html-editor'] = {}), global.ng.core, global.ng.common, global.skeleton, global.ng.forms, global.file, global.rxjs, global.rxjs.operators, global.lodashEs, global.ng.platformBrowser, global.Tribute, global.common$1));
5
+ }(this, (function (exports, core, common, skeleton, forms, file, rxjs, operators, lodashEs, platformBrowser, Tribute, common$1) { 'use strict';
6
6
 
7
7
  Tribute = Tribute && Object.prototype.hasOwnProperty.call(Tribute, 'default') ? Tribute['default'] : Tribute;
8
8
 
@@ -246,1046 +246,1059 @@
246
246
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
247
247
  }
248
248
 
249
- var RichButtons = [
250
- 'insertTable',
251
- 'insertImage',
252
- 'insertLink',
253
- 'insertVideo',
249
+ var RichButtons = [
250
+ 'insertTable',
251
+ 'insertImage',
252
+ 'insertLink',
253
+ 'insertVideo',
254
254
  ];
255
255
 
256
- var TextButtons = [
257
- 'paragraphFormat',
258
- 'code',
259
- 'bold',
260
- 'italic',
261
- 'underline',
262
- 'strikeThrough',
263
- 'subscript',
264
- 'superscript',
265
- 'fontFamily',
266
- 'fontSize',
267
- 'textColor',
268
- 'backgroundColor',
269
- 'inlineClass',
270
- 'inlineStyle',
271
- 'clearFormatting',
272
- 'quote',
256
+ var TextButtons = [
257
+ 'paragraphFormat',
258
+ 'code',
259
+ 'bold',
260
+ 'italic',
261
+ 'underline',
262
+ 'strikeThrough',
263
+ 'subscript',
264
+ 'superscript',
265
+ 'fontFamily',
266
+ 'fontSize',
267
+ 'textColor',
268
+ 'backgroundColor',
269
+ 'inlineClass',
270
+ 'inlineStyle',
271
+ 'clearFormatting',
272
+ 'quote',
273
273
  ];
274
274
 
275
- var ParagraphButtons = [
276
- 'align',
277
- 'formatOL',
278
- 'formatUL',
279
- 'checklist',
280
- 'indent',
281
- 'outdent',
275
+ var ParagraphButtons = [
276
+ 'align',
277
+ 'formatOL',
278
+ 'formatUL',
279
+ 'checklist',
280
+ 'indent',
281
+ 'outdent',
282
282
  ];
283
283
 
284
- var FS_HTML_EDITOR_DEFAULT_CONFIG = new core.InjectionToken('fs-html-editor.default-config');
284
+ var FS_HTML_EDITOR_DEFAULT_CONFIG = new core.InjectionToken('fs-html-editor.default-config');
285
285
  var FS_HTML_EDITOR_CONFIG = new core.InjectionToken('fs-html-editor.config');
286
286
 
287
- function resourceLoaderFactory() {
288
- var resourceBase = '/assets/js/froala/';
289
- var stylesBase = '/assets/css/';
290
- var head = document.getElementsByTagName('head')[0];
291
- var files = new Map();
292
- var resourcePaths = {
293
- froala: 'froala_editor.min.js',
294
- align: 'plugins/align.min.js',
295
- colors: 'plugins/colors.min.js',
296
- image: 'plugins/image.min.js',
297
- link: 'plugins/link.min.js',
298
- lists: 'plugins/lists.min.js',
299
- paragraph_format: 'plugins/paragraph_format.min.js',
300
- table: 'plugins/table.min.js',
301
- url: 'plugins/url.min.js',
302
- video: 'plugins/video.min.js',
303
- quote: 'plugins/quote.min.js',
304
- draggable: 'plugins/draggable.min.js',
305
- font_size: 'plugins/font_size.min.js',
306
- };
307
- var stylesPaths = {
308
- froala: 'froala_editor.pkgd.min.css',
309
- };
310
- var loadResource = function (scriptPath) {
311
- if (!files.has(scriptPath)) {
312
- var obs$ = new rxjs.Observable(function (obs) {
313
- var script = document.createElement('script');
314
- script.src = scriptPath;
315
- head.appendChild(script);
316
- script.onload = function () {
317
- obs.next();
318
- obs.complete();
319
- };
320
- script.onerror = function (err) {
321
- obs.error(err);
322
- };
323
- })
324
- .pipe(operators.shareReplay(1));
325
- files.set(scriptPath, obs$);
326
- }
327
- return files.get(scriptPath);
328
- };
329
- var loadStyles = function (stylePath) {
330
- if (!files.has(stylePath)) {
331
- var obs$ = new rxjs.Observable(function (obs) {
332
- var style = document.createElement('link');
333
- style.id = stylePath;
334
- style.rel = 'stylesheet';
335
- style.href = "" + stylePath;
336
- head.appendChild(style);
337
- style.onload = function () {
338
- obs.next();
339
- obs.complete();
340
- };
341
- style.onerror = function (err) {
342
- obs.error(err);
343
- };
344
- });
345
- files.set(stylePath, obs$);
346
- }
347
- return files.get(stylePath);
348
- };
349
- return {
350
- setResourceBase: function (path) {
351
- resourceBase = path;
352
- },
353
- setStylesBase: function (path) {
354
- stylesBase = path;
355
- },
356
- loadResource: function (resourceName) {
357
- var path = resourcePaths[resourceName] || resourceName;
358
- return loadResource(resourceBase + path);
359
- },
360
- loadStyles: function (resourceName) {
361
- var path = stylesPaths[resourceName] || resourceName;
362
- return loadStyles(stylesBase + path);
363
- }
364
- };
365
- }
287
+ function resourceLoaderFactory() {
288
+ var resourceBase = '/assets/js/froala/';
289
+ var stylesBase = '/assets/css/';
290
+ var head = document.getElementsByTagName('head')[0];
291
+ var files = new Map();
292
+ var resourcePaths = {
293
+ froala: 'froala_editor.min.js',
294
+ align: 'plugins/align.min.js',
295
+ colors: 'plugins/colors.min.js',
296
+ image: 'plugins/image.min.js',
297
+ link: 'plugins/link.min.js',
298
+ lists: 'plugins/lists.min.js',
299
+ paragraph_format: 'plugins/paragraph_format.min.js',
300
+ table: 'plugins/table.min.js',
301
+ url: 'plugins/url.min.js',
302
+ video: 'plugins/video.min.js',
303
+ quote: 'plugins/quote.min.js',
304
+ draggable: 'plugins/draggable.min.js',
305
+ font_size: 'plugins/font_size.min.js',
306
+ };
307
+ var stylesPaths = {
308
+ froala: 'froala_editor.pkgd.min.css',
309
+ };
310
+ var loadResource = function (scriptPath) {
311
+ if (!files.has(scriptPath)) {
312
+ var obs$ = new rxjs.Observable(function (obs) {
313
+ var script = document.createElement('script');
314
+ script.src = scriptPath;
315
+ head.appendChild(script);
316
+ script.onload = function () {
317
+ obs.next();
318
+ obs.complete();
319
+ };
320
+ script.onerror = function (err) {
321
+ obs.error(err);
322
+ };
323
+ })
324
+ .pipe(operators.shareReplay(1));
325
+ files.set(scriptPath, obs$);
326
+ }
327
+ return files.get(scriptPath);
328
+ };
329
+ var loadStyles = function (stylePath) {
330
+ if (!files.has(stylePath)) {
331
+ var obs$ = new rxjs.Observable(function (obs) {
332
+ var style = document.createElement('link');
333
+ style.id = stylePath;
334
+ style.rel = 'stylesheet';
335
+ style.href = "" + stylePath;
336
+ head.appendChild(style);
337
+ style.onload = function () {
338
+ obs.next();
339
+ obs.complete();
340
+ };
341
+ style.onerror = function (err) {
342
+ obs.error(err);
343
+ };
344
+ });
345
+ files.set(stylePath, obs$);
346
+ }
347
+ return files.get(stylePath);
348
+ };
349
+ return {
350
+ setResourceBase: function (path) {
351
+ resourceBase = path;
352
+ },
353
+ setStylesBase: function (path) {
354
+ stylesBase = path;
355
+ },
356
+ loadResource: function (resourceName) {
357
+ var path = resourcePaths[resourceName] || resourceName;
358
+ return loadResource(resourceBase + path);
359
+ },
360
+ loadStyles: function (resourceName) {
361
+ var path = stylesPaths[resourceName] || resourceName;
362
+ return loadStyles(stylesBase + path);
363
+ }
364
+ };
365
+ }
366
366
  var ResourceLoader = resourceLoaderFactory();
367
367
 
368
- var FsFroalaLoaderService = /** @class */ (function () {
369
- function FsFroalaLoaderService(_defaultConfig) {
370
- this._defaultConfig = _defaultConfig;
371
- this._froalaLoaded = new rxjs.BehaviorSubject(false);
372
- this._defaultPluginsLoaded = new rxjs.BehaviorSubject(false);
373
- this._loaded$ = rxjs.combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
374
- .pipe(operators.map(function (_a) {
375
- var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
376
- return pluginsRead && FroalaReady;
377
- }), operators.shareReplay(1));
378
- if (this._defaultConfig) {
379
- if (this._defaultConfig.assetsJSPath) {
380
- ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
381
- }
382
- if (this._defaultConfig.assetsCSSPath) {
383
- ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
384
- }
385
- }
386
- this._load();
387
- }
388
- Object.defineProperty(FsFroalaLoaderService.prototype, "loaded$", {
389
- get: function () {
390
- return this._loaded$;
391
- },
392
- enumerable: true,
393
- configurable: true
394
- });
395
- Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
396
- get: function () {
397
- return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
398
- },
399
- enumerable: true,
400
- configurable: true
401
- });
402
- Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
403
- get: function () {
404
- return this._FroalaEditor;
405
- },
406
- enumerable: true,
407
- configurable: true
408
- });
409
- FsFroalaLoaderService.prototype._load = function () {
410
- var _this = this;
411
- rxjs.combineLatest([
412
- ResourceLoader.loadResource('froala'),
413
- ResourceLoader.loadStyles('froala')
414
- ])
415
- .pipe(operators.tap(function () {
416
- _this._FroalaEditor = window.FroalaEditor;
417
- _this._froalaDone();
418
- }), operators.concatMap(function () {
419
- return _this._loadPlugins();
420
- }), operators.tap(function () {
421
- _this._defaultPluginsDone();
422
- }))
423
- .subscribe();
424
- };
425
- FsFroalaLoaderService.prototype._loadPlugins = function () {
426
- var imports = this._defaultConfig
427
- .defaultPlugins
428
- .reduce(function (acc, pluginName) {
429
- var import$ = ResourceLoader.loadResource(pluginName);
430
- acc.push(import$);
431
- return acc;
432
- }, []);
433
- return rxjs.combineLatest(imports);
434
- };
435
- FsFroalaLoaderService.prototype._froalaDone = function () {
436
- this._froalaLoaded.next(true);
437
- };
438
- FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
439
- this._defaultPluginsLoaded.next(true);
440
- };
441
- FsFroalaLoaderService.ctorParameters = function () { return [
442
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
443
- ]; };
444
- FsFroalaLoaderService.ɵprov = core.ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(core.ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
445
- FsFroalaLoaderService = __decorate([
446
- core.Injectable({
447
- providedIn: 'root',
448
- }),
449
- __param(0, core.Optional()), __param(0, core.Inject(FS_HTML_EDITOR_CONFIG)),
450
- __metadata("design:paramtypes", [Object])
451
- ], FsFroalaLoaderService);
452
- return FsFroalaLoaderService;
368
+ var FsFroalaLoaderService = /** @class */ (function () {
369
+ function FsFroalaLoaderService(_defaultConfig) {
370
+ this._defaultConfig = _defaultConfig;
371
+ this._froalaLoaded = new rxjs.BehaviorSubject(false);
372
+ this._defaultPluginsLoaded = new rxjs.BehaviorSubject(false);
373
+ this._loaded$ = rxjs.combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
374
+ .pipe(operators.map(function (_a) {
375
+ var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
376
+ return pluginsRead && FroalaReady;
377
+ }), operators.shareReplay(1));
378
+ if (this._defaultConfig) {
379
+ if (this._defaultConfig.assetsJSPath) {
380
+ ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
381
+ }
382
+ if (this._defaultConfig.assetsCSSPath) {
383
+ ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
384
+ }
385
+ }
386
+ this._load();
387
+ }
388
+ Object.defineProperty(FsFroalaLoaderService.prototype, "loaded$", {
389
+ get: function () {
390
+ return this._loaded$;
391
+ },
392
+ enumerable: true,
393
+ configurable: true
394
+ });
395
+ Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
396
+ get: function () {
397
+ return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
398
+ },
399
+ enumerable: true,
400
+ configurable: true
401
+ });
402
+ Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
403
+ get: function () {
404
+ return this._FroalaEditor;
405
+ },
406
+ enumerable: true,
407
+ configurable: true
408
+ });
409
+ FsFroalaLoaderService.prototype._load = function () {
410
+ var _this = this;
411
+ rxjs.combineLatest([
412
+ ResourceLoader.loadResource('froala'),
413
+ ResourceLoader.loadStyles('froala')
414
+ ])
415
+ .pipe(operators.tap(function () {
416
+ _this._FroalaEditor = window.FroalaEditor;
417
+ _this._froalaDone();
418
+ }), operators.concatMap(function () {
419
+ return _this._loadPlugins();
420
+ }), operators.tap(function () {
421
+ _this._defaultPluginsDone();
422
+ }))
423
+ .subscribe();
424
+ };
425
+ FsFroalaLoaderService.prototype._loadPlugins = function () {
426
+ var imports = this._defaultConfig
427
+ .defaultPlugins
428
+ .reduce(function (acc, pluginName) {
429
+ var import$ = ResourceLoader.loadResource(pluginName);
430
+ acc.push(import$);
431
+ return acc;
432
+ }, []);
433
+ return rxjs.combineLatest(imports);
434
+ };
435
+ FsFroalaLoaderService.prototype._froalaDone = function () {
436
+ this._froalaLoaded.next(true);
437
+ };
438
+ FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
439
+ this._defaultPluginsLoaded.next(true);
440
+ };
441
+ FsFroalaLoaderService.ctorParameters = function () { return [
442
+ { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
443
+ ]; };
444
+ FsFroalaLoaderService.ɵprov = core.ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(core.ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
445
+ FsFroalaLoaderService = __decorate([
446
+ core.Injectable({
447
+ providedIn: 'root',
448
+ }),
449
+ __param(0, core.Optional()), __param(0, core.Inject(FS_HTML_EDITOR_CONFIG)),
450
+ __metadata("design:paramtypes", [Object])
451
+ ], FsFroalaLoaderService);
452
+ return FsFroalaLoaderService;
453
453
  }());
454
454
 
455
- var FsHtmlEditorComponent = /** @class */ (function () {
456
- function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
457
- this._defaultConfig = _defaultConfig;
458
- this._cdRef = _cdRef;
459
- this._fr = _fr;
460
- this.classFocused = false;
461
- this.classDisabled = false;
462
- this.config = {};
463
- this.initialized = false;
464
- this._initialize$ = new rxjs.ReplaySubject();
465
- this._froalaReady$ = new rxjs.BehaviorSubject(null);
466
- this._destroy$ = new rxjs.Subject();
467
- this.onChange = function (data) { };
468
- this.onTouched = function () { };
469
- }
470
- FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
471
- Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
472
- get: function () {
473
- return this.elRef.nativeElement;
474
- },
475
- enumerable: true,
476
- configurable: true
477
- });
478
- Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
479
- get: function () {
480
- return this._html;
481
- },
482
- enumerable: true,
483
- configurable: true
484
- });
485
- Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
486
- get: function () {
487
- return this._editor;
488
- },
489
- enumerable: true,
490
- configurable: true
491
- });
492
- Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaLoaded$", {
493
- get: function () {
494
- return this._fr.loaded$;
495
- },
496
- enumerable: true,
497
- configurable: true
498
- });
499
- FsHtmlEditorComponent.prototype.ngOnInit = function () {
500
- this.config = this.config || {};
501
- this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
502
- this.initialized = !this.config.initOnClick;
503
- this._listenLazyInit();
504
- };
505
- FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
506
- if (!this.config.initOnClick || !this.hasContent()) {
507
- this.initialized = true;
508
- this._initialize$.next();
509
- }
510
- };
511
- FsHtmlEditorComponent.prototype.hasContent = function () {
512
- var el = document.createElement('div');
513
- if (el.querySelector('img')) {
514
- return true;
515
- }
516
- el.innerHTML = this._html;
517
- return !!el.innerText.length;
518
- };
519
- FsHtmlEditorComponent.prototype.initialize = function (options) {
520
- var _this = this;
521
- if (options === void 0) { options = {}; }
522
- var config = this._createConfig();
523
- this._initPlugins(config);
524
- // this.el.innerHTML = this._html || '';
525
- this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
526
- _this._froalaReady$.next({ config: config, options: options });
527
- });
528
- };
529
- FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
530
- var _this = this;
531
- var processor = new file.FileProcessor();
532
- var file$1 = new file.FsFile(blob);
533
- return processor.process([file$1], this.config.image)
534
- .pipe(operators.switchMap(function (_a) {
535
- var _b = __read(_a, 1), f = _b[0];
536
- return _this.config.image.upload(f.file);
537
- }));
538
- };
539
- FsHtmlEditorComponent.prototype._getTextNode = function (node) {
540
- if (node) {
541
- if (node.nodeType === Node.TEXT_NODE) {
542
- return node;
543
- }
544
- if (node.childNodes) {
545
- return this._getTextNode(node.childNodes[0]);
546
- }
547
- }
548
- };
549
- FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
550
- if (!event.defaultPrevented) {
551
- var target_1 = event.target;
552
- if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
553
- var targetTarget_1 = target_1.getAttribute('target');
554
- target_1.setAttribute('target', '_blank');
555
- setTimeout(function () {
556
- if (targetTarget_1) {
557
- target_1.setAttribute('target', targetTarget_1);
558
- }
559
- else {
560
- target_1.removeAttribute('target');
561
- }
562
- });
563
- }
564
- else {
565
- if (this.config.initClick) {
566
- this.config.initClick(event);
567
- }
568
- this._initialize$.next();
569
- this.initialized = true;
570
- }
571
- }
572
- };
573
- FsHtmlEditorComponent.prototype.updateSize = function () {
574
- // Hack: To trigger the toolbar button size modes
575
- window.dispatchEvent(new Event('resize'));
576
- };
577
- FsHtmlEditorComponent.prototype.validate = function (control) {
578
- var err = {};
579
- if (this.config.maxLength && this._html) {
580
- var maxLength = this.config.maxLength;
581
- var length_1 = this._html.length;
582
- if (length_1 > maxLength) {
583
- err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
584
- }
585
- }
586
- return Object.keys(err).length ? err : null;
587
- };
588
- FsHtmlEditorComponent.prototype.focus = function (options) {
589
- options = options ? options : {};
590
- if (options.cursorPosition === 'end') {
591
- this.editor.selection.setAtEnd(this.editor.$el.get(0));
592
- }
593
- else {
594
- this.editor.selection.setAtStart(this.editor.$el.get(0));
595
- }
596
- this.editor.selection.restore();
597
- var elSelection = this.editor.selection.element();
598
- if (elSelection) {
599
- elSelection.scrollIntoView({ block: 'center' });
600
- }
601
- };
602
- FsHtmlEditorComponent.prototype.clear = function () {
603
- this.writeValue('');
604
- };
605
- FsHtmlEditorComponent.prototype.disable = function () {
606
- this.classDisabled = true;
607
- };
608
- FsHtmlEditorComponent.prototype.setHtml = function (html) {
609
- this.writeValue(html);
610
- };
611
- FsHtmlEditorComponent.prototype.writeValue = function (html) {
612
- this._html = html || '';
613
- if (this.editor && this.editor.html) {
614
- try {
615
- this.editor.html.set(this._html);
616
- }
617
- catch (e) {
618
- }
619
- }
620
- this._cdRef.markForCheck();
621
- };
622
- FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
623
- this.onChange = fn;
624
- };
625
- FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
626
- this.onTouched = fn;
627
- };
628
- FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
629
- this._initialize$.complete();
630
- this._destroy$.next();
631
- this._destroy$.complete();
632
- this.destroy();
633
- };
634
- FsHtmlEditorComponent.prototype.destroy = function () {
635
- if (this.editor) {
636
- this.editor.destroy();
637
- }
638
- this.initialized = false;
639
- this._cdRef.markForCheck();
640
- this.el.innerHTML = '';
641
- };
642
- FsHtmlEditorComponent.prototype._createConfig = function () {
643
- return lodashEs.merge({ froalaConfig: {} }, this._defaultConfig, this.config);
644
- };
645
- FsHtmlEditorComponent.prototype._change = function (html) {
646
- // this._html = html;
647
- this.onChange(html);
648
- };
649
- FsHtmlEditorComponent.prototype._initPlugins = function (config) {
650
- var _this = this;
651
- (config.plugins || []).forEach(function (plugin) {
652
- _this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
653
- plugin.editor = editor;
654
- plugin.initialize();
655
- return plugin;
656
- };
657
- (plugin.config.buttons || []).forEach(function (button) {
658
- _this._fr.FroalaEditor.DefineIcon(button.name, {
659
- NAME: button.name,
660
- PATH: button.svgPath,
661
- });
662
- _this._fr.FroalaEditor.RegisterCommand(button.name, {
663
- icon: button.name,
664
- title: button.tooltip,
665
- undo: button.undo,
666
- focus: button.focus,
667
- showOnMobile: button.showOnMobile,
668
- refreshAfterCallback: button.refreshAfterCallback,
669
- callback: function () {
670
- if (button.click) {
671
- button.click(this);
672
- }
673
- },
674
- refresh: function (button) {
675
- if (button.refresh) {
676
- button.refresh(this, button);
677
- }
678
- }
679
- });
680
- });
681
- });
682
- };
683
- FsHtmlEditorComponent.prototype._createOptions = function () {
684
- var config = this._createConfig();
685
- return lodashEs.merge(
686
- // For some reason editor store somewhere pointer on default config object and dublicate options each time on init
687
- // Extra merge level fixed this problem and allow to init config properly without legacy data
688
- {}, {
689
- key: config.activationKey,
690
- placeholderText: config.placeholder,
691
- linkAlwaysBlank: true,
692
- tabSpaces: 2,
693
- typingTimer: 250,
694
- tooltips: false,
695
- wordPasteModal: false,
696
- imageDefaultWidth: 0,
697
- imageDefaultAlign: 'left',
698
- quickInsertEnabled: false,
699
- paragraphDefaultSelection: 'Format',
700
- videoUpload: false,
701
- paragraphFormat: {
702
- N: 'Normal',
703
- H1: 'Heading 1',
704
- H2: 'Heading 2',
705
- H3: 'Heading 3',
706
- H4: 'Heading 4',
707
- BLOCKQUOTE: 'Quote',
708
- },
709
- paragraphFormatSelection: true,
710
- toolbarButtonsXS: {
711
- moreText: {
712
- buttons: TextButtons,
713
- buttonsVisible: 1,
714
- },
715
- moreParagraph: {
716
- buttons: ParagraphButtons,
717
- buttonsVisible: 2,
718
- },
719
- moreRich: {
720
- buttons: RichButtons,
721
- buttonsVisible: 0,
722
- },
723
- },
724
- toolbarButtons: {
725
- moreText: {
726
- buttons: TextButtons,
727
- buttonsVisible: 3,
728
- },
729
- moreParagraph: {
730
- buttons: ParagraphButtons,
731
- buttonsVisible: 5,
732
- },
733
- moreRich: {
734
- buttons: RichButtons,
735
- buttonsVisible: 3,
736
- },
737
- },
738
- }, config.froalaConfig);
739
- };
740
- FsHtmlEditorComponent.prototype._listenLazyInit = function () {
741
- var _this = this;
742
- this.froalaLoaded$
743
- .pipe(operators.filter(function (ready) { return ready; }), operators.switchMap(function () { return _this._initialize$; }), operators.tap(function () {
744
- var selection = window.getSelection();
745
- var options = {};
746
- if (selection.baseNode) {
747
- options.selection = {
748
- node: selection.baseNode.nodeValue,
749
- offset: selection.baseOffset,
750
- };
751
- }
752
- _this.initialize(options);
753
- }), operators.switchMap(function () { return _this._froalaReady$; }), operators.filter(function (data) { return !!data; }), operators.tap(function (_a) {
754
- var config = _a.config, options = _a.options;
755
- _this._setupFroala(config, options);
756
- }))
757
- .subscribe();
758
- };
759
- FsHtmlEditorComponent.prototype._contentChanged = function () {
760
- var editorHTML = this._editor.html.get();
761
- if (this.html !== editorHTML) {
762
- this._change(editorHTML);
763
- }
764
- };
765
- FsHtmlEditorComponent.prototype._setupFroala = function (config, options) {
766
- var _this = this;
767
- this._cdRef.markForCheck();
768
- this.setHtml(this._html);
769
- if (config.disabled) {
770
- this.disable();
771
- }
772
- if (config.froalaConfig.events) {
773
- if (config.froalaConfig.events.initialized) {
774
- config.froalaConfig.events.initialized();
775
- }
776
- }
777
- this._editor.events.on('focus', function () {
778
- _this.classFocused = true;
779
- _this._cdRef.markForCheck();
780
- });
781
- this._editor.events.on('blur', function () {
782
- _this.classFocused = false;
783
- _this._cdRef.markForCheck();
784
- });
785
- rxjs.fromEventPattern(function (handler) {
786
- _this._editor.events.on('contentChanged', handler);
787
- }, function () { })
788
- .pipe(operators.startWith(this._html), operators.map(function () { return _this.editor.html.get(); }), operators.distinctUntilChanged(), operators.skip(1))
789
- .subscribe(function () {
790
- _this._contentChanged();
791
- });
792
- // this._editor.events.on('contentChanged', () => {
793
- // console.log('test');
794
- // if (!this._firstChange) {
795
- // this._contentChanged();
796
- // }
797
- // });
798
- this._editor.events.on('paste.afterCleanup', function (html) {
799
- var div = document.createElement('div');
800
- div.innerHTML = html;
801
- div.querySelectorAll('*')
802
- .forEach(function (el) {
803
- for (var i = 0; i < el.attributes.length; i++) {
804
- var name_1 = el.attributes[0].name;
805
- if (name_1 !== 'href') {
806
- el.removeAttribute(name_1);
807
- }
808
- }
809
- });
810
- return div.innerHTML;
811
- });
812
- this._editor.events.on('keydown', function () {
813
- _this.onTouched();
814
- });
815
- if (this.config.image && this.config.image.upload) {
816
- this._editor.events.on('image.beforePasteUpload', function (image) {
817
- fetch(image.getAttribute('src'))
818
- .then(function (res) {
819
- res.blob()
820
- .then(function (blob) {
821
- _this._processImageUpload(blob)
822
- .pipe(operators.takeUntil(_this._destroy$))
823
- .subscribe(function (url) {
824
- image.setAttribute('src', url);
825
- image.removeAttribute('data-fr-image-pasted');
826
- _this._contentChanged();
827
- });
828
- });
829
- });
830
- return false;
831
- });
832
- this._editor.events.on('image.beforeUpload', function (blobs) {
833
- _this._processImageUpload(blobs[0])
834
- .pipe(operators.takeUntil(_this._destroy$))
835
- .subscribe(function (url) {
836
- _this.editor.image.insert(url, null, null, _this.editor.image.get());
837
- });
838
- return false;
839
- });
840
- }
841
- if (this.el.querySelector('.fr-second-toolbar')) {
842
- this.el.querySelector('.fr-second-toolbar').remove();
843
- }
844
- var selection = options.selection;
845
- if (selection) {
846
- var node = Array.from(this.el.querySelectorAll('.fr-element *')).find(function (node) {
847
- return selection.node === node.textContent;
848
- });
849
- if (node) {
850
- var range = document.createRange();
851
- var sel = window.getSelection();
852
- range.setStart(this._getTextNode(node), selection.offset);
853
- range.collapse(true);
854
- sel.removeAllRanges();
855
- sel.addRange(range);
856
- }
857
- else if (this.config.autofocus) {
858
- this.focus();
859
- }
860
- }
861
- else if (this.config.autofocus) {
862
- this.focus();
863
- }
864
- };
865
- var FsHtmlEditorComponent_1;
866
- FsHtmlEditorComponent.ctorParameters = function () { return [
867
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
868
- { type: core.ChangeDetectorRef },
869
- { type: FsFroalaLoaderService }
870
- ]; };
871
- __decorate([
872
- core.HostBinding('class.focused'),
873
- __metadata("design:type", Object)
874
- ], FsHtmlEditorComponent.prototype, "classFocused", void 0);
875
- __decorate([
876
- core.HostBinding('class.disabled'),
877
- __metadata("design:type", Object)
878
- ], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
879
- __decorate([
880
- core.ViewChild('elRef'),
881
- __metadata("design:type", core.ElementRef)
882
- ], FsHtmlEditorComponent.prototype, "elRef", void 0);
883
- __decorate([
884
- core.Input(),
885
- __metadata("design:type", Object)
886
- ], FsHtmlEditorComponent.prototype, "config", void 0);
887
- FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
888
- core.Component({
889
- selector: 'fs-html-editor',
890
- 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",
891
- providers: [
892
- {
893
- provide: forms.NG_VALUE_ACCESSOR,
894
- useExisting: core.forwardRef(function () { return FsHtmlEditorComponent_1; }),
895
- multi: true
896
- },
897
- {
898
- provide: forms.NG_VALIDATORS,
899
- useExisting: core.forwardRef(function () { return FsHtmlEditorComponent_1; }),
900
- multi: true
901
- },
902
- ],
903
- changeDetection: core.ChangeDetectionStrategy.OnPush,
904
- 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}: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}"]
905
- }),
906
- __param(0, core.Optional()), __param(0, core.Inject(FS_HTML_EDITOR_CONFIG)),
907
- __metadata("design:paramtypes", [Object, core.ChangeDetectorRef,
908
- FsFroalaLoaderService])
909
- ], FsHtmlEditorComponent);
910
- return FsHtmlEditorComponent;
455
+ var FsHtmlEditorComponent = /** @class */ (function () {
456
+ function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
457
+ this._defaultConfig = _defaultConfig;
458
+ this._cdRef = _cdRef;
459
+ this._fr = _fr;
460
+ this.classFocused = false;
461
+ this.classDisabled = false;
462
+ this.config = {};
463
+ this.initialized = false;
464
+ this._initialize$ = new rxjs.ReplaySubject();
465
+ this._froalaReady$ = new rxjs.BehaviorSubject(null);
466
+ this._destroy$ = new rxjs.Subject();
467
+ this.onChange = function (data) { };
468
+ this.onTouched = function () { };
469
+ }
470
+ FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
471
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
472
+ get: function () {
473
+ return this.elRef.nativeElement;
474
+ },
475
+ enumerable: true,
476
+ configurable: true
477
+ });
478
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
479
+ get: function () {
480
+ return this._html;
481
+ },
482
+ enumerable: true,
483
+ configurable: true
484
+ });
485
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
486
+ get: function () {
487
+ return this._editor;
488
+ },
489
+ enumerable: true,
490
+ configurable: true
491
+ });
492
+ Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaLoaded$", {
493
+ get: function () {
494
+ return this._fr.loaded$;
495
+ },
496
+ enumerable: true,
497
+ configurable: true
498
+ });
499
+ FsHtmlEditorComponent.prototype.ngOnInit = function () {
500
+ this.config = this.config || {};
501
+ this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
502
+ this.initialized = !this.config.initOnClick;
503
+ this._listenLazyInit();
504
+ };
505
+ FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
506
+ if (!this.config.initOnClick || !this.hasContent()) {
507
+ this.initialized = true;
508
+ this._initialize$.next();
509
+ }
510
+ };
511
+ FsHtmlEditorComponent.prototype.hasContent = function () {
512
+ var el = document.createElement('div');
513
+ if (el.querySelector('img')) {
514
+ return true;
515
+ }
516
+ el.innerHTML = this._html;
517
+ return !!el.innerText.length;
518
+ };
519
+ FsHtmlEditorComponent.prototype.initialize = function (options) {
520
+ var _this = this;
521
+ if (options === void 0) { options = {}; }
522
+ var config = this._createConfig();
523
+ this._initPlugins(config);
524
+ // this.el.innerHTML = this._html || '';
525
+ this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
526
+ _this._froalaReady$.next({ config: config, options: options });
527
+ });
528
+ };
529
+ FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
530
+ var _this = this;
531
+ var processor = new file.FileProcessor();
532
+ var file$1 = new file.FsFile(blob);
533
+ return processor.process([file$1], this.config.image)
534
+ .pipe(operators.switchMap(function (_a) {
535
+ var _b = __read(_a, 1), f = _b[0];
536
+ return _this.config.image.upload(f.file);
537
+ }));
538
+ };
539
+ FsHtmlEditorComponent.prototype._getTextNode = function (node) {
540
+ if (node) {
541
+ if (node.nodeType === Node.TEXT_NODE) {
542
+ return node;
543
+ }
544
+ if (node.childNodes) {
545
+ return this._getTextNode(node.childNodes[0]);
546
+ }
547
+ }
548
+ };
549
+ FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
550
+ if (!event.defaultPrevented) {
551
+ var target_1 = event.target;
552
+ if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
553
+ var targetTarget_1 = target_1.getAttribute('target');
554
+ target_1.setAttribute('target', '_blank');
555
+ setTimeout(function () {
556
+ if (targetTarget_1) {
557
+ target_1.setAttribute('target', targetTarget_1);
558
+ }
559
+ else {
560
+ target_1.removeAttribute('target');
561
+ }
562
+ });
563
+ }
564
+ else {
565
+ if (this.config.initClick) {
566
+ this.config.initClick(event);
567
+ }
568
+ this._initialize$.next();
569
+ this.initialized = true;
570
+ }
571
+ }
572
+ };
573
+ FsHtmlEditorComponent.prototype.updateSize = function () {
574
+ // Hack: To trigger the toolbar button size modes
575
+ window.dispatchEvent(new Event('resize'));
576
+ };
577
+ FsHtmlEditorComponent.prototype.validate = function (control) {
578
+ var err = {};
579
+ if (this.config.maxLength && this._html) {
580
+ var maxLength = this.config.maxLength;
581
+ var length_1 = this._html.length;
582
+ if (length_1 > maxLength) {
583
+ err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
584
+ }
585
+ }
586
+ return Object.keys(err).length ? err : null;
587
+ };
588
+ FsHtmlEditorComponent.prototype.focus = function (options) {
589
+ options = options ? options : {};
590
+ if (options.cursorPosition === 'end') {
591
+ this.editor.selection.setAtEnd(this.editor.$el.get(0));
592
+ }
593
+ else {
594
+ this.editor.selection.setAtStart(this.editor.$el.get(0));
595
+ }
596
+ this.editor.selection.restore();
597
+ var elSelection = this.editor.selection.element();
598
+ if (elSelection) {
599
+ elSelection.scrollIntoView({ block: 'center' });
600
+ }
601
+ };
602
+ FsHtmlEditorComponent.prototype.clear = function () {
603
+ this.writeValue('');
604
+ };
605
+ FsHtmlEditorComponent.prototype.disable = function () {
606
+ this.classDisabled = true;
607
+ };
608
+ FsHtmlEditorComponent.prototype.setHtml = function (html) {
609
+ this.writeValue(html);
610
+ };
611
+ FsHtmlEditorComponent.prototype.writeValue = function (html) {
612
+ this._html = html || '';
613
+ if (this.editor && this.editor.html) {
614
+ try {
615
+ this.editor.html.set(this._html);
616
+ }
617
+ catch (e) {
618
+ }
619
+ }
620
+ this._cdRef.markForCheck();
621
+ };
622
+ FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
623
+ this.onChange = fn;
624
+ };
625
+ FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
626
+ this.onTouched = fn;
627
+ };
628
+ FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
629
+ this._initialize$.complete();
630
+ this._destroy$.next();
631
+ this._destroy$.complete();
632
+ this.destroy();
633
+ };
634
+ FsHtmlEditorComponent.prototype.destroy = function () {
635
+ if (this.editor) {
636
+ this.editor.destroy();
637
+ }
638
+ this.initialized = false;
639
+ this._cdRef.markForCheck();
640
+ this.el.innerHTML = '';
641
+ };
642
+ FsHtmlEditorComponent.prototype._createConfig = function () {
643
+ return lodashEs.merge({ froalaConfig: {} }, this._defaultConfig, this.config);
644
+ };
645
+ FsHtmlEditorComponent.prototype._change = function (html) {
646
+ // this._html = html;
647
+ this.onChange(html);
648
+ };
649
+ FsHtmlEditorComponent.prototype._initPlugins = function (config) {
650
+ var _this = this;
651
+ (config.plugins || []).forEach(function (plugin) {
652
+ _this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
653
+ plugin.editor = editor;
654
+ plugin.initialize();
655
+ return plugin;
656
+ };
657
+ (plugin.config.buttons || []).forEach(function (button) {
658
+ _this._fr.FroalaEditor.DefineIcon(button.name, {
659
+ NAME: button.name,
660
+ PATH: button.svgPath,
661
+ });
662
+ _this._fr.FroalaEditor.RegisterCommand(button.name, {
663
+ icon: button.name,
664
+ title: button.tooltip,
665
+ undo: button.undo,
666
+ focus: button.focus,
667
+ showOnMobile: button.showOnMobile,
668
+ refreshAfterCallback: button.refreshAfterCallback,
669
+ callback: function () {
670
+ if (button.click) {
671
+ button.click(this);
672
+ }
673
+ },
674
+ refresh: function (button) {
675
+ if (button.refresh) {
676
+ button.refresh(this, button);
677
+ }
678
+ }
679
+ });
680
+ });
681
+ });
682
+ };
683
+ FsHtmlEditorComponent.prototype._createOptions = function () {
684
+ var config = this._createConfig();
685
+ return lodashEs.merge(
686
+ // For some reason editor store somewhere pointer on default config object and dublicate options each time on init
687
+ // Extra merge level fixed this problem and allow to init config properly without legacy data
688
+ {}, {
689
+ key: config.activationKey,
690
+ placeholderText: config.placeholder,
691
+ linkAlwaysBlank: true,
692
+ tabSpaces: 2,
693
+ typingTimer: 250,
694
+ tooltips: false,
695
+ wordPasteModal: false,
696
+ imageDefaultWidth: 0,
697
+ imageDefaultAlign: 'left',
698
+ quickInsertEnabled: false,
699
+ paragraphDefaultSelection: 'Format',
700
+ videoUpload: false,
701
+ paragraphFormat: {
702
+ N: 'Normal',
703
+ H1: 'Heading 1',
704
+ H2: 'Heading 2',
705
+ H3: 'Heading 3',
706
+ H4: 'Heading 4',
707
+ BLOCKQUOTE: 'Quote',
708
+ },
709
+ paragraphFormatSelection: true,
710
+ toolbarButtonsXS: {
711
+ moreText: {
712
+ buttons: TextButtons,
713
+ buttonsVisible: 1,
714
+ },
715
+ moreParagraph: {
716
+ buttons: ParagraphButtons,
717
+ buttonsVisible: 2,
718
+ },
719
+ moreRich: {
720
+ buttons: RichButtons,
721
+ buttonsVisible: 0,
722
+ },
723
+ },
724
+ toolbarButtons: {
725
+ moreText: {
726
+ buttons: TextButtons,
727
+ buttonsVisible: 3,
728
+ },
729
+ moreParagraph: {
730
+ buttons: ParagraphButtons,
731
+ buttonsVisible: 5,
732
+ },
733
+ moreRich: {
734
+ buttons: RichButtons,
735
+ buttonsVisible: 3,
736
+ },
737
+ },
738
+ }, config.froalaConfig);
739
+ };
740
+ FsHtmlEditorComponent.prototype._listenLazyInit = function () {
741
+ var _this = this;
742
+ this.froalaLoaded$
743
+ .pipe(operators.filter(function (ready) { return ready; }), operators.switchMap(function () { return _this._initialize$; }), operators.tap(function () {
744
+ var selection = window.getSelection();
745
+ var options = {};
746
+ if (selection.baseNode) {
747
+ options.selection = {
748
+ node: selection.baseNode.nodeValue,
749
+ offset: selection.baseOffset,
750
+ };
751
+ }
752
+ _this.initialize(options);
753
+ }), operators.switchMap(function () { return _this._froalaReady$; }), operators.filter(function (data) { return !!data; }), operators.tap(function (_a) {
754
+ var config = _a.config, options = _a.options;
755
+ _this._setupFroala(config, options);
756
+ }))
757
+ .subscribe();
758
+ };
759
+ FsHtmlEditorComponent.prototype._contentChanged = function () {
760
+ var editorHTML = this._editor.html.get();
761
+ if (this.html !== editorHTML) {
762
+ this._change(editorHTML);
763
+ }
764
+ };
765
+ FsHtmlEditorComponent.prototype._setupFroala = function (config, options) {
766
+ var _this = this;
767
+ this._cdRef.markForCheck();
768
+ this.setHtml(this._html);
769
+ if (config.disabled) {
770
+ this.disable();
771
+ }
772
+ if (config.froalaConfig.events) {
773
+ if (config.froalaConfig.events.initialized) {
774
+ config.froalaConfig.events.initialized();
775
+ }
776
+ }
777
+ this._editor.events.on('focus', function () {
778
+ _this.classFocused = true;
779
+ _this._cdRef.markForCheck();
780
+ });
781
+ this._editor.events.on('blur', function () {
782
+ _this.classFocused = false;
783
+ _this._cdRef.markForCheck();
784
+ });
785
+ rxjs.fromEventPattern(function (handler) {
786
+ _this._editor.events.on('contentChanged', handler);
787
+ }, function () { })
788
+ .pipe(operators.startWith(this._html), operators.map(function () { return _this.editor.html.get(); }), operators.distinctUntilChanged(), operators.skip(1))
789
+ .subscribe(function () {
790
+ _this._contentChanged();
791
+ });
792
+ // this._editor.events.on('contentChanged', () => {
793
+ // console.log('test');
794
+ // if (!this._firstChange) {
795
+ // this._contentChanged();
796
+ // }
797
+ // });
798
+ this._editor.events.on('paste.afterCleanup', function (html) {
799
+ var div = document.createElement('div');
800
+ div.innerHTML = html;
801
+ div.querySelectorAll('*')
802
+ .forEach(function (el) {
803
+ for (var i = 0; i < el.attributes.length; i++) {
804
+ var name_1 = el.attributes[0].name;
805
+ if (name_1 !== 'href') {
806
+ el.removeAttribute(name_1);
807
+ }
808
+ }
809
+ });
810
+ return div.innerHTML;
811
+ });
812
+ this._editor.events.on('keydown', function () {
813
+ _this.onTouched();
814
+ });
815
+ if (this.config.image && this.config.image.upload) {
816
+ this._editor.events.on('image.beforePasteUpload', function (image) {
817
+ fetch(image.getAttribute('src'))
818
+ .then(function (res) {
819
+ res.blob()
820
+ .then(function (blob) {
821
+ _this._processImageUpload(blob)
822
+ .pipe(operators.takeUntil(_this._destroy$))
823
+ .subscribe(function (url) {
824
+ image.setAttribute('src', url);
825
+ image.removeAttribute('data-fr-image-pasted');
826
+ _this._contentChanged();
827
+ });
828
+ });
829
+ });
830
+ return false;
831
+ });
832
+ this._editor.events.on('image.beforeUpload', function (blobs) {
833
+ _this._processImageUpload(blobs[0])
834
+ .pipe(operators.takeUntil(_this._destroy$))
835
+ .subscribe(function (url) {
836
+ _this.editor.image.insert(url, null, null, _this.editor.image.get());
837
+ });
838
+ return false;
839
+ });
840
+ }
841
+ if (this.el.querySelector('.fr-second-toolbar')) {
842
+ this.el.querySelector('.fr-second-toolbar').remove();
843
+ }
844
+ var selection = options.selection;
845
+ if (selection) {
846
+ var node = Array.from(this.el.querySelectorAll('.fr-element *')).find(function (node) {
847
+ return selection.node === node.textContent;
848
+ });
849
+ if (node) {
850
+ var range = document.createRange();
851
+ var sel = window.getSelection();
852
+ range.setStart(this._getTextNode(node), selection.offset);
853
+ range.collapse(true);
854
+ sel.removeAllRanges();
855
+ sel.addRange(range);
856
+ }
857
+ else if (this.config.autofocus) {
858
+ this.focus();
859
+ }
860
+ }
861
+ else if (this.config.autofocus) {
862
+ this.focus();
863
+ }
864
+ };
865
+ var FsHtmlEditorComponent_1;
866
+ FsHtmlEditorComponent.ctorParameters = function () { return [
867
+ { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
868
+ { type: core.ChangeDetectorRef },
869
+ { type: FsFroalaLoaderService }
870
+ ]; };
871
+ __decorate([
872
+ core.HostBinding('class.focused'),
873
+ __metadata("design:type", Object)
874
+ ], FsHtmlEditorComponent.prototype, "classFocused", void 0);
875
+ __decorate([
876
+ core.HostBinding('class.disabled'),
877
+ __metadata("design:type", Object)
878
+ ], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
879
+ __decorate([
880
+ core.ViewChild('elRef'),
881
+ __metadata("design:type", core.ElementRef)
882
+ ], FsHtmlEditorComponent.prototype, "elRef", void 0);
883
+ __decorate([
884
+ core.Input(),
885
+ __metadata("design:type", Object)
886
+ ], FsHtmlEditorComponent.prototype, "config", void 0);
887
+ FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
888
+ core.Component({
889
+ selector: 'fs-html-editor',
890
+ 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",
891
+ providers: [
892
+ {
893
+ provide: forms.NG_VALUE_ACCESSOR,
894
+ useExisting: core.forwardRef(function () { return FsHtmlEditorComponent_1; }),
895
+ multi: true
896
+ },
897
+ {
898
+ provide: forms.NG_VALIDATORS,
899
+ useExisting: core.forwardRef(function () { return FsHtmlEditorComponent_1; }),
900
+ multi: true
901
+ },
902
+ ],
903
+ changeDetection: core.ChangeDetectionStrategy.OnPush,
904
+ 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}"]
905
+ }),
906
+ __param(0, core.Optional()), __param(0, core.Inject(FS_HTML_EDITOR_CONFIG)),
907
+ __metadata("design:paramtypes", [Object, core.ChangeDetectorRef,
908
+ FsFroalaLoaderService])
909
+ ], FsHtmlEditorComponent);
910
+ return FsHtmlEditorComponent;
911
911
  }());
912
912
 
913
- var FsHtmlRendererComponent = /** @class */ (function () {
914
- function FsHtmlRendererComponent(sanitized, _cdRef) {
915
- this.sanitized = sanitized;
916
- this._cdRef = _cdRef;
917
- }
918
- Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
919
- set: function (html) {
920
- this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html);
921
- this._cdRef.markForCheck();
922
- },
923
- enumerable: true,
924
- configurable: true
925
- });
926
- FsHtmlRendererComponent.ctorParameters = function () { return [
927
- { type: platformBrowser.DomSanitizer },
928
- { type: core.ChangeDetectorRef }
929
- ]; };
930
- __decorate([
931
- core.Input('html'),
932
- __metadata("design:type", Object),
933
- __metadata("design:paramtypes", [Object])
934
- ], FsHtmlRendererComponent.prototype, "setHtml", null);
935
- FsHtmlRendererComponent = __decorate([
936
- core.Component({
937
- selector: 'fs-html-renderer',
938
- template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
939
- changeDetection: core.ChangeDetectionStrategy.OnPush,
940
- styles: [""]
941
- }),
942
- __metadata("design:paramtypes", [platformBrowser.DomSanitizer,
943
- core.ChangeDetectorRef])
944
- ], FsHtmlRendererComponent);
945
- return FsHtmlRendererComponent;
913
+ var FsHtmlRendererComponent = /** @class */ (function () {
914
+ function FsHtmlRendererComponent(sanitized, _cdRef) {
915
+ this.sanitized = sanitized;
916
+ this._cdRef = _cdRef;
917
+ }
918
+ Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
919
+ set: function (html) {
920
+ this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html || '');
921
+ this._cdRef.markForCheck();
922
+ },
923
+ enumerable: true,
924
+ configurable: true
925
+ });
926
+ FsHtmlRendererComponent.ctorParameters = function () { return [
927
+ { type: platformBrowser.DomSanitizer },
928
+ { type: core.ChangeDetectorRef }
929
+ ]; };
930
+ __decorate([
931
+ core.Input('html'),
932
+ __metadata("design:type", Object),
933
+ __metadata("design:paramtypes", [Object])
934
+ ], FsHtmlRendererComponent.prototype, "setHtml", null);
935
+ FsHtmlRendererComponent = __decorate([
936
+ core.Component({
937
+ selector: 'fs-html-renderer',
938
+ template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
939
+ changeDetection: core.ChangeDetectionStrategy.OnPush,
940
+ styles: [""]
941
+ }),
942
+ __metadata("design:paramtypes", [platformBrowser.DomSanitizer,
943
+ core.ChangeDetectorRef])
944
+ ], FsHtmlRendererComponent);
945
+ return FsHtmlRendererComponent;
946
946
  }());
947
947
 
948
- var FsHtmlEditorModule = /** @class */ (function () {
949
- function FsHtmlEditorModule() {
950
- }
951
- FsHtmlEditorModule_1 = FsHtmlEditorModule;
952
- FsHtmlEditorModule.forRoot = function (config) {
953
- if (config === void 0) { config = {}; }
954
- return {
955
- ngModule: FsHtmlEditorModule_1,
956
- providers: [
957
- { provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
958
- {
959
- provide: FS_HTML_EDITOR_CONFIG,
960
- useFactory: FsHtmlEditorConfigFactory,
961
- deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
962
- }
963
- ]
964
- };
965
- };
966
- var FsHtmlEditorModule_1;
967
- FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
968
- core.NgModule({
969
- imports: [
970
- common.CommonModule,
971
- skeleton.FsSkeletonModule,
972
- ],
973
- exports: [
974
- FsHtmlEditorComponent,
975
- FsHtmlRendererComponent,
976
- ],
977
- declarations: [
978
- FsHtmlEditorComponent,
979
- FsHtmlRendererComponent,
980
- ],
981
- })
982
- ], FsHtmlEditorModule);
983
- return FsHtmlEditorModule;
984
- }());
985
- function FsHtmlEditorConfigFactory(config) {
986
- return __assign({ defaultPlugins: [
987
- "align" /* Align */,
988
- "colors" /* Colors */,
989
- "image" /* Image */,
990
- "link" /* Link */,
991
- "lists" /* Lists */,
992
- "paragraph_format" /* ParagraphFormat */,
993
- "quote" /* Quote */,
994
- "table" /* Table */,
995
- "url" /* Url */,
996
- "video" /* Video */,
997
- "draggable" /* Draggable */,
998
- "font_size" /* FontSize */,
999
- ] }, config);
948
+ var FsHtmlEditorModule = /** @class */ (function () {
949
+ function FsHtmlEditorModule() {
950
+ }
951
+ FsHtmlEditorModule_1 = FsHtmlEditorModule;
952
+ FsHtmlEditorModule.forRoot = function (config) {
953
+ if (config === void 0) { config = {}; }
954
+ return {
955
+ ngModule: FsHtmlEditorModule_1,
956
+ providers: [
957
+ { provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
958
+ {
959
+ provide: FS_HTML_EDITOR_CONFIG,
960
+ useFactory: FsHtmlEditorConfigFactory,
961
+ deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
962
+ }
963
+ ]
964
+ };
965
+ };
966
+ var FsHtmlEditorModule_1;
967
+ FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
968
+ core.NgModule({
969
+ imports: [
970
+ common.CommonModule,
971
+ skeleton.FsSkeletonModule,
972
+ ],
973
+ exports: [
974
+ FsHtmlEditorComponent,
975
+ FsHtmlRendererComponent,
976
+ ],
977
+ declarations: [
978
+ FsHtmlEditorComponent,
979
+ FsHtmlRendererComponent,
980
+ ],
981
+ })
982
+ ], FsHtmlEditorModule);
983
+ return FsHtmlEditorModule;
984
+ }());
985
+ function FsHtmlEditorConfigFactory(config) {
986
+ return __assign({ defaultPlugins: [
987
+ "align" /* Align */,
988
+ "colors" /* Colors */,
989
+ "image" /* Image */,
990
+ "link" /* Link */,
991
+ "lists" /* Lists */,
992
+ "paragraph_format" /* ParagraphFormat */,
993
+ "quote" /* Quote */,
994
+ "table" /* Table */,
995
+ "url" /* Url */,
996
+ "video" /* Video */,
997
+ "draggable" /* Draggable */,
998
+ "font_size" /* FontSize */,
999
+ ] }, config);
1000
1000
  }
1001
1001
 
1002
- var Plugin = /** @class */ (function () {
1003
- function Plugin() {
1004
- }
1005
- Plugin.prototype.initialize = function () { };
1006
- Plugin.prototype.destroy = function () { };
1007
- return Plugin;
1002
+ var Plugin = /** @class */ (function () {
1003
+ function Plugin() {
1004
+ }
1005
+ Plugin.prototype.initialize = function () { };
1006
+ Plugin.prototype.destroy = function () { };
1007
+ return Plugin;
1008
1008
  }());
1009
1009
 
1010
- var MentionPlugin = /** @class */ (function (_super) {
1011
- __extends(MentionPlugin, _super);
1012
- function MentionPlugin(config) {
1013
- var _this = _super.call(this) || this;
1014
- _this.config = config;
1015
- _this.config = __assign(__assign({}, config), { buttons: [
1016
- {
1017
- name: config.name,
1018
- tooltip: config.tooltip,
1019
- svgPath: config.iconPath,
1020
- click: function (editor) {
1021
- _this._closeAll();
1022
- _this._tribute.showMenuForCollection(editor.el);
1023
- }
1024
- }
1025
- ] });
1026
- _this._tribute = new Tribute({
1027
- values: lodashEs.debounce(_this._loadValues.bind(_this), 200),
1028
- searchOpts: {
1029
- pre: '',
1030
- post: '',
1031
- skip: true
1032
- },
1033
- containerClass: "fs-html-editor-mention-container " + (_this.config.containerClass || ''),
1034
- itemClass: "fs-html-editor-mention-menu-item " + (_this.config.menuItemClass || ''),
1035
- trigger: _this.config.trigger,
1036
- allowSpaces: true,
1037
- menuItemTemplate: function (item) {
1038
- return _this.config.menuItemTemplate(item.original);
1039
- },
1040
- selectTemplate: function (item) {
1041
- var template = _this.config.selectedTemplate(item.original);
1042
- var p = document.createElement('p');
1043
- p.innerHTML = template;
1044
- var node = p.firstElementChild;
1045
- if (!node) {
1046
- node = document.createElement('span');
1047
- node.innerHTML = template;
1048
- }
1049
- node.setAttribute('contenteditable', 'false');
1050
- node.classList.add('fr-deletable');
1051
- return node.outerHTML;
1052
- },
1053
- });
1054
- MentionPlugin._tributes.push(_this._tribute);
1055
- return _this;
1056
- }
1057
- MentionPlugin.prototype.initialize = function () {
1058
- var _this = this;
1059
- this._tribute.attach(this.editor.el);
1060
- this.editor.events.on('keydown', function (e) {
1061
- if (e.key === 'Enter' && _this._tribute.isActive) {
1062
- return false;
1063
- }
1064
- }, true);
1065
- };
1066
- MentionPlugin.prototype.destroy = function () { };
1067
- MentionPlugin.prototype._closeAll = function () {
1068
- MentionPlugin._tributes.forEach(function (tribute) {
1069
- if (tribute.menu) {
1070
- tribute.hideMenu();
1071
- }
1072
- });
1073
- };
1074
- MentionPlugin.prototype._loadValues = function (keyword, cb) {
1075
- return this.config.fetch(keyword)
1076
- .subscribe(function (data) {
1077
- cb(data);
1078
- });
1079
- };
1080
- MentionPlugin._tributes = [];
1081
- return MentionPlugin;
1010
+ var MentionPlugin = /** @class */ (function (_super) {
1011
+ __extends(MentionPlugin, _super);
1012
+ function MentionPlugin(config) {
1013
+ var _this = _super.call(this) || this;
1014
+ _this.config = config;
1015
+ _this._guid = common$1.guid();
1016
+ _this.selected = function (event) {
1017
+ if (_this.config.selected) {
1018
+ if (MentionPlugin._currentGuid === _this._guid) {
1019
+ _this.config.selected(event.detail.item.original);
1020
+ }
1021
+ }
1022
+ };
1023
+ _this.config = __assign(__assign({}, config), { buttons: [
1024
+ {
1025
+ name: config.name,
1026
+ tooltip: config.tooltip,
1027
+ svgPath: config.iconPath,
1028
+ click: function (editor) {
1029
+ _this._closeAll();
1030
+ _this._tribute.showMenuForCollection(editor.el);
1031
+ }
1032
+ }
1033
+ ] });
1034
+ _this._tribute = new Tribute({
1035
+ values: lodashEs.debounce(_this._loadValues.bind(_this), 200),
1036
+ searchOpts: {
1037
+ pre: '',
1038
+ post: '',
1039
+ skip: true
1040
+ },
1041
+ containerClass: "fs-html-editor-mention-container " + (_this.config.containerClass || ''),
1042
+ itemClass: "fs-html-editor-mention-menu-item " + (_this.config.menuItemClass || ''),
1043
+ trigger: _this.config.trigger,
1044
+ allowSpaces: true,
1045
+ menuItemTemplate: function (item) {
1046
+ return _this.config.menuItemTemplate(item.original);
1047
+ },
1048
+ selectTemplate: function (item) {
1049
+ var template = _this.config.selectedTemplate(item.original);
1050
+ var p = document.createElement('p');
1051
+ p.innerHTML = template;
1052
+ var node = p.firstElementChild;
1053
+ if (!node) {
1054
+ node = document.createElement('span');
1055
+ node.innerHTML = template;
1056
+ }
1057
+ node.setAttribute('contenteditable', 'false');
1058
+ node.classList.add('fr-deletable');
1059
+ return node.outerHTML;
1060
+ },
1061
+ });
1062
+ MentionPlugin._tributes.push(_this._tribute);
1063
+ return _this;
1064
+ }
1065
+ MentionPlugin.prototype.initialize = function () {
1066
+ var _this = this;
1067
+ this._tribute.attach(this.editor.el);
1068
+ this.editor.events.on('keydown', function (e) {
1069
+ if (e.key === 'Enter' && _this._tribute.isActive) {
1070
+ return false;
1071
+ }
1072
+ }, true);
1073
+ this.editor.el.addEventListener("tribute-replaced", this.selected);
1074
+ };
1075
+ MentionPlugin.prototype.destroy = function () {
1076
+ this.editor.el.removeEventListener("tribute-replaced", this.selected);
1077
+ };
1078
+ MentionPlugin.prototype._closeAll = function () {
1079
+ MentionPlugin._tributes.forEach(function (tribute) {
1080
+ if (tribute.menu) {
1081
+ tribute.hideMenu();
1082
+ }
1083
+ });
1084
+ };
1085
+ MentionPlugin.prototype._loadValues = function (keyword, cb) {
1086
+ MentionPlugin._currentGuid = this._guid;
1087
+ return this.config.fetch(keyword)
1088
+ .subscribe(function (data) {
1089
+ cb(data);
1090
+ });
1091
+ };
1092
+ MentionPlugin._currentGuid = null;
1093
+ MentionPlugin._tributes = [];
1094
+ return MentionPlugin;
1082
1095
  }(Plugin));
1083
1096
 
1084
- var ChecklistPlugin = /** @class */ (function (_super) {
1085
- __extends(ChecklistPlugin, _super);
1086
- function ChecklistPlugin(config) {
1087
- if (config === void 0) { config = { name: 'checklist' }; }
1088
- var _this = _super.call(this) || this;
1089
- _this.config = config;
1090
- _this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
1091
- {
1092
- name: 'checklist',
1093
- 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',
1094
- click: function (editor) {
1095
- editor.html.insert('<ul class="checklist"><li></li></ul>');
1096
- }
1097
- }
1098
- ] });
1099
- return _this;
1100
- }
1101
- ChecklistPlugin.prototype.initialize = function () {
1102
- this.editor.events.on('click', function (e) {
1103
- var li = e.target;
1104
- if (li.nodeName === 'LI' && e.offsetX < 0) {
1105
- var items = __spread([li], li.querySelectorAll('li'));
1106
- if (li.classList.contains('checked')) {
1107
- items.forEach(function (item) {
1108
- item.classList.remove('checked');
1109
- });
1110
- }
1111
- else {
1112
- items.forEach(function (item) {
1113
- item.classList.add('checked');
1114
- });
1115
- }
1116
- }
1117
- }, false);
1118
- };
1119
- return ChecklistPlugin;
1097
+ var ChecklistPlugin = /** @class */ (function (_super) {
1098
+ __extends(ChecklistPlugin, _super);
1099
+ function ChecklistPlugin(config) {
1100
+ if (config === void 0) { config = { name: 'checklist' }; }
1101
+ var _this = _super.call(this) || this;
1102
+ _this.config = config;
1103
+ _this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
1104
+ {
1105
+ name: 'checklist',
1106
+ 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',
1107
+ click: function (editor) {
1108
+ editor.html.insert('<ul class="checklist"><li></li></ul>');
1109
+ }
1110
+ }
1111
+ ] });
1112
+ return _this;
1113
+ }
1114
+ ChecklistPlugin.prototype.initialize = function () {
1115
+ this.editor.events.on('click', function (e) {
1116
+ var li = e.target;
1117
+ if (li.nodeName === 'LI' && e.offsetX < 0) {
1118
+ var items = __spread([li], li.querySelectorAll('li'));
1119
+ if (li.classList.contains('checked')) {
1120
+ items.forEach(function (item) {
1121
+ item.classList.remove('checked');
1122
+ });
1123
+ }
1124
+ else {
1125
+ items.forEach(function (item) {
1126
+ item.classList.add('checked');
1127
+ });
1128
+ }
1129
+ }
1130
+ }, false);
1131
+ };
1132
+ return ChecklistPlugin;
1120
1133
  }(Plugin));
1121
1134
 
1122
- var CodePlugin = /** @class */ (function (_super) {
1123
- __extends(CodePlugin, _super);
1124
- function CodePlugin(config) {
1125
- if (config === void 0) { config = { name: 'code' }; }
1126
- var _this = _super.call(this) || this;
1127
- _this.config = config;
1128
- _this.config = __assign(__assign({}, config), { name: 'code', buttons: [
1129
- {
1130
- name: 'code',
1131
- 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',
1132
- click: function (editor) {
1133
- var node = editor.selection.get();
1134
- var codeEl = _this._getCodeEl(node.baseNode);
1135
- if (codeEl) {
1136
- codeEl.classList.remove('code');
1137
- }
1138
- else {
1139
- editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
1140
- }
1141
- }
1142
- }
1143
- ] });
1144
- return _this;
1145
- }
1146
- CodePlugin.prototype.initialize = function () {
1147
- var _this = this;
1148
- this.editor.events.on('keydown', function (e) {
1149
- if (e.keyCode === 13) {
1150
- var selection = _this.editor.selection.get();
1151
- if (selection && _this._getCodeEl(selection.baseNode)) {
1152
- e.preventDefault();
1153
- e.stopPropagation();
1154
- e.stopImmediatePropagation();
1155
- var br = '<br>';
1156
- var base = selection.baseNode;
1157
- if (base.nodeName === '#text' && selection.baseOffset === base.length) {
1158
- if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
1159
- br += '<br>';
1160
- }
1161
- }
1162
- else {
1163
- var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
1164
- if (el && el.nodeName !== 'BR') {
1165
- br += '<br>';
1166
- }
1167
- }
1168
- _this.editor.html.insert(br);
1169
- return false;
1170
- }
1171
- }
1172
- }, true);
1173
- };
1174
- CodePlugin.prototype.destroy = function () { };
1175
- CodePlugin.prototype._getCodeEl = function (el) {
1176
- if (el) {
1177
- if (el.classList && el.classList.contains('code')) {
1178
- return el;
1179
- }
1180
- if (el.parentElement) {
1181
- return this._getCodeEl(el.parentElement);
1182
- }
1183
- }
1184
- return null;
1185
- };
1186
- return CodePlugin;
1135
+ var CodePlugin = /** @class */ (function (_super) {
1136
+ __extends(CodePlugin, _super);
1137
+ function CodePlugin(config) {
1138
+ if (config === void 0) { config = { name: 'code' }; }
1139
+ var _this = _super.call(this) || this;
1140
+ _this.config = config;
1141
+ _this.config = __assign(__assign({}, config), { name: 'code', buttons: [
1142
+ {
1143
+ name: 'code',
1144
+ 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',
1145
+ click: function (editor) {
1146
+ var node = editor.selection.get();
1147
+ var codeEl = _this._getCodeEl(node.baseNode);
1148
+ if (codeEl) {
1149
+ codeEl.classList.remove('code');
1150
+ }
1151
+ else {
1152
+ editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
1153
+ }
1154
+ }
1155
+ }
1156
+ ] });
1157
+ return _this;
1158
+ }
1159
+ CodePlugin.prototype.initialize = function () {
1160
+ var _this = this;
1161
+ this.editor.events.on('keydown', function (e) {
1162
+ if (e.keyCode === 13) {
1163
+ var selection = _this.editor.selection.get();
1164
+ if (selection && _this._getCodeEl(selection.baseNode)) {
1165
+ e.preventDefault();
1166
+ e.stopPropagation();
1167
+ e.stopImmediatePropagation();
1168
+ var br = '<br>';
1169
+ var base = selection.baseNode;
1170
+ if (base.nodeName === '#text' && selection.baseOffset === base.length) {
1171
+ if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
1172
+ br += '<br>';
1173
+ }
1174
+ }
1175
+ else {
1176
+ var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
1177
+ if (el && el.nodeName !== 'BR') {
1178
+ br += '<br>';
1179
+ }
1180
+ }
1181
+ _this.editor.html.insert(br);
1182
+ return false;
1183
+ }
1184
+ }
1185
+ }, true);
1186
+ };
1187
+ CodePlugin.prototype.destroy = function () { };
1188
+ CodePlugin.prototype._getCodeEl = function (el) {
1189
+ if (el) {
1190
+ if (el.classList && el.classList.contains('code')) {
1191
+ return el;
1192
+ }
1193
+ if (el.parentElement) {
1194
+ return this._getCodeEl(el.parentElement);
1195
+ }
1196
+ }
1197
+ return null;
1198
+ };
1199
+ return CodePlugin;
1187
1200
  }(Plugin));
1188
1201
 
1189
- var ScreenRecordPlugin = /** @class */ (function (_super) {
1190
- __extends(ScreenRecordPlugin, _super);
1191
- function ScreenRecordPlugin(config) {
1192
- if (config === void 0) { config = {}; }
1193
- var _this = _super.call(this) || this;
1194
- _this.config = config;
1195
- _this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
1196
- {
1197
- name: 'screenRecord',
1198
- 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",
1199
- tooltip: 'Screen Record',
1200
- click: function (editor) {
1201
- navigator.mediaDevices.getDisplayMedia({ video: true })
1202
- .then(function (stream) {
1203
- var chunks = [];
1204
- var options = { mimeType: 'video/webm; codecs=vp9' };
1205
- var mediaRecorder = new MediaRecorder(stream, options);
1206
- stream.addEventListener('inactive', function (e) {
1207
- mediaRecorder.stop();
1208
- mediaRecorder = null;
1209
- stream.getTracks().forEach(function (track) { return track.stop(); });
1210
- stream = null;
1211
- var blob = new Blob(chunks, { type: 'video/webm' });
1212
- config.upload(blob)
1213
- .subscribe(function (url) {
1214
- 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>");
1215
- });
1216
- });
1217
- mediaRecorder.addEventListener('dataavailable', function (event) {
1218
- if (event.data && event.data.size > 0) {
1219
- chunks.push(event.data);
1220
- }
1221
- });
1222
- mediaRecorder.start(10);
1223
- })
1224
- .catch(function (e) { });
1225
- }
1226
- }
1227
- ] });
1228
- return _this;
1229
- }
1230
- ScreenRecordPlugin.prototype.initialize = function () {
1231
- return __awaiter(this, void 0, void 0, function () {
1232
- var FroalaEditor;
1233
- var _this = this;
1234
- return __generator(this, function (_a) {
1235
- switch (_a.label) {
1236
- case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
1237
- .toPromise()];
1238
- case 1:
1239
- _a.sent();
1240
- FroalaEditor = window.FroalaEditor;
1241
- this.editor.events.on('mouseup', function (e) {
1242
- var el = _this._getEl(e.target);
1243
- if (el) {
1244
- _this.editor.popups.hideAll();
1245
- _this._activeEl = el;
1246
- _this._showPopup(el);
1247
- }
1248
- });
1249
- FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
1250
- FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
1251
- FroalaEditor.RegisterCommand('popupClose', {
1252
- title: 'Remove',
1253
- undo: false,
1254
- focus: false,
1255
- callback: function () {
1256
- if (_this._activeEl) {
1257
- _this._activeEl.remove();
1258
- }
1259
- }
1260
- });
1261
- return [2 /*return*/];
1262
- }
1263
- });
1264
- });
1265
- };
1266
- ScreenRecordPlugin.prototype._createPopup = function () {
1267
- var template = {
1268
- buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
1269
- };
1270
- return this.editor.popups.create('screenRecordPlugin.popup', template);
1271
- };
1272
- ScreenRecordPlugin.prototype._showPopup = function (el) {
1273
- var $popup = this.editor.popups.get('screenRecordPlugin.popup');
1274
- if (!$popup) {
1275
- $popup = this._createPopup();
1276
- }
1277
- this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
1278
- var left = el.offsetLeft + el.offsetWidth / 2;
1279
- this.editor.popups.show('screenRecordPlugin.popup', left, null);
1280
- };
1281
- ScreenRecordPlugin.prototype._getEl = function (el) {
1282
- if (el && el.classList) {
1283
- if (el.classList.contains('fr-screen-record'))
1284
- return el;
1285
- return this._getEl(el.parentNode);
1286
- }
1287
- };
1288
- return ScreenRecordPlugin;
1202
+ var ScreenRecordPlugin = /** @class */ (function (_super) {
1203
+ __extends(ScreenRecordPlugin, _super);
1204
+ function ScreenRecordPlugin(config) {
1205
+ if (config === void 0) { config = {}; }
1206
+ var _this = _super.call(this) || this;
1207
+ _this.config = config;
1208
+ _this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
1209
+ {
1210
+ name: 'screenRecord',
1211
+ 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",
1212
+ tooltip: 'Screen Record',
1213
+ click: function (editor) {
1214
+ navigator.mediaDevices.getDisplayMedia({ video: true })
1215
+ .then(function (stream) {
1216
+ var chunks = [];
1217
+ var options = { mimeType: 'video/webm; codecs=vp9' };
1218
+ var mediaRecorder = new MediaRecorder(stream, options);
1219
+ stream.addEventListener('inactive', function (e) {
1220
+ mediaRecorder.stop();
1221
+ mediaRecorder = null;
1222
+ stream.getTracks().forEach(function (track) { return track.stop(); });
1223
+ stream = null;
1224
+ var blob = new Blob(chunks, { type: 'video/webm' });
1225
+ config.upload(blob)
1226
+ .subscribe(function (url) {
1227
+ 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>");
1228
+ });
1229
+ });
1230
+ mediaRecorder.addEventListener('dataavailable', function (event) {
1231
+ if (event.data && event.data.size > 0) {
1232
+ chunks.push(event.data);
1233
+ }
1234
+ });
1235
+ mediaRecorder.start(10);
1236
+ })
1237
+ .catch(function (e) { });
1238
+ }
1239
+ }
1240
+ ] });
1241
+ return _this;
1242
+ }
1243
+ ScreenRecordPlugin.prototype.initialize = function () {
1244
+ return __awaiter(this, void 0, void 0, function () {
1245
+ var FroalaEditor;
1246
+ var _this = this;
1247
+ return __generator(this, function (_a) {
1248
+ switch (_a.label) {
1249
+ case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
1250
+ .toPromise()];
1251
+ case 1:
1252
+ _a.sent();
1253
+ FroalaEditor = window.FroalaEditor;
1254
+ this.editor.events.on('mouseup', function (e) {
1255
+ var el = _this._getEl(e.target);
1256
+ if (el) {
1257
+ _this.editor.popups.hideAll();
1258
+ _this._activeEl = el;
1259
+ _this._showPopup(el);
1260
+ }
1261
+ });
1262
+ FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
1263
+ FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
1264
+ FroalaEditor.RegisterCommand('popupClose', {
1265
+ title: 'Remove',
1266
+ undo: false,
1267
+ focus: false,
1268
+ callback: function () {
1269
+ if (_this._activeEl) {
1270
+ _this._activeEl.remove();
1271
+ }
1272
+ }
1273
+ });
1274
+ return [2 /*return*/];
1275
+ }
1276
+ });
1277
+ });
1278
+ };
1279
+ ScreenRecordPlugin.prototype._createPopup = function () {
1280
+ var template = {
1281
+ buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
1282
+ };
1283
+ return this.editor.popups.create('screenRecordPlugin.popup', template);
1284
+ };
1285
+ ScreenRecordPlugin.prototype._showPopup = function (el) {
1286
+ var $popup = this.editor.popups.get('screenRecordPlugin.popup');
1287
+ if (!$popup) {
1288
+ $popup = this._createPopup();
1289
+ }
1290
+ this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
1291
+ var left = el.offsetLeft + el.offsetWidth / 2;
1292
+ this.editor.popups.show('screenRecordPlugin.popup', left, null);
1293
+ };
1294
+ ScreenRecordPlugin.prototype._getEl = function (el) {
1295
+ if (el && el.classList) {
1296
+ if (el.classList.contains('fr-screen-record'))
1297
+ return el;
1298
+ return this._getEl(el.parentNode);
1299
+ }
1300
+ };
1301
+ return ScreenRecordPlugin;
1289
1302
  }(Plugin));
1290
1303
 
1291
1304
  exports.ChecklistPlugin = ChecklistPlugin;