@lexical/html 0.9.0 → 0.9.2

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.
@@ -18,10 +18,9 @@ var lexical = require('lexical');
18
18
 
19
19
  function $generateNodesFromDOM(editor, dom) {
20
20
  let lexicalNodes = [];
21
- const elements = dom.body ? Array.from(dom.body.childNodes) : [];
22
- const elementsLength = elements.length;
21
+ const elements = dom.body ? dom.body.childNodes : [];
23
22
 
24
- for (let i = 0; i < elementsLength; i++) {
23
+ for (let i = 0; i < elements.length; i++) {
25
24
  const element = elements[i];
26
25
 
27
26
  if (!IGNORE_TAGS.has(element.nodeName)) {
@@ -73,7 +72,7 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = nu
73
72
  return false;
74
73
  }
75
74
 
76
- const fragment = new DocumentFragment();
75
+ const fragment = document.createDocumentFragment();
77
76
 
78
77
  for (let i = 0; i < children.length; i++) {
79
78
  const childNode = children[i];
@@ -121,7 +120,7 @@ function getConversionFunction(domNode, editor) {
121
120
  return currentConversion !== null ? currentConversion.conversion : null;
122
121
  }
123
122
 
124
- const IGNORE_TAGS = new Set(['STYLE']);
123
+ const IGNORE_TAGS = new Set(['STYLE', 'SCRIPT']);
125
124
 
126
125
  function $createNodesFromDOM(node, editor, forChildMap = new Map(), parentLexicalNode, preformatted = false) {
127
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,b=null){let e=null!=b?d.isSelected():!0,l=q.$isElementNode(d)&&d.excludeFromCopy("html");var a=d;null!==b&&(a=n.$cloneWithProperties(d),a=q.$isTextNode(a)&&null!=b?n.$sliceSelectedTextNodeContent(b,a):a);let f=q.$isElementNode(a)?a.getChildren():[],{element:k,after:g}=a.exportDOM(c);if(!k)return!1;let m=new DocumentFragment;for(let p=0;p<f.length;p++){let t=f[p],w=r(c,t,m,b);!e&&q.$isElementNode(d)&&w&&d.extractWithChild(t,b,"html")&&(e=!0)}e&&!l?(k.append(m),h.append(k),g&&(c=g.call(a,
9
- k))&&k.replaceWith(c)):h.append(m);return e}let u=new Set(["STYLE"]);
10
- function v(c,d,h=new Map,b,e=!1){let l=[];if(u.has(c.nodeName))return l;let a=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;a=g.node;if(null!==a){for(var [,m]of h)if(a=m(a,b),!a)break;a&&l.push(a)}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;b=[];for(m=0;m<c.length;m++)b.push(...v(c[m],d,
11
- new Map(h),a,e||!0===(g&&g.preformatted)));null!=f&&(b=f(b));null==a?l=l.concat(b):q.$isElementNode(a)&&a.append(...b);return l}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"),b=q.$getRoot().getChildren();for(let e=0;e<b.length;e++)r(c,b[e],h,d);return h.innerHTML};
12
- exports.$generateNodesFromDOM=function(c,d){let h=[];d=d.body?Array.from(d.body.childNodes):[];let b=d.length;for(let l=0;l<b;l++){var e=d[l];u.has(e.nodeName)||(e=v(e,c),null!==e&&(h=h.concat(e)))}return h}
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
+ 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
+ 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
+ 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.0",
11
+ "version": "0.9.2",
12
12
  "main": "LexicalHtml.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.9.0"
14
+ "lexical": "0.9.2"
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.0"
22
+ "@lexical/selection": "0.9.2"
23
23
  }
24
24
  }