@vaadin/rich-text-editor 23.1.0-alpha3 → 23.1.0-beta2

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.
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@vaadin/rich-text-editor",
3
- "version": "23.1.0-alpha3",
3
+ "version": "23.1.0-beta2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "description": "vaadin-rich-text-editor",
8
8
  "license": "https://raw.githubusercontent.com/vaadin/web-components/master/packages/rich-text-editor/LICENSE",
9
+ "cvdlName": "vaadin-rich-text-editor",
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "https://github.com/vaadin/web-components.git",
@@ -38,14 +39,14 @@
38
39
  ],
39
40
  "dependencies": {
40
41
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/button": "23.1.0-alpha3",
42
- "@vaadin/component-base": "23.1.0-alpha3",
43
- "@vaadin/confirm-dialog": "23.1.0-alpha3",
44
- "@vaadin/text-field": "23.1.0-alpha3",
42
+ "@vaadin/button": "23.1.0-beta2",
43
+ "@vaadin/component-base": "23.1.0-beta2",
44
+ "@vaadin/confirm-dialog": "23.1.0-beta2",
45
+ "@vaadin/text-field": "23.1.0-beta2",
45
46
  "@vaadin/vaadin-license-checker": "^2.1.0",
46
- "@vaadin/vaadin-lumo-styles": "23.1.0-alpha3",
47
- "@vaadin/vaadin-material-styles": "23.1.0-alpha3",
48
- "@vaadin/vaadin-themable-mixin": "23.1.0-alpha3"
47
+ "@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
48
+ "@vaadin/vaadin-material-styles": "23.1.0-beta2",
49
+ "@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@esm-bundle/chai": "^4.3.4",
@@ -55,5 +56,5 @@
55
56
  "gulp-iconfont": "^11.0.0",
56
57
  "sinon": "^13.0.2"
57
58
  },
58
- "gitHead": "8c9e64e8dfa158dd52a9bf6da351ff038c88ca85"
59
+ "gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
59
60
  }
@@ -181,13 +181,13 @@ declare class RichTextEditor extends ElementMixin(ThemableMixin(HTMLElement)) {
181
181
  addEventListener<K extends keyof RichTextEditorEventMap>(
182
182
  type: K,
183
183
  listener: (this: RichTextEditor, ev: RichTextEditorEventMap[K]) => void,
184
- options?: boolean | AddEventListenerOptions
184
+ options?: boolean | AddEventListenerOptions,
185
185
  ): void;
186
186
 
187
187
  removeEventListener<K extends keyof RichTextEditorEventMap>(
188
188
  type: K,
189
189
  listener: (this: RichTextEditor, ev: RichTextEditorEventMap[K]) => void,
190
- options?: boolean | EventListenerOptions
190
+ options?: boolean | EventListenerOptions,
191
191
  ): void;
192
192
  }
193
193
 
@@ -31,19 +31,19 @@ const HANDLERS = [
31
31
  'list',
32
32
  'align',
33
33
  'blockquote',
34
- 'code-block'
34
+ 'code-block',
35
35
  ];
36
36
 
37
37
  const SOURCE = {
38
38
  API: 'api',
39
39
  USER: 'user',
40
- SILENT: 'silent'
40
+ SILENT: 'silent',
41
41
  };
42
42
 
43
43
  const STATE = {
44
44
  DEFAULT: 0,
45
45
  FOCUSED: 1,
46
- CLICKED: 2
46
+ CLICKED: 2,
47
47
  };
48
48
 
49
49
  const TAB_KEY = 9;
@@ -362,6 +362,10 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
362
362
  return 'vaadin-rich-text-editor';
363
363
  }
364
364
 
365
+ static get cvdlName() {
366
+ return 'vaadin-rich-text-editor';
367
+ }
368
+
365
369
  static get properties() {
366
370
  return {
367
371
  /**
@@ -382,7 +386,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
382
386
  value: {
383
387
  type: String,
384
388
  notify: true,
385
- value: ''
389
+ value: '',
386
390
  },
387
391
 
388
392
  /**
@@ -391,7 +395,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
391
395
  htmlValue: {
392
396
  type: String,
393
397
  notify: true,
394
- readOnly: true
398
+ readOnly: true,
395
399
  },
396
400
 
397
401
  /**
@@ -401,7 +405,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
401
405
  disabled: {
402
406
  type: Boolean,
403
407
  value: false,
404
- reflectToAttribute: true
408
+ reflectToAttribute: true,
405
409
  },
406
410
 
407
411
  /**
@@ -411,7 +415,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
411
415
  readonly: {
412
416
  type: Boolean,
413
417
  value: false,
414
- reflectToAttribute: true
418
+ reflectToAttribute: true,
415
419
  },
416
420
 
417
421
  /**
@@ -449,14 +453,14 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
449
453
  linkDialogTitle: 'Link address',
450
454
  ok: 'OK',
451
455
  cancel: 'Cancel',
452
- remove: 'Remove'
456
+ remove: 'Remove',
453
457
  };
454
- }
458
+ },
455
459
  },
456
460
 
457
461
  /** @private */
458
462
  _editor: {
459
- type: Object
463
+ type: Object,
460
464
  },
461
465
 
462
466
  /**
@@ -468,31 +472,31 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
468
472
  /** @private */
469
473
  __lastCommittedChange: {
470
474
  type: String,
471
- value: ''
475
+ value: '',
472
476
  },
473
477
 
474
478
  /** @private */
475
479
  _linkEditing: {
476
- type: Boolean
480
+ type: Boolean,
477
481
  },
478
482
 
479
483
  /** @private */
480
484
  _linkRange: {
481
485
  type: Object,
482
- value: null
486
+ value: null,
483
487
  },
484
488
 
485
489
  /** @private */
486
490
  _linkIndex: {
487
491
  type: Number,
488
- value: null
492
+ value: null,
489
493
  },
490
494
 
491
495
  /** @private */
492
496
  _linkUrl: {
493
497
  type: String,
494
- value: ''
495
- }
498
+ value: '',
499
+ },
496
500
  };
497
501
  }
498
502
 
@@ -558,8 +562,8 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
558
562
 
559
563
  this._editor = new Quill(editor, {
560
564
  modules: {
561
- toolbar: toolbarConfig
562
- }
565
+ toolbar: toolbarConfig,
566
+ },
563
567
  });
564
568
 
565
569
  this.__patchToolbar();
@@ -595,7 +599,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
595
599
  });
596
600
 
597
601
  editorContent.addEventListener('focus', () => {
598
- // format changed, but no value changed happened
602
+ // Format changed, but no value changed happened
599
603
  if (this._toolbarState === STATE.CLICKED) {
600
604
  this._cleanToolbarState();
601
605
  }
@@ -613,11 +617,11 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
613
617
  const toolbar = {
614
618
  container: this.shadowRoot.querySelector('[part="toolbar"]'),
615
619
  handlers: {
616
- clean: function () {
620
+ clean() {
617
621
  self._markToolbarClicked();
618
622
  clean.call(this);
619
- }
620
- }
623
+ },
624
+ },
621
625
  };
622
626
 
623
627
  HANDLERS.forEach((handler) => {
@@ -662,7 +666,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
662
666
  }
663
667
  });
664
668
 
665
- // mousedown happens before editor focusout
669
+ // Mousedown happens before editor focusout
666
670
  toolbar.addEventListener('mousedown', (e) => {
667
671
  if (buttons.indexOf(e.composedPath()[0]) > -1) {
668
672
  this._markToolbarFocused();
@@ -687,7 +691,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
687
691
 
688
692
  /** @private */
689
693
  __createFakeFocusTarget() {
690
- const isRTL = document.documentElement.getAttribute('dir') == 'rtl';
694
+ const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
691
695
  const elem = document.createElement('textarea');
692
696
  // Reset box model
693
697
  elem.style.border = '0';
@@ -704,7 +708,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
704
708
 
705
709
  /** @private */
706
710
  __patchFirefoxFocus() {
707
- // in Firefox 63+ with native Shadow DOM, when moving focus out of
711
+ // In Firefox 63+ with native Shadow DOM, when moving focus out of
708
712
  // contenteditable and back again within same shadow root, cursor
709
713
  // disappears. See https://bugzilla.mozilla.org/show_bug.cgi?id=1496769
710
714
  const editorContent = this.shadowRoot.querySelector('.ql-editor');
@@ -714,7 +718,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
714
718
  isFake = true;
715
719
  this.__fakeTarget = this.__createFakeFocusTarget();
716
720
  document.body.appendChild(this.__fakeTarget);
717
- // let the focus step out of shadow root!
721
+ // Let the focus step out of shadow root!
718
722
  this.__fakeTarget.focus();
719
723
  return new Promise((resolve) => {
720
724
  setTimeout(resolve);
@@ -753,7 +757,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
753
757
  const toolbar = this._editor.getModule('toolbar');
754
758
  const update = toolbar.update;
755
759
 
756
- // add custom link button to toggle state attribute
760
+ // Add custom link button to toggle state attribute
757
761
  toolbar.controls.push(['link', this.shadowRoot.querySelector('[part~="toolbar-button-link"]')]);
758
762
 
759
763
  toolbar.update = function (range) {
@@ -780,7 +784,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
780
784
  const keyboard = this._editor.getModule('keyboard');
781
785
  const bindings = keyboard.bindings[TAB_KEY];
782
786
 
783
- // exclude Quill shift-tab bindings, except for code block,
787
+ // Exclude Quill shift-tab bindings, except for code block,
784
788
  // as some of those are breaking when on a newline in the list
785
789
  // https://github.com/vaadin/vaadin-rich-text-editor/issues/67
786
790
  const originalBindings = bindings.filter((b) => !b.shiftKey || (b.format && b.format['code-block']));
@@ -788,7 +792,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
788
792
 
789
793
  keyboard.bindings[TAB_KEY] = [...originalBindings, moveFocusBinding];
790
794
 
791
- // alt-f10 focuses a toolbar button
795
+ // Alt-f10 focuses a toolbar button
792
796
  keyboard.addBinding({ key: 121, altKey: true, handler: focusToolbar });
793
797
  }
794
798
 
@@ -814,7 +818,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
814
818
  const LinkBlot = Quill.imports['formats/link'];
815
819
  const [link, offset] = this._editor.scroll.descendant(LinkBlot, range.index);
816
820
  if (link != null) {
817
- // existing link
821
+ // Existing link
818
822
  this._linkRange = { index: range.index - offset, length: link.length() };
819
823
  this._linkUrl = LinkBlot.formats(link.domNode);
820
824
  } else if (range.length === 0) {
@@ -912,7 +916,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
912
916
  [this.__dir === 'rtl' ? 'left' : 'right', 'center', 'justify'].forEach((align) => {
913
917
  content = content.replace(
914
918
  new RegExp(` class=[\\\\]?"\\s?ql-align-${align}[\\\\]?"`, 'g'),
915
- ` style="text-align: ${align}"`
919
+ ` style="text-align: ${align}"`,
916
920
  );
917
921
  });
918
922
 
@@ -951,7 +955,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
951
955
  .map((button) => button.getAttribute('title'))
952
956
  .join(', ');
953
957
  announcer.textContent = formatting;
954
- }
958
+ },
955
959
  );
956
960
  }
957
961
 
@@ -1017,7 +1021,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
1017
1021
  const range = this._editor.getSelection(true);
1018
1022
  this._editor.updateContents(
1019
1023
  new Quill.imports.delta().retain(range.index).delete(range.length).insert({ image }),
1020
- SOURCE.USER
1024
+ SOURCE.USER,
1021
1025
  );
1022
1026
  this._markToolbarClicked();
1023
1027
  this._editor.setSelection(range.index + 1, SOURCE.SILENT);
@@ -1056,7 +1060,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
1056
1060
  return;
1057
1061
  }
1058
1062
 
1059
- if (value == null || value == '[{"insert":"\\n"}]') {
1063
+ if (value == null || value === '[{"insert":"\\n"}]') {
1060
1064
  this.value = '';
1061
1065
  return;
1062
1066
  }
@@ -1072,7 +1076,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
1072
1076
  if (Array.isArray(parsedValue)) {
1073
1077
  this.__oldValue = value;
1074
1078
  } else {
1075
- throw new Error('expected JSON string with array of objects, got: ' + value);
1079
+ throw new Error(`expected JSON string with array of objects, got: ${value}`);
1076
1080
  }
1077
1081
  } catch (err) {
1078
1082
  // Use old value in case new one is not suitable
@@ -1081,7 +1085,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
1081
1085
  return;
1082
1086
  }
1083
1087
  const delta = new Quill.imports.delta(parsedValue);
1084
- // suppress text-change event to prevent infinite loop
1088
+ // Suppress text-change event to prevent infinite loop
1085
1089
  if (JSON.stringify(editor.getContents()) !== JSON.stringify(delta)) {
1086
1090
  editor.setContents(delta, SOURCE.SILENT);
1087
1091
  }
@@ -1091,7 +1095,7 @@ class RichTextEditor extends ElementMixin(ThemableMixin(PolymerElement)) {
1091
1095
  this._cleanToolbarState();
1092
1096
  this.__emitChangeEvent();
1093
1097
  } else if (!this._editor.hasFocus()) {
1094
- // value changed from outside
1098
+ // Value changed from outside
1095
1099
  this.__lastCommittedChange = this.value;
1096
1100
  }
1097
1101
  }
@@ -217,5 +217,5 @@ const richTextEditor = css`
217
217
  `;
218
218
 
219
219
  registerStyles('vaadin-rich-text-editor', [color, typography, richTextEditor], {
220
- moduleId: 'lumo-rich-text-editor'
220
+ moduleId: 'lumo-rich-text-editor',
221
221
  });
@@ -94,5 +94,5 @@ const richTextEditor = css`
94
94
  `;
95
95
 
96
96
  registerStyles('vaadin-rich-text-editor', [typography, richTextEditor], {
97
- moduleId: 'material-rich-text-editor'
97
+ moduleId: 'material-rich-text-editor',
98
98
  });