Socket
Socket
Sign inDemoInstall

@lexical/devtools-core

Package Overview
Dependencies
Maintainers
5
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/devtools-core - npm Package Compare versions

Comparing version 0.14.5 to 0.15.0

2

generateContent.d.ts

@@ -12,2 +12,2 @@ /**

payload: unknown;
}>, exportDOM: boolean): string;
}>, exportDOM: boolean, obfuscateText?: boolean): string;

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

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';

@@ -17,2 +19,15 @@

function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
for (var k in e) {
n[k] = e[k];
}
}
n.default = e;
return n;
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
/**

@@ -25,2 +40,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates.

*/
const NON_SINGLE_WIDTH_CHARS_REPLACEMENT = Object.freeze({

@@ -43,3 +59,3 @@ '\t': '\\t',

const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented'];
function generateContent(editor, commandsLog, exportDOM) {
function generateContent(editor, commandsLog, exportDOM, obfuscateText = false) {
const editorState = editor.getEditorState();

@@ -65,4 +81,4 @@ const editorConfig = editor._config;

const idsDisplay = mark.$isMarkNode(node) ? ` id: [ ${node.getIDs().join(', ')} ] ` : '';
res += `${isSelected ? SYMBOLS.selectedLine : ' '} ${indent.join(' ')} ${nodeKeyDisplay} ${typeDisplay} ${idsDisplay} ${printNode(node)}\n`;
res += printSelectedCharsLine({
res += `${isSelected ? SYMBOLS.selectedLine : ' '} ${indent.join(' ')} ${nodeKeyDisplay} ${typeDisplay} ${idsDisplay} ${printNode(node, obfuscateText)}\n`;
res += $printSelectedCharsLine({
indent,

@@ -129,11 +145,15 @@ isSelected,

}
function normalize(text) {
return Object.entries(NON_SINGLE_WIDTH_CHARS_REPLACEMENT).reduce((acc, [key, value]) => acc.replace(new RegExp(key, 'g'), String(value)), text);
function normalize(text, obfuscateText = false) {
const textToPrint = Object.entries(NON_SINGLE_WIDTH_CHARS_REPLACEMENT).reduce((acc, [key, value]) => acc.replace(new RegExp(key, 'g'), String(value)), text);
if (obfuscateText) {
return textToPrint.replace(/[^\s]/g, '*');
}
return textToPrint;
}
// TODO Pass via props to allow customizability
function printNode(node) {
function printNode(node, obfuscateText = false) {
if (lexical.$isTextNode(node)) {
const text = node.getTextContent();
const title = text.length === 0 ? '(empty)' : `"${normalize(text)}"`;
const title = text.length === 0 ? '(empty)' : `"${normalize(text, obfuscateText)}"`;
const properties = printAllTextNodeProperties(node);

@@ -143,3 +163,3 @@ return [title, properties.length !== 0 ? `{ ${properties} }` : null].filter(Boolean).join(' ').trim();

const link = node.getURL();
const title = link.length === 0 ? '(empty)' : `"${normalize(link)}"`;
const title = link.length === 0 ? '(empty)' : `"${normalize(link, obfuscateText)}"`;
const properties = printAllLinkNodeProperties(node);

@@ -212,3 +232,3 @@ return [title, properties.length !== 0 ? `{ ${properties} }` : null].filter(Boolean).join(' ').trim();

}
function printSelectedCharsLine({
function $printSelectedCharsLine({
indent,

@@ -305,2 +325,3 @@ isSelected,

*/
const LARGE_EDITOR_STATE_SIZE = 1000;

@@ -393,13 +414,13 @@ const TreeView = /*#__PURE__*/React.forwardRef(function TreeViewWrapped({

};
return /*#__PURE__*/React.createElement("div", {
return /*#__PURE__*/React__namespace.createElement("div", {
className: viewClassName
}, !showLimited && isLimited ? /*#__PURE__*/React.createElement("div", {
}, !showLimited && isLimited ? /*#__PURE__*/React__namespace.createElement("div", {
style: {
padding: 20
}
}, /*#__PURE__*/React.createElement("span", {
}, /*#__PURE__*/React__namespace.createElement("span", {
style: {
marginRight: 20
}
}, "Detected large EditorState, this can impact debugging performance."), /*#__PURE__*/React.createElement("button", {
}, "Detected large EditorState, this can impact debugging performance."), /*#__PURE__*/React__namespace.createElement("button", {
onClick: () => {

@@ -415,7 +436,7 @@ setShowLimited(true);

}
}, "Show full tree")) : null, !showLimited ? /*#__PURE__*/React.createElement("button", {
}, "Show full tree")) : null, !showLimited ? /*#__PURE__*/React__namespace.createElement("button", {
onClick: () => handleExportModeToggleClick(),
className: treeTypeButtonClassName,
type: "button"
}, showExportDOM ? 'Tree' : 'Export DOM') : null, !timeTravelEnabled && (showLimited || !isLimited) && totalEditorStates > 2 && /*#__PURE__*/React.createElement("button", {
}, showExportDOM ? 'Tree' : 'Export DOM') : null, !timeTravelEnabled && (showLimited || !isLimited) && totalEditorStates > 2 && /*#__PURE__*/React__namespace.createElement("button", {
onClick: () => {

@@ -428,7 +449,7 @@ setEditorReadOnly(true);

type: "button"
}, "Time Travel"), (showLimited || !isLimited) && /*#__PURE__*/React.createElement("pre", {
}, "Time Travel"), (showLimited || !isLimited) && /*#__PURE__*/React__namespace.createElement("pre", {
ref: ref
}, content), timeTravelEnabled && (showLimited || !isLimited) && /*#__PURE__*/React.createElement("div", {
}, content), timeTravelEnabled && (showLimited || !isLimited) && /*#__PURE__*/React__namespace.createElement("div", {
className: timeTravelPanelClassName
}, /*#__PURE__*/React.createElement("button", {
}, /*#__PURE__*/React__namespace.createElement("button", {
className: timeTravelPanelButtonClassName,

@@ -442,3 +463,3 @@ onClick: () => {

type: "button"
}, isPlaying ? 'Pause' : 'Play'), /*#__PURE__*/React.createElement("input", {
}, isPlaying ? 'Pause' : 'Play'), /*#__PURE__*/React__namespace.createElement("input", {
className: timeTravelPanelSliderClassName,

@@ -457,3 +478,3 @@ ref: inputRef,

max: totalEditorStates - 1
}), /*#__PURE__*/React.createElement("button", {
}), /*#__PURE__*/React__namespace.createElement("button", {
className: timeTravelPanelButtonClassName,

@@ -483,2 +504,3 @@ onClick: () => {

*/
function registerLexicalCommandLogger(editor, setLoggedCommands) {

@@ -485,0 +507,0 @@ const unregisterCommandListeners = new Set();

@@ -6,5 +6,7 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict'
const LexicalDevtoolsCore = process.env.NODE_ENV === 'development' ? require('./LexicalDevtoolsCore.dev.js') : require('./LexicalDevtoolsCore.prod.js');
module.exports = LexicalDevtoolsCore;

@@ -6,21 +6,23 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';var e=require("@lexical/html"),q=require("@lexical/link"),u=require("@lexical/mark"),K=require("@lexical/table"),L=require("lexical"),M=require("react");
let N=Object.freeze({"\t":"\\t","\n":"\\n"}),O=new RegExp(Object.keys(N).join("|"),"g"),P=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"}),U=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&
"Underline"],aa=[a=>a.hasTextFormat("bold")&&"Bold",a=>a.hasTextFormat("code")&&"Code",a=>a.hasTextFormat("italic")&&"Italic",a=>a.hasTextFormat("strikethrough")&&"Strikethrough",a=>a.hasTextFormat("subscript")&&"Subscript",a=>a.hasTextFormat("superscript")&&"Superscript",a=>a.hasTextFormat("underline")&&"Underline"],ba=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],ca=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented"];
function da(a){let b="";var c=V(a);b+=`: range ${""!==c?`{ ${c} }`:""} ${""!==a.style?`{ style: ${a.style} } `:""}`;c=a.anchor;a=a.focus;let f=c.offset,d=a.offset;b+=`\n \u251c anchor { key: ${c.key}, offset: ${null===f?"null":f}, type: ${c.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===d?"null":d}, type: ${a.type} }`}function ea(a){return L.$isNodeSelection(a)?`: node\n \u2514 [${Array.from(a._nodes).join(", ")}]`:""}
function W(a,b,c=[]){a=a.getChildren();let f=a.length;a.forEach((d,k)=>{b(d,c.concat(k===f-1?P.isLastChild:P.hasNextSibling));L.$isElementNode(d)&&W(d,b,c.concat(k===f-1?P.ancestorIsLastChild:P.ancestorHasNextSibling))})}function X(a){return Object.entries(N).reduce((b,[c,f])=>b.replace(new RegExp(c,"g"),String(f)),a)}
function fa(a){if(L.$isTextNode(a)){var b=a.getTextContent();b=0===b.length?"(empty)":`"${X(b)}"`;a=[V(a),ha(a),ia(a)].filter(Boolean).join(", ");return[b,0!==a.length?`{ ${a} }`:null].filter(Boolean).join(" ").trim()}if(q.$isLinkNode(a)){b=a.getURL();b=0===b.length?"(empty)":`"${X(b)}"`;var c=a.getTarget();null!=c&&(c="target: "+c);var f=Boolean;var d=a.getRel();null!=d&&(d="rel: "+d);a=a.getTitle();null!=a&&(a="title: "+a);a=[c,d,a].filter(f).join(", ");return[b,0!==a.length?`{ ${a} }`:null].filter(Boolean).join(" ").trim()}return L.$isParagraphNode(a)?
(a=ja(a),""!==a?`{ ${a} }`:""):""}function ja(a){let b=aa.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}function ha(a){let b=ba.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function ia(a){let b=ca.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}
function V(a){let b=U.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
function ka({indent:a,isSelected:b,node:c,nodeKeyDisplay:f,selection:d,typeDisplay:k}){if(!L.$isTextNode(c)||!L.$isRangeSelection(d)||!b||L.$isElementNode(c))return"";b=d.anchor;var m=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===m.offset)return"";b=d.getStartEndPoints();if(L.$isNodeSelection(d)||null===b)c=[-1,-1];else{var [h,g]=b;m=c.getTextContent();var l=m.length;b=d=-1;if("text"===h.type&&"text"===g.type){let v=h.getNode(),w=g.getNode();v===w&&c===v&&h.offset!==
g.offset?[d,b]=h.offset<g.offset?[h.offset,g.offset]:[g.offset,h.offset]:c===v?[d,b]=v.isBefore(w)?[h.offset,l]:[0,h.offset]:c===w?[d,b]=w.isBefore(v)?[g.offset,l]:[0,g.offset]:[d,b]=[0,l]}c=(m.slice(0,d).match(O)||[]).length;m=(m.slice(d,b).match(O)||[]).length;c=[d+c,b+c+m]}let [r,n]=c;if(r===n)return"";c=a[a.length-1]===P.hasNextSibling?P.ancestorHasNextSibling:P.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(r+1).fill(" ");d=Array(n-r).fill(P.selectedChar);f=Array(f.length+(k.length+
3)).fill(" ");return[P.selectedLine,a.join(" "),[...f,...c,...d].join("")].join(" ")+"\n"}function Y(a,b){let c=Array(b++ +1).join(" "),f=Array(b-1).join(" "),d;for(let k=0;k<a.children.length;k++)d=document.createTextNode("\n"+c),a.insertBefore(d,a.children[k]),Y(a.children[k],b),a.lastElementChild===a.children[k]&&(d=document.createTextNode("\n"+f),a.appendChild(d));return a}
let oa=M.forwardRef(function({treeTypeButtonClassName:a,timeTravelButtonClassName:b,timeTravelPanelSliderClassName:c,timeTravelPanelButtonClassName:f,viewClassName:d,timeTravelPanelClassName:k,editorState:m,setEditorState:h,setEditorReadOnly:g,generateContent:l},r){const [n,v]=M.useState([]),[w,C]=M.useState(""),[D,Q]=M.useState(!1),[B,la]=M.useState(!1),z=M.useRef(0),G=M.useRef(null),[E,H]=M.useState(!1),[F,ma]=M.useState(!1),[x,na]=M.useState(!1),R=M.useRef(),I=M.useRef(0),J=M.useCallback(p=>{const t=
++I.current;l(p).then(y=>{t===I.current&&C(y)}).catch(y=>{t===I.current&&C(`Error rendering tree: ${y.message}\n\nStack:\n${y.stack}`)})},[l]);M.useEffect(()=>{if(!x&&1E3<m._nodeMap.size&&(ma(!0),!x))return;R.current!==m&&(R.current=m,J(B),D||v(p=>[...p,[Date.now(),m]]))},[m,J,B,x,D]);const A=n.length;M.useEffect(()=>{if(E){let p;const t=()=>{const y=z.current;y===A-1?H(!1):p=setTimeout(()=>{z.current++;const S=z.current,T=G.current;null!==T&&(T.value=String(S));h(n[S][1]);t()},n[y+1][0]-n[y][0])};
t();return()=>{clearTimeout(p)}}},[n,E,A,h]);return M.createElement("div",{className:d},!x&&F?M.createElement("div",{style:{padding:20}},M.createElement("span",{style:{marginRight:20}},"Detected large EditorState, this can impact debugging performance."),M.createElement("button",{onClick:()=>{na(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5}},"Show full tree")):null,x?null:M.createElement("button",{onClick:()=>{J(!B);la(!B)},className:a,type:"button"},
B?"Tree":"Export DOM"),!D&&(x||!F)&&2<A&&M.createElement("button",{onClick:()=>{g(!0);z.current=A-1;Q(!0)},className:b,type:"button"},"Time Travel"),(x||!F)&&M.createElement("pre",{ref:r},w),D&&(x||!F)&&M.createElement("div",{className:k},M.createElement("button",{className:f,onClick:()=>{z.current===A-1&&(z.current=1);H(!E)},type:"button"},E?"Pause":"Play"),M.createElement("input",{className:c,ref:G,onChange:p=>{p=Number(p.target.value);const t=n[p];t&&(z.current=p,h(t[1]))},type:"range",min:"1",
max:A-1}),M.createElement("button",{className:f,onClick:()=>{g(!1);const p=n.length-1;h(n[p][1]);const t=G.current;null!==t&&(t.value=String(p));Q(!1);H(!1)},type:"button"},"Exit")))});function Z(a,b){let c=new Set;for(let [f]of a._commands)c.add(a.registerCommand(f,d=>{b(k=>{k=[...k];k.push({payload:d,type:f.type?f.type:"UNKNOWN"});10<k.length&&k.shift();return k});return!1},L.COMMAND_PRIORITY_CRITICAL));return()=>c.forEach(f=>f())}exports.TreeView=oa;
exports.generateContent=function(a,b,c){let f=a.getEditorState(),d=a._config,k=a._compositionKey,m=a._editable;if(c){let g="";f.read(()=>{var l=e.$generateHtmlFromNodes(a);let r=document.createElement("div");r.innerHTML=l.trim();g=Y(r,0).innerHTML});return g}let h=" root\n";c=f.read(()=>{const g=L.$getSelection();W(L.$getRoot(),(l,r)=>{const n=`(${l.getKey()})`,v=l.getType()||"",w=l.isSelected(),C=u.$isMarkNode(l)?` id: [ ${l.getIDs().join(", ")} ] `:"";h+=`${w?P.selectedLine:" "} ${r.join(" ")} ${n} ${v} ${C} ${fa(l)}\n`;
h+=ka({indent:r,isSelected:w,node:l,nodeKeyDisplay:n,selection:g,typeDisplay:v})});return null===g?": null":L.$isRangeSelection(g)?da(g):K.$isTableSelection(g)?`: table\n \u2514 { table: ${g.tableKey}, anchorCell: ${g.anchor.key}, focusCell: ${g.focus.key} }`:ea(g)});h+="\n selection"+c;h+="\n\n commands:";if(b.length)for(let {type:g,payload:l}of b)h+=`\n \u2514 { type: ${g}, payload: ${l instanceof Event?l.constructor.name:l} }`;else h+="\n \u2514 None dispatched.";h+="\n\n editor:";h+=`\n \u2514 namespace ${d.namespace}`;
null!==k&&(h+=`\n \u2514 compositionKey ${k}`);return h+=`\n \u2514 editable ${String(m)}`};exports.registerLexicalCommandLogger=Z;exports.useLexicalCommandsLog=function(a){let [b,c]=M.useState([]);M.useEffect(()=>Z(a,c),[a]);return M.useMemo(()=>b,[b])}
'use strict';var f=require("@lexical/html"),r=require("@lexical/link"),t=require("@lexical/mark"),aa=require("@lexical/table"),v=require("lexical"),L=require("react"),M=Object.create(null);if(L)for(var N in L)M[N]=L[N];M.default=L;
let O=Object.freeze({"\t":"\\t","\n":"\\n"}),P=new RegExp(Object.keys(O).join("|"),"g"),Q=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"}),ba=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&
"Underline"],ca=[a=>a.hasTextFormat("bold")&&"Bold",a=>a.hasTextFormat("code")&&"Code",a=>a.hasTextFormat("italic")&&"Italic",a=>a.hasTextFormat("strikethrough")&&"Strikethrough",a=>a.hasTextFormat("subscript")&&"Subscript",a=>a.hasTextFormat("superscript")&&"Superscript",a=>a.hasTextFormat("underline")&&"Underline"],da=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],ea=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented"];
function fa(a){let b="";var c=R(a);b+=`: range ${""!==c?`{ ${c} }`:""} ${""!==a.style?`{ style: ${a.style} } `:""}`;c=a.anchor;a=a.focus;let e=c.offset,d=a.offset;b+=`\n \u251c anchor { key: ${c.key}, offset: ${null===e?"null":e}, type: ${c.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===d?"null":d}, type: ${a.type} }`}function ha(a){return v.$isNodeSelection(a)?`: node\n \u2514 [${Array.from(a._nodes).join(", ")}]`:""}
function W(a,b,c=[]){a=a.getChildren();let e=a.length;a.forEach((d,h)=>{b(d,c.concat(h===e-1?Q.isLastChild:Q.hasNextSibling));v.$isElementNode(d)&&W(d,b,c.concat(h===e-1?Q.ancestorIsLastChild:Q.ancestorHasNextSibling))})}function X(a,b=!1){a=Object.entries(O).reduce((c,[e,d])=>c.replace(new RegExp(e,"g"),String(d)),a);return b?a.replace(/[^\s]/g,"*"):a}
function ia(a,b=!1){if(v.$isTextNode(a)){var c=a.getTextContent();b=0===c.length?"(empty)":`"${X(c,b)}"`;a=[R(a),ja(a),ka(a)].filter(Boolean).join(", ");return[b,0!==a.length?`{ ${a} }`:null].filter(Boolean).join(" ").trim()}if(r.$isLinkNode(a)){c=a.getURL();b=0===c.length?"(empty)":`"${X(c,b)}"`;c=a.getTarget();null!=c&&(c="target: "+c);var e=Boolean;var d=a.getRel();null!=d&&(d="rel: "+d);a=a.getTitle();null!=a&&(a="title: "+a);a=[c,d,a].filter(e).join(", ");return[b,0!==a.length?`{ ${a} }`:null].filter(Boolean).join(" ").trim()}return v.$isParagraphNode(a)?
(a=la(a),""!==a?`{ ${a} }`:""):""}function la(a){let b=ca.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}function ja(a){let b=da.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function ka(a){let b=ea.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}
function R(a){let b=ba.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
function ma({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:h}){if(!v.$isTextNode(c)||!v.$isRangeSelection(d)||!b||v.$isElementNode(c))return"";b=d.anchor;var n=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===n.offset)return"";b=d.getStartEndPoints();if(v.$isNodeSelection(d)||null===b)c=[-1,-1];else{var [p,g]=b;n=c.getTextContent();var k=n.length;b=d=-1;if("text"===p.type&&"text"===g.type){let w=p.getNode(),x=g.getNode();w===x&&c===w&&p.offset!==
g.offset?[d,b]=p.offset<g.offset?[p.offset,g.offset]:[g.offset,p.offset]:c===w?[d,b]=w.isBefore(x)?[p.offset,k]:[0,p.offset]:c===x?[d,b]=x.isBefore(w)?[g.offset,k]:[0,g.offset]:[d,b]=[0,k]}c=(n.slice(0,d).match(P)||[]).length;n=(n.slice(d,b).match(P)||[]).length;c=[d+c,b+c+n]}let [l,m]=c;if(l===m)return"";c=a[a.length-1]===Q.hasNextSibling?Q.ancestorHasNextSibling:Q.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(l+1).fill(" ");d=Array(m-l).fill(Q.selectedChar);e=Array(e.length+(h.length+
3)).fill(" ");return[Q.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+"\n"}function Y(a,b){let c=Array(b++ +1).join(" "),e=Array(b-1).join(" "),d;for(let h=0;h<a.children.length;h++)d=document.createTextNode("\n"+c),a.insertBefore(d,a.children[h]),Y(a.children[h],b),a.lastElementChild===a.children[h]&&(d=document.createTextNode("\n"+e),a.appendChild(d));return a}
let qa=L.forwardRef(function({treeTypeButtonClassName:a,timeTravelButtonClassName:b,timeTravelPanelSliderClassName:c,timeTravelPanelButtonClassName:e,viewClassName:d,timeTravelPanelClassName:h,editorState:n,setEditorState:p,setEditorReadOnly:g,generateContent:k},l){const [m,w]=L.useState([]),[x,D]=L.useState(""),[B,S]=L.useState(!1),[E,na]=L.useState(!1),A=L.useRef(0),H=L.useRef(null),[F,I]=L.useState(!1),[G,oa]=L.useState(!1),[y,pa]=L.useState(!1),T=L.useRef(),J=L.useRef(0),K=L.useCallback(q=>{const u=
++J.current;k(q).then(z=>{u===J.current&&D(z)}).catch(z=>{u===J.current&&D(`Error rendering tree: ${z.message}\n\nStack:\n${z.stack}`)})},[k]);L.useEffect(()=>{if(!y&&1E3<n._nodeMap.size&&(oa(!0),!y))return;T.current!==n&&(T.current=n,K(E),B||w(q=>[...q,[Date.now(),n]]))},[n,K,E,y,B]);const C=m.length;L.useEffect(()=>{if(F){let q;const u=()=>{const z=A.current;z===C-1?I(!1):q=setTimeout(()=>{A.current++;const U=A.current,V=H.current;null!==V&&(V.value=String(U));p(m[U][1]);u()},m[z+1][0]-m[z][0])};
u();return()=>{clearTimeout(q)}}},[m,F,C,p]);return M.createElement("div",{className:d},!y&&G?M.createElement("div",{style:{padding:20}},M.createElement("span",{style:{marginRight:20}},"Detected large EditorState, this can impact debugging performance."),M.createElement("button",{onClick:()=>{pa(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5}},"Show full tree")):null,y?null:M.createElement("button",{onClick:()=>{K(!E);na(!E)},className:a,type:"button"},
E?"Tree":"Export DOM"),!B&&(y||!G)&&2<C&&M.createElement("button",{onClick:()=>{g(!0);A.current=C-1;S(!0)},className:b,type:"button"},"Time Travel"),(y||!G)&&M.createElement("pre",{ref:l},x),B&&(y||!G)&&M.createElement("div",{className:h},M.createElement("button",{className:e,onClick:()=>{A.current===C-1&&(A.current=1);I(!F)},type:"button"},F?"Pause":"Play"),M.createElement("input",{className:c,ref:H,onChange:q=>{q=Number(q.target.value);const u=m[q];u&&(A.current=q,p(u[1]))},type:"range",min:"1",
max:C-1}),M.createElement("button",{className:e,onClick:()=>{g(!1);const q=m.length-1;p(m[q][1]);const u=H.current;null!==u&&(u.value=String(q));S(!1);I(!1)},type:"button"},"Exit")))});function Z(a,b){let c=new Set;for(let [e]of a._commands)c.add(a.registerCommand(e,d=>{b(h=>{h=[...h];h.push({payload:d,type:e.type?e.type:"UNKNOWN"});10<h.length&&h.shift();return h});return!1},v.COMMAND_PRIORITY_CRITICAL));return()=>c.forEach(e=>e())}exports.TreeView=qa;
exports.generateContent=function(a,b,c,e=!1){let d=a.getEditorState(),h=a._config,n=a._compositionKey,p=a._editable;if(c){let k="";d.read(()=>{var l=f.$generateHtmlFromNodes(a);let m=document.createElement("div");m.innerHTML=l.trim();k=Y(m,0).innerHTML});return k}let g=" root\n";c=d.read(()=>{const k=v.$getSelection();W(v.$getRoot(),(l,m)=>{const w=`(${l.getKey()})`,x=l.getType()||"",D=l.isSelected(),B=t.$isMarkNode(l)?` id: [ ${l.getIDs().join(", ")} ] `:"";g+=`${D?Q.selectedLine:" "} ${m.join(" ")} ${w} ${x} ${B} ${ia(l,
e)}\n`;g+=ma({indent:m,isSelected:D,node:l,nodeKeyDisplay:w,selection:k,typeDisplay:x})});return null===k?": null":v.$isRangeSelection(k)?fa(k):aa.$isTableSelection(k)?`: table\n \u2514 { table: ${k.tableKey}, anchorCell: ${k.anchor.key}, focusCell: ${k.focus.key} }`:ha(k)});g+="\n selection"+c;g+="\n\n commands:";if(b.length)for(let {type:k,payload:l}of b)g+=`\n \u2514 { type: ${k}, payload: ${l instanceof Event?l.constructor.name:l} }`;else g+="\n \u2514 None dispatched.";g+="\n\n editor:";g+=
`\n \u2514 namespace ${h.namespace}`;null!==n&&(g+=`\n \u2514 compositionKey ${n}`);return g+=`\n \u2514 editable ${String(p)}`};exports.registerLexicalCommandLogger=Z;exports.useLexicalCommandsLog=function(a){let [b,c]=L.useState([]);L.useEffect(()=>Z(a,c),[a]);return L.useMemo(()=>b,[b])}

@@ -11,12 +11,12 @@ {

"license": "MIT",
"version": "0.14.5",
"version": "0.15.0",
"main": "LexicalDevtoolsCore.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/html": "0.14.5",
"@lexical/link": "0.14.5",
"@lexical/mark": "0.14.5",
"@lexical/table": "0.14.5",
"@lexical/utils": "0.14.5",
"lexical": "0.14.5"
"@lexical/html": "0.15.0",
"@lexical/link": "0.15.0",
"@lexical/mark": "0.15.0",
"@lexical/table": "0.15.0",
"@lexical/utils": "0.15.0",
"lexical": "0.15.0"
},

@@ -23,0 +23,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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