@37signals/lexxy 0.9.16 → 0.9.17

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 (2) hide show
  1. package/dist/lexxy.esm.js +18 -12
  2. package/package.json +1 -1
package/dist/lexxy.esm.js CHANGED
@@ -7869,9 +7869,7 @@ class LexicalEditorElement extends HTMLElement {
7869
7869
  }
7870
7870
 
7871
7871
  get value() {
7872
- return this.cachedValue ??= this.editor?.read(() => {
7873
- return sanitize($generateHtmlFromNodes(this.editor, null))
7874
- }) ?? null
7872
+ return this.cachedValue ??= this.#readSanitizedEditorValue()
7875
7873
  }
7876
7874
 
7877
7875
  set value(html) {
@@ -7900,6 +7898,12 @@ class LexicalEditorElement extends HTMLElement {
7900
7898
  return this.#historyState.redo
7901
7899
  }
7902
7900
 
7901
+ #readSanitizedEditorValue(editor = this.editor) {
7902
+ return editor?.read(() => {
7903
+ return sanitize($generateHtmlFromNodes(this.editor, null))
7904
+ }) ?? null
7905
+ }
7906
+
7903
7907
  #parseHtmlIntoLexicalNodes(html, { editor = this.editor } = {}) {
7904
7908
  if (!html) html = "<p></p>";
7905
7909
  const nodes = this.$generateNodesFromDOM(parseHtml(`${html}`), { editor });
@@ -7937,7 +7941,6 @@ class LexicalEditorElement extends HTMLElement {
7937
7941
  this.#registerFileAcceptFilter();
7938
7942
  this.#attachDebugHooks();
7939
7943
  this.#attachToolbar();
7940
- this.#configureSanitizer();
7941
7944
  this.#resetBeforeTurboCaches();
7942
7945
  }
7943
7946
 
@@ -7963,7 +7966,11 @@ class LexicalEditorElement extends HTMLElement {
7963
7966
  html: {
7964
7967
  export: new Map([ [ TextNode, exportTextNodeDOM ], [ CodeHighlightNode, exportTextNodeDOM ] ])
7965
7968
  },
7966
- $initialEditorState: (editor) => this.#loadInitialValue(editor)
7969
+ $initialEditorState: (editor) => {
7970
+ this.#configureSanitizer(editor);
7971
+ this.#loadInitialValue(editor);
7972
+ this.#setInternalFormValue(this.#readSanitizedEditorValue(editor));
7973
+ },
7967
7974
  },
7968
7975
  ...this.extensions.lexicalExtensions
7969
7976
  );
@@ -8045,7 +8052,6 @@ class LexicalEditorElement extends HTMLElement {
8045
8052
  const initialHtml = this.valueBeforeDisconnect || this.getAttribute("value") || "<p><br></p>";
8046
8053
 
8047
8054
  this.#initialValue = initialHtml;
8048
- this.#setInternalFormValue(initialHtml);
8049
8055
  this.#setEditorHtml(initialHtml, { editor });
8050
8056
  }
8051
8057
 
@@ -8272,16 +8278,16 @@ class LexicalEditorElement extends HTMLElement {
8272
8278
  this.classList.toggle("lexxy-editor--empty", this.isEmpty);
8273
8279
  }
8274
8280
 
8275
- #configureSanitizer() {
8276
- setSanitizerConfig(this.#allowedElements);
8281
+ #configureSanitizer(editor) {
8282
+ setSanitizerConfig(this.#getAllowedElements(editor));
8277
8283
  }
8278
8284
 
8279
- get #allowedElements() {
8280
- return this.#importableTags.concat(this.extensions.allowedElements)
8285
+ #getAllowedElements(editor) {
8286
+ return this.#getImportableTags(editor).concat(this.extensions.allowedElements)
8281
8287
  }
8282
8288
 
8283
- get #importableTags() {
8284
- const tags = Array.from(this.editor._htmlConversions.keys());
8289
+ #getImportableTags(editor) {
8290
+ const tags = Array.from(editor._htmlConversions.keys());
8285
8291
  return tags.filter(tag => !tag.startsWith("#"))
8286
8292
  }
8287
8293
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@37signals/lexxy",
3
- "version": "0.9.16",
3
+ "version": "0.9.17",
4
4
  "description": "Lexxy - A modern rich text editor for Rails.",
5
5
  "module": "dist/lexxy.esm.js",
6
6
  "type": "module",