Socket
Socket
Sign inDemoInstall

@lexical/helpers

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/helpers - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

LexicalElementHelpers.dev.js

10

elements.js

@@ -1,1 +0,9 @@

'use strict';exports.addClassNamesToElement=function(b,...c){c.forEach(a=>{null!=a&&"string"===typeof a&&b.classList.add(...a.split(" "))})};exports.removeClassNamesFromElement=function(b,...c){c.forEach(a=>{b.classList.remove(...a.split(" "))})};
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalElementHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalElementHelpers.dev.js') : require('./LexicalElementHelpers.prod.js')
module.exports = LexicalElementHelpers;

26

events.js

@@ -1,17 +0,9 @@

'use strict';var e=require("lexical"),w=require("@lexical/list"),y=require("lexical/HeadingNode"),z=require("lexical/LinkNode"),A=require("lexical/CodeNode");
function B(a){a=a.getLatest();const b=a.constructor.clone(a);b.__parent=a.__parent;e.$isElementNode(a)&&e.$isElementNode(b)?(b.__children=Array.from(a.__children),b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir):e.$isTextNode(a)&&e.$isTextNode(b)?(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail):e.$isDecoratorNode(a)&&e.$isDecoratorNode(b)&&(b.__state=a.__state);return b}
function C(a,b,c,f,h){for(var d=b;null!==a;){for(b=a.getParent();null!==b&&b.excludeFromCopy();)b=b.getParent();if(null===b)break;if(!e.$isElementNode(a)||!a.excludeFromCopy()){const k=a.getKey();let g=h.get(k);const l=void 0===g;l&&(g=B(a),h.set(k,g));!e.$isTextNode(g)||g.isSegmented()||g.isToken()?e.$isElementNode(g)&&(g.__children=g.__children.slice(c?d:0,c?void 0:d+1)):g.__text=g.__text.slice(c?d:0,c?void 0:d);if(e.$isRootNode(b)){l&&f.push(k);break}}d=h.get(b.getKey());d=e.$isElementNode(d)?
d.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=b}}
const D={ul:()=>({node:w.$createListNode("ul")}),ol:()=>({node:w.$createListNode("ol")}),li:()=>({node:w.$createListItemNode()}),h1:()=>({node:y.$createHeadingNode("h1")}),h2:()=>({node:y.$createHeadingNode("h2")}),h3:()=>({node:y.$createHeadingNode("h3")}),h4:()=>({node:y.$createHeadingNode("h4")}),h5:()=>({node:y.$createHeadingNode("h5")}),p:()=>({node:e.$createParagraphNode()}),br:()=>({node:e.$createLineBreakNode()}),a:a=>({node:a instanceof HTMLAnchorElement?z.$createLinkNode(a.href):e.$createTextNode(a.textContent)}),
u:()=>({node:null,forChild:a=>{e.$isTextNode(a)&&a.toggleFormat("underline")}}),b:a=>{const b="normal"===a.style.fontWeight;return{node:null,forChild:c=>{e.$isTextNode(c)&&!b&&c.toggleFormat("bold")}}},strong:()=>({node:null,forChild:a=>{e.$isTextNode(a)&&a.toggleFormat("bold")}}),i:()=>({node:null,forChild:a=>{e.$isTextNode(a)&&a.toggleFormat("italic")}}),em:()=>({node:null,forChild:a=>{e.$isTextNode(a)&&a.toggleFormat("italic")}}),td:a=>{const b=a.classList.contains("js-file-line");return{node:null,
after:c=>{b&&a.parentNode&&a.parentNode.nextSibling&&c.push(e.$createLineBreakNode());return c}}},table:a=>({node:a.classList.contains("js-file-line-container")?A.$createCodeNode():null}),span:a=>{const b="700"===a.style.fontWeight;return{node:null,forChild:c=>{e.$isTextNode(c)&&b&&c.toggleFormat("bold")}}},"#text":a=>({node:e.$createTextNode(a.textContent)}),pre:()=>({node:A.$createCodeNode()}),div:a=>({node:null!==a.style.fontFamily.match("monospace")?A.$createCodeNode():null,after:b=>{const c=
a.parentNode;null!=c&&a!==c.lastChild&&b.push(e.$createLineBreakNode());return b}})};
function E(a,b,c,f=new Map){let h=[],d=null;var k=a.nodeName.toLowerCase(),g=(c._config.htmlTransforms||{})[k]||b[k],l=g?g(a):null;g=null;if(null!==l){g=l.after;d=l.node;if(null!==d){h.push(d);const n=Array.from(f.values());for(let m=0;m<n.length;m++)n[m](d)}null!=l.forChild&&f.set(k,l.forChild)}a=a.childNodes;k=[];for(l=0;l<a.length;l++)k.push(...E(a[l],b,c,f));null!=g&&(k=g(k));null==d?h=h.concat(k):e.$isElementNode(d)&&d.append(...k);return h}
function F(a,b,c){var f=a.getData("application/x-lexical-editor");if(f){var h=c._config.namespace;try{const l=JSON.parse(f);if(l.namespace===h){const {range:n,nodeMap:m}=l.state;var d=new Map(m);f=[];for(h=0;h<n.length;h++){var k=d.get(n[h]);if(void 0!==k){var g=e.$createNodeFromParse(k,d);f.push(g)}}b.insertNodes(f);return}}catch(l){}}if(d=a.getData("text/html")){d=(new DOMParser).parseFromString(d,"text/html");a=[];d=d.body?Array.from(d.body.childNodes):[];k=d.length;for(g=0;g<k;g++)f=E(d[g],D,
c),null!==f&&(a=a.concat(f));c=a;a=[];d=null;for(k=0;k<c.length;k++)g=c[k],!e.$isElementNode(g)||g.isInline()?(null===d&&(d=e.$createParagraphNode(),a.push(d)),null!==d&&d.append(g)):(a.push(g),d=null);b.insertNodes(a)}else G(a,b)}function G(a,b){a=a.getData("text/plain");null!=a&&b.insertRawText(a)}
function H(a,b){a.preventDefault();b.update(()=>{e.$log("onCopyForPlainText");const c=a.clipboardData,f=e.$getSelection();if(null!==f&&null!=c){var h=window.getSelection();if(!h.isCollapsed){var d=h.getRangeAt(0);d&&(h=document.createElement("div"),d=d.cloneContents(),h.appendChild(d),c.setData("text/html",h.innerHTML));c.setData("text/plain",f.getTextContent())}}})}
function I(a,b){a.preventDefault();b.update(()=>{e.$log("onCopyForRichText");const c=a.clipboardData;var f=e.$getSelection();if(null!==f&&null!=c){var h=window.getSelection();if(!h.isCollapsed){var d=h.getRangeAt(0);d&&(h=document.createElement("div"),d=d.cloneContents(),h.appendChild(d),c.setData("text/html",h.innerHTML));c.setData("text/plain",f.getTextContent());h=b._config.namespace;d=c.setData;var k=JSON,g=k.stringify;{var l=f.anchor,n=f.focus;var m=l.getCharacterOffset();const x=n.getCharacterOffset();
var p=l.getNode(),t=n.getNode(),q=p.getParentOrThrow();if(p===t&&e.$isTextNode(p)&&(q.canBeEmpty()||1<q.getChildrenSize()))f=B(p),p=x>m,f.__text=f.__text.slice(p?m:x,p?x:m),m=f.getKey(),m={range:[m],nodeMap:[[m,f]]};else if(f=f.getNodes(),0===f.length)m={range:[],nodeMap:[]};else{p=f.length;t=f[0];q=t.getParent();if(null!==q&&!q.canBeEmpty()){var u=q.__children;if(u.length===p){var r=!0;for(var v=0;v<u.length;v++)if(u[v]!==f[v].__key){r=!1;break}r&&(p++,f.push(q))}}q=f[p-1];l=l.isBefore(n);n=new Map;
u=[];C(t,l?m:x,!0,u,n);for(t=0;t<p;t++)if(r=f[t],v=r.getKey(),!(n.has(v)||e.$isElementNode(r)&&r.excludeFromCopy())){const J=B(r);e.$isRootNode(r.getParent())&&u.push(r.getKey());n.set(v,J)}C(q,l?x:m,!1,u,n);m={range:u,nodeMap:Array.from(n.entries())}}}d.call(c,"application/x-lexical-editor",g.call(k,{namespace:h,state:m}))}}})}exports.$createNodesFromDOM=E;exports.$insertDataTransferForPlainText=G;exports.$insertDataTransferForRichText=F;
exports.$shouldOverrideDefaultCharacterSelection=function(a,b){var c=a.focus;a=c.offset;"element"===c.type?b=c.getNode().getChildAtIndex(b?a-1:a):(c=c.getNode(),b=b&&0===a||!b&&a===c.getTextContentSize()?b?c.getPreviousSibling():c.getNextSibling():null);return e.$isDecoratorNode(b)};exports.onCopyForPlainText=H;exports.onCopyForRichText=I;exports.onCutForPlainText=function(a,b){H(a,b);b.update(()=>{e.$log("onCutForPlainText");const c=e.$getSelection();null!==c&&c.removeText()})};
exports.onCutForRichText=function(a,b){I(a,b);b.update(()=>{e.$log("onCutForRichText");const c=e.$getSelection();null!==c&&c.removeText()})};exports.onPasteForPlainText=function(a,b){a.preventDefault();b.update(()=>{e.$log("onPasteForPlainText");const c=e.$getSelection(),f=a.clipboardData;null!=f&&null!==c&&G(f,c)})};exports.onPasteForRichText=function(a,b){a.preventDefault();b.update(()=>{e.$log("onPasteForRichText");const c=e.$getSelection(),f=a.clipboardData;null!=f&&null!==c&&F(f,c,b)})};
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalEventHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalEventHelpers.dev.js') : require('./LexicalEventHelpers.prod.js')
module.exports = LexicalEventHelpers;

@@ -1,3 +0,9 @@

'use strict';var e=require("lexical");function f(a){const b=document.createElement("input");b.type="file";b.accept=".lexical";b.addEventListener("change",c=>{c=c.target.files[0];const d=new FileReader;d.readAsText(c,"UTF-8");d.onload=g=>{a(g.target.result)}});b.click()}
exports.exportFile=function(a,b=Object.freeze({})){var c=new Date;a=a.getEditorState();a={source:b.source||"Lexical",version:e.VERSION,lastSaved:c.getTime(),editorState:a};{b=`${b.fileName||c.toISOString()}.lexical`;c=document.createElement("a");const d=document.body;null!==d&&(d.appendChild(c),c.style.display="none",a=JSON.stringify(a),a=new Blob([a],{type:"octet/stream"}),a=window.URL.createObjectURL(a),c.href=a,c.download=b,c.click(),window.URL.revokeObjectURL(a),c.remove())}};
exports.importFile=function(a){f(b=>{b=JSON.parse(b);b=a.parseEditorState(JSON.stringify(b.editorState));a.setEditorState(b);a.execCommand("clearHistory")})};
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalFileHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalFileHelpers.dev.js') : require('./LexicalFileHelpers.prod.js')
module.exports = LexicalFileHelpers;

@@ -1,5 +0,9 @@

'use strict';var d=require("lexical"),g=require("lexical/TableNode"),h=require("lexical/TableRowNode"),k=require("lexical/TableCellNode");function q(a,b){let c=null;var e=b[a.nodeName.toLowerCase()];if(e&&(c=e(a),d.$isElementNode(c)))for(a=a.childNodes,e=0;e<a.length;e++){const f=q(a[e],b);null!==f&&c.append(f)}return c}function r(a){a=a.getPreviousSibling();return null===a||d.$isLineBreakNode(a)||d.$isTextNode(a)&&a.isSimpleText()&&a.getTextContent().endsWith(" ")}
function t(a){a=a.getNextSibling();return null===a||d.$isLineBreakNode(a)||d.$isTextNode(a)&&a.isSimpleText()&&a.getTextContent().startsWith(" ")}exports.$areSiblingsNullOrSpace=function(a){return r(a)&&t(a)};exports.$createLexicalNodeFromDOMNode=q;
exports.$createTableNodeWithDimensions=function(a,b,c=!0){const e=g.$createTableNode();for(let f=0;f<a;f++){const l=h.$createTableRowNode();for(let m=0;m<b;m++){const n=k.$createTableCellNode(0===f&&c),p=d.$createParagraphNode();p.append(d.$createTextNode());n.append(p);l.append(n)}e.append(l)}return e};
exports.$dfs__DEPRECATED=function(a,b){for(b(a);null!==a;){if(d.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let c=null;for(;null===c&&null!==a;)c=a.getNextSibling(),a=null===c?a.getParent():c}null!==a&&(a=b(a))}};exports.$findMatchingParent=function(a,b){for(;a!==d.$getRoot()&&null!=a;){if(b(a))return a;a=a.getParent()}return null};exports.$getNearestNodeOfType=function(a,b){for(;null!=a&&!(a instanceof b);)a=a.getParent();return a};exports.$isNextSiblingNullOrSpace=t;
exports.$isPreviousSiblingNullOrSpace=r;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalNodeHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalNodeHelpers.dev.js') : require('./LexicalNodeHelpers.prod.js')
module.exports = LexicalNodeHelpers;

@@ -1,9 +0,9 @@

'use strict';var q=require("lexical");
class t{constructor(b,a,c=1){this._offsetMap=b;this._firstNode=a;this._blockOffsetSize=c}createSelectionFromOffsets(b,a,c){var e=this._firstNode;if(null===e)return null;var f=y(e,b,this._blockOffsetSize);let h=y(e,a,this._blockOffsetSize);void 0!==c&&(b=z(b,f,c,this,this._blockOffsetSize),f=y(e,b,this._blockOffsetSize),a=z(a,h,c,this,this._blockOffsetSize),h=y(e,a,this._blockOffsetSize));if(null===f||null===h)return null;c=f.key;e=h.key;const m=q.$getNodeByKey(c),k=q.$getNodeByKey(e);if(null===m||
null===k)return null;let l=0,d=0,g="element",n="element";"text"===f.type?(l=b-f.start,g="text",f=m.getNextSibling(),b!==a&&l===m.getTextContentSize()&&q.$isTextNode(f)&&(l=0,c=f.__key)):"inline"===f.type&&(c=m.getParentOrThrow().getKey(),l=a>f.start?f.end:f.start);"text"===h.type?(d=a-h.start,n="text"):"inline"===h.type&&(e=k.getParentOrThrow().getKey(),d=a>h.start?h.end:h.start);b=q.$createRangeSelection();if(null===b)return null;b.anchor.set(c,l,g);b.focus.set(e,d,n);return b}getOffsetsFromSelection(b){var a=
b.anchor,c=b.focus,e=this._offsetMap;const f=a.offset;var h=c.offset;let m=b=-1;if("text"===a.type)a=e.get(a.key),void 0!==a&&(b=a.start+f);else{a=a.getNode().getDescendantByIndex(f);const k=e.get(a.getKey());void 0!==k&&(b=a.getIndexWithinParent()!==f?k.end:k.start)}"text"===c.type?(h=e.get(c.key),void 0!==h&&(m=h.start+c.offset)):(c=c.getNode().getDescendantByIndex(h),e=e.get(c.getKey()),void 0!==e&&(m=c.getIndexWithinParent()!==h?e.end:e.start));return[b,m]}}
function z(b,a,c,e,f){const h=c._offsetMap;e=e._offsetMap;const m=new Set;let k=b;for(;null!==a;){var l=a.key,d=h.get(l),g=a.end-a.start;m.add(l);void 0===d?k+=g:(l=d.end-d.start,l!==g&&(k+=g-l));g=a.prev;if(null!==g)a=g;else{for(a=a.parent;null!==a;)d=a.prev,null!==d&&(g=d.key,l=h.get(g),d=d.end-d.start,m.add(g),void 0===l?k+=d:(g=l.end-l.start,g!==d&&(k+=d-g))),a=a.parent;break}}c=c._firstNode;if(null!==c){a=y(c,b,f);for(b=!1;null!==a;){if(!m.has(a.key)){b=!0;break}a=a.parent}if(!b)for(;null!==
a;)b=a.key,m.has(b)||(f=e.get(b),b=a.end-a.start,void 0===f?k-=b:(f=f.end-f.start,b!==f&&(k+=f-b))),a=a.prev}return k}function y(b,a,c){for(;null!==b;){if(a<b.end+("element"!==b.type||0===c?1:0)){const e=b.child;if(null!==e){b=e;continue}return b}b=b.next;if(null===b)break}return null}
function A(b,a,c,e,f,h){let m=null,k=null;const l=a.length;for(let v=0;v<l;v++){{var d=b;var g=a[v];var n=c,r=e,w=f,u=h,p=r.get(g);if(void 0===p)throw Error("Minified Lexical error #3; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const x=d.offset;if(q.$isElementNode(p)){const B=p.__children;r=(p=0===B.length)?null:A(d,B,null,r,w,u);if(!d.prevIsBlock||p)d.prevIsBlock=!0,d.offset+=u;n={child:r,prev:null,next:null,type:"element",
start:x,end:x,key:g,parent:n};null!==r&&(r.parent=n);n.end=d.offset;w.set(g,n);g=n}else d.prevIsBlock=!1,u=q.$isTextNode(p),d=d.offset+=u?p.__text.length:1,d={child:null,prev:null,next:null,type:u?"text":"inline",start:x,end:d,key:g,parent:n},w.set(g,d),g=d}null===k?m=g:(g.prev=k,k.next=g);k=g}return m}
exports.$createOffsetView=function(b,a=1,c){c=(c||b._pendingEditorState||b._editorState)._nodeMap;const e=c.get("root");b=new Map;c=A({offset:0,prevIsBlock:!1},e.__children,null,c,b,a);return new t(b,c,a)};exports.OffsetView=t;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalOffsetHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalOffsetHelpers.dev.js') : require('./LexicalOffsetHelpers.prod.js')
module.exports = LexicalOffsetHelpers;

@@ -16,6 +16,6 @@ {

"license": "MIT",
"version": "0.1.7",
"version": "0.1.8",
"peerDependencies": {
"lexical": "0.1.7",
"@lexical/list": "0.1.7"
"lexical": "0.1.8",
"@lexical/list": "0.1.8"
},

@@ -22,0 +22,0 @@ "repository": {

@@ -1,2 +0,9 @@

'use strict';var d=require("lexical");function f(){return d.$getRoot().getTextContent()}function g(a,c=!0){if(a)return!1;a=f();c&&(a=a.trim());return""===a}function h(a){if(!g(a,!1))return!1;a=d.$getRoot().getChildren();const c=a.length;if(1<c)return!1;for(let e=0;e<c;e++){var b=a[e];if(d.$isElementNode(b)){if("paragraph"!==b.__type||0!==b.__indent)return!1;b=b.getChildren();const l=b.length;for(let k=0;k<l;k++)if(!d.$isTextNode(b[e]))return!1}}return!0}exports.$canShowPlaceholder=h;
exports.$canShowPlaceholderCurry=function(a){return()=>h(a)};exports.$isTextContentEmpty=g;exports.$isTextContentEmptyCurry=function(a,c){return()=>g(a,c)};exports.$textContent=f;exports.$textContentCurry=f;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalRootHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalRootHelpers.dev.js') : require('./LexicalRootHelpers.prod.js')
module.exports = LexicalRootHelpers;

@@ -1,13 +0,9 @@

'use strict';var l=require("lexical");const r=new Map;function v(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;l.$isElementNode(a)&&l.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):l.$isTextNode(a)&&l.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):l.$isDecoratorNode(a)&&l.$isDecoratorNode(c)&&(c.__state=a.__state);return c}
function w(a,c,b,g,k){for(var e=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!l.$isElementNode(a)||!a.excludeFromCopy()){const d=a.getKey();let f=k.get(d);const h=void 0===f;h&&(f=v(a),k.set(d,f));!l.$isTextNode(f)||f.isSegmented()||f.isToken()?l.$isElementNode(f)&&(f.__children=f.__children.slice(b?e:0,b?void 0:e+1)):f.__text=f.__text.slice(b?e:0,b?void 0:e);if(l.$isRootNode(c)){h&&g.push(d);break}}e=k.get(c.getKey());e=l.$isElementNode(e)?
e.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=c}}function x(a){return r.get(a)||null}function y(a,c){var b=x(a.getStyle());c=b?{...b,...c}:c;b="";for(g in c)g&&(b+=`${g}: ${c[g]};`);var g=b;a.setStyle(g);r.set(g,c)}function z(a,c,b,g){a.modify(c?"extend":"move",b,g)}function A(a){for(;null!==a&&!l.$isRootNode(a);){const c=a.getLatest(),b=a.getParent();0===c.__children.length&&a.remove();a=b}}
exports.$cloneContents=function(a){var c=a.anchor,b=a.focus,g=c.getCharacterOffset();const k=b.getCharacterOffset();var e=c.getNode(),d=b.getNode(),f=e.getParentOrThrow();if(e===d&&l.$isTextNode(e)&&(f.canBeEmpty()||1<f.getChildrenSize()))return a=v(e),e=k>g,a.__text=a.__text.slice(e?g:k,e?k:g),g=a.getKey(),{range:[g],nodeMap:[[g,a]]};a=a.getNodes();if(0===a.length)return{range:[],nodeMap:[]};e=a.length;d=a[0];f=d.getParent();if(null!==f&&!f.canBeEmpty()){var h=f.__children;if(h.length===e){var m=
!0;for(var n=0;n<h.length;n++)if(h[n]!==a[n].__key){m=!1;break}m&&(e++,a.push(f))}}f=a[e-1];c=c.isBefore(b);b=new Map;h=[];w(d,c?g:k,!0,h,b);for(d=0;d<e;d++)if(m=a[d],n=m.getKey(),!(b.has(n)||l.$isElementNode(m)&&m.excludeFromCopy())){const t=v(m);l.$isRootNode(m.getParent())&&h.push(m.getKey());b.set(n,t)}w(f,c?k:g,!1,h,b);return{range:h,nodeMap:Array.from(b.entries())}};
exports.$getSelectionStyleValueForProperty=function(a,c,b=""){let g=null;const k=a.getNodes();var e=a.anchor,d=a.focus,f=a.isBackward();a=f?d.offset:e.offset;e=f?d.getNode():e.getNode();for(d=0;d<k.length;d++){var h=k[d];if((0===d||0!==a||!h.is(e))&&l.$isTextNode(h)){f=c;var m=b;h=h.getStyle();h=x(h);f=null!==h?h[f]||m:m;if(null===g)g=f;else if(g!==f){g="";break}}}return null===g?b:g};exports.$isAtNodeEnd=function(a){return"text"===a.type?a.offset===a.getNode().getTextContentSize():a.offset===a.getNode().getChildrenSize()};
exports.$moveCaretSelection=z;exports.$moveCharacter=function(a,c,b){var g="rtl"===a.anchor.getNode().getParentOrThrow().getDirection();z(a,c,b?!g:g,"character")};
exports.$patchStyleText=function(a,c){var b=a.getNodes();const g=b.length-1;let k=b[0],e=b[g];if(!a.isCollapsed()){var d=a.anchor,f=a.focus;a=k.getTextContent().length;var h=f.offset,m=d.offset;d=(f=d.isBefore(f))?m:h;f=f?h:m;if(d===k.getTextContentSize()){const n=k.getNextSibling();l.$isTextNode(n)&&(d=m=0,k=n)}if(k.is(e))l.$isTextNode(k)&&(d=m>h?h:m,f=m>h?m:h,d!==f&&(0===d&&f===a?(y(k,c),k.select(d,f)):(b=k.splitText(d,f),b=0===d?b[0]:b[1],y(b,c),b.select(0,f-d))));else for(l.$isTextNode(k)&&(0!==
d&&([,k]=k.splitText(d)),y(k,c)),l.$isTextNode(e)&&(a=e.getTextContent().length,f!==a&&([e]=e.splitText(f)),0!==f&&y(e,c)),a=1;a<g;a++)h=b[a],m=h.getKey(),l.$isTextNode(h)&&m!==k.getKey()&&m!==e.getKey()&&!h.isToken()&&y(h,c)}};
exports.$selectAll=function(a){const c=a.anchor;a=a.focus;var b=c.getNode().getTopLevelElementOrThrow().getParentOrThrow();let g=b.getFirstDescendant();b=b.getLastDescendant();let k="element",e="element",d=0;l.$isTextNode(g)?k="text":l.$isElementNode(g)||null===g||(g=g.getParentOrThrow());l.$isTextNode(b)?(e="text",d=b.getTextContentSize()):l.$isElementNode(b)||null===b||(b=b.getParentOrThrow(),d=b.getChildrenSize());g&&b&&(c.set(g.getKey(),0,k),a.set(b.getKey(),d,e))};
exports.$wrapLeafNodesInElements=function(a,c,b){const g=a.getNodes(),k=g.length;if(0===k){a=a.anchor;a="text"===a.type?a.getNode().getParentOrThrow():a.getNode();var e=a.getChildren();let p=c();e.forEach(u=>p.append(u));b&&(p=b.append(p));a.replace(p)}else{var d=g[0],f=new Map;e=[];for(d=l.$isElementNode(d)?d:d.getParentOrThrow();null!==d;){var h=d.getPreviousSibling();if(null!==h){d=h;break}d=d.getParentOrThrow();if(l.$isRootNode(d))break}h=new Set;for(var m=0;m<k;m++){var n=g[m];l.$isElementNode(n)&&
0===n.getChildrenSize()&&h.add(n.getKey())}var t=new Set;for(m=0;m<k;m++){var q=g[m];n=q.getParent();if(null!==n&&l.$isLeafNode(q)&&!t.has(q.getKey())){if(q=n.getKey(),void 0===f.get(q)){const p=c();e.push(p);f.set(q,p);n.getChildren().forEach(u=>{p.append(u);t.add(u.getKey())});A(n)}}else h.has(q.getKey())&&(e.push(c()),q.remove())}if(b)for(c=0;c<e.length;c++)b.append(e[c]);if(l.$isRootNode(d))if(c=d.getFirstChild(),l.$isElementNode(c)&&(d=c),null===c)if(b)d.append(b);else for(b=0;b<e.length;b++)d.append(e[b]);
else if(b)c.insertBefore(b);else for(b=0;b<e.length;b++)c.insertBefore(e[b]);else if(b)d.insertAfter(b);else for(b=e.length-1;0<=b;b--)d.insertAfter(e[b]);a.dirty=!0}};exports.getStyleObjectFromCSS=x;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalSelectionHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalSelectionHelpers.dev.js') : require('./LexicalSelectionHelpers.prod.js')
module.exports = LexicalSelectionHelpers;

@@ -1,2 +0,9 @@

'use strict';var g=require("lexical");exports.$findTextIntersectionFromCharacters=function(c,d){var a=c.getFirstChild();c=0;a:for(;null!==a;){if(g.$isElementNode(a)){var b=a.getFirstChild();if(null!==b){a=b;continue}}else if(g.$isTextNode(a)){b=a.getTextContentSize();if(c+b>d)return{node:a,offset:d-c};c+=b}b=a.getNextSibling();if(null!==b)a=b;else{for(a=a.getParent();null!==a;){b=a.getNextSibling();if(null!==b){a=b;continue a}a=a.getParent()}break}}return null};
exports.$joinTextNodesFromElementNode=function(c,d,a,b){let e="";c=c.getChildren();const l=c.length;for(let h=0;h<l;++h){const f=c[h];if(g.$isTextNode(f)){const k=f.getTextContent();if(f.is(a)){if(b>k.length)throw Error("Minified Lexical error #50; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");e+=f.getTextContent().substr(0,b);break}else e+=k}else e+=d}return e};
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict'
const LexicalTextHelpers = process.env.NODE_ENV === 'development' ? require('./LexicalTextHelpers.dev.js') : require('./LexicalTextHelpers.prod.js')
module.exports = LexicalTextHelpers;
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