@lexical/html 0.47.1-nightly.20260715.0 → 0.48.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/dist/LexicalHtml.dev.js
CHANGED
|
@@ -2814,12 +2814,17 @@ const DOMImportExtension = /* @__PURE__ */lexical.defineExtension({
|
|
|
2814
2814
|
return {
|
|
2815
2815
|
$generateNodesFromDOM: (dom, options) => {
|
|
2816
2816
|
// The session record IS the root layer of the walk's context.
|
|
2817
|
-
//
|
|
2818
|
-
//
|
|
2819
|
-
//
|
|
2820
|
-
//
|
|
2821
|
-
|
|
2822
|
-
|
|
2817
|
+
// When this import runs nested inside another import operation —
|
|
2818
|
+
// e.g. raw HTML inside a Markdown import, or a rule re-entering
|
|
2819
|
+
// the walk for sub-content — it chains to the ambient import
|
|
2820
|
+
// context so states layered by the outer operation stay
|
|
2821
|
+
// readable; the outermost call chains to the editor's
|
|
2822
|
+
// contextDefaults. Per-call options.context applies on top,
|
|
2823
|
+
// and the record is always a *fresh* mutable child (never the
|
|
2824
|
+
// shared parent) so session.set writes never leak outward.
|
|
2825
|
+
const parentRecord = getContextRecord(DOMImportContextSymbol, editor) || defaults;
|
|
2826
|
+
const fromOpts = options && options.context ? contextFromPairs(options.context, parentRecord) : parentRecord;
|
|
2827
|
+
const sessionRecord = fromOpts !== undefined && fromOpts !== parentRecord ? fromOpts : Object.create(parentRecord || null);
|
|
2823
2828
|
const session = new ImportSessionImpl(sessionRecord);
|
|
2824
2829
|
const preprocessCtx = {
|
|
2825
2830
|
session
|
package/dist/LexicalHtml.dev.mjs
CHANGED
|
@@ -2812,12 +2812,17 @@ const DOMImportExtension = /* @__PURE__ */defineExtension({
|
|
|
2812
2812
|
return {
|
|
2813
2813
|
$generateNodesFromDOM: (dom, options) => {
|
|
2814
2814
|
// The session record IS the root layer of the walk's context.
|
|
2815
|
-
//
|
|
2816
|
-
//
|
|
2817
|
-
//
|
|
2818
|
-
//
|
|
2819
|
-
|
|
2820
|
-
|
|
2815
|
+
// When this import runs nested inside another import operation —
|
|
2816
|
+
// e.g. raw HTML inside a Markdown import, or a rule re-entering
|
|
2817
|
+
// the walk for sub-content — it chains to the ambient import
|
|
2818
|
+
// context so states layered by the outer operation stay
|
|
2819
|
+
// readable; the outermost call chains to the editor's
|
|
2820
|
+
// contextDefaults. Per-call options.context applies on top,
|
|
2821
|
+
// and the record is always a *fresh* mutable child (never the
|
|
2822
|
+
// shared parent) so session.set writes never leak outward.
|
|
2823
|
+
const parentRecord = getContextRecord(DOMImportContextSymbol, editor) || defaults;
|
|
2824
|
+
const fromOpts = options && options.context ? contextFromPairs(options.context, parentRecord) : parentRecord;
|
|
2825
|
+
const sessionRecord = fromOpts !== undefined && fromOpts !== parentRecord ? fromOpts : Object.create(parentRecord || null);
|
|
2821
2826
|
const session = new ImportSessionImpl(sessionRecord);
|
|
2822
2827
|
const preprocessCtx = {
|
|
2823
2828
|
session
|
package/dist/LexicalHtml.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
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 $="@lexical/html/DOM",y=Symbol.for("@lexical/html/DOMExportContext"),S="@lexical/html/DOMImport",E=Symbol.for("@lexical/html/DOMImportContext"),D=()=>!0;function C(e,t,n){return m(y,e,t,n)}const N=/* @__PURE__ */C("root",Boolean),I=/* @__PURE__ */C("isExport",Boolean);function O(e){const t=o.getPeerDependencyFromEditor(e,$);return t?t.output.defaults:void 0}function M(e){const t=o.getPeerDependencyFromEditor(e,$);return t?t.output.runtime:void 0}function v(e=t.$getEditor()){const n=M(e);return n?n.getSessionConfig():t.$getEditorDOMRenderConfig(e)}const R=h(y,O);function T(e){return t=>t instanceof e}function k(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.get(t);void 0===o&&r(339,s.name,t);for(const e of o)n[e]=!0}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 A(e){return(t,n,o,r,s)=>e(t,n,o,s)}function L(e){return(t,n,o,r,s,i)=>e(t,n,o,r,i)}function F(e,t){return(n,o)=>{const r=()=>e(n,o),s=t(n);return s?s(n,r,o):r()}}function _(e,t){return(n,o,r)=>{const s=()=>e(n,o,r),i=t(n);return i?i(n,o,s,r):s()}}const H=_,B=w;function P(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 z(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 j(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=t.getRegisteredSubtypeMap(o.getKnownTypesAndNodes(e).nodes),s={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$getSlotTargetElement:[],$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=-1;for(const o of t.iterStaticNodeConfigChain(e))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=k(r,e);for(const n in s){j(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 z(o,"$createDOM",r,F,b),z(o,"$exportDOM",r,F,b),z(o,"$extractWithChild",r,W,L),z(o,"$getDOMSlot",r,H,B),z(o,"$shouldExclude",r,_,w),z(o,"$shouldInclude",r,_,w),z(o,"$getSlotTargetElement",r,P,A),z(o,"$updateDOM",r,P,A),z(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(y,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=/* @__PURE__ */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=t.$getDocument().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:$}),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=/* @__PURE__ */ge("importSource",()=>"unknown"),$e=/* @__PURE__ */ge("importSourceDataTransfer",()=>null),ye=/* @__PURE__ */ge("textFormat",()=>0),Se=/* @__PURE__ */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=/* @__PURE__ */ge("whitespaceConfig",()=>({isInline:De,preservesWhitespace:Ee})),Ne=/* @__PURE__ */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 Me(e,n=t.$getEditor()){return i(function(e){return l(E,e)||Oe(e)}(n),e)}const ve=h(E,Oe);function Re(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(!He(o))return e;for(const n of e)t.$isBlockElementNode(n)&&""===n.getFormatType()&&n.setFormat(o);return e}function ke(e,n,o){1===e.length&&t.$isLineBreakNode(e[0])&&(e=[]);const r=t.$createParagraphNode();if(t.isHTMLElement(o)){const e=o.style.textAlign;He(e)&&r.setFormat(e)}return[r.splice(0,0,e)]}const be={$accepts:Re,$packageRun:ke,name:"BlockSchema"},we={$accepts:e=>!Re(e),name:"InlineSchema"},Ae={$accepts:Re,$packageRun:e=>e,name:"NestedBlockSchema"},Le={$accepts:Re,$packageRun:ke,name:"RootSchema"},Fe=ae,_e=new Set(["center","end","justify","left","right","start"]);function He(e){return _e.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"}},Pe={CODE:t.IS_CODE,MARK:t.IS_HIGHLIGHT};const We=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Ue=/* @__PURE__ */me({$import:(e,n)=>{const o=e.get(ye),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=Pe[n.nodeName];return p&&(u|=p),u===o?e.$importChildren(n):e.$importChildren(n,{context:[d(ye,u)]})},match:Fe.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"});function ze(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 je(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=/* @__PURE__ */me({$import:(e,n)=>{const o=e.get(ye),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)je(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=ze(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=ze(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 je(c,o),Ve(c,r),[c]},match:Fe.text(),name:"@lexical/html/#text"}),qe=/* @__PURE__ */me({$import:()=>[],match:Fe.tag("script","style"),name:"@lexical/html/script-style-ignore"}),Ke=/* @__PURE__ */me({$import:(e,n)=>t.isOnlyChildInBlockNode(n)||t.isLastChildInBlockNode(n)?[]:[t.$createLineBreakNode()],match:Fe.tag("br"),name:"@lexical/html/br"}),Je=/* @__PURE__ */me({$import:(e,n)=>{const o=t.$createParagraphNode();if(t.$setFormatFromDOM(o,n),t.setNodeIndentFromDOM(n,o),""===o.getFormatType()){const e=n.getAttribute("align");e&&He(e)&&o.setFormat(e)}return t.$setDirectionFromDOM(o,n),[o.splice(0,0,e.$importChildren(n))]},match:Fe.tag("p"),name:"@lexical/html/p"}),Qe=/* @__PURE__ */me({$import:(e,n,r)=>t.$getEditor().hasNode(o.HorizontalRuleNode)?[o.$createHorizontalRuleNode()]:r(),match:Fe.tag("hr"),name:"@lexical/html/hr"}),Ye=[qe,Je,Qe,/* @__PURE__ */me({$import:(e,n,o)=>t.isBlockDomNode(n)?Te(e.$importChildren(n,{schema:be}),n):o(),match:Fe.any(),name:"@lexical/html/transparent-block"}),Ge,Ke,Ue];function Ze(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 Xe(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,Ze(t,o));return{byTag:l,commentIndices:i,rules:t,textIndices:s,wildcardIndices:o}}function et(e,n){return t.isDOMTextNode(n)?e.textIndices:8===n.nodeType?e.commentIndices:t.isHTMLElement(n)?e.byTag.get(n.nodeName)||e.wildcardIndices:tt}const tt=Object.freeze([]);function nt(e){const t=[];for(const n of e)if(ot(n))for(const e of n.rules)t.push(e);else t.push(n);return t}function ot(e){return"object"==typeof e&&null!==e&&"__type"in e&&"CompiledOverlayRules"===e.__type}const rt=Object.freeze({});function st(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=()=>it(e,t,n);return n&&n.context?ve(n.context,e.editor)(o):o()}finally{o&&e.overlays.pop()}}(e,t,n),$importOne:(t,n)=>ct(e,t,n),captures:t,get:t=>Me(t,e.editor),session:e.session};return n}function it(e,t,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(t.childNodes)){const t=ct(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 ct(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=et(r,t);s.length>0&&n.push({dispatch:r,indices:s})}const o=et(e.dispatch,t);o.length>0&&n.push({dispatch:e.dispatch,indices:o});return n}(e,t);if(0===n.length)return lt(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=st(e,0===Object.keys(l).length?rt:l);try{return o.$import(n,t,s)}catch(e){throw e}}}o++,r=0}return lt(e,t)};return s()}(e,t);return n&&n.context?ve(n.context,e.editor)(o):o()}function lt(e,t){if(0===t.childNodes.length)return[];const n=[];for(const o of Array.from(t.childNodes)){const t=ct(e,o,void 0);for(const e of t)n.push(e)}return n}const ut=/* @__PURE__ */me({$import:(e,t)=>e.$importChildren(t),match:ae.any(),name:"@lexical/html/default-hoist"}),at=/* @__PURE__ */t.defineExtension({build(e,n){const o=Xe(nt(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 it({dispatch:e,editor:n,overlays:r.get(Ne).map(e=>e.dispatch),session:r},t.isDOMDocumentNode(o)?o.body:o,{schema:Le})}(o,e,n,u),e)},defaults:r}},config:{contextDefaults:[],preprocess:[g],rules:[ut]},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 ft=/* @__PURE__ */t.defineExtension({dependencies:[/* @__PURE__ */t.configExtension(at,{rules:Ye})],name:"@lexical/html/CoreImport"}),dt=[Qe],pt=/* @__PURE__ */t.defineExtension({dependencies:[o.HorizontalRuleExtension,ft],name:"@lexical/html/HorizontalRuleImport"}),ht={any:ae.any,comment:ae.comment,css:he,tag:ae.tag,text:ae.text},mt=new Set(["STYLE","SCRIPT"]);function gt(e,n=null,o=t.$getEditor()){return R([d(I,!0)],o)(()=>{const r=t.$getRoot(),s=v(o),i=t.$isRangeSelection(n)?t.$getSlotFrame(n.anchor.getNode()):null,c=e.append.bind(e);for(const e of(t.$isElementNode(i)?i:r).getChildren())xt(o,e,c,n,s);return e})}function xt(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=t.$getDocument().createDocumentFragment(),g=h?h():t.$isElementNode(u)?u.getChildren():[],x=c&&t.$isNodeSelection(s)&&t.$isElementNode(o)?null:s,$=m.append.bind(m);for(const e of g){const t=xt(n,e,$,x,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 $t(e,n,o,r,s=new Map,i){const c=[];if(mt.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(...$t(d[e],n,o,h,new Map(s),l));if(null!=f&&(p=f(p)),t.isBlockDomNode(e)&&(p=yt(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 yt(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.$appendNodeToHTML=function(e,t,n,o=null){return xt(e,t,n.append.bind(n),o,v(e))},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(Re(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=gt,exports.$generateDOMFromRoot=function(e,n=t.$getRoot()){const o=t.$getEditor();return R([d(I,!0),d(N,!0)],o)(()=>{const t=v(o),r=e.append.bind(e);return xt(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),gt(t.$getDocument().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(!mt.has(t.nodeName)){const n=$t(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(at).$generateNodesFromDOM(e,t)},exports.$getImportContextValue=Me,exports.$getRenderContextValue=function(e,n=t.$getEditor()){return i(function(e){return l(y,e)||O(e)}(n),e)},exports.$getSessionDOMRenderConfig=v,exports.$inlineStylesFromStyleSheets=g,exports.$isBlockLevel=Re,exports.$propagateTextAlignToBlockChildren=Te,exports.$setRenderContextValue=function(e,n,o=t.$getEditor()){const r=M(o);r&&r.setContextValue(e,n)},exports.$updateRenderContextValue=function(e,n,o=t.$getEditor()){const r=M(o);r&&r.setContextValue(e,n(i(r.editorContext,e)))},exports.$withImportContext=ve,exports.$withRenderContext=R,exports.BlockSchema=be,exports.CoreImportExtension=ft,exports.CoreImportRules=Ye,exports.DOMImportExtension=at,exports.DOMRenderExtension=ee,exports.HorizontalRuleImportExtension=pt,exports.HorizontalRuleImportRules=dt,exports.ImportOverlays=Ne,exports.ImportSource=xe,exports.ImportSourceDataTransfer=$e,exports.ImportTextFormat=ye,exports.ImportTextStyle=Se,exports.ImportWhitespaceConfig=Ce,exports.InlineSchema=we,exports.NestedBlockSchema=Ae,exports.RenderContextExport=I,exports.RenderContextRoot=N,exports.RootSchema=Le,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=nt(e);return{__type:"CompiledOverlayRules",dispatch:Xe(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=ht;
|
|
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 $="@lexical/html/DOM",y=Symbol.for("@lexical/html/DOMExportContext"),S="@lexical/html/DOMImport",E=Symbol.for("@lexical/html/DOMImportContext"),D=()=>!0;function C(e,t,n){return m(y,e,t,n)}const N=/* @__PURE__ */C("root",Boolean),I=/* @__PURE__ */C("isExport",Boolean);function O(e){const t=o.getPeerDependencyFromEditor(e,$);return t?t.output.defaults:void 0}function M(e){const t=o.getPeerDependencyFromEditor(e,$);return t?t.output.runtime:void 0}function v(e=t.$getEditor()){const n=M(e);return n?n.getSessionConfig():t.$getEditorDOMRenderConfig(e)}const R=h(y,O);function T(e){return t=>t instanceof e}function k(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.get(t);void 0===o&&r(339,s.name,t);for(const e of o)n[e]=!0}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 A(e){return(t,n,o,r,s)=>e(t,n,o,s)}function L(e){return(t,n,o,r,s,i)=>e(t,n,o,r,i)}function F(e,t){return(n,o)=>{const r=()=>e(n,o),s=t(n);return s?s(n,r,o):r()}}function _(e,t){return(n,o,r)=>{const s=()=>e(n,o,r),i=t(n);return i?i(n,o,s,r):s()}}const H=_,B=w;function P(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 z(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 j(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=t.getRegisteredSubtypeMap(o.getKnownTypesAndNodes(e).nodes),s={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$getSlotTargetElement:[],$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=-1;for(const o of t.iterStaticNodeConfigChain(e))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=k(r,e);for(const n in s){j(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 z(o,"$createDOM",r,F,b),z(o,"$exportDOM",r,F,b),z(o,"$extractWithChild",r,W,L),z(o,"$getDOMSlot",r,H,B),z(o,"$shouldExclude",r,_,w),z(o,"$shouldInclude",r,_,w),z(o,"$getSlotTargetElement",r,P,A),z(o,"$updateDOM",r,P,A),z(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(y,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=/* @__PURE__ */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=t.$getDocument().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:$}),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=/* @__PURE__ */ge("importSource",()=>"unknown"),$e=/* @__PURE__ */ge("importSourceDataTransfer",()=>null),ye=/* @__PURE__ */ge("textFormat",()=>0),Se=/* @__PURE__ */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=/* @__PURE__ */ge("whitespaceConfig",()=>({isInline:De,preservesWhitespace:Ee})),Ne=/* @__PURE__ */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 Me(e,n=t.$getEditor()){return i(function(e){return l(E,e)||Oe(e)}(n),e)}const ve=h(E,Oe);function Re(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(!He(o))return e;for(const n of e)t.$isBlockElementNode(n)&&""===n.getFormatType()&&n.setFormat(o);return e}function ke(e,n,o){1===e.length&&t.$isLineBreakNode(e[0])&&(e=[]);const r=t.$createParagraphNode();if(t.isHTMLElement(o)){const e=o.style.textAlign;He(e)&&r.setFormat(e)}return[r.splice(0,0,e)]}const be={$accepts:Re,$packageRun:ke,name:"BlockSchema"},we={$accepts:e=>!Re(e),name:"InlineSchema"},Ae={$accepts:Re,$packageRun:e=>e,name:"NestedBlockSchema"},Le={$accepts:Re,$packageRun:ke,name:"RootSchema"},Fe=ae,_e=new Set(["center","end","justify","left","right","start"]);function He(e){return _e.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"}},Pe={CODE:t.IS_CODE,MARK:t.IS_HIGHLIGHT};const We=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const Ue=/* @__PURE__ */me({$import:(e,n)=>{const o=e.get(ye),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=Pe[n.nodeName];return p&&(u|=p),u===o?e.$importChildren(n):e.$importChildren(n,{context:[d(ye,u)]})},match:Fe.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"});function ze(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 je(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=/* @__PURE__ */me({$import:(e,n)=>{const o=e.get(ye),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)je(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=ze(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=ze(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 je(c,o),Ve(c,r),[c]},match:Fe.text(),name:"@lexical/html/#text"}),qe=/* @__PURE__ */me({$import:()=>[],match:Fe.tag("script","style"),name:"@lexical/html/script-style-ignore"}),Ke=/* @__PURE__ */me({$import:(e,n)=>t.isOnlyChildInBlockNode(n)||t.isLastChildInBlockNode(n)?[]:[t.$createLineBreakNode()],match:Fe.tag("br"),name:"@lexical/html/br"}),Je=/* @__PURE__ */me({$import:(e,n)=>{const o=t.$createParagraphNode();if(t.$setFormatFromDOM(o,n),t.setNodeIndentFromDOM(n,o),""===o.getFormatType()){const e=n.getAttribute("align");e&&He(e)&&o.setFormat(e)}return t.$setDirectionFromDOM(o,n),[o.splice(0,0,e.$importChildren(n))]},match:Fe.tag("p"),name:"@lexical/html/p"}),Qe=/* @__PURE__ */me({$import:(e,n,r)=>t.$getEditor().hasNode(o.HorizontalRuleNode)?[o.$createHorizontalRuleNode()]:r(),match:Fe.tag("hr"),name:"@lexical/html/hr"}),Ye=[qe,Je,Qe,/* @__PURE__ */me({$import:(e,n,o)=>t.isBlockDomNode(n)?Te(e.$importChildren(n,{schema:be}),n):o(),match:Fe.any(),name:"@lexical/html/transparent-block"}),Ge,Ke,Ue];function Ze(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 Xe(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,Ze(t,o));return{byTag:l,commentIndices:i,rules:t,textIndices:s,wildcardIndices:o}}function et(e,n){return t.isDOMTextNode(n)?e.textIndices:8===n.nodeType?e.commentIndices:t.isHTMLElement(n)?e.byTag.get(n.nodeName)||e.wildcardIndices:tt}const tt=Object.freeze([]);function nt(e){const t=[];for(const n of e)if(ot(n))for(const e of n.rules)t.push(e);else t.push(n);return t}function ot(e){return"object"==typeof e&&null!==e&&"__type"in e&&"CompiledOverlayRules"===e.__type}const rt=Object.freeze({});function st(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=()=>it(e,t,n);return n&&n.context?ve(n.context,e.editor)(o):o()}finally{o&&e.overlays.pop()}}(e,t,n),$importOne:(t,n)=>ct(e,t,n),captures:t,get:t=>Me(t,e.editor),session:e.session};return n}function it(e,t,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(t.childNodes)){const t=ct(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 ct(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=et(r,t);s.length>0&&n.push({dispatch:r,indices:s})}const o=et(e.dispatch,t);o.length>0&&n.push({dispatch:e.dispatch,indices:o});return n}(e,t);if(0===n.length)return lt(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=st(e,0===Object.keys(l).length?rt:l);try{return o.$import(n,t,s)}catch(e){throw e}}}o++,r=0}return lt(e,t)};return s()}(e,t);return n&&n.context?ve(n.context,e.editor)(o):o()}function lt(e,t){if(0===t.childNodes.length)return[];const n=[];for(const o of Array.from(t.childNodes)){const t=ct(e,o,void 0);for(const e of t)n.push(e)}return n}const ut=/* @__PURE__ */me({$import:(e,t)=>e.$importChildren(t),match:ae.any(),name:"@lexical/html/default-hoist"}),at=/* @__PURE__ */t.defineExtension({build(e,n){const o=Xe(nt(n.rules)),r=a(n.contextDefaults,void 0),s=n.preprocess;return{$generateNodesFromDOM:(n,i)=>{const c=l(E,e)||r,u=i&&i.context?a(i.context,c):c,f=void 0!==u&&u!==c?u:Object.create(c||null),d=new Ie(f),h={session:d};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,h),p(E,f,()=>function(e,n,o,r){return it({dispatch:e,editor:n,overlays:r.get(Ne).map(e=>e.dispatch),session:r},t.isDOMDocumentNode(o)?o.body:o,{schema:Le})}(o,e,n,d),e)},defaults:r}},config:{contextDefaults:[],preprocess:[g],rules:[ut]},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 ft=/* @__PURE__ */t.defineExtension({dependencies:[/* @__PURE__ */t.configExtension(at,{rules:Ye})],name:"@lexical/html/CoreImport"}),dt=[Qe],pt=/* @__PURE__ */t.defineExtension({dependencies:[o.HorizontalRuleExtension,ft],name:"@lexical/html/HorizontalRuleImport"}),ht={any:ae.any,comment:ae.comment,css:he,tag:ae.tag,text:ae.text},mt=new Set(["STYLE","SCRIPT"]);function gt(e,n=null,o=t.$getEditor()){return R([d(I,!0)],o)(()=>{const r=t.$getRoot(),s=v(o),i=t.$isRangeSelection(n)?t.$getSlotFrame(n.anchor.getNode()):null,c=e.append.bind(e);for(const e of(t.$isElementNode(i)?i:r).getChildren())xt(o,e,c,n,s);return e})}function xt(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=t.$getDocument().createDocumentFragment(),g=h?h():t.$isElementNode(u)?u.getChildren():[],x=c&&t.$isNodeSelection(s)&&t.$isElementNode(o)?null:s,$=m.append.bind(m);for(const e of g){const t=xt(n,e,$,x,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 $t(e,n,o,r,s=new Map,i){const c=[];if(mt.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(...$t(d[e],n,o,h,new Map(s),l));if(null!=f&&(p=f(p)),t.isBlockDomNode(e)&&(p=yt(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 yt(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.$appendNodeToHTML=function(e,t,n,o=null){return xt(e,t,n.append.bind(n),o,v(e))},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(Re(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=gt,exports.$generateDOMFromRoot=function(e,n=t.$getRoot()){const o=t.$getEditor();return R([d(I,!0),d(N,!0)],o)(()=>{const t=v(o),r=e.append.bind(e);return xt(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),gt(t.$getDocument().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(!mt.has(t.nodeName)){const n=$t(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(at).$generateNodesFromDOM(e,t)},exports.$getImportContextValue=Me,exports.$getRenderContextValue=function(e,n=t.$getEditor()){return i(function(e){return l(y,e)||O(e)}(n),e)},exports.$getSessionDOMRenderConfig=v,exports.$inlineStylesFromStyleSheets=g,exports.$isBlockLevel=Re,exports.$propagateTextAlignToBlockChildren=Te,exports.$setRenderContextValue=function(e,n,o=t.$getEditor()){const r=M(o);r&&r.setContextValue(e,n)},exports.$updateRenderContextValue=function(e,n,o=t.$getEditor()){const r=M(o);r&&r.setContextValue(e,n(i(r.editorContext,e)))},exports.$withImportContext=ve,exports.$withRenderContext=R,exports.BlockSchema=be,exports.CoreImportExtension=ft,exports.CoreImportRules=Ye,exports.DOMImportExtension=at,exports.DOMRenderExtension=ee,exports.HorizontalRuleImportExtension=pt,exports.HorizontalRuleImportRules=dt,exports.ImportOverlays=Ne,exports.ImportSource=xe,exports.ImportSourceDataTransfer=$e,exports.ImportTextFormat=ye,exports.ImportTextStyle=Se,exports.ImportWhitespaceConfig=Ce,exports.InlineSchema=we,exports.NestedBlockSchema=Ae,exports.RenderContextExport=I,exports.RenderContextRoot=N,exports.RootSchema=Le,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=nt(e);return{__type:"CompiledOverlayRules",dispatch:Xe(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=ht;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
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,getRegisteredSubtypeMap as c,$isLexicalNode as l,iterStaticNodeConfigChain as u,$fullReconcile as f,defineExtension as a,shallowMergeConfig as d,RootNode as p,$getDocument as h,isDOMTextNode as g,isBlockDomNode as m,isInlineDomNode as y,$isElementNode as x,$isBlockElementNode as S,$isDecoratorNode as $,$isLineBreakNode as v,$createParagraphNode as C,IS_HIGHLIGHT as b,IS_CODE as k,$generateNodesFromRawText as D,$createTextNode as w,isOnlyChildInBlockNode as O,isLastChildInBlockNode as M,$createLineBreakNode as A,$setFormatFromDOM as N,setNodeIndentFromDOM as E,$setDirectionFromDOM as I,$isTextNode as W,IS_BOLD as R,IS_ITALIC as F,IS_UNDERLINE as T,IS_STRIKETHROUGH as P,IS_SUBSCRIPT as j,IS_SUPERSCRIPT as z,configExtension as _,$getRoot as L,$isRangeSelection as U,$getSlotFrame as B,$assumeActiveEditor as V,$isNodeSelection as q,isDocumentFragment as G,$isRootOrShadowRoot as H,ArtificialNode__DO_NOT_USE as J}from"lexical";import{objectKlassEquals as Q}from"@lexical/utils";import{getPeerDependencyFromEditor as K,getKnownTypesAndNodes as Y,HorizontalRuleNode as Z,$createHorizontalRuleNode as X,$getExtensionOutput as tt,HorizontalRuleExtension as et}from"@lexical/extension";function nt(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 ot;function rt(t,e){const{key:n}=e;return t&&n in t?t[n]:e.defaultValue}function st(t){return ot&&ot.editor===t?ot:void 0}function it(t,e){const n=st(e);return n&&n[t]}function ct(t,e){if("cfg"in e){const{cfg:n,updater:o}=e;return[n,o(rt(t,n))]}return e}function lt(t,e){let n=e;for(const o of t){const[t,r]=ct(n,o),s=t.key;if(n===e&&rt(n,t)===r)continue;const i=n===e||void 0===n?ut(e):n;i[s]=r,n=i}return n}function ut(t){return Object.create(t||null)}function ft(t,e){return[t,e]}function at(t,e){return{cfg:t,updater:e}}function dt(t,n,o,r=e()){const s=ot,i=st(r);try{return ot={...i,editor:r,[t]:n},o()}finally{ot=s}}function pt(t,n=()=>{}){return(o,r=e())=>e=>{const s=st(r),i=s&&s[t],c=lt(o,i||n(r));return c&&c!==i?dt(t,c,e,r):e()}}function ht(t,e,o,r){return Object.assign(n(Symbol(e),{isEqual:r,parse:o}),{[t]:!0})}const gt=(t,e,n)=>{mt(t),n()};function mt(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(!Q(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 yt="@lexical/html/DOM",xt=Symbol.for("@lexical/html/DOMExportContext"),St="@lexical/html/DOMImport",$t=Symbol.for("@lexical/html/DOMImportContext"),vt=()=>!0;function Ct(t,e,n){return ht(xt,t,e,n)}const bt=/* @__PURE__ */Ct("root",Boolean),kt=/* @__PURE__ */Ct("isExport",Boolean);function Dt(t){const e=K(t,yt);return e?e.output.defaults:void 0}function wt(t,n=e()){return rt(function(t){return it(xt,t)||Dt(t)}(n),t)}function Ot(t){const e=K(t,yt);return e?e.output.runtime:void 0}function Mt(t,n,o=e()){const r=Ot(o);r&&r.setContextValue(t,n)}function At(t,n,o=e()){const r=Ot(o);r&&r.setContextValue(t,n(rt(r.editorContext,t)))}function Nt(t=e()){const n=Ot(t);return n?n.getSessionConfig():s(t)}const Et=pt(xt,Dt);function It(t,e,n){return{...e,...n,nodes:t}}function Wt(t){return e=>e instanceof t}function Rt(t,{nodes:e}){if("*"===e)return vt;let n={};const o=[];for(const r of e)if("getType"in r){const e=r.getType();if(n){const o=t.get(e);void 0===o&&nt(339,r.name,e);for(const t of o)n[t]=!0}o.push(Wt(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 Ft(t){return(e,n,o)=>t(e,o)}function Tt(t){return(e,n,o,r)=>t(e,n,r)}function Pt(t){return(e,n,o,r,s)=>t(e,n,o,s)}function jt(t){return(e,n,o,r,s,i)=>t(e,n,o,r,i)}function zt(t,e){return(n,o)=>{const r=()=>t(n,o),s=e(n);return s?s(n,r,o):r()}}function _t(t,e){return(n,o,r)=>{const s=()=>t(n,o,r),i=e(n);return i?i(n,o,s,r):s()}}const Lt=_t,Ut=Tt;function Bt(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 Vt(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 qt(t,e){return(n,o,r,s)=>{t(n,o,r,s);const i=e(n);i&&i(n,o,r,s)}}function Gt(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 Ht(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 Jt(t){return"*"===t.nodes}function Qt(t,e){const n=c(Y(t).nodes),o={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$getSlotTargetElement:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const t of function(t){const e=[],n=[],o=[];for(const r of t)if(Jt(r))e.push(r);else if(Array.isArray(r.nodes))for(const t of r.nodes)l(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=-1;for(const n of u(t))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=Rt(n,t);for(const n in o){Ht(o,n,e,t[n])}}return o}function Kt(t){return t}function Yt(t,{overrides:e}){const n=Qt(t,e),o={...i,...t.dom};return Gt(n,"$createDOM",o,zt,Ft),Gt(n,"$exportDOM",o,zt,Ft),Gt(n,"$extractWithChild",o,Vt,jt),Gt(n,"$getDOMSlot",o,Lt,Ut),Gt(n,"$shouldExclude",o,_t,Tt),Gt(n,"$shouldInclude",o,_t,Tt),Gt(n,"$getSlotTargetElement",o,Bt,Pt),Gt(n,"$updateDOM",o,Bt,Pt),Gt(n,"$decorateDOM",o,qt,Kt),o}function Zt(t){return{get:e=>rt(t,e)}}function Xt(t){const e=Object.create(null);return lt(t,e)||e}function te(t,e){const n=Zt(e);return t.filter(t=>!(t.disabledForEditor&&t.disabledForEditor(n)))}function ee(t){if("*"===t.nodes)return()=>!0;const e=t.nodes.map(t=>{const e=t;return l(e.prototype)?t=>t instanceof e:t});return t=>e.some(e=>e(t))}class ne{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=te(n,o),this.hasSessionGates=n.some(t=>t.disabledForSession)}setContextValue(t,e){const n=this.installed;this.editorContext[t.key]=e;const o=te(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=Yt(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(ee(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(f,{discrete:!0}),s.$updateDOM=c}getSessionConfig(){const t=this.editor._config.dom||i;if(!this.hasSessionGates)return t;const e=Zt(it(xt,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=Yt(this.initialEditorConfig,{overrides:o}),this.sessionCache.set(r,s)),s}}const oe=/* @__PURE__ */a({build(t,e,n){const{initialEditorConfig:o}=n.getInitResult(),r=Xt(e.contextDefaults);return{defaults:r,runtime:new ne(t,o,e.overrides,r)}},config:{contextDefaults:[],overrides:[]},html:{export:new Map([[p,()=>{const t=h().createElement("div");return t.role="textbox",{element:t}}]])},init(t,e){const n={dom:t.dom,nodes:t.nodes},o=Xt(e.contextDefaults),r=te(e.overrides,o);return t.dom=Yt(t,{overrides:r}),{initialEditorConfig:n}},mergeConfig(t,e){const n=d(t,e);for(const o of["overrides","contextDefaults"])e[o]&&(n[o]=[...t[o],...e[o]]);return n},name:yt}),re=Symbol.for("@lexical/html/SelectorImpl");function se(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=>se(t,[...e,n]);return{[re]:n,attr:(t,e,n)=>s(le(t,e,n)),classAll:(...t)=>s(ce(t)),classAny:(...t)=>s(function(t){const e=ie(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)}}nt(362,JSON.stringify(t))}(t,e,n))}}function ie(t){const e=[];for(const n of t)n&&e.push(n);return e}function ce(t){const e=ie(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 le(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)}}nt(361,JSON.stringify(t))}const ue={kind:"text",predicate:g,tags:new Set},fe={[re]:ue},ae={kind:"comment",predicate:t=>8===t.nodeType,tags:new Set},de={[re]:ae},pe={any:()=>se(new Set,[]),comment:()=>de,tag(...t){t.length>0||nt(363);const e=new Set;for(const n of t)e.add(n.toUpperCase());return se(e,[])},text:()=>fe};function he(t,e){return r(t)&&t.nodeName===e.toUpperCase()}const ge=/[A-Za-z0-9_-]/;class me{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()&&ge.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||nt(364,String(this.pos+1),e,this.source)}}function ye(t){const e=new Set,n=[],o=[];if(t.skipWhitespace(),"*"===t.peek())t.consume();else if(ge.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(le("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(le(e,o))}}}return o.length>0&&n.push(ce(o)),{predicates:n,tags:e}}function xe(t){const e=new me(t,0),n=[];for(;;){const t=ye(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 se(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 se(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 Se(t){return t}function $e(t,e,n){return ht($t,t,e,n)}const ve=/* @__PURE__ */$e("importSource",()=>"unknown"),Ce=/* @__PURE__ */$e("importSourceDataTransfer",()=>null),be=/* @__PURE__ */$e("textFormat",()=>0),ke=/* @__PURE__ */$e("textStyle",()=>({}));function De(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 we(t){if(g(t))return!0;if(!r(t))return!1;const e=t.style.display;return e?e.startsWith("inline"):!m(t)&&y(t)}const Oe=/* @__PURE__ */$e("whitespaceConfig",()=>({isInline:we,preservesWhitespace:De})),Me=/* @__PURE__ */$e("importOverlays",()=>[]);class Ae{constructor(t){this.record=t}get(t){return rt(this.record,t)}set(t,e){this.record[t.key]=e}update(t,e){this.record[t.key]=e(rt(this.record,t))}has(t){return Object.prototype.hasOwnProperty.call(this.record,t.key)}}function Ne(t){const e=K(t,St);return e?e.output.defaults:void 0}function Ee(t,n=e()){return rt(function(t){return it($t,t)||Ne(t)}(n),t)}const Ie=pt($t,Ne);function We(t){return S(t)||$(t)&&!t.isInline()}function Re(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(We(s)){if(r(),x(s)){const t=Re(s.getChildren(),e);s.splice(0,s.getChildrenSize(),t)}n.push(s)}else o.push(s);return r(),n}function Fe(t,e){if(!r(e))return t;const n=e.style.textAlign;if(!Be(n))return t;for(const e of t)S(e)&&""===e.getFormatType()&&e.setFormat(n);return t}function Te(t,e,n){1===t.length&&v(t[0])&&(t=[]);const o=C();if(r(n)){const t=n.style.textAlign;Be(t)&&o.setFormat(t)}return[o.splice(0,0,t)]}const Pe={$accepts:We,$packageRun:Te,name:"BlockSchema"},je={$accepts:t=>!We(t),name:"InlineSchema"},ze={$accepts:We,$packageRun:t=>t,name:"NestedBlockSchema"},_e={$accepts:We,$packageRun:Te,name:"RootSchema"},Le=pe,Ue=new Set(["center","end","justify","left","right","start"]);function Be(t){return Ue.has(t)}const Ve={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"}},qe={CODE:k,MARK:b};const Ge=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const He=/* @__PURE__ */Se({$import:(t,e)=>{const n=t.get(be),o=Ve[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|=R:"normal"!==o&&"400"!==o||(n|=R),"italic"===r?e|=F:"normal"===r&&(n|=F),s){const t=s.split(" ");t.includes("underline")&&(e|=T),t.includes("line-through")&&(e|=P),t.includes("none")&&(n|=T|P)}return"sub"===i?(e|=j,n|=z):"super"===i?(e|=z,n|=j):"baseline"===i&&(n|=j|z),{clear:n,set:e}}(s),u&~f.clear|f.set);var u,f;const a=qe[e.nodeName];return a&&(l|=a),l===n?t.$importChildren(e):t.$importChildren(e,{context:[ft(be,l)]})},match:Le.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"});function Je(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(g(o))return o;if("BR"===o.nodeName)return null}}function Qe(t,e){return 0!==e&&W(t)?t.setFormat(e):t}function Ke(t,e){if(W(t)){const n=function(t){let e="";for(const n in t)Ge.has(n)||(e+=`${n}: ${t[n]}; `);return e.trimEnd()}(e);""!==n&&t.setStyle(n)}return t}const Ye=/* @__PURE__ */Se({$import:(t,e)=>{const n=t.get(be),o=t.get(ke),r=t.get(Oe);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=D(e.textContent||"");for(const e of t)Qe(e,n),Ke(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=Je(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=Je(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=w(s);return Qe(i,n),Ke(i,o),[i]},match:Le.text(),name:"@lexical/html/#text"}),Ze=/* @__PURE__ */Se({$import:()=>[],match:Le.tag("script","style"),name:"@lexical/html/script-style-ignore"}),Xe=/* @__PURE__ */Se({$import:(t,e)=>O(e)||M(e)?[]:[A()],match:Le.tag("br"),name:"@lexical/html/br"}),tn=/* @__PURE__ */Se({$import:(t,e)=>{const n=C();if(N(n,e),E(e,n),""===n.getFormatType()){const t=e.getAttribute("align");t&&Be(t)&&n.setFormat(t)}return I(n,e),[n.splice(0,0,t.$importChildren(e))]},match:Le.tag("p"),name:"@lexical/html/p"}),en=/* @__PURE__ */Se({$import:(t,n,o)=>e().hasNode(Z)?[X()]:o(),match:Le.tag("hr"),name:"@lexical/html/hr"}),nn=[Ze,tn,en,/* @__PURE__ */Se({$import:(t,e,n)=>m(e)?Fe(t.$importChildren(e,{schema:Pe}),e):n(),match:Le.any(),name:"@lexical/html/transparent-block"}),Ye,Xe,He];function on(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 rn(t){const e=[],n=new Map,o=[],r=[],s=[],i=new Set;t.forEach((t,c)=>{const l=function(t){const e=t[re];return void 0===e&&nt(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,on(e,o));return{byTag:c,commentIndices:s,rules:e,textIndices:r,wildcardIndices:o}}function sn(t,e){return g(e)?t.textIndices:8===e.nodeType?t.commentIndices:r(e)?t.byTag.get(e.nodeName)||t.wildcardIndices:cn}const cn=Object.freeze([]);function ln(t){const e=[];for(const n of t)if(un(n))for(const t of n.rules)e.push(t);else e.push(n);return e}function un(t){return"object"==typeof t&&null!==t&&"__type"in t&&"CompiledOverlayRules"===t.__type}function fn(t){const e=ln(t);return{__type:"CompiledOverlayRules",dispatch:rn(e),rules:e}}const an=Object.freeze({});function dn(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=()=>pn(t,e,n);return n&&n.context?Ie(n.context,t.editor)(o):o()}finally{o&&t.overlays.pop()}}(t,e,n),$importOne:(e,n)=>hn(t,e,n),captures:e,get:e=>Ee(e,t.editor),session:t.session};return n}function pn(t,e,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(e.childNodes)){const e=hn(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 hn(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=sn(r,e);s.length>0&&n.push({dispatch:r,indices:s})}const o=sn(t.dispatch,e);o.length>0&&n.push({dispatch:t.dispatch,indices:o});return n}(t,e);if(0===n.length)return gn(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=dn(t,0===Object.keys(l).length?an:l);try{return o.$import(n,e,s)}catch(t){throw t}}}o++,r=0}return gn(t,e)};return s()}(t,e);return n&&n.context?Ie(n.context,t.editor)(o):o()}function gn(t,e){if(0===e.childNodes.length)return[];const n=[];for(const o of Array.from(e.childNodes)){const e=hn(t,o,void 0);for(const t of e)n.push(t)}return n}const mn=/* @__PURE__ */Se({$import:(t,e)=>t.$importChildren(e),match:pe.any(),name:"@lexical/html/default-hoist"}),yn=/* @__PURE__ */a({build(t,e){const n=rn(ln(e.rules)),r=lt(e.contextDefaults,void 0),s=e.preprocess;return{$generateNodesFromDOM:(e,i)=>{const c=i&&i.context?lt(i.context,r):r,l=void 0!==c&&c!==r?c:Object.create(r||null),u=new Ae(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),dt($t,l,()=>function(t,e,n,r){return pn({dispatch:t,editor:e,overlays:r.get(Me).map(t=>t.dispatch),session:r},o(n)?n.body:n,{schema:_e})}(n,t,e,u),t)},defaults:r}},config:{contextDefaults:[],preprocess:[gt],rules:[mn]},mergeConfig:(t,e)=>d(t,{...e,...e.contextDefaults&&{contextDefaults:[...t.contextDefaults,...e.contextDefaults]},...e.preprocess&&{preprocess:[...t.preprocess,...e.preprocess]},...e.rules&&{rules:[...e.rules,...t.rules]}}),name:St});function xn(t,e){return tt(yn).$generateNodesFromDOM(t,e)}const Sn=/* @__PURE__ */a({dependencies:[/* @__PURE__ */_(yn,{rules:nn})],name:"@lexical/html/CoreImport"}),$n=[en],vn=/* @__PURE__ */a({dependencies:[et,Sn],name:"@lexical/html/HorizontalRuleImport"}),Cn={any:pe.any,comment:pe.comment,css:xe,tag:pe.tag,text:pe.text},bn=new Set(["STYLE","SCRIPT"]);function kn(t,e){mt(e);const n=o(e)?e.body.childNodes:e.childNodes,r=[],s=[];for(const e of n)if(!bn.has(e.nodeName)){const n=Nn(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 J&&e.insertAfter(A());for(const e of t){const t=e.getParent();t&&t.splice(e.getIndexWithinParent(),1,e.getChildren())}}(s),r}function Dn(t,n=null,o=e()){return Et([ft(kt,!0)],o)(()=>{const e=L(),r=Nt(o),s=U(n)?B(n.anchor.getNode()):null,i=t.append.bind(t);for(const t of(x(s)?s:e).getChildren())Mn(o,t,i,n,r);return t})}function wn(t,n=L()){const o=e();return Et([ft(kt,!0),ft(bt,!0)],o)(()=>{const e=Nt(o),r=t.append.bind(t);return Mn(o,n,r,null,e),t})}function On(t,e=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&nt(338),V(t),Dn(h().createElement("div"),e,t).innerHTML}function Mn(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&&W(n)&&(f=t(i,n,"clone"));const a=c.$exportDOM(f,e),{element:d,after:p,append:g,$getChildNodes:m}=a;if(!d)return!1;const y=h().createDocumentFragment(),S=m?m():x(f)?f.getChildren():[],$=l&&q(i)&&x(n)?null:i,v=y.append.bind(y);for(const t of S){const o=Mn(e,t,v,$,c);!l&&o&&c.$extractWithChild(n,t,i,"html",e)&&(l=!0)}if(l&&!u){if((r(d)||G(d))&&(g?g(y):d.append(y)),o(d),p){const t=p.call(f,d);t&&(G(d)?d.replaceChildren(t):d.replaceWith(t))}}else o(y);return l}function An(t,e,n,o=null){return Mn(t,e,n.append.bind(n),o,Nt(t))}function Nn(t,e,n,o,r=new Map,s){const i=[];if(bn.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 d=[];const p=(null==c||!H(c))&&(null!=c&&S(c)||o);for(let t=0;t<a.length;t++)d.push(...Nn(a[t],e,n,p,new Map(r),c));if(null!=f&&(d=f(d)),m(t)&&(d=En(t,d,p?()=>{const t=new J;return n.push(t),t}:C)),null==c)if(d.length>0)for(const t of d)i.push(t);else m(t)&&function(t){if(null==t.nextSibling||null==t.previousSibling)return!1;return y(t.nextSibling)&&y(t.previousSibling)}(t)&&i.push(A());else x(c)&&c.append(...d);return i}function En(t,e,n){const o=t.style.textAlign,r=[];let s=[];for(let t=0;t<e.length;t++){const i=e[t];if(S(i))o&&!i.getFormat()&&i.setFormat(o),r.push(i);else if(s.push(i),t===e.length-1||t<e.length-1&&S(e[t+1])){const t=n();t.setFormat(o),t.append(...s),r.push(t),s=[]}}return r}export{An as $appendNodeToHTML,Re as $distributeInlineWrapper,Dn as $generateDOMFromNodes,wn as $generateDOMFromRoot,On as $generateHtmlFromNodes,kn as $generateNodesFromDOM,xn as $generateNodesFromDOMViaExtension,Ee as $getImportContextValue,wt as $getRenderContextValue,Nt as $getSessionDOMRenderConfig,gt as $inlineStylesFromStyleSheets,We as $isBlockLevel,Fe as $propagateTextAlignToBlockChildren,Mt as $setRenderContextValue,At as $updateRenderContextValue,Ie as $withImportContext,Et as $withRenderContext,Pe as BlockSchema,Sn as CoreImportExtension,nn as CoreImportRules,yn as DOMImportExtension,oe as DOMRenderExtension,vn as HorizontalRuleImportExtension,$n as HorizontalRuleImportRules,Me as ImportOverlays,ve as ImportSource,Ce as ImportSourceDataTransfer,be as ImportTextFormat,ke as ImportTextStyle,Oe as ImportWhitespaceConfig,je as InlineSchema,ze as NestedBlockSchema,kt as RenderContextExport,bt as RenderContextRoot,_e as RootSchema,at as contextUpdater,ft as contextValue,$e as createImportState,Ct as createRenderState,we as defaultIsInline,De as defaultPreservesWhitespace,Se as defineImportRule,fn as defineOverlayRules,It as domOverride,he as isElementOfTag,xe as parseSelector,Cn as sel};
|
|
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,getRegisteredSubtypeMap as c,$isLexicalNode as l,iterStaticNodeConfigChain as u,$fullReconcile as f,defineExtension as a,shallowMergeConfig as d,RootNode as p,$getDocument as h,isDOMTextNode as g,isBlockDomNode as m,isInlineDomNode as y,$isElementNode as x,$isBlockElementNode as S,$isDecoratorNode as $,$isLineBreakNode as v,$createParagraphNode as C,IS_HIGHLIGHT as b,IS_CODE as k,$generateNodesFromRawText as D,$createTextNode as w,isOnlyChildInBlockNode as O,isLastChildInBlockNode as M,$createLineBreakNode as A,$setFormatFromDOM as N,setNodeIndentFromDOM as E,$setDirectionFromDOM as I,$isTextNode as W,IS_BOLD as R,IS_ITALIC as F,IS_UNDERLINE as T,IS_STRIKETHROUGH as P,IS_SUBSCRIPT as j,IS_SUPERSCRIPT as z,configExtension as _,$getRoot as L,$isRangeSelection as U,$getSlotFrame as B,$assumeActiveEditor as V,$isNodeSelection as q,isDocumentFragment as G,$isRootOrShadowRoot as H,ArtificialNode__DO_NOT_USE as J}from"lexical";import{objectKlassEquals as Q}from"@lexical/utils";import{getPeerDependencyFromEditor as K,getKnownTypesAndNodes as Y,HorizontalRuleNode as Z,$createHorizontalRuleNode as X,$getExtensionOutput as tt,HorizontalRuleExtension as et}from"@lexical/extension";function nt(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 ot;function rt(t,e){const{key:n}=e;return t&&n in t?t[n]:e.defaultValue}function st(t){return ot&&ot.editor===t?ot:void 0}function it(t,e){const n=st(e);return n&&n[t]}function ct(t,e){if("cfg"in e){const{cfg:n,updater:o}=e;return[n,o(rt(t,n))]}return e}function lt(t,e){let n=e;for(const o of t){const[t,r]=ct(n,o),s=t.key;if(n===e&&rt(n,t)===r)continue;const i=n===e||void 0===n?ut(e):n;i[s]=r,n=i}return n}function ut(t){return Object.create(t||null)}function ft(t,e){return[t,e]}function at(t,e){return{cfg:t,updater:e}}function dt(t,n,o,r=e()){const s=ot,i=st(r);try{return ot={...i,editor:r,[t]:n},o()}finally{ot=s}}function pt(t,n=()=>{}){return(o,r=e())=>e=>{const s=st(r),i=s&&s[t],c=lt(o,i||n(r));return c&&c!==i?dt(t,c,e,r):e()}}function ht(t,e,o,r){return Object.assign(n(Symbol(e),{isEqual:r,parse:o}),{[t]:!0})}const gt=(t,e,n)=>{mt(t),n()};function mt(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(!Q(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 yt="@lexical/html/DOM",xt=Symbol.for("@lexical/html/DOMExportContext"),St="@lexical/html/DOMImport",$t=Symbol.for("@lexical/html/DOMImportContext"),vt=()=>!0;function Ct(t,e,n){return ht(xt,t,e,n)}const bt=/* @__PURE__ */Ct("root",Boolean),kt=/* @__PURE__ */Ct("isExport",Boolean);function Dt(t){const e=K(t,yt);return e?e.output.defaults:void 0}function wt(t,n=e()){return rt(function(t){return it(xt,t)||Dt(t)}(n),t)}function Ot(t){const e=K(t,yt);return e?e.output.runtime:void 0}function Mt(t,n,o=e()){const r=Ot(o);r&&r.setContextValue(t,n)}function At(t,n,o=e()){const r=Ot(o);r&&r.setContextValue(t,n(rt(r.editorContext,t)))}function Nt(t=e()){const n=Ot(t);return n?n.getSessionConfig():s(t)}const Et=pt(xt,Dt);function It(t,e,n){return{...e,...n,nodes:t}}function Wt(t){return e=>e instanceof t}function Rt(t,{nodes:e}){if("*"===e)return vt;let n={};const o=[];for(const r of e)if("getType"in r){const e=r.getType();if(n){const o=t.get(e);void 0===o&&nt(339,r.name,e);for(const t of o)n[t]=!0}o.push(Wt(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 Ft(t){return(e,n,o)=>t(e,o)}function Tt(t){return(e,n,o,r)=>t(e,n,r)}function Pt(t){return(e,n,o,r,s)=>t(e,n,o,s)}function jt(t){return(e,n,o,r,s,i)=>t(e,n,o,r,i)}function zt(t,e){return(n,o)=>{const r=()=>t(n,o),s=e(n);return s?s(n,r,o):r()}}function _t(t,e){return(n,o,r)=>{const s=()=>t(n,o,r),i=e(n);return i?i(n,o,s,r):s()}}const Lt=_t,Ut=Tt;function Bt(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 Vt(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 qt(t,e){return(n,o,r,s)=>{t(n,o,r,s);const i=e(n);i&&i(n,o,r,s)}}function Gt(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 Ht(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 Jt(t){return"*"===t.nodes}function Qt(t,e){const n=c(Y(t).nodes),o={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$getSlotTargetElement:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const t of function(t){const e=[],n=[],o=[];for(const r of t)if(Jt(r))e.push(r);else if(Array.isArray(r.nodes))for(const t of r.nodes)l(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=-1;for(const n of u(t))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=Rt(n,t);for(const n in o){Ht(o,n,e,t[n])}}return o}function Kt(t){return t}function Yt(t,{overrides:e}){const n=Qt(t,e),o={...i,...t.dom};return Gt(n,"$createDOM",o,zt,Ft),Gt(n,"$exportDOM",o,zt,Ft),Gt(n,"$extractWithChild",o,Vt,jt),Gt(n,"$getDOMSlot",o,Lt,Ut),Gt(n,"$shouldExclude",o,_t,Tt),Gt(n,"$shouldInclude",o,_t,Tt),Gt(n,"$getSlotTargetElement",o,Bt,Pt),Gt(n,"$updateDOM",o,Bt,Pt),Gt(n,"$decorateDOM",o,qt,Kt),o}function Zt(t){return{get:e=>rt(t,e)}}function Xt(t){const e=Object.create(null);return lt(t,e)||e}function te(t,e){const n=Zt(e);return t.filter(t=>!(t.disabledForEditor&&t.disabledForEditor(n)))}function ee(t){if("*"===t.nodes)return()=>!0;const e=t.nodes.map(t=>{const e=t;return l(e.prototype)?t=>t instanceof e:t});return t=>e.some(e=>e(t))}class ne{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=te(n,o),this.hasSessionGates=n.some(t=>t.disabledForSession)}setContextValue(t,e){const n=this.installed;this.editorContext[t.key]=e;const o=te(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=Yt(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(ee(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(f,{discrete:!0}),s.$updateDOM=c}getSessionConfig(){const t=this.editor._config.dom||i;if(!this.hasSessionGates)return t;const e=Zt(it(xt,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=Yt(this.initialEditorConfig,{overrides:o}),this.sessionCache.set(r,s)),s}}const oe=/* @__PURE__ */a({build(t,e,n){const{initialEditorConfig:o}=n.getInitResult(),r=Xt(e.contextDefaults);return{defaults:r,runtime:new ne(t,o,e.overrides,r)}},config:{contextDefaults:[],overrides:[]},html:{export:new Map([[p,()=>{const t=h().createElement("div");return t.role="textbox",{element:t}}]])},init(t,e){const n={dom:t.dom,nodes:t.nodes},o=Xt(e.contextDefaults),r=te(e.overrides,o);return t.dom=Yt(t,{overrides:r}),{initialEditorConfig:n}},mergeConfig(t,e){const n=d(t,e);for(const o of["overrides","contextDefaults"])e[o]&&(n[o]=[...t[o],...e[o]]);return n},name:yt}),re=Symbol.for("@lexical/html/SelectorImpl");function se(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=>se(t,[...e,n]);return{[re]:n,attr:(t,e,n)=>s(le(t,e,n)),classAll:(...t)=>s(ce(t)),classAny:(...t)=>s(function(t){const e=ie(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)}}nt(362,JSON.stringify(t))}(t,e,n))}}function ie(t){const e=[];for(const n of t)n&&e.push(n);return e}function ce(t){const e=ie(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 le(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)}}nt(361,JSON.stringify(t))}const ue={kind:"text",predicate:g,tags:new Set},fe={[re]:ue},ae={kind:"comment",predicate:t=>8===t.nodeType,tags:new Set},de={[re]:ae},pe={any:()=>se(new Set,[]),comment:()=>de,tag(...t){t.length>0||nt(363);const e=new Set;for(const n of t)e.add(n.toUpperCase());return se(e,[])},text:()=>fe};function he(t,e){return r(t)&&t.nodeName===e.toUpperCase()}const ge=/[A-Za-z0-9_-]/;class me{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()&&ge.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||nt(364,String(this.pos+1),e,this.source)}}function ye(t){const e=new Set,n=[],o=[];if(t.skipWhitespace(),"*"===t.peek())t.consume();else if(ge.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(le("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(le(e,o))}}}return o.length>0&&n.push(ce(o)),{predicates:n,tags:e}}function xe(t){const e=new me(t,0),n=[];for(;;){const t=ye(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 se(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 se(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 Se(t){return t}function $e(t,e,n){return ht($t,t,e,n)}const ve=/* @__PURE__ */$e("importSource",()=>"unknown"),Ce=/* @__PURE__ */$e("importSourceDataTransfer",()=>null),be=/* @__PURE__ */$e("textFormat",()=>0),ke=/* @__PURE__ */$e("textStyle",()=>({}));function De(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 we(t){if(g(t))return!0;if(!r(t))return!1;const e=t.style.display;return e?e.startsWith("inline"):!m(t)&&y(t)}const Oe=/* @__PURE__ */$e("whitespaceConfig",()=>({isInline:we,preservesWhitespace:De})),Me=/* @__PURE__ */$e("importOverlays",()=>[]);class Ae{constructor(t){this.record=t}get(t){return rt(this.record,t)}set(t,e){this.record[t.key]=e}update(t,e){this.record[t.key]=e(rt(this.record,t))}has(t){return Object.prototype.hasOwnProperty.call(this.record,t.key)}}function Ne(t){const e=K(t,St);return e?e.output.defaults:void 0}function Ee(t,n=e()){return rt(function(t){return it($t,t)||Ne(t)}(n),t)}const Ie=pt($t,Ne);function We(t){return S(t)||$(t)&&!t.isInline()}function Re(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(We(s)){if(r(),x(s)){const t=Re(s.getChildren(),e);s.splice(0,s.getChildrenSize(),t)}n.push(s)}else o.push(s);return r(),n}function Fe(t,e){if(!r(e))return t;const n=e.style.textAlign;if(!Be(n))return t;for(const e of t)S(e)&&""===e.getFormatType()&&e.setFormat(n);return t}function Te(t,e,n){1===t.length&&v(t[0])&&(t=[]);const o=C();if(r(n)){const t=n.style.textAlign;Be(t)&&o.setFormat(t)}return[o.splice(0,0,t)]}const Pe={$accepts:We,$packageRun:Te,name:"BlockSchema"},je={$accepts:t=>!We(t),name:"InlineSchema"},ze={$accepts:We,$packageRun:t=>t,name:"NestedBlockSchema"},_e={$accepts:We,$packageRun:Te,name:"RootSchema"},Le=pe,Ue=new Set(["center","end","justify","left","right","start"]);function Be(t){return Ue.has(t)}const Ve={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"}},qe={CODE:k,MARK:b};const Ge=new Set(["font-weight","font-style","text-decoration","vertical-align"]);const He=/* @__PURE__ */Se({$import:(t,e)=>{const n=t.get(be),o=Ve[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|=R:"normal"!==o&&"400"!==o||(n|=R),"italic"===r?e|=F:"normal"===r&&(n|=F),s){const t=s.split(" ");t.includes("underline")&&(e|=T),t.includes("line-through")&&(e|=P),t.includes("none")&&(n|=T|P)}return"sub"===i?(e|=j,n|=z):"super"===i?(e|=z,n|=j):"baseline"===i&&(n|=j|z),{clear:n,set:e}}(s),u&~f.clear|f.set);var u,f;const a=qe[e.nodeName];return a&&(l|=a),l===n?t.$importChildren(e):t.$importChildren(e,{context:[ft(be,l)]})},match:Le.tag("b","strong","em","i","code","mark","s","sub","sup","u","span"),name:"@lexical/html/inline-format"});function Je(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(g(o))return o;if("BR"===o.nodeName)return null}}function Qe(t,e){return 0!==e&&W(t)?t.setFormat(e):t}function Ke(t,e){if(W(t)){const n=function(t){let e="";for(const n in t)Ge.has(n)||(e+=`${n}: ${t[n]}; `);return e.trimEnd()}(e);""!==n&&t.setStyle(n)}return t}const Ye=/* @__PURE__ */Se({$import:(t,e)=>{const n=t.get(be),o=t.get(ke),r=t.get(Oe);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=D(e.textContent||"");for(const e of t)Qe(e,n),Ke(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=Je(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=Je(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=w(s);return Qe(i,n),Ke(i,o),[i]},match:Le.text(),name:"@lexical/html/#text"}),Ze=/* @__PURE__ */Se({$import:()=>[],match:Le.tag("script","style"),name:"@lexical/html/script-style-ignore"}),Xe=/* @__PURE__ */Se({$import:(t,e)=>O(e)||M(e)?[]:[A()],match:Le.tag("br"),name:"@lexical/html/br"}),tn=/* @__PURE__ */Se({$import:(t,e)=>{const n=C();if(N(n,e),E(e,n),""===n.getFormatType()){const t=e.getAttribute("align");t&&Be(t)&&n.setFormat(t)}return I(n,e),[n.splice(0,0,t.$importChildren(e))]},match:Le.tag("p"),name:"@lexical/html/p"}),en=/* @__PURE__ */Se({$import:(t,n,o)=>e().hasNode(Z)?[X()]:o(),match:Le.tag("hr"),name:"@lexical/html/hr"}),nn=[Ze,tn,en,/* @__PURE__ */Se({$import:(t,e,n)=>m(e)?Fe(t.$importChildren(e,{schema:Pe}),e):n(),match:Le.any(),name:"@lexical/html/transparent-block"}),Ye,Xe,He];function on(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 rn(t){const e=[],n=new Map,o=[],r=[],s=[],i=new Set;t.forEach((t,c)=>{const l=function(t){const e=t[re];return void 0===e&&nt(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,on(e,o));return{byTag:c,commentIndices:s,rules:e,textIndices:r,wildcardIndices:o}}function sn(t,e){return g(e)?t.textIndices:8===e.nodeType?t.commentIndices:r(e)?t.byTag.get(e.nodeName)||t.wildcardIndices:cn}const cn=Object.freeze([]);function ln(t){const e=[];for(const n of t)if(un(n))for(const t of n.rules)e.push(t);else e.push(n);return e}function un(t){return"object"==typeof t&&null!==t&&"__type"in t&&"CompiledOverlayRules"===t.__type}function fn(t){const e=ln(t);return{__type:"CompiledOverlayRules",dispatch:rn(e),rules:e}}const an=Object.freeze({});function dn(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=()=>pn(t,e,n);return n&&n.context?Ie(n.context,t.editor)(o):o()}finally{o&&t.overlays.pop()}}(t,e,n),$importOne:(e,n)=>hn(t,e,n),captures:e,get:e=>Ee(e,t.editor),session:t.session};return n}function pn(t,e,n){const o=n&&n.$onChild,r=[];for(const n of Array.from(e.childNodes)){const e=hn(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 hn(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=sn(r,e);s.length>0&&n.push({dispatch:r,indices:s})}const o=sn(t.dispatch,e);o.length>0&&n.push({dispatch:t.dispatch,indices:o});return n}(t,e);if(0===n.length)return gn(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=dn(t,0===Object.keys(l).length?an:l);try{return o.$import(n,e,s)}catch(t){throw t}}}o++,r=0}return gn(t,e)};return s()}(t,e);return n&&n.context?Ie(n.context,t.editor)(o):o()}function gn(t,e){if(0===e.childNodes.length)return[];const n=[];for(const o of Array.from(e.childNodes)){const e=hn(t,o,void 0);for(const t of e)n.push(t)}return n}const mn=/* @__PURE__ */Se({$import:(t,e)=>t.$importChildren(e),match:pe.any(),name:"@lexical/html/default-hoist"}),yn=/* @__PURE__ */a({build(t,e){const n=rn(ln(e.rules)),r=lt(e.contextDefaults,void 0),s=e.preprocess;return{$generateNodesFromDOM:(e,i)=>{const c=it($t,t)||r,l=i&&i.context?lt(i.context,c):c,u=void 0!==l&&l!==c?l:Object.create(c||null),f=new Ae(u),a={session:f};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,a),dt($t,u,()=>function(t,e,n,r){return pn({dispatch:t,editor:e,overlays:r.get(Me).map(t=>t.dispatch),session:r},o(n)?n.body:n,{schema:_e})}(n,t,e,f),t)},defaults:r}},config:{contextDefaults:[],preprocess:[gt],rules:[mn]},mergeConfig:(t,e)=>d(t,{...e,...e.contextDefaults&&{contextDefaults:[...t.contextDefaults,...e.contextDefaults]},...e.preprocess&&{preprocess:[...t.preprocess,...e.preprocess]},...e.rules&&{rules:[...e.rules,...t.rules]}}),name:St});function xn(t,e){return tt(yn).$generateNodesFromDOM(t,e)}const Sn=/* @__PURE__ */a({dependencies:[/* @__PURE__ */_(yn,{rules:nn})],name:"@lexical/html/CoreImport"}),$n=[en],vn=/* @__PURE__ */a({dependencies:[et,Sn],name:"@lexical/html/HorizontalRuleImport"}),Cn={any:pe.any,comment:pe.comment,css:xe,tag:pe.tag,text:pe.text},bn=new Set(["STYLE","SCRIPT"]);function kn(t,e){mt(e);const n=o(e)?e.body.childNodes:e.childNodes,r=[],s=[];for(const e of n)if(!bn.has(e.nodeName)){const n=Nn(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 J&&e.insertAfter(A());for(const e of t){const t=e.getParent();t&&t.splice(e.getIndexWithinParent(),1,e.getChildren())}}(s),r}function Dn(t,n=null,o=e()){return Et([ft(kt,!0)],o)(()=>{const e=L(),r=Nt(o),s=U(n)?B(n.anchor.getNode()):null,i=t.append.bind(t);for(const t of(x(s)?s:e).getChildren())Mn(o,t,i,n,r);return t})}function wn(t,n=L()){const o=e();return Et([ft(kt,!0),ft(bt,!0)],o)(()=>{const e=Nt(o),r=t.append.bind(t);return Mn(o,n,r,null,e),t})}function On(t,e=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&nt(338),V(t),Dn(h().createElement("div"),e,t).innerHTML}function Mn(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&&W(n)&&(f=t(i,n,"clone"));const a=c.$exportDOM(f,e),{element:d,after:p,append:g,$getChildNodes:m}=a;if(!d)return!1;const y=h().createDocumentFragment(),S=m?m():x(f)?f.getChildren():[],$=l&&q(i)&&x(n)?null:i,v=y.append.bind(y);for(const t of S){const o=Mn(e,t,v,$,c);!l&&o&&c.$extractWithChild(n,t,i,"html",e)&&(l=!0)}if(l&&!u){if((r(d)||G(d))&&(g?g(y):d.append(y)),o(d),p){const t=p.call(f,d);t&&(G(d)?d.replaceChildren(t):d.replaceWith(t))}}else o(y);return l}function An(t,e,n,o=null){return Mn(t,e,n.append.bind(n),o,Nt(t))}function Nn(t,e,n,o,r=new Map,s){const i=[];if(bn.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 d=[];const p=(null==c||!H(c))&&(null!=c&&S(c)||o);for(let t=0;t<a.length;t++)d.push(...Nn(a[t],e,n,p,new Map(r),c));if(null!=f&&(d=f(d)),m(t)&&(d=En(t,d,p?()=>{const t=new J;return n.push(t),t}:C)),null==c)if(d.length>0)for(const t of d)i.push(t);else m(t)&&function(t){if(null==t.nextSibling||null==t.previousSibling)return!1;return y(t.nextSibling)&&y(t.previousSibling)}(t)&&i.push(A());else x(c)&&c.append(...d);return i}function En(t,e,n){const o=t.style.textAlign,r=[];let s=[];for(let t=0;t<e.length;t++){const i=e[t];if(S(i))o&&!i.getFormat()&&i.setFormat(o),r.push(i);else if(s.push(i),t===e.length-1||t<e.length-1&&S(e[t+1])){const t=n();t.setFormat(o),t.append(...s),r.push(t),s=[]}}return r}export{An as $appendNodeToHTML,Re as $distributeInlineWrapper,Dn as $generateDOMFromNodes,wn as $generateDOMFromRoot,On as $generateHtmlFromNodes,kn as $generateNodesFromDOM,xn as $generateNodesFromDOMViaExtension,Ee as $getImportContextValue,wt as $getRenderContextValue,Nt as $getSessionDOMRenderConfig,gt as $inlineStylesFromStyleSheets,We as $isBlockLevel,Fe as $propagateTextAlignToBlockChildren,Mt as $setRenderContextValue,At as $updateRenderContextValue,Ie as $withImportContext,Et as $withRenderContext,Pe as BlockSchema,Sn as CoreImportExtension,nn as CoreImportRules,yn as DOMImportExtension,oe as DOMRenderExtension,vn as HorizontalRuleImportExtension,$n as HorizontalRuleImportRules,Me as ImportOverlays,ve as ImportSource,Ce as ImportSourceDataTransfer,be as ImportTextFormat,ke as ImportTextStyle,Oe as ImportWhitespaceConfig,je as InlineSchema,ze as NestedBlockSchema,kt as RenderContextExport,bt as RenderContextRoot,_e as RootSchema,at as contextUpdater,ft as contextValue,$e as createImportState,Ct as createRenderState,we as defaultIsInline,De as defaultPreservesWhitespace,Se as defineImportRule,fn as defineOverlayRules,It as domOverride,he as isElementOfTag,xe as parseSelector,Cn as sel};
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"html"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.48.0",
|
|
12
12
|
"main": "./dist/LexicalHtml.js",
|
|
13
13
|
"types": "./dist/typescript-too-old.d.ts",
|
|
14
14
|
"repository": {
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"directory": "packages/lexical-html"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@lexical/extension": "0.
|
|
21
|
-
"@lexical/
|
|
22
|
-
"@lexical/
|
|
23
|
-
"
|
|
24
|
-
"lexical": "0.
|
|
20
|
+
"@lexical/extension": "0.48.0",
|
|
21
|
+
"@lexical/utils": "0.48.0",
|
|
22
|
+
"@lexical/selection": "0.48.0",
|
|
23
|
+
"lexical": "0.48.0",
|
|
24
|
+
"@lexical/internal": "0.48.0"
|
|
25
25
|
},
|
|
26
26
|
"module": "./dist/LexicalHtml.mjs",
|
|
27
27
|
"sideEffects": false,
|
|
@@ -18,7 +18,11 @@ import {$getExtensionOutput} from '@lexical/extension';
|
|
|
18
18
|
import {defineExtension, type LexicalNode, shallowMergeConfig} from 'lexical';
|
|
19
19
|
|
|
20
20
|
import {DOMImportContextSymbol, DOMImportExtensionName} from '../constants';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
$withFullContext,
|
|
23
|
+
contextFromPairs,
|
|
24
|
+
getContextRecord,
|
|
25
|
+
} from '../ContextRecord';
|
|
22
26
|
import {type CompiledDispatch, compileImportRules} from './compileImportRules';
|
|
23
27
|
import {defineImportRule} from './defineImportRule';
|
|
24
28
|
import {
|
|
@@ -140,18 +144,24 @@ export const DOMImportExtension = /* @__PURE__ */ defineExtension<
|
|
|
140
144
|
options?: GenerateNodesFromDOMOptions,
|
|
141
145
|
) => {
|
|
142
146
|
// The session record IS the root layer of the walk's context.
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
+
// When this import runs nested inside another import operation —
|
|
148
|
+
// e.g. raw HTML inside a Markdown import, or a rule re-entering
|
|
149
|
+
// the walk for sub-content — it chains to the ambient import
|
|
150
|
+
// context so states layered by the outer operation stay
|
|
151
|
+
// readable; the outermost call chains to the editor's
|
|
152
|
+
// contextDefaults. Per-call options.context applies on top,
|
|
153
|
+
// and the record is always a *fresh* mutable child (never the
|
|
154
|
+
// shared parent) so session.set writes never leak outward.
|
|
155
|
+
const parentRecord =
|
|
156
|
+
getContextRecord(DOMImportContextSymbol, editor) || defaults;
|
|
147
157
|
const fromOpts =
|
|
148
158
|
options && options.context
|
|
149
|
-
? contextFromPairs(options.context,
|
|
150
|
-
:
|
|
159
|
+
? contextFromPairs(options.context, parentRecord)
|
|
160
|
+
: parentRecord;
|
|
151
161
|
const sessionRecord: ContextRecord<typeof DOMImportContextSymbol> =
|
|
152
|
-
fromOpts !== undefined && fromOpts !==
|
|
162
|
+
fromOpts !== undefined && fromOpts !== parentRecord
|
|
153
163
|
? fromOpts
|
|
154
|
-
: Object.create(
|
|
164
|
+
: Object.create(parentRecord || null);
|
|
155
165
|
const session = new ImportSessionImpl(sessionRecord);
|
|
156
166
|
const preprocessCtx: DOMPreprocessContext = {session};
|
|
157
167
|
// Stack of preprocessors: config-level first, then per-call.
|