showai-reader 0.9.0-reader.cppyr4f7 → 0.9.0-reader.cutjua3r
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.
- package/README.md +1 -1
- package/chunks/CardGrid-F5LYBSDH.js +2 -0
- package/chunks/CommandReference-5TSKPHE3.js +3 -0
- package/chunks/{ComparisonMatrix-YQJRBJHK.js → ComparisonMatrix-27M44OZJ.js} +1 -1
- package/chunks/EventTimeline-35QURTAO.js +2 -0
- package/chunks/{ExperimentTracker-L4ERILSH.js → ExperimentTracker-P4QX3TFY.js} +1 -1
- package/chunks/{ExternalDiagram-CESN6AFD.js → ExternalDiagram-AKYOCLQZ.js} +3157 -768
- package/chunks/Flowchart-ZNPOCEPD.js +12 -0
- package/chunks/{G2Chart-N3VN7CJU.js → G2Chart-IA56I52P.js} +2 -2
- package/chunks/LayerDiagram-ES4DSFBP.js +2 -0
- package/chunks/{Mindmap-H2BMB2CH.js → Mindmap-SQCZEOJ2.js} +2 -2
- package/chunks/RichTextEditor-W3DYD6M3.js +157 -0
- package/chunks/Roadmap-GTVA7DQG.js +2 -0
- package/chunks/{Scene3D-RIDB2UPZ.js → Scene3D-H2F5Y2G3.js} +2 -2
- package/chunks/SequenceDiagram-VLOO736H.js +2 -0
- package/chunks/{StatusTree-DE6SBNV3.js → StatusTree-L6XZCK7R.js} +1 -1
- package/chunks/StepGuide-DLY5ZBMO.js +1 -0
- package/chunks/StructureBrowser-H72Y64DB.js +3 -0
- package/chunks/Waterfall-QA3U6LNC.js +2 -0
- package/chunks/{chunk-24VJITFC.js → chunk-2HAL7KBM.js} +1 -1
- package/chunks/chunk-3I4CQ55U.js +1 -0
- package/chunks/chunk-3RZMLHCB.js +1 -0
- package/chunks/chunk-AIBH6MTQ.js +1 -0
- package/chunks/chunk-D74K2NKW.js +1 -0
- package/chunks/chunk-EM2ABYID.js +1 -0
- package/chunks/chunk-EXOUDPUB.js +4 -0
- package/chunks/chunk-GLP5VV7P.js +1 -0
- package/chunks/chunk-HSNLLTYJ.js +2 -0
- package/chunks/chunk-JXKAISUX.js +1 -0
- package/chunks/{chunk-EJKNO2TI.js → chunk-JYWKSXK3.js} +1 -1
- package/chunks/chunk-NJBFXE6W.js +1 -0
- package/chunks/{chunk-UYGYV3XW.js → chunk-NWCMWKOF.js} +2 -2
- package/chunks/{chunk-KS3LLFYE.js → chunk-OYYVZA2J.js} +49 -47
- package/chunks/chunk-PVMEUQFU.js +21 -0
- package/chunks/{chunk-Z2EQGXZF.js.LEGAL.txt → chunk-PVMEUQFU.js.LEGAL.txt} +11 -9
- package/chunks/{chunk-X2BFI7UA.js → chunk-VQIPL7NG.js} +1 -1
- package/chunks/chunk-YLTLOYBH.js +1 -0
- package/index.js +1 -1
- package/manifest.json +5 -5
- package/package.json +1 -1
- package/reader-CUTJUA3R.js +44 -0
- package/chunks/Flowchart-7I3IRBXN.js +0 -10
- package/chunks/RichTextEditor-XPGN2LUL.js +0 -155
- package/chunks/chunk-M3KEZP5Z.js +0 -1
- package/chunks/chunk-QBNRB4AJ.js +0 -1
- package/chunks/chunk-Z2EQGXZF.js +0 -21
- package/chunks/chunk-ZZKYSVG3.js +0 -2
- package/reader-CPPYR4F7.js +0 -41
- /package/chunks/{Flowchart-7I3IRBXN.js.LEGAL.txt → Flowchart-ZNPOCEPD.js.LEGAL.txt} +0 -0
- /package/chunks/{G2Chart-N3VN7CJU.js.LEGAL.txt → G2Chart-IA56I52P.js.LEGAL.txt} +0 -0
- /package/chunks/{Scene3D-RIDB2UPZ.js.LEGAL.txt → Scene3D-H2F5Y2G3.js.LEGAL.txt} +0 -0
- /package/chunks/{chunk-UYGYV3XW.js.LEGAL.txt → chunk-NWCMWKOF.js.LEGAL.txt} +0 -0
- /package/{reader-CPPYR4F7.js.LEGAL.txt → reader-CUTJUA3R.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as w}from"./chunk-3I4CQ55U.js";import{a as A,b as v,d as L}from"./chunk-AIBH6MTQ.js";import"./chunk-D74K2NKW.js";import{d as R}from"./chunk-VQIPL7NG.js";import{a as M,c as C,jb as D,mb as E}from"./chunk-PVMEUQFU.js";import{c as x,d as T}from"./chunk-DUIGVKKG.js";var n=x(C(),1);M(`.sb-block.ly-block :is(h3,h4,p,ul,ol,li,pre):not(svg){margin:0}.sb-block.ly-block li:not(svg){padding:0}.sb-block.ly-block pre:not(svg){border:0;border-radius:0;background:none;color:inherit}.sb-block.ly-block{--ly-text: var(--sb-text);--ly-muted: var(--sb-muted);--ly-faint: color-mix(in srgb, var(--sb-muted) 70%, transparent);--ly-line: var(--sb-line);--ly-paper: var(--sb-surface);--ly-soft: var(--sb-soft);--ly-accent: var(--sb-accent);--ly-accent-soft: var(--sb-accent-soft);--ly-teal: #0d8579;--ly-teal-soft: #e6f4f2;--ly-orange: #bf6528;--ly-orange-soft: #fbefe6;--ly-violet: #7348d0;--ly-violet-soft: #f2edfc;--ly-rose: #c4415a;--ly-rose-soft: #fbebee;--ly-slate: #526476;--ly-slate-soft: #edf1f4;--t: var(--ly-accent);--ts: var(--ly-accent-soft);color:var(--ly-text);font-family:inherit;font-size:14px;line-height:1.65;padding:8px 0;container-type:inline-size;overflow-wrap:anywhere}:root[data-theme=dark] .sb-block.ly-block,[data-theme=dark] .sb-block.ly-block{--ly-teal: #4fc4b6;--ly-teal-soft: #163734;--ly-orange: #e79c64;--ly-orange-soft: #3b2b1e;--ly-violet: #b497ff;--ly-violet-soft: #2e2648;--ly-rose: #f0839a;--ly-rose-soft: #3e222a;--ly-slate: #a2b2c2;--ly-slate-soft: #242d35}.sb-block.ly-block *{box-sizing:border-box}.sb-block.ly-block [data-tone=accent]{--t: var(--ly-accent);--ts: var(--ly-accent-soft)}.sb-block.ly-block [data-tone=teal]{--t: var(--ly-teal);--ts: var(--ly-teal-soft)}.sb-block.ly-block [data-tone=orange]{--t: var(--ly-orange);--ts: var(--ly-orange-soft)}.sb-block.ly-block [data-tone=violet]{--t: var(--ly-violet);--ts: var(--ly-violet-soft)}.sb-block.ly-block [data-tone=rose]{--t: var(--ly-rose);--ts: var(--ly-rose-soft)}.sb-block.ly-block [data-tone=slate]{--t: var(--ly-slate);--ts: var(--ly-slate-soft)}.sb-block.ly-block .ly-top{display:flex;align-items:baseline;justify-content:space-between;gap:16px;margin:0 0 10px}.sb-block.ly-block .ly-title{margin:0;font-size:16px;line-height:1.5;font-weight:650}.sb-block.ly-block .ly-caption{margin:0;font-size:13px;color:var(--ly-muted);line-height:1.6}.sb-block.ly-block .ly-hint{flex:none;font-size:12px;color:var(--ly-faint);white-space:nowrap}.sb-block.ly-block code{font-family:var(--mono, ui-monospace, Menlo, Consolas, monospace);font-size:.88em;background:var(--ly-soft);border-radius:4px;padding:1px 5px}.sb-block.ly-block .ly-band{display:grid;grid-template-columns:minmax(150px,200px) minmax(0,1fr);align-items:center;gap:20px;padding:14px 16px;border:1px solid var(--ly-line);border-radius:10px;background:var(--ly-soft);transition:border-color .18s ease}.sb-block.ly-block .ly-band[data-active]{border-color:color-mix(in srgb,var(--t) 45%,var(--ly-line))}.sb-block.ly-block .ly-head{display:flex;align-items:flex-start;gap:12px;min-width:0}.sb-block.ly-block .ly-index{flex:none;width:24px;height:24px;margin-top:1px;border-radius:6px;background:var(--ts);color:var(--t);font-size:12px;font-weight:650;line-height:24px;text-align:center;font-variant-numeric:tabular-nums}.sb-block.ly-block .ly-head h4{margin:0;font-size:15px;line-height:1.6;font-weight:650}.sb-block.ly-block .ly-head small{display:block;font-size:12px;line-height:1.5;color:var(--ly-muted)}.sb-block.ly-block .ly-modules{display:flex;flex-wrap:wrap;gap:8px}.sb-block.ly-block .ly-chip{display:inline-flex;align-items:center;gap:8px;font:inherit;font-size:13px;line-height:1.4;color:var(--ly-text);background:var(--ly-paper);border:1px solid var(--ly-line);border-radius:6px;padding:6px 12px;cursor:pointer;transition:border-color .15s ease,background-color .15s ease}.sb-block.ly-block .ly-chip i{width:6px;height:6px;border-radius:50%;background:var(--t);opacity:.75;flex:none}.sb-block.ly-block .ly-chip:hover{border-color:color-mix(in srgb,var(--t) 55%,var(--ly-line))}.sb-block.ly-block .ly-chip[aria-pressed=true]{background:var(--ts);border-color:var(--t);box-shadow:0 0 0 1px var(--t) inset;font-weight:650}.sb-block.ly-block .ly-chip[aria-pressed=true] i{opacity:1}.sb-block.ly-block .ly-chip:focus-visible,.sb-block.ly-block a:focus-visible{outline:2px solid var(--ly-accent);outline-offset:2px}.sb-block.ly-block .ly-none{font-size:13px;color:var(--ly-faint)}.sb-block.ly-block .ly-link{height:22px;padding-left:23px;display:flex;align-items:center}.sb-block.ly-block .ly-link svg{display:block;fill:none;stroke:var(--ly-faint);stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.sb-block.ly-block .ly-panel{margin-top:14px;border:1px solid var(--ly-line);border-radius:10px;background:var(--ly-paper);padding:16px 20px;min-height:76px}.sb-block.ly-block .ly-panel[data-empty]{display:flex;align-items:center;border-style:dashed}.sb-block.ly-block .ly-panel>p{margin:0;color:var(--ly-muted);font-size:13px}.sb-block.ly-block .ly-crumb{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ly-muted);line-height:1.5}.sb-block.ly-block .ly-crumb span:first-child{color:var(--t);font-weight:650}.sb-block.ly-block .ly-crumb b{font-weight:400;color:var(--ly-faint)}.sb-block.ly-block .ly-panel h4{margin:2px 0 6px;font-size:15px;line-height:1.5;font-weight:650}.sb-block.ly-block .ly-path{display:inline-block;margin:0 0 8px;font-size:12px;padding:3px 8px;border-radius:6px;border:1px solid var(--ly-line);word-break:break-all}.sb-block.ly-block .ly-md p{margin:0 0 6px;font-size:14px;line-height:1.7}.sb-block.ly-block .ly-md p:last-child{margin-bottom:0}.sb-block.ly-block .ly-md strong{font-weight:650}.sb-block.ly-block .ly-md a{color:var(--ly-accent);text-underline-offset:3px}.sb-block.ly-block .ly-static{display:none}@container (max-width: 640px){.sb-block.ly-block .ly-hint{display:none}.sb-block.ly-block .ly-band{grid-template-columns:minmax(0,1fr);gap:10px;padding:12px 14px}.sb-block.ly-block .ly-link{padding-left:21px}.sb-block.ly-block .ly-panel{padding:14px 16px}}@media(prefers-reduced-motion:reduce){.sb-block.ly-block .ly-band,.sb-block.ly-block .ly-chip{transition:none}}@media print{.sb-block.ly-block .ly-hint,.sb-block.ly-block .ly-panel{display:none}.sb-block.ly-block .ly-band{break-inside:avoid}.sb-block.ly-block .ly-static{display:block;margin-top:12px;font-size:13px}.sb-block.ly-block .ly-static-layer{margin-bottom:8px}.sb-block.ly-block .ly-static ul{margin:4px 0 0;padding-left:20px}.sb-block.ly-block .ly-static li{break-inside:avoid;margin-bottom:4px}.sb-block.ly-block .ly-static code{margin-left:6px}}
|
|
2
|
+
`);var S=T("layerDiagram",{"zh-CN":{title:"\u5206\u5C42\u67B6\u6784\u56FE",hint:"\u70B9\u9009\u6A21\u5757\u67E5\u770B\u8BF4\u660E",modules:"{layer}\u7684\u6A21\u5757",empty:"\u6682\u65E0\u6A21\u5757",prompt:"\u9009\u62E9\u4E0A\u65B9\u4EFB\u4E00\u6A21\u5757\uFF0C\u67E5\u770B\u5B83\u7684\u804C\u8D23\u548C\u4F4D\u7F6E\u3002",path:"\u4F4D\u7F6E"},en:{title:"Layer diagram",hint:"Select a module to see its details",modules:"Modules in {layer}",empty:"No modules",prompt:"Select any module above to see what it does and where it lives.",path:"Location"}});var l=x(D(),1);function N({source:d,inline:s}){return(0,l.jsx)(l.Fragment,{children:L(d).map((a,t)=>s?(0,l.jsxs)(n.Fragment,{children:[t>0&&" ",(0,l.jsx)(w,{source:a})]},t):(0,l.jsx)("p",{children:(0,l.jsx)(w,{source:a})},t))})}var F=(d,s)=>A.includes(d.tone)?d.tone:v[s%v.length];function J({data:d}){let s=E(S),a=d,t=(0,n.useMemo)(()=>(Array.isArray(a.layers)?a.layers:[]).map((e,o)=>({...e,tone:F(e,o),modules:Array.isArray(e.modules)?e.modules:[]})),[a.layers]),p=t.some(e=>e.modules.some(o=>o.id===a.initial))?a.initial:null,[f,k]=(0,n.useState)(p),[I,B]=(0,n.useState)(p);I!==p&&(B(p),k(p));let u=(0,n.useRef)(new Map),z=t.findIndex(e=>e.modules.some(o=>o.id===f)),m=t[z],r=m?.modules.find(e=>e.id===f),O=(e,o,i)=>{if(e.key==="Escape")return k(null);let c,y=t[o].modules;if(e.key==="ArrowRight")c=y[Math.min(y.length-1,i+1)];else if(e.key==="ArrowLeft")c=y[Math.max(0,i-1)];else if(e.key==="ArrowDown"||e.key==="ArrowUp"){let b=e.key==="ArrowDown"?1:-1;for(let g=o+b;g>=0&&g<t.length;g+=b){let h=t[g].modules;if(h.length){c=h[Math.min(i,h.length-1)];break}}}c&&(e.preventDefault(),u.current.get(c.id)?.focus(),k(c.id))};return(0,l.jsxs)("section",{className:"sb-block ly-block","aria-label":R(a.title,s("title")),children:[(0,l.jsxs)("div",{className:"ly-top",children:[(0,l.jsxs)("div",{children:[a.title&&(0,l.jsx)("h3",{className:"ly-title",children:a.title}),a.caption&&(0,l.jsx)("p",{className:"ly-caption",children:(0,l.jsx)(N,{source:a.caption,inline:!0})})]}),(0,l.jsx)("span",{className:"ly-hint",children:s("hint")})]}),(0,l.jsx)("div",{className:"ly-stack",children:t.map((e,o)=>(0,l.jsxs)(n.Fragment,{children:[o>0&&(0,l.jsx)("div",{className:"ly-link","aria-hidden":"true",children:(0,l.jsxs)("svg",{width:"12",height:"20",viewBox:"0 0 12 20",children:[(0,l.jsx)("path",{d:"M6 1v15"}),(0,l.jsx)("path",{d:"M2.5 12.5 6 16.5l3.5-4"})]})}),(0,l.jsxs)("section",{className:"ly-band","data-tone":e.tone,"data-active":o===z?"":void 0,"aria-label":e.name,children:[(0,l.jsxs)("header",{className:"ly-head",children:[(0,l.jsx)("span",{className:"ly-index",children:o+1}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{children:e.name}),e.sub&&(0,l.jsx)("small",{children:e.sub})]})]}),(0,l.jsx)("div",{className:"ly-modules",role:"group","aria-label":s("modules",{layer:e.name}),children:e.modules.length?e.modules.map((i,c)=>{let y=i.id===f;return(0,l.jsxs)("button",{type:"button",className:"ly-chip",ref:b=>{b?u.current.set(i.id,b):u.current.delete(i.id)},"aria-pressed":y,onClick:()=>k(y?null:i.id),onKeyDown:b=>O(b,o,c),children:[(0,l.jsx)("i",{"aria-hidden":"true"}),i.name]},i.id)}):(0,l.jsx)("span",{className:"ly-none",children:s("empty")})})]})]},e.id))}),(0,l.jsx)("div",{className:"ly-panel","data-tone":m?.tone,"data-empty":r?void 0:"","aria-live":"polite",children:r&&m?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"ly-crumb",children:[(0,l.jsx)("span",{children:m.name}),(0,l.jsx)("b",{"aria-hidden":"true",children:"/"}),(0,l.jsx)("span",{children:r.name})]}),(0,l.jsx)("h4",{children:r.name}),r.path&&(0,l.jsx)("code",{className:"ly-path",title:s("path"),children:r.path}),r.detail&&(0,l.jsx)("div",{className:"ly-md",children:(0,l.jsx)(N,{source:r.detail})})]}):(0,l.jsx)("p",{children:s("prompt")})}),(0,l.jsx)("div",{className:"ly-static",children:t.map(e=>(0,l.jsxs)("div",{className:"ly-static-layer",children:[(0,l.jsx)("b",{children:e.name}),e.sub&&(0,l.jsxs)("span",{children:[" \xB7 ",e.sub]}),(0,l.jsx)("ul",{children:e.modules.map(o=>(0,l.jsxs)("li",{children:[(0,l.jsx)("b",{children:o.name}),o.path&&(0,l.jsx)("code",{children:o.path}),o.detail&&(0,l.jsx)("div",{className:"ly-md",children:(0,l.jsx)(N,{source:o.detail})})]},o.id))})]},e.id))})]})}export{J as LayerDiagramBlock};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as S,b as X,c as O,d as he,e as fe,f as ge,g as ye,h as we}from"./chunk-DG67SWQA.js";import{a as ve}from"./chunk-
|
|
2
|
-
`);var t=W(be(),1);function Je({data:Z,onChange:R,readOnly:Me=!1}){let a=ke(Le),n=(0,r.useMemo)(()=>X(Z),[Z]),d=!Me&&!!R,L=n.nodes.find(e=>e.parentId===null),[i,M]=(0,r.useState)(L.id),[H,k]=(0,r.useState)(!1),[c,z]=(0,r.useState)(null),D=(0,r.useRef)(null),K=(0,r.useRef)(!0),[Ee,Se]=(0,r.useState)(null),[_,ze]=(0,r.useState)(null),f=!d&&_?.layout||n.layout||"radial",g=!d&&_?.direction||n.direction||"right",x=Ee??new Set(n.nodes.filter(e=>e.collapsed).map(e=>e.id)),u=(0,r.useMemo)(()=>ye({...n,layout:f,direction:g},x),[n,f,g,JSON.stringify([...x])]),[h,P]=(0,r.useState)(1),[q,$]=(0,r.useState)(null),G=(0,r.useRef)(null),E=(0,r.useRef)(null),v=(0,r.useRef)(null),N=(0,r.useRef)(new Map),U=(0,r.useId)(),p=(0,r.useRef)({past:[],future:[],expected:null}),[Q,F]=(0,r.useState)(""),y=n.nodes.find(e=>e.id===i)??L,Y=O(n,y.id).length>0,ee=()=>{let e=E.current;e&&P(Math.max(.15,Math.min(1,(e.clientWidth-20)/u.width,(e.clientHeight-20)/u.height)))};(0,r.useLayoutEffect)(ee,[f,g]),(0,r.useEffect)(()=>{let e=JSON.stringify(n);p.current.expected!==null&&p.current.expected!==e&&(p.current.past=[],p.current.future=[]),p.current.expected=e},[n]),(0,r.useEffect)(()=>{!u.nodes.some(e=>e.id===i)&&c?.id!==i&&M(L.id)},[u,i,L.id,c?.id]);let w=e=>{M(e),requestAnimationFrame(()=>{let o=N.current.get(e);o?.focus({preventScroll:!0}),o?.scrollIntoView({block:"nearest",inline:"nearest"})})};(0,r.useLayoutEffect)(()=>{c&&(v.current?.focus(),K.current?v.current?.select():v.current?.setSelectionRange(c.value.length,c.value.length),v.current?.scrollIntoView({block:"nearest",inline:"nearest"}))},[c?.id,n.nodes.length]),(0,r.useLayoutEffect)(()=>{if(!H||c||!d){$(null);return}let e=()=>{let s=N.current.get(i),l=E.current;if(!s||!l)return;let m=s.getBoundingClientRect(),b=l.getBoundingClientRect();$(m.bottom<b.top||m.top>b.bottom||m.right<b.left||m.left>b.right?null:{left:Math.max(b.left,Math.min(b.right,m.left+m.width/2)),top:Math.max(b.top,m.top)})};e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e);let o=new ResizeObserver(e);return E.current&&o.observe(E.current),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),o.disconnect()}},[H,c,d,i,u,h]);let C=e=>{!d||e===n||(X(e),p.current.past=[...p.current.past.slice(-99),n],p.current.future=[],p.current.expected=JSON.stringify(e),F(""),R?.(e))},te=e=>{let o=e==="tree"&&f==="tree"?g==="right"?"left":"right":g;e===f&&o===g||(d?C({...n,layout:e,direction:o}):ze({layout:e,direction:o}))},I=(e=!1)=>{let s=(e?p.current.future:p.current.past).pop();!s||!d||((e?p.current.past:p.current.future).push(n),p.current.expected=JSON.stringify(s),R?.(s),w(s.nodes.some(l=>l.id===i)?i:L.id))},T=(e=i,o)=>{if(!d)return;let s=n.nodes.find(l=>l.id===e);s&&(D.current=e,K.current=o===void 0,$(null),z({id:e,value:o??s.label}))},J=(e=!1)=>{if(!c||D.current!==c.id)return;let o=c.value.trim();if(!e&&!o){F(a("enterNodeName")),v.current?.focus();return}D.current=null,z(null),!e&&o!==n.nodes.find(s=>s.id===c.id)?.label&&C({...n,nodes:n.nodes.map(s=>s.id===c.id?{...s,label:o}:s)}),w(c.id)},B=(e,o=!1)=>{if(!d)return;if(n.nodes.length>=S){F(a("nodeLimit",{count:S}));return}let s=crypto.randomUUID(),l=he(n,i,s,e,o);C(l),M(s),D.current=s,K.current=!0,z({id:s,value:l.nodes.find(m=>m.id===s).label})},ne=()=>{!d||y.parentId===null||(C(fe(n,i)),w(y.parentId))},V=()=>{if(!Y)return;let e=new Set(x);e.has(i)?e.delete(i):e.add(i),d?C({...n,nodes:n.nodes.map(o=>o.id===i?{...o,collapsed:e.has(i)}:o)}):Se(e),w(i)},De=e=>{if(e.nativeEvent.isComposing||e.keyCode===229||e.target.closest("input, .sm-view-controls"))return;let o=e.metaKey||e.ctrlKey,s=e.target.closest(".editor-bubble")?.id===U,l=e.target.closest(".sb-header .sb-actions");if(s||l?!o:!e.target.closest(".sm-node"))return;let m=!0;if(o&&e.key.toLowerCase()==="z"&&d)I(e.shiftKey);else if(o&&e.key.toLowerCase()==="y"&&d)I(!0);else if(o||e.altKey)m=!1;else if(e.key==="Tab"&&d&&!e.shiftKey)B("child");else if(e.key==="Tab"&&d&&e.shiftKey)C(ge(n,i)),w(i);else if(e.key==="Enter"&&d)B("sibling",e.shiftKey);else if(e.key==="F2"&&d)T();else if((e.key==="Delete"||e.key==="Backspace")&&d)ne();else if(e.key===" ")V();else if(e.key==="ArrowLeft")y.parentId&&w(y.parentId);else if(e.key==="ArrowRight")if(x.has(i))V();else{let b=O(n,i)[0];b&&w(b.id)}else if(e.key==="ArrowUp"||e.key==="ArrowDown"){let b=n.nodes.filter(j=>j.parentId===y.parentId),Ie=b.findIndex(j=>j.id===i),oe=b[Ie+(e.key==="ArrowUp"?-1:1)];oe&&w(oe.id)}else e.key==="Escape"?(k(!1),e.target.blur()):e.key.length===1&&d?T(i,e.key):m=!1;m&&(e.preventDefault(),e.stopPropagation())};return(0,t.jsxs)("section",{ref:G,className:"sb-block sm-block","aria-label":Ne(n.title,a("mindmap")),contentEditable:!1,"data-editor-keyboard-scope":"mindmap","data-mindmap-layout":f,"data-mindmap-direction":g,onClick:e=>e.stopPropagation(),onKeyDown:De,onFocus:e=>{e.target.closest(".sm-node, .sm-node-input")&&k(!0)},onBlur:e=>{!G.current?.contains(e.relatedTarget)&&!e.relatedTarget?.closest?.(`[id="${U}"]`)&&k(!1)},onContextMenu:()=>k(!1),children:[(0,t.jsxs)(Ce,{title:n.title,defaultTitle:"\u601D\u7EF4\u5BFC\u56FE",description:n.description,children:[(0,t.jsx)("button",{type:"button",className:"sb-icon-button","aria-label":a("radialLayout"),title:a("radialLayout"),"aria-pressed":f==="radial","data-surface-ui":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>te("radial"),children:(0,t.jsx)(de,{size:16})}),(0,t.jsx)("button",{type:"button",className:"sb-icon-button","aria-label":a("treeLayout"),title:a(g==="right"?f==="tree"?"treeLayout.rightToggle":"treeLayout.right":f==="tree"?"treeLayout.leftToggle":"treeLayout.left"),"aria-pressed":f==="tree","data-surface-ui":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>te("tree"),children:(0,t.jsx)(re,{size:16,style:{transform:g==="left"?"scaleX(-1)":void 0}})})]}),(0,t.jsx)("div",{ref:E,className:"sm-viewport",style:{height:n.height??460},children:(0,t.jsx)("div",{className:"sm-scroll-space",style:{width:u.width*h,height:u.height*h,minWidth:"100%",minHeight:"100%"},children:(0,t.jsxs)("div",{className:"sm-map",role:"tree","aria-label":a("nodes"),style:{width:u.width,height:u.height,transform:`scale(${h})`,left:`max(0px, calc(50% - ${u.width*h/2}px))`,top:`max(0px, calc(50% - ${u.height*h/2}px))`},children:[(0,t.jsx)("svg",{className:"sm-connections",width:u.width,height:u.height,"aria-hidden":"true",children:u.nodes.filter(e=>e.parentId).map(e=>{let o=u.nodes.find(s=>s.id===e.parentId);return(0,t.jsx)("path",{className:`sm-branch-${e.color}`,d:we(o,e)},e.id)})}),u.nodes.map(e=>{let o=O(n,e.id).length,s=c?.id===e.id;return(0,t.jsx)("div",{className:`sm-node-wrap sm-branch-${e.color}${e.parentId===null?" sm-root":""}`,style:{left:e.x,top:e.y,width:e.width,minHeight:e.height,"--sm-node-height":`${e.height}px`},children:s?(0,t.jsx)("input",{ref:v,className:"sm-node-input","aria-label":a("nodeName"),maxLength:200,value:c.value,onChange:l=>z({id:e.id,value:l.target.value}),onBlur:()=>J(),onKeyDown:l=>{l.stopPropagation(),!(l.nativeEvent.isComposing||l.keyCode===229)&&((l.key==="Enter"||l.key==="Tab")&&(l.preventDefault(),J()),l.key==="Escape"&&(l.preventDefault(),J(!0)))}}):(0,t.jsxs)("button",{type:"button",ref:l=>{l?N.current.set(e.id,l):N.current.delete(e.id)},className:`sm-node${H&&i===e.id?" is-selected":""}`,role:"treeitem","aria-level":e.depth+1,"aria-selected":i===e.id,"aria-expanded":o?!x.has(e.id):void 0,tabIndex:i===e.id?0:-1,onFocus:()=>M(e.id),onClick:l=>{l.currentTarget.focus({preventScroll:!0}),M(e.id),k(!0)},onDoubleClick:()=>T(e.id),children:[(0,t.jsx)("span",{children:e.label}),o>0&&x.has(e.id)&&(0,t.jsxs)("span",{className:"sm-count",children:["+",o]})]})},e.id)})]})})}),(0,t.jsx)("div",{className:"sm-footer",children:(0,t.jsxs)("div",{className:"sm-view-controls",role:"group","aria-label":a("view"),children:[(0,t.jsx)("button",{type:"button","aria-label":a("zoomOut"),disabled:h<=.15,onClick:()=>P(Math.max(.15,h/1.2)),children:(0,t.jsx)(le,{size:15})}),(0,t.jsxs)("button",{type:"button","aria-label":a("fit"),onClick:ee,children:[(0,t.jsx)(se,{size:15}),(0,t.jsxs)("span",{children:[Math.round(h*100),"%"]})]}),(0,t.jsx)("button",{type:"button","aria-label":a("zoomIn"),disabled:h>=2,onClick:()=>P(Math.min(2,h*1.2)),children:(0,t.jsx)(A,{size:15})})]})}),Q&&(0,t.jsx)("p",{role:"status",className:"sm-notice",children:Q}),q&&d&&!c&&(0,t.jsxs)(ve,{id:U,anchor:q,anchorElement:N.current.get(i),label:a("nodeActions"),keyboardScope:"mindmap",onEscape:()=>{k(!1),N.current.get(i)?.blur()},children:[(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("editNode"),title:a("editNode"),onClick:()=>T(),children:(0,t.jsx)(pe,{size:16})}),(0,t.jsx)("span",{className:"toolbar-divider"}),(0,t.jsxs)("button",{className:"editor-tool sm-labeled-action",type:"button","aria-label":a("newChild"),title:a("newChild"),disabled:n.nodes.length>=S,onClick:()=>B("child"),children:[(0,t.jsx)(A,{size:16}),(0,t.jsx)("span",{children:a("child")})]}),(0,t.jsxs)("button",{className:"editor-tool sm-labeled-action",type:"button","aria-label":a("newSibling"),title:a("newSibling"),disabled:n.nodes.length>=S||y.parentId===null,onClick:()=>B("sibling"),children:[(0,t.jsx)(A,{size:16}),(0,t.jsx)("span",{children:a("sibling")})]}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":x.has(i)?a("expandBranch"):a("collapseBranch"),title:a("toggleBranch"),disabled:!Y,onClick:V,children:(0,t.jsx)(ie,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("undoAction"),title:a("undo"),disabled:!p.current.past.length,onClick:()=>I(),children:(0,t.jsx)(me,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("redoAction"),title:a("redo"),disabled:!p.current.future.length,onClick:()=>I(!0),children:(0,t.jsx)(ce,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("deleteNodeAndChildren"),title:a("deleteBranch"),disabled:y.parentId===null,onClick:ne,children:(0,t.jsx)(ue,{size:16})})]})]})}export{Je as MindmapBlock};
|
|
1
|
+
import{a as S,b as X,c as O,d as he,e as fe,f as ge,g as ye,h as we}from"./chunk-DG67SWQA.js";import{a as ve}from"./chunk-HSNLLTYJ.js";import{d as Ne,e as Ce}from"./chunk-VQIPL7NG.js";import{A as ie,Ba as A,Fa as ce,a as ae,bb as ue,c as Te,cb as pe,eb as be,jb as me,la as re,mb as ke,qa as se,sa as le,wa as de}from"./chunk-PVMEUQFU.js";import{c as W,d as xe}from"./chunk-DUIGVKKG.js";var r=W(Te(),1);var Le=xe("mindmap",{"zh-CN":{mindmap:"\u601D\u7EF4\u5BFC\u56FE",enterNodeName:"\u8BF7\u8F93\u5165\u8282\u70B9\u540D\u79F0\u3002",nodeLimit:"\u601D\u7EF4\u5BFC\u56FE\u6700\u591A\u652F\u6301 {count} \u4E2A\u8282\u70B9\u3002",radialLayout:"\u56DB\u5468\u5C55\u5F00",treeLayout:"\u5355\u5411\u5C55\u5F00","treeLayout.right":"\u5355\u5411\u5C55\u5F00\uFF0C\u5F53\u524D\u5411\u53F3","treeLayout.left":"\u5355\u5411\u5C55\u5F00\uFF0C\u5F53\u524D\u5411\u5DE6","treeLayout.rightToggle":"\u5355\u5411\u5C55\u5F00\uFF0C\u5F53\u524D\u5411\u53F3\uFF1B\u518D\u6B21\u70B9\u51FB\u5207\u6362\u5411\u5DE6","treeLayout.leftToggle":"\u5355\u5411\u5C55\u5F00\uFF0C\u5F53\u524D\u5411\u5DE6\uFF1B\u518D\u6B21\u70B9\u51FB\u5207\u6362\u5411\u53F3",nodes:"\u5BFC\u56FE\u8282\u70B9",nodeName:"\u8282\u70B9\u540D\u79F0",view:"\u601D\u7EF4\u5BFC\u56FE\u89C6\u56FE",zoomOut:"\u7F29\u5C0F\u601D\u7EF4\u5BFC\u56FE",fit:"\u663E\u793A\u5B8C\u6574\u601D\u7EF4\u5BFC\u56FE",zoomIn:"\u653E\u5927\u601D\u7EF4\u5BFC\u56FE",nodeActions:"\u601D\u7EF4\u5BFC\u56FE\u8282\u70B9\u64CD\u4F5C",editNode:"\u7F16\u8F91\u8282\u70B9",newChild:"\u65B0\u5EFA\u5B50\u8282\u70B9",child:"\u5B50\u8282\u70B9",newSibling:"\u65B0\u5EFA\u540C\u7EA7\u8282\u70B9",sibling:"\u540C\u7EA7",expandBranch:"\u5C55\u5F00\u5206\u652F",collapseBranch:"\u6298\u53E0\u5206\u652F",toggleBranch:"\u6298\u53E0 / \u5C55\u5F00",undoAction:"\u64A4\u9500\u5BFC\u56FE\u64CD\u4F5C",undo:"\u64A4\u9500",redoAction:"\u91CD\u505A\u5BFC\u56FE\u64CD\u4F5C",redo:"\u91CD\u505A",deleteNodeAndChildren:"\u5220\u9664\u8282\u70B9\u53CA\u5176\u5B50\u8282\u70B9",deleteBranch:"\u5220\u9664\u5206\u652F"},en:{mindmap:"Mind map",enterNodeName:"Enter a node name.",nodeLimit:"A mind map can have up to {count} nodes.",radialLayout:"Radial layout",treeLayout:"One-way layout","treeLayout.right":"One-way layout, currently to the right","treeLayout.left":"One-way layout, currently to the left","treeLayout.rightToggle":"One-way layout, currently to the right. Click again to switch to the left.","treeLayout.leftToggle":"One-way layout, currently to the left. Click again to switch to the right.",nodes:"Mind map nodes",nodeName:"Node name",view:"Mind map view",zoomOut:"Zoom out mind map",fit:"Show entire mind map",zoomIn:"Zoom in mind map",nodeActions:"Mind map node actions",editNode:"Edit node",newChild:"New child node",child:"Child",newSibling:"New sibling node",sibling:"Sibling",expandBranch:"Expand branch",collapseBranch:"Collapse branch",toggleBranch:"Collapse / expand",undoAction:"Undo mind map change",undo:"Undo",redoAction:"Redo mind map change",redo:"Redo",deleteNodeAndChildren:"Delete node and its children",deleteBranch:"Delete branch"}});ae(`.sm-block{position:relative}.sm-viewport{overflow:auto;overscroll-behavior-x:contain;border-radius:8px;background:radial-gradient(var(--sb-line) .6px,transparent .6px) 0 0 / 20px 20px}.sm-scroll-space{position:relative;display:flex;justify-content:center;align-items:center}.sm-map{position:absolute;flex:none;transform-origin:top left}.sm-connections{position:absolute;inset:0;width:100%!important;height:100%!important;overflow:visible;pointer-events:none}.sm-connections path{fill:none;stroke:var(--sm-branch);stroke-width:2;opacity:.7}.sm-branch-0{--sm-branch: #5f8b78}.sm-branch-1{--sm-branch: #6b89b7}.sm-branch-2{--sm-branch: #c38b55}.sm-branch-3{--sm-branch: #ab7890}.sm-branch-4{--sm-branch: #8580b5}.sm-branch-5{--sm-branch: #789c9f}.sm-node-wrap{position:absolute}.sm-block .sm-node,.sm-block .sm-node-input{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:var(--sm-node-height);padding:10px 16px;border:1.5px solid var(--sm-branch, var(--sb-accent));border-radius:9px;background:var(--sb-surface);color:var(--sb-text);font:inherit;font-size:14px;line-height:20px;text-align:center;box-shadow:0 2px 8px #00000005}.sm-node span:first-child{overflow-wrap:anywhere;white-space:pre-wrap}.sm-node:hover{background:color-mix(in srgb,var(--sm-branch, var(--sb-accent)) 8%,var(--sb-surface))}.sm-node.is-selected,.sm-node:focus-visible{outline:3px solid color-mix(in srgb,var(--sm-branch, var(--sb-accent)) 30%,transparent);outline-offset:3px}.sm-root .sm-node{background:var(--sb-accent);color:var(--sb-surface);border-color:var(--sb-accent);font-weight:600}.sm-count{flex:none;font-size:11px;border-radius:4px;padding:1px 4px;background:var(--sb-soft);color:var(--sb-muted)}.sm-footer{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:10px 2px 0;color:var(--sb-muted);font-size:11px}.sm-view-controls{display:flex;flex:none;gap:2px}.sm-view-controls button{display:flex;align-items:center;justify-content:center;gap:6px;min-width:28px;height:28px;border-radius:4px}.sm-view-controls button:hover{background:var(--sb-soft)}.sm-notice{color:var(--sb-accent);font-size:12px}@media print{.sm-footer,.sm-notice{display:none}.sm-viewport{overflow:visible;background:none}}.sm-block .sm-root .sm-node:hover{background:var(--sb-accent);color:var(--sb-surface)}.editor-bubble[data-editor-keyboard-scope=mindmap]{--editor-line: var(--line);--editor-soft: var(--accent-soft);font-family:var( --font-sans, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif );font-size:12px;font-weight:400;line-height:1;letter-spacing:0}.editor-bubble[data-editor-keyboard-scope=mindmap] .editor-tool{font:inherit}.editor-bubble[data-editor-keyboard-scope=mindmap] .sm-labeled-action{width:auto;padding:0 7px;gap:4px;color:var(--text);white-space:nowrap}.editor-bubble[data-editor-keyboard-scope=mindmap] .editor-tool svg{display:block;flex:none}.sm-block>.sb-header>.sb-actions{flex-wrap:nowrap;gap:2px;border:1px solid var(--sb-line);box-shadow:0 2px 8px #00000008;pointer-events:none}.sm-block:hover>.sb-header>.sb-actions,.sm-block>.sb-header>.sb-actions:focus-within{opacity:1;pointer-events:auto}.sm-block>.sb-header.has-caption>.sb-heading{padding-right:78px}.sm-block .sb-actions .sb-icon-button[aria-pressed=true]{color:var(--sb-accent);background:var(--sb-accent-soft)}body:has([role=menu]) .sm-block>.sb-header>.sb-actions{opacity:0;pointer-events:none}@media(hover:none){.sm-block>.sb-header>.sb-actions{opacity:1;pointer-events:auto}}@media print{.sm-block>.sb-header>.sb-actions{display:none}}
|
|
2
|
+
`);var t=W(me(),1);function Je({data:Z,onChange:R,readOnly:Me=!1}){let a=ke(Le),n=(0,r.useMemo)(()=>X(Z),[Z]),d=!Me&&!!R,L=n.nodes.find(e=>e.parentId===null),[i,M]=(0,r.useState)(L.id),[H,k]=(0,r.useState)(!1),[c,z]=(0,r.useState)(null),D=(0,r.useRef)(null),K=(0,r.useRef)(!0),[Ee,Se]=(0,r.useState)(null),[_,ze]=(0,r.useState)(null),f=!d&&_?.layout||n.layout||"radial",g=!d&&_?.direction||n.direction||"right",x=Ee??new Set(n.nodes.filter(e=>e.collapsed).map(e=>e.id)),u=(0,r.useMemo)(()=>ye({...n,layout:f,direction:g},x),[n,f,g,JSON.stringify([...x])]),[h,P]=(0,r.useState)(1),[q,$]=(0,r.useState)(null),G=(0,r.useRef)(null),E=(0,r.useRef)(null),v=(0,r.useRef)(null),N=(0,r.useRef)(new Map),U=(0,r.useId)(),p=(0,r.useRef)({past:[],future:[],expected:null}),[Q,F]=(0,r.useState)(""),y=n.nodes.find(e=>e.id===i)??L,Y=O(n,y.id).length>0,ee=()=>{let e=E.current;e&&P(Math.max(.15,Math.min(1,(e.clientWidth-20)/u.width,(e.clientHeight-20)/u.height)))};(0,r.useLayoutEffect)(ee,[f,g]),(0,r.useEffect)(()=>{let e=JSON.stringify(n);p.current.expected!==null&&p.current.expected!==e&&(p.current.past=[],p.current.future=[]),p.current.expected=e},[n]),(0,r.useEffect)(()=>{!u.nodes.some(e=>e.id===i)&&c?.id!==i&&M(L.id)},[u,i,L.id,c?.id]);let w=e=>{M(e),requestAnimationFrame(()=>{let o=N.current.get(e);o?.focus({preventScroll:!0}),o?.scrollIntoView({block:"nearest",inline:"nearest"})})};(0,r.useLayoutEffect)(()=>{c&&(v.current?.focus(),K.current?v.current?.select():v.current?.setSelectionRange(c.value.length,c.value.length),v.current?.scrollIntoView({block:"nearest",inline:"nearest"}))},[c?.id,n.nodes.length]),(0,r.useLayoutEffect)(()=>{if(!H||c||!d){$(null);return}let e=()=>{let s=N.current.get(i),l=E.current;if(!s||!l)return;let b=s.getBoundingClientRect(),m=l.getBoundingClientRect();$(b.bottom<m.top||b.top>m.bottom||b.right<m.left||b.left>m.right?null:{left:Math.max(m.left,Math.min(m.right,b.left+b.width/2)),top:Math.max(m.top,b.top)})};e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e);let o=new ResizeObserver(e);return E.current&&o.observe(E.current),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),o.disconnect()}},[H,c,d,i,u,h]);let C=e=>{!d||e===n||(X(e),p.current.past=[...p.current.past.slice(-99),n],p.current.future=[],p.current.expected=JSON.stringify(e),F(""),R?.(e))},te=e=>{let o=e==="tree"&&f==="tree"?g==="right"?"left":"right":g;e===f&&o===g||(d?C({...n,layout:e,direction:o}):ze({layout:e,direction:o}))},I=(e=!1)=>{let s=(e?p.current.future:p.current.past).pop();!s||!d||((e?p.current.past:p.current.future).push(n),p.current.expected=JSON.stringify(s),R?.(s),w(s.nodes.some(l=>l.id===i)?i:L.id))},T=(e=i,o)=>{if(!d)return;let s=n.nodes.find(l=>l.id===e);s&&(D.current=e,K.current=o===void 0,$(null),z({id:e,value:o??s.label}))},J=(e=!1)=>{if(!c||D.current!==c.id)return;let o=c.value.trim();if(!e&&!o){F(a("enterNodeName")),v.current?.focus();return}D.current=null,z(null),!e&&o!==n.nodes.find(s=>s.id===c.id)?.label&&C({...n,nodes:n.nodes.map(s=>s.id===c.id?{...s,label:o}:s)}),w(c.id)},B=(e,o=!1)=>{if(!d)return;if(n.nodes.length>=S){F(a("nodeLimit",{count:S}));return}let s=crypto.randomUUID(),l=he(n,i,s,e,o);C(l),M(s),D.current=s,K.current=!0,z({id:s,value:l.nodes.find(b=>b.id===s).label})},ne=()=>{!d||y.parentId===null||(C(fe(n,i)),w(y.parentId))},V=()=>{if(!Y)return;let e=new Set(x);e.has(i)?e.delete(i):e.add(i),d?C({...n,nodes:n.nodes.map(o=>o.id===i?{...o,collapsed:e.has(i)}:o)}):Se(e),w(i)},De=e=>{if(e.nativeEvent.isComposing||e.keyCode===229||e.target.closest("input, .sm-view-controls"))return;let o=e.metaKey||e.ctrlKey,s=e.target.closest(".editor-bubble")?.id===U,l=e.target.closest(".sb-header .sb-actions");if(s||l?!o:!e.target.closest(".sm-node"))return;let b=!0;if(o&&e.key.toLowerCase()==="z"&&d)I(e.shiftKey);else if(o&&e.key.toLowerCase()==="y"&&d)I(!0);else if(o||e.altKey)b=!1;else if(e.key==="Tab"&&d&&!e.shiftKey)B("child");else if(e.key==="Tab"&&d&&e.shiftKey)C(ge(n,i)),w(i);else if(e.key==="Enter"&&d)B("sibling",e.shiftKey);else if(e.key==="F2"&&d)T();else if((e.key==="Delete"||e.key==="Backspace")&&d)ne();else if(e.key===" ")V();else if(e.key==="ArrowLeft")y.parentId&&w(y.parentId);else if(e.key==="ArrowRight")if(x.has(i))V();else{let m=O(n,i)[0];m&&w(m.id)}else if(e.key==="ArrowUp"||e.key==="ArrowDown"){let m=n.nodes.filter(j=>j.parentId===y.parentId),Ie=m.findIndex(j=>j.id===i),oe=m[Ie+(e.key==="ArrowUp"?-1:1)];oe&&w(oe.id)}else e.key==="Escape"?(k(!1),e.target.blur()):e.key.length===1&&d?T(i,e.key):b=!1;b&&(e.preventDefault(),e.stopPropagation())};return(0,t.jsxs)("section",{ref:G,className:"sb-block sm-block","aria-label":Ne(n.title,a("mindmap")),contentEditable:!1,"data-editor-keyboard-scope":"mindmap","data-mindmap-layout":f,"data-mindmap-direction":g,onClick:e=>e.stopPropagation(),onKeyDown:De,onFocus:e=>{e.target.closest(".sm-node, .sm-node-input")&&k(!0)},onBlur:e=>{!G.current?.contains(e.relatedTarget)&&!e.relatedTarget?.closest?.(`[id="${U}"]`)&&k(!1)},onContextMenu:()=>k(!1),children:[(0,t.jsxs)(Ce,{title:n.title,defaultTitle:"\u601D\u7EF4\u5BFC\u56FE",description:n.description,children:[(0,t.jsx)("button",{type:"button",className:"sb-icon-button","aria-label":a("radialLayout"),title:a("radialLayout"),"aria-pressed":f==="radial","data-surface-ui":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>te("radial"),children:(0,t.jsx)(de,{size:16})}),(0,t.jsx)("button",{type:"button",className:"sb-icon-button","aria-label":a("treeLayout"),title:a(g==="right"?f==="tree"?"treeLayout.rightToggle":"treeLayout.right":f==="tree"?"treeLayout.leftToggle":"treeLayout.left"),"aria-pressed":f==="tree","data-surface-ui":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>te("tree"),children:(0,t.jsx)(re,{size:16,style:{transform:g==="left"?"scaleX(-1)":void 0}})})]}),(0,t.jsx)("div",{ref:E,className:"sm-viewport",style:{height:n.height??460},children:(0,t.jsx)("div",{className:"sm-scroll-space",style:{width:u.width*h,height:u.height*h,minWidth:"100%",minHeight:"100%"},children:(0,t.jsxs)("div",{className:"sm-map",role:"tree","aria-label":a("nodes"),style:{width:u.width,height:u.height,transform:`scale(${h})`,left:`max(0px, calc(50% - ${u.width*h/2}px))`,top:`max(0px, calc(50% - ${u.height*h/2}px))`},children:[(0,t.jsx)("svg",{className:"sm-connections",width:u.width,height:u.height,"aria-hidden":"true",children:u.nodes.filter(e=>e.parentId).map(e=>{let o=u.nodes.find(s=>s.id===e.parentId);return(0,t.jsx)("path",{className:`sm-branch-${e.color}`,d:we(o,e)},e.id)})}),u.nodes.map(e=>{let o=O(n,e.id).length,s=c?.id===e.id;return(0,t.jsx)("div",{className:`sm-node-wrap sm-branch-${e.color}${e.parentId===null?" sm-root":""}`,style:{left:e.x,top:e.y,width:e.width,minHeight:e.height,"--sm-node-height":`${e.height}px`},children:s?(0,t.jsx)("input",{ref:v,className:"sm-node-input","aria-label":a("nodeName"),maxLength:200,value:c.value,onChange:l=>z({id:e.id,value:l.target.value}),onBlur:()=>J(),onKeyDown:l=>{l.stopPropagation(),!(l.nativeEvent.isComposing||l.keyCode===229)&&((l.key==="Enter"||l.key==="Tab")&&(l.preventDefault(),J()),l.key==="Escape"&&(l.preventDefault(),J(!0)))}}):(0,t.jsxs)("button",{type:"button",ref:l=>{l?N.current.set(e.id,l):N.current.delete(e.id)},className:`sm-node${H&&i===e.id?" is-selected":""}`,role:"treeitem","aria-level":e.depth+1,"aria-selected":i===e.id,"aria-expanded":o?!x.has(e.id):void 0,tabIndex:i===e.id?0:-1,onFocus:()=>M(e.id),onClick:l=>{l.currentTarget.focus({preventScroll:!0}),M(e.id),k(!0)},onDoubleClick:()=>T(e.id),children:[(0,t.jsx)("span",{children:e.label}),o>0&&x.has(e.id)&&(0,t.jsxs)("span",{className:"sm-count",children:["+",o]})]})},e.id)})]})})}),(0,t.jsx)("div",{className:"sm-footer",children:(0,t.jsxs)("div",{className:"sm-view-controls",role:"group","aria-label":a("view"),children:[(0,t.jsx)("button",{type:"button","aria-label":a("zoomOut"),disabled:h<=.15,onClick:()=>P(Math.max(.15,h/1.2)),children:(0,t.jsx)(le,{size:15})}),(0,t.jsxs)("button",{type:"button","aria-label":a("fit"),onClick:ee,children:[(0,t.jsx)(se,{size:15}),(0,t.jsxs)("span",{children:[Math.round(h*100),"%"]})]}),(0,t.jsx)("button",{type:"button","aria-label":a("zoomIn"),disabled:h>=2,onClick:()=>P(Math.min(2,h*1.2)),children:(0,t.jsx)(A,{size:15})})]})}),Q&&(0,t.jsx)("p",{role:"status",className:"sm-notice",children:Q}),q&&d&&!c&&(0,t.jsxs)(ve,{id:U,anchor:q,anchorElement:N.current.get(i),label:a("nodeActions"),keyboardScope:"mindmap",onEscape:()=>{k(!1),N.current.get(i)?.blur()},children:[(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("editNode"),title:a("editNode"),onClick:()=>T(),children:(0,t.jsx)(pe,{size:16})}),(0,t.jsx)("span",{className:"toolbar-divider"}),(0,t.jsxs)("button",{className:"editor-tool sm-labeled-action",type:"button","aria-label":a("newChild"),title:a("newChild"),disabled:n.nodes.length>=S,onClick:()=>B("child"),children:[(0,t.jsx)(A,{size:16}),(0,t.jsx)("span",{children:a("child")})]}),(0,t.jsxs)("button",{className:"editor-tool sm-labeled-action",type:"button","aria-label":a("newSibling"),title:a("newSibling"),disabled:n.nodes.length>=S||y.parentId===null,onClick:()=>B("sibling"),children:[(0,t.jsx)(A,{size:16}),(0,t.jsx)("span",{children:a("sibling")})]}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":x.has(i)?a("expandBranch"):a("collapseBranch"),title:a("toggleBranch"),disabled:!Y,onClick:V,children:(0,t.jsx)(ie,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("undoAction"),title:a("undo"),disabled:!p.current.past.length,onClick:()=>I(),children:(0,t.jsx)(be,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("redoAction"),title:a("redo"),disabled:!p.current.future.length,onClick:()=>I(!0),children:(0,t.jsx)(ce,{size:16})}),(0,t.jsx)("button",{className:"editor-tool",type:"button","aria-label":a("deleteNodeAndChildren"),title:a("deleteBranch"),disabled:y.parentId===null,onClick:ne,children:(0,t.jsx)(ue,{size:16})})]})]})}export{Je as MindmapBlock};
|