@lexical/html
Advanced tools
Comparing version 0.23.2-nightly.20250114.0 to 0.23.2-nightly.20250115.0
@@ -9,9 +9,2 @@ /** | ||
'use strict';var h=require("@lexical/selection"),q=require("@lexical/utils"),r=require("lexical"); | ||
function u(a,b,f,e=null){let g=null!==e?b.isSelected(e):!0,d=r.$isElementNode(b)&&b.excludeFromCopy("html");var c=b;null!==e&&(c=r.$cloneWithProperties(b),c=r.$isTextNode(c)&&null!==e?h.$sliceSelectedTextNodeContent(e,c):c);let l=r.$isElementNode(c)?c.getChildren():[];var m=a._nodes.get(c.getType());m=m&&void 0!==m.exportDOM?m.exportDOM(a,c):c.exportDOM(a);let {element:k,after:n}=m;if(!k)return!1;m=document.createDocumentFragment();for(let p=0;p<l.length;p++){let t=l[p],y=u(a,t,m,e);!g&&r.$isElementNode(b)&& | ||
y&&b.extractWithChild(t,e,"html")&&(g=!0)}g&&!d?((q.isHTMLElement(k)||r.isDocumentFragment(k))&&k.append(m),f.append(k),n&&(a=n.call(c,k))&&(r.isDocumentFragment(k)?k.replaceChildren(a):k.replaceWith(a))):f.append(m);return g}function v(a,b){var {nodeName:f}=a;f=b._htmlConversions.get(f.toLowerCase());b=null;if(void 0!==f)for(let e of f)f=e(a),null!==f&&(null===b||(b.priority||0)<=(f.priority||0))&&(b=f);return null!==b?b.conversion:null}let w=new Set(["STYLE","SCRIPT"]); | ||
function x(a,b,f,e,g=new Map,d){let c=[];if(w.has(a.nodeName))return c;let l=null;var m=v(a,b),k=m?m(a):null;m=null;if(null!==k){m=k.after;let p=k.node;l=Array.isArray(p)?p[p.length-1]:p;if(null!==l){for(var [,n]of g)if(l=n(l,d),!l)break;l&&c.push(...(Array.isArray(p)?p:[l]))}null!=k.forChild&&g.set(a.nodeName,k.forChild)}d=a.childNodes;n=[];e=null!=l&&r.$isRootOrShadowRoot(l)?!1:null!=l&&r.$isBlockElementNode(l)||e;for(k=0;k<d.length;k++)n.push(...x(d[k],b,f,e,new Map(g),l));null!=m&&(n=m(n));q.isBlockDomNode(a)&& | ||
(n=e?z(a,n,()=>{let p=new r.ArtificialNode__DO_NOT_USE;f.push(p);return p}):z(a,n,r.$createParagraphNode));null==l?0<n.length?c=c.concat(n):q.isBlockDomNode(a)&&A(a)&&(c=c.concat(r.$createLineBreakNode())):r.$isElementNode(l)&&l.append(...n);return c} | ||
function z(a,b,f){a=a.style.textAlign;let e=[],g=[];for(let c=0;c<b.length;c++){var d=b[c];if(r.$isBlockElementNode(d))a&&!d.getFormat()&&d.setFormat(a),e.push(d);else if(g.push(d),c===b.length-1||c<b.length-1&&r.$isBlockElementNode(b[c+1]))d=f(),d.setFormat(a),d.append(...g),e.push(d),g=[]}return e}function A(a){return null==a.nextSibling||null==a.previousSibling?!1:r.isInlineDomNode(a.nextSibling)&&r.isInlineDomNode(a.previousSibling)} | ||
exports.$generateHtmlFromNodes=function(a,b){if("undefined"===typeof document||"undefined"===typeof window&&"undefined"===typeof global.window)throw Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let f=document.createElement("div"),e=r.$getRoot().getChildren();for(let g=0;g<e.length;g++)u(a,e[g],f,b);return f.innerHTML}; | ||
exports.$generateNodesFromDOM=function(a,b){let f=b.body?b.body.childNodes:[];b=[];let e=[];for(let d=0;d<f.length;d++){var g=f[d];w.has(g.nodeName)||(g=x(g,a,e,!1),null!==g&&(b=b.concat(g)))}for(let d of e)d.getNextSibling()instanceof r.ArtificialNode__DO_NOT_USE&&d.insertAfter(r.$createLineBreakNode());for(let d of e){a=d.getChildren();for(let c of a)d.insertBefore(c);d.remove()}return b} | ||
"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}; |
@@ -11,3 +11,3 @@ { | ||
"license": "MIT", | ||
"version": "0.23.2-nightly.20250114.0", | ||
"version": "0.23.2-nightly.20250115.0", | ||
"main": "LexicalHtml.js", | ||
@@ -21,5 +21,5 @@ "types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/selection": "0.23.2-nightly.20250114.0", | ||
"@lexical/utils": "0.23.2-nightly.20250114.0", | ||
"lexical": "0.23.2-nightly.20250114.0" | ||
"@lexical/selection": "0.23.2-nightly.20250115.0", | ||
"@lexical/utils": "0.23.2-nightly.20250115.0", | ||
"lexical": "0.23.2-nightly.20250115.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "module": "LexicalHtml.mjs", |
32967
567
+ Added@lexical/clipboard@0.23.2-nightly.20250115.0(transitive)
+ Added@lexical/list@0.23.2-nightly.20250115.0(transitive)
+ Added@lexical/selection@0.23.2-nightly.20250115.0(transitive)
+ Added@lexical/table@0.23.2-nightly.20250115.0(transitive)
+ Added@lexical/utils@0.23.2-nightly.20250115.0(transitive)
+ Addedlexical@0.23.2-nightly.20250115.0(transitive)
- Removed@lexical/clipboard@0.23.2-nightly.20250114.0(transitive)
- Removed@lexical/list@0.23.2-nightly.20250114.0(transitive)
- Removed@lexical/selection@0.23.2-nightly.20250114.0(transitive)
- Removed@lexical/table@0.23.2-nightly.20250114.0(transitive)
- Removed@lexical/utils@0.23.2-nightly.20250114.0(transitive)
- Removedlexical@0.23.2-nightly.20250114.0(transitive)