@lexical/html 0.44.1-nightly.20260519.0 → 0.45.1-dev.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.
- package/{DOMRenderExtension.d.ts → dist/DOMRenderExtension.d.ts} +12 -1
- package/dist/DOMRenderRuntime.d.ts +51 -0
- package/dist/LexicalHtml.dev.js +3289 -0
- package/dist/LexicalHtml.dev.mjs +3242 -0
- package/{LexicalHtml.js.flow → dist/LexicalHtml.js.flow} +16 -16
- package/dist/LexicalHtml.mjs +57 -0
- package/dist/LexicalHtml.node.mjs +55 -0
- package/dist/LexicalHtml.prod.js +9 -0
- package/dist/LexicalHtml.prod.mjs +9 -0
- package/dist/RenderContext.d.ts +68 -0
- package/{compileDOMRenderConfigOverrides.d.ts → dist/compileDOMRenderConfigOverrides.d.ts} +1 -1
- package/{constants.d.ts → dist/constants.d.ts} +2 -0
- package/dist/domOverride.d.ts +23 -0
- package/dist/import/CoreImportExtension.d.ts +11 -0
- package/dist/import/DOMImportExtension.d.ts +82 -0
- package/dist/import/HorizontalRuleImportExtension.d.ts +28 -0
- package/dist/import/ImportContext.d.ts +208 -0
- package/dist/import/compileImportRules.d.ts +50 -0
- package/dist/import/coreImportRules.d.ts +25 -0
- package/dist/import/defineImportRule.d.ts +32 -0
- package/dist/import/defineOverlayRules.d.ts +66 -0
- package/dist/import/index.d.ts +38 -0
- package/dist/import/inlineStylesFromStyleSheets.d.ts +28 -0
- package/dist/import/parseCss.d.ts +18 -0
- package/dist/import/runImport.d.ts +19 -0
- package/dist/import/schemas.d.ts +106 -0
- package/dist/import/sel.d.ts +74 -0
- package/dist/import/types.d.ts +394 -0
- package/dist/index.d.ts +44 -0
- package/{types.d.ts → dist/types.d.ts} +96 -8
- package/package.json +33 -18
- package/src/ContextRecord.ts +243 -0
- package/src/DOMRenderExtension.ts +96 -0
- package/src/DOMRenderRuntime.ts +265 -0
- package/src/RenderContext.ts +168 -0
- package/src/compileDOMRenderConfigOverrides.ts +416 -0
- package/src/constants.ts +18 -0
- package/src/domOverride.ts +46 -0
- package/src/import/CoreImportExtension.ts +26 -0
- package/src/import/DOMImportExtension.ts +221 -0
- package/src/import/HorizontalRuleImportExtension.ts +52 -0
- package/src/import/ImportContext.ts +339 -0
- package/src/import/compileImportRules.ts +178 -0
- package/src/import/coreImportRules.ts +545 -0
- package/src/import/defineImportRule.ts +40 -0
- package/src/import/defineOverlayRules.ts +105 -0
- package/src/import/index.ts +97 -0
- package/src/import/inlineStylesFromStyleSheets.ts +104 -0
- package/src/import/parseCss.ts +219 -0
- package/src/import/runImport.ts +245 -0
- package/src/import/schemas.ts +280 -0
- package/src/import/sel.ts +314 -0
- package/src/import/types.ts +471 -0
- package/src/index.ts +561 -0
- package/src/types.ts +470 -0
- package/LexicalHtml.dev.js +0 -914
- package/LexicalHtml.dev.mjs +0 -900
- package/LexicalHtml.mjs +0 -24
- package/LexicalHtml.node.mjs +0 -22
- package/LexicalHtml.prod.js +0 -9
- package/LexicalHtml.prod.mjs +0 -9
- package/RenderContext.d.ts +0 -32
- package/domOverride.d.ts +0 -18
- package/index.d.ts +0 -32
- /package/{ContextRecord.d.ts → dist/ContextRecord.d.ts} +0 -0
- /package/{LexicalHtml.js → dist/LexicalHtml.js} +0 -0
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
BaseSelection,
|
|
13
13
|
DOMExportOutput,
|
|
14
14
|
EditorDOMRenderConfig,
|
|
15
|
-
|
|
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> = {
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
node:
|
|
77
|
+
readonly nodes: '*' | ReadonlyArray<NodeMatch<T>>,
|
|
78
|
+
readonly $getDOMSlot?: (
|
|
79
|
+
node: T,
|
|
80
80
|
dom: HTMLElement,
|
|
81
|
-
$next: () =>
|
|
81
|
+
$next: () => DOMSlotForNode<T>,
|
|
82
82
|
editor: LexicalEditor,
|
|
83
|
-
) =>
|
|
84
|
-
|
|
83
|
+
) => DOMSlotForNode<T>,
|
|
84
|
+
readonly $createDOM?: (
|
|
85
85
|
node: T,
|
|
86
86
|
$next: () => HTMLElement,
|
|
87
87
|
editor: LexicalEditor,
|
|
88
88
|
) => HTMLElement,
|
|
89
|
-
|
|
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
|
-
|
|
96
|
+
readonly $decorateDOM?: (
|
|
97
97
|
nextNode: T,
|
|
98
98
|
prevNode: T | null,
|
|
99
99
|
dom: HTMLElement,
|
|
100
100
|
editor: LexicalEditor,
|
|
101
101
|
) => void,
|
|
102
|
-
|
|
102
|
+
readonly $exportDOM?: (
|
|
103
103
|
node: T,
|
|
104
104
|
$next: () => DOMExportOutput,
|
|
105
105
|
editor: LexicalEditor,
|
|
106
106
|
) => DOMExportOutput,
|
|
107
|
-
|
|
107
|
+
readonly $shouldExclude?: (
|
|
108
108
|
node: T,
|
|
109
109
|
selection: null | BaseSelection,
|
|
110
110
|
$next: () => boolean,
|
|
111
111
|
editor: LexicalEditor,
|
|
112
112
|
) => boolean,
|
|
113
|
-
|
|
113
|
+
readonly $shouldInclude?: (
|
|
114
114
|
node: T,
|
|
115
115
|
selection: null | BaseSelection,
|
|
116
116
|
$next: () => boolean,
|
|
117
117
|
editor: LexicalEditor,
|
|
118
118
|
) => boolean,
|
|
119
|
-
|
|
119
|
+
readonly $extractWithChild?: (
|
|
120
120
|
node: T,
|
|
121
121
|
childNode: LexicalNode,
|
|
122
122
|
selection: null | BaseSelection,
|
|
@@ -0,0 +1,57 @@
|
|
|
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 $propagateTextAlignToBlockChildren = mod.$propagateTextAlignToBlockChildren;
|
|
24
|
+
export const $setRenderContextValue = mod.$setRenderContextValue;
|
|
25
|
+
export const $updateRenderContextValue = mod.$updateRenderContextValue;
|
|
26
|
+
export const $withImportContext = mod.$withImportContext;
|
|
27
|
+
export const $withRenderContext = mod.$withRenderContext;
|
|
28
|
+
export const BlockSchema = mod.BlockSchema;
|
|
29
|
+
export const CoreImportExtension = mod.CoreImportExtension;
|
|
30
|
+
export const CoreImportRules = mod.CoreImportRules;
|
|
31
|
+
export const DOMImportExtension = mod.DOMImportExtension;
|
|
32
|
+
export const DOMRenderExtension = mod.DOMRenderExtension;
|
|
33
|
+
export const HorizontalRuleImportExtension = mod.HorizontalRuleImportExtension;
|
|
34
|
+
export const HorizontalRuleImportRules = mod.HorizontalRuleImportRules;
|
|
35
|
+
export const ImportOverlays = mod.ImportOverlays;
|
|
36
|
+
export const ImportSource = mod.ImportSource;
|
|
37
|
+
export const ImportSourceDataTransfer = mod.ImportSourceDataTransfer;
|
|
38
|
+
export const ImportTextFormat = mod.ImportTextFormat;
|
|
39
|
+
export const ImportTextStyle = mod.ImportTextStyle;
|
|
40
|
+
export const ImportWhitespaceConfig = mod.ImportWhitespaceConfig;
|
|
41
|
+
export const InlineSchema = mod.InlineSchema;
|
|
42
|
+
export const NestedBlockSchema = mod.NestedBlockSchema;
|
|
43
|
+
export const RenderContextExport = mod.RenderContextExport;
|
|
44
|
+
export const RenderContextRoot = mod.RenderContextRoot;
|
|
45
|
+
export const RootSchema = mod.RootSchema;
|
|
46
|
+
export const contextUpdater = mod.contextUpdater;
|
|
47
|
+
export const contextValue = mod.contextValue;
|
|
48
|
+
export const createImportState = mod.createImportState;
|
|
49
|
+
export const createRenderState = mod.createRenderState;
|
|
50
|
+
export const defaultIsInline = mod.defaultIsInline;
|
|
51
|
+
export const defaultPreservesWhitespace = mod.defaultPreservesWhitespace;
|
|
52
|
+
export const defineImportRule = mod.defineImportRule;
|
|
53
|
+
export const defineOverlayRules = mod.defineOverlayRules;
|
|
54
|
+
export const domOverride = mod.domOverride;
|
|
55
|
+
export const isElementOfTag = mod.isElementOfTag;
|
|
56
|
+
export const parseSelector = mod.parseSelector;
|
|
57
|
+
export const sel = mod.sel;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 $propagateTextAlignToBlockChildren = mod.$propagateTextAlignToBlockChildren;
|
|
22
|
+
export const $setRenderContextValue = mod.$setRenderContextValue;
|
|
23
|
+
export const $updateRenderContextValue = mod.$updateRenderContextValue;
|
|
24
|
+
export const $withImportContext = mod.$withImportContext;
|
|
25
|
+
export const $withRenderContext = mod.$withRenderContext;
|
|
26
|
+
export const BlockSchema = mod.BlockSchema;
|
|
27
|
+
export const CoreImportExtension = mod.CoreImportExtension;
|
|
28
|
+
export const CoreImportRules = mod.CoreImportRules;
|
|
29
|
+
export const DOMImportExtension = mod.DOMImportExtension;
|
|
30
|
+
export const DOMRenderExtension = mod.DOMRenderExtension;
|
|
31
|
+
export const HorizontalRuleImportExtension = mod.HorizontalRuleImportExtension;
|
|
32
|
+
export const HorizontalRuleImportRules = mod.HorizontalRuleImportRules;
|
|
33
|
+
export const ImportOverlays = mod.ImportOverlays;
|
|
34
|
+
export const ImportSource = mod.ImportSource;
|
|
35
|
+
export const ImportSourceDataTransfer = mod.ImportSourceDataTransfer;
|
|
36
|
+
export const ImportTextFormat = mod.ImportTextFormat;
|
|
37
|
+
export const ImportTextStyle = mod.ImportTextStyle;
|
|
38
|
+
export const ImportWhitespaceConfig = mod.ImportWhitespaceConfig;
|
|
39
|
+
export const InlineSchema = mod.InlineSchema;
|
|
40
|
+
export const NestedBlockSchema = mod.NestedBlockSchema;
|
|
41
|
+
export const RenderContextExport = mod.RenderContextExport;
|
|
42
|
+
export const RenderContextRoot = mod.RenderContextRoot;
|
|
43
|
+
export const RootSchema = mod.RootSchema;
|
|
44
|
+
export const contextUpdater = mod.contextUpdater;
|
|
45
|
+
export const contextValue = mod.contextValue;
|
|
46
|
+
export const createImportState = mod.createImportState;
|
|
47
|
+
export const createRenderState = mod.createRenderState;
|
|
48
|
+
export const defaultIsInline = mod.defaultIsInline;
|
|
49
|
+
export const defaultPreservesWhitespace = mod.defaultPreservesWhitespace;
|
|
50
|
+
export const defineImportRule = mod.defineImportRule;
|
|
51
|
+
export const defineOverlayRules = mod.defineOverlayRules;
|
|
52
|
+
export const domOverride = mod.domOverride;
|
|
53
|
+
export const isElementOfTag = mod.isElementOfTag;
|
|
54
|
+
export const parseSelector = mod.parseSelector;
|
|
55
|
+
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"),C=()=>!0;function D(e,t,n){return m($,e,t,n)}const N=D("root",Boolean),I=D("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 k=h($,O);function T(e){return t=>t instanceof e}function R(e,{nodes:t}){if("*"===t)return C;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 b(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,B=w;function H(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 W(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=R(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,_,b),j(o,"$exportDOM",r,_,b),j(o,"$extractWithChild",r,W,A),j(o,"$getDOMSlot",r,P,B),j(o,"$shouldExclude",r,F,w),j(o,"$shouldInclude",r,F,w),j(o,"$updateDOM",r,H,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 Ce(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 De=ge("whitespaceConfig",()=>({isInline:Ce,preservesWhitespace:Ee})),Ne=ge("importOverlays",()=>[]);class Ie{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);function ke(e){return t.$isBlockElementNode(e)||t.$isDecoratorNode(e)&&!e.isInline()}function Te(e,n){if(!t.isHTMLElement(n))return e;const o=n.style.textAlign;if(!Pe(o))return e;for(const n of e)t.$isBlockElementNode(n)&&""===n.getFormatType()&&n.setFormat(o);return e}function Re(e,n,o){1===e.length&&t.$isLineBreakNode(e[0])&&(e=[]);const r=t.$createParagraphNode();if(t.isHTMLElement(o)){const e=o.style.textAlign;Pe(e)&&r.setFormat(e)}return[r.splice(0,0,e)]}const be={$accepts:ke,$packageRun:Re,name:"BlockSchema"},we={$accepts:e=>!ke(e),name:"InlineSchema"},Le={$accepts:ke,$packageRun:e=>e,name:"NestedBlockSchema"},Ae={$accepts:ke,$packageRun:Re,name:"RootSchema"},_e=ae,Fe=new Set(["center","end","justify","left","right","start"]);function Pe(e){return Fe.has(e)}const Be={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"}},He={CODE:t.IS_CODE,MARK:t.IS_HIGHLIGHT};const We=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Ue={$import:(e,n)=>{const o=e.get($e),r=Be[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=He[n.nodeName];return p&&(u|=p),u===o?e.$importChildren(n):e.$importChildren(n,{context:[d($e,u)]})},match:_e.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"};function je(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 ze(e,n){return 0!==n&&t.$isTextNode(e)?e.setFormat(n):e}function Ve(e,n){if(t.$isTextNode(e)){const t=function(e){let t="";for(const n in e)We.has(n)||(t+=`${n}: ${e[n]}; `);return t.trimEnd()}(n);""!==t&&e.setStyle(t)}return e}const Ge={$import:(e,n)=>{const o=e.get($e),r=e.get(Se),s=e.get(De);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)ze(t,o),Ve(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=je(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=je(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 ze(c,o),Ve(c,r),[c]},match:_e.text(),name:"@lexical/html/#text"},qe={$import:()=>[],match:_e.tag("script","style"),name:"@lexical/html/script-style-ignore"},Ke={$import:(e,n)=>t.isOnlyChildInBlockNode(n)||t.isLastChildInBlockNode(n)?[]:[t.$createLineBreakNode()],match:_e.tag("br"),name:"@lexical/html/br"},Je=[qe,{$import:(e,n)=>{const o=t.$createParagraphNode();if(t.$setFormatFromDOM(o,n),t.setNodeIndentFromDOM(n,o),""===o.getFormatType()){const e=n.getAttribute("align");e&&Pe(e)&&o.setFormat(e)}return t.$setDirectionFromDOM(o,n),[o.splice(0,0,e.$importChildren(n))]},match:_e.tag("p"),name:"@lexical/html/p"},{$import:(e,n,o)=>t.isBlockDomNode(n)?Te(e.$importChildren(n,{schema:be}),n):o(),match:_e.any(),name:"@lexical/html/transparent-block"},Ge,Ke,Ue];function Qe(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 Ye(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,Qe(t,o));return{byTag:l,commentIndices:i,rules:t,textIndices:s,wildcardIndices:o}}function Ze(e,n){return t.isDOMTextNode(n)?e.textIndices:8===n.nodeType?e.commentIndices:t.isHTMLElement(n)?e.byTag.get(n.nodeName)||e.wildcardIndices:Xe}const Xe=Object.freeze([]);function et(e){const t=[];for(const n of e)if(tt(n))for(const e of n.rules)t.push(e);else t.push(n);return t}function tt(e){return"object"==typeof e&&null!==e&&"__type"in e&&"CompiledOverlayRules"===e.__type}const nt=Object.freeze({});function ot(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=()=>rt(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)=>st(e,t,n),captures:t,get:t=>ve(t,e.editor),session:e.session};return n}function rt(e,t,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(t.childNodes)){const t=st(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 st(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=Ze(r,t);s.length>0&&n.push({dispatch:r,indices:s})}const o=Ze(e.dispatch,t);o.length>0&&n.push({dispatch:e.dispatch,indices:o});return n}(e,t);if(0===n.length)return it(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=ot(e,0===Object.keys(l).length?nt:l);try{return o.$import(n,t,s)}catch(e){throw e}}}o++,r=0}return it(e,t)};return s()}(e,t);return n&&n.context?Me(n.context,e.editor)(o):o()}function it(e,t){if(0===t.childNodes.length)return[];const n=[];for(const o of Array.from(t.childNodes)){const t=st(e,o,void 0);for(const e of t)n.push(e)}return n}const ct={$import:(e,t)=>e.$importChildren(t),match:ae.any(),name:"@lexical/html/default-hoist"},lt=t.defineExtension({build(e,n){const o=Ye(et(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 Ie(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 rt({dispatch:e,editor:n,overlays:r.get(Ne).map(e=>e.dispatch),session:r},t.isDOMDocumentNode(o)?o.body:o,{schema:Ae})}(o,e,n,u),e)},defaults:r}},config:{contextDefaults:[],preprocess:[g],rules:[ct]},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 ut=t.defineExtension({dependencies:[t.configExtension(lt,{rules:Je})],name:"@lexical/html/CoreImport"}),at=[{$import:()=>[o.$createHorizontalRuleNode()],match:ae.tag("hr"),name:"@lexical/html/hr"}],ft=t.defineExtension({dependencies:[o.HorizontalRuleExtension,t.configExtension(lt,{rules:at})],name:"@lexical/html/HorizontalRuleImport"}),dt={any:ae.any,comment:ae.comment,css:he,tag:ae.tag,text:ae.text},pt=new Set(["STYLE","SCRIPT"]);function ht(e,n=null,o=t.$getEditor()){return k([d(I,!0)],o)(()=>{const r=t.$getRoot(),s=M(o),i=e.append.bind(e);for(const e of r.getChildren())mt(o,e,i,n,s);return e})}function mt(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=mt(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 gt(e,n,o,r,s=new Map,i){const c=[];if(pt.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(...gt(d[e],n,o,h,new Map(s),l));if(null!=f&&(p=f(p)),t.isBlockDomNode(e)&&(p=xt(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 xt(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(ke(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=ht,exports.$generateDOMFromRoot=function(e,n=t.$getRoot()){const o=t.$getEditor();return k([d(I,!0),d(N,!0)],o)(()=>{const t=M(o),r=e.append.bind(e);return mt(o,n,r,null,t),e})},exports.$generateHtmlFromNodes=function(e,n=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&r(338),t.$assumeActiveEditor(e),ht(document.createElement("div"),n,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(!pt.has(t.nodeName)){const n=gt(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(lt).$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=ke,exports.$propagateTextAlignToBlockChildren=Te,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=k,exports.BlockSchema=be,exports.CoreImportExtension=ut,exports.CoreImportRules=Je,exports.DOMImportExtension=lt,exports.DOMRenderExtension=ee,exports.HorizontalRuleImportExtension=ft,exports.HorizontalRuleImportRules=at,exports.ImportOverlays=Ne,exports.ImportSource=xe,exports.ImportSourceDataTransfer=ye,exports.ImportTextFormat=$e,exports.ImportTextStyle=Se,exports.ImportWhitespaceConfig=De,exports.InlineSchema=we,exports.NestedBlockSchema=Le,exports.RenderContextExport=I,exports.RenderContextRoot=N,exports.RootSchema=Ae,exports.contextUpdater=function(e,t){return{cfg:e,updater:t}},exports.contextValue=d,exports.createImportState=ge,exports.createRenderState=D,exports.defaultIsInline=Ce,exports.defaultPreservesWhitespace=Ee,exports.defineImportRule=me,exports.defineOverlayRules=function(e){const t=et(e);return{__type:"CompiledOverlayRules",dispatch:Ye(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=dt;
|
|
@@ -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,$isElementNode as m,$isBlockElementNode as y,$isDecoratorNode as x,$isLineBreakNode as S,$createParagraphNode as $,IS_HIGHLIGHT as v,IS_CODE as b,$generateNodesFromRawText as C,$createTextNode as k,isOnlyChildInBlockNode as O,isLastChildInBlockNode as w,$createLineBreakNode as D,$setFormatFromDOM as M,setNodeIndentFromDOM as A,$setDirectionFromDOM as N,$isTextNode as I,IS_BOLD as E,IS_ITALIC as W,IS_UNDERLINE as R,IS_STRIKETHROUGH as F,IS_SUBSCRIPT as T,IS_SUPERSCRIPT as j,configExtension as P,$getRoot as z,$assumeActiveEditor as _,isDocumentFragment as L,$isRootOrShadowRoot as U,ArtificialNode__DO_NOT_USE as B}from"lexical";import{objectKlassEquals as V}from"@lexical/utils";import{getPeerDependencyFromEditor as q,getKnownTypesAndNodes as G,$getExtensionOutput as H,HorizontalRuleExtension as J,$createHorizontalRuleNode as Q}from"@lexical/extension";function K(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 Y;function Z(t,e){const{key:n}=e;return t&&n in t?t[n]:e.defaultValue}function X(t){return Y&&Y.editor===t?Y:void 0}function tt(t,e){const n=X(e);return n&&n[t]}function et(t,e){if("cfg"in e){const{cfg:n,updater:o}=e;return[n,o(Z(t,n))]}return e}function nt(t,e){let n=e;for(const o of t){const[t,r]=et(n,o),s=t.key;if(n===e&&Z(n,t)===r)continue;const i=n===e||void 0===n?ot(e):n;i[s]=r,n=i}return n}function ot(t){return Object.create(t||null)}function rt(t,e){return[t,e]}function st(t,e){return{cfg:t,updater:e}}function it(t,n,o,r=e()){const s=Y,i=X(r);try{return Y={...i,editor:r,[t]:n},o()}finally{Y=s}}function ct(t,n=()=>{}){return(o,r=e())=>e=>{const s=X(r),i=s&&s[t],c=nt(o,i||n(r));return c&&c!==i?it(t,c,e,r):e()}}function lt(t,e,o,r){return Object.assign(n(Symbol(e),{isEqual:r,parse:o}),{[t]:!0})}const ut=(t,e,n)=>{ft(t),n()};function ft(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(!V(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 at="@lexical/html/DOM",pt=Symbol.for("@lexical/html/DOMExportContext"),dt="@lexical/html/DOMImport",ht=Symbol.for("@lexical/html/DOMImportContext"),gt=()=>!0;function mt(t,e,n){return lt(pt,t,e,n)}const yt=mt("root",Boolean),xt=mt("isExport",Boolean);function St(t){const e=q(t,at);return e?e.output.defaults:void 0}function $t(t,n=e()){return Z(function(t){return tt(pt,t)||St(t)}(n),t)}function vt(t){const e=q(t,at);return e?e.output.runtime:void 0}function bt(t,n,o=e()){const r=vt(o);r&&r.setContextValue(t,n)}function Ct(t,n,o=e()){const r=vt(o);r&&r.setContextValue(t,n(Z(r.editorContext,t)))}function kt(t=e()){const n=vt(t);return n?n.getSessionConfig():s(t)}const Ot=ct(pt,St);function wt(t,e,n){return{...e,...n,nodes:t}}function Dt(t){return e=>e instanceof t}function Mt(t,{nodes:e}){if("*"===e)return gt;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&&K(339,r.name,e),n=Object.assign(n,o.types)}o.push(Dt(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 At(t){return(e,n,o)=>t(e,o)}function Nt(t){return(e,n,o,r)=>t(e,n,r)}function It(t){return(e,n,o,r,s)=>t(e,n,o,s)}function Et(t){return(e,n,o,r,s,i)=>t(e,n,o,r,i)}function Wt(t,e){return(n,o)=>{const r=()=>t(n,o),s=e(n);return s?s(n,r,o):r()}}function Rt(t,e){return(n,o,r)=>{const s=()=>t(n,o,r),i=e(n);return i?i(n,o,s,r):s()}}const Ft=Rt,Tt=Nt;function jt(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 Pt(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 zt(t,e){return(n,o,r,s)=>{t(n,o,r,s);const i=e(n);i&&i(n,o,r,s)}}function _t(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 Lt(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 Ut(t){return"*"===t.nodes}function Bt(t,e){const n=function(t){const e={},{nodes:n}=G(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(Ut(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=Mt(n,t);for(const n in o){Lt(o,n,e,t[n])}}return o}function Vt(t){return t}function qt(t,{overrides:e}){const n=Bt(t,e),o={...i,...t.dom};return _t(n,"$createDOM",o,Wt,At),_t(n,"$exportDOM",o,Wt,At),_t(n,"$extractWithChild",o,Pt,Et),_t(n,"$getDOMSlot",o,Ft,Tt),_t(n,"$shouldExclude",o,Rt,Nt),_t(n,"$shouldInclude",o,Rt,Nt),_t(n,"$updateDOM",o,jt,It),_t(n,"$decorateDOM",o,zt,Vt),o}function Gt(t){return{get:e=>Z(t,e)}}function Ht(t){const e=Object.create(null);return nt(t,e)||e}function Jt(t,e){const n=Gt(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 Kt{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=Jt(n,o),this.hasSessionGates=n.some(t=>t.disabledForSession)}setContextValue(t,e){const n=this.installed;this.editorContext[t.key]=e;const o=Jt(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=qt(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=Gt(tt(pt,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=qt(this.initialEditorConfig,{overrides:o}),this.sessionCache.set(r,s)),s}}const Yt=f({build(t,e,n){const{initialEditorConfig:o}=n.getInitResult(),r=Ht(e.contextDefaults);return{defaults:r,runtime:new Kt(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=Ht(e.contextDefaults),r=Jt(e.overrides,o);return t.dom=qt(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:at}),Zt=Symbol.for("@lexical/html/SelectorImpl");function Xt(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=>Xt(t,[...e,n]);return{[Zt]:n,attr:(t,e,n)=>s(ne(t,e,n)),classAll:(...t)=>s(ee(t)),classAny:(...t)=>s(function(t){const e=te(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)}}K(362,JSON.stringify(t))}(t,e,n))}}function te(t){const e=[];for(const n of t)n&&e.push(n);return e}function ee(t){const e=te(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 ne(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)}}K(361,JSON.stringify(t))}const oe={kind:"text",predicate:d,tags:new Set},re={[Zt]:oe},se={kind:"comment",predicate:t=>8===t.nodeType,tags:new Set},ie={[Zt]:se},ce={any:()=>Xt(new Set,[]),comment:()=>ie,tag(...t){t.length>0||K(363);const e=new Set;for(const n of t)e.add(n.toUpperCase());return Xt(e,[])},text:()=>re};function le(t,e){return r(t)&&t.nodeName===e.toUpperCase()}const ue=/[A-Za-z0-9_-]/;class fe{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()&&ue.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||K(364,String(this.pos+1),e,this.source)}}function ae(t){const e=new Set,n=[],o=[];if(t.skipWhitespace(),"*"===t.peek())t.consume();else if(ue.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(ne("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(ne(e,o))}}}return o.length>0&&n.push(ee(o)),{predicates:n,tags:e}}function pe(t){const e=new fe(t,0),n=[];for(;;){const t=ae(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 Xt(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 Xt(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 de(t){return t}function he(t,e,n){return lt(ht,t,e,n)}const ge=he("importSource",()=>"unknown"),me=he("importSourceDataTransfer",()=>null),ye=he("textFormat",()=>0),xe=he("textStyle",()=>({}));function Se(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 $e(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 ve=he("whitespaceConfig",()=>({isInline:$e,preservesWhitespace:Se})),be=he("importOverlays",()=>[]);class Ce{constructor(t){this.record=t}get(t){return Z(this.record,t)}set(t,e){this.record[t.key]=e}update(t,e){this.record[t.key]=e(Z(this.record,t))}has(t){return Object.prototype.hasOwnProperty.call(this.record,t.key)}}function ke(t){const e=q(t,dt);return e?e.output.defaults:void 0}function Oe(t,n=e()){return Z(function(t){return tt(ht,t)||ke(t)}(n),t)}const we=ct(ht,ke);function De(t){return y(t)||x(t)&&!t.isInline()}function Me(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(De(s)){if(r(),m(s)){const t=Me(s.getChildren(),e);s.splice(0,s.getChildrenSize(),t)}n.push(s)}else o.push(s);return r(),n}function Ae(t,e){if(!r(e))return t;const n=e.style.textAlign;if(!je(n))return t;for(const e of t)y(e)&&""===e.getFormatType()&&e.setFormat(n);return t}function Ne(t,e,n){1===t.length&&S(t[0])&&(t=[]);const o=$();if(r(n)){const t=n.style.textAlign;je(t)&&o.setFormat(t)}return[o.splice(0,0,t)]}const Ie={$accepts:De,$packageRun:Ne,name:"BlockSchema"},Ee={$accepts:t=>!De(t),name:"InlineSchema"},We={$accepts:De,$packageRun:t=>t,name:"NestedBlockSchema"},Re={$accepts:De,$packageRun:Ne,name:"RootSchema"},Fe=ce,Te=new Set(["center","end","justify","left","right","start"]);function je(t){return Te.has(t)}const Pe={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"}},ze={CODE:b,MARK:v};const _e=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Le={$import:(t,e)=>{const n=t.get(ye),o=Pe[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|=E:"normal"!==o&&"400"!==o||(n|=E),"italic"===r?e|=W:"normal"===r&&(n|=W),s){const t=s.split(" ");t.includes("underline")&&(e|=R),t.includes("line-through")&&(e|=F),t.includes("none")&&(n|=R|F)}return"sub"===i?(e|=T,n|=j):"super"===i?(e|=j,n|=T):"baseline"===i&&(n|=T|j),{clear:n,set:e}}(s),u&~f.clear|f.set);var u,f;const a=ze[e.nodeName];return a&&(l|=a),l===n?t.$importChildren(e):t.$importChildren(e,{context:[rt(ye,l)]})},match:Fe.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"};function Ue(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 Be(t,e){return 0!==e&&I(t)?t.setFormat(e):t}function Ve(t,e){if(I(t)){const n=function(t){let e="";for(const n in t)_e.has(n)||(e+=`${n}: ${t[n]}; `);return e.trimEnd()}(e);""!==n&&t.setStyle(n)}return t}const qe={$import:(t,e)=>{const n=t.get(ye),o=t.get(xe),r=t.get(ve);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=C(e.textContent||"");for(const e of t)Be(e,n),Ve(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=Ue(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=Ue(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=k(s);return Be(i,n),Ve(i,o),[i]},match:Fe.text(),name:"@lexical/html/#text"},Ge={$import:()=>[],match:Fe.tag("script","style"),name:"@lexical/html/script-style-ignore"},He={$import:(t,e)=>O(e)||w(e)?[]:[D()],match:Fe.tag("br"),name:"@lexical/html/br"},Je=[Ge,{$import:(t,e)=>{const n=$();if(M(n,e),A(e,n),""===n.getFormatType()){const t=e.getAttribute("align");t&&je(t)&&n.setFormat(t)}return N(n,e),[n.splice(0,0,t.$importChildren(e))]},match:Fe.tag("p"),name:"@lexical/html/p"},{$import:(t,e,n)=>h(e)?Ae(t.$importChildren(e,{schema:Ie}),e):n(),match:Fe.any(),name:"@lexical/html/transparent-block"},qe,He,Le];function Qe(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 Ke(t){const e=[],n=new Map,o=[],r=[],s=[],i=new Set;t.forEach((t,c)=>{const l=function(t){const e=t[Zt];return void 0===e&&K(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,Qe(e,o));return{byTag:c,commentIndices:s,rules:e,textIndices:r,wildcardIndices:o}}function Ye(t,e){return d(e)?t.textIndices:8===e.nodeType?t.commentIndices:r(e)?t.byTag.get(e.nodeName)||t.wildcardIndices:Ze}const Ze=Object.freeze([]);function Xe(t){const e=[];for(const n of t)if(tn(n))for(const t of n.rules)e.push(t);else e.push(n);return e}function tn(t){return"object"==typeof t&&null!==t&&"__type"in t&&"CompiledOverlayRules"===t.__type}function en(t){const e=Xe(t);return{__type:"CompiledOverlayRules",dispatch:Ke(e),rules:e}}const nn=Object.freeze({});function on(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=()=>rn(t,e,n);return n&&n.context?we(n.context,t.editor)(o):o()}finally{o&&t.overlays.pop()}}(t,e,n),$importOne:(e,n)=>sn(t,e,n),captures:e,get:e=>Oe(e,t.editor),session:t.session};return n}function rn(t,e,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(e.childNodes)){const e=sn(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 sn(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=Ye(r,e);s.length>0&&n.push({dispatch:r,indices:s})}const o=Ye(t.dispatch,e);o.length>0&&n.push({dispatch:t.dispatch,indices:o});return n}(t,e);if(0===n.length)return cn(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=on(t,0===Object.keys(l).length?nn:l);try{return o.$import(n,e,s)}catch(t){throw t}}}o++,r=0}return cn(t,e)};return s()}(t,e);return n&&n.context?we(n.context,t.editor)(o):o()}function cn(t,e){if(0===e.childNodes.length)return[];const n=[];for(const o of Array.from(e.childNodes)){const e=sn(t,o,void 0);for(const t of e)n.push(t)}return n}const ln={$import:(t,e)=>t.$importChildren(e),match:ce.any(),name:"@lexical/html/default-hoist"},un=f({build(t,e){const n=Ke(Xe(e.rules)),r=nt(e.contextDefaults,void 0),s=e.preprocess;return{$generateNodesFromDOM:(e,i)=>{const c=i&&i.context?nt(i.context,r):r,l=void 0!==c&&c!==r?c:Object.create(r||null),u=new Ce(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),it(ht,l,()=>function(t,e,n,r){return rn({dispatch:t,editor:e,overlays:r.get(be).map(t=>t.dispatch),session:r},o(n)?n.body:n,{schema:Re})}(n,t,e,u),t)},defaults:r}},config:{contextDefaults:[],preprocess:[ut],rules:[ln]},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:dt});function fn(t,e){return H(un).$generateNodesFromDOM(t,e)}const an=f({dependencies:[P(un,{rules:Je})],name:"@lexical/html/CoreImport"}),pn=[{$import:()=>[Q()],match:ce.tag("hr"),name:"@lexical/html/hr"}],dn=f({dependencies:[J,P(un,{rules:pn})],name:"@lexical/html/HorizontalRuleImport"}),hn={any:ce.any,comment:ce.comment,css:pe,tag:ce.tag,text:ce.text},gn=new Set(["STYLE","SCRIPT"]);function mn(t,e){ft(e);const n=o(e)?e.body.childNodes:e.childNodes,r=[],s=[];for(const e of n)if(!gn.has(e.nodeName)){const n=vn(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 B&&e.insertAfter(D());for(const e of t){const t=e.getParent();t&&t.splice(e.getIndexWithinParent(),1,e.getChildren())}}(s),r}function yn(t,n=null,o=e()){return Ot([rt(xt,!0)],o)(()=>{const e=z(),r=kt(o),s=t.append.bind(t);for(const t of e.getChildren())$n(o,t,s,n,r);return t})}function xn(t,n=z()){const o=e();return Ot([rt(xt,!0),rt(yt,!0)],o)(()=>{const e=kt(o),r=t.append.bind(t);return $n(o,n,r,null,e),t})}function Sn(t,e=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&K(338),_(t),yn(document.createElement("div"),e,t).innerHTML}function $n(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&&I(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 y=document.createDocumentFragment(),x=g?g():m(f)?f.getChildren():[],S=y.append.bind(y);for(const t of x){const o=$n(e,t,S,i,c);!l&&o&&c.$extractWithChild(n,t,i,"html",e)&&(l=!0)}if(l&&!u){if((r(p)||L(p))&&(h?h(y):p.append(y)),o(p),d){const t=d.call(f,p);t&&(L(p)?p.replaceChildren(t):p.replaceWith(t))}}else o(y);return l}function vn(t,e,n,o,r=new Map,s){const i=[];if(gn.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||!U(c))&&(null!=c&&y(c)||o);for(let t=0;t<a.length;t++)p.push(...vn(a[t],e,n,d,new Map(r),c));if(null!=f&&(p=f(p)),h(t)&&(p=bn(t,p,d?()=>{const t=new B;return n.push(t),t}:$)),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(D());else m(c)&&c.append(...p);return i}function bn(t,e,n){const o=t.style.textAlign,r=[];let s=[];for(let t=0;t<e.length;t++){const i=e[t];if(y(i))o&&!i.getFormat()&&i.setFormat(o),r.push(i);else if(s.push(i),t===e.length-1||t<e.length-1&&y(e[t+1])){const t=n();t.setFormat(o),t.append(...s),r.push(t),s=[]}}return r}export{Me as $distributeInlineWrapper,yn as $generateDOMFromNodes,xn as $generateDOMFromRoot,Sn as $generateHtmlFromNodes,mn as $generateNodesFromDOM,fn as $generateNodesFromDOMViaExtension,Oe as $getImportContextValue,$t as $getRenderContextValue,kt as $getSessionDOMRenderConfig,ut as $inlineStylesFromStyleSheets,De as $isBlockLevel,Ae as $propagateTextAlignToBlockChildren,bt as $setRenderContextValue,Ct as $updateRenderContextValue,we as $withImportContext,Ot as $withRenderContext,Ie as BlockSchema,an as CoreImportExtension,Je as CoreImportRules,un as DOMImportExtension,Yt as DOMRenderExtension,dn as HorizontalRuleImportExtension,pn as HorizontalRuleImportRules,be as ImportOverlays,ge as ImportSource,me as ImportSourceDataTransfer,ye as ImportTextFormat,xe as ImportTextStyle,ve as ImportWhitespaceConfig,Ee as InlineSchema,We as NestedBlockSchema,xt as RenderContextExport,yt as RenderContextRoot,Re as RootSchema,st as contextUpdater,rt as contextValue,he as createImportState,mt as createRenderState,$e as defaultIsInline,Se as defaultPreservesWhitespace,de as defineImportRule,en as defineOverlayRules,wt as domOverride,le as isElementOfTag,pe as parseSelector,hn 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,28 @@
|
|
|
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} together with the runtime
|
|
16
|
+
* {@link HorizontalRuleExtension}. The application is expected to
|
|
17
|
+
* already have `CoreImportExtension` (or some equivalent) in its
|
|
18
|
+
* dependency graph — the core/text/paragraph/inline-format rules are a
|
|
19
|
+
* shared baseline, not something this leaf importer should re-declare.
|
|
20
|
+
*
|
|
21
|
+
* Lives in `@lexical/html` (not `@lexical/extension`) because
|
|
22
|
+
* {@link DOMImportExtension} itself is in `@lexical/html`, and
|
|
23
|
+
* `@lexical/extension` is upstream of `@lexical/html` in the dependency
|
|
24
|
+
* graph.
|
|
25
|
+
*
|
|
26
|
+
* @experimental
|
|
27
|
+
*/
|
|
28
|
+
export declare const HorizontalRuleImportExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/html/HorizontalRuleImport", unknown, unknown>;
|