@wizishop/wizi-block 4.2.30-beta → 4.2.33-beta

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 (41) hide show
  1. package/bundles/wizishop-wizi-block.umd.js +141 -121
  2. package/bundles/wizishop-wizi-block.umd.js.map +1 -1
  3. package/bundles/wizishop-wizi-block.umd.min.js +1 -1
  4. package/bundles/wizishop-wizi-block.umd.min.js.map +1 -1
  5. package/esm2015/lib/shared/components/editorjs/editorjs.component.js +21 -12
  6. package/esm2015/lib/shared/components/editorjs/tools/inline/bold-tool.component.js +1 -1
  7. package/esm2015/lib/shared/components/editorjs/tools/inline/capitalize-tool.component.js +1 -1
  8. package/esm2015/lib/shared/components/editorjs/tools/inline/italic-tool.component.js +1 -1
  9. package/esm2015/lib/shared/components/editorjs/tools/inline/link-tool.component.js +1 -1
  10. package/esm2015/lib/shared/components/editorjs/tools/inline/strike-tool.component.js +1 -1
  11. package/esm2015/lib/shared/components/editorjs/tools/inline/subscript-tool.component.js +1 -1
  12. package/esm2015/lib/shared/components/editorjs/tools/inline/superscript-tool.component.js +1 -1
  13. package/esm2015/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.js +107 -64
  14. package/esm2015/lib/shared/components/editorjs/tools/inline/tool-type/text-tool.component.js +1 -18
  15. package/esm2015/lib/shared/components/editorjs/tools/inline/underline-tool.component.js +1 -1
  16. package/esm2015/lib/shared/components/editorjs/tools/paragraph/ordered-list-tool.component.js +2 -2
  17. package/esm2015/lib/shared/components/editorjs/tools/paragraph/quote-tool.component.js +2 -2
  18. package/esm2015/lib/shared/components/editorjs/tools/paragraph/text-align-tool.component.js +2 -2
  19. package/esm2015/lib/shared/components/editorjs/tools/paragraph/text-type-tool.component.js +2 -2
  20. package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/paragraph-style-tool.component.js +2 -18
  21. package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/text-edition.component.js +15 -16
  22. package/esm2015/lib/shared/components/editorjs/tools/paragraph/unordered-list-tool.component.js +2 -2
  23. package/esm2015/lib/shared/components/editorjs/tools/utils/editorjs-tool.component.js +8 -1
  24. package/fesm2015/wizishop-wizi-block.js +153 -127
  25. package/fesm2015/wizishop-wizi-block.js.map +1 -1
  26. package/lib/shared/components/editorjs/editorjs.component.d.ts +1 -0
  27. package/lib/shared/components/editorjs/tools/inline/bold-tool.component.d.ts +1 -1
  28. package/lib/shared/components/editorjs/tools/inline/capitalize-tool.component.d.ts +1 -1
  29. package/lib/shared/components/editorjs/tools/inline/italic-tool.component.d.ts +1 -1
  30. package/lib/shared/components/editorjs/tools/inline/link-tool.component.d.ts +1 -1
  31. package/lib/shared/components/editorjs/tools/inline/strike-tool.component.d.ts +1 -1
  32. package/lib/shared/components/editorjs/tools/inline/subscript-tool.component.d.ts +1 -1
  33. package/lib/shared/components/editorjs/tools/inline/superscript-tool.component.d.ts +1 -1
  34. package/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.d.ts +2 -0
  35. package/lib/shared/components/editorjs/tools/inline/tool-type/text-tool.component.d.ts +0 -1
  36. package/lib/shared/components/editorjs/tools/inline/underline-tool.component.d.ts +1 -1
  37. package/lib/shared/components/editorjs/tools/paragraph/tool-type/paragraph-style-tool.component.d.ts +0 -1
  38. package/lib/shared/components/editorjs/tools/utils/editorjs-tool.component.d.ts +2 -0
  39. package/package.json +5 -1
  40. package/wizi-block.scss +215 -215
  41. package/wizishop-wizi-block.metadata.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@ngx-translate/core'), require('uuid'), require('@angular/cdk/drag-drop'), require('@angular/animations'), require('@angular/common/http'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms'), require('@angular/platform-browser'), require('@ctrl/tinycolor'), require('quill'), require('monaco-editor'), require('ngx-quill'), require('@fortawesome/fontawesome-svg-core'), require('@fortawesome/free-solid-svg-icons'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-brands-svg-icons'), require('@wizishop/ng-wizi-bulma'), require('ngx-scrollbar'), require('@editorjs/editorjs'), require('@jaames/iro'), require('ngx-monaco-editor'), require('leaflet'), require('places.js'), require('@asymmetrik/ngx-leaflet'), require('ngx-color-picker')) :
3
- typeof define === 'function' && define.amd ? define('@wizishop/wizi-block', ['exports', '@angular/core', 'rxjs', '@ngx-translate/core', 'uuid', '@angular/cdk/drag-drop', '@angular/animations', '@angular/common/http', 'rxjs/operators', '@angular/common', '@angular/forms', '@angular/platform-browser', '@ctrl/tinycolor', 'quill', 'monaco-editor', 'ngx-quill', '@fortawesome/fontawesome-svg-core', '@fortawesome/free-solid-svg-icons', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-brands-svg-icons', '@wizishop/ng-wizi-bulma', 'ngx-scrollbar', '@editorjs/editorjs', '@jaames/iro', 'ngx-monaco-editor', 'leaflet', 'places.js', '@asymmetrik/ngx-leaflet', 'ngx-color-picker'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wizishop = global.wizishop || {}, global.wizishop['wizi-block'] = {}), global.ng.core, global.rxjs, global.i1, global['^3']['3']['2'], global.ng.cdk.dragDrop, global.ng.animations, global.ng.common.http, global.rxjs.operators, global.ng.common, global.ng.forms, global.ng.platformBrowser, global['^2']['5']['2'], global['^1']['3']['6'], global.monaco, global['^5']['0']['0'], global['^1']['2']['27'], global['^5']['12']['1'], global['^5']['12']['1'], global['^5']['12']['1'], global['^7']['0']['11'], global['^7']['2']['1-beta']['0'], global.EditorJS, global.iro, global['^8']['1']['1'], global['^1']['5']['1'], global['^1']['16']['4'], global['^5']['0']['2'], global['^9']['0']['0']));
5
- }(this, (function (exports, i0, rxjs, i1, uuid, dragDrop, animations, i1$1, operators, common, forms, platformBrowser, tinycolor, QuillNamespace, monaco, ngxQuill, fontawesomeSvgCore, freeSolidSvgIcons, freeRegularSvgIcons, freeBrandsSvgIcons, ngWiziBulma, ngxScrollbar, EditorJS, iro, ngxMonacoEditor, leaflet, places, ngxLeaflet, ngxColorPicker) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@ngx-translate/core'), require('uuid'), require('@angular/cdk/drag-drop'), require('@angular/animations'), require('@angular/common/http'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms'), require('@angular/platform-browser'), require('@ctrl/tinycolor'), require('quill'), require('monaco-editor'), require('ngx-quill'), require('@fortawesome/fontawesome-svg-core'), require('@fortawesome/free-solid-svg-icons'), require('@fortawesome/free-regular-svg-icons'), require('@fortawesome/free-brands-svg-icons'), require('@wizishop/ng-wizi-bulma'), require('ngx-scrollbar'), require('@editorjs/editorjs'), require('@jaames/iro'), require('codemirror'), require('@codemirror/state'), require('@codemirror/lang-html'), require('ngx-monaco-editor'), require('leaflet'), require('places.js'), require('@asymmetrik/ngx-leaflet'), require('ngx-color-picker')) :
3
+ typeof define === 'function' && define.amd ? define('@wizishop/wizi-block', ['exports', '@angular/core', 'rxjs', '@ngx-translate/core', 'uuid', '@angular/cdk/drag-drop', '@angular/animations', '@angular/common/http', 'rxjs/operators', '@angular/common', '@angular/forms', '@angular/platform-browser', '@ctrl/tinycolor', 'quill', 'monaco-editor', 'ngx-quill', '@fortawesome/fontawesome-svg-core', '@fortawesome/free-solid-svg-icons', '@fortawesome/free-regular-svg-icons', '@fortawesome/free-brands-svg-icons', '@wizishop/ng-wizi-bulma', 'ngx-scrollbar', '@editorjs/editorjs', '@jaames/iro', 'codemirror', '@codemirror/state', '@codemirror/lang-html', 'ngx-monaco-editor', 'leaflet', 'places.js', '@asymmetrik/ngx-leaflet', 'ngx-color-picker'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wizishop = global.wizishop || {}, global.wizishop['wizi-block'] = {}), global.ng.core, global.rxjs, global.i1, global['^3']['3']['2'], global.ng.cdk.dragDrop, global.ng.animations, global.ng.common.http, global.rxjs.operators, global.ng.common, global.ng.forms, global.ng.platformBrowser, global['^2']['5']['2'], global['^1']['3']['6'], global.monaco, global['^5']['0']['0'], global['^1']['2']['27'], global['^5']['12']['1'], global['^5']['12']['1'], global['^5']['12']['1'], global['^7']['0']['11'], global['^7']['2']['1-beta']['0'], global.EditorJS, global.iro, global.codemirror, global.state, global.langHtml, global['^8']['1']['1'], global['^1']['5']['1'], global['^1']['16']['4'], global['^5']['0']['2'], global['^9']['0']['0']));
5
+ }(this, (function (exports, i0, rxjs, i1, uuid, dragDrop, animations, i1$1, operators, common, forms, platformBrowser, tinycolor, QuillNamespace, monaco, ngxQuill, fontawesomeSvgCore, freeSolidSvgIcons, freeRegularSvgIcons, freeBrandsSvgIcons, ngWiziBulma, ngxScrollbar, EditorJS, iro, codemirror, state, langHtml, ngxMonacoEditor, leaflet, places, ngxLeaflet, ngxColorPicker) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -20355,6 +20355,13 @@
20355
20355
  var selection = this.currentSelection ? this.currentSelection : this.getSelection();
20356
20356
  return selection.anchorNode.parentElement.closest('.editorJs');
20357
20357
  };
20358
+ EditorJSTool.prototype.findParentModifier = function () {
20359
+ if (!this.parentEditor) {
20360
+ this.parentEditor = this.findParentEditor();
20361
+ }
20362
+ return (this.parentEditor.querySelectorAll('.ce-block')[this.api.blocks.getCurrentBlockIndex()].querySelector('.ce-paragraph')
20363
+ .children[0]);
20364
+ };
20358
20365
  EditorJSTool.prototype.clear = function () {
20359
20366
  resetBlockFocus(this.parentEditor);
20360
20367
  };
@@ -20422,7 +20429,7 @@
20422
20429
  }
20423
20430
  InlineStyleTool.prototype.execCommandStyle = function (action) {
20424
20431
  return __awaiter(this, void 0, void 0, function () {
20425
- var selection, anchorNode, container, sameSelection, error_1;
20432
+ var selection, anchorNode, container, sameSelection;
20426
20433
  return __generator(this, function (_c) {
20427
20434
  switch (_c.label) {
20428
20435
  case 0:
@@ -20444,41 +20451,38 @@
20444
20451
  return [4 /*yield*/, this.saveInlineSelection(container, true)];
20445
20452
  case 1:
20446
20453
  _c.sent();
20447
- _c.label = 2;
20448
- case 2:
20449
- _c.trys.push([2, 12, , 13]);
20450
- if (!this.linkDeletion) return [3 /*break*/, 4];
20454
+ console.log('=== inline tool execCommandStyle method ===');
20455
+ console.log(this.hasStyle(container));
20456
+ if (!this.linkDeletion) return [3 /*break*/, 3];
20451
20457
  return [4 /*yield*/, this.replaceLink(selection, this.hasStyle(container))];
20452
- case 3:
20458
+ case 2:
20453
20459
  _c.sent();
20454
- return [3 /*break*/, 8];
20455
- case 4:
20460
+ return [3 /*break*/, 7];
20461
+ case 3:
20456
20462
  if (!(sameSelection &&
20457
20463
  !this.isContainer(this.textContainers, container) &&
20458
20464
  this.hasStyle(container) &&
20459
- selection.toString() === this.hasStyle(container).innerText)) return [3 /*break*/, 6];
20465
+ selection.toString() === this.hasStyle(container).innerText)) return [3 /*break*/, 5];
20466
+ console.log('-> update selection');
20460
20467
  return [4 /*yield*/, this.updateSelection(selection, this.hasStyle(container), action, this.textContainers)];
20461
- case 5:
20468
+ case 4:
20462
20469
  _c.sent();
20463
- return [3 /*break*/, 8];
20464
- case 6: return [4 /*yield*/, this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers)];
20465
- case 7:
20470
+ return [3 /*break*/, 7];
20471
+ case 5:
20472
+ console.log('-> replace selection');
20473
+ return [4 /*yield*/, this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers)];
20474
+ case 6:
20466
20475
  _c.sent();
20467
- _c.label = 8;
20468
- case 8: return [4 /*yield*/, this.cleanupContainer(selection, container, true)];
20469
- case 9:
20476
+ _c.label = 7;
20477
+ case 7: return [4 /*yield*/, this.cleanupContainer(selection, container, true)];
20478
+ case 8:
20470
20479
  _c.sent();
20471
- if (!this.modifiedContent) return [3 /*break*/, 11];
20480
+ if (!this.modifiedContent) return [3 /*break*/, 10];
20472
20481
  return [4 /*yield*/, this.resetInlineSelection(container, true)];
20473
- case 10:
20482
+ case 9:
20474
20483
  _c.sent();
20475
- _c.label = 11;
20476
- case 11: return [3 /*break*/, 13];
20477
- case 12:
20478
- error_1 = _c.sent();
20479
- console.warn('Inline Tool Error : ' + error_1);
20480
- return [3 /*break*/, 13];
20481
- case 13: return [2 /*return*/];
20484
+ _c.label = 10;
20485
+ case 10: return [2 /*return*/];
20482
20486
  }
20483
20487
  });
20484
20488
  });
@@ -20535,20 +20539,21 @@
20535
20539
  InlineStyleTool.prototype.replaceSelection = function (container, action, selection, containers) {
20536
20540
  var _a;
20537
20541
  return __awaiter(this, void 0, void 0, function () {
20538
- var parentContainer, focusNode, offsetContainer, offsetParentContainer, range, currentFragment, currentElement_1, currentElementToAppend, currentParentElement, tmpElement, isLTR, selectionFocusOffset, selectionFocusNode, newSelection, preRange, preFragment, newElement, range, fragment, fragmentElement, newElement_2, elementToAppend;
20542
+ var focusNode, offsetContainer, parentContainer, offsetParentContainer, range, currentFragment, currentElement_1, currentElementToAppend, currentParentElement, tmpElement, isLTR, selectionFocusOffset, selectionFocusNode, newSelection, preRange, preFragment, newElement, range, fragment, fragmentElement, newElement_2, elementToAppend;
20539
20543
  return __generator(this, function (_c) {
20540
20544
  switch (_c.label) {
20541
20545
  case 0:
20542
- parentContainer = this.hasStyle(container);
20543
20546
  focusNode = selection.focusNode;
20544
20547
  offsetContainer = focusNode.nodeType !== Node.TEXT_NODE && focusNode.nodeType !== Node.COMMENT_NODE
20545
20548
  ? focusNode
20546
20549
  : focusNode.parentElement;
20550
+ parentContainer = this.hasStyle(container);
20547
20551
  offsetParentContainer = this.hasStyle(offsetContainer);
20548
20552
  if (!(parentContainer &&
20549
20553
  parentContainer === offsetParentContainer &&
20550
20554
  ((parentContainer.children.length > 0 && parentContainer.innerText !== parentContainer.children[0].textContent) ||
20551
20555
  parentContainer.innerText !== selection.toString()))) return [3 /*break*/, 3];
20556
+ console.log('if');
20552
20557
  range = this.getRangeObject(selection);
20553
20558
  currentFragment = range.extractContents();
20554
20559
  currentElement_1 = document.createElement('span');
@@ -20593,9 +20598,13 @@
20593
20598
  newElement.appendChild(preFragment);
20594
20599
  parentContainer.parentElement.insertBefore(currentElementToAppend, parentContainer);
20595
20600
  parentContainer.parentElement.insertBefore(newElement, currentElementToAppend);
20601
+ if (!parentContainer.textContent || parentContainer.textContent.length === 0) {
20602
+ parentContainer.parentElement.removeChild(parentContainer);
20603
+ }
20596
20604
  selection.selectAllChildren(currentElementToAppend);
20597
20605
  return [3 /*break*/, 7];
20598
20606
  case 3:
20607
+ console.log('else');
20599
20608
  range = this.getRangeObject(selection);
20600
20609
  fragment = range.extractContents();
20601
20610
  fragmentElement = document.createElement('div');
@@ -20603,6 +20612,7 @@
20603
20612
  case 4:
20604
20613
  newElement_2 = _c.sent();
20605
20614
  elementToAppend = newElement_2;
20615
+ console.log(newElement_2);
20606
20616
  fragmentElement.append(fragment);
20607
20617
  if (((_a = fragmentElement.children) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
20608
20618
  this.textContainers.split(',').indexOf(fragmentElement.children[0].tagName.toLowerCase()) > -1) {
@@ -20822,10 +20832,30 @@
20822
20832
  });
20823
20833
  });
20824
20834
  };
20835
+ InlineStyleTool.prototype.parentHasStyle = function (currentElement, referenceElement) {
20836
+ // Link exception
20837
+ if (!currentElement || referenceElement.tagName.toLowerCase() === 'a' || referenceElement.tagName.toLowerCase() === 'div') {
20838
+ return false;
20839
+ }
20840
+ if (referenceElement.tagName.toLowerCase() !== 'span' &&
20841
+ referenceElement.tagName.toLowerCase() === currentElement.tagName.toLowerCase()) {
20842
+ return true;
20843
+ }
20844
+ if (Object.keys(this.getInlineStyle(currentElement)).length > 0 && this.identicalInlineStyle(currentElement, referenceElement)) {
20845
+ return true;
20846
+ }
20847
+ if (currentElement.classList.length > 0 && this.identicalClassList(currentElement, referenceElement)) {
20848
+ return true;
20849
+ }
20850
+ if (currentElement.parentElement && currentElement.parentElement.tagName.toLowerCase() !== 'div') {
20851
+ return this.parentHasStyle(currentElement.parentElement, referenceElement);
20852
+ }
20853
+ return false;
20854
+ };
20825
20855
  InlineStyleTool.prototype.cleanupContainer = function (selection, container, firstTimeCall) {
20826
- var _a, _b;
20856
+ var _a;
20827
20857
  return __awaiter(this, void 0, void 0, function () {
20828
- var parentContainer, parentFound, children, currentNode, identicalElements, currentElement, nextElement, currentNodeFirstChild;
20858
+ var parentContainer, parentFound, children, currentNode, previousSibling, currentNodeFirstChild, nextCurrentElement, identicalElements, currentElement, nextElement, currentNodeFirstChild;
20829
20859
  return __generator(this, function (_c) {
20830
20860
  switch (_c.label) {
20831
20861
  case 0:
@@ -20849,25 +20879,27 @@
20849
20879
  }
20850
20880
  parentContainer.normalize();
20851
20881
  children = Array.from(parentContainer.childNodes);
20852
- if (!((children === null || children === void 0 ? void 0 : children.length) > 0)) return [3 /*break*/, 6];
20882
+ if (!((children === null || children === void 0 ? void 0 : children.length) > 0)) return [3 /*break*/, 4];
20853
20883
  currentNode = children[0];
20854
20884
  _c.label = 1;
20855
20885
  case 1:
20856
- if (!currentNode) return [3 /*break*/, 6];
20857
- console.log('currentNode');
20858
- console.log(currentNode);
20859
- console.log(currentNode.textContent);
20860
- console.log((_b = currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length);
20861
- if (!(!currentNode.textContent || currentNode.textContent.length === 0)) return [3 /*break*/, 2];
20862
- parentContainer.removeChild(currentNode);
20863
- return [3 /*break*/, 5];
20864
- case 2:
20865
- if (!(currentNode.childNodes.length > 0)) return [3 /*break*/, 4];
20866
- return [4 /*yield*/, this.cleanupContainer(selection, currentNode, false)];
20867
- case 3:
20868
- _c.sent();
20869
- _c.label = 4;
20870
- case 4:
20886
+ if (!currentNode) return [3 /*break*/, 4];
20887
+ if ((!currentNode.textContent || currentNode.textContent.length === 0) || (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.innerText.length === 0)) {
20888
+ previousSibling = currentNode.previousSibling;
20889
+ parentContainer.removeChild(currentNode);
20890
+ currentNode = previousSibling;
20891
+ }
20892
+ if (currentNode.nodeType === Node.ELEMENT_NODE &&
20893
+ this.parentHasStyle(currentNode.parentElement, currentNode)) {
20894
+ currentNodeFirstChild = currentNode;
20895
+ nextCurrentElement = currentNode.firstChild;
20896
+ while (currentNode.firstChild) {
20897
+ parentContainer.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
20898
+ currentNodeFirstChild = currentNodeFirstChild.nextSibling;
20899
+ }
20900
+ parentContainer.removeChild(currentNode);
20901
+ currentNode = nextCurrentElement;
20902
+ }
20871
20903
  identicalElements = true;
20872
20904
  while (identicalElements &&
20873
20905
  currentNode.nextSibling &&
@@ -20878,8 +20910,7 @@
20878
20910
  if (this.identicalInlineStyle(currentElement, nextElement) &&
20879
20911
  currentElement.tagName.toLowerCase() === nextElement.tagName.toLowerCase() &&
20880
20912
  this.identicalClassList(currentElement, nextElement) &&
20881
- !currentElement.hasAttributes() &&
20882
- !nextElement.hasAttributes()) {
20913
+ this.identicalAttributes(currentElement, nextElement)) {
20883
20914
  currentElement.innerHTML += nextElement.innerHTML;
20884
20915
  nextElement.remove();
20885
20916
  this.modifiedContent = true;
@@ -20902,11 +20933,15 @@
20902
20933
  this.modifiedContent = true;
20903
20934
  }
20904
20935
  currentNode.normalize();
20905
- _c.label = 5;
20906
- case 5:
20936
+ if (!(currentNode.childNodes.length > 0)) return [3 /*break*/, 3];
20937
+ return [4 /*yield*/, this.cleanupContainer(selection, currentNode, false)];
20938
+ case 2:
20939
+ _c.sent();
20940
+ _c.label = 3;
20941
+ case 3:
20907
20942
  currentNode = currentNode.nextSibling;
20908
20943
  return [3 /*break*/, 1];
20909
- case 6: return [2 /*return*/];
20944
+ case 4: return [2 /*return*/];
20910
20945
  }
20911
20946
  });
20912
20947
  });
@@ -20926,6 +20961,17 @@
20926
20961
  return (__spread(currentElement.classList).every(function (classList) { return nextElement.classList.contains(classList); }) &&
20927
20962
  __spread(nextElement.classList).every(function (classList) { return currentElement.classList.contains(classList); }));
20928
20963
  };
20964
+ InlineStyleTool.prototype.identicalAttributes = function (currentElement, nextElement) {
20965
+ var currentElementAttributes = currentElement.getAttributeNames();
20966
+ currentElementAttributes.forEach(function (attribute) {
20967
+ if (attribute !== 'style') {
20968
+ if (!nextElement.getAttribute(attribute) || nextElement.getAttribute(attribute) !== currentElement.getAttribute(attribute)) {
20969
+ return false;
20970
+ }
20971
+ }
20972
+ });
20973
+ return true;
20974
+ };
20929
20975
  InlineStyleTool.prototype.identicalInlineStyle = function (currentElement, nextElement) {
20930
20976
  var currentElementInlineStyle = this.getInlineStyle(currentElement);
20931
20977
  var nextElementInlineStyle = this.getInlineStyle(nextElement);
@@ -20971,7 +21017,7 @@
20971
21017
  InlineStyleTool.prototype.saveInlineSelection = function (container, firstTimeCall) {
20972
21018
  if (firstTimeCall === void 0) { firstTimeCall = false; }
20973
21019
  return __awaiter(this, void 0, void 0, function () {
20974
- var nextNode, selection, range, currentFragment, currentElement;
21020
+ var nextNode, selection, isLTR, range, currentFragment, currentElement;
20975
21021
  return __generator(this, function (_c) {
20976
21022
  switch (_c.label) {
20977
21023
  case 0:
@@ -20994,9 +21040,10 @@
20994
21040
  case 1:
20995
21041
  if (!(nextNode && (!this.foundAnchorNode || !this.foundFocusNode))) return [3 /*break*/, 4];
20996
21042
  if (nextNode === this.selectedAnchorNode) {
20997
- this.foundAnchorNode = true;
20998
- this.foundAnchorOffset += this.anchorOffset;
20999
21043
  selection = this.getSelection();
21044
+ isLTR = this.isAnchorBeforeFocus(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
21045
+ this.foundAnchorNode = true;
21046
+ this.foundAnchorOffset += isLTR ? this.anchorOffset : this.focusOffset;
21000
21047
  range = this.getRangeObject(selection);
21001
21048
  currentFragment = range.cloneContents();
21002
21049
  currentElement = document.createElement('span');
@@ -22667,7 +22714,7 @@
22667
22714
  if (!anchorNode) {
22668
22715
  return [2 /*return*/];
22669
22716
  }
22670
- parentModifier = this.findParentModifier(anchorNode.parentElement);
22717
+ parentModifier = this.findParentModifier();
22671
22718
  try {
22672
22719
  if (this.tag.toLowerCase() !== 'span') {
22673
22720
  this.changeContainerTag(parentModifier, selection);
@@ -22804,22 +22851,6 @@
22804
22851
  container.className += (container.className.length > 0 ? ' ' : '') + this.classToApply;
22805
22852
  }
22806
22853
  };
22807
- ParagraphStyleTool.prototype.findParentModifier = function (element) {
22808
- var currentElement = element;
22809
- if (currentElement.tagName.toLowerCase() === 'div') {
22810
- if (currentElement.classList.contains('ce-paragraph')) {
22811
- return currentElement.children[0];
22812
- }
22813
- return currentElement.closest('.codex-editor__redactor').querySelector('.ce-paragraph').children[0];
22814
- }
22815
- while (this.modifiers.split(',').indexOf(currentElement.tagName.toLowerCase()) === -1) {
22816
- if (currentElement.tagName.toLowerCase() === 'div') {
22817
- return null;
22818
- }
22819
- currentElement = currentElement.parentElement;
22820
- }
22821
- return currentElement;
22822
- };
22823
22854
  return ParagraphStyleTool;
22824
22855
  }(EditorJSTool));
22825
22856
  var listApi = null;
@@ -23158,7 +23189,7 @@
23158
23189
  if (!isBlockFocused) {
23159
23190
  setBlockFocus(this.parentEditor);
23160
23191
  }
23161
- var parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
23192
+ var parentModifier = this.findParentModifier();
23162
23193
  if (!parentModifier) {
23163
23194
  return false;
23164
23195
  }
@@ -23469,7 +23500,7 @@
23469
23500
  if (!isBlockFocused) {
23470
23501
  setBlockFocus(this.parentEditor);
23471
23502
  }
23472
- var parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
23503
+ var parentModifier = this.findParentModifier();
23473
23504
  if (!parentModifier) {
23474
23505
  return false;
23475
23506
  }
@@ -23605,7 +23636,7 @@
23605
23636
  if (!isBlockFocused) {
23606
23637
  setBlockFocus(this.parentEditor);
23607
23638
  }
23608
- var parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
23639
+ var parentModifier = this.findParentModifier();
23609
23640
  if (!parentModifier) {
23610
23641
  return false;
23611
23642
  }
@@ -23693,7 +23724,7 @@
23693
23724
  if (!isBlockFocused) {
23694
23725
  setBlockFocus(this.parentEditor);
23695
23726
  }
23696
- var parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
23727
+ var parentModifier = this.findParentModifier();
23697
23728
  if (!parentModifier) {
23698
23729
  return false;
23699
23730
  }
@@ -23781,7 +23812,7 @@
23781
23812
  if (!isBlockFocused) {
23782
23813
  setBlockFocus(this.parentEditor);
23783
23814
  }
23784
- var parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
23815
+ var parentModifier = this.findParentModifier();
23785
23816
  if (!parentModifier) {
23786
23817
  return false;
23787
23818
  }
@@ -24419,23 +24450,6 @@
24419
24450
  return true;
24420
24451
  }
24421
24452
  };
24422
- InlineTextTool.prototype.findParentModifier = function (element) {
24423
- var modifiers = 'h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote';
24424
- var currentElement = element;
24425
- if (currentElement.tagName.toLowerCase() === 'div') {
24426
- if (currentElement.classList.contains('ce-paragraph')) {
24427
- return currentElement.firstElementChild;
24428
- }
24429
- return currentElement.querySelector('.ce-paragraph').children[0];
24430
- }
24431
- while (modifiers.split(',').indexOf(currentElement.tagName.toLowerCase()) === -1) {
24432
- if (currentElement.tagName.toLowerCase() === 'div') {
24433
- return null;
24434
- }
24435
- currentElement = currentElement.parentElement;
24436
- }
24437
- return currentElement;
24438
- };
24439
24453
  return InlineTextTool;
24440
24454
  }(InlineStyleTool));
24441
24455
 
@@ -24674,20 +24688,17 @@
24674
24688
  modal.appendChild(editorContainer);
24675
24689
  modal.appendChild(buttonContainer);
24676
24690
  container.appendChild(modal);
24677
- document.querySelector('body').appendChild(container);
24678
- setTimeout(function () {
24679
- console.log('monacoeditor init');
24680
- var monacoEditor = monaco.editor.create(editorContainer, {
24681
- value: content,
24682
- language: 'html',
24683
- ariaContainerElement: container
24684
- });
24685
- saveButton.addEventListener('click', function () {
24686
- var content = monacoEditor.getValue();
24687
- saveCodeEditModal(content);
24688
- }, true);
24689
- buttonContainer.appendChild(saveButton);
24690
- }, 200);
24691
+ document.body.appendChild(container);
24692
+ var state$1 = state.EditorState.create({
24693
+ doc: content,
24694
+ extensions: [codemirror.basicSetup, langHtml.html()],
24695
+ });
24696
+ var view = new codemirror.EditorView({
24697
+ state: state$1,
24698
+ parent: editorContainer,
24699
+ });
24700
+ saveButton.addEventListener('click', function () { return saveCodeEditModal(view.state.doc.toString()); }, true);
24701
+ buttonContainer.appendChild(saveButton);
24691
24702
  };
24692
24703
  TextEditionTool.prototype.getSavedEditorContent = function (name) {
24693
24704
  return localStorage.getItem(name);
@@ -25271,6 +25282,7 @@
25271
25282
  this.timeoutHandle = null;
25272
25283
  this.timeoutTextEditionHandle = null;
25273
25284
  this.onChangeTimeoutHandle = null;
25285
+ this.editorInitialized = false;
25274
25286
  this.wrapperTags = 'h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote';
25275
25287
  }
25276
25288
  EditorJsComponent.prototype.ngOnInit = function () {
@@ -25337,7 +25349,7 @@
25337
25349
  clearTimeout(_this.onChangeTimeoutHandle);
25338
25350
  _this.onChangeTimeoutHandle = setTimeout(function () {
25339
25351
  _this.contentChanged(api, event);
25340
- }, 300);
25352
+ }, 200);
25341
25353
  },
25342
25354
  i18n: this.getI18nDictionnary(),
25343
25355
  });
@@ -25352,12 +25364,10 @@
25352
25364
  _this.content = content;
25353
25365
  _this.applyContent();
25354
25366
  _this.checkSingleChild();
25355
- setTimeout(function () {
25356
- var editorElement = document.getElementById('editorJs-' + _this.uuid);
25357
- editorElement.addEventListener('focusin', function () {
25358
- setlistApiEditor(_this.editor, editorElement);
25359
- });
25360
- }, 0);
25367
+ var editorElement = document.getElementById('editorJs-' + _this.uuid);
25368
+ editorElement.addEventListener('focusin', function () {
25369
+ setlistApiEditor(_this.editor, editorElement);
25370
+ });
25361
25371
  });
25362
25372
  return [3 /*break*/, 4];
25363
25373
  case 3:
@@ -25372,7 +25382,6 @@
25372
25382
  EditorJsComponent.prototype.ngOnDestroy = function () {
25373
25383
  var editorName = 'editorJs-' + this.uuid;
25374
25384
  this.deleteSavedEditorContent(editorName);
25375
- this.deleteSavedEditorContent(editorName);
25376
25385
  this.editor.destroy();
25377
25386
  };
25378
25387
  EditorJsComponent.prototype.handleDefaultContentTranslation = function () {
@@ -25390,7 +25399,13 @@
25390
25399
  .save()
25391
25400
  .then(function () {
25392
25401
  _this.content = _this.getEditorContent();
25393
- _this.saveEditorContent(_this.content, _this.uuid);
25402
+ if (!_this.editorInitialized) {
25403
+ _this.handleSaveEditor(_this.content, _this.uuid);
25404
+ _this.editorInitialized = true;
25405
+ }
25406
+ else {
25407
+ _this.saveEditorContent(_this.content);
25408
+ }
25394
25409
  _this.contentChange.emit(_this.content);
25395
25410
  })
25396
25411
  .catch(function (error) {
@@ -25533,12 +25548,12 @@
25533
25548
  }
25534
25549
  return null;
25535
25550
  };
25536
- EditorJsComponent.prototype.saveEditorContent = function (data, uuid) {
25551
+ EditorJsComponent.prototype.saveEditorContent = function (data) {
25537
25552
  var _this = this;
25538
25553
  if (!isTextEditionTool) {
25539
25554
  clearTimeout(this.timeoutHandle);
25540
25555
  this.timeoutHandle = setTimeout(function () {
25541
- _this.handleSaveEditor(data, uuid);
25556
+ _this.handleSaveEditor(data, _this.uuid);
25542
25557
  }, 2000);
25543
25558
  }
25544
25559
  else {
@@ -25554,6 +25569,10 @@
25554
25569
  var savedDataIndex = this.getSavedEditorContent(editorName + '-index')
25555
25570
  ? parseInt(this.getSavedEditorContent(editorName + '-index'))
25556
25571
  : -1;
25572
+ if (!this.editorInitialized) {
25573
+ savedData = null;
25574
+ savedDataIndex = -1;
25575
+ }
25557
25576
  var parsedSavedData = [];
25558
25577
  if (savedData) {
25559
25578
  parsedSavedData = JSON.parse(savedData);
@@ -25575,6 +25594,7 @@
25575
25594
  };
25576
25595
  EditorJsComponent.prototype.deleteSavedEditorContent = function (name) {
25577
25596
  localStorage.removeItem(name);
25597
+ localStorage.removeItem(name + '-index');
25578
25598
  };
25579
25599
  return EditorJsComponent;
25580
25600
  }());