@wizishop/wizi-block 4.2.23-beta → 4.2.26-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 (21) hide show
  1. package/assets/i18n/en.json +1 -1
  2. package/assets/i18n/fr.json +1 -1
  3. package/bundles/wizishop-wizi-block.umd.js +97 -32
  4. package/bundles/wizishop-wizi-block.umd.js.map +1 -1
  5. package/bundles/wizishop-wizi-block.umd.min.js +1 -1
  6. package/bundles/wizishop-wizi-block.umd.min.js.map +1 -1
  7. package/esm2015/lib/shared/components/editorjs/tools/inline/link-tool.component.js +52 -11
  8. package/esm2015/lib/shared/components/editorjs/tools/inline/text-background-color-tool.component.js +2 -1
  9. package/esm2015/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.js +5 -2
  10. package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/paragraph-style-tool.component.js +19 -5
  11. package/esm2015/lib/shared/components/editorjs/tools/paragraph/tool-type/text-edition.component.js +13 -14
  12. package/esm2015/lib/shared/components/editorjs/tools/utils/editorjs-tool.component.js +6 -1
  13. package/esm2015/lib/shared/components/editorjs/tools/utils/i18n/en-i18n.component.js +3 -3
  14. package/esm2015/lib/shared/components/editorjs/tools/utils/i18n/fr-i18n.component.js +3 -3
  15. package/fesm2015/wizishop-wizi-block.js +95 -32
  16. package/fesm2015/wizishop-wizi-block.js.map +1 -1
  17. package/lib/shared/components/editorjs/tools/inline/link-tool.component.d.ts +1 -0
  18. package/lib/shared/components/editorjs/tools/inline/tool-type/inline-style-tool.component.d.ts +1 -0
  19. package/lib/shared/components/editorjs/tools/utils/editorjs-tool.component.d.ts +1 -0
  20. package/package.json +4 -2
  21. package/wizi-block.scss +723 -689
@@ -18616,6 +18616,7 @@ class EditorJSTool {
18616
18616
  }
18617
18617
  resetUserSelection() {
18618
18618
  var _a;
18619
+ console.log('reset here');
18619
18620
  if (this.selectedAnchorNode.nodeType === Node.ELEMENT_NODE && this.selectedAnchorNode.children) {
18620
18621
  while (this.selectedAnchorNode.children &&
18621
18622
  this.selectedAnchorNode.innerText === ((_a = this.selectedAnchorNode.children[0]) === null || _a === void 0 ? void 0 : _a.innerText) &&
@@ -18639,6 +18640,10 @@ class EditorJSTool {
18639
18640
  }
18640
18641
  document.getSelection().setBaseAndExtent(this.selectedAnchorNode, this.anchorOffset, this.selectedFocusNode, this.focusOffset);
18641
18642
  }
18643
+ collapseSelection() {
18644
+ let selection = this.getSelection();
18645
+ document.getSelection().setBaseAndExtent(selection.anchorNode, 0, selection.anchorNode, 0);
18646
+ }
18642
18647
  findParentEditor() {
18643
18648
  const selection = this.currentSelection ? this.currentSelection : this.getSelection();
18644
18649
  return selection.anchorNode.parentElement.closest('.editorJs');
@@ -18697,6 +18702,7 @@ class InlineStyleTool extends EditorJSTool {
18697
18702
  this.foundFocusNode = false;
18698
18703
  this.tmpOffset = 0;
18699
18704
  this.modifiedContent = false;
18705
+ this.linkDeletion = false;
18700
18706
  this.modifies = {
18701
18707
  tag: false,
18702
18708
  style: false,
@@ -18723,7 +18729,7 @@ class InlineStyleTool extends EditorJSTool {
18723
18729
  const sameSelection = container && container.innerText === selection.toString();
18724
18730
  yield this.saveInlineSelection(container, true);
18725
18731
  // Link delete exception
18726
- if (this.modifies.tag && this.tag.toLowerCase() === 'a' && !this.attributesToApply) {
18732
+ if (this.linkDeletion) {
18727
18733
  yield this.replaceLink(selection, this.hasStyle(container));
18728
18734
  }
18729
18735
  else {
@@ -18860,6 +18866,8 @@ class InlineStyleTool extends EditorJSTool {
18860
18866
  }
18861
18867
  replaceLink(selection, container) {
18862
18868
  return __awaiter(this, void 0, void 0, function* () {
18869
+ console.log('container');
18870
+ console.log(container);
18863
18871
  let newElement = document.createElement('span');
18864
18872
  newElement.innerHTML = container.innerHTML;
18865
18873
  container.parentElement.replaceChild(newElement, container);
@@ -20393,6 +20401,7 @@ class TextBackgroundColorTool extends ColorTool {
20393
20401
  inputToFocus.focus();
20394
20402
  }
20395
20403
  //this.hideActions();
20404
+ this.collapseSelection();
20396
20405
  });
20397
20406
  }
20398
20407
  checkState(selection) {
@@ -20474,6 +20483,7 @@ class ParagraphStyleTool extends EditorJSTool {
20474
20483
  if (!selection) {
20475
20484
  return;
20476
20485
  }
20486
+ this.saveUserSelection();
20477
20487
  const anchorNode = selection.anchorNode;
20478
20488
  if (!this.parentEditor) {
20479
20489
  this.parentEditor = this.findParentEditor();
@@ -20488,8 +20498,7 @@ class ParagraphStyleTool extends EditorJSTool {
20488
20498
  if ((this.classToApply && this.classToApply.length > 0) || (this.classes && this.classes.length > 0)) {
20489
20499
  this.changeCurrentClass(parentModifier);
20490
20500
  }
20491
- this.saveUserSelection();
20492
- this.resetUserSelection();
20501
+ this.collapseSelection();
20493
20502
  });
20494
20503
  }
20495
20504
  checkOrderedListValue() {
@@ -20616,9 +20625,9 @@ class ParagraphStyleTool extends EditorJSTool {
20616
20625
  let currentElement = element;
20617
20626
  if (currentElement.tagName.toLowerCase() === 'div') {
20618
20627
  if (currentElement.classList.contains('ce-paragraph')) {
20619
- return currentElement;
20628
+ return currentElement.children[0];
20620
20629
  }
20621
- return currentElement.parentElement.querySelector('.ce-paragraph').children[0];
20630
+ return currentElement.closest('.codex-editor__redactor').querySelector('.ce-paragraph').children[0];
20622
20631
  }
20623
20632
  while (this.modifiers.split(',').indexOf(currentElement.tagName.toLowerCase()) === -1) {
20624
20633
  if (currentElement.tagName.toLowerCase() === 'div') {
@@ -20646,6 +20655,20 @@ function onEditList(event) {
20646
20655
  currentParagraph.removeEventListener('keydown', onEditList, true);
20647
20656
  document.getSelection().setBaseAndExtent(currentParagraph.querySelector('p'), 0, currentParagraph.querySelector('p'), 0);
20648
20657
  }
20658
+ else {
20659
+ let selection = document.getSelection();
20660
+ if (selection.anchorOffset === 0) {
20661
+ let newParagraph = document.createElement('p');
20662
+ let currentParagraph = listEditor.querySelectorAll('.ce-paragraph')[listApi.blocks.getCurrentBlockIndex()];
20663
+ newParagraph.innerHTML = currentParagraph.querySelector('li').innerHTML;
20664
+ currentParagraph.innerHTML = '';
20665
+ currentParagraph.appendChild(newParagraph);
20666
+ currentParagraph.removeEventListener('keydown', onEditList, true);
20667
+ document
20668
+ .getSelection()
20669
+ .setBaseAndExtent(currentParagraph.querySelector('p'), 0, currentParagraph.querySelector('p'), 0);
20670
+ }
20671
+ }
20649
20672
  }
20650
20673
  else {
20651
20674
  event.preventDefault();
@@ -20993,7 +21016,7 @@ const frI18nDictionnary = {
20993
21016
  placeholder: 'https://www.maboutique.fr or /monlien/',
20994
21017
  external: 'Externe ?',
20995
21018
  obfuscated: 'Lien Obfusqué ?',
20996
- info: 'L\'obfuscation de liens est une technique SEO avancée qui consiste à cacher un lien aux robots des moteurs de recherche, tout en le laissant accessible pour les internautes. <a href="https://www.wizishop.fr/blog/obfuscation-lien">Découvrir l\'article complet.</a>',
21019
+ info: 'L\'obfuscation de liens est une technique SEO avancée qui consiste à cacher un lien aux robots des moteurs de recherche, tout en le laissant accessible pour les internautes. <a href="https://www.wizishop.fr/blog/obfuscation-lien" target="_blank">Découvrir l\'article complet.</a>',
20997
21020
  },
20998
21021
  textBackgroundColor: {
20999
21022
  customColor: 'Sélectionner une couleur personnalisée :',
@@ -21012,7 +21035,7 @@ const frI18nDictionnary = {
21012
21035
  Small: 'Petit',
21013
21036
  Normal: 'Normal',
21014
21037
  Large: 'Grand',
21015
- Huge: 'Immense',
21038
+ Huge: 'Très grand',
21016
21039
  },
21017
21040
  codeEdit: {
21018
21041
  Cancel: 'Annuler',
@@ -21077,7 +21100,7 @@ const enI18nDictionnary = {
21077
21100
  placeholder: 'https://www.myshop.fr or /mylink/',
21078
21101
  external: 'External?',
21079
21102
  obfuscated: 'Obfuscated link?',
21080
- info: 'Link obfuscation is an advanced SEO technique that consists in hiding a link from search engine robots, while leaving it available for users. <a href="https://wizishop.com/blog/url-obfuscation">Read more</a>',
21103
+ info: 'Link obfuscation is an advanced SEO technique that consists in hiding a link from search engine robots, while leaving it available for users. <a href="https://wizishop.com/blog/url-obfuscation" target="_blank">Read more</a>',
21081
21104
  },
21082
21105
  textBackgroundColor: {
21083
21106
  customColor: 'Select a custom color :',
@@ -21096,7 +21119,7 @@ const enI18nDictionnary = {
21096
21119
  Small: 'Small',
21097
21120
  Normal: 'Normal',
21098
21121
  Large: 'Large',
21099
- Huge: 'Huge',
21122
+ Huge: 'Very large',
21100
21123
  },
21101
21124
  codeEdit: {
21102
21125
  Cancel: 'Cancel',
@@ -21443,6 +21466,7 @@ class LinkTool extends InlineStyleTool {
21443
21466
  };
21444
21467
  this.tag = 'SPAN';
21445
21468
  this.hasSeparatorBefore = true;
21469
+ this.linkDeletion = false;
21446
21470
  this.modifies = {
21447
21471
  tag: false,
21448
21472
  style: false,
@@ -21460,7 +21484,7 @@ class LinkTool extends InlineStyleTool {
21460
21484
  addButtonClass: 'ce-inline-actions--link__add',
21461
21485
  deleteButtonClass: 'ce-inline-actions--link__delete',
21462
21486
  };
21463
- this.attributeName = 'data-htap,href';
21487
+ this.attributeName = 'data-htap,href,data-knalb';
21464
21488
  this.attributesToApply = [];
21465
21489
  this.isLinkDropdownOpen = false;
21466
21490
  this.api = api;
@@ -21524,12 +21548,6 @@ class LinkTool extends InlineStyleTool {
21524
21548
  let targetCheckbox = this.parentEditor.querySelector('#' + this.linkCss['targetCheckboxId'] + uuid);
21525
21549
  let obfuscationCheckbox = this.parentEditor.querySelector('#' + this.linkCss['obfuscationCheckboxId'] + uuid);
21526
21550
  let linkInput = this.parentEditor.querySelector('#' + this.linkCss['linkInputId'] + uuid);
21527
- if (targetCheckbox.checked) {
21528
- this.attributesToApply.push({
21529
- name: 'target',
21530
- value: '_blank',
21531
- });
21532
- }
21533
21551
  if (obfuscationCheckbox.checked) {
21534
21552
  this.tag = 'SPAN';
21535
21553
  this.modifies.tag = false;
@@ -21537,6 +21555,12 @@ class LinkTool extends InlineStyleTool {
21537
21555
  name: 'data-htap',
21538
21556
  value: btoa(linkInput.value),
21539
21557
  });
21558
+ if (targetCheckbox.checked) {
21559
+ this.attributesToApply.push({
21560
+ name: 'data-knalb',
21561
+ value: 'true',
21562
+ });
21563
+ }
21540
21564
  }
21541
21565
  else {
21542
21566
  this.tag = 'A';
@@ -21545,6 +21569,12 @@ class LinkTool extends InlineStyleTool {
21545
21569
  name: 'href',
21546
21570
  value: linkInput.value,
21547
21571
  });
21572
+ if (targetCheckbox.checked) {
21573
+ this.attributesToApply.push({
21574
+ name: 'target',
21575
+ value: '_blank',
21576
+ });
21577
+ }
21548
21578
  }
21549
21579
  this.resetUserSelection();
21550
21580
  yield this.surround(null, true);
@@ -21557,13 +21587,44 @@ class LinkTool extends InlineStyleTool {
21557
21587
  if (!this.parentEditor) {
21558
21588
  this.parentEditor = this.findParentEditor();
21559
21589
  }
21560
- this.tag = 'A';
21561
- this.attributesToApply = null;
21562
- this.modifies.tag = true;
21590
+ let uuid = this.parentEditor.getAttribute('id').replace('editorJs-', '');
21591
+ let targetCheckbox = this.parentEditor.querySelector('#' + this.linkCss['targetCheckboxId'] + uuid);
21592
+ let obfuscationCheckbox = this.parentEditor.querySelector('#' + this.linkCss['obfuscationCheckboxId'] + uuid);
21593
+ let linkInput = this.parentEditor.querySelector('#' + this.linkCss['linkInputId'] + uuid);
21594
+ if (obfuscationCheckbox.checked) {
21595
+ this.tag = 'SPAN';
21596
+ this.modifies.tag = false;
21597
+ this.attributesToApply.push({
21598
+ name: 'data-htap',
21599
+ value: btoa(linkInput.value),
21600
+ });
21601
+ if (targetCheckbox.checked) {
21602
+ this.attributesToApply.push({
21603
+ name: 'data-knalb',
21604
+ value: 'true',
21605
+ });
21606
+ }
21607
+ }
21608
+ else {
21609
+ this.tag = 'A';
21610
+ this.modifies.tag = true;
21611
+ this.attributesToApply.push({
21612
+ name: 'href',
21613
+ value: linkInput.value,
21614
+ });
21615
+ if (targetCheckbox.checked) {
21616
+ this.attributesToApply.push({
21617
+ name: 'target',
21618
+ value: '_blank',
21619
+ });
21620
+ }
21621
+ }
21622
+ this.linkDeletion = true;
21563
21623
  this.resetUserSelection();
21564
21624
  yield this.surround(null, true);
21565
21625
  this.checkState(this.currentSelection);
21566
21626
  this.openLinkDropdown();
21627
+ this.linkDeletion = false;
21567
21628
  });
21568
21629
  }
21569
21630
  renderActions() {
@@ -21643,6 +21704,9 @@ class LinkTool extends InlineStyleTool {
21643
21704
  }
21644
21705
  }
21645
21706
  else {
21707
+ linkInput.value = '';
21708
+ targetCheckbox.checked = false;
21709
+ obfuscationCheckbox.checked = false;
21646
21710
  if (!deleteButton.classList.contains('hidden')) {
21647
21711
  deleteButton.classList.add('hidden');
21648
21712
  }
@@ -22105,8 +22169,7 @@ class TextEditionTool extends ParagraphStyleTool {
22105
22169
  }
22106
22170
  editHTML() {
22107
22171
  let content = this.getEditorContent();
22108
- let modal = this.createHTMLEditModal(content);
22109
- document.querySelector('body').appendChild(modal);
22172
+ this.createHTMLEditModal(content);
22110
22173
  }
22111
22174
  createHTMLEditModal(content) {
22112
22175
  let container = document.createElement('div');
@@ -22115,11 +22178,6 @@ class TextEditionTool extends ParagraphStyleTool {
22115
22178
  modal.classList.add(this.modalClass);
22116
22179
  let editorContainer = document.createElement('div');
22117
22180
  editorContainer.classList.add(this.editorClass);
22118
- var monacoEditor = editor.create(editorContainer, {
22119
- value: content,
22120
- language: 'html',
22121
- automaticLayout: true,
22122
- });
22123
22181
  codeEditEditor = this.findParentEditor();
22124
22182
  codeEditApi = this.api;
22125
22183
  let buttonContainer = document.createElement('div');
@@ -22128,17 +22186,22 @@ class TextEditionTool extends ParagraphStyleTool {
22128
22186
  cancelButton.innerText = editorJSI18nDictionnary.messages.tools.codeEdit['Cancel'];
22129
22187
  saveButton.innerText = editorJSI18nDictionnary.messages.tools.codeEdit['Save'];
22130
22188
  cancelButton.addEventListener('click', closeCodeEditModal, true);
22131
- saveButton.addEventListener('click', () => {
22132
- let content = monacoEditor.getValue();
22133
- saveCodeEditModal(content);
22134
- }, true);
22135
22189
  buttonContainer.appendChild(cancelButton);
22136
- buttonContainer.appendChild(saveButton);
22137
22190
  buttonContainer.classList.add(this.buttonClass);
22138
22191
  modal.appendChild(editorContainer);
22139
22192
  modal.appendChild(buttonContainer);
22140
22193
  container.appendChild(modal);
22141
- return container;
22194
+ document.querySelector('body').appendChild(container);
22195
+ var monacoEditor = editor.create(editorContainer, {
22196
+ value: content,
22197
+ language: 'html',
22198
+ });
22199
+ saveButton.addEventListener('click', () => {
22200
+ console.log("here");
22201
+ let content = monacoEditor.getValue();
22202
+ saveCodeEditModal(content);
22203
+ }, true);
22204
+ buttonContainer.appendChild(saveButton);
22142
22205
  }
22143
22206
  getSavedEditorContent(name) {
22144
22207
  return localStorage.getItem(name);