Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/html

Package Overview
Dependencies
Maintainers
6
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/html - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

31

LexicalHtml.dev.js

@@ -49,6 +49,3 @@ /**

const topLevelNode = topLevelChildren[i];
if (selection !== undefined) {
$appendNodesToHTML(editor, selection, topLevelNode, container);
}
$appendNodesToHTML(editor, topLevelNode, container, selection);
}

@@ -59,12 +56,18 @@

function $appendNodesToHTML(editor, selection$1, currentNode, parentElement) {
function $appendNodesToHTML(editor, currentNode, parentElement, selection$1 = null) {
let shouldInclude = selection$1 != null ? currentNode.isSelected() : true;
const shouldExclude = lexical.$isElementNode(currentNode) && currentNode.excludeFromCopy('html');
let clone = selection.$cloneWithProperties(currentNode);
clone = lexical.$isTextNode(clone) && selection$1 != null ? selection.$sliceSelectedTextNodeContent(selection$1, clone) : clone;
const children = lexical.$isElementNode(clone) ? clone.getChildren() : [];
let target = currentNode;
if (selection$1 !== null) {
let clone = selection.$cloneWithProperties(currentNode);
clone = lexical.$isTextNode(clone) && selection$1 != null ? selection.$sliceSelectedTextNodeContent(selection$1, clone) : clone;
target = clone;
}
const children = lexical.$isElementNode(target) ? target.getChildren() : [];
const {
element,
after
} = clone.exportDOM(editor);
} = target.exportDOM(editor);

@@ -79,3 +82,3 @@ if (!element) {

const childNode = children[i];
const shouldIncludeChild = $appendNodesToHTML(editor, selection$1, childNode, fragment);
const shouldIncludeChild = $appendNodesToHTML(editor, childNode, fragment, selection$1);

@@ -92,3 +95,3 @@ if (!shouldInclude && lexical.$isElementNode(currentNode) && shouldIncludeChild && currentNode.extractWithChild(childNode, selection$1, 'html')) {

if (after) {
const newElement = after.call(clone, element);
const newElement = after.call(target, element);
if (newElement) element.replaceWith(newElement);

@@ -127,3 +130,3 @@ }

function $createNodesFromDOM(node, editor, forChildMap = new Map(), parentLexicalNode) {
function $createNodesFromDOM(node, editor, forChildMap = new Map(), parentLexicalNode, preformatted = false) {
let lexicalNodes = [];

@@ -137,3 +140,3 @@

const transformFunction = getConversionFunction(node, editor);
const transformOutput = transformFunction ? transformFunction(node) : null;
const transformOutput = transformFunction ? transformFunction(node, undefined, preformatted) : null;
let postTransform = null;

@@ -170,3 +173,3 @@

for (let i = 0; i < children.length; i++) {
childLexicalNodes.push(...$createNodesFromDOM(children[i], editor, new Map(forChildMap), currentLexicalNode));
childLexicalNodes.push(...$createNodesFromDOM(children[i], editor, new Map(forChildMap), currentLexicalNode, preformatted || (transformOutput && transformOutput.preformatted) === true));
}

@@ -173,0 +176,0 @@

@@ -7,7 +7,7 @@ /**

*/
'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}
'use strict';var n=require("@lexical/selection"),q=require("lexical");
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,
k))&&k.replaceWith(c)):h.append(m);return e}let u=new Set(["STYLE"]);
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,
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(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 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};
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}

@@ -11,6 +11,6 @@ {

"license": "MIT",
"version": "0.4.1",
"version": "0.5.0",
"main": "LexicalHtml.js",
"peerDependencies": {
"lexical": "0.4.1"
"lexical": "0.5.0"
},

@@ -23,4 +23,4 @@ "repository": {

"dependencies": {
"@lexical/selection": "0.4.1"
"@lexical/selection": "0.5.0"
}
}

@@ -33,4 +33,3 @@ # `@lexical/html`

// Or insert them at a selection.
const selection = $getSelection();
selection.insertNodes(nodes);
$insertNodes(nodes);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc