@lexical/html 0.12.5 → 0.13.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/LexicalHtml.dev.js +3 -3
- package/LexicalHtml.prod.js +3 -3
- package/package.json +4 -4
package/LexicalHtml.dev.js
CHANGED
|
@@ -45,12 +45,12 @@ function $generateHtmlFromNodes(editor, selection) {
|
|
|
45
45
|
return container.innerHTML;
|
|
46
46
|
}
|
|
47
47
|
function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = null) {
|
|
48
|
-
let shouldInclude = selection$1
|
|
48
|
+
let shouldInclude = selection$1 !== null ? currentNode.isSelected(selection$1) : true;
|
|
49
49
|
const shouldExclude = lexical.$isElementNode(currentNode) && currentNode.excludeFromCopy('html');
|
|
50
50
|
let target = currentNode;
|
|
51
51
|
if (selection$1 !== null) {
|
|
52
52
|
let clone = selection.$cloneWithProperties(currentNode);
|
|
53
|
-
clone = lexical.$isTextNode(clone) && selection$1
|
|
53
|
+
clone = lexical.$isTextNode(clone) && selection$1 !== null ? selection.$sliceSelectedTextNodeContent(selection$1, clone) : clone;
|
|
54
54
|
target = clone;
|
|
55
55
|
}
|
|
56
56
|
const children = lexical.$isElementNode(target) ? target.getChildren() : [];
|
|
@@ -101,7 +101,7 @@ function getConversionFunction(domNode, editor) {
|
|
|
101
101
|
if (cachedConversions !== undefined) {
|
|
102
102
|
for (const cachedConversion of cachedConversions) {
|
|
103
103
|
const domConversion = cachedConversion(domNode);
|
|
104
|
-
if (domConversion !== null && (currentConversion === null || currentConversion.priority < domConversion.priority)) {
|
|
104
|
+
if (domConversion !== null && (currentConversion === null || (currentConversion.priority || 0) < (domConversion.priority || 0))) {
|
|
105
105
|
currentConversion = domConversion;
|
|
106
106
|
}
|
|
107
107
|
}
|
package/LexicalHtml.prod.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var m=require("@lexical/selection"),p=require("@lexical/utils"),q=require("lexical");
|
|
8
|
-
function u(c,e,h,a=null){let f=null
|
|
8
|
+
function u(c,e,h,a=null){let f=null!==a?e.isSelected(a):!0,k=q.$isElementNode(e)&&e.excludeFromCopy("html");var d=e;null!==a&&(d=m.$cloneWithProperties(e),d=q.$isTextNode(d)&&null!==a?m.$sliceSelectedTextNodeContent(a,d):d);let g=q.$isElementNode(d)?d.getChildren():[];var b=c._nodes.get(d.getType());b=b&&void 0!==b.exportDOM?b.exportDOM(c,d):d.exportDOM(c);let {element:l,after:r}=b;if(!l)return!1;b=document.createDocumentFragment();for(let n=0;n<g.length;n++){let t=g[n],x=u(c,t,b,a);!f&&q.$isElementNode(e)&&
|
|
9
9
|
x&&e.extractWithChild(t,a,"html")&&(f=!0)}f&&!k?(p.isHTMLElement(l)&&l.append(b),h.append(l),r&&(c=r.call(d,l))&&l.replaceWith(c)):h.append(b);return f}let v=new Set(["STYLE","SCRIPT"]);
|
|
10
|
-
function w(c,e,h=new Map,a){let f=[];if(v.has(c.nodeName))return f;let k=null;var d,{nodeName:g}=c,b=e._htmlConversions.get(g.toLowerCase());g=null;if(void 0!==b)for(d of b)b=d(c),null!==b&&(null===g||g.priority<b.priority)&&(g=b);g=(d=null!==g?g.conversion:null)?d(c):null;d=null;if(null!==g){d=g.after;b=g.node;k=Array.isArray(b)?b[b.length-1]:b;if(null!==k){for(var [,l]of h)if(k=l(k,a),!k)break;k&&f.push(...(Array.isArray(b)?b:[k]))}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;
|
|
11
|
-
[];for(l=0;l<c.length;l++)a.push(...w(c[l],e,new Map(h),k));null!=d&&(a=d(a));null==k?f=f.concat(a):q.$isElementNode(k)&&k.append(...a);return f}
|
|
10
|
+
function w(c,e,h=new Map,a){let f=[];if(v.has(c.nodeName))return f;let k=null;var d,{nodeName:g}=c,b=e._htmlConversions.get(g.toLowerCase());g=null;if(void 0!==b)for(d of b)b=d(c),null!==b&&(null===g||(g.priority||0)<(b.priority||0))&&(g=b);g=(d=null!==g?g.conversion:null)?d(c):null;d=null;if(null!==g){d=g.after;b=g.node;k=Array.isArray(b)?b[b.length-1]:b;if(null!==k){for(var [,l]of h)if(k=l(k,a),!k)break;k&&f.push(...(Array.isArray(b)?b:[k]))}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;
|
|
11
|
+
a=[];for(l=0;l<c.length;l++)a.push(...w(c[l],e,new Map(h),k));null!=d&&(a=d(a));null==k?f=f.concat(a):q.$isElementNode(k)&&k.append(...a);return f}
|
|
12
12
|
exports.$generateHtmlFromNodes=function(c,e){if("undefined"===typeof document||"undefined"===typeof window)throw Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let h=document.createElement("div"),a=q.$getRoot().getChildren();for(let f=0;f<a.length;f++)u(c,a[f],h,e);return h.innerHTML};
|
|
13
13
|
exports.$generateNodesFromDOM=function(c,e){e=e.body?e.body.childNodes:[];let h=[];for(let f=0;f<e.length;f++){var a=e[f];v.has(a.nodeName)||(a=w(a,c),null!==a&&(h=h.concat(a)))}return h}
|
package/package.json
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"html"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.13.0",
|
|
12
12
|
"main": "LexicalHtml.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.
|
|
14
|
+
"lexical": "0.13.0"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "packages/lexical-html"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@lexical/selection": "0.
|
|
23
|
-
"@lexical/utils": "0.
|
|
22
|
+
"@lexical/selection": "0.13.0",
|
|
23
|
+
"@lexical/utils": "0.13.0"
|
|
24
24
|
}
|
|
25
25
|
}
|