@fgbg/mdocs 1.3.24 → 1.3.26
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/agent-skills/changelog/SKILL.md +16 -0
- package/dist/web/assets/{AgentChatPanel-NcsMAhWM.js → AgentChatPanel-TJVgAwlH.js} +3 -3
- package/dist/web/assets/{AgentSkillFormCard-B99CncJO.js → AgentSkillFormCard-3ZpgH1RY.js} +2 -2
- package/dist/web/assets/{AiWriteWorkbench-DomEbwzU.js → AiWriteWorkbench-B9HrhEmd.js} +4 -4
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-BhsjOCtK.js → DiagramEditor-NtNY3sZL-CyddeNUo.js} +1 -1
- package/dist/web/assets/DocChrome-C5syeHbQ.js +11 -0
- package/dist/web/assets/DocumentEditor-mG7hvAWj.js +1 -0
- package/dist/web/assets/{HtmlEditor-g2NNYmv2.js → HtmlEditor-DABDor1R.js} +1 -1
- package/dist/web/assets/{MergeView-GL7xdFM4.js → MergeView-BczHMfos.js} +1 -1
- package/dist/web/assets/{PlaygroundPage-Bb4X1bvp.js → PlaygroundPage-zg5tjWQs.js} +1 -1
- package/dist/web/assets/SettingsPage-BU0is_e7.js +1 -0
- package/dist/web/assets/SheetEditor-4nXVP3NN.js +16 -0
- package/dist/web/assets/{Toolbar-Bk3LKZfg.js → Toolbar-xB4u1mY1.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-zafJ6beK.js → VisitorPickerModal-Djpm5bTf.js} +1 -1
- package/dist/web/assets/{check-BMeXlsHC.js → check--tqH9AMO.js} +1 -1
- package/dist/web/assets/{copy-CCsiKd_j.js → copy-5mwMd6zK.js} +1 -1
- package/dist/web/assets/{docPlainCharCount-BjBZaoHy.js → docPlainCharCount-CTaZfi-M.js} +1 -1
- package/dist/web/assets/{index-3B7_9QOQ.js → index-CINfyH_g.js} +17 -17
- package/dist/web/assets/index-DCgILSIv.css +1 -0
- package/dist/web/assets/{italic-B6bGjo1_.js → italic-phhei7W3.js} +1 -1
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-9HAADQ7Y.js → meta2dEngine-BD2XbzaV-BDjANcdr.js} +1 -1
- package/dist/web/assets/{plus-BD44y7Zf.js → plus-BxZJ-Mya.js} +1 -1
- package/dist/web/assets/{react-2y9P8xJn.js → react-8gAAnUbI.js} +5 -5
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/assets/DocChrome-wfHrPEB7.js +0 -11
- package/dist/web/assets/DocumentEditor-CCuqHlmF.js +0 -1
- package/dist/web/assets/SettingsPage-B4INgMK-.js +0 -1
- package/dist/web/assets/SheetEditor-Cka57s62.js +0 -16
- package/dist/web/assets/index-BF754bDB.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/scss-OYdSNvt2.js","assets/vue-DVfSmUF7.js","assets/typescript-BPQ3VLAy.js","assets/json-Cp-IABpG.js","assets/svelte-DZMnMd3x.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-BGX7qA9Y.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/php-Dhbhpdrm.js","assets/shellsession-BADoaaVG.js","assets/nginx-BpAMiNFr.js","assets/meta2dEngine-BD2XbzaV-
|
|
2
|
-
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as yn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as xn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as pn,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/scss-OYdSNvt2.js","assets/vue-DVfSmUF7.js","assets/typescript-BPQ3VLAy.js","assets/json-Cp-IABpG.js","assets/svelte-DZMnMd3x.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-BGX7qA9Y.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/php-Dhbhpdrm.js","assets/shellsession-BADoaaVG.js","assets/nginx-BpAMiNFr.js","assets/meta2dEngine-BD2XbzaV-BDjANcdr.js","assets/meta2d-DP4Vt_ZE.js","assets/react-vendor-BVS1XoFi.js","assets/editor-DBWWidi3.js","assets/ui-CEFkTVnG.js","assets/motion-BAXVQJfN.js","assets/diagram-BF8g9yg4.js","assets/index-CINfyH_g.js","assets/index-DCgILSIv.css","assets/plus-BxZJ-Mya.js","assets/check--tqH9AMO.js","assets/copy-5mwMd6zK.js","assets/DiagramEditor-NtNY3sZL-CyddeNUo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as yn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as xn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as pn,b7 as gw,b8 as Td,aI as bw}from"./index-CINfyH_g.js";import{P as Bm}from"./plus-BxZJ-Mya.js";import{C as yw}from"./check--tqH9AMO.js";import{C as xw}from"./copy-5mwMd6zK.js";/**
|
|
3
3
|
* @license lucide-react v0.562.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -355,7 +355,7 @@ $$
|
|
|
355
355
|
`,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:n,inlineMath:r}};function n(s,o,a,u){const l=s.value||"",h=a.createTracker(u),d="$".repeat(Math.max(t6(l,"$")+1,2)),g=a.enter("mathFlow");let m=h.move(d);if(s.meta){const y=a.enter("mathFlowMeta");m+=h.move(a.safe(s.meta,{after:`
|
|
356
356
|
`,before:m,encode:["$"],...h.current()})),y()}return m+=h.move(`
|
|
357
357
|
`),l&&(m+=h.move(l+`
|
|
358
|
-
`)),m+=h.move(d),g(),m}function r(s,o,a){let u=s.value||"",l=1;for(t||l++;new RegExp("(^|[^$])"+"\\$".repeat(l)+"([^$]|$)").test(u);)l++;const h="$".repeat(l);/[^ \r\n]/.test(u)&&(/^[ \r\n]/.test(u)&&/[ \r\n]$/.test(u)||/^\$|\$$/.test(u))&&(u=" "+u+" ");let d=-1;for(;++d<a.unsafe.length;){const g=a.unsafe[d];if(!g.atBreak)continue;const m=a.compilePattern(g);let y;for(;y=m.exec(u);){let w=y.index;u.codePointAt(w)===10&&u.codePointAt(w-1)===13&&w--,u=u.slice(0,w)+" "+u.slice(y.index+1)}}return h+u+h}function i(){return"$"}}const lM={tokenize:cM,concrete:!0,name:"mathFlow"},Wg={tokenize:hM,partial:!0};function cM(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return a;function a(M){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),u(M)}function u(M){return M===36?(e.consume(M),o++,u):o<2?n(M):(e.exit("mathFlowFenceSequence"),Ke(e,l,"whitespace")(M))}function l(M){return M===null||ve(M)?d(M):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(M))}function h(M){return M===null||ve(M)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(M)):M===36?n(M):(e.consume(M),h)}function d(M){return e.exit("mathFlowFence"),r.interrupt?t(M):e.attempt(Wg,g,_)(M)}function g(M){return e.attempt({tokenize:v,partial:!0},_,m)(M)}function m(M){return(s?Ke(e,y,"linePrefix",s+1):y)(M)}function y(M){return M===null?_(M):ve(M)?e.attempt(Wg,g,_)(M):(e.enter("mathFlowValue"),w(M))}function w(M){return M===null||ve(M)?(e.exit("mathFlowValue"),y(M)):(e.consume(M),w)}function _(M){return e.exit("mathFlow"),t(M)}function v(M,T,D){let R=0;return Ke(M,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function F(U){return M.enter("mathFlowFence"),M.enter("mathFlowFenceSequence"),j(U)}function j(U){return U===36?(R++,M.consume(U),j):R<o?D(U):(M.exit("mathFlowFenceSequence"),Ke(M,K,"whitespace")(U))}function K(U){return U===null||ve(U)?(M.exit("mathFlowFence"),T(U)):D(U)}}}function hM(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function fM(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:dM,previous:pM,name:"mathText"};function n(r,i,s){let o=0,a,u;return l;function l(y){return r.enter("mathText"),r.enter("mathTextSequence"),h(y)}function h(y){return y===36?(r.consume(y),o++,h):o<2&&!t?s(y):(r.exit("mathTextSequence"),d(y))}function d(y){return y===null?s(y):y===36?(u=r.enter("mathTextSequence"),a=0,m(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),d):ve(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),d):(r.enter("mathTextData"),g(y))}function g(y){return y===null||y===32||y===36||ve(y)?(r.exit("mathTextData"),d(y)):(r.consume(y),g)}function m(y){return y===36?(r.consume(y),a++,m):a===o?(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",g(y))}}}function dM(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pM(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function mM(e){return{flow:{36:lM},text:{36:fM(e)}}}const gM={};function bM(e){const t=this,n=e||gM,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mM(n)),s.push(aM()),o.push(uM(n))}const Zl=Qe("plugin","markdown"),yM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function xM(e){const t=e.replace(/^<\/?/,"").replace(/\/?>$/,"").trim(),n=/^([A-Za-z][\w-]*)/.exec(t);return n?n[1].toLowerCase():""}var kM=class{constructor(e){this.root=e,this.stack=[]}push(e){this.stack.push(e)}get isReadingHTML(){return this.stack.length>0}get last(){return this.stack.at(-1)}pop(){return this.stack.pop()}};function Kg(e,t){return e!=="paragraph"?t:Array.isArray(t)?{...ke.createParagraph(),children:t}:t.type!=="paragraph"?{...ke.createParagraph(),children:[t]}:t}function Ff(e,t,n,r={}){switch(e.type){case"text":return ke.createTextNode(e.value);default:{let i=[];if("children"in e&&Array.isArray(e.children)){let s=[];for(i=e.children.reduce((o,a,u)=>{if(a.type==="html"){if(a.value.startsWith("<!--")&&a.value.endsWith("-->"))return o;const l=xM(a.value),h=a.value.startsWith("</");if(!l)return o;if(yM.has(l)){const g=r.html;if(Array.isArray(g))for(const m of g){const y=m(a,[],u);if(y)return o.push(y),o}else if(typeof g=="function"){const m=g(a,[],u);if(m)return o.push(m),o}return o}if(h){const g=n.pop();if(s.pop(),(g==null?void 0:g.tag)!==l)return Zl.warn("HTML tag mismatch:",l),g&&o.push(ke.createTextNode(g.node.value),...g.children.flat().filter(Boolean)||[]),o.push(ke.createTextNode(a.value)),o;const m=r.html,y=g.children.flat().filter(Boolean)||[];if(Array.isArray(m))for(const w of m){const _=w(g.node,y,u);if(_)return o.push(_),o}else if(typeof m=="function"){const w=m(g.node,y,u);if(w)return o.push(w),o}return g&&o.push(...g.children),o}const d={children:[],index:u,isEndTag:h,node:a,tag:l};return s.push(d),n.push(d),o}if(s.length>0){const l=n.last;return l&&l.children.push(Ff(a,u,n,r)),o}return o.push(Ff(a,u,n,r)),o},[]).filter(Boolean).flat();s.length>0;){const o=s.shift();n.pop(),i.push(ke.createTextNode(o==null?void 0:o.node.value),...o.children.flat()),i=i.flat()}}if(r[e.type]){const s=r[e.type];if(Array.isArray(s))for(const o of s){const a=o(e,i,t);if(a)return Kg(e.type,a)}else if(typeof s=="function"){const o=s(e,i,t);if(o)return Kg(e.type,o)}}return e.type==="paragraph"?{...ke.createParagraph(),children:i}:i||null}}}function wM(e){const t=n=>typeof n=="function"||Array.isArray(n)&&n.length>0;t(e.root)||(e.root=(n,r)=>({...ke.createRootNode(),children:r})),t(e.paragraph)||(e.paragraph=(n,r)=>({...ke.createParagraph(),children:r})),t(e.heading)||(e.heading=(n,r)=>{const i=`h${Math.min(Math.max(n.depth,1),6)}`;return ke.createElementNode("heading",{children:r,direction:"ltr",format:"",indent:0,tag:i})})}function Yd(e,t={}){const n=[];let r=e;const i=/---markmap---(\n?)([\S\s]*?)\n?---\/markmap---/g;let s,o=0;for(;(s=i.exec(e))!==null;){const d=`|||MARKMAP_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"markmap"}),r=r.replace(s[0],d),o++}const a=/---meta2d---(\n?)([\S\s]*?)\n?---\/meta2d---/g;for(;(s=a.exec(e))!==null;){const d=`|||META2D_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"meta2d"}),r=r.replace(s[0],d),o++}const u=g6().use(wv).use(bM).use([[M6,{singleTilde:!1}]]).parse(r);Zl.debug("Parsed MDAST:",u);const l=new kM(u);wM(t);const h=Ff(u,0,l,t);if(n.length>0){const d=m=>{if(m.type==="text"&&typeof m.text=="string"){const y=[];let w=m.text,_=!1;for(const v of n){const M=w.indexOf(v.placeholder);if(M!==-1){_=!0,M>0&&y.push({...m,text:w.slice(0,Math.max(0,M))}),y.push({type:v.type,[v.type==="markmap"?"markdown":"diagram"]:v.content,version:1});const T=w.slice(Math.max(0,M+v.placeholder.length));if(T){const D=d({...m,text:T});Array.isArray(D)?y.push(...D):y.push(D)}break}}return _?y:m}if(m.children&&Array.isArray(m.children)){const y=[];for(const w of m.children){const _=d(w);Array.isArray(_)?y.push(..._):y.push(_)}if(m.children=y.filter(Boolean),m.type==="paragraph"&&m.children.length===1&&(m.children[0].type==="markmap"||m.children[0].type==="meta2d"))return m.children[0]}return m},g=[];for(const m of h.children){const y=d(m);Array.isArray(y)?g.push(...y):g.push(y)}h.children=g.filter(Boolean)}return h}function Vg(e){return Pt(e)&&!e.hasFormat("code")}function N6(e,t,n,r,i){for(let s=0;s<i;s++)if(e[t+s]!==n[r+s])return!1;return!0}const Gg=/[!-/:-@[-`{-~\s]/;function Xg(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const s=i-r;if(N6(e,s,n,0,r)&&e[s+r]!==" ")return s}return-1}function Jg(e,t){const n={};for(const r of e){const i=t(r);i&&(n[i]?n[i].push(r):n[i]=[r])}return n}let D6=/[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;try{D6=new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]","u")}catch{}function vM(e){return D6.test(e)}function SM(e){if(de(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=tk(t,"previous");if(r)if(nk(r))n=r.origin;else{const i=pb(r,rk(Sn(),"next").getFlipped());for(const s of i)if(Pt(s.origin)){n=s.origin;break}else if(fn(s.origin)&&!s.origin.isInline())break}if(n&&Pt(n)){const i=n.getFormat(),s=n.getStyle();(e.format!==i||e.style!==s)&&(e.format=i,e.style=s,e.dirty=!0)}}}function CM(e,t,n){e.dispatchCommand(ek,{nodes:t,selection:n})||(n.insertNodes(t),SM(n))}function _M(e){const t={};if(!e)return t;const n=e.split(";");for(const r of n)if(r!==""){const[i,s]=r.split(/:([^]+)/);i&&s&&(t[i.trim()]=s.trim())}return t}const EM=new Map;function TM(e){const t=e.getStyle(),n=_M(t);EM.set(t,n)}function I6(e){const t=[];for(const n of e){const r=X7(n);Pt(r)&&TM(r),t.push(r)}return t}function AM(e,t,n){CM(e,I6(t.children),n)}function L6(e){return e===null?!1:qn(e)||Hr(e)||So(e)}function MM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,trigger:a}of r){const u=s.match(o);if(i===a&&u&&u[0].length===(i==="enter"||u[0].endsWith(" ")?n:n-1))return!0}return!1}function NM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,replace:a,trigger:u}of r){const l=s.match(o);if(i===u&&l&&l[0].length===(i==="enter"||l[0].endsWith(" ")?n:n-1)){const h=t.getNextSiblings(),[d,g]=t.splitText(n);if(a(e,g?[g,...h]:h,l,!1)!==!1)return d.remove(),!0}}return!1}function DM(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(!i)return!1;t<r.length&&(r=r.slice(0,t));for(const s of i){if(!s.replace||!s.regExp)continue;const o=r.match(s.regExp);if(o===null)continue;const a=o.index||0,u=a+o[0].length;let l;return a===0?[l]=e.splitText(u):[,l]=e.splitText(a,u),l.selectNext(0,0),s.replace(l,o),!0}return!1}function IM(e,t,n){const r=e.getTextContent(),i=t-1,s=r[i],o=n[s];if(!o)return!1;for(const a of o){const{tag:u}=a,l=u.length,h=i-l+1;if(l>1&&!N6(r,h,u,0,l)||r[h-1]===" ")continue;const d=r[i+1];if(a.intraword===!1&&d&&!Gg.test(d))continue;const g=e;let m=g,y=Xg(r,h,u),w=m;for(;y<0&&(w=w.getPreviousSibling())&&!Qn(w);)if(Pt(w)){if(w.hasFormat("code"))continue;const K=w.getTextContent();m=w,y=Xg(K,K.length,u)}if(y<0||m===g&&y+l===h)continue;const _=m.getTextContent();if(y>0&&_[y-1]===s)continue;const v=_[y-1];if(a.intraword===!1&&v&&!Gg.test(v))continue;const M=g.getTextContent(),T=M.slice(0,h)+M.slice(i+1);g.setTextContent(T);const D=m===g?T:_;m.setTextContent(D.slice(0,y)+D.slice(y+l));const R=ce(),F=Lo();je(F);const j=i-l*(m===g?2:1)+1;if(F.anchor.set(m.__key,y,"text"),F.focus.set(g.__key,j,"text"),a.process){if(a.process(F)===!1){const K=ze(m.__key),U=ze(g.__key);Pt(K)&&K.setTextContent(_),U!==K&&Pt(U)&&U.setTextContent(M),je(e.selectEnd());continue}return!0}else if(a.format){for(const K of a.format)F.hasFormat(K)||F.formatText(K);F.anchor.set(F.focus.key,F.focus.offset,F.focus.type);for(const K of a.format)F.hasFormat(K)&&F.toggleFormat(K);de(R)&&(F.format=R.format)}else{je(R);continue}return!0}return!1}Ot();const Lt=uu("MarkdownShortCutService");var LM=class{constructor(e){this.kernel=e,this.elementTransformers=[],this.textFormatTransformers=[],this.textMatchTransformers=[],this.logger=Qe("service","markdown"),this._markdownWriters={},this._markdownReaders=[{},{},{}],this._textFormatTransformersByTrigger=null,this._textMatchTransformersByTrigger=null}get markdownWriters(){return this._markdownWriters}get markdownReaders(){return this._markdownReaders.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]||(e[n]=[]);const r=e[n],i=t[n];r.push(...i)}),e),{})}get textMatchTransformersByTrigger(){return this._textMatchTransformersByTrigger||(this._textMatchTransformersByTrigger=Jg(this.textMatchTransformers,({trigger:e})=>e)),this._textMatchTransformersByTrigger}get textFormatTransformersByTrigger(){return this._textFormatTransformersByTrigger||(this._textFormatTransformersByTrigger=Jg(this.textFormatTransformers,({tag:e})=>e.at(-1))),this._textFormatTransformersByTrigger}registerMarkdownShortCut(e){switch(e.type){case"element":this.elementTransformers.push(e);break;case"text-format":this.textFormatTransformers.push(e);break;case"text-match":this.textMatchTransformers.push(e);break;default:throw new Error(`Unknown transformer type: ${e}`)}}registerMarkdownShortCuts(e){for(const t of e)this.registerMarkdownShortCut(t)}testTransformers(e,t,n,r){if(MM(e,t,n,this.elementTransformers,r))return!0;if(r==="enter"){const i=t.getTextContent(),s=i[n-1],o=this.textMatchTransformersByTrigger[s];if(o){const a=n<i.length?i.slice(0,n):i;for(const u of o)if(u.regExp&&u.regExp.test(a))return!0}}return!1}runTransformers(e,t,n,r){return!!(NM(e,t,n,this.elementTransformers,r)||DM(t,n,this.textMatchTransformersByTrigger)||IM(t,n,this.textFormatTransformersByTrigger))}registerMarkdownWriter(e,t){var n;if(!this._markdownWriters[e]){this._markdownWriters[e]=t;return}if((n=this.kernel)!=null&&n.isHotReloadMode()){this.logger.warn(`🔄 Hot reload: markdown writer "${e}"`),this._markdownWriters[e]=t;return}throw new Error(`Markdown writer for type "${e}" is already registered.`)}registerMarkdownReader(e,t,n=2){var r;this._markdownReaders[n][e]||(this._markdownReaders[n][e]=[]),this._markdownReaders[n]&&((r=this._markdownReaders[n][e])==null||r.push(t))}parseMarkdownToLexical(e){return Yd(e,this.markdownReaders)}insertIRootNode(e,t,n){AM(e,t,n)}};function hU(e=0){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).getBoundingClientRect();if(n.height===0&&n.width===0){const i=t.focusNode;if(i){const s=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;s&&s.scrollIntoView({behavior:"smooth",block:"center"})}return}const r=n.top+n.height/2-window.innerHeight/2+e;window.scrollBy({behavior:"smooth",top:r})}function FM(e){if(!(e instanceof HTMLElement)||e.scrollHeight<=e.clientHeight+1)return!1;const t=window.getComputedStyle(e).overflowY||e.style.overflowY||e.style.overflow;return t==="auto"||t==="scroll"||t==="overlay"}function OM(){var n;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).getBoundingClientRect();if(t.width===0&&t.height===0){const r=e.focusNode;return r?((n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)==null?void 0:n.getBoundingClientRect())??null:null}return t}function zM(e=96){if(typeof window>"u"||typeof document>"u")return;const t=OM();if(!t)return;let n=document.activeElement;if(n instanceof Element)for(;n&&n!==document.body&&n!==document.documentElement;){if(FM(n)){const r=n.getBoundingClientRect(),i=r.bottom-e;t.bottom>i&&(n.scrollTop+=t.bottom-i);const s=r.top+Math.min(48,e/2);t.top<s&&(n.scrollTop-=s-t.top)}n=n.parentElement}}lu();var RM=class extends Nd{read(e,t,n){let r;typeof t=="string"?r=JSON.parse(t):r=t;const i=s=>{for(let o=0;o<s.children.length;o++){const a=s.children[o];"children"in a&&Array.isArray(a.children)&&i(a),a.type==="text"&&"format"in a&&typeof a.format=="number"&&(a.format&Mm)>0&&(s.children[o]={children:[{...a,format:a.format&~Mm}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},s.children.splice(o+1,0,df))}};i(r.root),e.setEditorState(e.parseEditorState({root:r.root}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var r,i,s;const n=ce();if(!n)return null;if(de(n)){const o=n.getNodes(),a=o.length-1,u=n.anchor,l=n.focus,h=u.isBefore(l),d=o[0],g=o[a],[m,y]=ab(n);let w=[];const _=[];for(let v=0;v<o.length;v++){const M=o[v];if(fn(M)){const T={...M.exportJSON(),$key:M.getKey()};for(let R=0;R<_.length;R++){const F=_[R],j=ze(F.$key);M.isParentOf(j)&&(T.children.push(F),_.splice(R,1),R--)}let D=!1;for(let R=w.length-1;R>=0;R--)if((r=ze(w[R].$key))!=null&&r.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T),w.push(T)}else if(Pt(M)){const T={...M.exportJSON(),$key:M.getKey()};M===d?M===g?(u.type!=="element"||l.type!=="element"||l.offset===u.offset)&&(T.text=m<y?T.text.slice(m,y):T.text.slice(y,m)):T.text=h?T.text.slice(m):T.text.slice(y):M===g&&(T.text=h?T.text.slice(0,y):T.text.slice(0,m));let D=!1;for(let R=w.length-1;R>=0;R--)if((i=ze(w[R].$key))!=null&&i.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}else{const T={...M.exportJSON(),$key:M.getKey()};let D=!1;for(let R=w.length-1;R>=0;R--)if((s=ze(w[R].$key))!=null&&s.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}}return _}return n.getNodes().map(o=>ff(o))}):e.read(()=>({root:ff(Sn())}))}};rn();var PM=class extends Nd{read(e,t){if(typeof t!="string")throw new Error("Invalid data type "+typeof t);const n=t.split(/\n/g),r=ke.createRootNode();n.forEach(i=>{const s=ke.createParagraph();if(i){const o=ke.createTextNode(i);ke.appendChild(s,o)}ke.appendChild(r,s)}),e.setEditorState(e.parseEditorState({root:r}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{const n=ce();return n?n.getTextContent().replaceAll("\uFEFF",""):null}):e.getEditorState().read(()=>Sn().getTextContent().replaceAll("\uFEFF",""))}};kr();function BM(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function $M(e){return gt(e.registerCommand(ou,()=>{if(cb){const t=document.getSelection();if(t!=null&&t.anchorNode){const n=BM(t.anchorNode);if(n!=null&&n.hasAttribute("data-lexical-linebreak")&&n.parentElement){const r=n.parentElement;return e.update(()=>{const i=u9(r,e);i&&i.selectEnd()}),!0}}}return!1},Fn))}const jM=["color","background-color"];function qM(e){const t=e.trim();return!t||t.length>128||/["'<>\\]|url\s*\(|expression\s*\(|@import/i.test(t)?!1:/^(#[\dA-Fa-f]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[A-Za-z]+)$/.test(t)}function HM(e){if(!(e!=null&&e.trim()))return{};const t={};for(const n of e.split(";")){if(!n.trim())continue;const r=n.indexOf(":");if(r<0)continue;const i=n.slice(0,r).trim().toLowerCase(),s=n.slice(r+1).trim();jM.includes(i)&&qM(s)&&(i==="color"&&(t.color=s),i==="background-color"&&(t["background-color"]=s))}return t}function Ql(e){const t=HM(e),n=[];return t.color&&n.push(`color: ${t.color}`),t["background-color"]&&n.push(`background-color: ${t["background-color"]}`),n.join("; ")}function UM(e){if(!/^<span\b/i.test(e.trim()))return"";const t=/\bstyle\s*=\s*"([^"]*)"/i.exec(e);if(t)return Ql(t[1]);const n=/\bstyle\s*=\s*'([^']*)'/i.exec(e);return n?Ql(n[1]):""}rn();function WM(e){e.registerMarkdownReader("blockquote",(t,n)=>ke.createElementNode("quote",{children:n,direction:"ltr",format:"",indent:0,version:1})),e.registerMarkdownReader("strong",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r))),e.registerMarkdownReader("emphasis",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r))),e.registerMarkdownReader("delete",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|J7),r))),e.registerMarkdownReader("subscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Y7),r))),e.registerMarkdownReader("superscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Z7),r))),e.registerMarkdownReader("html",(t,n)=>{if(["<ins>","<u>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Q7),r));if(["<em>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r));if(["<strong>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r));if(/^<span\b/i.test(t.value.trim())){const r=UM(t.value);return r?n.map(i=>(ke.isTextNode(i)&&(i.style=Ql([i.style,r].filter(Boolean).join("; "))),i)):!1}return!1})}function F6(e){const t=e.target;if(!(t instanceof Node))return null;const n=t.nodeType===Node.TEXT_NODE?t.parentElement:t;return n!=null&&n.closest?n:null}function O6(e){const t=F6(e);return t?!!t.closest('textarea, input:not([type="hidden"]), select'):!1}function KM(e){const t=F6(e);return t?!!t.closest(".cm-editor, .cm-content, .CodeMirror"):!1}const VM=({clipboardData:e})=>{const t=e.items;for(const n of t)if(n.kind==="file")return"skip";return"next"},GM=({clipboardData:e,config:t,editor:n,event:r})=>{if(!t.pasteVSCodeAsCodeBlock)return"next";const i=e.getData("vscode-editor-data");if(!i)return"next";try{const s=JSON.parse(i),o=s.mode||s.language||"plaintext",a=e.getData("text/plain");return a?(r.preventDefault(),n.update(()=>{if(!de(ce()))return;const u=di(o,a);_n([u]);const l=yn();l.add(u.getKey()),je(l)}),"handled"):"next"}catch{return"next"}},XM=({clipboardData:e,editor:t,event:n})=>{const r=e.getData("text/plain");return r?(n.preventDefault(),t.dispatchCommand(sk,r),"handled"):"skip"};function JM(e,t){for(const n of t){const r=n(e);if(r==="handled")return!0;if(r==="skip")return!1}return!1}Es();Ot();const YM=Qe("plugin","common");function Yg(e,t,n){const r=e.getParent();let i=n,s=e;return r!==null&&(t&&n===0?(i=s.getIndexWithinParent(),s=r):!t&&n===s.getChildrenSize()&&(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(t?i-1:i)}function ZM(e){if(!xn(e))return!1;const t=e.getParent();if(!mt(t))return!1;let n=t.getLastChild();do{if(Qn(n))return!1;if(n===e)return t;n=n==null?void 0:n.getPreviousSibling()}while(n!==e&&n);return n===e?t:!1}function Zg(e,t){var r;const n=e.offset;if(e.type==="element")return Yg(e.getNode(),t,n);{const i=e.getNode();if(t&&n===0||!t&&n===i.getTextContentSize()){const s=t?i.getPreviousSibling():i.getNextSibling();return s===null?Yg(i.getParentOrThrow(),t,i.getIndexWithinParent()+(t?0:1)):s}else if(!t&&ZM(i))return((r=i.getParent())==null?void 0:r.getNextSibling())||null}return null}function Qg(e,t){let n=e.getNode();for(;n!==null&&n.isInline();)n=n.getParent();if(!n)return null;let r=t?n.getPreviousSibling():n.getNextSibling();for(;!r&&!qn(n);){if(n=n.getParent(),!n)return null;r=t?n.getPreviousSibling():n.getNextSibling()}return r||null}function QM(e){const t=e.focus;return t.key==="root"&&t.offset===Sn().getChildrenSize()}function eN(e){return e.registerCommand(Il,t=>{const n=e.getEditorState().read(()=>{const r=ce();if(!de(r)||!r.isCollapsed())return!1;const i=r.anchor;if(i.offset!==0)return!1;const s=i.getNode();if(Pt(s)){if(s.getPreviousSibling())return!1;const o=s.getParentOrThrow();return _o(o)?o:!1}return _o(s)?s:!1});return n?(t.stopImmediatePropagation(),t.preventDefault(),t.stopPropagation(),e.update(()=>{const r=hn();n.replace(r,!0),r.select(0,0)}),!0):!1},Ma)}function tN(e,t,n){const{enableHotkey:r=!0}=n||{};return gt(t.registerHotkey(Nt.PasteAsPlainText,async()=>{try{const i=await navigator.clipboard.readText();e.update(()=>{const s=ce();de(s)&&s.insertText(i)})}catch(i){YM.error("❌ Failed to paste as plain text:",i)}},{enabled:r,preventDefault:!0,stopPropagation:!0}),t.registerHotkey(Nt.Bold,()=>e.dispatchCommand(aa,"bold"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Italic,()=>e.dispatchCommand(aa,"italic"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Underline,()=>e.dispatchCommand(aa,"underline"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Strikethrough,()=>e.dispatchCommand(aa,"strikethrough"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Undo,()=>e.dispatchCommand(db,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Redo,()=>e.dispatchCommand(fb,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHighCommand(ys,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0)return o[0].selectPrevious(),i.preventDefault(),!0}else if(de(s)){const o=Zg(s.focus,!0),a=o||Qg(s.focus,!0);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectEnd(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(Co,i=>{const s=ce();if(de(s)){if(!s.isCollapsed())return!1;const o=s.focus.getNode(),a=Oa(o,l=>l.getType()===ub.getType());if(!a||a.getNextSibling())return!1;const u=a.getLastChild();return!u||!Oa(o,l=>l===u)?!1:(i.preventDefault(),e.update(()=>{const l=hn();a.insertAfter(l),l.select()}),!0)}return!1},Xe),t.registerHighCommand(Co,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0){const a=o[0].getNextSibling();if(qn(a)){const u=a.getParent();if(u){const l=a.getIndexWithinParent();return u.select(l,l),i.preventDefault(),!0}}return a==null||a.selectStart(),i.preventDefault(),!0}}else if(de(s)){if(QM(s))return i.preventDefault(),!0;const o=Zg(s.focus,!1),a=o||Qg(s.focus,!1);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectStart(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(nb,i=>{var o,a;const s=ce();if(de(s)){const u=s.focus.getNode();if(fn(u)&&((o=u.getChildAtIndex(s.focus.offset))==null?void 0:o.getType())==="table")return(a=u.getChildAtIndex(s.focus.offset))==null||a.selectStart(),i.preventDefault(),!0}else if(Ln(s)){const u=s.getNodes();if(u.length>0){const l=u[0].getNextSibling();if(qn(l)){const h=l.getParent();if(h){const d=l.getIndexWithinParent();return h.select(d,d),i.preventDefault(),!0}}}}return!1},Tt))}const e2=new Set(["code","table","block-image","meta2d"]);function nN(e){let t=!1;return e.registerUpdateListener(({dirtyElements:n})=>{e.isEditable()&&(!n.has("root")&&!Array.from(n.keys()).some(r=>{var i,s;return((s=(i=e.getEditorState()._nodeMap.get(r))==null?void 0:i.getParent())==null?void 0:s.getKey())==="root"})||t||e.getEditorState().read(()=>{const r=Sn().getLastChild();return e2.has(r==null?void 0:r.getType())})&&(t=!0,queueMicrotask(()=>{e.update(()=>{const r=Sn(),i=r.getLastChild();if(e2.has(i==null?void 0:i.getType())){const s=hn();r.append(s)}t=!1})})))})}lu();var to;const rN=(to=class extends zt{constructor(t,n={}){super(),this.kernel=t,this.config=n,this.formats={bold:!0,header:!0,italic:!0,quote:!0,strikethrough:!0,subscript:!1,superscript:!1};const r=n.markdownOption??!0;typeof r=="object"?(this.formats.bold=r.bold??!0,this.formats.header=r.header??!0,this.formats.italic=r.italic??!0,this.formats.quote=r.quote??!0,this.formats.strikethrough=r.strikethrough??!0,this.formats.subscript=r.subscript??!1,this.formats.superscript=r.superscript??!1):r===!1&&(this.formats.bold=!1,this.formats.header=!1,this.formats.italic=!1,this.formats.quote=!1,this.formats.strikethrough=!1,this.formats.subscript=!1,this.formats.superscript=!1),t.registerDataSource(new RM("json")),t.registerDataSource(new PM("text")),t.registerNodes([H7,ub,Ti]),n!=null&&n.theme&&t.registerThemes({quote:n.theme.quote,text:{bold:n.theme.textBold,code:n.theme.textCode,highlight:n.theme.textHighlight,italic:n.theme.textItalic,strikethrough:n.theme.textStrikethrough,subscript:n.theme.textSubscript,superscript:n.theme.textSuperscript,underline:n.theme.textUnderline,underlineStrikethrough:n.theme.textUnderlineStrikethrough}})}registerMarkdown(t){var o;const n=t.requireService(Lt);if(!n)return;const r=(((o=this.config)==null?void 0:o.markdownOption)??!0)!==!1?`
|
|
358
|
+
`)),m+=h.move(d),g(),m}function r(s,o,a){let u=s.value||"",l=1;for(t||l++;new RegExp("(^|[^$])"+"\\$".repeat(l)+"([^$]|$)").test(u);)l++;const h="$".repeat(l);/[^ \r\n]/.test(u)&&(/^[ \r\n]/.test(u)&&/[ \r\n]$/.test(u)||/^\$|\$$/.test(u))&&(u=" "+u+" ");let d=-1;for(;++d<a.unsafe.length;){const g=a.unsafe[d];if(!g.atBreak)continue;const m=a.compilePattern(g);let y;for(;y=m.exec(u);){let w=y.index;u.codePointAt(w)===10&&u.codePointAt(w-1)===13&&w--,u=u.slice(0,w)+" "+u.slice(y.index+1)}}return h+u+h}function i(){return"$"}}const lM={tokenize:cM,concrete:!0,name:"mathFlow"},Wg={tokenize:hM,partial:!0};function cM(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return a;function a(M){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),u(M)}function u(M){return M===36?(e.consume(M),o++,u):o<2?n(M):(e.exit("mathFlowFenceSequence"),Ke(e,l,"whitespace")(M))}function l(M){return M===null||ve(M)?d(M):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(M))}function h(M){return M===null||ve(M)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(M)):M===36?n(M):(e.consume(M),h)}function d(M){return e.exit("mathFlowFence"),r.interrupt?t(M):e.attempt(Wg,g,_)(M)}function g(M){return e.attempt({tokenize:v,partial:!0},_,m)(M)}function m(M){return(s?Ke(e,y,"linePrefix",s+1):y)(M)}function y(M){return M===null?_(M):ve(M)?e.attempt(Wg,g,_)(M):(e.enter("mathFlowValue"),w(M))}function w(M){return M===null||ve(M)?(e.exit("mathFlowValue"),y(M)):(e.consume(M),w)}function _(M){return e.exit("mathFlow"),t(M)}function v(M,T,D){let R=0;return Ke(M,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function F(U){return M.enter("mathFlowFence"),M.enter("mathFlowFenceSequence"),j(U)}function j(U){return U===36?(R++,M.consume(U),j):R<o?D(U):(M.exit("mathFlowFenceSequence"),Ke(M,K,"whitespace")(U))}function K(U){return U===null||ve(U)?(M.exit("mathFlowFence"),T(U)):D(U)}}}function hM(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function fM(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:dM,previous:pM,name:"mathText"};function n(r,i,s){let o=0,a,u;return l;function l(y){return r.enter("mathText"),r.enter("mathTextSequence"),h(y)}function h(y){return y===36?(r.consume(y),o++,h):o<2&&!t?s(y):(r.exit("mathTextSequence"),d(y))}function d(y){return y===null?s(y):y===36?(u=r.enter("mathTextSequence"),a=0,m(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),d):ve(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),d):(r.enter("mathTextData"),g(y))}function g(y){return y===null||y===32||y===36||ve(y)?(r.exit("mathTextData"),d(y)):(r.consume(y),g)}function m(y){return y===36?(r.consume(y),a++,m):a===o?(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",g(y))}}}function dM(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pM(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function mM(e){return{flow:{36:lM},text:{36:fM(e)}}}const gM={};function bM(e){const t=this,n=e||gM,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mM(n)),s.push(aM()),o.push(uM(n))}const Zl=Qe("plugin","markdown"),yM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function xM(e){const t=e.replace(/^<\/?/,"").replace(/\/?>$/,"").trim(),n=/^([A-Za-z][\w-]*)/.exec(t);return n?n[1].toLowerCase():""}var kM=class{constructor(e){this.root=e,this.stack=[]}push(e){this.stack.push(e)}get isReadingHTML(){return this.stack.length>0}get last(){return this.stack.at(-1)}pop(){return this.stack.pop()}};function Kg(e,t){return e!=="paragraph"?t:Array.isArray(t)?{...ke.createParagraph(),children:t}:t.type!=="paragraph"?{...ke.createParagraph(),children:[t]}:t}function Ff(e,t,n,r={}){switch(e.type){case"text":return ke.createTextNode(e.value);default:{let i=[];if("children"in e&&Array.isArray(e.children)){let s=[];for(i=e.children.reduce((o,a,u)=>{if(a.type==="html"){if(a.value.startsWith("<!--")&&a.value.endsWith("-->"))return o;const l=xM(a.value),h=a.value.startsWith("</");if(!l)return o;if(yM.has(l)){const g=r.html;if(Array.isArray(g))for(const m of g){const y=m(a,[],u);if(y)return o.push(y),o}else if(typeof g=="function"){const m=g(a,[],u);if(m)return o.push(m),o}return o}if(h){const g=n.pop();if(s.pop(),(g==null?void 0:g.tag)!==l)return Zl.warn("HTML tag mismatch:",l),g&&o.push(ke.createTextNode(g.node.value),...g.children.flat().filter(Boolean)||[]),o.push(ke.createTextNode(a.value)),o;const m=r.html,y=g.children.flat().filter(Boolean)||[];if(Array.isArray(m))for(const w of m){const _=w(g.node,y,u);if(_)return o.push(_),o}else if(typeof m=="function"){const w=m(g.node,y,u);if(w)return o.push(w),o}return g&&o.push(...g.children),o}const d={children:[],index:u,isEndTag:h,node:a,tag:l};return s.push(d),n.push(d),o}if(s.length>0){const l=n.last;return l&&l.children.push(Ff(a,u,n,r)),o}return o.push(Ff(a,u,n,r)),o},[]).filter(Boolean).flat();s.length>0;){const o=s.shift();n.pop(),i.push(ke.createTextNode(o==null?void 0:o.node.value),...o.children.flat()),i=i.flat()}}if(r[e.type]){const s=r[e.type];if(Array.isArray(s))for(const o of s){const a=o(e,i,t);if(a)return Kg(e.type,a)}else if(typeof s=="function"){const o=s(e,i,t);if(o)return Kg(e.type,o)}}return e.type==="paragraph"?{...ke.createParagraph(),children:i}:i||null}}}function wM(e){const t=n=>typeof n=="function"||Array.isArray(n)&&n.length>0;t(e.root)||(e.root=(n,r)=>({...ke.createRootNode(),children:r})),t(e.paragraph)||(e.paragraph=(n,r)=>({...ke.createParagraph(),children:r})),t(e.heading)||(e.heading=(n,r)=>{const i=`h${Math.min(Math.max(n.depth,1),6)}`;return ke.createElementNode("heading",{children:r,direction:"ltr",format:"",indent:0,tag:i})})}function Yd(e,t={}){const n=[];let r=e;const i=/---markmap---(\n?)([\S\s]*?)\n?---\/markmap---/g;let s,o=0;for(;(s=i.exec(e))!==null;){const d=`|||MARKMAP_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"markmap"}),r=r.replace(s[0],d),o++}const a=/---meta2d---(\n?)([\S\s]*?)\n?---\/meta2d---/g;for(;(s=a.exec(e))!==null;){const d=`|||META2D_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"meta2d"}),r=r.replace(s[0],d),o++}const u=g6().use(wv).use(bM).use([[M6,{singleTilde:!1}]]).parse(r);Zl.debug("Parsed MDAST:",u);const l=new kM(u);wM(t);const h=Ff(u,0,l,t);if(n.length>0){const d=m=>{if(m.type==="text"&&typeof m.text=="string"){const y=[];let w=m.text,_=!1;for(const v of n){const M=w.indexOf(v.placeholder);if(M!==-1){_=!0,M>0&&y.push({...m,text:w.slice(0,Math.max(0,M))}),y.push({type:v.type,[v.type==="markmap"?"markdown":"diagram"]:v.content,version:1});const T=w.slice(Math.max(0,M+v.placeholder.length));if(T){const D=d({...m,text:T});Array.isArray(D)?y.push(...D):y.push(D)}break}}return _?y:m}if(m.children&&Array.isArray(m.children)){const y=[];for(const w of m.children){const _=d(w);Array.isArray(_)?y.push(..._):y.push(_)}if(m.children=y.filter(Boolean),m.type==="paragraph"&&m.children.length===1&&(m.children[0].type==="markmap"||m.children[0].type==="meta2d"))return m.children[0]}return m},g=[];for(const m of h.children){const y=d(m);Array.isArray(y)?g.push(...y):g.push(y)}h.children=g.filter(Boolean)}return h}function Vg(e){return Pt(e)&&!e.hasFormat("code")}function N6(e,t,n,r,i){for(let s=0;s<i;s++)if(e[t+s]!==n[r+s])return!1;return!0}const Gg=/[!-/:-@[-`{-~\s]/;function Xg(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const s=i-r;if(N6(e,s,n,0,r)&&e[s+r]!==" ")return s}return-1}function Jg(e,t){const n={};for(const r of e){const i=t(r);i&&(n[i]?n[i].push(r):n[i]=[r])}return n}let D6=/[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;try{D6=new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]","u")}catch{}function vM(e){return D6.test(e)}function SM(e){if(de(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=tk(t,"previous");if(r)if(nk(r))n=r.origin;else{const i=pb(r,rk(Sn(),"next").getFlipped());for(const s of i)if(Pt(s.origin)){n=s.origin;break}else if(fn(s.origin)&&!s.origin.isInline())break}if(n&&Pt(n)){const i=n.getFormat(),s=n.getStyle();(e.format!==i||e.style!==s)&&(e.format=i,e.style=s,e.dirty=!0)}}}function CM(e,t,n){e.dispatchCommand(ek,{nodes:t,selection:n})||(n.insertNodes(t),SM(n))}function _M(e){const t={};if(!e)return t;const n=e.split(";");for(const r of n)if(r!==""){const[i,s]=r.split(/:([^]+)/);i&&s&&(t[i.trim()]=s.trim())}return t}const EM=new Map;function TM(e){const t=e.getStyle(),n=_M(t);EM.set(t,n)}function I6(e){const t=[];for(const n of e){const r=X7(n);Pt(r)&&TM(r),t.push(r)}return t}function AM(e,t,n){CM(e,I6(t.children),n)}function L6(e){return e===null?!1:qn(e)||Hr(e)||So(e)}function MM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,trigger:a}of r){const u=s.match(o);if(i===a&&u&&u[0].length===(i==="enter"||u[0].endsWith(" ")?n:n-1))return!0}return!1}function NM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,replace:a,trigger:u}of r){const l=s.match(o);if(i===u&&l&&l[0].length===(i==="enter"||l[0].endsWith(" ")?n:n-1)){const h=t.getNextSiblings(),[d,g]=t.splitText(n);if(a(e,g?[g,...h]:h,l,!1)!==!1)return d.remove(),!0}}return!1}function DM(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(!i)return!1;t<r.length&&(r=r.slice(0,t));for(const s of i){if(!s.replace||!s.regExp)continue;const o=r.match(s.regExp);if(o===null)continue;const a=o.index||0,u=a+o[0].length;let l;return a===0?[l]=e.splitText(u):[,l]=e.splitText(a,u),l.selectNext(0,0),s.replace(l,o),!0}return!1}function IM(e,t,n){const r=e.getTextContent(),i=t-1,s=r[i],o=n[s];if(!o)return!1;for(const a of o){const{tag:u}=a,l=u.length,h=i-l+1;if(l>1&&!N6(r,h,u,0,l)||r[h-1]===" ")continue;const d=r[i+1];if(a.intraword===!1&&d&&!Gg.test(d))continue;const g=e;let m=g,y=Xg(r,h,u),w=m;for(;y<0&&(w=w.getPreviousSibling())&&!Qn(w);)if(Pt(w)){if(w.hasFormat("code"))continue;const K=w.getTextContent();m=w,y=Xg(K,K.length,u)}if(y<0||m===g&&y+l===h)continue;const _=m.getTextContent();if(y>0&&_[y-1]===s)continue;const v=_[y-1];if(a.intraword===!1&&v&&!Gg.test(v))continue;const M=g.getTextContent(),T=M.slice(0,h)+M.slice(i+1);g.setTextContent(T);const D=m===g?T:_;m.setTextContent(D.slice(0,y)+D.slice(y+l));const R=ce(),F=Lo();je(F);const j=i-l*(m===g?2:1)+1;if(F.anchor.set(m.__key,y,"text"),F.focus.set(g.__key,j,"text"),a.process){if(a.process(F)===!1){const K=ze(m.__key),U=ze(g.__key);Pt(K)&&K.setTextContent(_),U!==K&&Pt(U)&&U.setTextContent(M),je(e.selectEnd());continue}return!0}else if(a.format){for(const K of a.format)F.hasFormat(K)||F.formatText(K);F.anchor.set(F.focus.key,F.focus.offset,F.focus.type);for(const K of a.format)F.hasFormat(K)&&F.toggleFormat(K);de(R)&&(F.format=R.format)}else{je(R);continue}return!0}return!1}Ot();const Lt=uu("MarkdownShortCutService");var LM=class{constructor(e){this.kernel=e,this.elementTransformers=[],this.textFormatTransformers=[],this.textMatchTransformers=[],this.logger=Qe("service","markdown"),this._markdownWriters={},this._markdownReaders=[{},{},{}],this._textFormatTransformersByTrigger=null,this._textMatchTransformersByTrigger=null}get markdownWriters(){return this._markdownWriters}get markdownReaders(){return this._markdownReaders.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]||(e[n]=[]);const r=e[n],i=t[n];r.push(...i)}),e),{})}get textMatchTransformersByTrigger(){return this._textMatchTransformersByTrigger||(this._textMatchTransformersByTrigger=Jg(this.textMatchTransformers,({trigger:e})=>e)),this._textMatchTransformersByTrigger}get textFormatTransformersByTrigger(){return this._textFormatTransformersByTrigger||(this._textFormatTransformersByTrigger=Jg(this.textFormatTransformers,({tag:e})=>e.at(-1))),this._textFormatTransformersByTrigger}registerMarkdownShortCut(e){switch(e.type){case"element":this.elementTransformers.push(e);break;case"text-format":this.textFormatTransformers.push(e);break;case"text-match":this.textMatchTransformers.push(e);break;default:throw new Error(`Unknown transformer type: ${e}`)}}registerMarkdownShortCuts(e){for(const t of e)this.registerMarkdownShortCut(t)}testTransformers(e,t,n,r){if(MM(e,t,n,this.elementTransformers,r))return!0;if(r==="enter"){const i=t.getTextContent(),s=i[n-1],o=this.textMatchTransformersByTrigger[s];if(o){const a=n<i.length?i.slice(0,n):i;for(const u of o)if(u.regExp&&u.regExp.test(a))return!0}}return!1}runTransformers(e,t,n,r){return!!(NM(e,t,n,this.elementTransformers,r)||DM(t,n,this.textMatchTransformersByTrigger)||IM(t,n,this.textFormatTransformersByTrigger))}registerMarkdownWriter(e,t){var n;if(!this._markdownWriters[e]){this._markdownWriters[e]=t;return}if((n=this.kernel)!=null&&n.isHotReloadMode()){this.logger.warn(`🔄 Hot reload: markdown writer "${e}"`),this._markdownWriters[e]=t;return}throw new Error(`Markdown writer for type "${e}" is already registered.`)}registerMarkdownReader(e,t,n=2){var r;this._markdownReaders[n][e]||(this._markdownReaders[n][e]=[]),this._markdownReaders[n]&&((r=this._markdownReaders[n][e])==null||r.push(t))}parseMarkdownToLexical(e){return Yd(e,this.markdownReaders)}insertIRootNode(e,t,n){AM(e,t,n)}};function hU(e=0){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).getBoundingClientRect();if(n.height===0&&n.width===0){const i=t.focusNode;if(i){const s=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;s&&s.scrollIntoView({behavior:"smooth",block:"center"})}return}const r=n.top+n.height/2-window.innerHeight/2+e;window.scrollBy({behavior:"smooth",top:r})}function FM(e){if(!(e instanceof HTMLElement)||e.scrollHeight<=e.clientHeight+1)return!1;const t=window.getComputedStyle(e).overflowY||e.style.overflowY||e.style.overflow;return t==="auto"||t==="scroll"||t==="overlay"}function OM(){var n;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).getBoundingClientRect();if(t.width===0&&t.height===0){const r=e.focusNode;return r?((n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)==null?void 0:n.getBoundingClientRect())??null:null}return t}function zM(e=96){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||!t.isCollapsed)return;const n=OM();if(!n)return;let r=document.activeElement;if(r instanceof Element)for(;r&&r!==document.body&&r!==document.documentElement;){if(FM(r)){const i=r.getBoundingClientRect(),s=i.bottom-e;n.bottom>s&&(r.scrollTop+=n.bottom-s);const o=i.top+Math.min(48,e/2);n.top<o&&(r.scrollTop-=o-n.top)}r=r.parentElement}}lu();var RM=class extends Nd{read(e,t,n){let r;typeof t=="string"?r=JSON.parse(t):r=t;const i=s=>{for(let o=0;o<s.children.length;o++){const a=s.children[o];"children"in a&&Array.isArray(a.children)&&i(a),a.type==="text"&&"format"in a&&typeof a.format=="number"&&(a.format&Mm)>0&&(s.children[o]={children:[{...a,format:a.format&~Mm}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},s.children.splice(o+1,0,df))}};i(r.root),e.setEditorState(e.parseEditorState({root:r.root}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var r,i,s;const n=ce();if(!n)return null;if(de(n)){const o=n.getNodes(),a=o.length-1,u=n.anchor,l=n.focus,h=u.isBefore(l),d=o[0],g=o[a],[m,y]=ab(n);let w=[];const _=[];for(let v=0;v<o.length;v++){const M=o[v];if(fn(M)){const T={...M.exportJSON(),$key:M.getKey()};for(let R=0;R<_.length;R++){const F=_[R],j=ze(F.$key);M.isParentOf(j)&&(T.children.push(F),_.splice(R,1),R--)}let D=!1;for(let R=w.length-1;R>=0;R--)if((r=ze(w[R].$key))!=null&&r.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T),w.push(T)}else if(Pt(M)){const T={...M.exportJSON(),$key:M.getKey()};M===d?M===g?(u.type!=="element"||l.type!=="element"||l.offset===u.offset)&&(T.text=m<y?T.text.slice(m,y):T.text.slice(y,m)):T.text=h?T.text.slice(m):T.text.slice(y):M===g&&(T.text=h?T.text.slice(0,y):T.text.slice(0,m));let D=!1;for(let R=w.length-1;R>=0;R--)if((i=ze(w[R].$key))!=null&&i.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}else{const T={...M.exportJSON(),$key:M.getKey()};let D=!1;for(let R=w.length-1;R>=0;R--)if((s=ze(w[R].$key))!=null&&s.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}}return _}return n.getNodes().map(o=>ff(o))}):e.read(()=>({root:ff(Sn())}))}};rn();var PM=class extends Nd{read(e,t){if(typeof t!="string")throw new Error("Invalid data type "+typeof t);const n=t.split(/\n/g),r=ke.createRootNode();n.forEach(i=>{const s=ke.createParagraph();if(i){const o=ke.createTextNode(i);ke.appendChild(s,o)}ke.appendChild(r,s)}),e.setEditorState(e.parseEditorState({root:r}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{const n=ce();return n?n.getTextContent().replaceAll("\uFEFF",""):null}):e.getEditorState().read(()=>Sn().getTextContent().replaceAll("\uFEFF",""))}};kr();function BM(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function $M(e){return gt(e.registerCommand(ou,()=>{if(cb){const t=document.getSelection();if(t!=null&&t.anchorNode){const n=BM(t.anchorNode);if(n!=null&&n.hasAttribute("data-lexical-linebreak")&&n.parentElement){const r=n.parentElement;return e.update(()=>{const i=u9(r,e);i&&i.selectEnd()}),!0}}}return!1},Fn))}const jM=["color","background-color"];function qM(e){const t=e.trim();return!t||t.length>128||/["'<>\\]|url\s*\(|expression\s*\(|@import/i.test(t)?!1:/^(#[\dA-Fa-f]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[A-Za-z]+)$/.test(t)}function HM(e){if(!(e!=null&&e.trim()))return{};const t={};for(const n of e.split(";")){if(!n.trim())continue;const r=n.indexOf(":");if(r<0)continue;const i=n.slice(0,r).trim().toLowerCase(),s=n.slice(r+1).trim();jM.includes(i)&&qM(s)&&(i==="color"&&(t.color=s),i==="background-color"&&(t["background-color"]=s))}return t}function Ql(e){const t=HM(e),n=[];return t.color&&n.push(`color: ${t.color}`),t["background-color"]&&n.push(`background-color: ${t["background-color"]}`),n.join("; ")}function UM(e){if(!/^<span\b/i.test(e.trim()))return"";const t=/\bstyle\s*=\s*"([^"]*)"/i.exec(e);if(t)return Ql(t[1]);const n=/\bstyle\s*=\s*'([^']*)'/i.exec(e);return n?Ql(n[1]):""}rn();function WM(e){e.registerMarkdownReader("blockquote",(t,n)=>ke.createElementNode("quote",{children:n,direction:"ltr",format:"",indent:0,version:1})),e.registerMarkdownReader("strong",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r))),e.registerMarkdownReader("emphasis",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r))),e.registerMarkdownReader("delete",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|J7),r))),e.registerMarkdownReader("subscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Y7),r))),e.registerMarkdownReader("superscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Z7),r))),e.registerMarkdownReader("html",(t,n)=>{if(["<ins>","<u>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Q7),r));if(["<em>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r));if(["<strong>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r));if(/^<span\b/i.test(t.value.trim())){const r=UM(t.value);return r?n.map(i=>(ke.isTextNode(i)&&(i.style=Ql([i.style,r].filter(Boolean).join("; "))),i)):!1}return!1})}function F6(e){const t=e.target;if(!(t instanceof Node))return null;const n=t.nodeType===Node.TEXT_NODE?t.parentElement:t;return n!=null&&n.closest?n:null}function O6(e){const t=F6(e);return t?!!t.closest('textarea, input:not([type="hidden"]), select'):!1}function KM(e){const t=F6(e);return t?!!t.closest(".cm-editor, .cm-content, .CodeMirror"):!1}const VM=({clipboardData:e})=>{const t=e.items;for(const n of t)if(n.kind==="file")return"skip";return"next"},GM=({clipboardData:e,config:t,editor:n,event:r})=>{if(!t.pasteVSCodeAsCodeBlock)return"next";const i=e.getData("vscode-editor-data");if(!i)return"next";try{const s=JSON.parse(i),o=s.mode||s.language||"plaintext",a=e.getData("text/plain");return a?(r.preventDefault(),n.update(()=>{if(!de(ce()))return;const u=di(o,a);_n([u]);const l=yn();l.add(u.getKey()),je(l)}),"handled"):"next"}catch{return"next"}},XM=({clipboardData:e,editor:t,event:n})=>{const r=e.getData("text/plain");return r?(n.preventDefault(),t.dispatchCommand(sk,r),"handled"):"skip"};function JM(e,t){for(const n of t){const r=n(e);if(r==="handled")return!0;if(r==="skip")return!1}return!1}Es();Ot();const YM=Qe("plugin","common");function Yg(e,t,n){const r=e.getParent();let i=n,s=e;return r!==null&&(t&&n===0?(i=s.getIndexWithinParent(),s=r):!t&&n===s.getChildrenSize()&&(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(t?i-1:i)}function ZM(e){if(!xn(e))return!1;const t=e.getParent();if(!mt(t))return!1;let n=t.getLastChild();do{if(Qn(n))return!1;if(n===e)return t;n=n==null?void 0:n.getPreviousSibling()}while(n!==e&&n);return n===e?t:!1}function Zg(e,t){var r;const n=e.offset;if(e.type==="element")return Yg(e.getNode(),t,n);{const i=e.getNode();if(t&&n===0||!t&&n===i.getTextContentSize()){const s=t?i.getPreviousSibling():i.getNextSibling();return s===null?Yg(i.getParentOrThrow(),t,i.getIndexWithinParent()+(t?0:1)):s}else if(!t&&ZM(i))return((r=i.getParent())==null?void 0:r.getNextSibling())||null}return null}function Qg(e,t){let n=e.getNode();for(;n!==null&&n.isInline();)n=n.getParent();if(!n)return null;let r=t?n.getPreviousSibling():n.getNextSibling();for(;!r&&!qn(n);){if(n=n.getParent(),!n)return null;r=t?n.getPreviousSibling():n.getNextSibling()}return r||null}function QM(e){const t=e.focus;return t.key==="root"&&t.offset===Sn().getChildrenSize()}function eN(e){return e.registerCommand(Il,t=>{const n=e.getEditorState().read(()=>{const r=ce();if(!de(r)||!r.isCollapsed())return!1;const i=r.anchor;if(i.offset!==0)return!1;const s=i.getNode();if(Pt(s)){if(s.getPreviousSibling())return!1;const o=s.getParentOrThrow();return _o(o)?o:!1}return _o(s)?s:!1});return n?(t.stopImmediatePropagation(),t.preventDefault(),t.stopPropagation(),e.update(()=>{const r=hn();n.replace(r,!0),r.select(0,0)}),!0):!1},Ma)}function tN(e,t,n){const{enableHotkey:r=!0}=n||{};return gt(t.registerHotkey(Nt.PasteAsPlainText,async()=>{try{const i=await navigator.clipboard.readText();e.update(()=>{const s=ce();de(s)&&s.insertText(i)})}catch(i){YM.error("❌ Failed to paste as plain text:",i)}},{enabled:r,preventDefault:!0,stopPropagation:!0}),t.registerHotkey(Nt.Bold,()=>e.dispatchCommand(aa,"bold"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Italic,()=>e.dispatchCommand(aa,"italic"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Underline,()=>e.dispatchCommand(aa,"underline"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Strikethrough,()=>e.dispatchCommand(aa,"strikethrough"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Undo,()=>e.dispatchCommand(db,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Redo,()=>e.dispatchCommand(fb,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHighCommand(ys,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0)return o[0].selectPrevious(),i.preventDefault(),!0}else if(de(s)){const o=Zg(s.focus,!0),a=o||Qg(s.focus,!0);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectEnd(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(Co,i=>{const s=ce();if(de(s)){if(!s.isCollapsed())return!1;const o=s.focus.getNode(),a=Oa(o,l=>l.getType()===ub.getType());if(!a||a.getNextSibling())return!1;const u=a.getLastChild();return!u||!Oa(o,l=>l===u)?!1:(i.preventDefault(),e.update(()=>{const l=hn();a.insertAfter(l),l.select()}),!0)}return!1},Xe),t.registerHighCommand(Co,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0){const a=o[0].getNextSibling();if(qn(a)){const u=a.getParent();if(u){const l=a.getIndexWithinParent();return u.select(l,l),i.preventDefault(),!0}}return a==null||a.selectStart(),i.preventDefault(),!0}}else if(de(s)){if(QM(s))return i.preventDefault(),!0;const o=Zg(s.focus,!1),a=o||Qg(s.focus,!1);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectStart(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(nb,i=>{var o,a;const s=ce();if(de(s)){const u=s.focus.getNode();if(fn(u)&&((o=u.getChildAtIndex(s.focus.offset))==null?void 0:o.getType())==="table")return(a=u.getChildAtIndex(s.focus.offset))==null||a.selectStart(),i.preventDefault(),!0}else if(Ln(s)){const u=s.getNodes();if(u.length>0){const l=u[0].getNextSibling();if(qn(l)){const h=l.getParent();if(h){const d=l.getIndexWithinParent();return h.select(d,d),i.preventDefault(),!0}}}}return!1},Tt))}const e2=new Set(["code","table","block-image","meta2d"]);function nN(e){let t=!1;return e.registerUpdateListener(({dirtyElements:n})=>{e.isEditable()&&(!n.has("root")&&!Array.from(n.keys()).some(r=>{var i,s;return((s=(i=e.getEditorState()._nodeMap.get(r))==null?void 0:i.getParent())==null?void 0:s.getKey())==="root"})||t||e.getEditorState().read(()=>{const r=Sn().getLastChild();return e2.has(r==null?void 0:r.getType())})&&(t=!0,queueMicrotask(()=>{e.update(()=>{const r=Sn(),i=r.getLastChild();if(e2.has(i==null?void 0:i.getType())){const s=hn();r.append(s)}t=!1})})))})}lu();var to;const rN=(to=class extends zt{constructor(t,n={}){super(),this.kernel=t,this.config=n,this.formats={bold:!0,header:!0,italic:!0,quote:!0,strikethrough:!0,subscript:!1,superscript:!1};const r=n.markdownOption??!0;typeof r=="object"?(this.formats.bold=r.bold??!0,this.formats.header=r.header??!0,this.formats.italic=r.italic??!0,this.formats.quote=r.quote??!0,this.formats.strikethrough=r.strikethrough??!0,this.formats.subscript=r.subscript??!1,this.formats.superscript=r.superscript??!1):r===!1&&(this.formats.bold=!1,this.formats.header=!1,this.formats.italic=!1,this.formats.quote=!1,this.formats.strikethrough=!1,this.formats.subscript=!1,this.formats.superscript=!1),t.registerDataSource(new RM("json")),t.registerDataSource(new PM("text")),t.registerNodes([H7,ub,Ti]),n!=null&&n.theme&&t.registerThemes({quote:n.theme.quote,text:{bold:n.theme.textBold,code:n.theme.textCode,highlight:n.theme.textHighlight,italic:n.theme.textItalic,strikethrough:n.theme.textStrikethrough,subscript:n.theme.textSubscript,superscript:n.theme.textSuperscript,underline:n.theme.textUnderline,underlineStrikethrough:n.theme.textUnderlineStrikethrough}})}registerMarkdown(t){var o;const n=t.requireService(Lt);if(!n)return;const r=(((o=this.config)==null?void 0:o.markdownOption)??!0)!==!1?`
|
|
359
359
|
|
|
360
360
|
`:`
|
|
361
361
|
`,i=this.formats;i.quote&&n.registerMarkdownShortCut({regExp:/^>\s/,replace:(a,u,l,h)=>{if(h){const g=a.getPreviousSibling();if(So(g)){g.splice(g.getChildrenSize(),0,[xd(),...u]),a.remove();return}}const d=kd();d.append(...u),a.replace(d),h||d.select(0,0)},type:"element"}),i.header&&n.registerMarkdownShortCut({regExp:/^(#{1,6})\s/,replace:Bb((a,u)=>{const l="h"+a[1].length;return _o(u)&&u.getTag()===l?hn():lb(l)}),type:"element"});const s=[];i.bold&&s.push({format:["bold"],tag:"**",type:"text-format"},{format:["bold"],intraword:!1,tag:"__",type:"text-format"}),i.strikethrough&&s.push({format:["strikethrough"],tag:"~~",type:"text-format"}),i.italic&&s.push({format:["italic"],tag:"*",type:"text-format"},{format:["italic"],intraword:!1,tag:"_",type:"text-format"}),i.superscript&&s.push({format:["superscript"],tag:"^",type:"text-format"}),i.subscript&&s.push({format:["subscript"],tag:"~",type:"text-format"}),s.length>0&&n.registerMarkdownShortCuts(s),n.registerMarkdownWriter("paragraph",a=>{a.wrap("",r)}),i.quote&&n.registerMarkdownWriter("quote",(a,u)=>{So(u)&&a.wrap("> ",r)}),i.header&&n.registerMarkdownWriter("heading",(a,u)=>{if(_o(u))switch(u.getTag()){case"h1":a.wrap("# ",`
|
|
@@ -374,7 +374,7 @@ $$
|
|
|
374
374
|
|
|
375
375
|
`);break}}),n.registerMarkdownWriter("text",(a,u)=>{if(!Pt(u))return;const l=i.bold&&u.hasFormat("bold"),h=i.italic&&u.hasFormat("italic"),d=u.hasFormat("underline"),g=i.strikethrough&&u.hasFormat("strikethrough"),m=i.superscript&&u.hasFormat("superscript"),y=i.subscript&&u.hasFormat("subscript"),w=Ql(u.getStyle());w&&a.appendLine(`<span style="${w}">`),l&&a.appendLine("**"),g&&a.appendLine("~~"),h&&a.appendLine("_"),d&&a.appendLine("<ins>"),m&&a.appendLine("^"),y&&a.appendLine("~");const _=u.getTextContent(),v=_.match(/\s+$/);let M="";v&&(M=v[0]);const T=_.trimEnd(),D=T.at(-1);a.appendLine(T),y&&a.appendLine("~"),m&&a.appendLine("^"),d&&a.appendLine("</ins>"),h&&a.appendLine("_"),g&&a.appendLine("~~"),l&&a.appendLine("**"),w&&a.appendLine("</span>"),M?a.appendLine(M):D&&vM(D)&&a.appendLine(" ")}),n.registerMarkdownWriter("linebreak",a=>{a.appendLine(`
|
|
376
376
|
`)}),WM(n)}onInit(t){var n;this.register(t.registerUpdateListener(({tags:r})=>{r.has(Qh)||r.has(Aa)||typeof window>"u"||requestAnimationFrame(()=>{t.getRootElement()===document.activeElement&&zM(96)})})),this.register(this.kernel.registerHighCommand(yc,r=>{var o,a;if(!(r instanceof ClipboardEvent)||O6(r))return!1;const i=r.clipboardData;if(!i)return!1;this.kernel.emit("onPaste",r);const s={clipboardData:i,config:this.config,editor:t,event:r};return(o=this.config)!=null&&o.pasteVSCodeAsCodeBlock&&GM(s)==="handled"?!0:(a=this.config)!=null&&a.pasteAsPlainText?JM(s,[VM,XM]):!1},Zn)),this.registerClears(U7(t),cb?W7(t):Fo,K7(t,this.kernel.getHistoryState(),300),eN(t),tN(t,this.kernel,{enableHotkey:(n=this.config)==null?void 0:n.enableHotkey}),iC(t),$M(t),N9(t),nN(t),t.registerCommand(V7,()=>{const r=ce();if(!de(r))return!1;const{inCell:i,inTable:s}=_9(r);return i||s||E9(r)?!1:(t.update(()=>{t.dispatchCommand(G7,void 0)}),!0)},Fn)),this.registerMarkdown(this.kernel)}destroy(){super.destroy()}},to.pluginName="CommonPlugin",to),z6=()=>null;z6.displayName="ReactEditorContent";const iN=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?E.useLayoutEffect:E.useEffect;function sN(e,t){const[n,r]=E.useState(()=>{var i;return((i=e.getLexicalEditor())==null?void 0:i.getDecorators())||{}});return iN(()=>{let i=[];const s=a=>{r(a.getDecorators()),i.push(a.registerDecoratorListener(u=>{Pi.flushSync(()=>{r(u)})}))},o=e.getLexicalEditor();return o?s(o):(e.on("initialized",s),i.push(()=>{e.off("initialized",s)})),()=>{i.forEach(a=>a())}},[e]),E.useMemo(()=>{var o;const i=[],s=Object.keys(n);for(const a of s){const u=n[a],l=O.jsx(t,{onError:d=>{var g;return(g=e.getLexicalEditor())==null?void 0:g._onError(d)},children:O.jsx(E.Suspense,{fallback:null,children:"render"in u?u.render:u})}),h=(o=e.getLexicalEditor())==null?void 0:o.getElementByKey(a);h!=null&&i.push(Pi.createPortal(l,"queryDOM"in u?u.queryDOM(h):h,a))}return i},[t,n,e])}Ot();const ch=Qe("plugin","markdown"),Of=lt("INSERT_MARKDOWN_COMMAND"),oN=lt("GET_MARKDOWN_SELECTION_COMMAND");function t2(e,t){return e.slice(0,Math.max(0,t)).split(`
|
|
377
|
-
`).length}function aN(e,t){t&&e.setEditorState(t.editorState,{tag:Aa})}function n2(e){let t=e,n=t.getParent();for(;n!==null&&!qn(n);)t=n,n=t.getParent();return t}function uN(e){var r,i,s;if(e.length===0)return;let t=ce();if(!de(t)){Sn().append(...e),(r=e.at(-1))==null||r.selectEnd();return}t.isCollapsed()||t.removeText();let n=n2(t.anchor.getNode());if(n.getTextContent()!==""){if(t.insertParagraph(),t=ce(),!de(t)){Sn().append(...e),(i=e.at(-1))==null||i.selectEnd();return}n=n2(t.anchor.getNode())}for(const o of e)n.insertBefore(o);n.getTextContent()===""&&n.remove(),(s=e.at(-1))==null||s.selectEnd()}function lN(e){const t=[],n=e.getLexicalEditor();return n&&n.getEditorState().read(()=>{function r(i){Pt(i)&&i.getType()!=="cursor"&&t.push({key:i.getKey(),text:i.getTextContent()}),fn(i)&&i.getChildren().forEach(r)}r(Sn())}),t}function r2(e,t,n,r){let i=0;for(const s of t){const o=[];let a=0;const u=i;for(;a<s.text.length&&i<e.length;)e[i]===s.text[a]?(o[a]=i,i++,a++):i++;if(s.key===n){if(r<s.text.length)return o[r]??u+r;const l=s.text.length-1;return(o[l]??u+l)+1}}return 0}function cN(e,t,n){return gt(e.registerCommand(Of,r=>{const{markdown:i}=r;ch.debug("INSERT_MARKDOWN_COMMAND payload:",r),r.editorState?e.setEditorState(r.editorState,{tag:Aa}):aN(e,r.historyState);const s=e.getEditorState().read(()=>Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"")==="");return r.replaceDocument||s?(t.setDocument("markdown",i,{keepHistory:!0}),!1):(setTimeout(()=>{e.update(()=>{try{const o=Yd(i,n.markdownReaders);let a=ce();a===null&&(Sn().selectEnd(),a=ce());const u=I6(o.children);return ch.debug("INSERT_MARKDOWN_COMMAND nodes:",u),uN(u),!0}catch(o){ch.error("Failed to handle markdown paste:",o)}},{tag:j7})},0),!1)},Fn),e.registerCommand(oN,r=>{const i=t.getDocument("markdown");if(!i)return!1;const s=t.getSelection();if(!s||s.type!=="range")return!1;const o=lN(t),a=r2(i,o,s.startNodeId,s.startOffset),u=r2(i,o,s.endNodeId,s.endOffset),l=Math.min(a,u),h=Math.max(a,u);return r.onResult(t2(i,l),t2(i,h)),!1},Fn))}const Zd=uu("INodeService");var hN=class{constructor(){this.processNodeTreeHandlers=[]}registerProcessNodeTree(e){this.processNodeTreeHandlers.push(e)}processNodeTree(e){for(const t of this.processNodeTreeHandlers)t(e)}};Bt();var no;const fN=(no=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n;const r=new hN;t.registerService(Zd,r)}onInit(){}},no.pluginName="INodePlugin",no);var hh=class R6{constructor(t){this.before="",this.after="",this.children=[],this.markdownService=t}appendLine(t){this.children.push(t)}newChild(){const t=new R6(this.markdownService);return this.children.push(t),t}wrap(t,n){this.before=t,this.after=n}addProcessor(t){this.processor=t}toString(){const t=this.before+this.children.map(n=>n.toString()).join("")+this.after;return this.processor?this.processor(this.before,this.children.map(n=>n.toString()).join(""),this.after):t}processChild(t,n){const r=this.markdownService.markdownWriters[n.getType()];let i=t;fn(n)&&(i=i.newChild());let s=!1;r&&(s=r(i,n)),!s&&fn(n)&&n.getChildren().forEach(o=>this.processChild(i,o))}};rn();var dN=class extends Nd{formatMarkdown(e){try{const t=g6().use([[M6,{singleTilde:!1}]]).data("settings",{bullet:"-",emphasis:"*",fences:!0,resourceLink:!0,rule:"-",strong:"*",tightDefinitions:!0}).processSync(e);return String(t)}catch(t){return Zl.error("Failed to format markdown:",t),e}}constructor(e,t,n){super(e),this.dataType=e,this.markdownService=t,this.getService=n}read(e,t){var r,i;const n={root:Yd(t,this.markdownService.markdownReaders)};(i=(r=this.getService)==null?void 0:r.call(this,Zd))==null||i.processNodeTree(n),Zl.debug("Parsed Lexical State:",n),e.setEditorState(e.parseEditorState(n))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var u,l,h;const n=ce();if(!n)return null;const r=n.getNodes();if(de(n)){const d=r.length-1,g=n.anchor,m=n.focus,y=g.isBefore(m),w=r[0],_=r[d],[v,M]=ab(n);let T=[];const D=[];for(let U=0;U<r.length;U++){const z=r[U];if(fn(z)){const V={...z.exportJSON(),$key:z.getKey()};for(let ee=0;ee<D.length;ee++){const Q=D[ee],ae=ze(Q.$key);z.isParentOf(ae)&&(V.children.push(Q),D.splice(ee,1),ee--)}let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((u=ze(T[ee].$key))!=null&&u.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V),T.push(V)}else if(Pt(z)){const V={...z.exportJSON(),$key:z.getKey()};z===w?z===_?(g.type!=="element"||m.type!=="element"||m.offset===g.offset)&&(V.text=v<M?V.text.slice(v,M):V.text.slice(M,v)):V.text=y?V.text.slice(v):V.text.slice(M):z===_&&(V.text=y?V.text.slice(0,M):V.text.slice(0,v));let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((l=ze(T[ee].$key))!=null&&l.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}else{const V={...z.exportJSON(),$key:z.getKey()};let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((h=ze(T[ee].$key))!=null&&h.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}}const R=ke.createRootNode();if(D.some(U=>ke.isTextNode(U))){const U=ke.createParagraph();ke.appendChild(U,...D),ke.appendChild(R,U)}else ke.appendChild(R,...D);const F=e.parseEditorState({root:R}),j=F._nodeMap.get("root"),K=new hh(this.markdownService);return F.read(()=>(j.getChildren().forEach(U=>K.processChild(K,U)),this.formatMarkdown(K.toString())))}const i=ke.createRootNode();if(r.some(d=>d.isInline())){const d=ke.createParagraph();ke.appendChild(d,...r.map(g=>g.exportJSON())),ke.appendChild(i,d)}else ke.appendChild(i,...r.map(d=>d.exportJSON()));const s=e.parseEditorState({root:i}),o=s._nodeMap.get("root"),a=new hh(this.markdownService);return s.read(()=>(o.getChildren().forEach(d=>a.processChild(a,d)),a.toString()))}):e.getEditorState().read(()=>{const n=Sn(),r=new hh(this.markdownService);return n.getChildren().forEach(i=>r.processChild(r,i)),this.formatMarkdown(r.toString())})}};Bt();Ot();const pN="strong,em,b,i,h1,h2,h3,h4,h5,h6,ul,ol,table,img,blockquote,pre>code,a[href]";function mN(e){let t=0;return/^#{1,6}\s+\S+/m.test(e)&&(t+=3),/(\*\*|__)[\S\s]+?\1/.test(e)&&(t+=2),/([*_])[\S\s]+?\1/.test(e)&&(t+=1),/~~[\S\s]+?~~/.test(e)&&(t+=2),/`[^`]+`/.test(e)&&(t+=2),/^```[\w+-]*\s*$/m.test(e)&&/^```\s*$/m.test(e)&&(t+=4),/\[.+?]\s*\([^)]+\)/.test(e)&&(t+=2),/!\[.*?]\s*\([^)]+\)/.test(e)&&(t+=2),/^[*+-]\s+\S+/m.test(e)&&(t+=2),/^\d+\.\s+\S+/m.test(e)&&(t+=2),/^>\s+\S+/m.test(e)&&(t+=2),/^[*_-]{3,}\s*$/m.test(e)&&(t+=2),/^\|.*\|/.test(e)&&/^\|[:-]+\|/.test(e)&&(t+=3),t}function gN(){const e=ce();if(de(e)){let t=e.anchor.getNode();for(;t;){if(mt(t)||xn(t)||Mi(t))return!0;t=t.getParent()}return!1}return Ln(e)?e.getNodes().some(t=>mt(t)||Mi(t)):!1}var ro;const Vi=(ro=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","markdown"),this.service=new LM(t),t.registerService(Lt,this.service),this.markdownDataSource=new dN("markdown",this.service,r=>t.requireService(r)),t.registerDataSource(this.markdownDataSource)}onInit(t){this.register(t.registerUpdateListener(({tags:n,dirtyLeaves:r,editorState:i,prevEditorState:s})=>{if(n.has(z7)||n.has(Aa)||t.isComposing())return;const o=i.read(ce),a=s.read(ce);if(!de(a)||!de(o)||!o.isCollapsed()||o.is(a))return;const u=o.anchor.key,l=o.anchor.offset,h=i._nodeMap.get(u);!Pt(h)||!r.has(u)||l!==1&&l>a.anchor.offset+1||t.update(()=>{if(!Vg(h))return;const d=h.getParent();d===null||mt(d)||this.service.runTransformers(d,h,o.anchor.offset)&&this.kernel.emit("markdownTransform",{trigger:"type"})})})),this.register(t.registerCommand(R7,n=>{const r=t.getEditorState().read(()=>{const a=ce();if(!de(a)||!a.isCollapsed())return!1;const u=a.anchor.key,l=ze(u);return l?{anchorNode:l,offset:a.anchor.offset}:!1});if(!r)return!1;const{anchorNode:i,offset:s}=r;if(!Vg(i))return!1;const o=i.getParent();return o===null||mt(o)?!1:this.service.testTransformers(o,i,s,"enter")?(queueMicrotask(()=>{t.update(()=>{this.service.runTransformers(o,i,s,"enter")}),this.kernel.emit("markdownTransform",{trigger:"enter"})}),n==null||n.stopPropagation(),n==null||n.stopImmediatePropagation(),n==null||n.preventDefault(),!0):!1},Zn)),this.register(t.registerCommand(yc,n=>{var a;if(!(n instanceof ClipboardEvent)||O6(n)||KM(n)||!this.shouldHandlePasteMarkdown()||t.getEditorState().read(()=>gN()))return!1;const r=n.clipboardData;if(!r)return!1;const i=r.getData("text/plain").trimEnd().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");if(!i)return!1;const s=mN(i);if((a=this.config)!=null&&a.onPasteMarkdown&&s>=2){n.preventDefault(),n.stopPropagation();const u=this.kernel.getHistoryState().current,l=t.getEditorState(),h=l.read(()=>{const d=ce(),g=Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");return g===""?!0:de(d)&&!d.isCollapsed()&&d.getTextContent().length>=g.length-1});return Promise.resolve(this.config.onPasteMarkdown(i)).then(d=>{d?(t.dispatchCommand(Of,{editorState:l,historyState:u,markdown:i,replaceDocument:h}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:u,markdown:i,matchedPatterns:[],score:s})):(t.setEditorState(l,{tag:Aa}),setTimeout(()=>{t.update(()=>{const g=ce();de(g)&&g.insertRawText(i)})},0))}),!0}if(this.hasRichHTML(r)||/^https?:\/\/\S+$/i.test(i)||s<2||s<6)return!1;const o=this.kernel.getHistoryState().current;return setTimeout(()=>{t.dispatchCommand(Of,{historyState:o,markdown:i}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:o,markdown:i,matchedPatterns:[],score:s})},10),!1},Zn)),this.register(cN(t,this.kernel,this.service)),this.register(t.registerCommand(P7,n=>{if(!(n instanceof ClipboardEvent))return!1;const r=n.clipboardData;if(!r)return!1;const i=ce();if(!i||i.isCollapsed())return!1;const s=this.markdownDataSource.write(t,{selection:!0});return s?(n.preventDefault(),B7(r,$7(i)),r.setData("text/plain",s),r.setData("text/markdown",s),this.logger.debug("copy with text/markdown:",{markdownLength:s.length}),!0):!1},Xe))}hasRichHTML(t){const n=t.getData("text/html");return!n||/data-vscode|vscode-/i.test(n)||typeof DOMParser>"u"?!1:new DOMParser().parseFromString(n,"text/html").body.querySelectorAll(pN).length>0}shouldHandlePasteMarkdown(){var t,n;return((t=this.config)==null?void 0:t.enablePasteMarkdown)===!1?!1:((n=this.config)==null?void 0:n.autoFormatMarkdown)!==!1}},ro.pluginName="MarkdownPlugin",ro),bN=tt(({css:e,cssVar:t})=>({placeholder:e`
|
|
377
|
+
`).length}function aN(e,t){t&&e.setEditorState(t.editorState,{tag:Aa})}function n2(e){let t=e,n=t.getParent();for(;n!==null&&!qn(n);)t=n,n=t.getParent();return t}function uN(e){var r,i,s;if(e.length===0)return;let t=ce();if(!de(t)){Sn().append(...e),(r=e.at(-1))==null||r.selectEnd();return}t.isCollapsed()||t.removeText();let n=n2(t.anchor.getNode());if(n.getTextContent()!==""){if(t.insertParagraph(),t=ce(),!de(t)){Sn().append(...e),(i=e.at(-1))==null||i.selectEnd();return}n=n2(t.anchor.getNode())}for(const o of e)n.insertBefore(o);n.getTextContent()===""&&n.remove(),(s=e.at(-1))==null||s.selectEnd()}function lN(e){const t=[],n=e.getLexicalEditor();return n&&n.getEditorState().read(()=>{function r(i){Pt(i)&&i.getType()!=="cursor"&&t.push({key:i.getKey(),text:i.getTextContent()}),fn(i)&&i.getChildren().forEach(r)}r(Sn())}),t}function r2(e,t,n,r){let i=0;for(const s of t){const o=[];let a=0;const u=i;for(;a<s.text.length&&i<e.length;)e[i]===s.text[a]?(o[a]=i,i++,a++):i++;if(s.key===n){if(r<s.text.length)return o[r]??u+r;const l=s.text.length-1;return(o[l]??u+l)+1}}return 0}function cN(e,t,n){return gt(e.registerCommand(Of,r=>{const{markdown:i}=r;ch.debug("INSERT_MARKDOWN_COMMAND payload:",r),r.editorState?e.setEditorState(r.editorState,{tag:Aa}):aN(e,r.historyState);const s=e.getEditorState().read(()=>Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"")==="");return r.replaceDocument||s?(t.setDocument("markdown",i,{keepHistory:!0}),!1):(setTimeout(()=>{e.update(()=>{try{const o=Yd(i,n.markdownReaders);let a=ce();a===null&&(Sn().selectEnd(),a=ce());const u=I6(o.children);return ch.debug("INSERT_MARKDOWN_COMMAND nodes:",u),uN(u),!0}catch(o){ch.error("Failed to handle markdown paste:",o)}},{tag:j7})},0),!1)},Fn),e.registerCommand(oN,r=>{const i=t.getDocument("markdown");if(!i)return!1;const s=t.getSelection();if(!s||s.type!=="range")return!1;const o=lN(t),a=r2(i,o,s.startNodeId,s.startOffset),u=r2(i,o,s.endNodeId,s.endOffset),l=Math.min(a,u),h=Math.max(a,u);return r.onResult(t2(i,l),t2(i,h)),!1},Fn))}const Zd=uu("INodeService");var hN=class{constructor(){this.processNodeTreeHandlers=[]}registerProcessNodeTree(e){this.processNodeTreeHandlers.push(e)}processNodeTree(e){for(const t of this.processNodeTreeHandlers)t(e)}};Bt();var no;const fN=(no=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n;const r=new hN;t.registerService(Zd,r)}onInit(){}},no.pluginName="INodePlugin",no);var hh=class R6{constructor(t){this.before="",this.after="",this.children=[],this.markdownService=t}appendLine(t){this.children.push(t)}newChild(){const t=new R6(this.markdownService);return this.children.push(t),t}wrap(t,n){this.before=t,this.after=n}addProcessor(t){this.processor=t}toString(){const t=this.before+this.children.map(n=>n.toString()).join("")+this.after;return this.processor?this.processor(this.before,this.children.map(n=>n.toString()).join(""),this.after):t}processChild(t,n){const r=this.markdownService.markdownWriters[n.getType()];let i=t;fn(n)&&(i=i.newChild());let s=!1;r&&(s=r(i,n)),!s&&fn(n)&&n.getChildren().forEach(o=>this.processChild(i,o))}};rn();var dN=class extends Nd{formatMarkdown(e){try{const t=g6().use([[M6,{singleTilde:!1}]]).data("settings",{bullet:"-",emphasis:"*",fences:!0,resourceLink:!0,rule:"-",strong:"*",tightDefinitions:!0}).processSync(e);return String(t)}catch(t){return Zl.error("Failed to format markdown:",t),e}}constructor(e,t,n){super(e),this.dataType=e,this.markdownService=t,this.getService=n}read(e,t){var r,i;const n={root:Yd(t,this.markdownService.markdownReaders)};(i=(r=this.getService)==null?void 0:r.call(this,Zd))==null||i.processNodeTree(n),Zl.debug("Parsed Lexical State:",n),e.setEditorState(e.parseEditorState(n))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var u,l,h;const n=ce();if(!n)return null;const r=n.getNodes();if(de(n)){const d=r.length-1,g=n.anchor,m=n.focus,y=g.isBefore(m),w=r[0],_=r[d],[v,M]=ab(n);let T=[];const D=[];for(let U=0;U<r.length;U++){const z=r[U];if(fn(z)){const V={...z.exportJSON(),$key:z.getKey()};for(let ee=0;ee<D.length;ee++){const Q=D[ee],ae=ze(Q.$key);z.isParentOf(ae)&&(V.children.push(Q),D.splice(ee,1),ee--)}let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((u=ze(T[ee].$key))!=null&&u.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V),T.push(V)}else if(Pt(z)){const V={...z.exportJSON(),$key:z.getKey()};z===w?z===_?(g.type!=="element"||m.type!=="element"||m.offset===g.offset)&&(V.text=v<M?V.text.slice(v,M):V.text.slice(M,v)):V.text=y?V.text.slice(v):V.text.slice(M):z===_&&(V.text=y?V.text.slice(0,M):V.text.slice(0,v));let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((l=ze(T[ee].$key))!=null&&l.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}else{const V={...z.exportJSON(),$key:z.getKey()};let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((h=ze(T[ee].$key))!=null&&h.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}}const R=ke.createRootNode();if(D.some(U=>ke.isTextNode(U))){const U=ke.createParagraph();ke.appendChild(U,...D),ke.appendChild(R,U)}else ke.appendChild(R,...D);const F=e.parseEditorState({root:R}),j=F._nodeMap.get("root"),K=new hh(this.markdownService);return F.read(()=>(j.getChildren().forEach(U=>K.processChild(K,U)),this.formatMarkdown(K.toString())))}const i=ke.createRootNode();if(r.some(d=>d.isInline())){const d=ke.createParagraph();ke.appendChild(d,...r.map(g=>g.exportJSON())),ke.appendChild(i,d)}else ke.appendChild(i,...r.map(d=>d.exportJSON()));const s=e.parseEditorState({root:i}),o=s._nodeMap.get("root"),a=new hh(this.markdownService);return s.read(()=>(o.getChildren().forEach(d=>a.processChild(a,d)),a.toString()))}):e.getEditorState().read(()=>{const n=Sn(),r=new hh(this.markdownService);return n.getChildren().forEach(i=>r.processChild(r,i)),this.formatMarkdown(r.toString())})}};Bt();Ot();const pN="strong,em,b,i,h1,h2,h3,h4,h5,h6,ul,ol,table,img,blockquote,pre>code,a[href]";function mN(e){let t=0;return/^#{1,6}\s+\S+/m.test(e)&&(t+=3),/(\*\*|__)[\S\s]+?\1/.test(e)&&(t+=2),/([*_])[\S\s]+?\1/.test(e)&&(t+=1),/~~[\S\s]+?~~/.test(e)&&(t+=2),/`[^`]+`/.test(e)&&(t+=2),/^```[\w+-]*\s*$/m.test(e)&&/^```\s*$/m.test(e)&&(t+=4),/\[.+?]\s*\([^)]+\)/.test(e)&&(t+=2),/!\[.*?]\s*\([^)]+\)/.test(e)&&(t+=2),/^[*+-]\s+\S+/m.test(e)&&(t+=2),/^\d+\.\s+\S+/m.test(e)&&(t+=2),/^>\s+\S+/m.test(e)&&(t+=2),/^[*_-]{3,}\s*$/m.test(e)&&(t+=2),/^\|.*\|/.test(e)&&/^\|[:-]+\|/.test(e)&&(t+=3),t}function gN(){const e=ce();if(de(e)){let t=e.anchor.getNode();for(;t;){if(mt(t)||xn(t)||Mi(t))return!0;t=t.getParent()}return!1}return Ln(e)?e.getNodes().some(t=>mt(t)||Mi(t)):!1}var ro;const Vi=(ro=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","markdown"),this.service=new LM(t),t.registerService(Lt,this.service),this.markdownDataSource=new dN("markdown",this.service,r=>t.requireService(r)),t.registerDataSource(this.markdownDataSource)}onInit(t){this.register(t.registerUpdateListener(({tags:n,dirtyLeaves:r,editorState:i,prevEditorState:s})=>{if(n.has(z7)||n.has(Aa)||t.isComposing())return;const o=i.read(ce),a=s.read(ce);if(!de(a)||!de(o)||!o.isCollapsed()||o.is(a))return;const u=o.anchor.key,l=o.anchor.offset,h=i._nodeMap.get(u);!Pt(h)||!r.has(u)||l!==1&&l>a.anchor.offset+1||t.update(()=>{if(!Vg(h))return;const d=h.getParent();d===null||mt(d)||this.service.runTransformers(d,h,o.anchor.offset)&&this.kernel.emit("markdownTransform",{trigger:"type"})})})),this.register(t.registerCommand(R7,n=>{const r=t.getEditorState().read(()=>{const a=ce();if(!de(a)||!a.isCollapsed())return!1;const u=a.anchor.key,l=ze(u);return l?{anchorNode:l,offset:a.anchor.offset}:!1});if(!r)return!1;const{anchorNode:i,offset:s}=r;if(!Vg(i))return!1;const o=i.getParent();return o===null||mt(o)?!1:this.service.testTransformers(o,i,s,"enter")?(queueMicrotask(()=>{t.update(()=>{this.service.runTransformers(o,i,s,"enter")}),this.kernel.emit("markdownTransform",{trigger:"enter"})}),n==null||n.stopPropagation(),n==null||n.stopImmediatePropagation(),n==null||n.preventDefault(),!0):!1},Zn)),this.register(t.registerCommand(yc,n=>{var a;if(!(n instanceof ClipboardEvent)||O6(n)||KM(n)||!this.shouldHandlePasteMarkdown()||t.getEditorState().read(()=>gN()))return!1;const r=n.clipboardData;if(!r)return!1;const i=r.getData("text/plain").trimEnd().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");if(!i||this.hasRichHTML(r))return!1;const s=mN(i);if((a=this.config)!=null&&a.onPasteMarkdown&&s>=2){n.preventDefault(),n.stopPropagation();const u=this.kernel.getHistoryState().current,l=t.getEditorState(),h=l.read(()=>{const d=ce(),g=Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");return g===""?!0:de(d)&&!d.isCollapsed()&&d.getTextContent().length>=g.length-1});return Promise.resolve(this.config.onPasteMarkdown(i)).then(d=>{d?(t.dispatchCommand(Of,{editorState:l,historyState:u,markdown:i,replaceDocument:h}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:u,markdown:i,matchedPatterns:[],score:s})):(t.setEditorState(l,{tag:Aa}),setTimeout(()=>{t.update(()=>{const g=ce();de(g)&&g.insertRawText(i)})},0))}),!0}if(/^https?:\/\/\S+$/i.test(i)||s<2||s<6)return!1;const o=this.kernel.getHistoryState().current;return setTimeout(()=>{t.dispatchCommand(Of,{historyState:o,markdown:i}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:o,markdown:i,matchedPatterns:[],score:s})},10),!1},Zn)),this.register(cN(t,this.kernel,this.service)),this.register(t.registerCommand(P7,n=>{if(!(n instanceof ClipboardEvent))return!1;const r=n.clipboardData;if(!r)return!1;const i=ce();if(!i||i.isCollapsed())return!1;const s=this.markdownDataSource.write(t,{selection:!0});return s?(n.preventDefault(),B7(r,$7(i)),r.setData("text/plain",s),r.setData("text/markdown",s),this.logger.debug("copy with text/markdown:",{markdownLength:s.length}),!0):!1},Xe))}hasRichHTML(t){const n=t.getData("text/html");return!n||/data-vscode|vscode-/i.test(n)||typeof DOMParser>"u"?!1:new DOMParser().parseFromString(n,"text/html").body.querySelectorAll(pN).length>0}shouldHandlePasteMarkdown(){var t,n;return((t=this.config)==null?void 0:t.enablePasteMarkdown)===!1?!1:((n=this.config)==null?void 0:n.autoFormatMarkdown)!==!1}},ro.pluginName="MarkdownPlugin",ro),bN=tt(({css:e,cssVar:t})=>({placeholder:e`
|
|
378
378
|
pointer-events: none;
|
|
379
379
|
user-select: none;
|
|
380
380
|
|
|
@@ -1734,7 +1734,7 @@ ${this.__markdown}
|
|
|
1734
1734
|
## 分支 2`,style:{border:"none",flex:1,fontFamily:"monospace",fontSize:14,lineHeight:1.6,outline:"none",padding:16,resize:"none"},value:r})]}),O.jsx("div",{style:{display:"flex",flexDirection:"column",width:"50%"},children:O.jsx(Wx,{markdown:r})})]})]})}function zq({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__markdown;E.useLayoutEffect(()=>{const u=n.getKey();let l=!1;t.getEditorState().read(()=>{const h=ze(u);h&&j4(h)&&h.__autoOpenEditor&&(l=!0)}),l&&(i(!0),t.update(()=>{const h=ze(u);h&&j4(h)&&h.__autoOpenEditor&&h.clearAutoOpenEditor()}))},[t,n.getKey()]);const o=E.useCallback(()=>{t.update(()=>{const u=n.getLatest(),l=u.getNextSibling(),h=u.getPreviousSibling();if(u.remove(),l){l.selectStart();return}h&&h.selectEnd()})},[t,n]),a=E.useCallback(u=>{t.update(()=>{n.updateMarkdown(u)}),i(!1)},[t,n]);return r?O.jsx("div",{className:e,children:O.jsx(Oq,{markdown:s,onClose:()=>i(!1),onSave:a})}):O.jsxs("div",{className:e,style:{margin:"8px 0",position:"relative"},children:[O.jsxs("div",{style:{bottom:8,display:"flex",gap:4,position:"absolute",right:8,zIndex:10},children:[O.jsx("button",{onClick:()=>i(!0),style:{background:"rgba(0,0,0,0.5)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"编辑"}),O.jsx("button",{onClick:o,style:{background:"rgba(255,77,79,0.7)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"删除"})]}),O.jsx("div",{style:{border:"1px solid #f0f0f0",borderRadius:8,height:350},children:O.jsx(Wx,{markdown:s})})]})}function xU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((s,o)=>O.jsx(zq,{className:e,editor:o,node:s}),[e]),i=E.useRef(!1);return i.current||(i.current=!0,n.registerPlugin(Fq,{decorator:r,theme:t})),null}const Rq=lt("INSERT_MATH_COMMAND"),Kx=lt("UPDATE_MATH_COMMAND"),Nl=lt("SELECT_MATH_SIDE_COMMAND");function Pq(e){return gt(e.registerCommand(Rq,t=>{const{code:n}=t;return e.update(()=>{const r=cu(n);_n([r]),qn(r.getParentOrThrow())&&xs(r,hn).selectEnd()}),!0},Fn),e.registerCommand(Kx,t=>{const{code:n,key:r}=t;return e.update(()=>{const i=ze(r);i&&(i.updateCode(n),i.selectNext())}),!0},Fn),e.registerCommand(Nl,t=>{const{key:n,prev:r}=t;return e.update(()=>{const i=ze(n);i&&(r?i.selectPrevious():i.selectNext())}),!0},Fn))}function Bq(e){const t=e.trim();return t?!!(/\\[A-Za-z]/.test(t)||/[\d!()*+,/<=>^_{|}-]/.test(t)||/^[A-Za-z]$/.test(t)):!1}rn();Bt();Ot();var wo;const $q=(wo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","math"),t.registerNodes([xa,Fi]),n!=null&&n.theme&&t.registerThemes(n==null?void 0:n.theme),this.registerDecorator(t,xa.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null),this.registerDecorator(t,Fi.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Pq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t==null||t.registerMarkdownShortCut({regExp:/\$([^\s$](?:[^$]*[^\s$])?)\$\s?$/,replace:(n,r)=>{const[,i]=r;if(!Bq(i))return;const s=cu(i);this.logger.debug("Math node inserted:",s),n.insertBefore(s),n.setTextContent(""),n.select()},trigger:"$",type:"text-match"}),t==null||t.registerMarkdownShortCut({regExp:/^(\$\$)$/,replace:(n,r,i,s)=>{const o=wc();s||n.getNextSibling()?n.replace(o):n.insertBefore(o);const a=yn();a.add(o.getKey()),je(a)},trigger:"enter",type:"element"}),t==null||t.registerMarkdownWriter(xa.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownWriter(Fi.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownReader("inlineMath",n=>ke.createElementNode("math",{code:n.value,version:1})),t==null||t.registerMarkdownReader("math",n=>ke.createElementNode("mathBlock",{code:n.value,version:1}))}},wo.pluginName="MathPlugin",wo),Vx=E.memo(({children:e,isBlockMode:t,mathDOM:n,onFocus:r,prev:i})=>{const s=E.useRef(null),[o,a]=E.useState(void 0),u=E.useRef(void 0),l=E.useCallback(m=>{const y=typeof m=="number"?Math.round(m):void 0;u.current!==y&&(u.current=y,a(y))},[]),h=E.useCallback(()=>{if(!t){l(void 0);return}const m=n==null?void 0:n.closest('[contenteditable="true"]');m&&l(m.getBoundingClientRect().width)},[t,n,l]),d=E.useCallback(()=>Zc({callback:()=>{!s.current||!n||(r==null||r(),h())},floating:s.current,placement:t?"bottom-start":"bottom",reference:n}),[t,n,r,h]),g=E.useCallback(()=>{n&&d()},[n,d]);return E.useEffect(()=>{if(!n||!s.current)return;const m=s.current,y=new ResizeObserver(()=>{h()});y.observe(m);let w=null;return t&&(w=n.closest('[contenteditable="true"]'),w&&y.observe(w)),d(),window.addEventListener("resize",d),()=>{y.disconnect(),window.removeEventListener("resize",d)}},[n,i,t,d]),E.useEffect(()=>{n||!s.current||tu(s.current)},[n]),O.jsx(au,{arrow:!1,content:O.jsx(It,{className:zi.mathEditor,"data-math-editor-container":!0,style:o?{width:o}:void 0,children:e}),open:!!n,placement:t?"bottomLeft":"bottom",styles:{content:{borderRadius:"6px",padding:0}},children:O.jsx("span",{className:zi.mathEditorAnchor,onClick:g,ref:s})})});Vx.displayName="MathEditorContainer";Hb();const Gx=E.memo(({focusRef:e,mathNode:t,onArrowLeft:n,onArrowRight:r,onCancel:i,onDelete:s,onSubmit:o,onValidationChange:a,onValueChange:u,value:l})=>{const h=nr(),d=E.useRef(null),[g,m]=E.useState("");E.useEffect(()=>{e==null||e(d.current)},[e]),E.useEffect(()=>{if(!t)return;if(!l.trim()){m(""),a==null||a(!0);return}const w=setTimeout(()=>{try{tw(l,{displayMode:!0,throwOnError:!0}),m(""),a==null||a(!0)}catch(_){m(_ instanceof Error?_.message:"LaTeX Parse Error"),a==null||a(!1)}},50);return()=>clearTimeout(w)},[l,t,a]);const y=E.useCallback(w=>{if(t){if(ob(w,qb)&&w.key==="Enter"){w.preventDefault(),o();return}if(w.key==="Escape"){w.preventDefault(),i();return}if(w.key==="Backspace"&&!l.trim()){w.preventDefault(),s();return}w.key==="ArrowLeft"&&w.currentTarget.selectionStart===0&&(w.preventDefault(),n()),w.key==="ArrowRight"&&w.currentTarget.selectionStart===w.currentTarget.value.length&&(w.preventDefault(),r())}},[t,o,i,s,n,r,l]);return O.jsxs(O.Fragment,{children:[O.jsx(nw,{autoFocus:!0,autoSize:{maxRows:6,minRows:1},className:zi.mathEditorTextArea,onChange:w=>{u(w.target.value)},onKeyDown:y,placeholder:`${h("math.placeholder")}...`,ref:d,resize:!1,value:l,variant:"borderless"}),g&&O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,paddingBlock:4,paddingInline:12,width:"100%",children:O.jsx(qr,{fontSize:13,type:"danger",children:g})}),O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,justify:"flex-end",padding:4,width:"100%",children:O.jsxs(Pl,{onClick:w=>{w.preventDefault(),o()},size:"small",type:"text",variant:"filled",children:[h("confirm"),O.jsx(Eb,{compact:!0,keys:"mod+enter",variant:"borderless"})]})})]})});Gx.displayName="MathEditorContent";kr();const jq=E.memo(({renderComp:e})=>{const t=E.useRef(null),n=E.useRef(!1),[r,i]=E.useState(null),[s,o]=E.useState(""),a=E.useRef(""),u=E.useRef(!0),[l,h]=E.useState(null),[d,g]=E.useState(!1),[m,y]=E.useState(!1),[w,_]=E.useState(!1),[v]=_t();E.useEffect(()=>{if(!r||!u.current)return;const z=setTimeout(()=>{const V=v.getLexicalEditor();if(V&&!n.current){const X=r.code;if(s&&X&&X===s)return;n.current=!0,V.update(()=>{if(V.getEditorState().read(()=>V.getElementByKey(r.getKey()))){const ee=r.getWritable();ee.__code=s}}),setTimeout(()=>{n.current=!1},50)}},50);return()=>clearTimeout(z)},[s,r,v]);const M=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();if(z){const V=u.current?s:a.current;z.dispatchCommand(Kx,{code:V,key:r.getKey()})}},[v,r,s]),T=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&(z.dispatchCommand(Nl,{key:r.getKey(),prev:!1}),z.focus())},[r,v]),D=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&z.update(()=>{r.remove()})},[r,v]),R=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!0})},[r,v]),F=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!1})},[r,v]),j=E.useCallback(()=>{var z,V,X,ee;(z=t.current)==null||z.focus(),d&&((ee=(X=(V=t.current)==null?void 0:V.resizableTextArea)==null?void 0:X.textArea)==null||ee.setSelectionRange(0,0))},[d]),K=E.useCallback(z=>{t.current=z},[]);br(z=>gt(z.registerUpdateListener(({prevEditorState:V})=>{if(n.current)return;const X=z.getEditorState().read(()=>{const ee=ce();if(!Ln(ee))return!1;const Q=ee.getNodes()[0];if(!x3(Q))return!1;const ae=r&&r.getKey()===Q.getKey();return i(Q),!ae&&Q.code!==s&&(o(Q.code),a.current=Q.code,u.current=!0),h(z.getElementByKey(Q.getKey())),y(Q instanceof Fi),Q});if(X){const ee=V.read(()=>{const Q=V._selection;return de(Q)?Q.anchor.key:!1});z.getEditorState().read(()=>{const Q=ee?ze(ee):null;Q&&f9(Q,X)<0?g(!0):g(!1)}),_(!0)}X||(i(null),h(null),o(""),a.current="",u.current=!0,y(!1),_(!1))})),[r,s]);const U=O.jsx(Gx,{focusRef:K,mathNode:r,onArrowLeft:R,onArrowRight:F,onCancel:T,onDelete:D,onSubmit:M,onValidationChange:z=>{u.current=z,z&&(a.current=s)},onValueChange:o,value:s});return E.useEffect(()=>{if(!w)return;const z=V=>{const X=V.target;X&&(Array.from(document.querySelectorAll("[data-math-editor-container]")).some(ee=>ee&&ee.contains(X))||T())};return document.addEventListener("mousedown",z),document.addEventListener("touchstart",z),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("touchstart",z)}},[w,T]),e?O.jsx(O.Fragment,{children:e({children:O.jsx("div",{"data-math-editor-container":!0,children:U}),open:w})}):O.jsx(Yc,{children:O.jsx(Vx,{isBlockMode:m,mathDOM:l,onFocus:j,prev:d,children:U})})}),qq=({mathBlock:e})=>{const t=nr(),n=O.jsx(qr,{as:"span",className:at("katex",zi.mathPlaceholder),fontSize:e?"1.2em":"1em",type:"secondary",children:t("math.placeholder")});return e?O.jsx(af,{padding:18,width:"100%",children:n}):n};Ot();const Hq=Qe("plugin","math"),Uq=({editor:e,node:t,className:n})=>{const r=E.useRef(null),[i,s,o]=zo(t.getKey()),[a,u]=E.useState(!1),l=t instanceof Fi;return E.useEffect(()=>{r.current&&t.code&&Yk.render(t.code,r.current,{displayMode:t instanceof Fi,throwOnError:!1})},[t.code]),E.useEffect(()=>{const h=e.getElementByKey(t.getKey());if(h){const d=setTimeout(()=>{a?(Ut(h,"editing"),ua(h,"selected")):i?(Ut(h,"selected"),ua(h,"editing")):(ua(h,"selected"),ua(h,"editing"))},10);return()=>clearTimeout(d)}},[i,a,e,t]),br(h=>h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const d=ce();if(!Ln(d)){u(!1);return}const g=d.getNodes()[0];if(!x3(g)){u(!1);return}g.getKey()===t.getKey()?u(!0):u(!1)})}),[t]),O.jsx("span",{className:n,onClick:E.useCallback(h=>{Hq.debug("📊 Math click event:",h.target===r.current),h.preventDefault(),h.stopPropagation(),i&&o(),s(!0),e.focus()},[o,e,i,s]),ref:r,children:t.code?t.code:O.jsx(qq,{mathBlock:l})})},Wq=({className:e,renderComp:t,theme:n})=>{const[r]=_t();return E.useLayoutEffect(()=>{r.registerPlugin(Vi),r.registerPlugin($q,{decorator:(i,s)=>O.jsx(Uq,{className:e,editor:s,node:i}),theme:n||zi})},[r,e,n,zi]),O.jsx(jq,{renderComp:t})};Wq.displayName="ReactMathPlugin";var Gs=class Dl extends Wr{static getType(){return"meta2d"}static clone(t){return new Dl(t.__diagram,t.__svg,t.__key,t.__autoOpenEditor)}static importJSON(t){return new Dl(t.diagram,t.svg)}constructor(t="",n="",r,i=!1){super(r),this.__diagram=t,this.__svg=n,this.__autoOpenEditor=i}clearAutoOpenEditor(){const t=this.getWritable();t.__autoOpenEditor=!1}createDOM(t){const n=document.createElement("div");return Ut(n,t.theme.meta2d??"editor-meta2d"),n}decorate(t){var r;const n=(r=Hi(t))==null?void 0:r.getDecorator(Dl.getType());return n?typeof n=="function"?n(this,t):{queryDOM:n.queryDOM,render:n.render(this,t)}:null}exportJSON(){return{...super.exportJSON(),diagram:this.__diagram,svg:this.__svg}}getTextContent(){return`---meta2d---
|
|
1735
1735
|
${this.__diagram}
|
|
1736
1736
|
---/meta2d---
|
|
1737
|
-
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Kq=lt("INSERT_META2D_COMMAND");function Vq(e){return e.registerCommand(Kq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Gq=/^---meta2d---$/i,Xq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Jq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Yq=(vo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,t.registerNodes([Gs]),n!=null&&n.theme&&t.registerThemes(n.theme),this.registerDecorator(t,Gs.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Vq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Gq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=yn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Jq(n).match(Xq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:xD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Zq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-9HAADQ7Y.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Qq(e){return(await Zq()).generateSvgFromDiagram(e)}function eH(e){const t=e.trimStart();return t.startsWith("<svg")?t.replace(/^<svg\b/,'<svg style="max-width:100%;height:auto;display:block;margin:0 auto" '):e}function W4({color:e,label:t,onClick:n,title:r}){return O.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),n()},style:{alignItems:"center",background:"#fff",border:"1px solid #e5e5e5",borderRadius:6,color:e,cursor:"pointer",display:"inline-flex",height:28,justifyContent:"center",width:28},title:r,type:"button",children:t})}function tH({diagram:e,onDelete:t,onEdit:n,onSvgReady:r,svg:i}){const[s,o]=E.useState(!1),[a,u]=E.useState(null),[l,h]=E.useState(!1),[d,g]=E.useState(!1),m=E.useRef(null);return E.useEffect(()=>{u(null),g(!1)},[e]),E.useEffect(()=>{if(!e||d||s)return;if(i){m.current=e;return}let y=!0;const w=window.setTimeout(()=>{y&&(u("Preview timeout (still loading). Double-click to open editor."),g(!0),o(!1))},5e3);return o(!0),Qq(e).then(_=>{if(y){if(window.clearTimeout(w),_){m.current=e,r(_);return}u("Preview generation failed. Double-click to open editor."),g(!0)}}).finally(()=>{y&&o(!1)}),()=>{y=!1,window.clearTimeout(w)}},[e,d,r,i]),O.jsxs("div",{onDoubleClick:y=>{y.stopPropagation(),n()},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{background:"#fff",border:"1px solid #efefef",borderRadius:10,cursor:"pointer",minHeight:140,overflow:"hidden",padding:10,position:"relative"},children:[l&&!!i&&O.jsxs("div",{style:{display:"flex",gap:8,position:"absolute",right:10,top:10,zIndex:1},children:[O.jsx(W4,{color:"#1677ff",label:"✎",onClick:n,title:"Edit diagram"}),O.jsx(W4,{color:"#ff4d4f",label:"🗑",onClick:t,title:"Delete diagram"})]}),i?O.jsx("div",{style:{alignItems:"center",display:"flex",justifyContent:"center",maxHeight:400,overflow:"auto",width:"100%"},children:O.jsx("div",{dangerouslySetInnerHTML:{__html:eH(i)},style:{lineHeight:0,maxWidth:"100%",width:"100%"}})}):O.jsx("div",{style:{alignItems:"center",color:a?"#cf1322":"#999",display:"flex",justifyContent:"center",minHeight:120,textAlign:"center"},children:s?"Generating preview...":a||"Double-click to edit diagram"})]})}const nH=E.memo(tH),rH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-BhsjOCtK.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function iH({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__diagram,o=n.__svg;E.useLayoutEffect(()=>{const l=n.getKey();let h=!1;t.getEditorState().read(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&(h=!0)}),h&&i(!0),h&&t.update(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&d.clearAutoOpenEditor()})},[t,n.getKey()]);const a=E.useCallback(()=>{t.update(()=>{const l=n.getLatest(),h=l.getNextSibling(),d=l.getPreviousSibling();if(l.remove(),h){h.selectStart();return}d&&d.selectEnd()})},[t,n]),u=E.useCallback((l,h)=>{t.update(()=>{n.updateDiagram(l,h)}),i(!1)},[t,n]);return O.jsxs("div",{className:e,style:{margin:0},children:[O.jsx(nH,{diagram:s,onDelete:a,onEdit:()=>i(!0),onSvgReady:E.useCallback(l=>{t.update(()=>{n.updateDiagram(n.__diagram,l)})},[t,n]),svg:o}),r&&O.jsx(E.Suspense,{fallback:null,children:O.jsx(rH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function kU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(iH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Yq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),sH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};sH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function wU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function oH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const vU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=yn();h.add(u),je(h)}),requestAnimationFrame(()=>{const h=l.getElementByKey(u);h&&h.scrollIntoView({behavior:"smooth",block:"center"})}))},[e]);return!r||i.length===0?null:O.jsxs("div",{style:{borderLeft:"1px solid rgba(0, 0, 0, 0.08)",paddingLeft:12},children:[O.jsx("div",{style:{color:"rgba(0,0,0,0.45)",fontSize:12,fontWeight:600,marginBottom:8},children:"OUTLINE"}),i.map(u=>O.jsx("div",{onClick:()=>a(u.key),onMouseEnter:l=>{l.currentTarget.style.background="rgba(0,0,0,0.04)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},style:{borderRadius:4,color:"rgba(0,0,0,0.75)",cursor:"pointer",fontSize:13,lineHeight:"28px",overflow:"hidden",paddingLeft:(u.level-1)*16+8,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.text},u.key))]})},aH="Hide outline",uH="Show outline",lH="outline";function SU(e){const{collapseTitle:t=aH,expandTitle:n=uH,onVisibleChange:r,visible:i}=e??{},s=oH(i!==void 0&&r!==void 0?{onVisibleChange:r,visible:i}:void 0);return E.useMemo(()=>{if(!s.ready)return null;const{toggle:o,visible:a}=s;return{active:a,icon:a?zb:Ow,key:lH,label:a?t:n,onClick:o}},[t,n,s])}kr();function cH(e,t){const{domRows:n}=e;for(const[r,i]of n.entries())if(i)for(const[s,o]of i.entries()){if(!o)continue;const a=jr(o.elem);a!==null&&t(o,a,{x:s,y:r})}}function hH(e,t){const n=t.elem,r=e._config.theme;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode"),Ut(n,r.tableCellSelected)}function fH(e,t){const n=t.elem;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode");const r=e._config.theme;ua(n,r.tableCellSelected)}function dH(e,t,n){const r=new Set(n?n.getNodes():[]);cH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,hH(e,i)):(i.highlighted=!1,fH(e,i),o.getAttribute("style")||o.removeAttribute("style"))})}function K4(e){const t=e.getShape();return{columns:t.toX-t.fromX+1,rows:t.toY-t.fromY+1}}function pH(){const e=ce();if(de(e)&&!e.isCollapsed()||fi(e)&&!e.anchor.is(e.focus)||!de(e)&&!fi(e))return!1;const[t]=Cb(e.anchor);return t.__colSpan>1||t.__rowSpan>1}function mH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(pH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&mH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon:$w,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:Rw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon:Uw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Kw,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Iw,key:"table-delete",label:m("table.delete"),onClick:()=>D()}],[n,u,h,o.rows,o.columns,i.__headerState,w,_,v,M,R,T,D,F,j])},children:r})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1737
|
+
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Kq=lt("INSERT_META2D_COMMAND");function Vq(e){return e.registerCommand(Kq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Gq=/^---meta2d---$/i,Xq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Jq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Yq=(vo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,t.registerNodes([Gs]),n!=null&&n.theme&&t.registerThemes(n.theme),this.registerDecorator(t,Gs.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Vq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Gq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=yn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Jq(n).match(Xq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:xD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Zq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-BDjANcdr.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Qq(e){return(await Zq()).generateSvgFromDiagram(e)}function eH(e){const t=e.trimStart();return t.startsWith("<svg")?t.replace(/^<svg\b/,'<svg style="max-width:100%;height:auto;display:block;margin:0 auto" '):e}function W4({color:e,label:t,onClick:n,title:r}){return O.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),n()},style:{alignItems:"center",background:"#fff",border:"1px solid #e5e5e5",borderRadius:6,color:e,cursor:"pointer",display:"inline-flex",height:28,justifyContent:"center",width:28},title:r,type:"button",children:t})}function tH({diagram:e,onDelete:t,onEdit:n,onSvgReady:r,svg:i}){const[s,o]=E.useState(!1),[a,u]=E.useState(null),[l,h]=E.useState(!1),[d,g]=E.useState(!1),m=E.useRef(null);return E.useEffect(()=>{u(null),g(!1)},[e]),E.useEffect(()=>{if(!e||d||s)return;if(i){m.current=e;return}let y=!0;const w=window.setTimeout(()=>{y&&(u("Preview timeout (still loading). Double-click to open editor."),g(!0),o(!1))},5e3);return o(!0),Qq(e).then(_=>{if(y){if(window.clearTimeout(w),_){m.current=e,r(_);return}u("Preview generation failed. Double-click to open editor."),g(!0)}}).finally(()=>{y&&o(!1)}),()=>{y=!1,window.clearTimeout(w)}},[e,d,r,i]),O.jsxs("div",{onDoubleClick:y=>{y.stopPropagation(),n()},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{background:"#fff",border:"1px solid #efefef",borderRadius:10,cursor:"pointer",minHeight:140,overflow:"hidden",padding:10,position:"relative"},children:[l&&!!i&&O.jsxs("div",{style:{display:"flex",gap:8,position:"absolute",right:10,top:10,zIndex:1},children:[O.jsx(W4,{color:"#1677ff",label:"✎",onClick:n,title:"Edit diagram"}),O.jsx(W4,{color:"#ff4d4f",label:"🗑",onClick:t,title:"Delete diagram"})]}),i?O.jsx("div",{style:{alignItems:"center",display:"flex",justifyContent:"center",maxHeight:400,overflow:"auto",width:"100%"},children:O.jsx("div",{dangerouslySetInnerHTML:{__html:eH(i)},style:{lineHeight:0,maxWidth:"100%",width:"100%"}})}):O.jsx("div",{style:{alignItems:"center",color:a?"#cf1322":"#999",display:"flex",justifyContent:"center",minHeight:120,textAlign:"center"},children:s?"Generating preview...":a||"Double-click to edit diagram"})]})}const nH=E.memo(tH),rH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-CyddeNUo.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function iH({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__diagram,o=n.__svg;E.useLayoutEffect(()=>{const l=n.getKey();let h=!1;t.getEditorState().read(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&(h=!0)}),h&&i(!0),h&&t.update(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&d.clearAutoOpenEditor()})},[t,n.getKey()]);const a=E.useCallback(()=>{t.update(()=>{const l=n.getLatest(),h=l.getNextSibling(),d=l.getPreviousSibling();if(l.remove(),h){h.selectStart();return}d&&d.selectEnd()})},[t,n]),u=E.useCallback((l,h)=>{t.update(()=>{n.updateDiagram(l,h)}),i(!1)},[t,n]);return O.jsxs("div",{className:e,style:{margin:0},children:[O.jsx(nH,{diagram:s,onDelete:a,onEdit:()=>i(!0),onSvgReady:E.useCallback(l=>{t.update(()=>{n.updateDiagram(n.__diagram,l)})},[t,n]),svg:o}),r&&O.jsx(E.Suspense,{fallback:null,children:O.jsx(rH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function kU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(iH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Yq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),sH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};sH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function wU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function oH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const vU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=yn();h.add(u),je(h)}),requestAnimationFrame(()=>{const h=l.getElementByKey(u);h&&h.scrollIntoView({behavior:"smooth",block:"center"})}))},[e]);return!r||i.length===0?null:O.jsxs("div",{style:{borderLeft:"1px solid rgba(0, 0, 0, 0.08)",paddingLeft:12},children:[O.jsx("div",{style:{color:"rgba(0,0,0,0.45)",fontSize:12,fontWeight:600,marginBottom:8},children:"OUTLINE"}),i.map(u=>O.jsx("div",{onClick:()=>a(u.key),onMouseEnter:l=>{l.currentTarget.style.background="rgba(0,0,0,0.04)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},style:{borderRadius:4,color:"rgba(0,0,0,0.75)",cursor:"pointer",fontSize:13,lineHeight:"28px",overflow:"hidden",paddingLeft:(u.level-1)*16+8,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.text},u.key))]})},aH="Hide outline",uH="Show outline",lH="outline";function SU(e){const{collapseTitle:t=aH,expandTitle:n=uH,onVisibleChange:r,visible:i}=e??{},s=oH(i!==void 0&&r!==void 0?{onVisibleChange:r,visible:i}:void 0);return E.useMemo(()=>{if(!s.ready)return null;const{toggle:o,visible:a}=s;return{active:a,icon:a?zb:Ow,key:lH,label:a?t:n,onClick:o}},[t,n,s])}kr();function cH(e,t){const{domRows:n}=e;for(const[r,i]of n.entries())if(i)for(const[s,o]of i.entries()){if(!o)continue;const a=jr(o.elem);a!==null&&t(o,a,{x:s,y:r})}}function hH(e,t){const n=t.elem,r=e._config.theme;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode"),Ut(n,r.tableCellSelected)}function fH(e,t){const n=t.elem;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode");const r=e._config.theme;ua(n,r.tableCellSelected)}function dH(e,t,n){const r=new Set(n?n.getNodes():[]);cH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,hH(e,i)):(i.highlighted=!1,fH(e,i),o.getAttribute("style")||o.removeAttribute("style"))})}function K4(e){const t=e.getShape();return{columns:t.toX-t.fromX+1,rows:t.toY-t.fromY+1}}function pH(){const e=ce();if(de(e)&&!e.isCollapsed()||fi(e)&&!e.anchor.is(e.focus)||!de(e)&&!fi(e))return!1;const[t]=Cb(e.anchor);return t.__colSpan>1||t.__rowSpan>1}function mH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(pH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&mH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon:$w,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:Rw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon:Uw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Kw,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Iw,key:"table-delete",label:m("table.delete"),onClick:()=>D()}],[n,u,h,o.rows,o.columns,i.__headerState,w,_,v,M,R,T,D,F,j])},children:r})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1738
1738
|
transform: translateX(2px);
|
|
1739
1739
|
`,root:e`
|
|
1740
1740
|
will-change: transform;
|
package/dist/web/index.html
CHANGED
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
opacity: 0.65;
|
|
28
28
|
}
|
|
29
29
|
</style>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-CINfyH_g.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BVS1XoFi.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/motion-BAXVQJfN.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/ui-CEFkTVnG.js">
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/diagram-BF8g9yg4.js">
|
|
35
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
35
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DCgILSIv.css">
|
|
36
36
|
</head>
|
|
37
37
|
<body>
|
|
38
38
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgbg/mdocs",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.26",
|
|
4
4
|
"description": "A Markdown knowledge base for small teams",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@earendil-works/pi-agent-core": "^0.82.1",
|
|
43
43
|
"@earendil-works/pi-ai": "^0.82.1",
|
|
44
44
|
"@lexical/rich-text": "0.42.0",
|
|
45
|
-
"@lobehub/editor": "npm:@fgbg/lobe-editor@1.0.0-fork.
|
|
45
|
+
"@lobehub/editor": "npm:@fgbg/lobe-editor@1.0.0-fork.23",
|
|
46
46
|
"@lobehub/ui": "^5.0.0",
|
|
47
47
|
"@node-rs/jieba": "^2.0.1",
|
|
48
48
|
"@shikijs/langs": "4.0.2",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{r as v,j as n}from"./react-vendor-BVS1XoFi.js";import{o as k,c as D,T as B,U as M,V as g,l as x,W as j,Y as P,Z as E,S as I,_ as S}from"./index-3B7_9QOQ.js";import{g as W}from"./file-type-policy-C6Nun42Q.js";/**
|
|
2
|
-
* @license lucide-react v0.562.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const w=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],A=k("chevron-up",w);/**
|
|
7
|
-
* @license lucide-react v0.562.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const z=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],O=k("text-align-justify",z);function L(e){const{t:a,lang:s}=D(),l=W(e.fileType||"md"),f=!!(l!=null&&l.aiWrite&&e.onAiWrite),C=!!(l!=null&&l.comments&&e.onToggleComments);e.canEdit&&(e.editing||e.actionsAlwaysVisible);const[d,N]=v.useState(!1),m=e.domains.length?e.domains:[B],o="mdocs-editor-toolbar"+(e.readerChrome?e.readerHeaderDocked?" mdocs-editor-toolbar--docked":" mdocs-editor-toolbar--float":""),c=e.readerChrome&&!e.readerHeaderDocked&&e.readerDragOffset?{transform:`translateY(${e.readerDragOffset}px)`}:void 0;if(e.readerChrome){const t=n.jsxs("div",{className:"mdocs-editor-toolbar-leading",onPointerDown:e.onReaderHeaderPointerDown,onPointerMove:e.onReaderHeaderPointerMove,onPointerUp:e.onReaderHeaderPointerUp,onPointerCancel:e.onReaderHeaderPointerUp,children:[n.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>{var i;return(i=e.onOpenMobileNav)==null?void 0:i.call(e)},"aria-label":a("expandSidebar"),children:n.jsx(M,{size:18,strokeWidth:1.75})}),n.jsx("input",{className:"mdocs-editor-title-input",value:e.displayName,onChange:i=>e.onDisplayNameChange(i.target.value),onBlur:e.onDisplayNameBlur,placeholder:a("displayNamePlaceholder"),disabled:!e.editing,readOnly:!e.editing})]}),r=n.jsx(g,{domains:m,value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:i=>x(i,s,a)}),u=e.canEdit&&e.onPublish?n.jsx("button",{type:"button",className:"primary mdocs-reader-action-btn",disabled:e.busy,onClick:()=>{var i,y;e.editing||(i=e.onEnterEdit)==null||i.call(e),(y=e.onPublish)==null||y.call(e)},children:e.busy?a("publishing"):a("publish")}):null,h=e.onSyncClick?n.jsx("button",{type:"button",className:"mdocs-sync-btn mdocs-reader-sync-btn"+(e.syncBehind?" behind":""),"aria-label":e.syncBehind?a("syncBehindHint"):a("syncPull"),onClick:()=>{var i;return void((i=e.onSyncClick)==null?void 0:i.call(e))},children:n.jsx(j,{size:16,strokeWidth:1.75})}):null,b=e.readerMoreMenu!=null?n.jsxs("div",{ref:e.readerMoreMenuRef,className:"mdocs-reader-more-menu",children:[n.jsx("button",{type:"button",className:"mdocs-reader-more-btn","aria-label":"更多","aria-expanded":e.readerMoreOpen,onClick:()=>{var i;return(i=e.onToggleReaderMore)==null?void 0:i.call(e)},children:n.jsx(P,{size:18,strokeWidth:1.75})}),e.readerMoreOpen?n.jsx("div",{className:"mdocs-reader-more-dropdown card",children:e.readerMoreMenu}):null]}):null;return e.readerActionsCollapsible?n.jsxs("div",{className:o+" mdocs-editor-toolbar--stacked",style:c,children:[n.jsxs("div",{className:"mdocs-reader-top-row",children:[t,h,n.jsx("button",{type:"button",className:"mdocs-reader-expand-btn",onClick:()=>N(i=>!i),"aria-label":d?"收起操作栏":"展开操作栏",children:n.jsx(A,{size:16,strokeWidth:2,style:{transform:d?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s"}})}),b]}),d&&n.jsxs("div",{className:"mdocs-reader-actions-row",children:[r,e.leadingExtra,u,e.trailingExtra]})]}):n.jsxs("div",{className:o,style:c,children:[t,r,e.leadingExtra,h,u,b,e.trailingExtra]})}return n.jsxs("div",{className:o,style:c,children:[n.jsxs("div",{className:"mdocs-editor-toolbar-leading",children:[n.jsx("input",{className:"mdocs-editor-title-input",value:e.displayName,onChange:t=>e.onDisplayNameChange(t.target.value),onBlur:e.onDisplayNameBlur,placeholder:a("displayNamePlaceholder"),disabled:!e.editing}),n.jsx(g,{domains:m,value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:t=>x(t,s,a)}),f?n.jsxs("button",{type:"button",className:"secondary",onClick:()=>{var t;return(t=e.onAiWrite)==null?void 0:t.call(e)},style:{padding:"4px 10px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:E,alt:"",width:16,height:16,style:{display:"block"}}),"帮写"]}):null,e.leadingExtra]}),n.jsx("span",{className:"mdocs-editor-toolbar-spacer","aria-hidden":!0}),n.jsxs("div",{className:"mdocs-editor-toolbar-trailing",children:[e.onToggleBookmark?n.jsxs("button",{type:"button",className:"ghost mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>{var t;return(t=e.onToggleBookmark)==null?void 0:t.call(e)},disabled:e.bookmarkBusy,"data-tooltip":e.isBookmarked?"取消收藏":"收藏",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,opacity:e.bookmarkBusy?.5:1},children:[n.jsx(I,{size:18,strokeWidth:1.5,style:{color:e.isBookmarked?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:e.isBookmarked?"#faad14":"none"}}),e.isBookmarked?n.jsx("span",{children:"已收藏"}):null]}):null,n.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[e.onSyncClick?n.jsxs("button",{type:"button",className:"mdocs-sync-btn mdocs-tooltip mdocs-tooltip-bottom"+(e.syncBehind?" behind":""),"data-tooltip":e.syncBehind?a("syncBehindHint"):a("syncPull"),onClick:()=>{var t;return void((t=e.onSyncClick)==null?void 0:t.call(e))},style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx(j,{size:16,strokeWidth:1.5}),n.jsx("span",{children:a("syncPull")})]}):null,e.editing?n.jsxs(n.Fragment,{children:[localStorage.getItem("mdocs.autoPublish")!=="true"&&n.jsxs("span",{className:"mdocs-save-indicator",children:[n.jsx("span",{className:"mdocs-save-dot "+(e.busy?"saving":e.draftExists?"unsaved":"saved")}),n.jsx("span",{children:e.busy?a("publishing"):e.draftExists?a("unsaved"):a("published")})]}),e.onPublish?n.jsx("button",{type:"button",className:"primary",disabled:e.busy,onClick:()=>{var t;return(t=e.onPublish)==null?void 0:t.call(e)},children:e.busy?a("publishing"):a("publish")}):null,e.onDelete?n.jsx("button",{type:"button",className:"danger",disabled:e.busy,onClick:()=>{var t;return(t=e.onDelete)==null?void 0:t.call(e)},children:a("delete")}):null]}):null,!e.editing&&e.canEdit&&e.onEnterEdit?n.jsx("button",{type:"button",className:"primary",onClick:()=>{var t;return(t=e.onEnterEdit)==null?void 0:t.call(e)},children:a("edit")}):null,e.trailingExtra,C?n.jsxs("button",{type:"button",className:"ghost mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>{var t;return(t=e.onToggleComments)==null?void 0:t.call(e)},"data-tooltip":"评论",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,background:e.commentPanelOpen?"var(--mdocs-hover-bg, #f0f0f0)":void 0},children:[n.jsx(S,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}}),e.commentCount&&e.commentCount>0?n.jsx("span",{style:{fontSize:"0.85rem"},children:e.commentCount}):null]}):null,e.onToggleDocInfo?n.jsxs("div",{ref:e.docInfoMenuRef,className:"mdocs-tooltip mdocs-tooltip-bottom","data-tooltip":a("docInfo"),style:{position:"relative"},children:[n.jsx("button",{type:"button",className:"secondary",onClick:()=>{var t;return(t=e.onToggleDocInfo)==null?void 0:t.call(e)},style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(O,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}})}),e.docInfoOpen?n.jsx("div",{className:"mdocs-doc-info-dropdown",children:e.docInfoMenu}):null]}):null]})]})]})}export{L as D};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,j as a}from"./react-vendor-BVS1XoFi.js";import{ad as ge}from"./ui-CEFkTVnG.js";import{g as be,u as Ee,a as ve,s as We,d as Ge,b as xe,c as Ye,f as Je,e as $e,h as Ke,N as Xe,S as Qe,l as Ze,r as pe,i as et,j as tt,D as ee,k as nt,m as at,n as Ie}from"./index-3B7_9QOQ.js";import{z as it,A as rt,m as ce,n as ot,o as st,p as ct,r as lt,s as ut,t as dt,v as mt,x as ft,B as ht,R as yt,a as gt,b as ke,c as vt,d as xt,e as It,f as kt,g as St,h as Ct,i as wt,w as le,j as bt,O as Et,E as Mt,q as Dt,l as Rt,C as jt,D as At}from"./react-2y9P8xJn.js";import{H as Nt,a as Pt,b as Tt,M as Bt,T as Lt,S as Ot,W as _t,o as zt,c as Se}from"./Toolbar-Bk3LKZfg.js";import{D as Ht}from"./DocChrome-wfHrPEB7.js";import{V as Ft}from"./VisitorPickerModal-zafJ6beK.js";import{c as Ut,U as qt,S as Vt}from"./docPlainCharCount-BjBZaoHy.js";import"./motion-BAXVQJfN.js";import"./diagram-BF8g9yg4.js";import"./editor-DBWWidi3.js";import"./plus-BD44y7Zf.js";import"./check-BMeXlsHC.js";import"./copy-CCsiKd_j.js";import"./italic-B6bGjo1_.js";import"./file-type-policy-C6Nun42Q.js";const Wt=48;function te(e){try{const i=e.getDocument("markdown");return typeof i=="string"?i:""}catch{return null}}function Gt(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}function Yt({editor:e,documentId:i,displayName:l,debounceMs:g=1e3,enabled:y=!0,localBaseCommitIdAtEditStart:C,snapshotMeta:D,seedDraftExists:H=!1}){const[F,_]=n.useState(!1),[ne,P]=n.useState(H),[T,w]=n.useState(null),d=n.useRef(null),h=n.useRef(null),I=n.useRef(!1),x=n.useRef(""),v=n.useRef(!1),z=n.useRef(i),U=n.useRef(l),B=n.useRef(C),$=n.useRef(D);z.current=i,U.current=l,B.current=C,$.current=D;const b=n.useCallback(async()=>{if(!e)return;if(!x.current){console.log("[useAutoSave] performSave blocked: lastContentRef is empty");return}const c=Gt(e);c!=null&&(console.log("[useAutoSave] performSave saving draft, documentId:",z.current,"content preview:",c.slice(0,80)),await be(z.current).execute(()=>Ee({documentId:z.current,content:c,displayName:U.current,localBaseCommitIdAtEditStart:B.current,snapshotMeta:$.current})),x.current=te(e)??x.current,P(!0),_(!1),w(Date.now()),I.current=!0,v.current=!1)},[e]);n.useEffect(()=>{let c=!1;const f=xe();return ve(i).then(m=>{if(c||xe()!==f)return;const R=!!(m&&!m.published);P(R),R&&m?(w(m.updatedAt),I.current=!0):(w(null),I.current=!1,v.current=!1)}),()=>{c=!0}},[i]),n.useEffect(()=>We((c,f)=>{c===z.current&&(P(f),f||(w(null),I.current=!1))}),[]),n.useEffect(()=>{var W,k;if(!y){(W=h.current)==null||W.call(h),h.current=null;return}if(!e)return;const c=e.getLexicalEditor();if(!c)return;(k=h.current)==null||k.call(h);let f=!1,m=0,R=0;const V=()=>{if(f)return;const E=te(e);if(E===null){if(R+=1,R>Wt)return;m=requestAnimationFrame(V);return}x.current=E;const G=c.registerUpdateListener(()=>{const L=te(e);L!==null&&L!==x.current&&(console.log("[useAutoSave] updateListener dirty, documentId:",i,"oldLen:",x.current.length,"newLen:",L.length),x.current=L,_(!0),v.current=!0,I.current=!1,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,b()},g))});h.current=()=>{G(),d.current&&(clearTimeout(d.current),d.current=null)}};return queueMicrotask(()=>{f||(m=requestAnimationFrame(V))}),()=>{var E;f=!0,cancelAnimationFrame(m),(E=h.current)==null||E.call(h)}},[y,e,i,l,g,C,D,b]),n.useEffect(()=>{var m;if(!y||!e)return;const c=(m=e.getLexicalEditor())==null?void 0:m.getRootElement();if(!c)return;const f=()=>{d.current&&(clearTimeout(d.current),d.current=null),v.current&&b()};return c.addEventListener("blur",f),()=>c.removeEventListener("blur",f)},[y,e,b]),n.useEffect(()=>{if(!y)return;const c=()=>{document.visibilityState==="hidden"&&(d.current&&(clearTimeout(d.current),d.current=null),v.current&&b())},f=()=>{v.current&&(d.current&&(clearTimeout(d.current),d.current=null),b())};return document.addEventListener("visibilitychange",c),window.addEventListener("beforeunload",f),()=>{document.removeEventListener("visibilitychange",c),window.removeEventListener("beforeunload",f)}},[y,b]);async function K(){await Ge(i),P(!1),_(!1),v.current=!1,I.current=!1,x.current=""}async function X(){const c=await ve(i);return c?c.content:null}function q(){P(!0),_(!1),v.current=!1,w(Date.now()),I.current=!0,e&&(x.current=te(e)??"")}return{isDirty:F,draftExists:ne,lastSavedAt:T,clearDraft:K,loadDraftContent:X,markDraftSaved:q}}function Jt({isDirty:e,draftExists:i}){const l=e&&!i;n.useEffect(()=>{if(!l)return;const g=y=>{y.preventDefault()};return window.addEventListener("beforeunload",g),()=>window.removeEventListener("beforeunload",g)},[l])}function ue(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}const Ce='{"root":{"direction":"ltr","format":"","indent":0,"version":1,"type":"root","children":[{"direction":"ltr","format":"","indent":0,"version":1,"textFormat":0,"textStyle":"","children":[],"type":"paragraph"}]}}';function we(e){const l=(e instanceof Error?e.message:String(e)).trim();return/^File too large$/i.test(l)?"文件过大(单文件上限 55MB)":/^unsupported file type$/i.test(l)?"不支持的文件类型":/^not an image$/i.test(l)?"不是有效的图片文件":l||"上传失败"}function $t(e,i){if(!e)return i==="json"?Ce:e;if(i!=="json")return e;try{const l=JSON.parse(e);if(l!=null&&l.root&&Array.isArray(l.root.children)&&l.root.children.length===0)return Ce}catch{}return e}function Kt({editor:e}){const{visible:i}=jt();return a.jsx("div",{className:"mdocs-outline-siderail",style:{flexShrink:0,overflow:"hidden",transition:"width 0.2s ease",width:i?200:0},children:a.jsx("div",{style:{width:200},children:a.jsx(At,{editor:e})})})}function fn(e){const{t:i,lang:l}=Ye(),[g,y]=n.useState(!1),[C,D]=n.useState(!1),H=n.useRef(null),F=n.useRef(null),[_,ne]=n.useState([]),[P,T]=n.useState(!1),[w,d]=n.useState(e.meta.permission),[h,I]=n.useState(!1),[x,v]=n.useState(!1),[z,U]=n.useState(!1),[B,$]=n.useState(new Map),[b,K]=n.useState(!1),[X,q]=n.useState(null),c=n.useRef(0);n.useEffect(()=>{const t=r=>{H.current&&!H.current.contains(r.target)&&y(!1),F.current&&!F.current.contains(r.target)&&D(!1)};return(g||C)&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[g,C]),n.useEffect(()=>{let t=!0;return Je().then(r=>{t&&ne(r)}).catch(()=>{}),()=>{t=!1}},[]);function f(t){const r=_.find(s=>s.visitorId===t);return(r==null?void 0:r.visitorName)??t.slice(0,8)}const[m,R]=n.useState(e.initialDisplayName),[V,W]=n.useState(!1),[k,E]=n.useState(!1),[G,L]=n.useState(!1),[Me,De]=n.useState(()=>localStorage.getItem("mdocs.autoEdit")!=="false"),ae=e.canEdit&&Me,[u,de]=n.useState(null),[Re,me]=n.useState(!1),ie=n.useRef(null);n.useLayoutEffect(()=>{me(!1),de(null),ie.current=null},[e.meta.documentId]),n.useEffect(()=>{const t=requestAnimationFrame(()=>me(!0));return()=>cancelAnimationFrame(t)},[e.meta.documentId]),n.useEffect(()=>{if(!g&&!C)return;const t=++c.current;q(null);const r=()=>{if(t===c.current)try{let o=e.initialContent||"";if(u)try{const N=u.getDocument("markdown");typeof N=="string"&&(o=N)}catch{}const S=Ut("md",o);t===c.current&&q(S)}catch{t===c.current&&q(0)}},s=window;if(typeof s.requestIdleCallback=="function"){const o=s.requestIdleCallback(r);return()=>{var S;return(S=s.cancelIdleCallback)==null?void 0:S.call(s,o)}}const M=window.setTimeout(r,0);return()=>window.clearTimeout(M)},[g,C,u,e.initialContent,e.meta.documentId,e.contentRevision]);const j=n.useMemo(()=>{var t;if(!e.initialContent)return"json";try{const r=JSON.parse(e.initialContent);return Array.isArray((t=r==null?void 0:r.root)==null?void 0:t.children)?"json":"markdown"}catch{return"markdown"}},[e.initialContent,e.contentRevision]),Y=n.useMemo(()=>$t(e.initialContent||"",j),[e.initialContent,j,e.contentRevision]),{isDirty:fe,draftExists:Q,markDraftSaved:je}=Yt({editor:u,documentId:e.meta.documentId,displayName:m,enabled:e.canEdit,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId},seedDraftExists:e.hasLocalDraft});n.useEffect(()=>{var t;(t=e.onDraftExistsChange)==null||t.call(e,Q)},[Q,e.onDraftExistsChange]),Jt({isDirty:fe,draftExists:Q}),n.useEffect(()=>{if(u)try{u.setDocument(j,Y)}catch{}},[u,e.meta.documentId,e.contentRevision,Y,j]),n.useEffect(()=>{u==null||u.setLocale(l==="zh"?it:rt)},[u,l]),n.useEffect(()=>{R(e.initialDisplayName)},[e.initialDisplayName,e.meta.documentId,e.contentRevision]),n.useEffect(()=>{d(e.meta.permission)},[e.meta.permission,e.meta.documentId]),n.useEffect(()=>{let t=!0;return(async()=>{try{const r=await $e(e.meta.documentId);t&&E(r.bookmarked)}catch{}})(),()=>{t=!1}},[e.meta.documentId]);async function re(){var t,r;if(!G){L(!0);try{k?(await pe(e.meta.documentId),E(!1),(t=e.onShowToast)==null||t.call(e,i("bookmarkRemoved"))):(await et(e.meta.documentId),E(!0),(r=e.onShowToast)==null||r.call(e,i("bookmarkAdded")))}finally{L(!1)}}}n.useEffect(()=>(e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=_e),()=>{e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=void 0)})),n.useEffect(()=>{if(e.exportMarkdownRef)return e.exportMarkdownRef.current=()=>{const t=ie.current;if(!t)return"";try{const r=t.getDocument("markdown");return typeof r=="string"?r:String(r??"")}catch{return""}},()=>{e.exportMarkdownRef&&(e.exportMarkdownRef.current=void 0)}});function Ae(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const Ne=n.useCallback(t=>{ie.current=t,de(t);const r=Y;if(!r)return;const s=()=>{try{t.setDocument(j,r)}catch{requestAnimationFrame(()=>{try{t.setDocument(j,r)}catch{}})}};queueMicrotask(()=>{queueMicrotask(s)})},[j,Y]);async function he(){if(!(!u||!e.canEdit)){W(!0);try{const t=ue(u);if(!t)return;await e.onPublish(t,m,e.meta.documentId)}catch(t){throw t}finally{W(!1)}}}async function Pe(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(m.trim()!==t)try{await he()}catch{}}const A=n.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),Te=n.useMemo(()=>{const t=(A==null?void 0:A.permission)??"public";return Ke(t)},[A==null?void 0:A.permission]);function Be(t){return t===ee.PRIVATE?i("permissionPrivate"):t===ee.DOMAIN_READ?i("permissionInvite"):t===ee.DOMAIN_WRITE?i("permissionDomainWrite"):t===ee.PUBLIC_READ?i("permissionPublicRead"):i("permissionPublicEdit")}async function Le(){var t;if(h||w===e.meta.permission){T(!1);return}I(!0);try{const s=(u?ue(u):null)??e.initialContent;await e.onPublish(s,m,e.meta.documentId,w),T(!1),(t=e.onShowToast)==null||t.call(e,i("docInfoPermissionUpdated"))}finally{I(!1)}}async function Oe(t){var r;if(!b){K(!0);try{const s=new Set(t.map(o=>o.visitorId)),M=new Map(t.map(o=>[o.visitorId,o.permission]));for(const[o]of B)s.has(o)||await nt(e.meta.documentId,o);for(const{visitorId:o,permission:S}of t){const N=B.get(o);(!N||N!==S)&&await at(e.meta.documentId,o,S)}v(!1),(r=e.onShowToast)==null||r.call(e,i("docInfoInviteSuccess",{count:t.length}))}finally{K(!1)}}}async function _e(){if(!u||!e.canEdit)return;if(!fe){console.log("[DocumentEditor.saveDraft] skipped: not dirty, documentId:",e.meta.documentId);return}const t=ue(u);t&&(console.log("[DocumentEditor.saveDraft] saving draft, documentId:",e.meta.documentId,"content preview:",t.slice(0,80)),je(),await be(e.meta.documentId).execute(()=>Ee({documentId:e.meta.documentId,content:t,displayName:m,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})))}const ze=n.useMemo(()=>[{icon:Nt,key:"h1",label:"Heading 1",onSelect:t=>{t.dispatchCommand(ce,{tag:"h1"})}},{icon:Pt,key:"h2",label:"Heading 2",onSelect:t=>{t.dispatchCommand(ce,{tag:"h2"})}},{icon:Tt,key:"h3",label:"Heading 3",onSelect:t=>{t.dispatchCommand(ce,{tag:"h3"})}},{type:"divider"},{icon:Bt,key:"hr",label:"Hr",onSelect:t=>{t.dispatchCommand(ot,{})}},{icon:Lt,key:"table",label:"Table",onSelect:t=>{t.dispatchCommand(st,{columns:"3",rows:"3"})}},{icon:Ot,key:"tex",label:"TeX",onSelect:t=>{t.dispatchCommand(ct,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>t.focus())}},{type:"divider"},{key:"file",label:"File",onSelect:t=>{zt(r=>{for(const s of r)t.dispatchCommand(Dt,{file:s})},".pdf,.zip,.txt,.md,.csv,.html,.htm,audio/*,*/*")}},{key:"insert-link",label:"Insert Link",onSelect:t=>{t.dispatchCommand(lt,{url:"https://example.com"}),queueMicrotask(()=>t.focus())}},{key:"insert-codeInline",label:"Inline Code",onSelect:t=>{t.dispatchCommand(ut,void 0),queueMicrotask(()=>t.focus())}},{key:"insert-codeBlock",label:"Code Block",onSelect:t=>{t.dispatchCommand(dt,void 0),queueMicrotask(()=>t.focus())}},{icon:_t,key:"meta2d",label:"Meta2d",onSelect:t=>{t.dispatchCommand(mt,void 0),queueMicrotask(()=>t.focus())}},{icon:Xe,key:"markmap",label:"Markmap",onSelect:t=>{t.dispatchCommand(ft,void 0),queueMicrotask(()=>t.focus())}}].map(t=>"type"in t&&t.type==="divider"?t:{...t,extra:a.jsx("span",{style:{color:"var(--mdocs-text-muted)",fontFamily:"monospace",fontSize:12},children:t.key})}),[]),He=n.useMemo(()=>[ht,yt,gt,ke,vt,xt,It,kt,St,Ct,wt,le(bt,{children:u?a.jsx(Se,{editor:u,floating:!0,outlineCollapseTitle:i("outlineHide"),outlineExpandTitle:i("outlineShow"),outlineToggle:!0}):null}),le(Rt,{handleUpload:async t=>{var r;try{return{url:await Ie(t,e.meta.documentId)}}catch(s){throw(r=e.onShowError)==null||r.call(e,we(s)),s}}}),le(ke,{defaultBlockImage:!0,needRehost:t=>t.startsWith("blob:"),handleRehost:async t=>{var r;try{const M=await(await fetch(t)).blob(),o=new File([M],"image.png",{type:M.type});return{url:await Ie(o,e.meta.documentId)}}catch(s){throw(r=e.onShowError)==null||r.call(e,we(s)),s}}})],[u,i,e.meta.documentId,e.onShowError]),O=!!e.readerChrome,[J,oe]=n.useState(!1),Z=n.useRef(null),[Fe,se]=n.useState(0);n.useEffect(()=>{if(!O){oe(!1),se(0);return}if(J)return;const t=window.setTimeout(()=>oe(!0),2800);return()=>window.clearTimeout(t)},[O,J,e.meta.documentId]),n.useEffect(()=>{D(!1),y(!1)},[e.meta.documentId]);function Ue(t){!O||J||t.target.closest("button, a, input, textarea, select")||(Z.current={startY:t.clientY,dragging:!0},t.currentTarget.setPointerCapture(t.pointerId))}function qe(t){const r=Z.current;if(!(r!=null&&r.dragging))return;const s=t.clientY-r.startY;se(Math.max(-72,Math.min(0,s)))}function Ve(t){const r=Z.current;if(!(r!=null&&r.dragging))return;Z.current=null;const s=t.clientY-r.startY;se(0),s<-36&&oe(!0);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}function p(){y(!1),D(!1)}function ye(t,r){const s=(r==null?void 0:r.includeBookmark)??!0,M={width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{padding:"4px 16px",fontSize:"13px"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoCreator")}),a.jsx("span",{children:f(e.meta.ownerVisitorId)})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoCreatedAt")}),a.jsx("span",{children:new Date(e.meta.createdAt).toLocaleString(l==="zh"?"zh-CN":"en-US")})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoSize")}),a.jsx("span",{children:Ae(new Blob([e.initialContent]).size)})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoCharCount")}),a.jsx("span",{children:X===null?"…":X.toLocaleString(l==="zh"?"zh-CN":"en-US")})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[a.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:i("docInfoUpdatedAt")}),a.jsx("span",{children:new Date(e.meta.updatedAt).toLocaleString(l==="zh"?"zh-CN":"en-US")})]})]}),a.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),s?a.jsxs("button",{type:"button",style:M,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{re(),t()},children:[a.jsx("span",{children:k?"⭐":"☆"}),a.jsx("span",{children:i(k?"bookmarkRemove":"bookmarkAdd")})]}):null,e.canManageInvites?a.jsxs("button",{type:"button",style:M,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{t(),(async()=>{U(!0);try{const o=await tt(e.meta.documentId),S=new Map(o.map(N=>[N.visitorId,N.permission]));$(S),v(!0)}finally{U(!1)}})()},children:[a.jsx(qt,{size:14}),a.jsx("span",{children:i("docInfoInviteMember")})]}):null,a.jsxs("button",{type:"button",style:M,onMouseEnter:o=>{o.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:o=>{o.currentTarget.style.background="none"},onClick:()=>{t(),d(e.meta.permission),T(!0)},children:[a.jsx(Vt,{size:14}),a.jsx("span",{children:i("docInfoChangePermission")})]})]})}return a.jsxs("div",{className:"mdocs-editor"+(O?" mdocs-editor--reader":"")+(O&&J?" mdocs-editor--reader-docked":""),children:[a.jsx(Ht,{fileType:e.meta.fileType||"md",displayName:m,onDisplayNameChange:R,onDisplayNameBlur:()=>void Pe(),domains:e.domains,currentDomainId:e.currentDomainId,onDomainChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,canEdit:e.canEdit,editing:ae,onEnterEdit:()=>De(!0),onAiWrite:e.onAiWrite,syncBehind:e.syncBehind,onSyncClick:e.onSyncClick,busy:V,draftExists:Q,onPublish:()=>{he().catch(()=>{})},onDelete:()=>{e.onDelete()},isBookmarked:k,bookmarkBusy:G,onToggleBookmark:()=>void re(),onToggleComments:e.onToggleComments,commentPanelOpen:e.commentPanelOpen,commentCount:e.commentCount,docInfoMenu:ye(p),docInfoOpen:g,onToggleDocInfo:()=>y(!g),docInfoMenuRef:H,readerChrome:O,onOpenMobileNav:e.onOpenMobileNav,readerHeaderDocked:J,readerDragOffset:Fe,onReaderHeaderPointerDown:Ue,onReaderHeaderPointerMove:qe,onReaderHeaderPointerUp:Ve,readerMoreOpen:C,onToggleReaderMore:()=>D(t=>!t),readerMoreMenuRef:F,readerMoreMenu:a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"mdocs-reader-more-item",disabled:G,onClick:()=>{re(),p()},children:[a.jsx(Qe,{size:16,strokeWidth:1.5,style:{color:k?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:k?"#faad14":"none"}}),a.jsx("span",{children:i(k?"bookmarkRemove":"bookmarkAdd")})]}),e.canEdit?a.jsx("button",{type:"button",className:"mdocs-reader-more-item mdocs-reader-more-item--danger",disabled:V,onClick:()=>{p(),e.onDelete()},children:a.jsx("span",{children:i("delete")})}):null,a.jsx("div",{className:"mdocs-reader-more-divider"}),ye(p,{includeBookmark:!1})]})}),P&&a.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&T(!1)},children:a.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480},children:[a.jsx("h1",{style:{fontSize:"1.1rem",marginBottom:12},children:i("docInfoChangePermission")}),a.jsxs("div",{className:"muted",style:{marginBottom:12},children:[i("domainPermission"),":",A?Ze(A.domainName,l,i):e.meta.domainId]}),a.jsx("div",{style:{display:"grid",gap:8},children:Te.map(t=>a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[a.jsx("input",{type:"radio",name:"doc-permission",value:t,checked:w===t,onChange:()=>d(t)}),a.jsx("span",{children:Be(t)})]},t))}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[a.jsx("button",{type:"button",onClick:()=>T(!1),children:i("cancel")}),a.jsx("button",{type:"button",className:"primary",disabled:h,onClick:()=>void Le(),children:i(h?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&a.jsx(Ft,{open:x,title:i("docInfoInviteMember"),initialSelectedIds:[...B.keys()],initialPermissions:B,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:i("invitePermissionRead")},{value:"edit",label:i("invitePermissionEdit")}],onClose:()=>v(!1),onConfirm:t=>{Oe(t)}}),a.jsx(Et,{children:a.jsx(ge,{flex:1,style:{minHeight:0},children:a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[ae&&u&&!O?a.jsx(Se,{editor:u,outlineCollapseTitle:i("outlineHide"),outlineExpandTitle:i("outlineShow"),outlineToggle:!0}):null,a.jsx("div",{className:"mdocs-editor-content-area",style:{flex:1,display:"flex",minHeight:0},children:a.jsxs(ge,{variant:"outlined",horizontal:!0,style:{background:"var(--mdocs-surface)",flex:1,minHeight:0,minWidth:0,borderRadius:0,outline:"none"},children:[a.jsx("div",{className:"mdocs-editor-scroll-host",children:Re?a.jsx(Mt,{content:Y,type:j,confirmPasteMarkdown:!0,editable:ae,onInit:Ne,plugins:He,lineEmptyPlaceholder:i("displayNamePlaceholder"),placeholder:i("displayNamePlaceholder"),slashOption:{items:ze},className:"mdocs-document-editor-root"},e.meta.documentId):null}),u&&a.jsx(Kt,{editor:u})]})})]})})})]})}export{fn as DocumentEditor};
|