@lexical/html 0.9.1 → 0.10.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.
@@ -72,7 +72,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = nu
72
72
  return false;
73
73
  }
74
74
 
75
- const fragment = new DocumentFragment();
75
+ const fragment = document.createDocumentFragment();
76
76
 
77
77
  for (let i = 0; i < children.length; i++) {
78
78
  const childNode = children[i];
@@ -120,7 +120,7 @@ function getConversionFunction(domNode, editor) {
120
120
  return currentConversion !== null ? currentConversion.conversion : null;
121
121
  }
122
122
 
123
- const IGNORE_TAGS = new Set(['STYLE']);
123
+ const IGNORE_TAGS = new Set(['STYLE', 'SCRIPT']);
124
124
 
125
125
  function $createNodesFromDOM(node, editor, forChildMap = new Map(), parentLexicalNode, preformatted = false) {
126
126
  let lexicalNodes = [];
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var n=require("@lexical/selection"),q=require("lexical");
8
- function r(c,d,h,a=null){let e=null!=a?d.isSelected():!0,m=q.$isElementNode(d)&&d.excludeFromCopy("html");var b=d;null!==a&&(b=n.$cloneWithProperties(d),b=q.$isTextNode(b)&&null!=a?n.$sliceSelectedTextNodeContent(a,b):b);let f=q.$isElementNode(b)?b.getChildren():[],{element:k,after:g}=b.exportDOM(c);if(!k)return!1;let l=new DocumentFragment;for(let p=0;p<f.length;p++){let t=f[p],w=r(c,t,l,a);!e&&q.$isElementNode(d)&&w&&d.extractWithChild(t,a,"html")&&(e=!0)}e&&!m?(k.append(l),h.append(k),g&&(c=g.call(b,
9
- k))&&k.replaceWith(c)):h.append(l);return e}let u=new Set(["STYLE"]);
8
+ function r(c,d,h,a=null){let e=null!=a?d.isSelected():!0,m=q.$isElementNode(d)&&d.excludeFromCopy("html");var b=d;null!==a&&(b=n.$cloneWithProperties(d),b=q.$isTextNode(b)&&null!=a?n.$sliceSelectedTextNodeContent(a,b):b);let f=q.$isElementNode(b)?b.getChildren():[],{element:k,after:g}=b.exportDOM(c);if(!k)return!1;let l=document.createDocumentFragment();for(let p=0;p<f.length;p++){let t=f[p],w=r(c,t,l,a);!e&&q.$isElementNode(d)&&w&&d.extractWithChild(t,a,"html")&&(e=!0)}e&&!m?(k.append(l),h.append(k),
9
+ g&&(c=g.call(b,k))&&k.replaceWith(c)):h.append(l);return e}let u=new Set(["STYLE","SCRIPT"]);
10
10
  function v(c,d,h=new Map,a,e=!1){let m=[];if(u.has(c.nodeName))return m;let b=null;var {nodeName:f}=c,k=d._htmlConversions.get(f.toLowerCase());f=null;if(void 0!==k)for(g of k)k=g(c),null!==k&&(null===f||f.priority<k.priority)&&(f=k);var g=(g=null!==f?f.conversion:null)?g(c,void 0,e):null;f=null;if(null!==g){f=g.after;b=g.node;if(null!==b){for(var [,l]of h)if(b=l(b,a),!b)break;b&&m.push(b)}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;a=[];for(l=0;l<c.length;l++)a.push(...v(c[l],d,
11
11
  new Map(h),b,e||!0===(g&&g.preformatted)));null!=f&&(a=f(a));null==b?m=m.concat(a):q.$isElementNode(b)&&b.append(...a);return m}exports.$generateHtmlFromNodes=function(c,d){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 e=0;e<a.length;e++)r(c,a[e],h,d);return h.innerHTML};
12
12
  exports.$generateNodesFromDOM=function(c,d){let h=[];d=d.body?d.body.childNodes:[];for(let e=0;e<d.length;e++){var a=d[e];u.has(a.nodeName)||(a=v(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.9.1",
11
+ "version": "0.10.0",
12
12
  "main": "LexicalHtml.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.9.1"
14
+ "lexical": "0.10.0"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -19,6 +19,6 @@
19
19
  "directory": "packages/lexical-html"
20
20
  },
21
21
  "dependencies": {
22
- "@lexical/selection": "0.9.1"
22
+ "@lexical/selection": "0.10.0"
23
23
  }
24
24
  }