@lexical/html 0.32.2-nightly.20250620.0 → 0.32.2-nightly.20250623.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.
@@ -65,7 +65,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = nu
65
65
  target = clone;
66
66
  }
67
67
  const children = lexical.$isElementNode(target) ? target.getChildren() : [];
68
- const registeredNode = editor._nodes.get(target.getType());
68
+ const registeredNode = lexical.getRegisteredNode(editor, target.getType());
69
69
  let exportOutput;
70
70
 
71
71
  // Use HTMLConfig overrides, if available.
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { $sliceSelectedTextNodeContent } from '@lexical/selection';
10
10
  import { isHTMLElement, isBlockDomNode } from '@lexical/utils';
11
- import { $getRoot, $isElementNode, $cloneWithProperties, $isTextNode, isDocumentFragment, $isRootOrShadowRoot, $isBlockElementNode, $createLineBreakNode, ArtificialNode__DO_NOT_USE, isInlineDomNode, $createParagraphNode } from 'lexical';
11
+ import { $getRoot, $isElementNode, $cloneWithProperties, $isTextNode, getRegisteredNode, isDocumentFragment, $isRootOrShadowRoot, $isBlockElementNode, $createLineBreakNode, ArtificialNode__DO_NOT_USE, isInlineDomNode, $createParagraphNode } from 'lexical';
12
12
 
13
13
  /**
14
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -63,7 +63,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection = null
63
63
  target = clone;
64
64
  }
65
65
  const children = $isElementNode(target) ? target.getChildren() : [];
66
- const registeredNode = editor._nodes.get(target.getType());
66
+ const registeredNode = getRegisteredNode(editor, target.getType());
67
67
  let exportOutput;
68
68
 
69
69
  // Use HTMLConfig overrides, if available.
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/selection"),n=require("@lexical/utils"),t=require("lexical");function o(l,i,r,s=null){let c=null===s||i.isSelected(s);const u=t.$isElementNode(i)&&i.excludeFromCopy("html");let d=i;if(null!==s){let n=t.$cloneWithProperties(i);n=t.$isTextNode(n)&&null!==s?e.$sliceSelectedTextNodeContent(s,n):n,d=n}const a=t.$isElementNode(d)?d.getChildren():[],f=l._nodes.get(d.getType());let m;m=f&&void 0!==f.exportDOM?f.exportDOM(l,d):d.exportDOM(l);const{element:h,after:p}=m;if(!h)return!1;const g=document.createDocumentFragment();for(let e=0;e<a.length;e++){const n=a[e],r=o(l,n,g,s);!c&&t.$isElementNode(i)&&r&&i.extractWithChild(n,s,"html")&&(c=!0)}if(c&&!u){if((n.isHTMLElement(h)||t.isDocumentFragment(h))&&h.append(g),r.append(h),p){const e=p.call(d,h);e&&(t.isDocumentFragment(h)?h.replaceChildren(e):h.replaceWith(e))}}else r.append(g);return c}const l=new Set(["STYLE","SCRIPT"]);function i(e,o,s,c,u=new Map,d){let a=[];if(l.has(e.nodeName))return a;let f=null;const m=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t)}return null!==l?l.conversion:null}(e,o),h=m?m(e):null;let p=null;if(null!==h){p=h.after;const n=h.node;if(f=Array.isArray(n)?n[n.length-1]:n,null!==f){for(const[,e]of u)if(f=e(f,d),!f)break;f&&a.push(...Array.isArray(n)?n:[f])}null!=h.forChild&&u.set(e.nodeName,h.forChild)}const g=e.childNodes;let N=[];const $=(null==f||!t.$isRootOrShadowRoot(f))&&(null!=f&&t.$isBlockElementNode(f)||c);for(let e=0;e<g.length;e++)N.push(...i(g[e],o,s,$,new Map(u),f));return null!=p&&(N=p(N)),n.isBlockDomNode(e)&&(N=r(e,N,$?()=>{const e=new t.ArtificialNode__DO_NOT_USE;return s.push(e),e}:t.$createParagraphNode)),null==f?N.length>0?a=a.concat(N):n.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return!1;return t.isInlineDomNode(e.nextSibling)&&t.isInlineDomNode(e.previousSibling)}(e)&&(a=a.concat(t.$createLineBreakNode())):t.$isElementNode(f)&&f.append(...N),a}function r(e,n,o){const l=e.style.textAlign,i=[];let r=[];for(let e=0;e<n.length;e++){const s=n[e];if(t.$isBlockElementNode(s))l&&!s.getFormat()&&s.setFormat(l),i.push(s);else if(r.push(s),e===n.length-1||e<n.length-1&&t.$isBlockElementNode(n[e+1])){const e=o();e.setFormat(l),e.append(...r),i.push(e),r=[]}}return i}exports.$generateHtmlFromNodes=function(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const l=document.createElement("div"),i=t.$getRoot().getChildren();for(let t=0;t<i.length;t++){o(e,i[t],l,n)}return l.innerHTML},exports.$generateNodesFromDOM=function(e,n){const o=n.body?n.body.childNodes:[];let r=[];const s=[];for(let n=0;n<o.length;n++){const t=o[n];if(!l.has(t.nodeName)){const n=i(t,e,s,!1);null!==n&&(r=r.concat(n))}}return function(e){for(const n of e)n.getNextSibling()instanceof t.ArtificialNode__DO_NOT_USE&&n.insertAfter(t.$createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove()}}(s),r};
9
+ "use strict";var e=require("@lexical/selection"),t=require("@lexical/utils"),n=require("lexical");function o(l,i,r,s=null){let c=null===s||i.isSelected(s);const d=n.$isElementNode(i)&&i.excludeFromCopy("html");let u=i;if(null!==s){let t=n.$cloneWithProperties(i);t=n.$isTextNode(t)&&null!==s?e.$sliceSelectedTextNodeContent(s,t):t,u=t}const a=n.$isElementNode(u)?u.getChildren():[],f=n.getRegisteredNode(l,u.getType());let m;m=f&&void 0!==f.exportDOM?f.exportDOM(l,u):u.exportDOM(l);const{element:h,after:p}=m;if(!h)return!1;const g=document.createDocumentFragment();for(let e=0;e<a.length;e++){const t=a[e],r=o(l,t,g,s);!c&&n.$isElementNode(i)&&r&&i.extractWithChild(t,s,"html")&&(c=!0)}if(c&&!d){if((t.isHTMLElement(h)||n.isDocumentFragment(h))&&h.append(g),r.append(h),p){const e=p.call(u,h);e&&(n.isDocumentFragment(h)?h.replaceChildren(e):h.replaceWith(e))}}else r.append(g);return c}const l=new Set(["STYLE","SCRIPT"]);function i(e,o,s,c,d=new Map,u){let a=[];if(l.has(e.nodeName))return a;let f=null;const m=function(e,t){const{nodeName:n}=e,o=t._htmlConversions.get(n.toLowerCase());let l=null;if(void 0!==o)for(const t of o){const n=t(e);null!==n&&(null===l||(l.priority||0)<=(n.priority||0))&&(l=n)}return null!==l?l.conversion:null}(e,o),h=m?m(e):null;let p=null;if(null!==h){p=h.after;const t=h.node;if(f=Array.isArray(t)?t[t.length-1]:t,null!==f){for(const[,e]of d)if(f=e(f,u),!f)break;f&&a.push(...Array.isArray(t)?t:[f])}null!=h.forChild&&d.set(e.nodeName,h.forChild)}const g=e.childNodes;let N=[];const $=(null==f||!n.$isRootOrShadowRoot(f))&&(null!=f&&n.$isBlockElementNode(f)||c);for(let e=0;e<g.length;e++)N.push(...i(g[e],o,s,$,new Map(d),f));return null!=p&&(N=p(N)),t.isBlockDomNode(e)&&(N=r(e,N,$?()=>{const e=new n.ArtificialNode__DO_NOT_USE;return s.push(e),e}:n.$createParagraphNode)),null==f?N.length>0?a=a.concat(N):t.isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return!1;return n.isInlineDomNode(e.nextSibling)&&n.isInlineDomNode(e.previousSibling)}(e)&&(a=a.concat(n.$createLineBreakNode())):n.$isElementNode(f)&&f.append(...N),a}function r(e,t,o){const l=e.style.textAlign,i=[];let r=[];for(let e=0;e<t.length;e++){const s=t[e];if(n.$isBlockElementNode(s))l&&!s.getFormat()&&s.setFormat(l),i.push(s);else if(r.push(s),e===t.length-1||e<t.length-1&&n.$isBlockElementNode(t[e+1])){const e=o();e.setFormat(l),e.append(...r),i.push(e),r=[]}}return i}exports.$generateHtmlFromNodes=function(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const l=document.createElement("div"),i=n.$getRoot().getChildren();for(let n=0;n<i.length;n++){o(e,i[n],l,t)}return l.innerHTML},exports.$generateNodesFromDOM=function(e,t){const o=t.body?t.body.childNodes:[];let r=[];const s=[];for(let t=0;t<o.length;t++){const n=o[t];if(!l.has(n.nodeName)){const t=i(n,e,s,!1);null!==t&&(r=r.concat(t))}}return function(e){for(const t of e)t.getNextSibling()instanceof n.ArtificialNode__DO_NOT_USE&&t.insertAfter(n.$createLineBreakNode());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(s),r};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$sliceSelectedTextNodeContent as e}from"@lexical/selection";import{isHTMLElement as n,isBlockDomNode as t}from"@lexical/utils";import{$getRoot as o,$isElementNode as l,$cloneWithProperties as r,$isTextNode as i,isDocumentFragment as s,$isRootOrShadowRoot as c,$isBlockElementNode as u,$createLineBreakNode as f,ArtificialNode__DO_NOT_USE as a,isInlineDomNode as d,$createParagraphNode as p}from"lexical";function h(e,n){const t=n.body?n.body.childNodes:[];let o=[];const l=[];for(let n=0;n<t.length;n++){const r=t[n];if(!x.has(r.nodeName)){const n=y(r,e,l,!1);null!==n&&(o=o.concat(n))}}return function(e){for(const n of e)n.getNextSibling()instanceof a&&n.insertAfter(f());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove()}}(l),o}function m(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),l=o().getChildren();for(let o=0;o<l.length;o++){g(e,l[o],t,n)}return t.innerHTML}function g(t,o,c,u=null){let f=null===u||o.isSelected(u);const a=l(o)&&o.excludeFromCopy("html");let d=o;if(null!==u){let n=r(o);n=i(n)&&null!==u?e(u,n):n,d=n}const p=l(d)?d.getChildren():[],h=t._nodes.get(d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:x,after:y}=m;if(!x)return!1;const w=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],r=g(t,n,w,u);!f&&l(o)&&r&&o.extractWithChild(n,u,"html")&&(f=!0)}if(f&&!a){if((n(x)||s(x))&&x.append(w),c.append(x),y){const e=y.call(d,x);e&&(s(x)?x.replaceChildren(e):x.replaceWith(e))}}else c.append(w);return f}const x=new Set(["STYLE","SCRIPT"]);function y(e,n,o,r,i=new Map,s){let h=[];if(x.has(e.nodeName))return h;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t)}return null!==l?l.conversion:null}(e,n),b=g?g(e):null;let C=null;if(null!==b){C=b.after;const n=b.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&h.push(...Array.isArray(n)?n:[m])}null!=b.forChild&&i.set(e.nodeName,b.forChild)}const S=e.childNodes;let v=[];const N=(null==m||!c(m))&&(null!=m&&u(m)||r);for(let e=0;e<S.length;e++)v.push(...y(S[e],n,o,N,new Map(i),m));return null!=C&&(v=C(v)),t(e)&&(v=w(e,v,N?()=>{const e=new a;return o.push(e),e}:p)),null==m?v.length>0?h=h.concat(v):t(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return!1;return d(e.nextSibling)&&d(e.previousSibling)}(e)&&(h=h.concat(f())):l(m)&&m.append(...v),h}function w(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(u(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&u(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[]}}return l}export{m as $generateHtmlFromNodes,h as $generateNodesFromDOM};
9
+ import{$sliceSelectedTextNodeContent as e}from"@lexical/selection";import{isHTMLElement as n,isBlockDomNode as t}from"@lexical/utils";import{$getRoot as o,$isElementNode as l,$cloneWithProperties as r,$isTextNode as i,getRegisteredNode as s,isDocumentFragment as c,$isRootOrShadowRoot as u,$isBlockElementNode as f,$createLineBreakNode as a,ArtificialNode__DO_NOT_USE as d,isInlineDomNode as p,$createParagraphNode as h}from"lexical";function m(e,n){const t=n.body?n.body.childNodes:[];let o=[];const l=[];for(let n=0;n<t.length;n++){const r=t[n];if(!y.has(r.nodeName)){const n=w(r,e,l,!1);null!==n&&(o=o.concat(n))}}return function(e){for(const n of e)n.getNextSibling()instanceof d&&n.insertAfter(a());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove()}}(l),o}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),l=o().getChildren();for(let o=0;o<l.length;o++){x(e,l[o],t,n)}return t.innerHTML}function x(t,o,u,f=null){let a=null===f||o.isSelected(f);const d=l(o)&&o.excludeFromCopy("html");let p=o;if(null!==f){let n=r(o);n=i(n)&&null!==f?e(f,n):n,p=n}const h=l(p)?p.getChildren():[],m=s(t,p.getType());let g;g=m&&void 0!==m.exportDOM?m.exportDOM(t,p):p.exportDOM(t);const{element:y,after:w}=g;if(!y)return!1;const b=document.createDocumentFragment();for(let e=0;e<h.length;e++){const n=h[e],r=x(t,n,b,f);!a&&l(o)&&r&&o.extractWithChild(n,f,"html")&&(a=!0)}if(a&&!d){if((n(y)||c(y))&&y.append(b),u.append(y),w){const e=w.call(p,y);e&&(c(y)?y.replaceChildren(e):y.replaceWith(e))}}else u.append(b);return a}const y=new Set(["STYLE","SCRIPT"]);function w(e,n,o,r,i=new Map,s){let c=[];if(y.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t)}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let C=null;if(null!==x){C=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m])}null!=x.forChild&&i.set(e.nodeName,x.forChild)}const S=e.childNodes;let v=[];const N=(null==m||!u(m))&&(null!=m&&f(m)||r);for(let e=0;e<S.length;e++)v.push(...w(S[e],n,o,N,new Map(i),m));return null!=C&&(v=C(v)),t(e)&&(v=b(e,v,N?()=>{const e=new d;return o.push(e),e}:h)),null==m?v.length>0?c=c.concat(v):t(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return!1;return p(e.nextSibling)&&p(e.previousSibling)}(e)&&(c=c.concat(a())):l(m)&&m.append(...v),c}function b(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(f(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&f(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[]}}return l}export{g as $generateHtmlFromNodes,m as $generateNodesFromDOM};
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "html"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.32.2-nightly.20250620.0",
11
+ "version": "0.32.2-nightly.20250623.0",
12
12
  "main": "LexicalHtml.js",
13
13
  "types": "index.d.ts",
14
14
  "repository": {
@@ -17,9 +17,9 @@
17
17
  "directory": "packages/lexical-html"
18
18
  },
19
19
  "dependencies": {
20
- "@lexical/selection": "0.32.2-nightly.20250620.0",
21
- "@lexical/utils": "0.32.2-nightly.20250620.0",
22
- "lexical": "0.32.2-nightly.20250620.0"
20
+ "@lexical/selection": "0.32.2-nightly.20250623.0",
21
+ "@lexical/utils": "0.32.2-nightly.20250623.0",
22
+ "lexical": "0.32.2-nightly.20250623.0"
23
23
  },
24
24
  "module": "LexicalHtml.mjs",
25
25
  "sideEffects": false,