@lexical/html 0.44.1-nightly.20260518.0 → 0.45.0

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 (66) hide show
  1. package/{DOMRenderExtension.d.ts → dist/DOMRenderExtension.d.ts} +12 -1
  2. package/dist/DOMRenderRuntime.d.ts +51 -0
  3. package/dist/LexicalHtml.dev.js +3192 -0
  4. package/dist/LexicalHtml.dev.mjs +3146 -0
  5. package/{LexicalHtml.js.flow → dist/LexicalHtml.js.flow} +16 -16
  6. package/dist/LexicalHtml.mjs +56 -0
  7. package/dist/LexicalHtml.node.mjs +54 -0
  8. package/dist/LexicalHtml.prod.js +9 -0
  9. package/dist/LexicalHtml.prod.mjs +9 -0
  10. package/dist/RenderContext.d.ts +68 -0
  11. package/{compileDOMRenderConfigOverrides.d.ts → dist/compileDOMRenderConfigOverrides.d.ts} +1 -1
  12. package/{constants.d.ts → dist/constants.d.ts} +2 -0
  13. package/dist/domOverride.d.ts +23 -0
  14. package/dist/import/CoreImportExtension.d.ts +11 -0
  15. package/dist/import/DOMImportExtension.d.ts +82 -0
  16. package/dist/import/HorizontalRuleImportExtension.d.ts +27 -0
  17. package/dist/import/ImportContext.d.ts +208 -0
  18. package/dist/import/compileImportRules.d.ts +50 -0
  19. package/dist/import/coreImportRules.d.ts +25 -0
  20. package/dist/import/defineImportRule.d.ts +32 -0
  21. package/dist/import/defineOverlayRules.d.ts +66 -0
  22. package/dist/import/index.d.ts +38 -0
  23. package/dist/import/inlineStylesFromStyleSheets.d.ts +28 -0
  24. package/dist/import/parseCss.d.ts +18 -0
  25. package/dist/import/runImport.d.ts +19 -0
  26. package/dist/import/schemas.d.ts +91 -0
  27. package/dist/import/sel.d.ts +74 -0
  28. package/dist/import/types.d.ts +394 -0
  29. package/dist/index.d.ts +44 -0
  30. package/{types.d.ts → dist/types.d.ts} +96 -8
  31. package/package.json +33 -18
  32. package/src/ContextRecord.ts +243 -0
  33. package/src/DOMRenderExtension.ts +96 -0
  34. package/src/DOMRenderRuntime.ts +265 -0
  35. package/src/RenderContext.ts +168 -0
  36. package/src/compileDOMRenderConfigOverrides.ts +416 -0
  37. package/src/constants.ts +18 -0
  38. package/src/domOverride.ts +46 -0
  39. package/src/import/CoreImportExtension.ts +26 -0
  40. package/src/import/DOMImportExtension.ts +221 -0
  41. package/src/import/HorizontalRuleImportExtension.ts +53 -0
  42. package/src/import/ImportContext.ts +339 -0
  43. package/src/import/compileImportRules.ts +178 -0
  44. package/src/import/coreImportRules.ts +485 -0
  45. package/src/import/defineImportRule.ts +40 -0
  46. package/src/import/defineOverlayRules.ts +105 -0
  47. package/src/import/index.ts +96 -0
  48. package/src/import/inlineStylesFromStyleSheets.ts +104 -0
  49. package/src/import/parseCss.ts +219 -0
  50. package/src/import/runImport.ts +245 -0
  51. package/src/import/schemas.ts +236 -0
  52. package/src/import/sel.ts +314 -0
  53. package/src/import/types.ts +471 -0
  54. package/src/index.ts +555 -0
  55. package/src/types.ts +470 -0
  56. package/LexicalHtml.dev.js +0 -914
  57. package/LexicalHtml.dev.mjs +0 -900
  58. package/LexicalHtml.mjs +0 -24
  59. package/LexicalHtml.node.mjs +0 -22
  60. package/LexicalHtml.prod.js +0 -9
  61. package/LexicalHtml.prod.mjs +0 -9
  62. package/RenderContext.d.ts +0 -32
  63. package/domOverride.d.ts +0 -18
  64. package/index.d.ts +0 -32
  65. /package/{ContextRecord.d.ts → dist/ContextRecord.d.ts} +0 -0
  66. /package/{LexicalHtml.js → dist/LexicalHtml.js} +0 -0
@@ -12,7 +12,7 @@ import type {
12
12
  BaseSelection,
13
13
  DOMExportOutput,
14
14
  EditorDOMRenderConfig,
15
- ElementDOMSlot,
15
+ DOMSlotForNode,
16
16
  LexicalEditor,
17
17
  LexicalExtension,
18
18
  LexicalNode,
@@ -23,13 +23,13 @@ import type {
23
23
 
24
24
  type AnyContextSymbol = symbol;
25
25
 
26
- type ContextRecord<K extends symbol> = {+[string | symbol]: unknown};
26
+ type ContextRecord<K extends symbol> = {readonly [string | symbol]: unknown};
27
27
 
28
28
  type ContextConfig<Sym extends symbol, V> = StateConfig<symbol, V>;
29
29
 
30
30
  type ContextConfigUpdater<Ctx extends AnyContextSymbol, V> = {
31
- +cfg: ContextConfig<Ctx, V>,
32
- +updater: (prev: V) => V,
31
+ readonly cfg: ContextConfig<Ctx, V>,
32
+ readonly updater: (prev: V) => V,
33
33
  };
34
34
 
35
35
  type ContextConfigPair<Ctx extends AnyContextSymbol, V> = Readonly<
@@ -74,49 +74,49 @@ export type NodeMatch<T extends LexicalNode> =
74
74
  | ((node: LexicalNode) => boolean);
75
75
 
76
76
  export type DOMRenderMatch<T extends LexicalNode> = {
77
- +nodes: '*' | ReadonlyArray<NodeMatch<T>>,
78
- +$getDOMSlot?: <N extends LexicalNode>(
79
- node: N,
77
+ readonly nodes: '*' | ReadonlyArray<NodeMatch<T>>,
78
+ readonly $getDOMSlot?: (
79
+ node: T,
80
80
  dom: HTMLElement,
81
- $next: () => ElementDOMSlot<HTMLElement>,
81
+ $next: () => DOMSlotForNode<T>,
82
82
  editor: LexicalEditor,
83
- ) => ElementDOMSlot<HTMLElement>,
84
- +$createDOM?: (
83
+ ) => DOMSlotForNode<T>,
84
+ readonly $createDOM?: (
85
85
  node: T,
86
86
  $next: () => HTMLElement,
87
87
  editor: LexicalEditor,
88
88
  ) => HTMLElement,
89
- +$updateDOM?: (
89
+ readonly $updateDOM?: (
90
90
  nextNode: T,
91
91
  prevNode: T,
92
92
  dom: HTMLElement,
93
93
  $next: () => boolean,
94
94
  editor: LexicalEditor,
95
95
  ) => boolean,
96
- +$decorateDOM?: (
96
+ readonly $decorateDOM?: (
97
97
  nextNode: T,
98
98
  prevNode: T | null,
99
99
  dom: HTMLElement,
100
100
  editor: LexicalEditor,
101
101
  ) => void,
102
- +$exportDOM?: (
102
+ readonly $exportDOM?: (
103
103
  node: T,
104
104
  $next: () => DOMExportOutput,
105
105
  editor: LexicalEditor,
106
106
  ) => DOMExportOutput,
107
- +$shouldExclude?: (
107
+ readonly $shouldExclude?: (
108
108
  node: T,
109
109
  selection: null | BaseSelection,
110
110
  $next: () => boolean,
111
111
  editor: LexicalEditor,
112
112
  ) => boolean,
113
- +$shouldInclude?: (
113
+ readonly $shouldInclude?: (
114
114
  node: T,
115
115
  selection: null | BaseSelection,
116
116
  $next: () => boolean,
117
117
  editor: LexicalEditor,
118
118
  ) => boolean,
119
- +$extractWithChild?: (
119
+ readonly $extractWithChild?: (
120
120
  node: T,
121
121
  childNode: LexicalNode,
122
122
  selection: null | BaseSelection,
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as modDev from './LexicalHtml.dev.mjs';
10
+ import * as modProd from './LexicalHtml.prod.mjs';
11
+ const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
+ export const $distributeInlineWrapper = mod.$distributeInlineWrapper;
13
+ export const $generateDOMFromNodes = mod.$generateDOMFromNodes;
14
+ export const $generateDOMFromRoot = mod.$generateDOMFromRoot;
15
+ export const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
16
+ export const $generateNodesFromDOM = mod.$generateNodesFromDOM;
17
+ export const $generateNodesFromDOMViaExtension = mod.$generateNodesFromDOMViaExtension;
18
+ export const $getImportContextValue = mod.$getImportContextValue;
19
+ export const $getRenderContextValue = mod.$getRenderContextValue;
20
+ export const $getSessionDOMRenderConfig = mod.$getSessionDOMRenderConfig;
21
+ export const $inlineStylesFromStyleSheets = mod.$inlineStylesFromStyleSheets;
22
+ export const $isBlockLevel = mod.$isBlockLevel;
23
+ export const $setRenderContextValue = mod.$setRenderContextValue;
24
+ export const $updateRenderContextValue = mod.$updateRenderContextValue;
25
+ export const $withImportContext = mod.$withImportContext;
26
+ export const $withRenderContext = mod.$withRenderContext;
27
+ export const BlockSchema = mod.BlockSchema;
28
+ export const CoreImportExtension = mod.CoreImportExtension;
29
+ export const CoreImportRules = mod.CoreImportRules;
30
+ export const DOMImportExtension = mod.DOMImportExtension;
31
+ export const DOMRenderExtension = mod.DOMRenderExtension;
32
+ export const HorizontalRuleImportExtension = mod.HorizontalRuleImportExtension;
33
+ export const HorizontalRuleImportRules = mod.HorizontalRuleImportRules;
34
+ export const ImportOverlays = mod.ImportOverlays;
35
+ export const ImportSource = mod.ImportSource;
36
+ export const ImportSourceDataTransfer = mod.ImportSourceDataTransfer;
37
+ export const ImportTextFormat = mod.ImportTextFormat;
38
+ export const ImportTextStyle = mod.ImportTextStyle;
39
+ export const ImportWhitespaceConfig = mod.ImportWhitespaceConfig;
40
+ export const InlineSchema = mod.InlineSchema;
41
+ export const NestedBlockSchema = mod.NestedBlockSchema;
42
+ export const RenderContextExport = mod.RenderContextExport;
43
+ export const RenderContextRoot = mod.RenderContextRoot;
44
+ export const RootSchema = mod.RootSchema;
45
+ export const contextUpdater = mod.contextUpdater;
46
+ export const contextValue = mod.contextValue;
47
+ export const createImportState = mod.createImportState;
48
+ export const createRenderState = mod.createRenderState;
49
+ export const defaultIsInline = mod.defaultIsInline;
50
+ export const defaultPreservesWhitespace = mod.defaultPreservesWhitespace;
51
+ export const defineImportRule = mod.defineImportRule;
52
+ export const defineOverlayRules = mod.defineOverlayRules;
53
+ export const domOverride = mod.domOverride;
54
+ export const isElementOfTag = mod.isElementOfTag;
55
+ export const parseSelector = mod.parseSelector;
56
+ export const sel = mod.sel;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalHtml.dev.mjs') : import('./LexicalHtml.prod.mjs'));
10
+ export const $distributeInlineWrapper = mod.$distributeInlineWrapper;
11
+ export const $generateDOMFromNodes = mod.$generateDOMFromNodes;
12
+ export const $generateDOMFromRoot = mod.$generateDOMFromRoot;
13
+ export const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
14
+ export const $generateNodesFromDOM = mod.$generateNodesFromDOM;
15
+ export const $generateNodesFromDOMViaExtension = mod.$generateNodesFromDOMViaExtension;
16
+ export const $getImportContextValue = mod.$getImportContextValue;
17
+ export const $getRenderContextValue = mod.$getRenderContextValue;
18
+ export const $getSessionDOMRenderConfig = mod.$getSessionDOMRenderConfig;
19
+ export const $inlineStylesFromStyleSheets = mod.$inlineStylesFromStyleSheets;
20
+ export const $isBlockLevel = mod.$isBlockLevel;
21
+ export const $setRenderContextValue = mod.$setRenderContextValue;
22
+ export const $updateRenderContextValue = mod.$updateRenderContextValue;
23
+ export const $withImportContext = mod.$withImportContext;
24
+ export const $withRenderContext = mod.$withRenderContext;
25
+ export const BlockSchema = mod.BlockSchema;
26
+ export const CoreImportExtension = mod.CoreImportExtension;
27
+ export const CoreImportRules = mod.CoreImportRules;
28
+ export const DOMImportExtension = mod.DOMImportExtension;
29
+ export const DOMRenderExtension = mod.DOMRenderExtension;
30
+ export const HorizontalRuleImportExtension = mod.HorizontalRuleImportExtension;
31
+ export const HorizontalRuleImportRules = mod.HorizontalRuleImportRules;
32
+ export const ImportOverlays = mod.ImportOverlays;
33
+ export const ImportSource = mod.ImportSource;
34
+ export const ImportSourceDataTransfer = mod.ImportSourceDataTransfer;
35
+ export const ImportTextFormat = mod.ImportTextFormat;
36
+ export const ImportTextStyle = mod.ImportTextStyle;
37
+ export const ImportWhitespaceConfig = mod.ImportWhitespaceConfig;
38
+ export const InlineSchema = mod.InlineSchema;
39
+ export const NestedBlockSchema = mod.NestedBlockSchema;
40
+ export const RenderContextExport = mod.RenderContextExport;
41
+ export const RenderContextRoot = mod.RenderContextRoot;
42
+ export const RootSchema = mod.RootSchema;
43
+ export const contextUpdater = mod.contextUpdater;
44
+ export const contextValue = mod.contextValue;
45
+ export const createImportState = mod.createImportState;
46
+ export const createRenderState = mod.createRenderState;
47
+ export const defaultIsInline = mod.defaultIsInline;
48
+ export const defaultPreservesWhitespace = mod.defaultPreservesWhitespace;
49
+ export const defineImportRule = mod.defineImportRule;
50
+ export const defineOverlayRules = mod.defineOverlayRules;
51
+ export const domOverride = mod.domOverride;
52
+ export const isElementOfTag = mod.isElementOfTag;
53
+ export const parseSelector = mod.parseSelector;
54
+ export const sel = mod.sel;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ "use strict";var e=require("@lexical/selection"),t=require("lexical"),n=require("@lexical/utils"),o=require("@lexical/extension");function r(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let s;function i(e,t){const{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function c(e){return s&&s.editor===e?s:void 0}function l(e,t){const n=c(t);return n&&n[e]}function u(e,t){if("cfg"in t){const{cfg:n,updater:o}=t;return[n,o(i(e,n))]}return t}function a(e,t){let n=t;for(const o of e){const[e,r]=u(n,o),s=e.key;if(n===t&&i(n,e)===r)continue;const c=n===t||void 0===n?f(t):n;c[s]=r,n=c}return n}function f(e){return Object.create(e||null)}function d(e,t){return[e,t]}function p(e,n,o,r=t.$getEditor()){const i=s,l=c(r);try{return s={...l,editor:r,[e]:n},o()}finally{s=i}}function h(e,n=()=>{}){return(o,r=t.$getEditor())=>t=>{const s=c(r),i=s&&s[e],l=a(o,i||n(r));return l&&l!==i?p(e,l,t,r):t()}}function m(e,n,o,r){return Object.assign(t.createState(Symbol(n),{isEqual:r,parse:o}),{[e]:!0})}const g=(e,t,n)=>{x(e),n()};function x(e){if(!t.isDOMDocumentNode(e))return;const o=e;if(null===o.querySelector("style"))return;const r=new Map;function s(e){let t=r.get(e);if(void 0===t){t=new Set;for(let n=0;n<e.style.length;n++)t.add(e.style[n]);r.set(e,t)}return t}try{for(const e of Array.from(o.styleSheets)){let r;try{r=e.cssRules}catch(e){continue}for(const e of Array.from(r)){if(!n.objectKlassEquals(e,CSSStyleRule))continue;let r;try{r=o.querySelectorAll(e.selectorText)}catch(e){continue}for(const n of Array.from(r)){if(!t.isHTMLElement(n))continue;const o=s(n);for(let t=0;t<e.style.length;t++){const r=e.style[t];o.has(r)||n.style.setProperty(r,e.style.getPropertyValue(r),e.style.getPropertyPriority(r))}}}}}catch(e){}}const y="@lexical/html/DOM",$=Symbol.for("@lexical/html/DOMExportContext"),S="@lexical/html/DOMImport",E=Symbol.for("@lexical/html/DOMImportContext"),D=()=>!0;function C(e,t,n){return m($,e,t,n)}const I=C("root",Boolean),N=C("isExport",Boolean);function O(e){const t=o.getPeerDependencyFromEditor(e,y);return t?t.output.defaults:void 0}function v(e){const t=o.getPeerDependencyFromEditor(e,y);return t?t.output.runtime:void 0}function M(e=t.$getEditor()){const n=v(e);return n?n.getSessionConfig():t.$getEditorDOMRenderConfig(e)}const R=h($,O);function T(e){return t=>t instanceof e}function b(e,{nodes:t}){if("*"===t)return D;let n={};const o=[];for(const s of t)if("getType"in s){const t=s.getType();if(n){const o=e[t];void 0===o&&r(339,s.name,t),n=Object.assign(n,o.types)}o.push(T(s))}else n=void 0,o.push(s);return n||(1===o.length?o[0]:e=>{for(const t of o)if(t(e))return!0;return!1})}function k(e){return(t,n,o)=>e(t,o)}function w(e){return(t,n,o,r)=>e(t,n,r)}function L(e){return(t,n,o,r,s)=>e(t,n,o,s)}function A(e){return(t,n,o,r,s,i)=>e(t,n,o,r,i)}function _(e,t){return(n,o)=>{const r=()=>e(n,o),s=t(n);return s?s(n,r,o):r()}}function F(e,t){return(n,o,r)=>{const s=()=>e(n,o,r),i=t(n);return i?i(n,o,s,r):s()}}const P=F,H=w;function W(e,t){return(n,o,r,s)=>{const i=()=>e(n,o,r,s),c=t(n);return c?c(n,o,r,i,s):i()}}function B(e,t){return(n,o,r,s,i)=>{const c=()=>e(n,o,r,s,i),l=t(n);return l?l(n,o,r,s,c,i):c()}}function U(e,t){return(n,o,r,s)=>{e(n,o,r,s);const i=t(n);i&&i(n,o,r,s)}}function j(e,t,n,o,r){let s=n[t];for(const n of e[t])if("function"==typeof n[0]){const[e,t]=n;s=o(s,n=>e(n)&&t||void 0)}else{const e=n[1],t={};for(const n in e){const r=e[n];r&&(t[n]=r.reduce((e,t)=>o(e,()=>t),s))}s=o(s,e=>{const n=t[e.getType()];return n&&r(n)})}n[t]=s}function z(e,t,n,o){if(!o)return;const r=e[t];if("function"==typeof n)r.push([n,o]);else{const e=r[r.length-1];let t;e&&"types"===e[0]?t=e[1]:(t={},r.push(["types",t]));for(const e in n){const n=t[e]||[];t[e]=n,n.push(o)}}}function V(e){return"*"===e.nodes}function G(e,n){const r=function(e){const n={},{nodes:r}=o.getKnownTypesAndNodes(e);for(const e of r)n[e.getType()]={klass:e,types:{}};for(const e of Object.values(n))if(e){const o=e.klass.getType();for(let{klass:r}=e;t.$isLexicalNode(r.prototype);r=Object.getPrototypeOf(r)){const{ownNodeType:e}=t.getStaticNodeConfig(r),s=e&&n[e];s&&(s.types[o]=!0)}}return n}(e),s={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const e of function(e){const n=[],o=[],r=[];for(const s of e)if(V(s))n.push(s);else if(Array.isArray(s.nodes))for(const e of s.nodes)t.$isLexicalNode(e.prototype)?r.push(1===s.nodes.length?s:{...s,nodes:[e]}):o.push(1===s.nodes.length?s:{...s,nodes:[e]});const s=new Map,i=e=>{let n=s.get(e);if(void 0===n){n=0;for(let o=e;t.$isLexicalNode(o.prototype);o=Object.getPrototypeOf(o))n++;s.set(e,n)}return n};return r.sort((e,t)=>i(e.nodes[0])-i(t.nodes[0])),[...r,...o,...n]}(n)){const t=b(r,e);for(const n in s){z(s,n,t,e[n])}}return s}function q(e){return e}function K(e,{overrides:n}){const o=G(e,n),r={...t.DEFAULT_EDITOR_DOM_CONFIG,...e.dom};return j(o,"$createDOM",r,_,k),j(o,"$exportDOM",r,_,k),j(o,"$extractWithChild",r,B,A),j(o,"$getDOMSlot",r,P,H),j(o,"$shouldExclude",r,F,w),j(o,"$shouldInclude",r,F,w),j(o,"$updateDOM",r,W,L),j(o,"$decorateDOM",r,U,q),r}function J(e){return{get:t=>i(e,t)}}function Q(e){const t=Object.create(null);return a(e,t)||t}function Y(e,t){const n=J(t);return e.filter(e=>!(e.disabledForEditor&&e.disabledForEditor(n)))}function Z(e){if("*"===e.nodes)return()=>!0;const n=e.nodes.map(e=>{const n=e;return t.$isLexicalNode(n.prototype)?e=>e instanceof n:e});return e=>n.some(t=>t(e))}class X{editor;initialEditorConfig;overrides;editorContext;hasSessionGates;installed;sessionCache=new Map;constructor(e,t,n,o){this.editor=e,this.initialEditorConfig=t,this.overrides=n,this.editorContext=o,this.installed=Y(n,o),this.hasSessionGates=n.some(e=>e.disabledForSession)}setContextValue(e,n){const o=this.installed;this.editorContext[e.key]=n;const r=Y(this.overrides,this.editorContext);if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(o,r))return;const s=function(e,t){const n=new Set(e),o=new Set(t),r=[];for(const t of e)o.has(t)||r.push(t);for(const e of t)n.has(e)||r.push(e);return r}(o,r);this.installed=r,this.sessionCache.clear();const i=K(this.initialEditorConfig,{overrides:r});this.editor._config.dom=i;const c=function(e){const t=[];for(const n of e)(n.$createDOM||n.$getDOMSlot||n.$decorateDOM)&&t.push(Z(n));return 0===t.length?null:e=>t.some(t=>t(e))}(s);if(!c)return;const l=i.$updateDOM;i.$updateDOM=(e,t,n,o)=>!!c(e)||l(e,t,n,o),this.editor.update(t.$fullReconcile,{discrete:!0}),i.$updateDOM=l}getSessionConfig(){const e=this.editor._config.dom||t.DEFAULT_EDITOR_DOM_CONFIG;if(!this.hasSessionGates)return e;const n=J(l($,this.editor)||this.editorContext),o=[],r=[];if(this.installed.forEach((e,t)=>{e.disabledForSession&&e.disabledForSession(n)?o.push(String(t)):r.push(e)}),0===o.length)return e;const s=o.join(",");let i=this.sessionCache.get(s);return i||(i=K(this.initialEditorConfig,{overrides:r}),this.sessionCache.set(s,i)),i}}const ee=t.defineExtension({build(e,t,n){const{initialEditorConfig:o}=n.getInitResult(),r=Q(t.contextDefaults);return{defaults:r,runtime:new X(e,o,t.overrides,r)}},config:{contextDefaults:[],overrides:[]},html:{export:new Map([[t.RootNode,()=>{const e=document.createElement("div");return e.role="textbox",{element:e}}]])},init(e,t){const n={dom:e.dom,nodes:e.nodes},o=Q(t.contextDefaults),r=Y(t.overrides,o);return e.dom=K(e,{overrides:r}),{initialEditorConfig:n}},mergeConfig(e,n){const o=t.shallowMergeConfig(e,n);for(const t of["overrides","contextDefaults"])n[t]&&(o[t]=[...e[t],...n[t]]);return o},name:y}),te=Symbol.for("@lexical/html/SelectorImpl");function ne(e,n){const o={kind:"element",predicate:(s=n,0===s.length?t.isHTMLElement:1===s.length?s[0]:(e,t)=>{for(const n of s)if(!n(e,t))return!1;return!0}),tags:e};var s;const i=t=>ne(e,[...n,t]);return{[te]:o,attr:(e,t,n)=>i(se(e,t,n)),classAll:(...e)=>i(re(e)),classAny:(...e)=>i(function(e){const n=oe(e);if(0===n.length)return()=>!1;return e=>{if(!t.isHTMLElement(e))return!1;const o=e.classList;for(const e of n)if(o.contains(e))return!0;return!1}}(e)),styleAny:(e,n,o)=>i(function(e,n,o){if("string"==typeof n)return o=>t.isHTMLElement(o)&&o.style.getPropertyValue(e)===n;if(n instanceof RegExp){const r=o&&o.capture,s=n;return(n,o)=>{if(!t.isHTMLElement(n))return!1;const i=n.style.getPropertyValue(e);if(!i)return!1;const c=i.match(s);return null!==c&&(void 0!==r&&(o[r]=c),!0)}}r(362,JSON.stringify(e))}(e,n,o))}}function oe(e){const t=[];for(const n of e)n&&t.push(n);return t}function re(e){const n=oe(e);return 0===n.length?()=>!0:e=>{if(!t.isHTMLElement(e))return!1;const o=e.classList;for(const e of n)if(!o.contains(e))return!1;return!0}}function se(e,n,o){if(!0===n)return n=>t.isHTMLElement(n)&&n.hasAttribute(e);if("string"==typeof n)return o=>t.isHTMLElement(o)&&o.getAttribute(e)===n;if(n instanceof RegExp){const r=o&&o.capture,s=n;return(n,o)=>{if(!t.isHTMLElement(n))return!1;const i=n.getAttribute(e);if(null==i)return!1;const c=i.match(s);return null!==c&&(void 0!==r&&(o[r]=c),!0)}}r(361,JSON.stringify(e))}const ie={kind:"text",predicate:t.isDOMTextNode,tags:new Set},ce={[te]:ie},le={kind:"comment",predicate:e=>8===e.nodeType,tags:new Set},ue={[te]:le},ae={any:()=>ne(new Set,[]),comment:()=>ue,tag(...e){e.length>0||r(363);const t=new Set;for(const n of e)t.add(n.toUpperCase());return ne(t,[])},text:()=>ce};const fe=/[A-Za-z0-9_-]/;class de{constructor(e,t){this.source=e,this.pos=t}peek(e=0){return this.source[this.pos+e]||""}consume(){return this.source[this.pos++]||""}eof(){return this.pos>=this.source.length}skipWhitespace(){for(;!this.eof()&&/\s/.test(this.peek());)this.pos++}readIdent(){const e=this.pos;for(;!this.eof()&&fe.test(this.peek());)this.pos++;return this.source.slice(e,this.pos)}readQuoted(){const e=this.consume();this.assert('"'===e||"'"===e,"expected quote");const t=this.pos;for(;!this.eof()&&this.peek()!==e;)"\\"===this.peek()?this.pos+=2:this.pos++;this.assert(!this.eof(),"unterminated string");const n=this.source.slice(t,this.pos);return this.pos++,n.replace(/\\(.)/g,"$1")}assert(e,t){e||r(364,String(this.pos+1),t,this.source)}}function pe(e){const t=new Set,n=[],o=[];if(e.skipWhitespace(),"*"===e.peek())e.consume();else if(fe.test(e.peek())){const n=e.readIdent();n&&t.add(n.toUpperCase())}for(;!e.eof();){const t=e.peek();if("."===t){e.consume();const t=e.readIdent();e.assert(""!==t,'expected class name after "."'),o.push(t)}else if("#"===t){e.consume();const t=e.readIdent();e.assert(""!==t,'expected id after "#"'),n.push(se("id",t))}else{if("["!==t)break;{e.consume(),e.skipWhitespace();const t=e.readIdent();e.assert(""!==t,'expected attribute name after "["'),e.skipWhitespace();let o=!0;if("="===e.peek()){e.consume(),e.skipWhitespace();const t=e.peek();'"'===t||"'"===t?o=e.readQuoted():(o=e.readIdent(),e.assert(""!==o,"expected attribute value")),e.skipWhitespace()}e.assert("]"===e.peek(),'expected "]"'),e.consume(),n.push(se(t,o))}}}return o.length>0&&n.push(re(o)),{predicates:n,tags:t}}function he(e){const t=new de(e,0),n=[];for(;;){const e=pe(t);if(n.push(e),t.skipWhitespace(),t.eof())break;t.assert(","===t.peek(),'expected "," (selector lists are the only supported combinator)'),t.consume(),t.skipWhitespace()}if(1===n.length)return ne(n[0].tags,n[0].predicates);const o=new Set;for(const e of n)for(const t of e.tags)o.add(t);return ne(o,[(e,t)=>{for(const o of n){const n=e.nodeName;if(o.tags.size>0&&!o.tags.has(n))continue;let r=!0;for(const n of o.predicates)if(!n(e,t)){r=!1;break}if(r)return!0}return!1}])}function me(e){return e}function ge(e,t,n){return m(E,e,t,n)}const xe=ge("importSource",()=>"unknown"),ye=ge("importSourceDataTransfer",()=>null),$e=ge("textFormat",()=>0),Se=ge("textStyle",()=>({}));function Ee(e){if(!t.isHTMLElement(e))return!1;if("PRE"===e.nodeName)return!0;const n=e.style.whiteSpace;return"string"==typeof n&&n.startsWith("pre")}function De(e){if(t.isDOMTextNode(e))return!0;if(!t.isHTMLElement(e))return!1;const n=e.style.display;return n?n.startsWith("inline"):!t.isBlockDomNode(e)&&t.isInlineDomNode(e)}const Ce=ge("whitespaceConfig",()=>({isInline:De,preservesWhitespace:Ee})),Ie=ge("importOverlays",()=>[]);class Ne{constructor(e){this.record=e}get(e){return i(this.record,e)}set(e,t){this.record[e.key]=t}update(e,t){this.record[e.key]=t(i(this.record,e))}has(e){return Object.prototype.hasOwnProperty.call(this.record,e.key)}}function Oe(e){const t=o.getPeerDependencyFromEditor(e,S);return t?t.output.defaults:void 0}function ve(e,n=t.$getEditor()){return i(function(e){return l(E,e)||Oe(e)}(n),e)}const Me=h(E,Oe),Re=ae,Te=new Set(["center","end","justify","left","right","start"]);function be(e){return Te.has(e)}const ke={B:{fontWeight:"bold"},EM:{fontStyle:"italic"},I:{fontStyle:"italic"},S:{textDecoration:"line-through"},STRONG:{fontWeight:"bold"},SUB:{verticalAlign:"sub"},SUP:{verticalAlign:"super"},U:{textDecoration:"underline"}},we={CODE:t.IS_CODE,MARK:t.IS_HIGHLIGHT};const Le=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Ae={$import:(e,n)=>{const o=e.get($e),r=ke[n.nodeName],s=function(e){return{fontStyle:e.style.fontStyle,fontWeight:e.style.fontWeight,textDecoration:e.style.textDecoration,verticalAlign:e.style.verticalAlign}}(n),i=r?(c=r,{fontStyle:(l=s).fontStyle||c.fontStyle,fontWeight:l.fontWeight||c.fontWeight,textDecoration:l.textDecoration||c.textDecoration,verticalAlign:l.verticalAlign||c.verticalAlign}):s;var c,l;let u=(a=o,f=function(e){let n=0,o=0;const{fontWeight:r,fontStyle:s,textDecoration:i,verticalAlign:c}=e;if("700"===r||"bold"===r?n|=t.IS_BOLD:"normal"!==r&&"400"!==r||(o|=t.IS_BOLD),"italic"===s?n|=t.IS_ITALIC:"normal"===s&&(o|=t.IS_ITALIC),i){const e=i.split(" ");e.includes("underline")&&(n|=t.IS_UNDERLINE),e.includes("line-through")&&(n|=t.IS_STRIKETHROUGH),e.includes("none")&&(o|=t.IS_UNDERLINE|t.IS_STRIKETHROUGH)}return"sub"===c?(n|=t.IS_SUBSCRIPT,o|=t.IS_SUPERSCRIPT):"super"===c?(n|=t.IS_SUPERSCRIPT,o|=t.IS_SUBSCRIPT):"baseline"===c&&(o|=t.IS_SUBSCRIPT|t.IS_SUPERSCRIPT),{clear:o,set:n}}(i),a&~f.clear|f.set);var a,f;const p=we[n.nodeName];return p&&(u|=p),u===o?e.$importChildren(n):e.$importChildren(n,{context:[d($e,u)]})},match:Re.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"};function _e(e,n,o){let r=e;for(;;){let e=null;for(;null===(e=n?r.nextSibling:r.previousSibling);){const e=r.parentNode;if(null===e)return null;r=e}if(r=e,!o.isInline(r))return null;let s=r;for(;null!==(s=n?r.firstChild:r.lastChild);)r=s;if(t.isDOMTextNode(r))return r;if("BR"===r.nodeName)return null}}function Fe(e,n){return 0!==n&&t.$isTextNode(e)?e.setFormat(n):e}function Pe(e,n){if(t.$isTextNode(e)){const t=function(e){let t="";for(const n in e)Le.has(n)||(t+=`${n}: ${e[n]}; `);return t.trimEnd()}(n);""!==t&&e.setStyle(t)}return e}const He={$import:(e,n)=>{const o=e.get($e),r=e.get(Se),s=e.get(Ce);if(function(e,t){let n=e.parentNode;for(;null!==n;){if(t.preservesWhitespace(n))return!0;n=n.parentNode}return!1}(n,s)){const e=t.$generateNodesFromRawText(n.textContent||"");for(const t of e)Fe(t,o),Pe(t,r);return e}const i=function(e,t){let n=(e.textContent||"").replace(/\r/g,"").replace(/[ \t\n]+/g," ");if(0===n.length)return"";if(" "===n[0]){let o=e,r=!0;for(;null!==o&&null!==(o=_e(o,!1,t));){const e=o.textContent||"";if(e.length>0){/[ \t\n]$/.test(e)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n.length>0&&" "===n[n.length-1]){let o=e,r=!0;for(;null!==o&&null!==(o=_e(o,!0,t));)if((o.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){r=!1;break}r&&(n=n.slice(0,-1))}return n}(n,s);if(""===i)return[];const c=t.$createTextNode(i);return Fe(c,o),Pe(c,r),[c]},match:Re.text(),name:"@lexical/html/#text"},We={$import:()=>[],match:Re.tag("script","style"),name:"@lexical/html/script-style-ignore"},Be={$import:()=>[t.$createLineBreakNode()],match:Re.tag("br"),name:"@lexical/html/br"},Ue=[We,{$import:(e,n)=>{const o=t.$createParagraphNode();if(t.$setFormatFromDOM(o,n),t.setNodeIndentFromDOM(n,o),""===o.getFormatType()){const e=n.getAttribute("align");e&&be(e)&&o.setFormat(e)}return t.$setDirectionFromDOM(o,n),[o.splice(0,0,e.$importChildren(n))]},match:Re.tag("p"),name:"@lexical/html/p"},He,Be,Ae];function je(e,t){const n=[];let o=0,r=0;for(;o<e.length&&r<t.length;)e[o]<=t[r]?n.push(e[o++]):n.push(t[r++]);for(;o<e.length;)n.push(e[o++]);for(;r<t.length;)n.push(t[r++]);return n}function ze(e){const t=[],n=new Map,o=[],s=[],i=[],c=new Set;e.forEach((e,l)=>{const u=function(e){const t=e[te];return void 0===t&&r(360),t}(e.match),a=e.name||function(e,t){if("text"===e.kind)return`#text@${t}`;if("comment"===e.kind)return`#comment@${t}`;if(0===e.tags.size)return`*@${t}`;const n=Array.from(e.tags).join(",").toLowerCase();return`${n}@${t}`}(u,l);if(e.name&&c.add(e.name),t.push({$import:e.$import,name:a,predicate:u.predicate}),"text"===u.kind)s.push(l);else if("comment"===u.kind)i.push(l);else if(0===u.tags.size)o.push(l);else for(const e of u.tags){let t=n.get(e);t||(t=[],n.set(e,t)),t.push(l)}});const l=new Map;if(0===o.length)for(const[e,t]of n)l.set(e,t);else for(const[e,t]of n)l.set(e,je(t,o));return{byTag:l,commentIndices:i,rules:t,textIndices:s,wildcardIndices:o}}function Ve(e,n){return t.isDOMTextNode(n)?e.textIndices:8===n.nodeType?e.commentIndices:t.isHTMLElement(n)?e.byTag.get(n.nodeName)||e.wildcardIndices:Ge}const Ge=Object.freeze([]);function qe(e){const t=[];for(const n of e)if(Ke(n))for(const e of n.rules)t.push(e);else t.push(n);return t}function Ke(e){return"object"==typeof e&&null!==e&&"__type"in e&&"CompiledOverlayRules"===e.__type}function Je(e){return t.$isBlockElementNode(e)||t.$isDecoratorNode(e)&&!e.isInline()}function Qe(e,n,o){const r=t.$createParagraphNode();if(t.isHTMLElement(o)){const e=o.style.textAlign;be(e)&&r.setFormat(e)}return[r.splice(0,0,e)]}const Ye={$accepts:Je,$packageRun:Qe,name:"BlockSchema"},Ze={$accepts:e=>!Je(e),name:"InlineSchema"},Xe={$accepts:Je,$packageRun:e=>e,name:"NestedBlockSchema"},et={$accepts:Je,$packageRun:Qe,name:"RootSchema"},tt=Object.freeze({});function nt(e,t){const n={$importChildren:(t,n)=>function(e,t,n){const o=n&&n.rules?n.rules.dispatch:void 0;o&&e.overlays.push(o);try{const o=()=>ot(e,t,n);return n&&n.context?Me(n.context,e.editor)(o):o()}finally{o&&e.overlays.pop()}}(e,t,n),$importOne:(t,n)=>rt(e,t,n),captures:t,get:t=>ve(t,e.editor),session:e.session};return n}function ot(e,t,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(t.childNodes)){const t=rt(e,n,void 0);for(const e of t){const t=o?o(e):e;null!=t&&r.push(t)}}const s=n&&n.$after?n.$after(r):r,i=n&&n.schema;return i?function(e,t,n,o){const r=[];let s=null;const i=()=>{if(null===s)return;const t=s;if(s=null,e.$packageRun){const s=e.$packageRun(t,n,o);if(s.length>0){for(const e of s)r.push(e);return}}if("hoist"===e.onReject)for(const e of t)r.push(e)};for(const o of t)e.$accepts(o,n)?(i(),r.push(o)):(null===s&&(s=[]),s.push(o));return i(),e.$finalize?e.$finalize(r,n):r}(i,s,null,t):s}function rt(e,t,n){const o=()=>function(e,t){const n=function(e,t){const n=[];for(let o=e.overlays.length-1;o>=0;o--){const r=e.overlays[o],s=Ve(r,t);s.length>0&&n.push({dispatch:r,indices:s})}const o=Ve(e.dispatch,t);o.length>0&&n.push({dispatch:e.dispatch,indices:o});return n}(e,t);if(0===n.length)return st(e,t);let o=0,r=0;const s=()=>{for(;o<n.length;){const{dispatch:i,indices:c}=n[o];for(;r<c.length;){const n=c[r++],o=i.rules[n],l={};if(o.predicate(t,l)){const n=nt(e,0===Object.keys(l).length?tt:l);try{return o.$import(n,t,s)}catch(e){throw e}}}o++,r=0}return st(e,t)};return s()}(e,t);return n&&n.context?Me(n.context,e.editor)(o):o()}function st(e,t){if(0===t.childNodes.length)return[];const n=[];for(const o of Array.from(t.childNodes)){const t=rt(e,o,void 0);for(const e of t)n.push(e)}return n}const it={$import:(e,t)=>e.$importChildren(t),match:ae.any(),name:"@lexical/html/default-hoist"},ct=t.defineExtension({build(e,n){const o=ze(qe(n.rules)),r=a(n.contextDefaults,void 0),s=n.preprocess;return{$generateNodesFromDOM:(n,i)=>{const c=i&&i.context?a(i.context,r):r,l=void 0!==c&&c!==r?c:Object.create(r||null),u=new Ne(l),f={session:u};return function(e,t,n){let o=e.length-1;const r=()=>{for(;o>=0;)return void(0,e[o--])(t,n,r)};r()}(i&&i.preprocess?[...s,...i.preprocess]:s,n,f),p(E,l,()=>function(e,n,o,r){return ot({dispatch:e,editor:n,overlays:r.get(Ie).map(e=>e.dispatch),session:r},t.isDOMDocumentNode(o)?o.body:o,{schema:et})}(o,e,n,u),e)},defaults:r}},config:{contextDefaults:[],preprocess:[g],rules:[it]},mergeConfig:(e,n)=>t.shallowMergeConfig(e,{...n,...n.contextDefaults&&{contextDefaults:[...e.contextDefaults,...n.contextDefaults]},...n.preprocess&&{preprocess:[...e.preprocess,...n.preprocess]},...n.rules&&{rules:[...n.rules,...e.rules]}}),name:S});const lt=t.defineExtension({dependencies:[t.configExtension(ct,{rules:Ue})],name:"@lexical/html/CoreImport"}),ut=[{$import:()=>[o.$createHorizontalRuleNode()],match:ae.tag("hr"),name:"@lexical/html/hr"}],at=t.defineExtension({dependencies:[lt,o.HorizontalRuleExtension,t.configExtension(ct,{rules:ut})],name:"@lexical/html/HorizontalRuleImport"}),ft={any:ae.any,comment:ae.comment,css:he,tag:ae.tag,text:ae.text},dt=new Set(["STYLE","SCRIPT"]);function pt(e,n=null,o=t.$getEditor()){return R([d(N,!0)],o)(()=>{const r=t.$getRoot(),s=M(o),i=e.append.bind(e);for(const e of r.getChildren())ht(o,e,i,n,s);return e})}function ht(n,o,r,s=null,i=t.$getEditorDOMRenderConfig(n)){let c=i.$shouldInclude(o,s,n);const l=i.$shouldExclude(o,s,n);let u=o;null!==s&&t.$isTextNode(o)&&(u=e.$sliceSelectedTextNodeContent(s,o,"clone"));const a=i.$exportDOM(u,n),{element:f,after:d,append:p,$getChildNodes:h}=a;if(!f)return!1;const m=document.createDocumentFragment(),g=h?h():t.$isElementNode(u)?u.getChildren():[],x=m.append.bind(m);for(const e of g){const t=ht(n,e,x,s,i);!c&&t&&i.$extractWithChild(o,e,s,"html",n)&&(c=!0)}if(c&&!l){if((t.isHTMLElement(f)||t.isDocumentFragment(f))&&(p?p(m):f.append(m)),r(f),d){const e=d.call(u,f);e&&(t.isDocumentFragment(f)?f.replaceChildren(e):f.replaceWith(e))}}else r(m);return c}function mt(e,n,o,r,s=new Map,i){const c=[];if(dt.has(e.nodeName))return c;let l=null;const u=function(e,t){const{nodeName:n}=e,o=t._htmlConversions.get(n.toLowerCase());let r=null;if(void 0!==o)for(const t of o){const n=t(e);null!==n&&(null===r||(r.priority||0)<=(n.priority||0))&&(r=n)}return null!==r?r.conversion:null}(e,n),a=u?u(e):null;let f=null;if(null!==a){f=a.after;const t=a.node;if(l=Array.isArray(t)?t[t.length-1]:t,null!==l){for(const[,e]of s)if(l=e(l,i),!l)break;l&&c.push(...Array.isArray(t)?t:[l])}null!=a.forChild&&s.set(e.nodeName,a.forChild)}const d=e.childNodes;let p=[];const h=(null==l||!t.$isRootOrShadowRoot(l))&&(null!=l&&t.$isBlockElementNode(l)||r);for(let e=0;e<d.length;e++)p.push(...mt(d[e],n,o,h,new Map(s),l));if(null!=f&&(p=f(p)),t.isBlockDomNode(e)&&(p=gt(e,p,h?()=>{const e=new t.ArtificialNode__DO_NOT_USE;return o.push(e),e}:t.$createParagraphNode)),null==l)if(p.length>0)for(const e of p)c.push(e);else t.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return!1;return t.isInlineDomNode(e.nextSibling)&&t.isInlineDomNode(e.previousSibling)}(e)&&c.push(t.$createLineBreakNode());else t.$isElementNode(l)&&l.append(...p);return c}function gt(e,n,o){const r=e.style.textAlign,s=[];let i=[];for(let e=0;e<n.length;e++){const c=n[e];if(t.$isBlockElementNode(c))r&&!c.getFormat()&&c.setFormat(r),s.push(c);else if(i.push(c),e===n.length-1||e<n.length-1&&t.$isBlockElementNode(n[e+1])){const e=o();e.setFormat(r),e.append(...i),s.push(e),i=[]}}return s}exports.$distributeInlineWrapper=function e(n,o){const r=[];let s=[];const i=()=>{0!==s.length&&(r.push(o().splice(0,0,s)),s=[])};for(const c of n)if(Je(c)){if(i(),t.$isElementNode(c)){const t=e(c.getChildren(),o);c.splice(0,c.getChildrenSize(),t)}r.push(c)}else s.push(c);return i(),r},exports.$generateDOMFromNodes=pt,exports.$generateDOMFromRoot=function(e,n=t.$getRoot()){const o=t.$getEditor();return R([d(N,!0),d(I,!0)],o)(()=>{const t=M(o),r=e.append.bind(e);return ht(o,n,r,null,t),e})},exports.$generateHtmlFromNodes=function(e,t=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&r(338),pt(document.createElement("div"),t,e).innerHTML},exports.$generateNodesFromDOM=function(e,n){x(n);const o=t.isDOMDocumentNode(n)?n.body.childNodes:n.childNodes,r=[],s=[];for(const t of o)if(!dt.has(t.nodeName)){const n=mt(t,e,s,!1);if(null!==n)for(const e of n)r.push(e)}return function(e){for(const n of e)n.getParent()&&n.getNextSibling()instanceof t.ArtificialNode__DO_NOT_USE&&n.insertAfter(t.$createLineBreakNode());for(const t of e){const e=t.getParent();e&&e.splice(t.getIndexWithinParent(),1,t.getChildren())}}(s),r},exports.$generateNodesFromDOMViaExtension=function(e,t){return o.$getExtensionOutput(ct).$generateNodesFromDOM(e,t)},exports.$getImportContextValue=ve,exports.$getRenderContextValue=function(e,n=t.$getEditor()){return i(function(e){return l($,e)||O(e)}(n),e)},exports.$getSessionDOMRenderConfig=M,exports.$inlineStylesFromStyleSheets=g,exports.$isBlockLevel=Je,exports.$setRenderContextValue=function(e,n,o=t.$getEditor()){const r=v(o);r&&r.setContextValue(e,n)},exports.$updateRenderContextValue=function(e,n,o=t.$getEditor()){const r=v(o);r&&r.setContextValue(e,n(i(r.editorContext,e)))},exports.$withImportContext=Me,exports.$withRenderContext=R,exports.BlockSchema=Ye,exports.CoreImportExtension=lt,exports.CoreImportRules=Ue,exports.DOMImportExtension=ct,exports.DOMRenderExtension=ee,exports.HorizontalRuleImportExtension=at,exports.HorizontalRuleImportRules=ut,exports.ImportOverlays=Ie,exports.ImportSource=xe,exports.ImportSourceDataTransfer=ye,exports.ImportTextFormat=$e,exports.ImportTextStyle=Se,exports.ImportWhitespaceConfig=Ce,exports.InlineSchema=Ze,exports.NestedBlockSchema=Xe,exports.RenderContextExport=N,exports.RenderContextRoot=I,exports.RootSchema=et,exports.contextUpdater=function(e,t){return{cfg:e,updater:t}},exports.contextValue=d,exports.createImportState=ge,exports.createRenderState=C,exports.defaultIsInline=De,exports.defaultPreservesWhitespace=Ee,exports.defineImportRule=me,exports.defineOverlayRules=function(e){const t=qe(e);return{__type:"CompiledOverlayRules",dispatch:ze(t),rules:t}},exports.domOverride=function(e,t,n){return{...t,...n,nodes:e}},exports.isElementOfTag=function(e,n){return t.isHTMLElement(e)&&e.nodeName===n.toUpperCase()},exports.parseSelector=he,exports.sel=ft;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import{$sliceSelectedTextNodeContent as t}from"@lexical/selection";import{$getEditor as e,createState as n,isDOMDocumentNode as o,isHTMLElement as r,$getEditorDOMRenderConfig as s,DEFAULT_EDITOR_DOM_CONFIG as i,$isLexicalNode as c,getStaticNodeConfig as l,$fullReconcile as u,defineExtension as f,shallowMergeConfig as a,RootNode as p,isDOMTextNode as d,isBlockDomNode as h,isInlineDomNode as g,IS_HIGHLIGHT as m,IS_CODE as y,$generateNodesFromRawText as x,$createTextNode as S,$createLineBreakNode as $,$createParagraphNode as v,$setFormatFromDOM as b,setNodeIndentFromDOM as C,$setDirectionFromDOM as k,$isTextNode as O,IS_BOLD as w,IS_ITALIC as D,IS_UNDERLINE as M,IS_STRIKETHROUGH as A,IS_SUBSCRIPT as N,IS_SUPERSCRIPT as I,$isElementNode as E,$isBlockElementNode as W,$isDecoratorNode as R,configExtension as j,$getRoot as T,isDocumentFragment as F,$isRootOrShadowRoot as P,ArtificialNode__DO_NOT_USE as z}from"lexical";import{objectKlassEquals as _}from"@lexical/utils";import{getPeerDependencyFromEditor as L,getKnownTypesAndNodes as U,$getExtensionOutput as B,HorizontalRuleExtension as V,$createHorizontalRuleNode as q}from"@lexical/extension";function G(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let H;function J(t,e){const{key:n}=e;return t&&n in t?t[n]:e.defaultValue}function Q(t){return H&&H.editor===t?H:void 0}function K(t,e){const n=Q(e);return n&&n[t]}function Y(t,e){if("cfg"in e){const{cfg:n,updater:o}=e;return[n,o(J(t,n))]}return e}function Z(t,e){let n=e;for(const o of t){const[t,r]=Y(n,o),s=t.key;if(n===e&&J(n,t)===r)continue;const i=n===e||void 0===n?X(e):n;i[s]=r,n=i}return n}function X(t){return Object.create(t||null)}function tt(t,e){return[t,e]}function et(t,e){return{cfg:t,updater:e}}function nt(t,n,o,r=e()){const s=H,i=Q(r);try{return H={...i,editor:r,[t]:n},o()}finally{H=s}}function ot(t,n=()=>{}){return(o,r=e())=>e=>{const s=Q(r),i=s&&s[t],c=Z(o,i||n(r));return c&&c!==i?nt(t,c,e,r):e()}}function rt(t,e,o,r){return Object.assign(n(Symbol(e),{isEqual:r,parse:o}),{[t]:!0})}const st=(t,e,n)=>{it(t),n()};function it(t){if(!o(t))return;const e=t;if(null===e.querySelector("style"))return;const n=new Map;function s(t){let e=n.get(t);if(void 0===e){e=new Set;for(let n=0;n<t.style.length;n++)e.add(t.style[n]);n.set(t,e)}return e}try{for(const t of Array.from(e.styleSheets)){let n;try{n=t.cssRules}catch(t){continue}for(const t of Array.from(n)){if(!_(t,CSSStyleRule))continue;let n;try{n=e.querySelectorAll(t.selectorText)}catch(t){continue}for(const e of Array.from(n)){if(!r(e))continue;const n=s(e);for(let o=0;o<t.style.length;o++){const r=t.style[o];n.has(r)||e.style.setProperty(r,t.style.getPropertyValue(r),t.style.getPropertyPriority(r))}}}}}catch(t){}}const ct="@lexical/html/DOM",lt=Symbol.for("@lexical/html/DOMExportContext"),ut="@lexical/html/DOMImport",ft=Symbol.for("@lexical/html/DOMImportContext"),at=()=>!0;function pt(t,e,n){return rt(lt,t,e,n)}const dt=pt("root",Boolean),ht=pt("isExport",Boolean);function gt(t){const e=L(t,ct);return e?e.output.defaults:void 0}function mt(t,n=e()){return J(function(t){return K(lt,t)||gt(t)}(n),t)}function yt(t){const e=L(t,ct);return e?e.output.runtime:void 0}function xt(t,n,o=e()){const r=yt(o);r&&r.setContextValue(t,n)}function St(t,n,o=e()){const r=yt(o);r&&r.setContextValue(t,n(J(r.editorContext,t)))}function $t(t=e()){const n=yt(t);return n?n.getSessionConfig():s(t)}const vt=ot(lt,gt);function bt(t,e,n){return{...e,...n,nodes:t}}function Ct(t){return e=>e instanceof t}function kt(t,{nodes:e}){if("*"===e)return at;let n={};const o=[];for(const r of e)if("getType"in r){const e=r.getType();if(n){const o=t[e];void 0===o&&G(339,r.name,e),n=Object.assign(n,o.types)}o.push(Ct(r))}else n=void 0,o.push(r);return n||(1===o.length?o[0]:t=>{for(const e of o)if(e(t))return!0;return!1})}function Ot(t){return(e,n,o)=>t(e,o)}function wt(t){return(e,n,o,r)=>t(e,n,r)}function Dt(t){return(e,n,o,r,s)=>t(e,n,o,s)}function Mt(t){return(e,n,o,r,s,i)=>t(e,n,o,r,i)}function At(t,e){return(n,o)=>{const r=()=>t(n,o),s=e(n);return s?s(n,r,o):r()}}function Nt(t,e){return(n,o,r)=>{const s=()=>t(n,o,r),i=e(n);return i?i(n,o,s,r):s()}}const It=Nt,Et=wt;function Wt(t,e){return(n,o,r,s)=>{const i=()=>t(n,o,r,s),c=e(n);return c?c(n,o,r,i,s):i()}}function Rt(t,e){return(n,o,r,s,i)=>{const c=()=>t(n,o,r,s,i),l=e(n);return l?l(n,o,r,s,c,i):c()}}function jt(t,e){return(n,o,r,s)=>{t(n,o,r,s);const i=e(n);i&&i(n,o,r,s)}}function Tt(t,e,n,o,r){let s=n[e];for(const n of t[e])if("function"==typeof n[0]){const[t,e]=n;s=o(s,n=>t(n)&&e||void 0)}else{const t=n[1],e={};for(const n in t){const r=t[n];r&&(e[n]=r.reduce((t,e)=>o(t,()=>e),s))}s=o(s,t=>{const n=e[t.getType()];return n&&r(n)})}n[e]=s}function Ft(t,e,n,o){if(!o)return;const r=t[e];if("function"==typeof n)r.push([n,o]);else{const t=r[r.length-1];let e;t&&"types"===t[0]?e=t[1]:(e={},r.push(["types",e]));for(const t in n){const n=e[t]||[];e[t]=n,n.push(o)}}}function Pt(t){return"*"===t.nodes}function zt(t,e){const n=function(t){const e={},{nodes:n}=U(t);for(const t of n)e[t.getType()]={klass:t,types:{}};for(const t of Object.values(e))if(t){const n=t.klass.getType();for(let{klass:o}=t;c(o.prototype);o=Object.getPrototypeOf(o)){const{ownNodeType:t}=l(o),r=t&&e[t];r&&(r.types[n]=!0)}}return e}(t),o={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const t of function(t){const e=[],n=[],o=[];for(const r of t)if(Pt(r))e.push(r);else if(Array.isArray(r.nodes))for(const t of r.nodes)c(t.prototype)?o.push(1===r.nodes.length?r:{...r,nodes:[t]}):n.push(1===r.nodes.length?r:{...r,nodes:[t]});const r=new Map,s=t=>{let e=r.get(t);if(void 0===e){e=0;for(let n=t;c(n.prototype);n=Object.getPrototypeOf(n))e++;r.set(t,e)}return e};return o.sort((t,e)=>s(t.nodes[0])-s(e.nodes[0])),[...o,...n,...e]}(e)){const e=kt(n,t);for(const n in o){Ft(o,n,e,t[n])}}return o}function _t(t){return t}function Lt(t,{overrides:e}){const n=zt(t,e),o={...i,...t.dom};return Tt(n,"$createDOM",o,At,Ot),Tt(n,"$exportDOM",o,At,Ot),Tt(n,"$extractWithChild",o,Rt,Mt),Tt(n,"$getDOMSlot",o,It,Et),Tt(n,"$shouldExclude",o,Nt,wt),Tt(n,"$shouldInclude",o,Nt,wt),Tt(n,"$updateDOM",o,Wt,Dt),Tt(n,"$decorateDOM",o,jt,_t),o}function Ut(t){return{get:e=>J(t,e)}}function Bt(t){const e=Object.create(null);return Z(t,e)||e}function Vt(t,e){const n=Ut(e);return t.filter(t=>!(t.disabledForEditor&&t.disabledForEditor(n)))}function qt(t){if("*"===t.nodes)return()=>!0;const e=t.nodes.map(t=>{const e=t;return c(e.prototype)?t=>t instanceof e:t});return t=>e.some(e=>e(t))}class Gt{editor;initialEditorConfig;overrides;editorContext;hasSessionGates;installed;sessionCache=new Map;constructor(t,e,n,o){this.editor=t,this.initialEditorConfig=e,this.overrides=n,this.editorContext=o,this.installed=Vt(n,o),this.hasSessionGates=n.some(t=>t.disabledForSession)}setContextValue(t,e){const n=this.installed;this.editorContext[t.key]=e;const o=Vt(this.overrides,this.editorContext);if(function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}(n,o))return;const r=function(t,e){const n=new Set(t),o=new Set(e),r=[];for(const e of t)o.has(e)||r.push(e);for(const t of e)n.has(t)||r.push(t);return r}(n,o);this.installed=o,this.sessionCache.clear();const s=Lt(this.initialEditorConfig,{overrides:o});this.editor._config.dom=s;const i=function(t){const e=[];for(const n of t)(n.$createDOM||n.$getDOMSlot||n.$decorateDOM)&&e.push(qt(n));return 0===e.length?null:t=>e.some(e=>e(t))}(r);if(!i)return;const c=s.$updateDOM;s.$updateDOM=(t,e,n,o)=>!!i(t)||c(t,e,n,o),this.editor.update(u,{discrete:!0}),s.$updateDOM=c}getSessionConfig(){const t=this.editor._config.dom||i;if(!this.hasSessionGates)return t;const e=Ut(K(lt,this.editor)||this.editorContext),n=[],o=[];if(this.installed.forEach((t,r)=>{t.disabledForSession&&t.disabledForSession(e)?n.push(String(r)):o.push(t)}),0===n.length)return t;const r=n.join(",");let s=this.sessionCache.get(r);return s||(s=Lt(this.initialEditorConfig,{overrides:o}),this.sessionCache.set(r,s)),s}}const Ht=f({build(t,e,n){const{initialEditorConfig:o}=n.getInitResult(),r=Bt(e.contextDefaults);return{defaults:r,runtime:new Gt(t,o,e.overrides,r)}},config:{contextDefaults:[],overrides:[]},html:{export:new Map([[p,()=>{const t=document.createElement("div");return t.role="textbox",{element:t}}]])},init(t,e){const n={dom:t.dom,nodes:t.nodes},o=Bt(e.contextDefaults),r=Vt(e.overrides,o);return t.dom=Lt(t,{overrides:r}),{initialEditorConfig:n}},mergeConfig(t,e){const n=a(t,e);for(const o of["overrides","contextDefaults"])e[o]&&(n[o]=[...t[o],...e[o]]);return n},name:ct}),Jt=Symbol.for("@lexical/html/SelectorImpl");function Qt(t,e){const n={kind:"element",predicate:(o=e,0===o.length?r:1===o.length?o[0]:(t,e)=>{for(const n of o)if(!n(t,e))return!1;return!0}),tags:t};var o;const s=n=>Qt(t,[...e,n]);return{[Jt]:n,attr:(t,e,n)=>s(Zt(t,e,n)),classAll:(...t)=>s(Yt(t)),classAny:(...t)=>s(function(t){const e=Kt(t);if(0===e.length)return()=>!1;return t=>{if(!r(t))return!1;const n=t.classList;for(const t of e)if(n.contains(t))return!0;return!1}}(t)),styleAny:(t,e,n)=>s(function(t,e,n){if("string"==typeof e)return n=>r(n)&&n.style.getPropertyValue(t)===e;if(e instanceof RegExp){const o=n&&n.capture,s=e;return(e,n)=>{if(!r(e))return!1;const i=e.style.getPropertyValue(t);if(!i)return!1;const c=i.match(s);return null!==c&&(void 0!==o&&(n[o]=c),!0)}}G(362,JSON.stringify(t))}(t,e,n))}}function Kt(t){const e=[];for(const n of t)n&&e.push(n);return e}function Yt(t){const e=Kt(t);return 0===e.length?()=>!0:t=>{if(!r(t))return!1;const n=t.classList;for(const t of e)if(!n.contains(t))return!1;return!0}}function Zt(t,e,n){if(!0===e)return e=>r(e)&&e.hasAttribute(t);if("string"==typeof e)return n=>r(n)&&n.getAttribute(t)===e;if(e instanceof RegExp){const o=n&&n.capture,s=e;return(e,n)=>{if(!r(e))return!1;const i=e.getAttribute(t);if(null==i)return!1;const c=i.match(s);return null!==c&&(void 0!==o&&(n[o]=c),!0)}}G(361,JSON.stringify(t))}const Xt={kind:"text",predicate:d,tags:new Set},te={[Jt]:Xt},ee={kind:"comment",predicate:t=>8===t.nodeType,tags:new Set},ne={[Jt]:ee},oe={any:()=>Qt(new Set,[]),comment:()=>ne,tag(...t){t.length>0||G(363);const e=new Set;for(const n of t)e.add(n.toUpperCase());return Qt(e,[])},text:()=>te};function re(t,e){return r(t)&&t.nodeName===e.toUpperCase()}const se=/[A-Za-z0-9_-]/;class ie{constructor(t,e){this.source=t,this.pos=e}peek(t=0){return this.source[this.pos+t]||""}consume(){return this.source[this.pos++]||""}eof(){return this.pos>=this.source.length}skipWhitespace(){for(;!this.eof()&&/\s/.test(this.peek());)this.pos++}readIdent(){const t=this.pos;for(;!this.eof()&&se.test(this.peek());)this.pos++;return this.source.slice(t,this.pos)}readQuoted(){const t=this.consume();this.assert('"'===t||"'"===t,"expected quote");const e=this.pos;for(;!this.eof()&&this.peek()!==t;)"\\"===this.peek()?this.pos+=2:this.pos++;this.assert(!this.eof(),"unterminated string");const n=this.source.slice(e,this.pos);return this.pos++,n.replace(/\\(.)/g,"$1")}assert(t,e){t||G(364,String(this.pos+1),e,this.source)}}function ce(t){const e=new Set,n=[],o=[];if(t.skipWhitespace(),"*"===t.peek())t.consume();else if(se.test(t.peek())){const n=t.readIdent();n&&e.add(n.toUpperCase())}for(;!t.eof();){const e=t.peek();if("."===e){t.consume();const e=t.readIdent();t.assert(""!==e,'expected class name after "."'),o.push(e)}else if("#"===e){t.consume();const e=t.readIdent();t.assert(""!==e,'expected id after "#"'),n.push(Zt("id",e))}else{if("["!==e)break;{t.consume(),t.skipWhitespace();const e=t.readIdent();t.assert(""!==e,'expected attribute name after "["'),t.skipWhitespace();let o=!0;if("="===t.peek()){t.consume(),t.skipWhitespace();const e=t.peek();'"'===e||"'"===e?o=t.readQuoted():(o=t.readIdent(),t.assert(""!==o,"expected attribute value")),t.skipWhitespace()}t.assert("]"===t.peek(),'expected "]"'),t.consume(),n.push(Zt(e,o))}}}return o.length>0&&n.push(Yt(o)),{predicates:n,tags:e}}function le(t){const e=new ie(t,0),n=[];for(;;){const t=ce(e);if(n.push(t),e.skipWhitespace(),e.eof())break;e.assert(","===e.peek(),'expected "," (selector lists are the only supported combinator)'),e.consume(),e.skipWhitespace()}if(1===n.length)return Qt(n[0].tags,n[0].predicates);const o=new Set;for(const t of n)for(const e of t.tags)o.add(e);return Qt(o,[(t,e)=>{for(const o of n){const n=t.nodeName;if(o.tags.size>0&&!o.tags.has(n))continue;let r=!0;for(const n of o.predicates)if(!n(t,e)){r=!1;break}if(r)return!0}return!1}])}function ue(t){return t}function fe(t,e,n){return rt(ft,t,e,n)}const ae=fe("importSource",()=>"unknown"),pe=fe("importSourceDataTransfer",()=>null),de=fe("textFormat",()=>0),he=fe("textStyle",()=>({}));function ge(t){if(!r(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function me(t){if(d(t))return!0;if(!r(t))return!1;const e=t.style.display;return e?e.startsWith("inline"):!h(t)&&g(t)}const ye=fe("whitespaceConfig",()=>({isInline:me,preservesWhitespace:ge})),xe=fe("importOverlays",()=>[]);class Se{constructor(t){this.record=t}get(t){return J(this.record,t)}set(t,e){this.record[t.key]=e}update(t,e){this.record[t.key]=e(J(this.record,t))}has(t){return Object.prototype.hasOwnProperty.call(this.record,t.key)}}function $e(t){const e=L(t,ut);return e?e.output.defaults:void 0}function ve(t,n=e()){return J(function(t){return K(ft,t)||$e(t)}(n),t)}const be=ot(ft,$e),Ce=oe,ke=new Set(["center","end","justify","left","right","start"]);function Oe(t){return ke.has(t)}const we={B:{fontWeight:"bold"},EM:{fontStyle:"italic"},I:{fontStyle:"italic"},S:{textDecoration:"line-through"},STRONG:{fontWeight:"bold"},SUB:{verticalAlign:"sub"},SUP:{verticalAlign:"super"},U:{textDecoration:"underline"}},De={CODE:y,MARK:m};const Me=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Ae={$import:(t,e)=>{const n=t.get(de),o=we[e.nodeName],r=function(t){return{fontStyle:t.style.fontStyle,fontWeight:t.style.fontWeight,textDecoration:t.style.textDecoration,verticalAlign:t.style.verticalAlign}}(e),s=o?(i=o,{fontStyle:(c=r).fontStyle||i.fontStyle,fontWeight:c.fontWeight||i.fontWeight,textDecoration:c.textDecoration||i.textDecoration,verticalAlign:c.verticalAlign||i.verticalAlign}):r;var i,c;let l=(u=n,f=function(t){let e=0,n=0;const{fontWeight:o,fontStyle:r,textDecoration:s,verticalAlign:i}=t;if("700"===o||"bold"===o?e|=w:"normal"!==o&&"400"!==o||(n|=w),"italic"===r?e|=D:"normal"===r&&(n|=D),s){const t=s.split(" ");t.includes("underline")&&(e|=M),t.includes("line-through")&&(e|=A),t.includes("none")&&(n|=M|A)}return"sub"===i?(e|=N,n|=I):"super"===i?(e|=I,n|=N):"baseline"===i&&(n|=N|I),{clear:n,set:e}}(s),u&~f.clear|f.set);var u,f;const a=De[e.nodeName];return a&&(l|=a),l===n?t.$importChildren(e):t.$importChildren(e,{context:[tt(de,l)]})},match:Ce.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"};function Ne(t,e,n){let o=t;for(;;){let t=null;for(;null===(t=e?o.nextSibling:o.previousSibling);){const t=o.parentNode;if(null===t)return null;o=t}if(o=t,!n.isInline(o))return null;let r=o;for(;null!==(r=e?o.firstChild:o.lastChild);)o=r;if(d(o))return o;if("BR"===o.nodeName)return null}}function Ie(t,e){return 0!==e&&O(t)?t.setFormat(e):t}function Ee(t,e){if(O(t)){const n=function(t){let e="";for(const n in t)Me.has(n)||(e+=`${n}: ${t[n]}; `);return e.trimEnd()}(e);""!==n&&t.setStyle(n)}return t}const We={$import:(t,e)=>{const n=t.get(de),o=t.get(he),r=t.get(ye);if(function(t,e){let n=t.parentNode;for(;null!==n;){if(e.preservesWhitespace(n))return!0;n=n.parentNode}return!1}(e,r)){const t=x(e.textContent||"");for(const e of t)Ie(e,n),Ee(e,o);return t}const s=function(t,e){let n=(t.textContent||"").replace(/\r/g,"").replace(/[ \t\n]+/g," ");if(0===n.length)return"";if(" "===n[0]){let o=t,r=!0;for(;null!==o&&null!==(o=Ne(o,!1,e));){const t=o.textContent||"";if(t.length>0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n.length>0&&" "===n[n.length-1]){let o=t,r=!0;for(;null!==o&&null!==(o=Ne(o,!0,e));)if((o.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){r=!1;break}r&&(n=n.slice(0,-1))}return n}(e,r);if(""===s)return[];const i=S(s);return Ie(i,n),Ee(i,o),[i]},match:Ce.text(),name:"@lexical/html/#text"},Re={$import:()=>[],match:Ce.tag("script","style"),name:"@lexical/html/script-style-ignore"},je={$import:()=>[$()],match:Ce.tag("br"),name:"@lexical/html/br"},Te=[Re,{$import:(t,e)=>{const n=v();if(b(n,e),C(e,n),""===n.getFormatType()){const t=e.getAttribute("align");t&&Oe(t)&&n.setFormat(t)}return k(n,e),[n.splice(0,0,t.$importChildren(e))]},match:Ce.tag("p"),name:"@lexical/html/p"},We,je,Ae];function Fe(t,e){const n=[];let o=0,r=0;for(;o<t.length&&r<e.length;)t[o]<=e[r]?n.push(t[o++]):n.push(e[r++]);for(;o<t.length;)n.push(t[o++]);for(;r<e.length;)n.push(e[r++]);return n}function Pe(t){const e=[],n=new Map,o=[],r=[],s=[],i=new Set;t.forEach((t,c)=>{const l=function(t){const e=t[Jt];return void 0===e&&G(360),e}(t.match),u=t.name||function(t,e){if("text"===t.kind)return`#text@${e}`;if("comment"===t.kind)return`#comment@${e}`;if(0===t.tags.size)return`*@${e}`;const n=Array.from(t.tags).join(",").toLowerCase();return`${n}@${e}`}(l,c);if(t.name&&i.add(t.name),e.push({$import:t.$import,name:u,predicate:l.predicate}),"text"===l.kind)r.push(c);else if("comment"===l.kind)s.push(c);else if(0===l.tags.size)o.push(c);else for(const t of l.tags){let e=n.get(t);e||(e=[],n.set(t,e)),e.push(c)}});const c=new Map;if(0===o.length)for(const[t,e]of n)c.set(t,e);else for(const[t,e]of n)c.set(t,Fe(e,o));return{byTag:c,commentIndices:s,rules:e,textIndices:r,wildcardIndices:o}}function ze(t,e){return d(e)?t.textIndices:8===e.nodeType?t.commentIndices:r(e)?t.byTag.get(e.nodeName)||t.wildcardIndices:_e}const _e=Object.freeze([]);function Le(t){const e=[];for(const n of t)if(Ue(n))for(const t of n.rules)e.push(t);else e.push(n);return e}function Ue(t){return"object"==typeof t&&null!==t&&"__type"in t&&"CompiledOverlayRules"===t.__type}function Be(t){const e=Le(t);return{__type:"CompiledOverlayRules",dispatch:Pe(e),rules:e}}function Ve(t){return W(t)||R(t)&&!t.isInline()}function qe(t,e){const n=[];let o=[];const r=()=>{0!==o.length&&(n.push(e().splice(0,0,o)),o=[])};for(const s of t)if(Ve(s)){if(r(),E(s)){const t=qe(s.getChildren(),e);s.splice(0,s.getChildrenSize(),t)}n.push(s)}else o.push(s);return r(),n}function Ge(t,e,n){const o=v();if(r(n)){const t=n.style.textAlign;Oe(t)&&o.setFormat(t)}return[o.splice(0,0,t)]}const He={$accepts:Ve,$packageRun:Ge,name:"BlockSchema"},Je={$accepts:t=>!Ve(t),name:"InlineSchema"},Qe={$accepts:Ve,$packageRun:t=>t,name:"NestedBlockSchema"},Ke={$accepts:Ve,$packageRun:Ge,name:"RootSchema"},Ye=Object.freeze({});function Ze(t,e){const n={$importChildren:(e,n)=>function(t,e,n){const o=n&&n.rules?n.rules.dispatch:void 0;o&&t.overlays.push(o);try{const o=()=>Xe(t,e,n);return n&&n.context?be(n.context,t.editor)(o):o()}finally{o&&t.overlays.pop()}}(t,e,n),$importOne:(e,n)=>tn(t,e,n),captures:e,get:e=>ve(e,t.editor),session:t.session};return n}function Xe(t,e,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(e.childNodes)){const e=tn(t,n,void 0);for(const t of e){const e=o?o(t):t;null!=e&&r.push(e)}}const s=n&&n.$after?n.$after(r):r,i=n&&n.schema;return i?function(t,e,n,o){const r=[];let s=null;const i=()=>{if(null===s)return;const e=s;if(s=null,t.$packageRun){const s=t.$packageRun(e,n,o);if(s.length>0){for(const t of s)r.push(t);return}}if("hoist"===t.onReject)for(const t of e)r.push(t)};for(const o of e)t.$accepts(o,n)?(i(),r.push(o)):(null===s&&(s=[]),s.push(o));return i(),t.$finalize?t.$finalize(r,n):r}(i,s,null,e):s}function tn(t,e,n){const o=()=>function(t,e){const n=function(t,e){const n=[];for(let o=t.overlays.length-1;o>=0;o--){const r=t.overlays[o],s=ze(r,e);s.length>0&&n.push({dispatch:r,indices:s})}const o=ze(t.dispatch,e);o.length>0&&n.push({dispatch:t.dispatch,indices:o});return n}(t,e);if(0===n.length)return en(t,e);let o=0,r=0;const s=()=>{for(;o<n.length;){const{dispatch:i,indices:c}=n[o];for(;r<c.length;){const n=c[r++],o=i.rules[n],l={};if(o.predicate(e,l)){const n=Ze(t,0===Object.keys(l).length?Ye:l);try{return o.$import(n,e,s)}catch(t){throw t}}}o++,r=0}return en(t,e)};return s()}(t,e);return n&&n.context?be(n.context,t.editor)(o):o()}function en(t,e){if(0===e.childNodes.length)return[];const n=[];for(const o of Array.from(e.childNodes)){const e=tn(t,o,void 0);for(const t of e)n.push(t)}return n}const nn={$import:(t,e)=>t.$importChildren(e),match:oe.any(),name:"@lexical/html/default-hoist"},on=f({build(t,e){const n=Pe(Le(e.rules)),r=Z(e.contextDefaults,void 0),s=e.preprocess;return{$generateNodesFromDOM:(e,i)=>{const c=i&&i.context?Z(i.context,r):r,l=void 0!==c&&c!==r?c:Object.create(r||null),u=new Se(l),f={session:u};return function(t,e,n){let o=t.length-1;const r=()=>{for(;o>=0;)return void(0,t[o--])(e,n,r)};r()}(i&&i.preprocess?[...s,...i.preprocess]:s,e,f),nt(ft,l,()=>function(t,e,n,r){return Xe({dispatch:t,editor:e,overlays:r.get(xe).map(t=>t.dispatch),session:r},o(n)?n.body:n,{schema:Ke})}(n,t,e,u),t)},defaults:r}},config:{contextDefaults:[],preprocess:[st],rules:[nn]},mergeConfig:(t,e)=>a(t,{...e,...e.contextDefaults&&{contextDefaults:[...t.contextDefaults,...e.contextDefaults]},...e.preprocess&&{preprocess:[...t.preprocess,...e.preprocess]},...e.rules&&{rules:[...e.rules,...t.rules]}}),name:ut});function rn(t,e){return B(on).$generateNodesFromDOM(t,e)}const sn=f({dependencies:[j(on,{rules:Te})],name:"@lexical/html/CoreImport"}),cn=[{$import:()=>[q()],match:oe.tag("hr"),name:"@lexical/html/hr"}],ln=f({dependencies:[sn,V,j(on,{rules:cn})],name:"@lexical/html/HorizontalRuleImport"}),un={any:oe.any,comment:oe.comment,css:le,tag:oe.tag,text:oe.text},fn=new Set(["STYLE","SCRIPT"]);function an(t,e){it(e);const n=o(e)?e.body.childNodes:e.childNodes,r=[],s=[];for(const e of n)if(!fn.has(e.nodeName)){const n=mn(e,t,s,!1);if(null!==n)for(const t of n)r.push(t)}return function(t){for(const e of t)e.getParent()&&e.getNextSibling()instanceof z&&e.insertAfter($());for(const e of t){const t=e.getParent();t&&t.splice(e.getIndexWithinParent(),1,e.getChildren())}}(s),r}function pn(t,n=null,o=e()){return vt([tt(ht,!0)],o)(()=>{const e=T(),r=$t(o),s=t.append.bind(t);for(const t of e.getChildren())gn(o,t,s,n,r);return t})}function dn(t,n=T()){const o=e();return vt([tt(ht,!0),tt(dt,!0)],o)(()=>{const e=$t(o),r=t.append.bind(t);return gn(o,n,r,null,e),t})}function hn(t,e=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&G(338),pn(document.createElement("div"),e,t).innerHTML}function gn(e,n,o,i=null,c=s(e)){let l=c.$shouldInclude(n,i,e);const u=c.$shouldExclude(n,i,e);let f=n;null!==i&&O(n)&&(f=t(i,n,"clone"));const a=c.$exportDOM(f,e),{element:p,after:d,append:h,$getChildNodes:g}=a;if(!p)return!1;const m=document.createDocumentFragment(),y=g?g():E(f)?f.getChildren():[],x=m.append.bind(m);for(const t of y){const o=gn(e,t,x,i,c);!l&&o&&c.$extractWithChild(n,t,i,"html",e)&&(l=!0)}if(l&&!u){if((r(p)||F(p))&&(h?h(m):p.append(m)),o(p),d){const t=d.call(f,p);t&&(F(p)?p.replaceChildren(t):p.replaceWith(t))}}else o(m);return l}function mn(t,e,n,o,r=new Map,s){const i=[];if(fn.has(t.nodeName))return i;let c=null;const l=function(t,e){const{nodeName:n}=t,o=e._htmlConversions.get(n.toLowerCase());let r=null;if(void 0!==o)for(const e of o){const n=e(t);null!==n&&(null===r||(r.priority||0)<=(n.priority||0))&&(r=n)}return null!==r?r.conversion:null}(t,e),u=l?l(t):null;let f=null;if(null!==u){f=u.after;const e=u.node;if(c=Array.isArray(e)?e[e.length-1]:e,null!==c){for(const[,t]of r)if(c=t(c,s),!c)break;c&&i.push(...Array.isArray(e)?e:[c])}null!=u.forChild&&r.set(t.nodeName,u.forChild)}const a=t.childNodes;let p=[];const d=(null==c||!P(c))&&(null!=c&&W(c)||o);for(let t=0;t<a.length;t++)p.push(...mn(a[t],e,n,d,new Map(r),c));if(null!=f&&(p=f(p)),h(t)&&(p=yn(t,p,d?()=>{const t=new z;return n.push(t),t}:v)),null==c)if(p.length>0)for(const t of p)i.push(t);else h(t)&&function(t){if(null==t.nextSibling||null==t.previousSibling)return!1;return g(t.nextSibling)&&g(t.previousSibling)}(t)&&i.push($());else E(c)&&c.append(...p);return i}function yn(t,e,n){const o=t.style.textAlign,r=[];let s=[];for(let t=0;t<e.length;t++){const i=e[t];if(W(i))o&&!i.getFormat()&&i.setFormat(o),r.push(i);else if(s.push(i),t===e.length-1||t<e.length-1&&W(e[t+1])){const t=n();t.setFormat(o),t.append(...s),r.push(t),s=[]}}return r}export{qe as $distributeInlineWrapper,pn as $generateDOMFromNodes,dn as $generateDOMFromRoot,hn as $generateHtmlFromNodes,an as $generateNodesFromDOM,rn as $generateNodesFromDOMViaExtension,ve as $getImportContextValue,mt as $getRenderContextValue,$t as $getSessionDOMRenderConfig,st as $inlineStylesFromStyleSheets,Ve as $isBlockLevel,xt as $setRenderContextValue,St as $updateRenderContextValue,be as $withImportContext,vt as $withRenderContext,He as BlockSchema,sn as CoreImportExtension,Te as CoreImportRules,on as DOMImportExtension,Ht as DOMRenderExtension,ln as HorizontalRuleImportExtension,cn as HorizontalRuleImportRules,xe as ImportOverlays,ae as ImportSource,pe as ImportSourceDataTransfer,de as ImportTextFormat,he as ImportTextStyle,ye as ImportWhitespaceConfig,Je as InlineSchema,Qe as NestedBlockSchema,ht as RenderContextExport,dt as RenderContextRoot,Ke as RootSchema,et as contextUpdater,tt as contextValue,fe as createImportState,pt as createRenderState,me as defaultIsInline,ge as defaultPreservesWhitespace,ue as defineImportRule,Be as defineOverlayRules,bt as domOverride,re as isElementOfTag,le as parseSelector,un as sel};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { EditorDOMRenderConfig } from 'lexical';
9
+ import { LexicalEditor } from 'lexical';
10
+ import { AnyRenderStateConfigPairOrUpdater, RenderStateConfig } from './types';
11
+ /**
12
+ * Create a context state to be used during render.
13
+ *
14
+ * Note that to support the ValueOrUpdater pattern you can not use a
15
+ * function for V (but you may wrap it in an array or object).
16
+ *
17
+ * @experimental
18
+ * @__NO_SIDE_EFFECTS__
19
+ */
20
+ export declare function createRenderState<V>(name: string, getDefaultValue: () => V, isEqual?: (a: V, b: V) => boolean): RenderStateConfig<V>;
21
+ /**
22
+ * Render context state that is true if the export was initiated from the root of the document.
23
+ * @experimental
24
+ */
25
+ export declare const RenderContextRoot: RenderStateConfig<boolean>;
26
+ /**
27
+ * Render context state that is true if this is an export operation ($generateHtmlFromNodes).
28
+ * @experimental
29
+ */
30
+ export declare const RenderContextExport: RenderStateConfig<boolean>;
31
+ /**
32
+ * Get a render context value during a DOM render or export operation.
33
+ * @experimental
34
+ */
35
+ export declare function $getRenderContextValue<V>(cfg: RenderStateConfig<V>, editor?: LexicalEditor): V;
36
+ /**
37
+ * Imperatively set a value in the persistent editor render context.
38
+ *
39
+ * Unlike {@link $withRenderContext} (which scopes values to a callback), this
40
+ * persists on the editor. If the change flips any override's
41
+ * `disabledForEditor` result, the resident render config is recompiled and the
42
+ * affected nodes are re-rendered. No-op if {@link DOMRenderExtension} is not
43
+ * installed.
44
+ *
45
+ * @experimental
46
+ */
47
+ export declare function $setRenderContextValue<V>(cfg: RenderStateConfig<V>, value: V, editor?: LexicalEditor): void;
48
+ /**
49
+ * Imperatively update a value in the persistent editor render context with an
50
+ * updater function. See {@link $setRenderContextValue}.
51
+ *
52
+ * @experimental
53
+ */
54
+ export declare function $updateRenderContextValue<V>(cfg: RenderStateConfig<V>, updater: (prev: V) => V, editor?: LexicalEditor): void;
55
+ /**
56
+ * Resolve the {@link EditorDOMRenderConfig} to use for the current
57
+ * export/generate session, applying any `disabledForSession` overrides against
58
+ * the active session context. Falls back to the editor's resident config when
59
+ * {@link DOMRenderExtension} is not installed.
60
+ *
61
+ * @experimental
62
+ */
63
+ export declare function $getSessionDOMRenderConfig(editor?: LexicalEditor): EditorDOMRenderConfig;
64
+ /**
65
+ * Execute a callback within a render context with the given config pairs.
66
+ * @experimental
67
+ */
68
+ export declare const $withRenderContext: (cfg: readonly AnyRenderStateConfigPairOrUpdater[], editor?: LexicalEditor) => <T>(f: () => T) => T;
@@ -18,5 +18,5 @@ type PreEditorDOMRenderConfig = {
18
18
  [K in keyof EditorDOMRenderConfig]: AnyRender<AnyDOMRenderMatch[K]>[];
19
19
  };
20
20
  export declare function precompileDOMRenderConfigOverrides(editorConfig: Pick<InitialEditorConfig, 'nodes'>, overrides: DOMRenderConfig['overrides']): PreEditorDOMRenderConfig;
21
- export declare function compileDOMRenderConfigOverrides(editorConfig: InitialEditorConfig, { overrides }: DOMRenderConfig): EditorDOMRenderConfig;
21
+ export declare function compileDOMRenderConfigOverrides(editorConfig: Pick<InitialEditorConfig, 'nodes' | 'dom'>, { overrides }: Pick<DOMRenderConfig, 'overrides'>): EditorDOMRenderConfig;
22
22
  export {};
@@ -7,4 +7,6 @@
7
7
  */
8
8
  export declare const DOMRenderExtensionName = "@lexical/html/DOM";
9
9
  export declare const DOMRenderContextSymbol: unique symbol;
10
+ export declare const DOMImportExtensionName = "@lexical/html/DOMImport";
11
+ export declare const DOMImportContextSymbol: unique symbol;
10
12
  export declare const ALWAYS_TRUE: () => true;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { DOMOverrideOptions, DOMRenderMatch, DOMRenderMatchConfig, NodeMatch } from './types';
9
+ import type { LexicalNode } from 'lexical';
10
+ /**
11
+ * A convenience function for type inference when constructing DOM overrides for
12
+ * use with {@link DOMRenderExtension}.
13
+ *
14
+ * The optional `options` argument controls *whether* the override is installed
15
+ * based only on render context — `disabledForEditor` gates residency in the
16
+ * editor's render pipeline (reconciliation), `disabledForSession` gates
17
+ * participation in a single export/generate session. See {@link DOMOverrideOptions}.
18
+ *
19
+ * @experimental
20
+ * @__NO_SIDE_EFFECTS__
21
+ */
22
+ export declare function domOverride(nodes: '*', config: DOMRenderMatchConfig<LexicalNode>, options?: DOMOverrideOptions): DOMRenderMatch<LexicalNode>;
23
+ export declare function domOverride<T extends LexicalNode>(nodes: readonly NodeMatch<T>[], config: DOMRenderMatchConfig<T>, options?: DOMOverrideOptions): DOMRenderMatch<T>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Bundles {@link CoreImportRules} into a {@link DOMImportExtension}-aware
3
+ * extension. Depend on this from your editor (directly or via richer
4
+ * extensions like `RichTextImportExtension`) to get the equivalent of the
5
+ * legacy core `importDOM` behavior for `<p>`, `<span>`, `<b>`,
6
+ * `<strong>`, `<em>`, `<i>`, `<code>`, `<mark>`, `<s>`, `<sub>`, `<sup>`,
7
+ * `<u>`, `<br>`, and `#text`.
8
+ *
9
+ * @experimental
10
+ */
11
+ export declare const CoreImportExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/html/CoreImport", unknown, unknown>;
@@ -0,0 +1,82 @@
1
+ import type { DOMImportRuleEntry } from './defineOverlayRules';
2
+ import type { DOMImportExtensionOutput, DOMPreprocessFn, GenerateNodesFromDOMOptions, ImportContextPairOrUpdater } from './types';
3
+ import { type LexicalNode } from 'lexical';
4
+ /**
5
+ * Configuration for {@link DOMImportExtension}.
6
+ *
7
+ * @experimental
8
+ */
9
+ export interface DOMImportConfig {
10
+ /**
11
+ * The set of rules contributed by this extension and its dependencies.
12
+ * Entries can be raw {@link DOMImportRule}s or a
13
+ * {@link CompiledOverlayRules} produced by {@link defineOverlayRules}
14
+ * (the latter is inlined in priority order — useful for libraries
15
+ * that already publish a compiled overlay).
16
+ *
17
+ * Rules are dispatched in priority order: rules contributed by
18
+ * extensions merged later (i.e. closer to the editor root) run first
19
+ * and may call `$next()` to delegate to lower-priority rules.
20
+ *
21
+ * `mergeConfig` prepends `partial.rules` to existing `rules`, so later
22
+ * configuration carries higher priority.
23
+ */
24
+ readonly rules: readonly DOMImportRuleEntry[];
25
+ /**
26
+ * Default context pairs applied to every `$generateNodesFromDOM` call.
27
+ * Per-call overrides can be supplied via
28
+ * {@link GenerateNodesFromDOMOptions.context}.
29
+ */
30
+ readonly contextDefaults: readonly ImportContextPairOrUpdater[];
31
+ /**
32
+ * Functions run in order on the DOM before walking begins, mutating in
33
+ * place. The default config registers
34
+ * {@link $inlineStylesFromStyleSheets} (resolves `<style>` rules to
35
+ * inline styles so the rules' style-driven matchers see them); apps
36
+ * append additional preprocessors (e.g. strip unsafe elements,
37
+ * normalize attributes, resolve relative URLs).
38
+ *
39
+ * `mergeConfig` appends, so each contributing extension's preprocessors
40
+ * run in dependency order. Per-call preprocessors registered via
41
+ * {@link GenerateNodesFromDOMOptions.preprocess} run AFTER these.
42
+ */
43
+ readonly preprocess: readonly DOMPreprocessFn[];
44
+ }
45
+ /**
46
+ * Lowest-priority catch-all rule used as the default `config.rules` entry
47
+ * for {@link DOMImportExtension}: descends into the element's children
48
+ * and returns whatever they produced. With no other matching rule, an
49
+ * element vanishes and its contents are inserted in its place — the
50
+ * legacy `$createNodesFromDOM` hoisting behavior, but now expressed as a
51
+ * regular rule that apps can override (e.g. with a `sel.any()` rule that
52
+ * captures and discards unknown elements).
53
+ *
54
+ * @experimental
55
+ */
56
+ export declare const DefaultHoistRule: import("./types").DOMImportRule<import("./types").ElementSelectorBuilder<HTMLElement, Record<string, never>>>;
57
+ /**
58
+ * @experimental
59
+ *
60
+ * Extension-based replacement for the legacy `importDOM` / `DOMConversion`
61
+ * machinery. Rules are contributed via configuration (see
62
+ * {@link DOMImportConfig.rules}), compiled into a tag-bucketed dispatcher at
63
+ * editor build time, and consumed via the extension's
64
+ * {@link DOMImportExtensionOutput.$generateNodesFromDOM} output.
65
+ *
66
+ * The legacy `$generateNodesFromDOM` continues to work in parallel; the
67
+ * intent is to migrate node packages over to this extension incrementally.
68
+ */
69
+ export declare const DOMImportExtension: import("lexical").LexicalExtension<DOMImportConfig, "@lexical/html/DOMImport", DOMImportExtensionOutput, void>;
70
+ /**
71
+ * Look up the editor's {@link DOMImportExtension} and run its
72
+ * `$generateNodesFromDOM`. Designed as a drop-in replacement for the
73
+ * legacy `$generateNodesFromDOM(editor, dom)` signature so it can be
74
+ * supplied to `ClipboardImportExtension.$generateNodesFromDOM` (or any
75
+ * other consumer that wants to route through the extension pipeline).
76
+ *
77
+ * Throws if the editor was not built with {@link DOMImportExtension} as a
78
+ * dependency.
79
+ *
80
+ * @experimental
81
+ */
82
+ export declare function $generateNodesFromDOMViaExtension(dom: Document | ParentNode, options?: GenerateNodesFromDOMOptions): LexicalNode[];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Import rules for {@link HorizontalRuleNode}.
10
+ *
11
+ * @experimental
12
+ */
13
+ export declare const HorizontalRuleImportRules: import("./types").DOMImportRule<import("./types").ElementSelectorBuilder<HTMLHRElement, Record<string, never>>>[];
14
+ /**
15
+ * Bundles {@link HorizontalRuleImportRules} (plus
16
+ * {@link CoreImportExtension}) into a single dependency. The legacy
17
+ * {@link HorizontalRuleExtension.importDOM} continues to work in parallel;
18
+ * depend on this extension to opt into the new pipeline.
19
+ *
20
+ * Lives in `@lexical/html` (not `@lexical/extension`) because
21
+ * {@link DOMImportExtension} itself is in `@lexical/html`, and
22
+ * `@lexical/extension` is upstream of `@lexical/html` in the dependency
23
+ * graph — same arrangement as {@link CoreImportExtension}.
24
+ *
25
+ * @experimental
26
+ */
27
+ export declare const HorizontalRuleImportExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/html/HorizontalRuleImport", unknown, unknown>;