@firestitch/html-editor 9.4.4 → 9.4.5

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