@firestitch/html-editor 12.4.2 → 12.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,11 +7,10 @@ export declare class FsFroalaLoaderService {
7
7
  private _FroalaEditor;
8
8
  private _froalaLoaded;
9
9
  private _froalaPluginsLoaded;
10
- private _resourceLoader;
10
+ private _sourceLoader;
11
11
  private _loaded$;
12
12
  constructor(_defaultConfig: FsHtmlEditorConfig, _document: Document);
13
13
  get loaded$(): Observable<boolean>;
14
- get ready(): boolean;
15
14
  get FroalaEditor(): any;
16
15
  private _load;
17
16
  private _loadPlugins;
@@ -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/label'), 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/label', '@firestitch/skeleton', '@angular/forms', '@firestitch/file', 'rxjs', 'rxjs/operators', 'lodash-es', '@angular/platform-browser', 'tributejs', '@firestitch/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch["html-editor"] = {}), global.ng.core, global.ng.common, global.i2, global.i5, global.ng.forms, global.file, global.rxjs, global.rxjs.operators, global.lodashEs, global.ng.platformBrowser, global.Tribute, global.common));
5
- })(this, (function (exports, i0, i4, i2, i5, forms, file, rxjs, operators, lodashEs, i1, Tribute, common) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@firestitch/label'), require('@firestitch/skeleton'), require('@angular/forms'), require('@firestitch/file'), require('rxjs'), require('rxjs/operators'), require('lodash-es'), require('@firestitch/common'), require('@angular/platform-browser'), require('tributejs')) :
3
+ typeof define === 'function' && define.amd ? define('@firestitch/html-editor', ['exports', '@angular/core', '@angular/common', '@firestitch/label', '@firestitch/skeleton', '@angular/forms', '@firestitch/file', 'rxjs', 'rxjs/operators', 'lodash-es', '@firestitch/common', '@angular/platform-browser', 'tributejs'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.firestitch = global.firestitch || {}, global.firestitch["html-editor"] = {}), global.ng.core, global.ng.common, global.i2, global.i5, global.ng.forms, global.file, global.rxjs, global.rxjs.operators, global.lodashEs, global.common, global.ng.platformBrowser, global.Tribute));
5
+ })(this, (function (exports, i0, i4, i2, i5, forms, file, rxjs, operators, lodashEs, common, i1, Tribute) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -388,114 +388,19 @@
388
388
  var FS_HTML_EDITOR_DEFAULT_CONFIG = new i0.InjectionToken('fs-html-editor.default-config');
389
389
  var FS_HTML_EDITOR_CONFIG = new i0.InjectionToken('fs-html-editor.config');
390
390
 
391
- function resourceLoaderFactory(document) {
392
- var resourceBase = '/assets/js/froala/';
393
- var stylesBase = '/assets/css/';
394
- var head = document.getElementsByTagName('head')[0];
395
- var files = new Map();
396
- var window = document.defaultView;
397
- var resourcePaths = {
398
- froala: 'froala_editor.min.js',
399
- align: 'plugins/align.min.js',
400
- colors: 'plugins/colors.min.js',
401
- image: 'plugins/image.min.js',
402
- link: 'plugins/link.min.js',
403
- lists: 'plugins/lists.min.js',
404
- paragraph_format: 'plugins/paragraph_format.min.js',
405
- table: 'plugins/table.min.js',
406
- url: 'plugins/url.min.js',
407
- video: 'plugins/video.min.js',
408
- quote: 'plugins/quote.min.js',
409
- draggable: 'plugins/draggable.min.js',
410
- font_size: 'plugins/font_size.min.js',
411
- quick_insert: 'plugins/quick_insert.min.js',
412
- line_height: 'plugins/line_height.min.js'
413
- };
414
- var stylesPaths = {
415
- froala: 'froala_editor.pkgd.min.css',
416
- };
417
- var loadResource = function (scriptPath) {
418
- if (!files.has(scriptPath)) {
419
- var obs$ = new rxjs.Observable(function (obs) {
420
- var script = document.createElement('script');
421
- script.src = scriptPath;
422
- head.appendChild(script);
423
- script.onload = function () {
424
- obs.next();
425
- obs.complete();
426
- };
427
- script.onerror = function (err) {
428
- obs.error(err);
429
- };
430
- })
431
- .pipe(operators.shareReplay(1));
432
- files.set(scriptPath, obs$);
433
- }
434
- return files.get(scriptPath);
435
- };
436
- var loadStyles = function (stylePath) {
437
- if (!files.has(stylePath)) {
438
- var obs$ = new rxjs.Observable(function (obs) {
439
- var style = document.createElement('link');
440
- style.id = stylePath;
441
- style.rel = 'stylesheet';
442
- style.href = "" + stylePath;
443
- head.appendChild(style);
444
- style.onload = function () {
445
- obs.next();
446
- obs.complete();
447
- };
448
- style.onerror = function (err) {
449
- obs.error(err);
450
- };
451
- });
452
- files.set(stylePath, obs$);
453
- }
454
- return files.get(stylePath);
455
- };
456
- return {
457
- setResourceBase: function (path) {
458
- resourceBase = path;
459
- },
460
- setStylesBase: function (path) {
461
- stylesBase = path;
462
- },
463
- loadResource: function (resourceName) {
464
- /*
465
- this line must be here for cases when html-editor loaded together with text-editor
466
- monaco-editor has it's own loader and it declares "define" variable, so froala tryes to load itself in wrong way
467
- */
468
- window.define = null;
469
- var path = resourcePaths[resourceName] || resourceName;
470
- return loadResource(resourceBase + path);
471
- },
472
- loadStyles: function (resourceName) {
473
- var path = stylesPaths[resourceName] || resourceName;
474
- return loadStyles(stylesBase + path);
475
- }
476
- };
477
- }
478
-
479
391
  var FsFroalaLoaderService = /** @class */ (function () {
480
392
  function FsFroalaLoaderService(_defaultConfig, _document) {
481
393
  this._defaultConfig = _defaultConfig;
482
394
  this._document = _document;
483
395
  this._froalaLoaded = new rxjs.BehaviorSubject(false);
484
396
  this._froalaPluginsLoaded = new rxjs.BehaviorSubject(false);
485
- this._resourceLoader = resourceLoaderFactory(this._document);
397
+ this._sourceLoader = common.fsSourceLoader;
486
398
  this._loaded$ = rxjs.combineLatest([this._froalaLoaded, this._froalaPluginsLoaded])
487
399
  .pipe(operators.map(function (_a) {
488
400
  var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
489
401
  return pluginsRead && FroalaReady;
490
402
  }), operators.shareReplay(1));
491
- if (this._defaultConfig) {
492
- if (this._defaultConfig.assetsJSPath) {
493
- this._resourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
494
- }
495
- if (this._defaultConfig.assetsCSSPath) {
496
- this._resourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
497
- }
498
- }
403
+ this._sourceLoader.setDocument(this._document);
499
404
  this._load();
500
405
  }
501
406
  Object.defineProperty(FsFroalaLoaderService.prototype, "loaded$", {
@@ -505,13 +410,6 @@
505
410
  enumerable: false,
506
411
  configurable: true
507
412
  });
508
- Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
509
- get: function () {
510
- return this._froalaLoaded.getValue() && this._froalaPluginsLoaded.getValue();
511
- },
512
- enumerable: false,
513
- configurable: true
514
- });
515
413
  Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
516
414
  get: function () {
517
415
  return this._FroalaEditor;
@@ -521,10 +419,27 @@
521
419
  });
522
420
  FsFroalaLoaderService.prototype._load = function () {
523
421
  var _this = this;
524
- rxjs.combineLatest([
525
- this._resourceLoader.loadResource('froala'),
526
- this._resourceLoader.loadStyles('froala')
527
- ])
422
+ this._sourceLoader.registerResources({
423
+ froala: [
424
+ '/assets/js/froala/froala_editor.min.js',
425
+ '/assets/css/froala_editor.pkgd.min.css',
426
+ ],
427
+ froala_align: '/assets/js/froala/plugins/align.min.js',
428
+ froala_colors: '/assets/js/froala/plugins/colors.min.js',
429
+ froala_image: '/assets/js/froala/plugins/image.min.js',
430
+ froala_link: '/assets/js/froala/plugins/link.min.js',
431
+ froala_lists: '/assets/js/froala/plugins/lists.min.js',
432
+ froala_paragraph_format: '/assets/js/froala/plugins/paragraph_format.min.js',
433
+ froala_table: '/assets/js/froala/plugins/table.min.js',
434
+ froala_url: '/assets/js/froala/plugins/url.min.js',
435
+ froala_video: '/assets/js/froala/plugins/video.min.js',
436
+ froala_quote: '/assets/js/froala/plugins/quote.min.js',
437
+ froala_draggable: '/assets/js/froala/plugins/draggable.min.js',
438
+ froala_font_size: '/assets/js/froala/plugins/font_size.min.js',
439
+ froala_quick_insert: '/assets/js/froala/plugins/quick_insert.min.js',
440
+ froala_line_height: '/assets/js/froala/plugins/line_height.min.js'
441
+ });
442
+ this._sourceLoader.loadResource('froala')
528
443
  .pipe(operators.tap(function () {
529
444
  _this._FroalaEditor = window.FroalaEditor;
530
445
  _this._froalaDone();
@@ -536,15 +451,10 @@
536
451
  .subscribe();
537
452
  };
538
453
  FsFroalaLoaderService.prototype._loadPlugins = function () {
539
- var _this = this;
540
- var imports = this._defaultConfig
454
+ var resources = this._defaultConfig
541
455
  .froalaPlugins
542
- .reduce(function (acc, pluginName) {
543
- var import$ = _this._resourceLoader.loadResource(pluginName);
544
- acc.push(import$);
545
- return acc;
546
- }, []);
547
- return rxjs.combineLatest(imports);
456
+ .map(function (pluginName) { return "froala_" + pluginName; });
457
+ return this._sourceLoader.loadResources(resources);
548
458
  };
549
459
  FsFroalaLoaderService.prototype._froalaDone = function () {
550
460
  this._froalaLoaded.next(true);
@@ -1454,34 +1364,28 @@
1454
1364
  var FroalaEditor;
1455
1365
  var _this = this;
1456
1366
  return __generator(this, function (_a) {
1457
- switch (_a.label) {
1458
- case 0: return [4 /*yield*/, resourceLoaderFactory(document).loadStyles('froala')
1459
- .toPromise()];
1460
- case 1:
1461
- _a.sent();
1462
- FroalaEditor = window.FroalaEditor;
1463
- this.editor.events.on('mouseup', function (e) {
1464
- var el = _this._getEl(e.target);
1465
- if (el) {
1466
- _this.editor.popups.hideAll();
1467
- _this._activeEl = el;
1468
- _this._showPopup(el);
1469
- }
1470
- });
1471
- FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
1472
- FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
1473
- FroalaEditor.RegisterCommand('popupClose', {
1474
- title: 'Remove',
1475
- undo: false,
1476
- focus: false,
1477
- callback: function () {
1478
- if (_this._activeEl) {
1479
- _this._activeEl.remove();
1480
- }
1481
- }
1482
- });
1483
- return [2 /*return*/];
1484
- }
1367
+ FroalaEditor = window.FroalaEditor;
1368
+ this.editor.events.on('mouseup', function (e) {
1369
+ var el = _this._getEl(e.target);
1370
+ if (el) {
1371
+ _this.editor.popups.hideAll();
1372
+ _this._activeEl = el;
1373
+ _this._showPopup(el);
1374
+ }
1375
+ });
1376
+ FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
1377
+ FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
1378
+ FroalaEditor.RegisterCommand('popupClose', {
1379
+ title: 'Remove',
1380
+ undo: false,
1381
+ focus: false,
1382
+ callback: function () {
1383
+ if (_this._activeEl) {
1384
+ _this._activeEl.remove();
1385
+ }
1386
+ }
1387
+ });
1388
+ return [2 /*return*/];
1485
1389
  });
1486
1390
  });
1487
1391
  };