@lexical/html
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -55,3 +55,6 @@ /** | ||
const topLevelNode = topLevelChildren[i]; | ||
$appendNodesToHTML(editor, selection, topLevelNode, container); | ||
if (selection !== undefined) { | ||
$appendNodesToHTML(editor, selection, topLevelNode, container); | ||
} | ||
} | ||
@@ -113,11 +116,9 @@ | ||
if (cachedConversions !== undefined) { | ||
cachedConversions.forEach(cachedConversion => { | ||
for (const cachedConversion of cachedConversions) { | ||
const domConversion = cachedConversion(domNode); | ||
if (domConversion !== null) { | ||
if (currentConversion === null || currentConversion.priority < domConversion.priority) { | ||
currentConversion = domConversion; | ||
} | ||
if (domConversion !== null && (currentConversion === null || currentConversion.priority < domConversion.priority)) { | ||
currentConversion = domConversion; | ||
} | ||
}); | ||
} | ||
} | ||
@@ -124,0 +125,0 @@ |
@@ -7,7 +7,7 @@ /** | ||
*/ | ||
'use strict';var l=require("@lexical/selection"),p=require("lexical"); | ||
function q(d,b,e,c){let a=null!=b?e.isSelected():!0,f=p.$isElementNode(e)&&e.excludeFromCopy("html"),g=l.$cloneWithProperties(e);g=p.$isTextNode(g)&&null!=b?l.$sliceSelectedTextNodeContent(b,g):g;let k=p.$isElementNode(g)?g.getChildren():[],{element:h,after:r}=g.exportDOM(d);if(!h)return!1;let m=new DocumentFragment;for(let n=0;n<k.length;n++){let t=k[n],w=q(d,b,t,m);!a&&p.$isElementNode(e)&&w&&e.extractWithChild(t,b,"html")&&(a=!0)}a&&!f?(h.append(m),c.append(h),r&&(d=r.call(g,h))&&h.replaceWith(d)): | ||
c.append(m);return a}function u(d,b){let {nodeName:e}=d;b=b._htmlConversions.get(e.toLowerCase());let c=null;void 0!==b&&b.forEach(a=>{a=a(d);null!==a&&(null===c||c.priority<a.priority)&&(c=a)});return null!==c?c.conversion:null}let v=new Set(["STYLE"]); | ||
function x(d,b,e=new Map,c){let a=[];if(v.has(d.nodeName))return a;let f=null;var g=u(d,b);let k=g?g(d):null;g=null;if(null!==k){g=k.after;f=k.node;if(null!==f){for(var [,h]of e)if(f=h(f,c),!f)break;f&&a.push(f)}null!=k.forChild&&e.set(d.nodeName,k.forChild)}d=d.childNodes;c=[];for(h=0;h<d.length;h++)c.push(...x(d[h],b,new Map(e),f));null!=g&&(c=g(c));null==f?a=a.concat(c):p.$isElementNode(f)&&f.append(...c);return a} | ||
exports.$generateHtmlFromNodes=function(d,b){if(null==document||null==window)throw Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let e=document.createElement("div"),c=p.$getRoot().getChildren();for(let a=0;a<c.length;a++)q(d,b,c[a],e);return e.innerHTML}; | ||
exports.$generateNodesFromDOM=function(d,b){let e=[];b=b.body?Array.from(b.body.childNodes):[];let c=b.length;for(let f=0;f<c;f++){var a=b[f];v.has(a.nodeName)||(a=x(a,d),null!==a&&(e=e.concat(a)))}return e} | ||
'use strict';var m=require("@lexical/selection"),q=require("lexical"); | ||
function r(c,d,e,h){let a=null!=d?e.isSelected():!0,b=q.$isElementNode(e)&&e.excludeFromCopy("html"),f=m.$cloneWithProperties(e);f=q.$isTextNode(f)&&null!=d?m.$sliceSelectedTextNodeContent(d,f):f;let g=q.$isElementNode(f)?f.getChildren():[],{element:k,after:l}=f.exportDOM(c);if(!k)return!1;let n=new DocumentFragment;for(let p=0;p<g.length;p++){let t=g[p],w=r(c,d,t,n);!a&&q.$isElementNode(e)&&w&&e.extractWithChild(t,d,"html")&&(a=!0)}a&&!b?(k.append(n),h.append(k),l&&(c=l.call(f,k))&&k.replaceWith(c)): | ||
h.append(n);return a}let u=new Set(["STYLE"]); | ||
function v(c,d,e=new Map,h){let a=[];if(u.has(c.nodeName))return a;let b=null;var f,{nodeName:g}=c,k=d._htmlConversions.get(g.toLowerCase());g=null;if(void 0!==k)for(f of k)k=f(c),null!==k&&(null===g||g.priority<k.priority)&&(g=k);g=(f=null!==g?g.conversion:null)?f(c):null;f=null;if(null!==g){f=g.after;b=g.node;if(null!==b){for(var [,l]of e)if(b=l(b,h),!b)break;b&&a.push(b)}null!=g.forChild&&e.set(c.nodeName,g.forChild)}c=c.childNodes;h=[];for(l=0;l<c.length;l++)h.push(...v(c[l],d,new Map(e),b)); | ||
null!=f&&(h=f(h));null==b?a=a.concat(h):q.$isElementNode(b)&&b.append(...h);return a}exports.$generateHtmlFromNodes=function(c,d){if(null==document||null==window)throw Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let e=document.createElement("div"),h=q.$getRoot().getChildren();for(let a=0;a<h.length;a++){let b=h[a];void 0!==d&&r(c,d,b,e)}return e.innerHTML}; | ||
exports.$generateNodesFromDOM=function(c,d){let e=[];d=d.body?Array.from(d.body.childNodes):[];let h=d.length;for(let b=0;b<h;b++){var a=d[b];u.has(a.nodeName)||(a=v(a,c),null!==a&&(e=e.concat(a)))}return e} |
@@ -11,6 +11,6 @@ { | ||
"license": "MIT", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"main": "LexicalHtml.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.5" | ||
"lexical": "0.3.6" | ||
}, | ||
@@ -17,0 +17,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12598