@lexical/html 0.11.3 → 0.12.1

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.
@@ -7,6 +7,7 @@
7
7
  'use strict';
8
8
 
9
9
  var selection = require('@lexical/selection');
10
+ var utils = require('@lexical/utils');
10
11
  var lexical = require('lexical');
11
12
 
12
13
  /** @module @lexical/html */
@@ -84,7 +85,10 @@ function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = nu
84
85
  }
85
86
 
86
87
  if (shouldInclude && !shouldExclude) {
87
- element.append(fragment);
88
+ if (utils.isHTMLElement(element)) {
89
+ element.append(fragment);
90
+ }
91
+
88
92
  parentElement.append(element);
89
93
 
90
94
  if (after) {
@@ -4,10 +4,10 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var m=require("@lexical/selection"),q=require("lexical");
8
- function r(c,d,h,a=null){let e=null!=a?d.isSelected(a):!0,k=q.$isElementNode(d)&&d.excludeFromCopy("html");var f=d;null!==a&&(f=m.$cloneWithProperties(d),f=q.$isTextNode(f)&&null!=a?m.$sliceSelectedTextNodeContent(a,f):f);let g=q.$isElementNode(f)?f.getChildren():[],{element:b,after:l}=f.exportDOM(c);if(!b)return!1;let n=document.createDocumentFragment();for(let p=0;p<g.length;p++){let t=g[p],w=r(c,t,n,a);!e&&q.$isElementNode(d)&&w&&d.extractWithChild(t,a,"html")&&(e=!0)}e&&!k?(b.append(n),h.append(b),
9
- l&&(c=l.call(f,b))&&b.replaceWith(c)):h.append(n);return e}let u=new Set(["STYLE","SCRIPT"]);
10
- function v(c,d,h=new Map,a){let e=[];if(u.has(c.nodeName))return e;let k=null;var f,{nodeName:g}=c,b=d._htmlConversions.get(g.toLowerCase());g=null;if(void 0!==b)for(f of b)b=f(c),null!==b&&(null===g||g.priority<b.priority)&&(g=b);g=(f=null!==g?g.conversion:null)?f(c):null;f=null;if(null!==g){f=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&&e.push(...(Array.isArray(b)?b:[k]))}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;a=
11
- [];for(l=0;l<c.length;l++)a.push(...v(c[l],d,new Map(h),k));null!=f&&(a=f(a));null==k?e=e.concat(a):q.$isElementNode(k)&&k.append(...a);return e}
12
- 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};
13
- exports.$generateNodesFromDOM=function(c,d){d=d.body?d.body.childNodes:[];let h=[];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}
7
+ 'use strict';var m=require("@lexical/selection"),q=require("@lexical/utils"),r=require("lexical");
8
+ function u(c,d,h,a=null){let e=null!=a?d.isSelected(a):!0,k=r.$isElementNode(d)&&d.excludeFromCopy("html");var f=d;null!==a&&(f=m.$cloneWithProperties(d),f=r.$isTextNode(f)&&null!=a?m.$sliceSelectedTextNodeContent(a,f):f);let g=r.$isElementNode(f)?f.getChildren():[],{element:b,after:l}=f.exportDOM(c);if(!b)return!1;let n=document.createDocumentFragment();for(let p=0;p<g.length;p++){let t=g[p],x=u(c,t,n,a);!e&&r.$isElementNode(d)&&x&&d.extractWithChild(t,a,"html")&&(e=!0)}e&&!k?(q.isHTMLElement(b)&&
9
+ b.append(n),h.append(b),l&&(c=l.call(f,b))&&b.replaceWith(c)):h.append(n);return e}let v=new Set(["STYLE","SCRIPT"]);
10
+ function w(c,d,h=new Map,a){let e=[];if(v.has(c.nodeName))return e;let k=null;var f,{nodeName:g}=c,b=d._htmlConversions.get(g.toLowerCase());g=null;if(void 0!==b)for(f of b)b=f(c),null!==b&&(null===g||g.priority<b.priority)&&(g=b);g=(f=null!==g?g.conversion:null)?f(c):null;f=null;if(null!==g){f=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&&e.push(...(Array.isArray(b)?b:[k]))}null!=g.forChild&&h.set(c.nodeName,g.forChild)}c=c.childNodes;a=
11
+ [];for(l=0;l<c.length;l++)a.push(...w(c[l],d,new Map(h),k));null!=f&&(a=f(a));null==k?e=e.concat(a):r.$isElementNode(k)&&k.append(...a);return e}
12
+ 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=r.$getRoot().getChildren();for(let e=0;e<a.length;e++)u(c,a[e],h,d);return h.innerHTML};
13
+ exports.$generateNodesFromDOM=function(c,d){d=d.body?d.body.childNodes:[];let h=[];for(let e=0;e<d.length;e++){var a=d[e];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.3",
11
+ "version": "0.12.1",
12
12
  "main": "LexicalHtml.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.11.3"
14
+ "lexical": "0.12.1"
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.11.3"
22
+ "@lexical/selection": "0.12.1"
23
23
  }
24
24
  }