@lexical/html 0.44.1-nightly.20260519.0 → 0.45.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{DOMRenderExtension.d.ts → dist/DOMRenderExtension.d.ts} +12 -1
- package/dist/DOMRenderRuntime.d.ts +51 -0
- package/dist/LexicalHtml.dev.js +3289 -0
- package/dist/LexicalHtml.dev.mjs +3242 -0
- package/{LexicalHtml.js.flow → dist/LexicalHtml.js.flow} +16 -16
- package/dist/LexicalHtml.mjs +57 -0
- package/dist/LexicalHtml.node.mjs +55 -0
- package/dist/LexicalHtml.prod.js +9 -0
- package/dist/LexicalHtml.prod.mjs +9 -0
- package/dist/RenderContext.d.ts +68 -0
- package/{compileDOMRenderConfigOverrides.d.ts → dist/compileDOMRenderConfigOverrides.d.ts} +1 -1
- package/{constants.d.ts → dist/constants.d.ts} +2 -0
- package/dist/domOverride.d.ts +23 -0
- package/dist/import/CoreImportExtension.d.ts +11 -0
- package/dist/import/DOMImportExtension.d.ts +82 -0
- package/dist/import/HorizontalRuleImportExtension.d.ts +28 -0
- package/dist/import/ImportContext.d.ts +208 -0
- package/dist/import/compileImportRules.d.ts +50 -0
- package/dist/import/coreImportRules.d.ts +25 -0
- package/dist/import/defineImportRule.d.ts +32 -0
- package/dist/import/defineOverlayRules.d.ts +66 -0
- package/dist/import/index.d.ts +38 -0
- package/dist/import/inlineStylesFromStyleSheets.d.ts +28 -0
- package/dist/import/parseCss.d.ts +18 -0
- package/dist/import/runImport.d.ts +19 -0
- package/dist/import/schemas.d.ts +106 -0
- package/dist/import/sel.d.ts +74 -0
- package/dist/import/types.d.ts +394 -0
- package/dist/index.d.ts +44 -0
- package/{types.d.ts → dist/types.d.ts} +96 -8
- package/package.json +33 -18
- package/src/ContextRecord.ts +243 -0
- package/src/DOMRenderExtension.ts +96 -0
- package/src/DOMRenderRuntime.ts +265 -0
- package/src/RenderContext.ts +168 -0
- package/src/compileDOMRenderConfigOverrides.ts +416 -0
- package/src/constants.ts +18 -0
- package/src/domOverride.ts +46 -0
- package/src/import/CoreImportExtension.ts +26 -0
- package/src/import/DOMImportExtension.ts +221 -0
- package/src/import/HorizontalRuleImportExtension.ts +52 -0
- package/src/import/ImportContext.ts +339 -0
- package/src/import/compileImportRules.ts +178 -0
- package/src/import/coreImportRules.ts +545 -0
- package/src/import/defineImportRule.ts +40 -0
- package/src/import/defineOverlayRules.ts +105 -0
- package/src/import/index.ts +97 -0
- package/src/import/inlineStylesFromStyleSheets.ts +104 -0
- package/src/import/parseCss.ts +219 -0
- package/src/import/runImport.ts +245 -0
- package/src/import/schemas.ts +280 -0
- package/src/import/sel.ts +314 -0
- package/src/import/types.ts +471 -0
- package/src/index.ts +561 -0
- package/src/types.ts +470 -0
- package/LexicalHtml.dev.js +0 -914
- package/LexicalHtml.dev.mjs +0 -900
- package/LexicalHtml.mjs +0 -24
- package/LexicalHtml.node.mjs +0 -22
- package/LexicalHtml.prod.js +0 -9
- package/LexicalHtml.prod.mjs +0 -9
- package/RenderContext.d.ts +0 -32
- package/domOverride.d.ts +0 -18
- package/index.d.ts +0 -32
- /package/{ContextRecord.d.ts → dist/ContextRecord.d.ts} +0 -0
- /package/{LexicalHtml.js → dist/LexicalHtml.js} +0 -0
package/LexicalHtml.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as modDev from './LexicalHtml.dev.mjs';
|
|
10
|
-
import * as modProd from './LexicalHtml.prod.mjs';
|
|
11
|
-
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
-
export const $generateDOMFromNodes = mod.$generateDOMFromNodes;
|
|
13
|
-
export const $generateDOMFromRoot = mod.$generateDOMFromRoot;
|
|
14
|
-
export const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
|
|
15
|
-
export const $generateNodesFromDOM = mod.$generateNodesFromDOM;
|
|
16
|
-
export const $getRenderContextValue = mod.$getRenderContextValue;
|
|
17
|
-
export const $withRenderContext = mod.$withRenderContext;
|
|
18
|
-
export const DOMRenderExtension = mod.DOMRenderExtension;
|
|
19
|
-
export const RenderContextExport = mod.RenderContextExport;
|
|
20
|
-
export const RenderContextRoot = mod.RenderContextRoot;
|
|
21
|
-
export const contextUpdater = mod.contextUpdater;
|
|
22
|
-
export const contextValue = mod.contextValue;
|
|
23
|
-
export const createRenderState = mod.createRenderState;
|
|
24
|
-
export const domOverride = mod.domOverride;
|
package/LexicalHtml.node.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalHtml.dev.mjs') : import('./LexicalHtml.prod.mjs'));
|
|
10
|
-
export const $generateDOMFromNodes = mod.$generateDOMFromNodes;
|
|
11
|
-
export const $generateDOMFromRoot = mod.$generateDOMFromRoot;
|
|
12
|
-
export const $generateHtmlFromNodes = mod.$generateHtmlFromNodes;
|
|
13
|
-
export const $generateNodesFromDOM = mod.$generateNodesFromDOM;
|
|
14
|
-
export const $getRenderContextValue = mod.$getRenderContextValue;
|
|
15
|
-
export const $withRenderContext = mod.$withRenderContext;
|
|
16
|
-
export const DOMRenderExtension = mod.DOMRenderExtension;
|
|
17
|
-
export const RenderContextExport = mod.RenderContextExport;
|
|
18
|
-
export const RenderContextRoot = mod.RenderContextRoot;
|
|
19
|
-
export const contextUpdater = mod.contextUpdater;
|
|
20
|
-
export const contextValue = mod.contextValue;
|
|
21
|
-
export const createRenderState = mod.createRenderState;
|
|
22
|
-
export const domOverride = mod.domOverride;
|
package/LexicalHtml.prod.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
"use strict";var e=require("@lexical/selection"),t=require("lexical"),n=require("@lexical/extension");function o(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 r;function s(e,t){const{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function i(e){return r&&r.editor===e?r:void 0}function c(e,t){if("cfg"in t){const{cfg:n,updater:o}=t;return[n,o(s(e,n))]}return t}function l(e,t){let n=t;for(const o of e){const[e,r]=c(n,o),i=e.key;if(n===t&&s(n,e)===r)continue;const l=n||u(t);l[i]=r,n=l}return n}function u(e){return Object.create(e||null)}function f(e,t){return[e,t]}const d="@lexical/html/DOM",a=Symbol.for("@lexical/html/DOMExportContext"),p=()=>!0;function g(e,n,o){return function(e,n,o,r){return Object.assign(t.createState(Symbol(n),{isEqual:r,parse:o}),{[e]:!0})}(a,e,n,o)}const h=g("root",Boolean),m=g("isExport",Boolean);function y(e){const t=n.getPeerDependencyFromEditor(e,d);return t?t.output.defaults:void 0}function x(e){return function(e,t){const n=i(t);return n&&n[e]}(a,e)||y(e)}const $=function(e,n=()=>{}){return(o,s=t.$getEditor())=>c=>{const u=i(s),f=u&&u[e],d=l(o,f||n(s));return d&&d!==f?function(e,n,o,s=t.$getEditor()){const c=r,l=i(s);try{return r={...l,editor:s,[e]:n},o()}finally{r=c}}(e,d,c,s):c()}}(a,y);function D(e){return t=>t instanceof e}function N(e,{nodes:t}){if("*"===t)return p;let n={};const r=[];for(const s of t)if("getType"in s){const t=s.getType();if(n){const r=e[t];void 0===r&&o(339,s.name,t),n=Object.assign(n,r.types)}r.push(D(s))}else n=void 0,r.push(s);return n||(1===r.length?r[0]:e=>{for(const t of r)if(t(e))return!0;return!1})}function O(e){return(t,n,o)=>e(t,o)}function E(e){return(t,n,o,r)=>e(t,n,r)}function M(e){return(t,n,o,r,s)=>e(t,n,o,s)}function S(e){return(t,n,o,r,s,i)=>e(t,n,o,r,i)}function v(e,t){return(n,o)=>{const r=()=>e(n,o),s=t(n);return s?s(n,r,o):r()}}function C(e,t){return(n,o,r)=>{const s=()=>e(n,o,r),i=t(n);return i?i(n,o,s,r):s()}}function w(e,t){return(n,o,r,s)=>{const i=()=>e(n,o,r,s),c=t(n);return c?c(n,o,r,i,s):i()}}function R(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 b(e,t){return(n,o,r,s)=>{e(n,o,r,s);const i=t(n);i&&i(n,o,r,s)}}function T(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 A(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 L(e){return"*"===e.nodes}function k(e,o){const r=function(e){const o={},{nodes:r}=n.getKnownTypesAndNodes(e);for(const e of r)o[e.getType()]={klass:e,types:{}};for(const e of Object.values(o))if(e){const n=e.klass.getType();for(let{klass:r}=e;t.$isLexicalNode(r.prototype);r=Object.getPrototypeOf(r)){const{ownNodeType:e}=t.getStaticNodeConfig(r),s=e&&o[e];s&&(s.types[n]=!0)}}return o}(e),s={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const e of function(e){const n=[],o=[],r=[];for(const s of e)if(L(s))n.push(s);else if(Array.isArray(s.nodes))for(const e of s.nodes)t.$isLexicalNode(e.prototype)?r.push(1===s.nodes.length?s:{...s,nodes:[e]}):o.push(1===s.nodes.length?s:{...s,nodes:[e]});const s=new Map,i=e=>{let n=s.get(e);if(void 0===n){n=0;for(let o=e;t.$isLexicalNode(o.prototype);o=Object.getPrototypeOf(o))n++;s.set(e,n)}return n};return r.sort((e,t)=>i(e.nodes[0])-i(t.nodes[0])),[...r,...o,...n]}(o)){const t=N(r,e);for(const n in s){A(s,n,t,e[n])}}return s}function F(e){return e}const P=t.defineExtension({build:(e,t,n)=>({defaults:l(t.contextDefaults,void 0)}),config:{contextDefaults:[],overrides:[]},html:{export:new Map([[t.RootNode,()=>{const e=document.createElement("div");return e.role="textbox",{element:e}}]])},init(e,n){e.dom=function(e,{overrides:n}){const o=k(e,n),r={...t.DEFAULT_EDITOR_DOM_CONFIG,...e.dom};return T(o,"$createDOM",r,v,O),T(o,"$exportDOM",r,v,O),T(o,"$extractWithChild",r,R,S),T(o,"$getDOMSlot",r,C,E),T(o,"$shouldExclude",r,C,E),T(o,"$shouldInclude",r,C,E),T(o,"$updateDOM",r,w,M),T(o,"$decorateDOM",r,b,F),r}(e,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:d});function _(e){return e.constructor.name===CSSStyleRule.name}const B=new Set(["STYLE","SCRIPT"]);function I(e,n=null,o=t.$getEditor()){return $([f(m,!0)],o)(()=>{const r=t.$getRoot(),s=t.$getEditorDOMRenderConfig(o),i=e.append.bind(e);for(const e of r.getChildren())j(o,e,i,n,s);return e})}function j(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 f=i.$exportDOM(u,n),{element:d,after:a,append:p,$getChildNodes:g}=f;if(!d)return!1;const h=document.createDocumentFragment(),m=g?g():t.$isElementNode(u)?u.getChildren():[],y=h.append.bind(h);for(const e of m){const t=j(n,e,y,s,i);!c&&t&&i.$extractWithChild(o,e,s,"html",n)&&(c=!0)}if(c&&!l){if((t.isHTMLElement(d)||t.isDocumentFragment(d))&&(p?p(h):d.append(h)),r(d),a){const e=a.call(u,d);e&&(t.isDocumentFragment(d)?d.replaceChildren(e):d.replaceWith(e))}}else r(h);return c}function q(e,n,o,r,s=new Map,i){const c=[];if(B.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),f=u?u(e):null;let d=null;if(null!==f){d=f.after;const t=f.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!=f.forChild&&s.set(e.nodeName,f.forChild)}const a=e.childNodes;let p=[];const g=(null==l||!t.$isRootOrShadowRoot(l))&&(null!=l&&t.$isBlockElementNode(l)||r);for(let e=0;e<a.length;e++)p.push(...q(a[e],n,o,g,new Map(s),l));if(null!=d&&(p=d(p)),t.isBlockDomNode(e)&&(p=U(e,p,g?()=>{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 U(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.$generateDOMFromNodes=I,exports.$generateDOMFromRoot=function(e,n=t.$getRoot()){const o=t.$getEditor();return $([f(m,!0),f(h,!0)],o)(()=>{const r=t.$getEditorDOMRenderConfig(o),s=e.append.bind(e);return j(o,n,s,null,r),e})},exports.$generateHtmlFromNodes=function(e,t=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&o(338),I(document.createElement("div"),t,e).innerHTML},exports.$generateNodesFromDOM=function(e,n){t.isDOMDocumentNode(n)&&function(e){if(null===e.querySelector("style"))return;const n=new Map;function o(e){let t=n.get(e);if(void 0===t){t=new Set;for(let n=0;n<e.style.length;n++)t.add(e.style[n]);n.set(e,t)}return t}try{for(const n of Array.from(e.styleSheets)){let r;try{r=n.cssRules}catch(e){continue}for(const n of Array.from(r)){if(!_(n))continue;let r;try{r=e.querySelectorAll(n.selectorText)}catch(e){continue}for(const e of Array.from(r)){if(!t.isHTMLElement(e))continue;const r=o(e);for(let t=0;t<n.style.length;t++){const o=n.style[t];r.has(o)||e.style.setProperty(o,n.style.getPropertyValue(o),n.style.getPropertyPriority(o))}}}}}catch(e){}}(n);const o=t.isDOMDocumentNode(n)?n.body.childNodes:n.childNodes,r=[],s=[];for(const t of o)if(!B.has(t.nodeName)){const n=q(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.$getRenderContextValue=function(e,n=t.$getEditor()){return s(x(n),e)},exports.$withRenderContext=$,exports.DOMRenderExtension=P,exports.RenderContextExport=m,exports.RenderContextRoot=h,exports.contextUpdater=function(e,t){return{cfg:e,updater:t}},exports.contextValue=f,exports.createRenderState=g,exports.domOverride=function(e,t){return{...t,nodes:e}};
|
package/LexicalHtml.prod.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import{$sliceSelectedTextNodeContent as t}from"@lexical/selection";import{$getEditor as n,createState as e,DEFAULT_EDITOR_DOM_CONFIG as o,$isLexicalNode as r,getStaticNodeConfig as c,defineExtension as s,shallowMergeConfig as u,RootNode as i,$getRoot as l,$getEditorDOMRenderConfig as f,isDOMDocumentNode as d,$isTextNode as a,$isElementNode as p,isHTMLElement as h,isDocumentFragment as y,$isRootOrShadowRoot as g,$isBlockElementNode as m,isBlockDomNode as x,$createLineBreakNode as v,ArtificialNode__DO_NOT_USE as $,isInlineDomNode as S,$createParagraphNode as b}from"lexical";import{getPeerDependencyFromEditor as O,getKnownTypesAndNodes as M}from"@lexical/extension";function w(t,...n){const e=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of n)o.append("v",t);throw e.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let D;function C(t,n){const{key:e}=n;return t&&e in t?t[e]:n.defaultValue}function A(t){return D&&D.editor===t?D:void 0}function P(t,n){if("cfg"in n){const{cfg:e,updater:o}=n;return[e,o(C(t,e))]}return n}function E(t,n){let e=n;for(const o of t){const[t,r]=P(e,o),c=t.key;if(e===n&&C(e,t)===r)continue;const s=e||N(n);s[c]=r,e=s}return e}function N(t){return Object.create(t||null)}function T(t,n){return[t,n]}function j(t,n){return{cfg:t,updater:n}}const k="@lexical/html/DOM",L=Symbol.for("@lexical/html/DOMExportContext"),I=()=>!0;function R(t,n,o){return function(t,n,o,r){return Object.assign(e(Symbol(n),{isEqual:r,parse:o}),{[t]:!0})}(L,t,n,o)}const W=R("root",Boolean),F=R("isExport",Boolean);function q(t){const n=O(t,k);return n?n.output.defaults:void 0}function B(t){return function(t,n){const e=A(n);return e&&e[t]}(L,t)||q(t)}function U(t,e=n()){return C(B(e),t)}const V=function(t,e=()=>{}){return(o,r=n())=>c=>{const s=A(r),u=s&&s[t],i=E(o,u||e(r));return i&&i!==u?function(t,e,o,r=n()){const c=D,s=A(r);try{return D={...s,editor:r,[t]:e},o()}finally{D=c}}(t,i,c,r):c()}}(L,q);function H(t,n){return{...n,nodes:t}}function Y(t){return n=>n instanceof t}function _(t,{nodes:n}){if("*"===n)return I;let e={};const o=[];for(const r of n)if("getType"in r){const n=r.getType();if(e){const o=t[n];void 0===o&&w(339,r.name,n),e=Object.assign(e,o.types)}o.push(Y(r))}else e=void 0,o.push(r);return e||(1===o.length?o[0]:t=>{for(const n of o)if(n(t))return!0;return!1})}function z(t){return(n,e,o)=>t(n,o)}function G(t){return(n,e,o,r)=>t(n,e,r)}function J(t){return(n,e,o,r,c)=>t(n,e,o,c)}function K(t){return(n,e,o,r,c,s)=>t(n,e,o,r,s)}function Q(t,n){return(e,o)=>{const r=()=>t(e,o),c=n(e);return c?c(e,r,o):r()}}function X(t,n){return(e,o,r)=>{const c=()=>t(e,o,r),s=n(e);return s?s(e,o,c,r):c()}}function Z(t,n){return(e,o,r,c)=>{const s=()=>t(e,o,r,c),u=n(e);return u?u(e,o,r,s,c):s()}}function tt(t,n){return(e,o,r,c,s)=>{const u=()=>t(e,o,r,c,s),i=n(e);return i?i(e,o,r,c,u,s):u()}}function nt(t,n){return(e,o,r,c)=>{t(e,o,r,c);const s=n(e);s&&s(e,o,r,c)}}function et(t,n,e,o,r){let c=e[n];for(const e of t[n])if("function"==typeof e[0]){const[t,n]=e;c=o(c,e=>t(e)&&n||void 0)}else{const t=e[1],n={};for(const e in t){const r=t[e];r&&(n[e]=r.reduce((t,n)=>o(t,()=>n),c))}c=o(c,t=>{const e=n[t.getType()];return e&&r(e)})}e[n]=c}function ot(t,n,e,o){if(!o)return;const r=t[n];if("function"==typeof e)r.push([e,o]);else{const t=r[r.length-1];let n;t&&"types"===t[0]?n=t[1]:(n={},r.push(["types",n]));for(const t in e){const e=n[t]||[];n[t]=e,e.push(o)}}}function rt(t){return"*"===t.nodes}function ct(t,n){const e=function(t){const n={},{nodes:e}=M(t);for(const t of e)n[t.getType()]={klass:t,types:{}};for(const t of Object.values(n))if(t){const e=t.klass.getType();for(let{klass:o}=t;r(o.prototype);o=Object.getPrototypeOf(o)){const{ownNodeType:t}=c(o),r=t&&n[t];r&&(r.types[e]=!0)}}return n}(t),o={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const t of function(t){const n=[],e=[],o=[];for(const c of t)if(rt(c))n.push(c);else if(Array.isArray(c.nodes))for(const t of c.nodes)r(t.prototype)?o.push(1===c.nodes.length?c:{...c,nodes:[t]}):e.push(1===c.nodes.length?c:{...c,nodes:[t]});const c=new Map,s=t=>{let n=c.get(t);if(void 0===n){n=0;for(let e=t;r(e.prototype);e=Object.getPrototypeOf(e))n++;c.set(t,n)}return n};return o.sort((t,n)=>s(t.nodes[0])-s(n.nodes[0])),[...o,...e,...n]}(n)){const n=_(e,t);for(const e in o){ot(o,e,n,t[e])}}return o}function st(t){return t}const ut=s({build:(t,n,e)=>({defaults:E(n.contextDefaults,void 0)}),config:{contextDefaults:[],overrides:[]},html:{export:new Map([[i,()=>{const t=document.createElement("div");return t.role="textbox",{element:t}}]])},init(t,n){t.dom=function(t,{overrides:n}){const e=ct(t,n),r={...o,...t.dom};return et(e,"$createDOM",r,Q,z),et(e,"$exportDOM",r,Q,z),et(e,"$extractWithChild",r,tt,K),et(e,"$getDOMSlot",r,X,G),et(e,"$shouldExclude",r,X,G),et(e,"$shouldInclude",r,X,G),et(e,"$updateDOM",r,Z,J),et(e,"$decorateDOM",r,nt,st),r}(t,n)},mergeConfig(t,n){const e=u(t,n);for(const o of["overrides","contextDefaults"])n[o]&&(e[o]=[...t[o],...n[o]]);return e},name:k});function it(t){return t.constructor.name===CSSStyleRule.name}const lt=new Set(["STYLE","SCRIPT"]);function ft(t,n){d(n)&&function(t){if(null===t.querySelector("style"))return;const n=new Map;function e(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 n of Array.from(t.styleSheets)){let o;try{o=n.cssRules}catch(t){continue}for(const n of Array.from(o)){if(!it(n))continue;let o;try{o=t.querySelectorAll(n.selectorText)}catch(t){continue}for(const t of Array.from(o)){if(!h(t))continue;const o=e(t);for(let e=0;e<n.style.length;e++){const r=n.style[e];o.has(r)||t.style.setProperty(r,n.style.getPropertyValue(r),n.style.getPropertyPriority(r))}}}}}catch(t){}}(n);const e=d(n)?n.body.childNodes:n.childNodes,o=[],r=[];for(const n of e)if(!lt.has(n.nodeName)){const e=yt(n,t,r,!1);if(null!==e)for(const t of e)o.push(t)}return function(t){for(const n of t)n.getParent()&&n.getNextSibling()instanceof $&&n.insertAfter(v());for(const n of t){const t=n.getParent();t&&t.splice(n.getIndexWithinParent(),1,n.getChildren())}}(r),o}function dt(t,e=null,o=n()){return V([T(F,!0)],o)(()=>{const n=l(),r=f(o),c=t.append.bind(t);for(const t of n.getChildren())ht(o,t,c,e,r);return t})}function at(t,e=l()){const o=n();return V([T(F,!0),T(W,!0)],o)(()=>{const n=f(o),r=t.append.bind(t);return ht(o,e,r,null,n),t})}function pt(t,n=null){return("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)&&w(338),dt(document.createElement("div"),n,t).innerHTML}function ht(n,e,o,r=null,c=f(n)){let s=c.$shouldInclude(e,r,n);const u=c.$shouldExclude(e,r,n);let i=e;null!==r&&a(e)&&(i=t(r,e,"clone"));const l=c.$exportDOM(i,n),{element:d,after:g,append:m,$getChildNodes:x}=l;if(!d)return!1;const v=document.createDocumentFragment(),$=x?x():p(i)?i.getChildren():[],S=v.append.bind(v);for(const t of $){const o=ht(n,t,S,r,c);!s&&o&&c.$extractWithChild(e,t,r,"html",n)&&(s=!0)}if(s&&!u){if((h(d)||y(d))&&(m?m(v):d.append(v)),o(d),g){const t=g.call(i,d);t&&(y(d)?d.replaceChildren(t):d.replaceWith(t))}}else o(v);return s}function yt(t,n,e,o,r=new Map,c){const s=[];if(lt.has(t.nodeName))return s;let u=null;const i=function(t,n){const{nodeName:e}=t,o=n._htmlConversions.get(e.toLowerCase());let r=null;if(void 0!==o)for(const n of o){const e=n(t);null!==e&&(null===r||(r.priority||0)<=(e.priority||0))&&(r=e)}return null!==r?r.conversion:null}(t,n),l=i?i(t):null;let f=null;if(null!==l){f=l.after;const n=l.node;if(u=Array.isArray(n)?n[n.length-1]:n,null!==u){for(const[,t]of r)if(u=t(u,c),!u)break;u&&s.push(...Array.isArray(n)?n:[u])}null!=l.forChild&&r.set(t.nodeName,l.forChild)}const d=t.childNodes;let a=[];const h=(null==u||!g(u))&&(null!=u&&m(u)||o);for(let t=0;t<d.length;t++)a.push(...yt(d[t],n,e,h,new Map(r),u));if(null!=f&&(a=f(a)),x(t)&&(a=gt(t,a,h?()=>{const t=new $;return e.push(t),t}:b)),null==u)if(a.length>0)for(const t of a)s.push(t);else x(t)&&function(t){if(null==t.nextSibling||null==t.previousSibling)return!1;return S(t.nextSibling)&&S(t.previousSibling)}(t)&&s.push(v());else p(u)&&u.append(...a);return s}function gt(t,n,e){const o=t.style.textAlign,r=[];let c=[];for(let t=0;t<n.length;t++){const s=n[t];if(m(s))o&&!s.getFormat()&&s.setFormat(o),r.push(s);else if(c.push(s),t===n.length-1||t<n.length-1&&m(n[t+1])){const t=e();t.setFormat(o),t.append(...c),r.push(t),c=[]}}return r}export{dt as $generateDOMFromNodes,at as $generateDOMFromRoot,pt as $generateHtmlFromNodes,ft as $generateNodesFromDOM,U as $getRenderContextValue,V as $withRenderContext,ut as DOMRenderExtension,F as RenderContextExport,W as RenderContextRoot,j as contextUpdater,T as contextValue,R as createRenderState,H as domOverride};
|
package/RenderContext.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor } from 'lexical';
|
|
2
|
-
import { AnyRenderStateConfigPairOrUpdater, RenderStateConfig } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Create a context state to be used during render.
|
|
5
|
-
*
|
|
6
|
-
* Note that to support the ValueOrUpdater pattern you can not use a
|
|
7
|
-
* function for V (but you may wrap it in an array or object).
|
|
8
|
-
*
|
|
9
|
-
* @experimental
|
|
10
|
-
* @__NO_SIDE_EFFECTS__
|
|
11
|
-
*/
|
|
12
|
-
export declare function createRenderState<V>(name: string, getDefaultValue: () => V, isEqual?: (a: V, b: V) => boolean): RenderStateConfig<V>;
|
|
13
|
-
/**
|
|
14
|
-
* Render context state that is true if the export was initiated from the root of the document.
|
|
15
|
-
* @experimental
|
|
16
|
-
*/
|
|
17
|
-
export declare const RenderContextRoot: RenderStateConfig<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
* Render context state that is true if this is an export operation ($generateHtmlFromNodes).
|
|
20
|
-
* @experimental
|
|
21
|
-
*/
|
|
22
|
-
export declare const RenderContextExport: RenderStateConfig<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Get a render context value during a DOM render or export operation.
|
|
25
|
-
* @experimental
|
|
26
|
-
*/
|
|
27
|
-
export declare function $getRenderContextValue<V>(cfg: RenderStateConfig<V>, editor?: LexicalEditor): V;
|
|
28
|
-
/**
|
|
29
|
-
* Execute a callback within a render context with the given config pairs.
|
|
30
|
-
* @experimental
|
|
31
|
-
*/
|
|
32
|
-
export declare const $withRenderContext: (cfg: readonly AnyRenderStateConfigPairOrUpdater[], editor?: LexicalEditor) => <T>(f: () => T) => T;
|
package/domOverride.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import type { DOMRenderMatch, NodeMatch } from './types';
|
|
9
|
-
import type { LexicalNode } from 'lexical';
|
|
10
|
-
/**
|
|
11
|
-
* A convenience function for type inference when constructing DOM overrides for
|
|
12
|
-
* use with {@link DOMRenderExtension}.
|
|
13
|
-
*
|
|
14
|
-
* @experimental
|
|
15
|
-
* @__NO_SIDE_EFFECTS__
|
|
16
|
-
*/
|
|
17
|
-
export declare function domOverride(nodes: '*', config: Omit<DOMRenderMatch<LexicalNode>, 'nodes'>): DOMRenderMatch<LexicalNode>;
|
|
18
|
-
export declare function domOverride<T extends LexicalNode>(nodes: readonly NodeMatch<T>[], config: Omit<DOMRenderMatch<T>, 'nodes'>): DOMRenderMatch<T>;
|
package/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import type { BaseSelection, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
-
export { contextUpdater, contextValue } from './ContextRecord';
|
|
10
|
-
export { domOverride } from './domOverride';
|
|
11
|
-
export { DOMRenderExtension } from './DOMRenderExtension';
|
|
12
|
-
export { $getRenderContextValue, $withRenderContext, createRenderState, RenderContextExport, RenderContextRoot, } from './RenderContext';
|
|
13
|
-
export type { AnyDOMRenderMatch, AnyRenderStateConfig, AnyRenderStateConfigPairOrUpdater, ContextPairOrUpdater, DOMRenderConfig, DOMRenderExtensionOutput, DOMRenderMatch, NodeMatch, } from './types';
|
|
14
|
-
/**
|
|
15
|
-
* How you parse your html string to get a document is left up to you. In the browser you can use the native
|
|
16
|
-
* DOMParser API to generate a document (see clipboard.ts), but to use in a headless environment you can use JSDom
|
|
17
|
-
* or an equivalent library and pass in the document here.
|
|
18
|
-
*/
|
|
19
|
-
export declare function $generateNodesFromDOM(editor: LexicalEditor, dom: Document | ParentNode): Array<LexicalNode>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate DOM nodes from the editor state into the given container element,
|
|
22
|
-
* using the editor's {@link EditorDOMRenderConfig}.
|
|
23
|
-
* @experimental
|
|
24
|
-
*/
|
|
25
|
-
export declare function $generateDOMFromNodes<T extends HTMLElement | DocumentFragment>(container: T, selection?: null | BaseSelection, editor?: LexicalEditor): T;
|
|
26
|
-
/**
|
|
27
|
-
* Generate DOM nodes from a root node into the given container element,
|
|
28
|
-
* including the root node itself. Uses the editor's {@link EditorDOMRenderConfig}.
|
|
29
|
-
* @experimental
|
|
30
|
-
*/
|
|
31
|
-
export declare function $generateDOMFromRoot<T extends HTMLElement | DocumentFragment>(container: T, root?: LexicalNode): T;
|
|
32
|
-
export declare function $generateHtmlFromNodes(editor: LexicalEditor, selection?: BaseSelection | null): string;
|
|
File without changes
|
|
File without changes
|