@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
@@ -23,6 +23,9 @@ import { NgScrollbarModule } from 'ngx-scrollbar';
23
23
  import { __awaiter } from 'tslib';
24
24
  import EditorJS from '@editorjs/editorjs';
25
25
  import iro from '@jaames/iro';
26
+ import { basicSetup, EditorView } from 'codemirror';
27
+ import { EditorState } from '@codemirror/state';
28
+ import { html } from '@codemirror/lang-html';
26
29
  import { MonacoEditorModule } from 'ngx-monaco-editor';
27
30
  import { tileLayer, latLng, marker, icon } from 'leaflet';
28
31
  import places from 'places.js';
@@ -18648,6 +18651,13 @@ class EditorJSTool {
18648
18651
  const selection = this.currentSelection ? this.currentSelection : this.getSelection();
18649
18652
  return selection.anchorNode.parentElement.closest('.editorJs');
18650
18653
  }
18654
+ findParentModifier() {
18655
+ if (!this.parentEditor) {
18656
+ this.parentEditor = this.findParentEditor();
18657
+ }
18658
+ return (this.parentEditor.querySelectorAll('.ce-block')[this.api.blocks.getCurrentBlockIndex()].querySelector('.ce-paragraph')
18659
+ .children[0]);
18660
+ }
18651
18661
  clear() {
18652
18662
  resetBlockFocus(this.parentEditor);
18653
18663
  }
@@ -18728,29 +18738,28 @@ class InlineStyleTool extends EditorJSTool {
18728
18738
  : anchorNode.parentElement;
18729
18739
  const sameSelection = container && container.innerText === selection.toString();
18730
18740
  yield this.saveInlineSelection(container, true);
18731
- try {
18732
- // Link delete exception
18733
- if (this.linkDeletion) {
18734
- yield this.replaceLink(selection, this.hasStyle(container));
18741
+ console.log('=== inline tool execCommandStyle method ===');
18742
+ console.log(this.hasStyle(container));
18743
+ // Link delete exception
18744
+ if (this.linkDeletion) {
18745
+ yield this.replaceLink(selection, this.hasStyle(container));
18746
+ }
18747
+ else {
18748
+ if (sameSelection &&
18749
+ !this.isContainer(this.textContainers, container) &&
18750
+ this.hasStyle(container) &&
18751
+ selection.toString() === this.hasStyle(container).innerText) {
18752
+ console.log('-> update selection');
18753
+ yield this.updateSelection(selection, this.hasStyle(container), action, this.textContainers);
18735
18754
  }
18736
18755
  else {
18737
- if (sameSelection &&
18738
- !this.isContainer(this.textContainers, container) &&
18739
- this.hasStyle(container) &&
18740
- selection.toString() === this.hasStyle(container).innerText) {
18741
- yield this.updateSelection(selection, this.hasStyle(container), action, this.textContainers);
18742
- }
18743
- else {
18744
- yield this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers);
18745
- }
18746
- }
18747
- yield this.cleanupContainer(selection, container, true);
18748
- if (this.modifiedContent) {
18749
- yield this.resetInlineSelection(container, true);
18756
+ console.log('-> replace selection');
18757
+ yield this.replaceSelection(this.getMostDescendantChild(container), action, selection, this.textContainers);
18750
18758
  }
18751
18759
  }
18752
- catch (error) {
18753
- console.warn('Inline Tool Error : ' + error);
18760
+ yield this.cleanupContainer(selection, container, true);
18761
+ if (this.modifiedContent) {
18762
+ yield this.resetInlineSelection(container, true);
18754
18763
  }
18755
18764
  });
18756
18765
  }
@@ -18794,16 +18803,17 @@ class InlineStyleTool extends EditorJSTool {
18794
18803
  replaceSelection(container, action, selection, containers) {
18795
18804
  var _a;
18796
18805
  return __awaiter(this, void 0, void 0, function* () {
18797
- let parentContainer = this.hasStyle(container);
18798
18806
  const focusNode = selection.focusNode;
18799
18807
  let offsetContainer = focusNode.nodeType !== Node.TEXT_NODE && focusNode.nodeType !== Node.COMMENT_NODE
18800
18808
  ? focusNode
18801
18809
  : focusNode.parentElement;
18810
+ let parentContainer = this.hasStyle(container);
18802
18811
  let offsetParentContainer = this.hasStyle(offsetContainer);
18803
18812
  if (parentContainer &&
18804
18813
  parentContainer === offsetParentContainer &&
18805
18814
  ((parentContainer.children.length > 0 && parentContainer.innerText !== parentContainer.children[0].textContent) ||
18806
18815
  parentContainer.innerText !== selection.toString())) {
18816
+ console.log('if');
18807
18817
  const range = this.getRangeObject(selection);
18808
18818
  const currentFragment = range.extractContents();
18809
18819
  const currentElement = document.createElement('span');
@@ -18845,14 +18855,19 @@ class InlineStyleTool extends EditorJSTool {
18845
18855
  newElement.appendChild(preFragment);
18846
18856
  parentContainer.parentElement.insertBefore(currentElementToAppend, parentContainer);
18847
18857
  parentContainer.parentElement.insertBefore(newElement, currentElementToAppend);
18858
+ if (!parentContainer.textContent || parentContainer.textContent.length === 0) {
18859
+ parentContainer.parentElement.removeChild(parentContainer);
18860
+ }
18848
18861
  selection.selectAllChildren(currentElementToAppend);
18849
18862
  }
18850
18863
  else {
18864
+ console.log('else');
18851
18865
  const range = this.getRangeObject(selection);
18852
18866
  const fragment = range.extractContents();
18853
18867
  let fragmentElement = document.createElement('div');
18854
18868
  let newElement = yield this.createElement(container, action, containers);
18855
18869
  let elementToAppend = newElement;
18870
+ console.log(newElement);
18856
18871
  fragmentElement.append(fragment);
18857
18872
  if (((_a = fragmentElement.children) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
18858
18873
  this.textContainers.split(',').indexOf(fragmentElement.children[0].tagName.toLowerCase()) > -1) {
@@ -19024,8 +19039,28 @@ class InlineStyleTool extends EditorJSTool {
19024
19039
  }
19025
19040
  });
19026
19041
  }
19042
+ parentHasStyle(currentElement, referenceElement) {
19043
+ // Link exception
19044
+ if (!currentElement || referenceElement.tagName.toLowerCase() === 'a' || referenceElement.tagName.toLowerCase() === 'div') {
19045
+ return false;
19046
+ }
19047
+ if (referenceElement.tagName.toLowerCase() !== 'span' &&
19048
+ referenceElement.tagName.toLowerCase() === currentElement.tagName.toLowerCase()) {
19049
+ return true;
19050
+ }
19051
+ if (Object.keys(this.getInlineStyle(currentElement)).length > 0 && this.identicalInlineStyle(currentElement, referenceElement)) {
19052
+ return true;
19053
+ }
19054
+ if (currentElement.classList.length > 0 && this.identicalClassList(currentElement, referenceElement)) {
19055
+ return true;
19056
+ }
19057
+ if (currentElement.parentElement && currentElement.parentElement.tagName.toLowerCase() !== 'div') {
19058
+ return this.parentHasStyle(currentElement.parentElement, referenceElement);
19059
+ }
19060
+ return false;
19061
+ }
19027
19062
  cleanupContainer(selection, container, firstTimeCall) {
19028
- var _a, _b;
19063
+ var _a;
19029
19064
  return __awaiter(this, void 0, void 0, function* () {
19030
19065
  let parentContainer;
19031
19066
  let parentFound = false;
@@ -19050,51 +19085,57 @@ class InlineStyleTool extends EditorJSTool {
19050
19085
  const children = Array.from(parentContainer.childNodes);
19051
19086
  if ((children === null || children === void 0 ? void 0 : children.length) > 0) {
19052
19087
  for (var currentNode = children[0]; currentNode; currentNode = currentNode.nextSibling) {
19053
- console.log('currentNode');
19054
- console.log(currentNode);
19055
- console.log(currentNode.textContent);
19056
- console.log((_b = currentNode.textContent) === null || _b === void 0 ? void 0 : _b.length);
19057
- if (!currentNode.textContent || currentNode.textContent.length === 0) {
19088
+ if ((!currentNode.textContent || currentNode.textContent.length === 0) || (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.innerText.length === 0)) {
19089
+ let previousSibling = currentNode.previousSibling;
19058
19090
  parentContainer.removeChild(currentNode);
19091
+ currentNode = previousSibling;
19059
19092
  }
19060
- else {
19061
- if (currentNode.childNodes.length > 0) {
19062
- yield this.cleanupContainer(selection, currentNode, false);
19063
- }
19064
- let identicalElements = true;
19065
- while (identicalElements &&
19066
- currentNode.nextSibling &&
19067
- currentNode.nodeType === Node.ELEMENT_NODE &&
19068
- currentNode.nextSibling.nodeType === Node.ELEMENT_NODE) {
19069
- let currentElement = currentNode;
19070
- let nextElement = currentNode.nextSibling;
19071
- if (this.identicalInlineStyle(currentElement, nextElement) &&
19072
- currentElement.tagName.toLowerCase() === nextElement.tagName.toLowerCase() &&
19073
- this.identicalClassList(currentElement, nextElement) &&
19074
- !currentElement.hasAttributes() &&
19075
- !nextElement.hasAttributes()) {
19076
- currentElement.innerHTML += nextElement.innerHTML;
19077
- nextElement.remove();
19078
- this.modifiedContent = true;
19079
- }
19080
- else {
19081
- identicalElements = false;
19082
- }
19093
+ if (currentNode.nodeType === Node.ELEMENT_NODE &&
19094
+ this.parentHasStyle(currentNode.parentElement, currentNode)) {
19095
+ let currentNodeFirstChild = currentNode;
19096
+ let nextCurrentElement = currentNode.firstChild;
19097
+ while (currentNode.firstChild) {
19098
+ parentContainer.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
19099
+ currentNodeFirstChild = currentNodeFirstChild.nextSibling;
19083
19100
  }
19084
- if (currentNode.nodeType === Node.ELEMENT_NODE &&
19085
- currentNode.tagName.toLowerCase() === 'span' &&
19086
- Object.keys(this.getInlineStyle(currentNode)).length === 0 &&
19087
- (!currentNode.classList || currentNode.classList.length === 0) &&
19088
- this.hasNoAttributes(currentNode)) {
19089
- let currentNodeFirstChild = currentNode;
19090
- while (currentNode.firstChild) {
19091
- currentNodeFirstChild.parentElement.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
19092
- currentNodeFirstChild = currentNodeFirstChild.nextSibling;
19093
- }
19094
- currentNode.remove();
19101
+ parentContainer.removeChild(currentNode);
19102
+ currentNode = nextCurrentElement;
19103
+ }
19104
+ let identicalElements = true;
19105
+ while (identicalElements &&
19106
+ currentNode.nextSibling &&
19107
+ currentNode.nodeType === Node.ELEMENT_NODE &&
19108
+ currentNode.nextSibling.nodeType === Node.ELEMENT_NODE) {
19109
+ let currentElement = currentNode;
19110
+ let nextElement = currentNode.nextSibling;
19111
+ if (this.identicalInlineStyle(currentElement, nextElement) &&
19112
+ currentElement.tagName.toLowerCase() === nextElement.tagName.toLowerCase() &&
19113
+ this.identicalClassList(currentElement, nextElement) &&
19114
+ this.identicalAttributes(currentElement, nextElement)) {
19115
+ currentElement.innerHTML += nextElement.innerHTML;
19116
+ nextElement.remove();
19095
19117
  this.modifiedContent = true;
19096
19118
  }
19097
- currentNode.normalize();
19119
+ else {
19120
+ identicalElements = false;
19121
+ }
19122
+ }
19123
+ if (currentNode.nodeType === Node.ELEMENT_NODE &&
19124
+ currentNode.tagName.toLowerCase() === 'span' &&
19125
+ Object.keys(this.getInlineStyle(currentNode)).length === 0 &&
19126
+ (!currentNode.classList || currentNode.classList.length === 0) &&
19127
+ this.hasNoAttributes(currentNode)) {
19128
+ let currentNodeFirstChild = currentNode;
19129
+ while (currentNode.firstChild) {
19130
+ currentNodeFirstChild.parentElement.insertBefore(currentNode.firstChild, currentNodeFirstChild.nextSibling);
19131
+ currentNodeFirstChild = currentNodeFirstChild.nextSibling;
19132
+ }
19133
+ currentNode.remove();
19134
+ this.modifiedContent = true;
19135
+ }
19136
+ currentNode.normalize();
19137
+ if (currentNode.childNodes.length > 0) {
19138
+ yield this.cleanupContainer(selection, currentNode, false);
19098
19139
  }
19099
19140
  }
19100
19141
  }
@@ -19114,6 +19155,17 @@ class InlineStyleTool extends EditorJSTool {
19114
19155
  return ([...currentElement.classList].every((classList) => nextElement.classList.contains(classList)) &&
19115
19156
  [...nextElement.classList].every((classList) => currentElement.classList.contains(classList)));
19116
19157
  }
19158
+ identicalAttributes(currentElement, nextElement) {
19159
+ let currentElementAttributes = currentElement.getAttributeNames();
19160
+ currentElementAttributes.forEach(attribute => {
19161
+ if (attribute !== 'style') {
19162
+ if (!nextElement.getAttribute(attribute) || nextElement.getAttribute(attribute) !== currentElement.getAttribute(attribute)) {
19163
+ return false;
19164
+ }
19165
+ }
19166
+ });
19167
+ return true;
19168
+ }
19117
19169
  identicalInlineStyle(currentElement, nextElement) {
19118
19170
  const currentElementInlineStyle = this.getInlineStyle(currentElement);
19119
19171
  const nextElementInlineStyle = this.getInlineStyle(nextElement);
@@ -19167,9 +19219,10 @@ class InlineStyleTool extends EditorJSTool {
19167
19219
  let nextNode = container.firstChild;
19168
19220
  while (nextNode && (!this.foundAnchorNode || !this.foundFocusNode)) {
19169
19221
  if (nextNode === this.selectedAnchorNode) {
19170
- this.foundAnchorNode = true;
19171
- this.foundAnchorOffset += this.anchorOffset;
19172
19222
  let selection = this.getSelection();
19223
+ const isLTR = this.isAnchorBeforeFocus(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
19224
+ this.foundAnchorNode = true;
19225
+ this.foundAnchorOffset += isLTR ? this.anchorOffset : this.focusOffset;
19173
19226
  let range = this.getRangeObject(selection);
19174
19227
  const currentFragment = range.cloneContents();
19175
19228
  const currentElement = document.createElement('span');
@@ -20549,7 +20602,7 @@ class ParagraphStyleTool extends EditorJSTool {
20549
20602
  if (!anchorNode) {
20550
20603
  return;
20551
20604
  }
20552
- let parentModifier = this.findParentModifier(anchorNode.parentElement);
20605
+ let parentModifier = this.findParentModifier();
20553
20606
  try {
20554
20607
  if (this.tag.toLowerCase() !== 'span') {
20555
20608
  this.changeContainerTag(parentModifier, selection);
@@ -20684,22 +20737,6 @@ class ParagraphStyleTool extends EditorJSTool {
20684
20737
  container.className += (container.className.length > 0 ? ' ' : '') + this.classToApply;
20685
20738
  }
20686
20739
  }
20687
- findParentModifier(element) {
20688
- let currentElement = element;
20689
- if (currentElement.tagName.toLowerCase() === 'div') {
20690
- if (currentElement.classList.contains('ce-paragraph')) {
20691
- return currentElement.children[0];
20692
- }
20693
- return currentElement.closest('.codex-editor__redactor').querySelector('.ce-paragraph').children[0];
20694
- }
20695
- while (this.modifiers.split(',').indexOf(currentElement.tagName.toLowerCase()) === -1) {
20696
- if (currentElement.tagName.toLowerCase() === 'div') {
20697
- return null;
20698
- }
20699
- currentElement = currentElement.parentElement;
20700
- }
20701
- return currentElement;
20702
- }
20703
20740
  }
20704
20741
  var listApi = null;
20705
20742
  var listEditor = null;
@@ -20996,7 +21033,7 @@ class TextTypeTool extends ParagraphTextTool {
20996
21033
  if (!isBlockFocused) {
20997
21034
  setBlockFocus(this.parentEditor);
20998
21035
  }
20999
- const parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
21036
+ const parentModifier = this.findParentModifier();
21000
21037
  if (!parentModifier) {
21001
21038
  return false;
21002
21039
  }
@@ -21271,7 +21308,7 @@ class TextAlignTool extends ParagraphTextTool {
21271
21308
  if (!isBlockFocused) {
21272
21309
  setBlockFocus(this.parentEditor);
21273
21310
  }
21274
- const parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
21311
+ const parentModifier = this.findParentModifier();
21275
21312
  if (!parentModifier) {
21276
21313
  return false;
21277
21314
  }
@@ -21375,7 +21412,7 @@ class UnorderedListTool extends ParagraphStyleTool {
21375
21412
  if (!isBlockFocused) {
21376
21413
  setBlockFocus(this.parentEditor);
21377
21414
  }
21378
- const parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
21415
+ const parentModifier = this.findParentModifier();
21379
21416
  if (!parentModifier) {
21380
21417
  return false;
21381
21418
  }
@@ -21440,7 +21477,7 @@ class OrderedListTool extends ParagraphStyleTool {
21440
21477
  if (!isBlockFocused) {
21441
21478
  setBlockFocus(this.parentEditor);
21442
21479
  }
21443
- const parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
21480
+ const parentModifier = this.findParentModifier();
21444
21481
  if (!parentModifier) {
21445
21482
  return false;
21446
21483
  }
@@ -21505,7 +21542,7 @@ class QuoteTool extends ParagraphStyleTool {
21505
21542
  if (!isBlockFocused) {
21506
21543
  setBlockFocus(this.parentEditor);
21507
21544
  }
21508
- const parentModifier = this.findParentModifier(selection.anchorNode.parentElement);
21545
+ const parentModifier = this.findParentModifier();
21509
21546
  if (!parentModifier) {
21510
21547
  return false;
21511
21548
  }
@@ -22040,23 +22077,6 @@ class InlineTextTool extends InlineStyleTool {
22040
22077
  return true;
22041
22078
  }
22042
22079
  }
22043
- findParentModifier(element) {
22044
- const modifiers = 'h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote';
22045
- let currentElement = element;
22046
- if (currentElement.tagName.toLowerCase() === 'div') {
22047
- if (currentElement.classList.contains('ce-paragraph')) {
22048
- return currentElement.firstElementChild;
22049
- }
22050
- return currentElement.querySelector('.ce-paragraph').children[0];
22051
- }
22052
- while (modifiers.split(',').indexOf(currentElement.tagName.toLowerCase()) === -1) {
22053
- if (currentElement.tagName.toLowerCase() === 'div') {
22054
- return null;
22055
- }
22056
- currentElement = currentElement.parentElement;
22057
- }
22058
- return currentElement;
22059
- }
22060
22080
  }
22061
22081
 
22062
22082
  // @dynamic
@@ -22256,20 +22276,17 @@ class TextEditionTool extends ParagraphStyleTool {
22256
22276
  modal.appendChild(editorContainer);
22257
22277
  modal.appendChild(buttonContainer);
22258
22278
  container.appendChild(modal);
22259
- document.querySelector('body').appendChild(container);
22260
- setTimeout(() => {
22261
- console.log('monacoeditor init');
22262
- var monacoEditor = editor.create(editorContainer, {
22263
- value: content,
22264
- language: 'html',
22265
- ariaContainerElement: container
22266
- });
22267
- saveButton.addEventListener('click', () => {
22268
- let content = monacoEditor.getValue();
22269
- saveCodeEditModal(content);
22270
- }, true);
22271
- buttonContainer.appendChild(saveButton);
22272
- }, 200);
22279
+ document.body.appendChild(container);
22280
+ let state = EditorState.create({
22281
+ doc: content,
22282
+ extensions: [basicSetup, html()],
22283
+ });
22284
+ let view = new EditorView({
22285
+ state: state,
22286
+ parent: editorContainer,
22287
+ });
22288
+ saveButton.addEventListener('click', () => saveCodeEditModal(view.state.doc.toString()), true);
22289
+ buttonContainer.appendChild(saveButton);
22273
22290
  }
22274
22291
  getSavedEditorContent(name) {
22275
22292
  return localStorage.getItem(name);
@@ -22758,6 +22775,7 @@ class EditorJsComponent {
22758
22775
  this.timeoutHandle = null;
22759
22776
  this.timeoutTextEditionHandle = null;
22760
22777
  this.onChangeTimeoutHandle = null;
22778
+ this.editorInitialized = false;
22761
22779
  this.wrapperTags = 'h1,h2,h3,h4,h5,h6,p,ul,ol,blockquote';
22762
22780
  }
22763
22781
  ngOnInit() {
@@ -22819,7 +22837,7 @@ class EditorJsComponent {
22819
22837
  clearTimeout(this.onChangeTimeoutHandle);
22820
22838
  this.onChangeTimeoutHandle = setTimeout(() => {
22821
22839
  this.contentChanged(api, event);
22822
- }, 300);
22840
+ }, 200);
22823
22841
  },
22824
22842
  i18n: this.getI18nDictionnary(),
22825
22843
  });
@@ -22830,12 +22848,10 @@ class EditorJsComponent {
22830
22848
  this.content = content;
22831
22849
  this.applyContent();
22832
22850
  this.checkSingleChild();
22833
- setTimeout(() => {
22834
- const editorElement = document.getElementById('editorJs-' + this.uuid);
22835
- editorElement.addEventListener('focusin', () => {
22836
- setlistApiEditor(this.editor, editorElement);
22837
- });
22838
- }, 0);
22851
+ const editorElement = document.getElementById('editorJs-' + this.uuid);
22852
+ editorElement.addEventListener('focusin', () => {
22853
+ setlistApiEditor(this.editor, editorElement);
22854
+ });
22839
22855
  });
22840
22856
  }
22841
22857
  catch (reason) {
@@ -22846,7 +22862,6 @@ class EditorJsComponent {
22846
22862
  ngOnDestroy() {
22847
22863
  const editorName = 'editorJs-' + this.uuid;
22848
22864
  this.deleteSavedEditorContent(editorName);
22849
- this.deleteSavedEditorContent(editorName);
22850
22865
  this.editor.destroy();
22851
22866
  }
22852
22867
  handleDefaultContentTranslation() {
@@ -22863,7 +22878,13 @@ class EditorJsComponent {
22863
22878
  .save()
22864
22879
  .then(() => {
22865
22880
  this.content = this.getEditorContent();
22866
- this.saveEditorContent(this.content, this.uuid);
22881
+ if (!this.editorInitialized) {
22882
+ this.handleSaveEditor(this.content, this.uuid);
22883
+ this.editorInitialized = true;
22884
+ }
22885
+ else {
22886
+ this.saveEditorContent(this.content);
22887
+ }
22867
22888
  this.contentChange.emit(this.content);
22868
22889
  })
22869
22890
  .catch((error) => {
@@ -23005,11 +23026,11 @@ class EditorJsComponent {
23005
23026
  }
23006
23027
  return null;
23007
23028
  }
23008
- saveEditorContent(data, uuid) {
23029
+ saveEditorContent(data) {
23009
23030
  if (!isTextEditionTool) {
23010
23031
  clearTimeout(this.timeoutHandle);
23011
23032
  this.timeoutHandle = setTimeout(() => {
23012
- this.handleSaveEditor(data, uuid);
23033
+ this.handleSaveEditor(data, this.uuid);
23013
23034
  }, 2000);
23014
23035
  }
23015
23036
  else {
@@ -23025,6 +23046,10 @@ class EditorJsComponent {
23025
23046
  let savedDataIndex = this.getSavedEditorContent(editorName + '-index')
23026
23047
  ? parseInt(this.getSavedEditorContent(editorName + '-index'))
23027
23048
  : -1;
23049
+ if (!this.editorInitialized) {
23050
+ savedData = null;
23051
+ savedDataIndex = -1;
23052
+ }
23028
23053
  let parsedSavedData = [];
23029
23054
  if (savedData) {
23030
23055
  parsedSavedData = JSON.parse(savedData);
@@ -23046,6 +23071,7 @@ class EditorJsComponent {
23046
23071
  }
23047
23072
  deleteSavedEditorContent(name) {
23048
23073
  localStorage.removeItem(name);
23074
+ localStorage.removeItem(name + '-index');
23049
23075
  }
23050
23076
  }
23051
23077
  EditorJsComponent.decorators = [