@limetech/lime-elements 37.45.0 → 37.45.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [37.45.2](https://github.com/Lundalogik/lime-elements/compare/v37.45.1...v37.45.2) (2024-05-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+
7
+ * **text-editor:** do not emit event for pointer transactions ([18f6d1c](https://github.com/Lundalogik/lime-elements/commit/18f6d1caf27622f3f8a5e8273d64194a139ea629))
8
+ * **text-editor:** never emit change event as result of getting updated value from consumer ([e4a52d0](https://github.com/Lundalogik/lime-elements/commit/e4a52d0db5f2401cbd9d6a9df38bce1f27fab84a))
9
+
10
+ ## [37.45.1](https://github.com/Lundalogik/lime-elements/compare/v37.45.0...v37.45.1) (2024-05-31)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+
16
+ * **text-editor:** throw error if the content type is not supported ([b5183e6](https://github.com/Lundalogik/lime-elements/commit/b5183e62202be3127146ced823e02daec3884ff8))
17
+
18
+ ### Performance Improvements
19
+
20
+
21
+ * **text-editor:** destroy view on disconnect ([2acbf8c](https://github.com/Lundalogik/lime-elements/commit/2acbf8cc59396079aa7c99a64620955385e7fffa))
22
+
1
23
  ## [37.45.0](https://github.com/Lundalogik/lime-elements/compare/v37.44.3...v37.45.0) (2024-05-29)
2
24
 
3
25
 
@@ -25560,6 +25560,7 @@ const ProsemirrorAdapter = class {
25560
25560
  constructor(hostRef) {
25561
25561
  index.registerInstance(this, hostRef);
25562
25562
  this.change = index.createEvent(this, "change", 7);
25563
+ this.suppressChangeEvent = false;
25563
25564
  this.getActionBarItems = () => {
25564
25565
  this.actionBarItems = getTextEditorMenuItems().map(this.getTranslatedItem);
25565
25566
  };
@@ -25576,6 +25577,12 @@ const ProsemirrorAdapter = class {
25576
25577
  this.handleTransaction = (transaction) => {
25577
25578
  const newState = this.view.state.apply(transaction);
25578
25579
  this.view.updateState(newState);
25580
+ if (this.suppressChangeEvent) {
25581
+ return;
25582
+ }
25583
+ if (transaction.getMeta('pointer')) {
25584
+ return;
25585
+ }
25579
25586
  this.change.emit(this.contentConverter.serialize(this.view, this.schema));
25580
25587
  };
25581
25588
  this.handleActionBarItem = (event) => {
@@ -25646,13 +25653,19 @@ const ProsemirrorAdapter = class {
25646
25653
  index.h("limel-action-bar", { accessibleLabel: "Toolbar", actions: this.actionBarItems, onItemSelected: this.handleActionBarItem }),
25647
25654
  ];
25648
25655
  }
25656
+ disconnectedCallback() {
25657
+ this.view.destroy();
25658
+ }
25649
25659
  setupContentConverter() {
25650
- /* eslint-disable multiline-ternary */
25651
- this.contentConverter =
25652
- this.contentType === 'markdown'
25653
- ? new markdownConverter()
25654
- : new HTMLConverter();
25655
- /* eslint-enable multiline-ternary */
25660
+ if (this.contentType === 'markdown') {
25661
+ this.contentConverter = new markdownConverter();
25662
+ }
25663
+ else if (this.contentType === 'html') {
25664
+ this.contentConverter = new HTMLConverter();
25665
+ }
25666
+ else {
25667
+ throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`);
25668
+ }
25656
25669
  }
25657
25670
  async initializeTextEditor() {
25658
25671
  this.schema = this.initializeSchema();
@@ -25696,6 +25709,7 @@ const ProsemirrorAdapter = class {
25696
25709
  });
25697
25710
  }
25698
25711
  async updateView(content) {
25712
+ this.suppressChangeEvent = true;
25699
25713
  const html = await this.contentConverter.parseAsHTML(content, this.schema);
25700
25714
  const prosemirrorDOMparser = DOMParser.fromSchema(this.view.state.schema);
25701
25715
  const domParser = new window.DOMParser();
@@ -25704,6 +25718,7 @@ const ProsemirrorAdapter = class {
25704
25718
  const tr = this.view.state.tr;
25705
25719
  tr.replaceWith(0, tr.doc.content.size, prosemirrorDoc.content);
25706
25720
  this.view.dispatch(tr);
25721
+ this.suppressChangeEvent = false;
25707
25722
  }
25708
25723
  dispatchMenuCommand(command) {
25709
25724
  const { state } = this.view;