@lexical/devtools-core 0.46.1-nightly.20260706.0 → 0.46.1-nightly.20260707.0
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.
|
@@ -347,6 +347,7 @@ function $printSelectedCharsLine({
|
|
|
347
347
|
return [SYMBOLS.selectedLine, indentionChars.join(' '), [...nodePrintSpaces, ...unselectedChars, ...selectedChars].join('')].join(' ') + '\n';
|
|
348
348
|
}
|
|
349
349
|
function printPrettyHTML(str) {
|
|
350
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
350
351
|
const div = document.createElement('div');
|
|
351
352
|
div.innerHTML = str.trim();
|
|
352
353
|
return prettifyHTML(div, 0).innerHTML;
|
|
@@ -356,10 +357,12 @@ function prettifyHTML(node, level) {
|
|
|
356
357
|
const indentAfter = new Array(level - 1).join(' ');
|
|
357
358
|
let textNode;
|
|
358
359
|
for (let i = 0; i < node.children.length; i++) {
|
|
360
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
359
361
|
textNode = document.createTextNode('\n' + indentBefore);
|
|
360
362
|
node.insertBefore(textNode, node.children[i]);
|
|
361
363
|
prettifyHTML(node.children[i], level);
|
|
362
364
|
if (node.lastElementChild === node.children[i]) {
|
|
365
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
363
366
|
textNode = document.createTextNode('\n' + indentAfter);
|
|
364
367
|
node.appendChild(textNode);
|
|
365
368
|
}
|
|
@@ -345,6 +345,7 @@ function $printSelectedCharsLine({
|
|
|
345
345
|
return [SYMBOLS.selectedLine, indentionChars.join(' '), [...nodePrintSpaces, ...unselectedChars, ...selectedChars].join('')].join(' ') + '\n';
|
|
346
346
|
}
|
|
347
347
|
function printPrettyHTML(str) {
|
|
348
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
348
349
|
const div = document.createElement('div');
|
|
349
350
|
div.innerHTML = str.trim();
|
|
350
351
|
return prettifyHTML(div, 0).innerHTML;
|
|
@@ -354,10 +355,12 @@ function prettifyHTML(node, level) {
|
|
|
354
355
|
const indentAfter = new Array(level - 1).join(' ');
|
|
355
356
|
let textNode;
|
|
356
357
|
for (let i = 0; i < node.children.length; i++) {
|
|
358
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
357
359
|
textNode = document.createTextNode('\n' + indentBefore);
|
|
358
360
|
node.insertBefore(textNode, node.children[i]);
|
|
359
361
|
prettifyHTML(node.children[i], level);
|
|
360
362
|
if (node.lastElementChild === node.children[i]) {
|
|
363
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
361
364
|
textNode = document.createTextNode('\n' + indentAfter);
|
|
362
365
|
node.appendChild(textNode);
|
|
363
366
|
}
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/html"),t=require("@lexical/link"),n=require("@lexical/mark"),o=require("@lexical/table"),r=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:"\u251c",isLastChild:"\u2514",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 o=[];for(const t of r.$getSlotNames(e)){const n=r.$getSlot(e,t);null!==n&&o.push([t,n])}const s=r.$isElementNode(e)?e.getChildren():[],i=o.length+s.length;let l=0;for(const[e,s]of o){const o=l===i-1;t(s,n.concat(o?c.isLastChild:c.hasNextSibling),e),(r.$isElementNode(s)||r.$isDecoratorNode(s))&&g(s,t,n.concat(o?c.ancestorIsLastChild:c.ancestorHasNextSibling)),l++}for(const e of s){const o=l===i-1;t(e,n.concat(o?c.isLastChild:c.hasNextSibling)),(r.$isElementNode(e)||r.$isDecoratorNode(e))&&g(e,t,n.concat(o?c.ancestorIsLastChild:c.ancestorHasNextSibling)),l++}}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 $(e){let t=h.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function y(e){let t=u.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function x(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function N(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function S(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function C(e){if(!e.__state)return!1;const t=[];for(const[n,o]of e.__state.knownState.entries()){if(n.isEqual(o,n.defaultValue))continue;const e=JSON.stringify(n.unparse(o));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(" "),o=new Array(t-1).join(" ");let r;for(let s=0;s<e.children.length;s++)r=document.createTextNode("\n"+n),e.insertBefore(r,e.children[s]),b(e.children[s],t),e.lastElementChild===e.children[s]&&(r=document.createTextNode("\n"+o),e.appendChild(r));return e}const T=/*#__PURE__*/s.forwardRef(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:o,viewClassName:r,timeTravelPanelClassName:l,editorState:a,setEditorState:c,setEditorReadOnly:u,generateContent:f,commandsLog:d=[]},h){const[g,m]=s.useState([]),[p,$]=s.useState(""),[y,x]=s.useState(!1),[N,S]=s.useState(!1),C=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&&$(e)}).catch(e=>{t===F.current&&$(`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(N),!y&&e&&m(e=>[...e,[Date.now(),a]])}},[a,B,N,v,y,d]);const _=g.length;s.useEffect(()=>{if(T){let e;const t=()=>{const n=C.current;if(n===_-1)return void j(!1);const o=g[n][0],r=g[n+1][0];e=setTimeout(()=>{C.current++;const e=C.current,n=b.current;null!==n&&(n.value=String(e)),c(g[e][1]),t()},r-o)};return t(),()=>{clearTimeout(e)}}},[g,T,_,c])
|
|
9
|
+
"use strict";var e=require("@lexical/html"),t=require("@lexical/link"),n=require("@lexical/mark"),o=require("@lexical/table"),r=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:"\u251c",isLastChild:"\u2514",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 o=[];for(const t of r.$getSlotNames(e)){const n=r.$getSlot(e,t);null!==n&&o.push([t,n])}const s=r.$isElementNode(e)?e.getChildren():[],i=o.length+s.length;let l=0;for(const[e,s]of o){const o=l===i-1;t(s,n.concat(o?c.isLastChild:c.hasNextSibling),e),(r.$isElementNode(s)||r.$isDecoratorNode(s))&&g(s,t,n.concat(o?c.ancestorIsLastChild:c.ancestorHasNextSibling)),l++}for(const e of s){const o=l===i-1;t(e,n.concat(o?c.isLastChild:c.hasNextSibling)),(r.$isElementNode(e)||r.$isDecoratorNode(e))&&g(e,t,n.concat(o?c.ancestorIsLastChild:c.ancestorHasNextSibling)),l++}}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 $(e){let t=h.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function y(e){let t=u.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function x(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function N(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function S(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function C(e){if(!e.__state)return!1;const t=[];for(const[n,o]of e.__state.knownState.entries()){if(n.isEqual(o,n.defaultValue))continue;const e=JSON.stringify(n.unparse(o));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(" "),o=new Array(t-1).join(" ");let r;for(let s=0;s<e.children.length;s++)r=document.createTextNode("\n"+n),e.insertBefore(r,e.children[s]),b(e.children[s],t),e.lastElementChild===e.children[s]&&(r=document.createTextNode("\n"+o),e.appendChild(r));return e}const T=/*#__PURE__*/s.forwardRef(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:o,viewClassName:r,timeTravelPanelClassName:l,editorState:a,setEditorState:c,setEditorReadOnly:u,generateContent:f,commandsLog:d=[]},h){const[g,m]=s.useState([]),[p,$]=s.useState(""),[y,x]=s.useState(!1),[N,S]=s.useState(!1),C=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&&$(e)}).catch(e=>{t===F.current&&$(`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(N),!y&&e&&m(e=>[...e,[Date.now(),a]])}},[a,B,N,v,y,d]);const _=g.length;s.useEffect(()=>{if(T){let e;const t=()=>{const n=C.current;if(n===_-1)return void j(!1);const o=g[n][0],r=g[n+1][0];e=setTimeout(()=>{C.current++;const e=C.current,n=b.current;null!==n&&(n.value=String(e)),c(g[e][1]),t()},r-o)};return t(),()=>{clearTimeout(e)}}},[g,T,_,c]);
|
|
10
10
|
return i.jsxs("div",{className:r,children:[!v&&k?/*#__PURE__*/i.jsxs("div",{style:{padding:20},children:[/*#__PURE__*/i.jsx("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),/*#__PURE__*/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:/*#__PURE__*/i.jsx("button",{onClick:()=>(B(!N),void S(!N)),className:e,type:"button",children:N?"Tree":"Export DOM"}),!y&&(v||!k)&&_>2&&/*#__PURE__*/i.jsx("button",{onClick:()=>{u(!0),C.current=_-1,x(!0)},className:t,type:"button",children:"Time Travel"}),(v||!k)&&/*#__PURE__*/i.jsx("pre",{ref:h,children:p}),y&&(v||!k)&&/*#__PURE__*/i.jsxs("div",{className:l,children:[/*#__PURE__*/i.jsx("button",{className:o,onClick:()=>{C.current===_-1&&(C.current=1),j(!T)},type:"button",children:T?"Pause":"Play"}),/*#__PURE__*/i.jsx("input",{className:n,ref:b,onChange:e=>{const t=Number(e.target.value),n=g[t];n&&(C.current=t,c(n[1]))},type:"range",min:"1",max:_-1}),/*#__PURE__*/i.jsx("button",{className:o,onClick:()=>{u(!1);const e=g.length-1,t=g[e];c(t[1]);const n=b.current;null!==n&&(n.value=String(e)),x(!1),j(!1)},type:"button",children:"Exit"})]})]})});function j(e,t){const n=[];let o=0;for(const s of e._commands.keys())n.push(e.registerCommand(s,e=>{o+=1;const n={index:o,payload:e,type:s.type?s.type:"UNKNOWN"};return t(e=>[...e.slice(-9),n]),!1},r.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))},{editor:s}),t}let L=" root\n";const v=h.read(()=>{const e=r.$getSelection();return g(r.$getRoot(),(o,s,i)=>{const l=`(${o.getKey()})`,h=o.getType()||"",g=o.isSelected(),b=void 0!==i?`[slot: ${i}] `:"",T=function(e,t){if(void 0===t)return"";if(r.$isElementNode(e)&&e.isShadowRoot())return" [shadow-root]";if(r.$isDecoratorNode(e)&&!e.isInline())return" [atomic decorator]";return""}(o,i);L+=`${g?c.selectedLine:" "} ${s.join(" ")} ${l} ${b}${h}${T} ${function(e,o,s=!1){const i=o?o(e,s):void 0;if(void 0!==i&&i.length>0)return i;if(r.$isTextNode(e)){const t=e.getTextContent(),n=0===t.length?"(empty)":`"${m(t,s)}"`,o=function(e){return[y(e),p(e),$(e),C(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(t.$isLinkNode(e)){const t=e.getURL(),n=0===t.length?"(empty)":`"${m(t,s)}"`,o=function(e){return[x(e),N(e),S(e),C(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(n.$isMarkNode(e))return`ids: [ ${e.getIDs().join(", ")} ]`;if(r.$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""}(o,u,d)}\n`,L+=function({indent:e,isSelected:t,node:n,nodeKeyDisplay:o,selection:s,typeDisplay:i}){if(!r.$isTextNode(n)||!r.$isRangeSelection(s)||!t||r.$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(r.$isNodeSelection(t)||null===n)return[-1,-1];const[o,s]=n,i=e.getTextContent(),l=i.length;let c=-1,u=-1;if("text"===o.type&&"text"===s.type){const t=o.getNode(),n=s.getNode();t===n&&e===t&&o.offset!==s.offset?[c,u]=o.offset<s.offset?[o.offset,s.offset]:[s.offset,o.offset]:[c,u]=e===t?t.isBefore(n)?[o.offset,l]:[0,o.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),$=i.length+2,y=Array(o.length+$).fill(" ");return[c.selectedLine,g.join(" "),[...y,...m,...p].join("")].join(" ")+"\n"}({indent:s,isSelected:g,node:o,nodeKeyDisplay:l,selection:e,typeDisplay:h})}),null===e?": null":r.$isRangeSelection(e)?function(e){let t="";const n=y(e),o=function(e){let t=e;for(;null!==t;){const e=r.$getSlotNameWithinHost(t);if(null!==e){const n=r.$getSlotHost(t);if(null!==n)return{host:n,name:e}}t=t.getParent()??r.$getSlotHost(t)}return null}(e.anchor.getNode()),s=null!==o?` (in slot "${o.name}" of ${o.host.getType()} { key: ${o.host.getKey()} })`:"";t+=`: range${s} ${""!==n?`{ ${n} }`:""} ${""!==e.style?`{ style: ${e.style} } `:""}`;const i=e.anchor,l=e.focus,a=i.offset,c=l.offset;return t+=`\n \u251c anchor { key: ${i.key}, offset: ${null===a?"null":a}, type: ${i.type} }`,t+=`\n \u2514 focus { key: ${l.key}, offset: ${null===c?"null":c}, type: ${l.type} }`,t}(e):o.$isTableSelection(e)?function(e){return`: table\n \u2514 { table: ${e.tableKey}, anchorCell: ${e.anchor.key}, focusCell: ${e.focus.key} }`}(e):function(e){if(!r.$isNodeSelection(e))return"";return`: node\n \u2514 [${Array.from(e._nodes).join(", ")}]`}(e)},{editor:s});if(L+="\n selection"+v,L+="\n\n commands:",i.length)for(const{index:e,type:t,payload:n}of i)L+=`\n \u2514 ${e}. { type: ${t}, payload: ${n instanceof Event?n.constructor.name:n} }`;else L+="\n \u2514 None dispatched.";const{version:E}=s.constructor;return L+=`\n\n editor${E?` (v${E})`:""}:`,L+=`\n \u2514 namespace ${T.namespace}`,null!==j&&(L+=`\n \u2514 compositionKey ${j}`),L+=`\n \u2514 editable ${String(k)}`,L},exports.registerLexicalCommandLogger=j,exports.useLexicalCommandsLog=function(e){const[t,n]=s.useState([]);return s.useEffect(()=>j(e,n),[e]),t};
|
|
@@ -6,5 +6,5 @@
|
|
|
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 o}from"@lexical/table";import{$getSelection as r,$getRoot as i,$isRangeSelection as l,$getSlotNameWithinHost as s,$getSlotHost as c,$isNodeSelection as a,$getSlotNames as u,$getSlot as f,$isElementNode as d,$isDecoratorNode as h,$isTextNode as m,$isParagraphNode as g,COMMAND_PRIORITY_CRITICAL as p}from"lexical";import{forwardRef as y,useState as $,useRef as b,useCallback as x,useEffect as C}from"react";import{jsxs as N,jsx as S}from"react/jsx-runtime";const T=Object.freeze({"\t":"\\t","\n":"\\n"}),k=new RegExp(Object.keys(T).join("|"),"g"),j=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"}),v=[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"],L=[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"],w=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],B=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function F(u,f,p,y,$=!1){const b=u.getEditorState(),x=u._config,C=u._compositionKey,N=u._editable;if(p){let t="";return b.read(()=>{t=function(e){const t=document.createElement("div");return t.innerHTML=e.trim(),A(t,0).innerHTML}(e(u))},{editor:u}),t}let S=" root\n";const T=b.read(()=>{const e=r();return E(i(),(o,r,i)=>{const s=`(${o.getKey()})`,c=o.getType()||"",u=o.isSelected(),f=void 0!==i?`[slot: ${i}] `:"",p=function(e,t){if(void 0===t)return"";if(d(e)&&e.isShadowRoot())return" [shadow-root]";if(h(e)&&!e.isInline())return" [atomic decorator]";return""}(o,i);S+=`${u?j.selectedLine:" "} ${r.join(" ")} ${s} ${f}${c}${p} ${function(e,o,r=!1){const i=o?o(e,r):void 0;if(void 0!==i&&i.length>0)return i;if(m(e)){const t=e.getTextContent(),n=0===t.length?"(empty)":`"${_(t,r)}"`,o=function(e){return[I(e),D(e),H(e),R(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(t(e)){const t=e.getURL(),n=0===t.length?"(empty)":`"${_(t,r)}"`,o=function(e){return[K(e),O(e),P(e),R(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(n(e))return`ids: [ ${e.getIDs().join(", ")} ]`;if(g(e)){const t=function(e){let t=L.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""}(o,y,$)}\n`,S+=function({indent:e,isSelected:t,node:n,nodeKeyDisplay:o,selection:r,typeDisplay:i}){if(!m(n)||!l(r)||!t||d(n))return"";const s=r.anchor,c=r.focus;if(""===n.getTextContent()||s.getNode()===r.focus.getNode()&&s.offset===c.offset)return"";const[u,f]=function(e,t){const n=t.getStartEndPoints();if(a(t)||null===n)return[-1,-1];const[o,r]=n,i=e.getTextContent(),l=i.length;let s=-1,c=-1;if("text"===o.type&&"text"===r.type){const t=o.getNode(),n=r.getNode();t===n&&e===t&&o.offset!==r.offset?[s,c]=o.offset<r.offset?[o.offset,r.offset]:[r.offset,o.offset]:[s,c]=e===t?t.isBefore(n)?[o.offset,l]:[0,o.offset]:e===n?n.isBefore(t)?[r.offset,l]:[0,r.offset]:[0,l]}const u=(i.slice(0,s).match(k)||[]).length,f=(i.slice(s,c).match(k)||[]).length;return[s+u,c+u+f]}(n,r);if(u===f)return"";const h=e[e.length-1]===j.hasNextSibling?j.ancestorHasNextSibling:j.ancestorIsLastChild,g=[...e.slice(0,e.length-1),h],p=Array(u+1).fill(" "),y=Array(f-u).fill(j.selectedChar),$=i.length+2,b=Array(o.length+$).fill(" ");return[j.selectedLine,g.join(" "),[...b,...p,...y].join("")].join(" ")+"\n"}({indent:r,isSelected:u,node:o,nodeKeyDisplay:s,selection:e,typeDisplay:c})}),null===e?": null":l(e)?function(e){let t="";const n=I(e),o=function(e){let t=e;for(;null!==t;){const e=s(t);if(null!==e){const n=c(t);if(null!==n)return{host:n,name:e}}t=t.getParent()??c(t)}return null}(e.anchor.getNode()),r=null!==o?` (in slot "${o.name}" of ${o.host.getType()} { key: ${o.host.getKey()} })`:"";t+=`: range${r} ${""!==n?`{ ${n} }`:""} ${""!==e.style?`{ style: ${e.style} } `:""}`;const i=e.anchor,l=e.focus,a=i.offset,u=l.offset;return t+=`\n \u251c anchor { key: ${i.key}, offset: ${null===a?"null":a}, type: ${i.type} }`,t+=`\n \u2514 focus { key: ${l.key}, offset: ${null===u?"null":u}, type: ${l.type} }`,t}(e):o(e)?function(e){return`: table\n \u2514 { table: ${e.tableKey}, anchorCell: ${e.anchor.key}, focusCell: ${e.focus.key} }`}(e):function(e){if(!a(e))return"";return`: node\n \u2514 [${Array.from(e._nodes).join(", ")}]`}(e)},{editor:u});if(S+="\n selection"+T,S+="\n\n commands:",f.length)for(const{index:e,type:t,payload:n}of f)S+=`\n \u2514 ${e}. { type: ${t}, payload: ${n instanceof Event?n.constructor.name:n} }`;else S+="\n \u2514 None dispatched.";const{version:v}=u.constructor;return S+=`\n\n editor${v?` (v${v})`:""}:`,S+=`\n \u2514 namespace ${x.namespace}`,null!==C&&(S+=`\n \u2514 compositionKey ${C}`),S+=`\n \u2514 editable ${String(N)}`,S}function E(e,t,n=[]){const o=[];for(const t of u(e)){const n=f(e,t);null!==n&&o.push([t,n])}const r=d(e)?e.getChildren():[],i=o.length+r.length;let l=0;for(const[e,r]of o){const o=l===i-1;t(r,n.concat(o?j.isLastChild:j.hasNextSibling),e),(d(r)||h(r))&&E(r,t,n.concat(o?j.ancestorIsLastChild:j.ancestorHasNextSibling)),l++}for(const e of r){const o=l===i-1;t(e,n.concat(o?j.isLastChild:j.hasNextSibling)),(d(e)||h(e))&&E(e,t,n.concat(o?j.ancestorIsLastChild:j.ancestorHasNextSibling)),l++}}function _(e,t=!1){const n=Object.entries(T).reduce((e,[t,n])=>e.replace(new RegExp(t,"g"),String(n)),e);return t?n.replace(/[^\s]/g,"*"):n}function D(e){let t=w.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="detail: "+t),t}function H(e){let t=B.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function I(e){let t=v.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function K(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function O(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function P(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function R(e){if(!e.__state)return!1;const t=[];for(const[n,o]of e.__state.knownState.entries()){if(n.isEqual(o,n.defaultValue))continue;const e=JSON.stringify(n.unparse(o));t.push(`[${n.key}: ${e}]`)}let n=t.join(",");return""!==n&&(n="state: "+n),n}function A(e,t){const n=new Array(1+t++).join(" "),o=new Array(t-1).join(" ");let r;for(let i=0;i<e.children.length;i++)r=document.createTextNode("\n"+n),e.insertBefore(r,e.children[i]),A(e.children[i],t),e.lastElementChild===e.children[i]&&(r=document.createTextNode("\n"+o),e.appendChild(r));return e}const U=/*#__PURE__*/y(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:o,viewClassName:r,timeTravelPanelClassName:i,editorState:l,setEditorState:s,setEditorReadOnly:c,generateContent:a,commandsLog:u=[]},f){const[d,h]=$([]),[m,g]=$(""),[p,y]=$(!1),[T,k]=$(!1),j=b(0),v=b(null),[L,w]=$(!1),[B,F]=$(!1),[E,_]=$(!1),D=b(null),H=b([]),I=b(0),K=x(e=>{const t=++I.current;a(e).then(e=>{t===I.current&&g(e)}).catch(e=>{t===I.current&&g(`Error rendering tree: ${e.message}\n\nStack:\n${e.stack}`)})},[a]);C(()=>{if(!E&&l._nodeMap.size>1e3&&(F(!0),!E))return;if(D.current!==l||H.current!==u){const e=D.current!==l;D.current=l,H.current=u,K(T),!p&&e&&h(e=>[...e,[Date.now(),l]])}},[l,K,T,E,p,u]);const O=d.length;C(()=>{if(L){let e;const t=()=>{const n=j.current;if(n===O-1)return void w(!1);const o=d[n][0],r=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()},r-o)};return t(),()=>{clearTimeout(e)}}},[d,L,O,s])
|
|
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 o}from"@lexical/table";import{$getSelection as r,$getRoot as i,$isRangeSelection as l,$getSlotNameWithinHost as s,$getSlotHost as c,$isNodeSelection as a,$getSlotNames as u,$getSlot as f,$isElementNode as d,$isDecoratorNode as h,$isTextNode as m,$isParagraphNode as g,COMMAND_PRIORITY_CRITICAL as p}from"lexical";import{forwardRef as y,useState as $,useRef as b,useCallback as x,useEffect as C}from"react";import{jsxs as N,jsx as S}from"react/jsx-runtime";const T=Object.freeze({"\t":"\\t","\n":"\\n"}),k=new RegExp(Object.keys(T).join("|"),"g"),j=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"}),v=[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"],L=[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"],w=[e=>e.isDirectionless()&&"Directionless",e=>e.isUnmergeable()&&"Unmergeable"],B=[e=>e.isToken()&&"Token",e=>e.isSegmented()&&"Segmented"];function F(u,f,p,y,$=!1){const b=u.getEditorState(),x=u._config,C=u._compositionKey,N=u._editable;if(p){let t="";return b.read(()=>{t=function(e){const t=document.createElement("div");return t.innerHTML=e.trim(),A(t,0).innerHTML}(e(u))},{editor:u}),t}let S=" root\n";const T=b.read(()=>{const e=r();return E(i(),(o,r,i)=>{const s=`(${o.getKey()})`,c=o.getType()||"",u=o.isSelected(),f=void 0!==i?`[slot: ${i}] `:"",p=function(e,t){if(void 0===t)return"";if(d(e)&&e.isShadowRoot())return" [shadow-root]";if(h(e)&&!e.isInline())return" [atomic decorator]";return""}(o,i);S+=`${u?j.selectedLine:" "} ${r.join(" ")} ${s} ${f}${c}${p} ${function(e,o,r=!1){const i=o?o(e,r):void 0;if(void 0!==i&&i.length>0)return i;if(m(e)){const t=e.getTextContent(),n=0===t.length?"(empty)":`"${_(t,r)}"`,o=function(e){return[I(e),D(e),H(e),R(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(t(e)){const t=e.getURL(),n=0===t.length?"(empty)":`"${_(t,r)}"`,o=function(e){return[K(e),O(e),P(e),R(e)].filter(Boolean).join(", ")}(e);return[n,0!==o.length?`{ ${o} }`:null].filter(Boolean).join(" ").trim()}if(n(e))return`ids: [ ${e.getIDs().join(", ")} ]`;if(g(e)){const t=function(e){let t=L.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""}(o,y,$)}\n`,S+=function({indent:e,isSelected:t,node:n,nodeKeyDisplay:o,selection:r,typeDisplay:i}){if(!m(n)||!l(r)||!t||d(n))return"";const s=r.anchor,c=r.focus;if(""===n.getTextContent()||s.getNode()===r.focus.getNode()&&s.offset===c.offset)return"";const[u,f]=function(e,t){const n=t.getStartEndPoints();if(a(t)||null===n)return[-1,-1];const[o,r]=n,i=e.getTextContent(),l=i.length;let s=-1,c=-1;if("text"===o.type&&"text"===r.type){const t=o.getNode(),n=r.getNode();t===n&&e===t&&o.offset!==r.offset?[s,c]=o.offset<r.offset?[o.offset,r.offset]:[r.offset,o.offset]:[s,c]=e===t?t.isBefore(n)?[o.offset,l]:[0,o.offset]:e===n?n.isBefore(t)?[r.offset,l]:[0,r.offset]:[0,l]}const u=(i.slice(0,s).match(k)||[]).length,f=(i.slice(s,c).match(k)||[]).length;return[s+u,c+u+f]}(n,r);if(u===f)return"";const h=e[e.length-1]===j.hasNextSibling?j.ancestorHasNextSibling:j.ancestorIsLastChild,g=[...e.slice(0,e.length-1),h],p=Array(u+1).fill(" "),y=Array(f-u).fill(j.selectedChar),$=i.length+2,b=Array(o.length+$).fill(" ");return[j.selectedLine,g.join(" "),[...b,...p,...y].join("")].join(" ")+"\n"}({indent:r,isSelected:u,node:o,nodeKeyDisplay:s,selection:e,typeDisplay:c})}),null===e?": null":l(e)?function(e){let t="";const n=I(e),o=function(e){let t=e;for(;null!==t;){const e=s(t);if(null!==e){const n=c(t);if(null!==n)return{host:n,name:e}}t=t.getParent()??c(t)}return null}(e.anchor.getNode()),r=null!==o?` (in slot "${o.name}" of ${o.host.getType()} { key: ${o.host.getKey()} })`:"";t+=`: range${r} ${""!==n?`{ ${n} }`:""} ${""!==e.style?`{ style: ${e.style} } `:""}`;const i=e.anchor,l=e.focus,a=i.offset,u=l.offset;return t+=`\n \u251c anchor { key: ${i.key}, offset: ${null===a?"null":a}, type: ${i.type} }`,t+=`\n \u2514 focus { key: ${l.key}, offset: ${null===u?"null":u}, type: ${l.type} }`,t}(e):o(e)?function(e){return`: table\n \u2514 { table: ${e.tableKey}, anchorCell: ${e.anchor.key}, focusCell: ${e.focus.key} }`}(e):function(e){if(!a(e))return"";return`: node\n \u2514 [${Array.from(e._nodes).join(", ")}]`}(e)},{editor:u});if(S+="\n selection"+T,S+="\n\n commands:",f.length)for(const{index:e,type:t,payload:n}of f)S+=`\n \u2514 ${e}. { type: ${t}, payload: ${n instanceof Event?n.constructor.name:n} }`;else S+="\n \u2514 None dispatched.";const{version:v}=u.constructor;return S+=`\n\n editor${v?` (v${v})`:""}:`,S+=`\n \u2514 namespace ${x.namespace}`,null!==C&&(S+=`\n \u2514 compositionKey ${C}`),S+=`\n \u2514 editable ${String(N)}`,S}function E(e,t,n=[]){const o=[];for(const t of u(e)){const n=f(e,t);null!==n&&o.push([t,n])}const r=d(e)?e.getChildren():[],i=o.length+r.length;let l=0;for(const[e,r]of o){const o=l===i-1;t(r,n.concat(o?j.isLastChild:j.hasNextSibling),e),(d(r)||h(r))&&E(r,t,n.concat(o?j.ancestorIsLastChild:j.ancestorHasNextSibling)),l++}for(const e of r){const o=l===i-1;t(e,n.concat(o?j.isLastChild:j.hasNextSibling)),(d(e)||h(e))&&E(e,t,n.concat(o?j.ancestorIsLastChild:j.ancestorHasNextSibling)),l++}}function _(e,t=!1){const n=Object.entries(T).reduce((e,[t,n])=>e.replace(new RegExp(t,"g"),String(n)),e);return t?n.replace(/[^\s]/g,"*"):n}function D(e){let t=w.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="detail: "+t),t}function H(e){let t=B.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="mode: "+t),t}function I(e){let t=v.map(t=>t(e)).filter(Boolean).join(", ").toLocaleLowerCase();return""!==t&&(t="format: "+t),t}function K(e){let t=e.getTarget();return null!=t&&(t="target: "+t),t}function O(e){let t=e.getRel();return null!=t&&(t="rel: "+t),t}function P(e){let t=e.getTitle();return null!=t&&(t="title: "+t),t}function R(e){if(!e.__state)return!1;const t=[];for(const[n,o]of e.__state.knownState.entries()){if(n.isEqual(o,n.defaultValue))continue;const e=JSON.stringify(n.unparse(o));t.push(`[${n.key}: ${e}]`)}let n=t.join(",");return""!==n&&(n="state: "+n),n}function A(e,t){const n=new Array(1+t++).join(" "),o=new Array(t-1).join(" ");let r;for(let i=0;i<e.children.length;i++)r=document.createTextNode("\n"+n),e.insertBefore(r,e.children[i]),A(e.children[i],t),e.lastElementChild===e.children[i]&&(r=document.createTextNode("\n"+o),e.appendChild(r));return e}const U=/*#__PURE__*/y(function({treeTypeButtonClassName:e,timeTravelButtonClassName:t,timeTravelPanelSliderClassName:n,timeTravelPanelButtonClassName:o,viewClassName:r,timeTravelPanelClassName:i,editorState:l,setEditorState:s,setEditorReadOnly:c,generateContent:a,commandsLog:u=[]},f){const[d,h]=$([]),[m,g]=$(""),[p,y]=$(!1),[T,k]=$(!1),j=b(0),v=b(null),[L,w]=$(!1),[B,F]=$(!1),[E,_]=$(!1),D=b(null),H=b([]),I=b(0),K=x(e=>{const t=++I.current;a(e).then(e=>{t===I.current&&g(e)}).catch(e=>{t===I.current&&g(`Error rendering tree: ${e.message}\n\nStack:\n${e.stack}`)})},[a]);C(()=>{if(!E&&l._nodeMap.size>1e3&&(F(!0),!E))return;if(D.current!==l||H.current!==u){const e=D.current!==l;D.current=l,H.current=u,K(T),!p&&e&&h(e=>[...e,[Date.now(),l]])}},[l,K,T,E,p,u]);const O=d.length;C(()=>{if(L){let e;const t=()=>{const n=j.current;if(n===O-1)return void w(!1);const o=d[n][0],r=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()},r-o)};return t(),()=>{clearTimeout(e)}}},[d,L,O,s]);
|
|
10
10
|
return N("div",{className:r,children:[!E&&B?/*#__PURE__*/N("div",{style:{padding:20},children:[/*#__PURE__*/S("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),/*#__PURE__*/S("button",{onClick:()=>{_(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5},children:"Show full tree"})]}):null,E?null:/*#__PURE__*/S("button",{onClick:()=>(K(!T),void k(!T)),className:e,type:"button",children:T?"Tree":"Export DOM"}),!p&&(E||!B)&&O>2&&/*#__PURE__*/S("button",{onClick:()=>{c(!0),j.current=O-1,y(!0)},className:t,type:"button",children:"Time Travel"}),(E||!B)&&/*#__PURE__*/S("pre",{ref:f,children:m}),p&&(E||!B)&&/*#__PURE__*/N("div",{className:i,children:[/*#__PURE__*/S("button",{className:o,onClick:()=>{j.current===O-1&&(j.current=1),w(!L)},type:"button",children:L?"Pause":"Play"}),/*#__PURE__*/S("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:O-1}),/*#__PURE__*/S("button",{className:o,onClick:()=>{c(!1);const e=d.length-1,t=d[e];s(t[1]);const n=v.current;null!==n&&(n.value=String(e)),y(!1),w(!1)},type:"button",children:"Exit"})]})]})});function M(e,t){const n=[];let o=0;for(const r of e._commands.keys())n.push(e.registerCommand(r,e=>{o+=1;const n={index:o,payload:e,type:r.type?r.type:"UNKNOWN"};return t(e=>[...e.slice(-9),n]),!1},p));return()=>n.forEach(e=>e())}function z(e){const[t,n]=$([]);return C(()=>M(e,n),[e]),t}export{U as TreeView,F as generateContent,M as registerLexicalCommandLogger,z as useLexicalCommandsLog};
|
package/package.json
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"utils"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.46.1-nightly.
|
|
11
|
+
"version": "0.46.1-nightly.20260707.0",
|
|
12
12
|
"main": "./dist/LexicalDevtoolsCore.js",
|
|
13
13
|
"types": "./dist/typescript-too-old.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/
|
|
16
|
-
"@lexical/
|
|
17
|
-
"@lexical/
|
|
18
|
-
"@lexical/
|
|
19
|
-
"@lexical/
|
|
20
|
-
"lexical": "0.46.1-nightly.
|
|
15
|
+
"@lexical/link": "0.46.1-nightly.20260707.0",
|
|
16
|
+
"@lexical/mark": "0.46.1-nightly.20260707.0",
|
|
17
|
+
"@lexical/table": "0.46.1-nightly.20260707.0",
|
|
18
|
+
"@lexical/html": "0.46.1-nightly.20260707.0",
|
|
19
|
+
"@lexical/utils": "0.46.1-nightly.20260707.0",
|
|
20
|
+
"lexical": "0.46.1-nightly.20260707.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=18.x",
|
package/src/generateContent.ts
CHANGED
|
@@ -588,6 +588,7 @@ function $printSelectedCharsLine({
|
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
function printPrettyHTML(str: string) {
|
|
591
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
591
592
|
const div = document.createElement('div');
|
|
592
593
|
div.innerHTML = str.trim();
|
|
593
594
|
return prettifyHTML(div, 0).innerHTML;
|
|
@@ -599,10 +600,12 @@ function prettifyHTML(node: Element, level: number) {
|
|
|
599
600
|
let textNode;
|
|
600
601
|
|
|
601
602
|
for (let i = 0; i < node.children.length; i++) {
|
|
603
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
602
604
|
textNode = document.createTextNode('\n' + indentBefore);
|
|
603
605
|
node.insertBefore(textNode, node.children[i]);
|
|
604
606
|
prettifyHTML(node.children[i], level);
|
|
605
607
|
if (node.lastElementChild === node.children[i]) {
|
|
608
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
606
609
|
textNode = document.createTextNode('\n' + indentAfter);
|
|
607
610
|
node.appendChild(textNode);
|
|
608
611
|
}
|