@lexical/devtools-core 0.36.2-nightly.20250930.0 → 0.36.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.
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/html"),t=require("@lexical/link"),n=require("@lexical/mark"),r=require("@lexical/table"),o=require("lexical"),s=require("react"),i=require("react/jsx-runtime");const l=Object.freeze({"\t":"\\t","\n":"\\n"}),a=new RegExp(Object.keys(l).join("|"),"g"),c=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"├",isLastChild:"└",selectedChar:"^",selectedLine:">"}),u=[e=>e.hasFormat("bold")&&"Bold",e=>e.hasFormat("code")&&"Code",e=>e.hasFormat("italic")&&"Italic",e=>e.hasFormat("strikethrough")&&"Strikethrough",e=>e.hasFormat("subscript")&&"Subscript",e=>e.hasFormat("superscript")&&"Superscript",e=>e.hasFormat("underline")&&"Underline",e=>e.hasFormat("highlight")&&"Highlight"],f=[e=>e.hasTextFormat("bold")&&"Bold",e=>e.hasTextFormat("code")&&"Code",e=>e.hasTextFormat("italic")&&"Italic",e=>e.hasTextFormat("strikethrough")&&"Strikethrough",e=>e.hasTextFormat("subscript")&&"Subscript",e=>e.hasTextFormat("superscript")&&"Superscript",e=>e.hasTextFormat("underline")&&"Underline",e=>e.hasTextFormat("highlight")&&"Highlight"],d=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],h=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function g(e,t,n=[]){const r=e.getChildren(),s=r.length;r.forEach((
|
|
9
|
+
"use strict";var e=require("@lexical/html"),t=require("@lexical/link"),n=require("@lexical/mark"),r=require("@lexical/table"),o=require("lexical"),s=require("react"),i=require("react/jsx-runtime");const l=Object.freeze({"\t":"\\t","\n":"\\n"}),a=new RegExp(Object.keys(l).join("|"),"g"),c=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"├",isLastChild:"└",selectedChar:"^",selectedLine:">"}),u=[e=>e.hasFormat("bold")&&"Bold",e=>e.hasFormat("code")&&"Code",e=>e.hasFormat("italic")&&"Italic",e=>e.hasFormat("strikethrough")&&"Strikethrough",e=>e.hasFormat("subscript")&&"Subscript",e=>e.hasFormat("superscript")&&"Superscript",e=>e.hasFormat("underline")&&"Underline",e=>e.hasFormat("highlight")&&"Highlight"],f=[e=>e.hasTextFormat("bold")&&"Bold",e=>e.hasTextFormat("code")&&"Code",e=>e.hasTextFormat("italic")&&"Italic",e=>e.hasTextFormat("strikethrough")&&"Strikethrough",e=>e.hasTextFormat("subscript")&&"Subscript",e=>e.hasTextFormat("superscript")&&"Superscript",e=>e.hasTextFormat("underline")&&"Underline",e=>e.hasTextFormat("highlight")&&"Highlight"],d=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],h=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function g(e,t,n=[]){const r=e.getChildren(),s=r.length;r.forEach((e,r)=>{t(e,n.concat(r===s-1?c.isLastChild:c.hasNextSibling)),o.$isElementNode(e)&&g(e,t,n.concat(r===s-1?c.ancestorIsLastChild:c.ancestorHasNextSibling))})}function m(e,t=!1){const n=Object.entries(l).reduce((e,[t,n])=>e.replace(new RegExp(t,"g"),String(n)),e);return t?n.replace(/[^\s]/g,"*"):n}function p(e){let t=d.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="detail: "+t),t}function y(e){let t=h.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function x(e){let t=u.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function $(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function S(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function C(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function N(e){if(!e.__state)return!1;const t=[];for(const[n,r]of e.__state.knownState.entries()){if(n.isEqual(r,n.defaultValue))continue;const e=JSON.stringify(n.unparse(r));t.push(`[${n.key}: ${e}]`)}let n=t.join(",");return""!==n&&(n="state: "+n),n}function b(e,t){const n=new Array(1+t++).join(" "),r=new Array(t-1).join(" ");let o;for(let s=0;s<e.children.length;s++)o=document.createTextNode("\n"+n),e.insertBefore(o,e.children[s]),b(e.children[s],t),e.lastElementChild===e.children[s]&&(o=document.createTextNode("\n"+r),e.appendChild(o));return e}const T=s.forwardRef(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:r,viewClassName:o,timeTravelPanelClassName:l,editorState:a,setEditorState:c,setEditorReadOnly:u,generateContent:f,commandsLog:d=[]},h){const[g,m]=s.useState([]),[p,y]=s.useState(""),[x,$]=s.useState(!1),[S,C]=s.useState(!1),N=s.useRef(0),b=s.useRef(null),[T,j]=s.useState(!1),[k,L]=s.useState(!1),[v,E]=s.useState(!1),R=s.useRef(null),w=s.useRef([]),F=s.useRef(0),B=s.useCallback(e=>{const t=++F.current;f(e).then(e=>{t===F.current&&y(e)}).catch(e=>{t===F.current&&y(`Error rendering tree: ${e.message}\n\nStack:\n${e.stack}`)})},[f]);s.useEffect(()=>{if(!v&&a._nodeMap.size>1e3&&(L(!0),!v))return;if(R.current!==a||w.current!==d){const e=R.current!==a;R.current=a,w.current=d,B(S),!x&&e&&m(e=>[...e,[Date.now(),a]])}},[a,B,S,v,x,d]);const _=g.length;s.useEffect(()=>{if(T){let e;const t=()=>{const n=N.current;if(n===_-1)return void j(!1);const r=g[n][0],o=g[n+1][0];e=setTimeout(()=>{N.current++;const e=N.current,n=b.current;null!==n&&(n.value=String(e)),c(g[e][1]),t()},o-r)};return t(),()=>{clearTimeout(e)}}},[g,T,_,c]);return i.jsxs("div",{className:o,children:[!v&&k?i.jsxs("div",{style:{padding:20},children:[i.jsx("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),i.jsx("button",{onClick:()=>{E(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5},children:"Show full tree"})]}):null,v?null:i.jsx("button",{onClick:()=>(B(!S),void C(!S)),className:e,type:"button",children:S?"Tree":"Export DOM"}),!x&&(v||!k)&&_>2&&i.jsx("button",{onClick:()=>{u(!0),N.current=_-1,$(!0)},className:t,type:"button",children:"Time Travel"}),(v||!k)&&i.jsx("pre",{ref:h,children:p}),x&&(v||!k)&&i.jsxs("div",{className:l,children:[i.jsx("button",{className:r,onClick:()=>{N.current===_-1&&(N.current=1),j(!T)},type:"button",children:T?"Pause":"Play"}),i.jsx("input",{className:n,ref:b,onChange:e=>{const t=Number(e.target.value),n=g[t];n&&(N.current=t,c(n[1]))},type:"range",min:"1",max:_-1}),i.jsx("button",{className:r,onClick:()=>{u(!1);const e=g.length-1,t=g[e];c(t[1]);const n=b.current;null!==n&&(n.value=String(e)),$(!1),j(!1)},type:"button",children:"Exit"})]})]})});function j(e,t){const n=new Set;let r=0;for(const[s]of e._commands)n.add(e.registerCommand(s,e=>(t(t=>{r+=1;const n=[...t];return n.push({index:r,payload:e,type:s.type?s.type:"UNKNOWN"}),n.length>10&&n.shift(),n}),!1),o.COMMAND_PRIORITY_CRITICAL));return()=>n.forEach(e=>e())}exports.TreeView=T,exports.generateContent=function(s,i,l,u,d=!1){const h=s.getEditorState(),T=s._config,j=s._compositionKey,k=s._editable;if(l){let t="";return h.read(()=>{t=function(e){const t=document.createElement("div");return t.innerHTML=e.trim(),b(t,0).innerHTML}(e.$generateHtmlFromNodes(s))}),t}let L=" root\n";const v=h.read(()=>{const e=o.$getSelection();return g(o.$getRoot(),(r,s)=>{const i=`(${r.getKey()})`,l=r.getType()||"",h=r.isSelected();L+=`${h?c.selectedLine:" "} ${s.join(" ")} ${i} ${l} ${function(e,r,s=!1){const i=r?r(e,s):void 0;if(void 0!==i&&i.length>0)return i;if(o.$isTextNode(e)){const t=e.getTextContent(),n=0===t.length?"(empty)":`"${m(t,s)}"`,r=function(e){return[x(e),p(e),y(e),N(e)].filter(Boolean).join(", ")}(e);return[n,0!==r.length?`{ ${r} }`:null].filter(Boolean).join(" ").trim()}if(t.$isLinkNode(e)){const t=e.getURL(),n=0===t.length?"(empty)":`"${m(t,s)}"`,r=function(e){return[$(e),S(e),C(e),N(e)].filter(Boolean).join(", ")}(e);return[n,0!==r.length?`{ ${r} }`:null].filter(Boolean).join(" ").trim()}if(n.$isMarkNode(e))return`ids: [ ${e.getIDs().join(", ")} ]`;if(o.$isParagraphNode(e)){const t=function(e){let t=f.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();""!==t&&(t="format: "+t);return t}(e);let n=""!==t?`{ ${t} }`:"";return n+=e.__style?`(${e.__style})`:"",n}return""}(r,u,d)}\n`,L+=function({indent:e,isSelected:t,node:n,nodeKeyDisplay:r,selection:s,typeDisplay:i}){if(!o.$isTextNode(n)||!o.$isRangeSelection(s)||!t||o.$isElementNode(n))return"";const l=s.anchor,u=s.focus;if(""===n.getTextContent()||l.getNode()===s.focus.getNode()&&l.offset===u.offset)return"";const[f,d]=function(e,t){const n=t.getStartEndPoints();if(o.$isNodeSelection(t)||null===n)return[-1,-1];const[r,s]=n,i=e.getTextContent(),l=i.length;let c=-1,u=-1;if("text"===r.type&&"text"===s.type){const t=r.getNode(),n=s.getNode();t===n&&e===t&&r.offset!==s.offset?[c,u]=r.offset<s.offset?[r.offset,s.offset]:[s.offset,r.offset]:[c,u]=e===t?t.isBefore(n)?[r.offset,l]:[0,r.offset]:e===n?n.isBefore(t)?[s.offset,l]:[0,s.offset]:[0,l]}const f=(i.slice(0,c).match(a)||[]).length,d=(i.slice(c,u).match(a)||[]).length;return[c+f,u+f+d]}(n,s);if(f===d)return"";const h=e[e.length-1]===c.hasNextSibling?c.ancestorHasNextSibling:c.ancestorIsLastChild,g=[...e.slice(0,e.length-1),h],m=Array(f+1).fill(" "),p=Array(d-f).fill(c.selectedChar),y=i.length+2,x=Array(r.length+y).fill(" ");return[c.selectedLine,g.join(" "),[...x,...m,...p].join("")].join(" ")+"\n"}({indent:s,isSelected:h,node:r,nodeKeyDisplay:i,selection:e,typeDisplay:l})}),null===e?": null":o.$isRangeSelection(e)?function(e){let t="";const n=x(e);t+=`: range ${""!==n?`{ ${n} }`:""} ${""!==e.style?`{ style: ${e.style} } `:""}`;const r=e.anchor,o=e.focus,s=r.offset,i=o.offset;return t+=`\n ├ anchor { key: ${r.key}, offset: ${null===s?"null":s}, type: ${r.type} }`,t+=`\n └ focus { key: ${o.key}, offset: ${null===i?"null":i}, type: ${o.type} }`,t}(e):r.$isTableSelection(e)?function(e){return`: table\n └ { table: ${e.tableKey}, anchorCell: ${e.anchor.key}, focusCell: ${e.focus.key} }`}(e):function(e){if(!o.$isNodeSelection(e))return"";return`: node\n └ [${Array.from(e._nodes).join(", ")}]`}(e)});if(L+="\n selection"+v,L+="\n\n commands:",i.length)for(const{index:e,type:t,payload:n}of i)L+=`\n └ ${e}. { type: ${t}, payload: ${n instanceof Event?n.constructor.name:n} }`;else L+="\n └ None dispatched.";const{version:E}=s.constructor;return L+=`\n\n editor${E?` (v${E})`:""}:`,L+=`\n └ namespace ${T.namespace}`,null!==j&&(L+=`\n └ compositionKey ${j}`),L+=`\n └ editable ${String(k)}`,L},exports.registerLexicalCommandLogger=j,exports.useLexicalCommandsLog=function(e){const[t,n]=s.useState([]);return s.useEffect(()=>j(e,n),[e]),s.useMemo(()=>t,[t])};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$generateHtmlFromNodes as e}from"@lexical/html";import{$isLinkNode as t}from"@lexical/link";import{$isMarkNode as n}from"@lexical/mark";import{$isTableSelection as r}from"@lexical/table";import{$getSelection as o,$getRoot as i,$isRangeSelection as l,$isNodeSelection as s,$isElementNode as a,$isTextNode as c,$isParagraphNode as u,COMMAND_PRIORITY_CRITICAL as f}from"lexical";import{forwardRef as d,useState as h,useRef as m,useCallback as g,useEffect as p,useMemo as y}from"react";import{jsxs as $,jsx as b}from"react/jsx-runtime";const x=Object.freeze({"\t":"\\t","\n":"\\n"}),C=new RegExp(Object.keys(x).join("|"),"g"),S=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"├",isLastChild:"└",selectedChar:"^",selectedLine:">"}),N=[e=>e.hasFormat("bold")&&"Bold",e=>e.hasFormat("code")&&"Code",e=>e.hasFormat("italic")&&"Italic",e=>e.hasFormat("strikethrough")&&"Strikethrough",e=>e.hasFormat("subscript")&&"Subscript",e=>e.hasFormat("superscript")&&"Superscript",e=>e.hasFormat("underline")&&"Underline",e=>e.hasFormat("highlight")&&"Highlight"],T=[e=>e.hasTextFormat("bold")&&"Bold",e=>e.hasTextFormat("code")&&"Code",e=>e.hasTextFormat("italic")&&"Italic",e=>e.hasTextFormat("strikethrough")&&"Strikethrough",e=>e.hasTextFormat("subscript")&&"Subscript",e=>e.hasTextFormat("superscript")&&"Superscript",e=>e.hasTextFormat("underline")&&"Underline",e=>e.hasTextFormat("highlight")&&"Highlight"],k=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],j=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function v(f,d,h,m,g=!1){const p=f.getEditorState(),y=f._config,$=f._compositionKey,b=f._editable;if(h){let t="";return p.read((
|
|
9
|
+
import{$generateHtmlFromNodes as e}from"@lexical/html";import{$isLinkNode as t}from"@lexical/link";import{$isMarkNode as n}from"@lexical/mark";import{$isTableSelection as r}from"@lexical/table";import{$getSelection as o,$getRoot as i,$isRangeSelection as l,$isNodeSelection as s,$isElementNode as a,$isTextNode as c,$isParagraphNode as u,COMMAND_PRIORITY_CRITICAL as f}from"lexical";import{forwardRef as d,useState as h,useRef as m,useCallback as g,useEffect as p,useMemo as y}from"react";import{jsxs as $,jsx as b}from"react/jsx-runtime";const x=Object.freeze({"\t":"\\t","\n":"\\n"}),C=new RegExp(Object.keys(x).join("|"),"g"),S=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"├",isLastChild:"└",selectedChar:"^",selectedLine:">"}),N=[e=>e.hasFormat("bold")&&"Bold",e=>e.hasFormat("code")&&"Code",e=>e.hasFormat("italic")&&"Italic",e=>e.hasFormat("strikethrough")&&"Strikethrough",e=>e.hasFormat("subscript")&&"Subscript",e=>e.hasFormat("superscript")&&"Superscript",e=>e.hasFormat("underline")&&"Underline",e=>e.hasFormat("highlight")&&"Highlight"],T=[e=>e.hasTextFormat("bold")&&"Bold",e=>e.hasTextFormat("code")&&"Code",e=>e.hasTextFormat("italic")&&"Italic",e=>e.hasTextFormat("strikethrough")&&"Strikethrough",e=>e.hasTextFormat("subscript")&&"Subscript",e=>e.hasTextFormat("superscript")&&"Superscript",e=>e.hasTextFormat("underline")&&"Underline",e=>e.hasTextFormat("highlight")&&"Highlight"],k=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],j=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function v(f,d,h,m,g=!1){const p=f.getEditorState(),y=f._config,$=f._compositionKey,b=f._editable;if(h){let t="";return p.read(()=>{t=function(e){const t=document.createElement("div");return t.innerHTML=e.trim(),K(t,0).innerHTML}(e(f))}),t}let x=" root\n";const N=p.read(()=>{const e=o();return L(i(),(r,o)=>{const i=`(${r.getKey()})`,f=r.getType()||"",d=r.isSelected();x+=`${d?S.selectedLine:" "} ${o.join(" ")} ${i} ${f} ${function(e,r,o=!1){const i=r?r(e,o):void 0;if(void 0!==i&&i.length>0)return i;if(c(e)){const t=e.getTextContent(),n=0===t.length?"(empty)":`"${B(t,o)}"`,r=function(e){return[w(e),E(e),F(e),H(e)].filter(Boolean).join(", ")}(e);return[n,0!==r.length?`{ ${r} }`:null].filter(Boolean).join(" ").trim()}if(t(e)){const t=e.getURL(),n=0===t.length?"(empty)":`"${B(t,o)}"`,r=function(e){return[_(e),D(e),O(e),H(e)].filter(Boolean).join(", ")}(e);return[n,0!==r.length?`{ ${r} }`:null].filter(Boolean).join(" ").trim()}if(n(e))return`ids: [ ${e.getIDs().join(", ")} ]`;if(u(e)){const t=function(e){let t=T.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();""!==t&&(t="format: "+t);return t}(e);let n=""!==t?`{ ${t} }`:"";return n+=e.__style?`(${e.__style})`:"",n}return""}(r,m,g)}\n`,x+=function({indent:e,isSelected:t,node:n,nodeKeyDisplay:r,selection:o,typeDisplay:i}){if(!c(n)||!l(o)||!t||a(n))return"";const u=o.anchor,f=o.focus;if(""===n.getTextContent()||u.getNode()===o.focus.getNode()&&u.offset===f.offset)return"";const[d,h]=function(e,t){const n=t.getStartEndPoints();if(s(t)||null===n)return[-1,-1];const[r,o]=n,i=e.getTextContent(),l=i.length;let a=-1,c=-1;if("text"===r.type&&"text"===o.type){const t=r.getNode(),n=o.getNode();t===n&&e===t&&r.offset!==o.offset?[a,c]=r.offset<o.offset?[r.offset,o.offset]:[o.offset,r.offset]:[a,c]=e===t?t.isBefore(n)?[r.offset,l]:[0,r.offset]:e===n?n.isBefore(t)?[o.offset,l]:[0,o.offset]:[0,l]}const u=(i.slice(0,a).match(C)||[]).length,f=(i.slice(a,c).match(C)||[]).length;return[a+u,c+u+f]}(n,o);if(d===h)return"";const m=e[e.length-1]===S.hasNextSibling?S.ancestorHasNextSibling:S.ancestorIsLastChild,g=[...e.slice(0,e.length-1),m],p=Array(d+1).fill(" "),y=Array(h-d).fill(S.selectedChar),$=i.length+2,b=Array(r.length+$).fill(" ");return[S.selectedLine,g.join(" "),[...b,...p,...y].join("")].join(" ")+"\n"}({indent:o,isSelected:d,node:r,nodeKeyDisplay:i,selection:e,typeDisplay:f})}),null===e?": null":l(e)?function(e){let t="";const n=w(e);t+=`: range ${""!==n?`{ ${n} }`:""} ${""!==e.style?`{ style: ${e.style} } `:""}`;const r=e.anchor,o=e.focus,i=r.offset,l=o.offset;return t+=`\n ├ anchor { key: ${r.key}, offset: ${null===i?"null":i}, type: ${r.type} }`,t+=`\n └ focus { key: ${o.key}, offset: ${null===l?"null":l}, type: ${o.type} }`,t}(e):r(e)?function(e){return`: table\n └ { table: ${e.tableKey}, anchorCell: ${e.anchor.key}, focusCell: ${e.focus.key} }`}(e):function(e){if(!s(e))return"";return`: node\n └ [${Array.from(e._nodes).join(", ")}]`}(e)});if(x+="\n selection"+N,x+="\n\n commands:",d.length)for(const{index:e,type:t,payload:n}of d)x+=`\n └ ${e}. { type: ${t}, payload: ${n instanceof Event?n.constructor.name:n} }`;else x+="\n └ None dispatched.";const{version:k}=f.constructor;return x+=`\n\n editor${k?` (v${k})`:""}:`,x+=`\n └ namespace ${y.namespace}`,null!==$&&(x+=`\n └ compositionKey ${$}`),x+=`\n └ editable ${String(b)}`,x}function L(e,t,n=[]){const r=e.getChildren(),o=r.length;r.forEach((e,r)=>{t(e,n.concat(r===o-1?S.isLastChild:S.hasNextSibling)),a(e)&&L(e,t,n.concat(r===o-1?S.ancestorIsLastChild:S.ancestorHasNextSibling))})}function B(e,t=!1){const n=Object.entries(x).reduce((e,[t,n])=>e.replace(new RegExp(t,"g"),String(n)),e);return t?n.replace(/[^\s]/g,"*"):n}function E(e){let t=k.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="detail: "+t),t}function F(e){let t=j.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function w(e){let t=N.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function _(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function D(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function O(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function H(e){if(!e.__state)return!1;const t=[];for(const[n,r]of e.__state.knownState.entries()){if(n.isEqual(r,n.defaultValue))continue;const e=JSON.stringify(n.unparse(r));t.push(`[${n.key}: ${e}]`)}let n=t.join(",");return""!==n&&(n="state: "+n),n}function K(e,t){const n=new Array(1+t++).join(" "),r=new Array(t-1).join(" ");let o;for(let i=0;i<e.children.length;i++)o=document.createTextNode("\n"+n),e.insertBefore(o,e.children[i]),K(e.children[i],t),e.lastElementChild===e.children[i]&&(o=document.createTextNode("\n"+r),e.appendChild(o));return e}const A=d(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:r,viewClassName:o,timeTravelPanelClassName:i,editorState:l,setEditorState:s,setEditorReadOnly:a,generateContent:c,commandsLog:u=[]},f){const[d,y]=h([]),[x,C]=h(""),[S,N]=h(!1),[T,k]=h(!1),j=m(0),v=m(null),[L,B]=h(!1),[E,F]=h(!1),[w,_]=h(!1),D=m(null),O=m([]),H=m(0),K=g(e=>{const t=++H.current;c(e).then(e=>{t===H.current&&C(e)}).catch(e=>{t===H.current&&C(`Error rendering tree: ${e.message}\n\nStack:\n${e.stack}`)})},[c]);p(()=>{if(!w&&l._nodeMap.size>1e3&&(F(!0),!w))return;if(D.current!==l||O.current!==u){const e=D.current!==l;D.current=l,O.current=u,K(T),!S&&e&&y(e=>[...e,[Date.now(),l]])}},[l,K,T,w,S,u]);const A=d.length;p(()=>{if(L){let e;const t=()=>{const n=j.current;if(n===A-1)return void B(!1);const r=d[n][0],o=d[n+1][0];e=setTimeout(()=>{j.current++;const e=j.current,n=v.current;null!==n&&(n.value=String(e)),s(d[e][1]),t()},o-r)};return t(),()=>{clearTimeout(e)}}},[d,L,A,s]);return $("div",{className:o,children:[!w&&E?$("div",{style:{padding:20},children:[b("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),b("button",{onClick:()=>{_(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5},children:"Show full tree"})]}):null,w?null:b("button",{onClick:()=>(K(!T),void k(!T)),className:e,type:"button",children:T?"Tree":"Export DOM"}),!S&&(w||!E)&&A>2&&b("button",{onClick:()=>{a(!0),j.current=A-1,N(!0)},className:t,type:"button",children:"Time Travel"}),(w||!E)&&b("pre",{ref:f,children:x}),S&&(w||!E)&&$("div",{className:i,children:[b("button",{className:r,onClick:()=>{j.current===A-1&&(j.current=1),B(!L)},type:"button",children:L?"Pause":"Play"}),b("input",{className:n,ref:v,onChange:e=>{const t=Number(e.target.value),n=d[t];n&&(j.current=t,s(n[1]))},type:"range",min:"1",max:A-1}),b("button",{className:r,onClick:()=>{a(!1);const e=d.length-1,t=d[e];s(t[1]);const n=v.current;null!==n&&(n.value=String(e)),N(!1),B(!1)},type:"button",children:"Exit"})]})]})});function I(e,t){const n=new Set;let r=0;for(const[o]of e._commands)n.add(e.registerCommand(o,e=>(t(t=>{r+=1;const n=[...t];return n.push({index:r,payload:e,type:o.type?o.type:"UNKNOWN"}),n.length>10&&n.shift(),n}),!1),f));return()=>n.forEach(e=>e())}function P(e){const[t,n]=h([]);return p(()=>I(e,n),[e]),y(()=>t,[t])}export{A as TreeView,v as generateContent,I as registerLexicalCommandLogger,P as useLexicalCommandsLog};
|
package/package.json
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"utils"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.36.2
|
|
11
|
+
"version": "0.36.2",
|
|
12
12
|
"main": "LexicalDevtoolsCore.js",
|
|
13
13
|
"types": "index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/html": "0.36.2
|
|
16
|
-
"@lexical/link": "0.36.2
|
|
17
|
-
"@lexical/mark": "0.36.2
|
|
18
|
-
"@lexical/table": "0.36.2
|
|
19
|
-
"@lexical/utils": "0.36.2
|
|
20
|
-
"lexical": "0.36.2
|
|
15
|
+
"@lexical/html": "0.36.2",
|
|
16
|
+
"@lexical/link": "0.36.2",
|
|
17
|
+
"@lexical/mark": "0.36.2",
|
|
18
|
+
"@lexical/table": "0.36.2",
|
|
19
|
+
"@lexical/utils": "0.36.2",
|
|
20
|
+
"lexical": "0.36.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=17.x",
|