collabmd 0.1.48 → 0.1.51
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 +15 -608
- package/bin/collabmd.js +39 -20
- package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-Crf9Y3Q6.js +1 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-PuinKbSQ.js +1 -0
- package/dist/client/assets/ar-SA-5WIASEJP-Di7OimCN.js +10 -0
- package/dist/client/assets/{architectureDiagram-5GKGNRK7-I39sYjHI.js → architectureDiagram-5GKGNRK7-46hPkrZv.js} +3 -3
- package/dist/client/assets/az-AZ-V5EUQD6C-C19OGTT_.js +1 -0
- package/dist/client/assets/bg-BG-EXASCMTR-BIt0xWyb.js +5 -0
- package/dist/client/assets/{blockDiagram-NRAW4CY4-C6DtJy5Y.js → blockDiagram-I7D4REHJ-C1S5Bzf8.js} +4 -4
- package/dist/client/assets/bn-BD-U4SYNFCO-CdNaPy4Q.js +3 -0
- package/dist/client/assets/bn-IN-HKDJIITE-CdNaPy4Q.js +3 -0
- package/dist/client/assets/{browser-BKLM0ThC-IxjwuOIz-BBqQnUEb.js → browser-BKLM0ThC-IxjwuOIz-DyJcVMFR.js} +1 -1
- package/dist/client/assets/browser-utils-DbXSMI-6.js +1 -0
- package/dist/client/assets/{c4Diagram-UCG6FXSJ-CtWtxS9_.js → c4Diagram-7LVT6UL2-VAk1HPmz.js} +1 -1
- package/dist/client/assets/ca-ES-2KGUU5XB-C9t-c0cH.js +8 -0
- package/dist/client/assets/channel-jwdhnPiV.js +1 -0
- package/dist/client/assets/chunk-2E4U76K2-Ba8Wf22k.js +1 -0
- package/dist/client/assets/{chunk-TEH6E4GO-DVayPj-q.js → chunk-4HAMMTFA-Ht-73lsT.js} +20 -20
- package/dist/client/assets/chunk-5XKZK2GL-D4UAZSOJ.js +1 -0
- package/dist/client/assets/{chunk-75Z2AOVW-CdFSaPjz.js → chunk-75Z2AOVW-B2cZexqK.js} +1 -1
- package/dist/client/assets/{chunk-CLGD4ZFX-DQLgbQrv.js → chunk-CLGD4ZFX-Cmtx89ht.js} +1 -1
- package/dist/client/assets/chunk-DU6HZSFF-C6d6PJfE.js +127 -0
- package/dist/client/assets/{chunk-F27PBJKO-CNHIFhjo.js → chunk-F27PBJKO-Dg3H6KLL.js} +1 -1
- package/dist/client/assets/{chunk-GMAD6QVW-CbcBqPM5.js → chunk-GMAD6QVW-DUfjx_d5.js} +1 -1
- package/dist/client/assets/{chunk-OBVCFTLP-BJR7u1jh.js → chunk-GVQU2GXP-D1l7oRGR.js} +1 -1
- package/dist/client/assets/{chunk-G27WJ6UU-D9-eg537.js → chunk-IMKFNOWR-3F6NhHUP.js} +2 -2
- package/dist/client/assets/{chunk-JQ64N6SF-DSFNH4bh.js → chunk-L3NEJ4N5-BmCVn4y-.js} +1 -1
- package/dist/client/assets/chunk-OSK3NFVY-CWHXAmfx.js +10 -0
- package/dist/client/assets/{chunk-P2QGCYS3-BRpqY32H.js → chunk-P2QGCYS3-Du8EtwOa.js} +1 -1
- package/dist/client/assets/{chunk-POPQ4Y6H-Cb4SlVZF.js → chunk-POPQ4Y6H-B5yJIrZE.js} +1 -1
- package/dist/client/assets/{chunk-PWAF6VOD-Cz8IwBB5.js → chunk-PWAF6VOD-B3gML4ps.js} +1 -1
- package/dist/client/assets/{chunk-RHFEMEQ7-CWY8cf4H.js → chunk-SHT3W25Y-BKaI8jZO.js} +5 -5
- package/dist/client/assets/{chunk-SVP7TREG-CyHOmcac.js → chunk-SVP7TREG-XlsB_ZMZ.js} +1 -1
- package/dist/client/assets/{chunk-LCL6LL3I-DmDkVukh.js → chunk-TICWLB2K-Cpp2z8yK.js} +4 -4
- package/dist/client/assets/chunk-TLUHSLCS-Yl7B0Vrz.js +1 -0
- package/dist/client/assets/chunk-ZNVOA63L-BmCQjhx-.js +40 -0
- package/dist/client/assets/{chunk-FLYJHZSQ-Be7lKF17.js → chunk-ZPMXAHWN-Dt0TxJa6.js} +2 -2
- package/dist/client/assets/classDiagram-ZZMXUADV-BRw9vo8U.js +1 -0
- package/dist/client/assets/classDiagram-v2-VYDZK3BY-BRw9vo8U.js +1 -0
- package/dist/client/assets/comment-markdown-renderer-B9_vPc3F.js +1 -0
- package/dist/client/assets/comment-thread-store-NNHqRVsX.js +1 -0
- package/dist/client/assets/comment-threads-nJhK1yfc.js +4 -0
- package/dist/client/assets/cs-CZ-VUCGPRML-BfCoYAgj.js +7 -0
- package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CdTPi2yO.js → cynefinDiagram-5FMLGOSQ-BRoCEoZM.js} +1 -1
- package/dist/client/assets/da-DK-NNDP2IVP-DBw9ZNTR.js +2 -0
- package/dist/client/assets/{dagre-3AP2YEHR-5gtJtd0O.js → dagre-GXQ25YYZ-BSfKCfy7.js} +2 -2
- package/dist/client/assets/de-CH-I7RAVIZN-DYW18Vsr.js +11 -0
- package/dist/client/assets/de-DE-WBQ3DQLR-DYW18Vsr.js +11 -0
- package/dist/client/assets/deferred-collab-rBe4nuQ2.css +1 -0
- package/dist/client/assets/deferred-git-BHKtkFYi.css +1 -0
- package/dist/client/assets/deferred-preview-pe7Iwwx3.css +1 -0
- package/dist/client/assets/{diagram-S7CK7UJ4-BudWz9WU.js → diagram-S7CK7UJ4-D7KaM9yj.js} +2 -2
- package/dist/client/assets/{diagram-UQ7AKVKN-3v4rbH-s.js → diagram-UQ7AKVKN-JevUZuYi.js} +1 -1
- package/dist/client/assets/diagram-VSXAHHWV-B3-U-Q2E.js +3 -0
- package/dist/client/assets/{diagram-VX7I27RA-C_-rj0sw.js → diagram-VX7I27RA-pSD4HMh1.js} +1 -1
- package/dist/client/assets/{diagram-Z3DM3KII-B4yxavgj.js → diagram-Z3DM3KII-D8r1_CIb.js} +1 -1
- package/dist/client/assets/{direct-engine-DdrQKpgq-CtKfQzCt.js → direct-engine-DdrQKpgq-B5zIoeQw.js} +1 -1
- package/dist/client/assets/dist-B3HdUPsK.js +1 -0
- package/dist/client/assets/{dist-Tw-Fxpeb.js → dist-B7XMN9AT.js} +1 -1
- package/dist/client/assets/dist-BIRygGYH.js +1 -0
- package/dist/client/assets/dist-BPyOlNLY.js +2 -0
- package/dist/client/assets/{dist-D5wCC32z.js → dist-BR81yxMt.js} +1 -1
- package/dist/client/assets/{dist-Bw3VIE_v.js → dist-B_B4XLmq.js} +1 -1
- package/dist/client/assets/dist-Bdy9ZRzd.js +9 -0
- package/dist/client/assets/{dist-netZOQtD.js → dist-Bfxzlnrf.js} +1 -1
- package/dist/client/assets/{dist-CietwTVS.js → dist-Bx3QkS-3.js} +1 -1
- package/dist/client/assets/{dist-mj2Ht75J.js → dist-By7ieqAf.js} +1 -1
- package/dist/client/assets/dist-ByhQbe-x.js +1 -0
- package/dist/client/assets/{dist-CdmKGRGr.js → dist-BzFSJM0U.js} +1 -1
- package/dist/client/assets/dist-C5NkYKAa.js +1 -0
- package/dist/client/assets/{dist-D3fehAZ2.js → dist-CELhfKzh.js} +1 -1
- package/dist/client/assets/dist-CEirJSxk.js +1 -0
- package/dist/client/assets/dist-CO0-4CuV.js +39 -0
- package/dist/client/assets/dist-CRnJ0D9h.js +1 -0
- package/dist/client/assets/{dist-DDUn5zTz.js → dist-CbDyXgCo.js} +1 -1
- package/dist/client/assets/{dist-BeajGMhO.js → dist-CqXVyYoH.js} +1 -1
- package/dist/client/assets/{dist-LQ4kDCKz.js → dist-CrWzIWEE.js} +1 -1
- package/dist/client/assets/dist-CyNrloSI.js +1 -0
- package/dist/client/assets/dist-D60_kdpQ.js +1 -0
- package/dist/client/assets/{dist-DuH3ZrHo.js → dist-DCpIH3-_.js} +1 -1
- package/dist/client/assets/{dist-BPHLJ09L.js → dist-DJAMplZI.js} +2 -2
- package/dist/client/assets/{dist-DGEbEfw4.js → dist-DVXzbeDx.js} +1 -1
- package/dist/client/assets/{dist-C5NgpdG5.js → dist-Drv_wZYC.js} +1 -1
- package/dist/client/assets/{dist-DVy5woUy.js → dist-EWJYvBK1.js} +1 -1
- package/dist/client/assets/dist-Hdhj3L3t.js +1 -0
- package/dist/client/assets/{dist-B_yQaEv_.js → dist-gRRhmB-2.js} +3 -3
- package/dist/client/assets/dist-kWb2d1CH.js +1 -0
- package/dist/client/assets/dist-kiD2GIsD.js +13 -0
- package/dist/client/assets/dist-l-56SowH.js +19 -0
- package/dist/client/assets/{dist-BK9QvQrc.js → dist-nxQErAaK.js} +2 -2
- package/dist/client/assets/dist-sLzRQQk7.js +1 -0
- package/dist/client/assets/{document-formatter-Dxl_a8XO.js → document-formatter-Qdiq9uJs.js} +1 -2
- package/dist/client/assets/drawioEditor-CHf1vtdQ.js +9 -0
- package/dist/client/assets/ebnfDiagram-PWID7BFC-UJ0Fz5ci.js +1 -0
- package/dist/client/assets/editor-session-4Bn81iWm.js +14 -0
- package/dist/client/assets/el-GR-TYQHVGXW-Dx82YYAS.js +7 -0
- package/dist/client/assets/embedded-editor-base-jK221GC8.css +1 -0
- package/dist/client/assets/{embedpdf-DA4bA119-BPqZxwjc.js → embedpdf-DA4bA119-E8wZ11J2.js} +2 -3
- package/dist/client/assets/{embedpdf-BmE13ZZ0.js → embedpdf-LUXDBD3-.js} +1 -1
- package/dist/client/assets/{en-SJ2YIMFF-CJBL3nkq.js → en-2RFA324Y-BsuNJTcL.js} +1 -1
- package/dist/client/assets/{erDiagram-SSCWMZ5O-C-iy6VkX.js → erDiagram-RLTQ6QDP-CWrH1UJ9.js} +2 -2
- package/dist/client/assets/es-ES-JEUOREKJ-Rx0NUQDl.js +12 -0
- package/dist/client/assets/eu-ES-SO5DEEAN-CDYm-BcK.js +8 -0
- package/dist/client/assets/excalidraw-element-link-iA6zo0_f.js +7 -0
- package/dist/client/assets/{excalidraw-scene-BOben2gr.js → excalidraw-scene-6uROebca.js} +1 -1
- package/dist/client/assets/{excalidraw-editor-BbSbI80a.css → excalidrawEditor-DDE0n1Pk.css} +1 -1
- package/dist/client/assets/excalidrawEditor-WIuguTz7.js +9 -0
- package/dist/client/assets/export-page-AN-wI5p4.js +56 -0
- package/dist/client/assets/exportDocument-B7IagJhQ.css +1 -0
- package/dist/client/assets/exportDocument-B9xNKpQe.js +2 -0
- package/dist/client/assets/fa-IR-FIYUE2GQ-C865Nx3X.js +9 -0
- package/dist/client/assets/fi-FI-REAEF6HQ-BIpjJqIb.js +6 -0
- package/dist/client/assets/flowDiagram-HODETNUW-kb1lUSBo.js +1 -0
- package/dist/client/assets/fr-FR-SUCL7J6B-DGAKE8jH.js +12 -0
- package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DtKHAbez.js → ganttDiagram-EL5Y4UJY-BBNzDfaV.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-oue8fQ5o.js → gitGraphDiagram-WWUBYQGX-Csf0Dm_1.js} +1 -1
- package/dist/client/assets/gl-ES-KHCSOGVH-DWKh0CMu.js +6 -0
- package/dist/client/assets/he-IL-JYXVXV2Q-zqbcM-4g.js +9 -0
- package/dist/client/assets/hi-IN-BU52H3BO-CY8v6eG9.js +3 -0
- package/dist/client/assets/highlight-theme-CzNkO-IJ.js +1 -0
- package/dist/client/assets/hu-HU-OWADXDQ3-CEl6Udfh.js +3 -0
- package/dist/client/assets/id-ID-EOMR5R3I-CGQwUjoL.js +8 -0
- package/dist/client/assets/image-2QKV3NAF-BUbX0y5Y.js +1 -0
- package/dist/client/assets/index-BAmZnTFV.css +1 -0
- package/dist/client/assets/index-mWiw418b.js +1111 -0
- package/dist/client/assets/{infoDiagram-RXCK75RN-BMzo6KIn.js → infoDiagram-27XIBGKW-Bzy6kCbb.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BIM3h287.js → ishikawaDiagram-5VMMS53U-CRy9vIS5.js} +1 -1
- package/dist/client/assets/it-IT-FC2VTM3L-KTijNcUe.js +12 -0
- package/dist/client/assets/ja-JP-JBNTKYP4-BflWlGhw.js +12 -0
- package/dist/client/assets/{journeyDiagram-EYS64GPL-mF6Lh8O-.js → journeyDiagram-3NMN7TZE-D4ZR_s9J.js} +2 -2
- package/dist/client/assets/kaa-TC3VIB7V-B-xtZfy0.js +1 -0
- package/dist/client/assets/kab-KAB-UOUDSQKM-BmO0O4Y4.js +4 -0
- package/dist/client/assets/{kanban-definition-3QL26DDD-DLN2NyoR.js → kanban-definition-UXKFOSKX-CIDTmu5g.js} +4 -4
- package/dist/client/assets/kk-KZ-P5H2X7YS-CSQFB8IN.js +1 -0
- package/dist/client/assets/{km-KH-PCWDKPHP-DSmy5shj.js → km-KH-IHMV2US7-BxrjuEzr.js} +4 -4
- package/dist/client/assets/ko-KR-ZTMANIDF-BnNRXd5J.js +5 -0
- package/dist/client/assets/ku-TR-GPJTRB5G-BZM7f2aT.js +6 -0
- package/dist/client/assets/{line-BfTWJmgf.js → line-DSWLHgpx.js} +1 -1
- package/dist/client/assets/lobby-presence-Rdjnc0_0.js +1 -0
- package/dist/client/assets/lt-LT-V3XDOK3P-MVQBOHmF.js +3 -0
- package/dist/client/assets/lv-LV-DVQ3FADO-CrenwAhS.js +4 -0
- package/dist/client/assets/markdown-it-CocJWnjv.js +13 -0
- package/dist/client/assets/mermaid-parser.core-DrdLA3p0.js +3 -0
- package/dist/client/assets/mermaid.core-C_FK-7n4.js +1 -0
- package/dist/client/assets/mermaid.core-D0cMM4Rl.js +10 -0
- package/dist/client/assets/{mindmap-definition-FBJOCRG2-CRyHaHTk.js → mindmap-definition-YA3MSWOX-DO8NB9VH.js} +8 -8
- package/dist/client/assets/mr-IN-VZ6HH5FE-B-PHPglH.js +9 -0
- package/dist/client/assets/my-MM-XYKWHRK6-Be5sYp5q.js +1 -0
- package/dist/client/assets/nb-NO-UNO2GGZJ-BvSKGdja.js +8 -0
- package/dist/client/assets/nl-NL-76EFHT4P-C2yNx1Cj.js +13 -0
- package/dist/client/assets/nn-NO-CFKD7ABE-4NsqlDRP.js +4 -0
- package/dist/client/assets/oc-FR-YBJTCJ3J-B4OTQsWW.js +4 -0
- package/dist/client/assets/pa-IN-SNOXSMRV-CKj_sOG7.js +4 -0
- package/dist/client/assets/pegDiagram-XKGWAZYB-DS6Ab21R.js +1 -0
- package/dist/client/assets/percentages-Q7USCRWZ-DWE6uvTs.js +1 -0
- package/dist/client/assets/{pieDiagram-E7YTZNPT-B5OZPb88.js → pieDiagram-E7YTZNPT-BbFe6Tgs.js} +1 -1
- package/dist/client/assets/pl-PL-BSY6YFZ3-CFuzA6L0.js +12 -0
- package/dist/client/assets/preload-helper-CtT0-S4g.js +1 -0
- package/dist/client/assets/preview-render-compiler-C_7J7eia.js +43 -0
- package/dist/client/assets/preview-render-compiler-DzJ1KR_M.js +1 -0
- package/dist/client/assets/preview-render-worker-1DoIDllV.js +59 -0
- package/dist/client/assets/prod-D5TxmmoB.js +1 -0
- package/dist/client/assets/prod-pbFU4TaM.js +145 -0
- package/dist/client/assets/pt-BR-CZDV62R3-CkPMtyNx.js +10 -0
- package/dist/client/assets/pt-PT-JO57XJJW-CBSnfGtF.js +12 -0
- package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Drrw14YH.js → quadrantDiagram-AXDQQJYC-fJE7iAxt.js} +1 -1
- package/dist/client/assets/quick-switcher-De4PjZFC.css +1 -0
- package/dist/client/assets/quick-switcher-controller-CUajuy78.js +1 -0
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CUQKqbCK.js +1 -0
- package/dist/client/assets/{requirementDiagram-EFPCY7ZU-CRZG6mRB.js → requirementDiagram-BXWQKSXE-Balm0WW8.js} +2 -2
- package/dist/client/assets/ro-RO-UZ5ICYYN-BOuntc_r.js +12 -0
- package/dist/client/assets/room-DX7lIfnu.js +1 -0
- package/dist/client/assets/ru-RU-AN7JPREC-D-ow3SNR.js +10 -0
- package/dist/client/assets/runtime-config-BFVdhnJu.js +1 -0
- package/dist/client/assets/runtime-paths-Cn0snt_9.js +1 -0
- package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DvarEJpo.js → sankeyDiagram-P5KCCOFB-CcbMqrlQ.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-B4oWlb-w.js → sequenceDiagram-WJ2MYXX4-BL1j3Sn-.js} +6 -6
- package/dist/client/assets/si-LK-7CBLD6QQ-c91EepX0.js +1 -0
- package/dist/client/assets/sk-SK-SWR6DKBI-D5vFMIL6.js +7 -0
- package/dist/client/assets/sl-SI-JRML4FIH-D53L_0S2.js +6 -0
- package/dist/client/assets/{stateDiagram-HBIQ2CUA-qbHIIqRZ.js → stateDiagram-D77RDMKH-DNi924hh.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-MP3YSRHH-C62JEwak.js +1 -0
- package/dist/client/assets/sv-SE-4ZPKFFXF-DT-G7RCI.js +12 -0
- package/dist/client/assets/{swimlanes-XN3QIQJK-xB6CtUGj.js → swimlanes-42K2YHIH-ColgjSH4.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-VR7AAH4N-B9UZhEj4.js +8 -0
- package/dist/client/assets/ta-IN-V6NHHU6Z-D5jy7_AE.js +6 -0
- package/dist/client/assets/th-TH-P7CTMGDK-6sy0NO7K.js +1 -0
- package/dist/client/assets/{timeline-definition-24CTP7MA-Lj_yTNlY.js → timeline-definition-24CTP7MA-7pch5JAr.js} +1 -1
- package/dist/client/assets/tr-TR-GUFYG22B-ClVaf8h1.js +4 -0
- package/dist/client/assets/uk-UA-K6SV5NFQ-BLTTtyNB.js +6 -0
- package/dist/client/assets/uz-UZ-TVKTZO2G-Bm02Eg3D.js +1 -0
- package/dist/client/assets/vault-api-client-QjZ_T03l.js +7 -0
- package/dist/client/assets/vault-utils-Bct69Xw2.js +1 -0
- package/dist/client/assets/{vennDiagram-4TSXK5OY-BekRp5Y0.js → vennDiagram-4TSXK5OY-C5taziCX.js} +1 -1
- package/dist/client/assets/vi-VN-7FKFXJNO-CL3WPhmG.js +7 -0
- package/dist/client/assets/{wardleyDiagram-VM6X3IG4-kdnV_Hdm.js → wardleyDiagram-VM6X3IG4-BbSlUwuM.js} +1 -1
- package/dist/client/assets/wiki-link-resolver-C2P_WmTV.js +1 -0
- package/dist/client/assets/{worker-engine-m0rlHn8R-S8mpn_O0.js → worker-engine-m0rlHn8R-eSDcDGEI.js} +1 -1
- package/dist/client/assets/workspace-change-CVA9dVmy.js +1 -0
- package/dist/client/assets/workspace-sync-client-D4nblH_2.js +1 -0
- package/dist/client/assets/{xychartDiagram-S5SC5T6Z-DufGwNSB.js → xychartDiagram-S5SC5T6Z-D06X1arY.js} +1 -1
- package/dist/client/assets/yjs-B41tM6Sz.js +4 -0
- package/dist/client/assets/yjs-provider-reset-guard-R43MnLNc.js +1 -0
- package/dist/client/assets/zh-CN-AOKVLNNK-DGidDH2b.js +11 -0
- package/dist/client/assets/zh-HK-CDKPF5DC-CRcNR3rk.js +1 -0
- package/dist/client/assets/zh-TW-ZVGYESGW-C7Qji1y6.js +13 -0
- package/dist/client/drawio-editor.html +12 -5
- package/dist/client/excalidraw-editor.html +46 -5
- package/dist/client/export-document.html +6 -8
- package/dist/client/index.html +79 -43
- package/package.json +39 -36
- package/src/client/app/drawio-editor.html +3 -3
- package/src/client/app/excalidraw-editor.html +3 -3
- package/src/client/app/export-document.html +2 -2
- package/src/client/app/index.html +77 -37
- package/src/client/app/main-entry.js +13 -17
- package/src/client/application/app-shell/chat-feature.js +7 -22
- package/src/client/application/app-shell/comments-feature.js +6 -0
- package/src/client/application/app-shell/git-feature.js +23 -5
- package/src/client/application/app-shell/presence-feature.js +8 -25
- package/src/client/application/app-shell/ui-feature-shell.js +172 -149
- package/src/client/application/app-shell/ui-feature-sidebar.js +43 -7
- package/src/client/application/app-shell/ui-feature-tab-activity.js +27 -9
- package/src/client/application/app-shell/ui-feature-toolbar.js +16 -129
- package/src/client/application/app-shell-elements.js +9 -0
- package/src/client/application/highlight-theme.js +16 -0
- package/src/client/application/preview-render-compiler.js +44 -107
- package/src/client/application/preview-render-executor.js +0 -26
- package/src/client/application/preview-render-scheduler.js +8 -24
- package/src/client/application/preview-renderer.js +26 -9
- package/src/client/application/webmcp-diagram-renderer.js +47 -0
- package/src/client/application/workspace-coordinator.js +23 -22
- package/src/client/application/workspace-route-controller.js +7 -0
- package/src/client/bootstrap/collabmd-app-shell.js +148 -35
- package/src/client/bootstrap/lazy-collab-clients.js +90 -0
- package/src/client/domain/excalidraw-element-link.js +73 -0
- package/src/client/domain/excalidraw-scene-reconcile.js +5 -2
- package/src/client/domain/excalidraw-scene.js +21 -0
- package/src/client/domain/hash-routes.js +13 -0
- package/src/client/domain/highlight-runtime.js +47 -0
- package/src/client/domain/lobby-chat.js +2 -0
- package/src/client/domain/room.js +1 -5
- package/src/client/domain/runtime-paths.js +61 -7
- package/src/client/domain/vault-utils.js +11 -0
- package/src/client/excalidraw-editor.js +155 -14
- package/src/client/export/export-host.js +3 -1
- package/src/client/export/export-pipeline.js +4 -17
- package/src/client/infrastructure/agent-connection-api-client.js +23 -0
- package/src/client/infrastructure/auth-client.js +4 -15
- package/src/client/infrastructure/browser-preferences-port.js +16 -0
- package/src/client/infrastructure/editor-session.js +11 -0
- package/src/client/infrastructure/editor-view-adapter.js +56 -8
- package/src/client/infrastructure/excalidraw-room-client.js +89 -2
- package/src/client/infrastructure/git-api-client.js +39 -33
- package/src/client/infrastructure/hosted-api-client.js +60 -0
- package/src/client/infrastructure/lobby-presence.js +4 -7
- package/src/client/infrastructure/runtime-config.js +14 -2
- package/src/client/infrastructure/tab-activity-lock.js +2 -5
- package/src/client/infrastructure/vault-api-client.js +33 -26
- package/src/client/infrastructure/webmcp-tool-registry.js +297 -0
- package/src/client/infrastructure/workspace-sync-client.js +6 -4
- package/src/client/presentation/agent-connection-controller.js +255 -0
- package/src/client/presentation/backlinks-panel.js +3 -0
- package/src/client/presentation/bases-preview-controller.js +27 -18
- package/src/client/presentation/comment-markdown-renderer.js +2 -14
- package/src/client/presentation/comment-overview-controller.js +1 -2
- package/src/client/presentation/comment-ui/comment-ui-card.js +4 -2
- package/src/client/presentation/comment-ui/comment-ui-shared.js +5 -2
- package/src/client/presentation/create-menu-presenter.js +19 -16
- package/src/client/presentation/excalidraw-embed-controller.js +164 -4
- package/src/client/presentation/file-explorer-controller.js +3 -0
- package/src/client/presentation/file-explorer-view.js +338 -182
- package/src/client/presentation/file-history-view-controller.js +13 -11
- package/src/client/presentation/git-diff-view-controller.js +35 -43
- package/src/client/presentation/git-panel-controller.js +78 -28
- package/src/client/presentation/hosted-workspace-gate-controller.js +180 -0
- package/src/client/presentation/image-lightbox-controller.js +20 -16
- package/src/client/presentation/layout-controller.js +13 -2
- package/src/client/presentation/quick-switcher-controller.js +20 -78
- package/src/client/presentation/quick-switcher-text-search.js +10 -14
- package/src/client/presentation/team-settings-controller.js +228 -0
- package/src/client/styles/components/navigation.css +1 -2
- package/src/client/styles/deferred-collab.css +5 -0
- package/src/client/styles/deferred-git.css +7 -0
- package/src/client/styles/deferred-preview.css +6 -0
- package/src/client/styles/features/agent-connection.css +202 -0
- package/src/client/styles/features/collaboration-chat.css +8 -1
- package/src/client/styles/features/collaboration-dialogs.css +16 -1
- package/src/client/styles/features/collaboration-presence.css +17 -4
- package/src/client/styles/features/diagram-preview.css +0 -15
- package/src/client/styles/features/diff-toolbar.css +1 -1
- package/src/client/styles/features/media-lightbox.css +12 -3
- package/src/client/styles/features/outline.css +4 -2
- package/src/client/styles/features/preview-markdown.css +25 -11
- package/src/client/styles/features/quick-switcher.css +20 -11
- package/src/client/styles/features/team-settings.css +162 -0
- package/src/client/styles/foundation/themes.css +2 -0
- package/src/client/styles/foundation/tokens.css +2 -2
- package/src/client/styles/layout/editor-page.css +25 -24
- package/src/client/styles/layout/overlays.css +16 -0
- package/src/client/styles/layout/responsive.css +7 -25
- package/src/client/styles/layout/shell.css +21 -1
- package/src/client/styles/layout/sidebar.css +99 -7
- package/src/client/styles/primitives/controls.css +21 -54
- package/src/client/styles/style.css +4 -19
- package/src/domain/agent-tool-definitions.js +872 -0
- package/src/domain/collabmd-content-capabilities.js +149 -0
- package/src/domain/collaboration-protocol.js +2 -0
- package/src/domain/comment-threads.js +3 -5
- package/src/domain/diagram-source.js +50 -0
- package/src/domain/editable-content-revision.js +10 -0
- package/src/domain/editable-text.js +3 -0
- package/src/domain/exact-text-edits.js +69 -0
- package/src/domain/excalidraw-agent-scene.js +624 -0
- package/src/domain/excalidraw-agent-verification.js +554 -0
- package/src/domain/excalidraw-room-codec.js +13 -6
- package/src/domain/literal-text-search.js +13 -0
- package/src/domain/video-embed.js +76 -0
- package/src/server/application/agent-connection-service.js +178 -0
- package/src/server/application/agent-content-service.js +841 -0
- package/src/server/application/workspace-reconciliation.js +5 -7
- package/src/server/config/env.js +147 -6
- package/src/server/create-app-server.js +47 -141
- package/src/server/domain/bases/base-query-service.js +1 -5
- package/src/server/domain/collaboration/collaboration-room.js +121 -25
- package/src/server/domain/collaboration/protocol.js +4 -0
- package/src/server/domain/hosted-workspace.js +31 -1
- package/src/server/domain/markdown-reference-extractor.js +15 -1
- package/src/server/domain/ripgrep-search-service.js +68 -21
- package/src/server/infrastructure/git/git-service.js +19 -1
- package/src/server/infrastructure/git/history-service.js +1 -1
- package/src/server/infrastructure/git/local-exclude.js +37 -0
- package/src/server/infrastructure/git/parsers.js +19 -17
- package/src/server/infrastructure/git/path-utils.js +0 -16
- package/src/server/infrastructure/git/status-service.js +1 -1
- package/src/server/infrastructure/git/untracked-files.js +12 -21
- package/src/server/infrastructure/http/create-agent-api-handler.js +171 -0
- package/src/server/infrastructure/http/create-git-api-command-handler.js +32 -0
- package/src/server/infrastructure/http/create-hosted-api-handler.js +5 -0
- package/src/server/infrastructure/http/create-request-handler.js +123 -26
- package/src/server/infrastructure/http/create-static-handler.js +9 -0
- package/src/server/infrastructure/http/create-vault-api-query-handler.js +15 -2
- package/src/server/infrastructure/mcp/create-agent-mcp-handler.js +200 -0
- package/src/server/infrastructure/persistence/agent-connection-store.js +120 -0
- package/src/server/infrastructure/persistence/pull-backup-store.js +2 -27
- package/src/server/infrastructure/persistence/sidecar-store.js +12 -5
- package/src/server/infrastructure/persistence/vault-file-store.js +11 -5
- package/src/server/infrastructure/websocket/attach-collaboration-gateway.js +48 -22
- package/src/server/shared/agent-tool-image.js +22 -0
- package/src/server/shared/agent-tool-rate-limiter.js +27 -0
- package/src/server/startup/git-remote-bootstrap.js +58 -79
- package/src/server/vault-registry.js +251 -0
- package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-BPH4FJkv.js +0 -1
- package/dist/client/assets/abnfDiagram-VCTEODGH-BNDLzJ7L.js +0 -1
- package/dist/client/assets/ar-SA-PQUY64WN-xjXgbW6d.js +0 -10
- package/dist/client/assets/az-AZ-OXJXL76K-4JkO4Pca.js +0 -1
- package/dist/client/assets/base-CaIEJUF9.css +0 -1
- package/dist/client/assets/bg-BG-W2GKIJDF-DnkH_o81.js +0 -5
- package/dist/client/assets/bn-BD-TGL7M4PJ-CG4JkmtP.js +0 -3
- package/dist/client/assets/bn-IN-BKETKYEH-CG4JkmtP.js +0 -3
- package/dist/client/assets/browser-utils--H_DkyEF.js +0 -1
- package/dist/client/assets/ca-ES-LD5SCRVV-U6_TVMX9.js +0 -8
- package/dist/client/assets/channel-CaoKA_We.js +0 -1
- package/dist/client/assets/chunk-7XWMRXBY-CfMzEq80.js +0 -1
- package/dist/client/assets/chunk-CKBBP62Z-DG26UiBv.js +0 -2
- package/dist/client/assets/chunk-DSNCTWBM-8xkug7fQ.js +0 -2
- package/dist/client/assets/chunk-DU6HZSFF-COXDzJK1.js +0 -127
- package/dist/client/assets/chunk-R7TYR2AO-CTd0Yj98.js +0 -10
- package/dist/client/assets/chunk-RM4UPSZO-CWRwxNWJ.js +0 -41
- package/dist/client/assets/classDiagram-DTDB5LWJ-7fEmn0zV.js +0 -1
- package/dist/client/assets/classDiagram-v2-JRS7N3AN-7fEmn0zV.js +0 -1
- package/dist/client/assets/comment-thread-store-CdcwrObc.js +0 -1
- package/dist/client/assets/comment-threads-9J6Em-_y.js +0 -4
- package/dist/client/assets/comment-ui-shared-DuoyznXW.js +0 -7
- package/dist/client/assets/cs-CZ-OFPU5DBV-BmFAIhqX.js +0 -7
- package/dist/client/assets/da-DK-FRDJFYWF-H387Jw8B.js +0 -2
- package/dist/client/assets/de-CH-ZG7H3QK3-C_groygo.js +0 -11
- package/dist/client/assets/de-DE-SIJYH4IH-C_groygo.js +0 -11
- package/dist/client/assets/diagram-VSXAHHWV-CQRVEZR7.js +0 -3
- package/dist/client/assets/dist-73RPdcyU.js +0 -1
- package/dist/client/assets/dist-BJ1bJs33.js +0 -1
- package/dist/client/assets/dist-ByrG2qBA.js +0 -1
- package/dist/client/assets/dist-CH-sQu3r.js +0 -1
- package/dist/client/assets/dist-CKS_-are.js +0 -1
- package/dist/client/assets/dist-D37Hyu3h.js +0 -9
- package/dist/client/assets/dist-DZAAWTG-.js +0 -1
- package/dist/client/assets/dist-Dir5dDKZ.js +0 -1
- package/dist/client/assets/dist-Dl_tpDSr.js +0 -1
- package/dist/client/assets/dist-DutPuFmC.js +0 -1
- package/dist/client/assets/dist-RKBTaQMb.js +0 -13
- package/dist/client/assets/dist-eBx8q6Sy.js +0 -1
- package/dist/client/assets/drawio-editor-BVaNNtYp.js +0 -9
- package/dist/client/assets/drawioEditor-BkIBlXx0.js +0 -2
- package/dist/client/assets/ebnfDiagram-PWID7BFC-OXa8VEp1.js +0 -1
- package/dist/client/assets/editor-session-DMyVdHLj.js +0 -54
- package/dist/client/assets/el-GR-IEE2CGI2-BkT6YT54.js +0 -7
- package/dist/client/assets/embedded-editor-base-B3l6Xy65.css +0 -1
- package/dist/client/assets/es-ES-TVVPWKV5-CpPKJXTM.js +0 -12
- package/dist/client/assets/eu-ES-CGBMFQDT-Bu3N2493.js +0 -8
- package/dist/client/assets/excalidraw-editor-BjYaNEMY.js +0 -9
- package/dist/client/assets/excalidraw-mermaid-stub-BNckbX2n.js +0 -1
- package/dist/client/assets/excalidraw-mermaid-stub-DE5FTiZB.js +0 -1
- package/dist/client/assets/excalidrawEditor-ChqF_d82.js +0 -2
- package/dist/client/assets/export-page-Dyu0XCbu.js +0 -57
- package/dist/client/assets/exportDocument-CJBx4Xjx.css +0 -1
- package/dist/client/assets/exportDocument-Dgvfa2Sd.js +0 -2
- package/dist/client/assets/fa-IR-IE6XAPR4-BEvLCORD.js +0 -9
- package/dist/client/assets/fi-FI-P7TKNHRM-DI0q8iSX.js +0 -6
- package/dist/client/assets/file-icon-svg-Y_kpF957.js +0 -1
- package/dist/client/assets/flowDiagram-A5DVABFB-CiW1eN8C.js +0 -1
- package/dist/client/assets/fr-FR-QI2XZNT7-y8kXd8LA.js +0 -12
- package/dist/client/assets/gl-ES-TLYCNOZZ-Br-Fhff-.js +0 -6
- package/dist/client/assets/he-IL-ZX43XLGP-qKQq6V9X.js +0 -9
- package/dist/client/assets/hi-IN-UTYRMTUF-DOUcwrDO.js +0 -3
- package/dist/client/assets/hu-HU-AJOSEBW6-FqTyvHlD.js +0 -3
- package/dist/client/assets/id-ID-ETLTVG6C-CQqh3CLS.js +0 -8
- package/dist/client/assets/image-ZVKINSPA-0zXSnE7M.js +0 -1
- package/dist/client/assets/index-CSNIMyOP.css +0 -1
- package/dist/client/assets/index-DG3N2Ps-.js +0 -2
- package/dist/client/assets/it-IT-B4B6TP6L-V-yK3SZz.js +0 -12
- package/dist/client/assets/ja-JP-IYKVURR5-BQKBXRpX.js +0 -12
- package/dist/client/assets/kaa-SE2BUIKX-CZ5kfwPg.js +0 -1
- package/dist/client/assets/kab-KAB-Y3GLKXLR-Do7GWfuN.js +0 -4
- package/dist/client/assets/kk-KZ-ABWUFVOH-BpqVciQz.js +0 -1
- package/dist/client/assets/ko-KR-7JQDXKGM-N42lep78.js +0 -5
- package/dist/client/assets/ku-TR-NAH2Q5B7-K8LLl9fk.js +0 -6
- package/dist/client/assets/lt-LT-VQFYRSNQ-BmOd0ALn.js +0 -3
- package/dist/client/assets/lv-LV-T62VSYUM-B22WdPhp.js +0 -4
- package/dist/client/assets/main-D0wCxpVn.js +0 -903
- package/dist/client/assets/mermaid-parser.core-Bl0efOMt.js +0 -4
- package/dist/client/assets/mermaid.core-BJRLUQZE.js +0 -11
- package/dist/client/assets/modulepreload-polyfill-P2Xu9kJm.js +0 -1
- package/dist/client/assets/mr-IN-V4FHLCJE-XX069tpm.js +0 -9
- package/dist/client/assets/my-MM-E3SQ6E54-cst_-5SB.js +0 -1
- package/dist/client/assets/nb-NO-MLNOFN5H-Bu2URWko.js +0 -8
- package/dist/client/assets/nl-NL-D5L3ZV4M-BqrV0btt.js +0 -13
- package/dist/client/assets/nn-NO-NNHDGPKB-DK-xZaWM.js +0 -4
- package/dist/client/assets/oc-FR-DWCRF55G-BZ5Po5R6.js +0 -4
- package/dist/client/assets/pa-IN-3JSAY44M-BZQSjKrS.js +0 -4
- package/dist/client/assets/pegDiagram-XKGWAZYB-B31fKPR2.js +0 -1
- package/dist/client/assets/percentages-ETZPVQEE-DFxFqXgH.js +0 -1
- package/dist/client/assets/pl-PL-ACURYKP3-qcEOSfCk.js +0 -12
- package/dist/client/assets/preload-helper-HclGiUj8.js +0 -1
- package/dist/client/assets/preview-render-compiler-CrJIooVD.js +0 -35
- package/dist/client/assets/preview-render-compiler-O0JxBVNF.js +0 -1
- package/dist/client/assets/preview-render-profile-B4RWYWHt.js +0 -1
- package/dist/client/assets/preview-render-worker-_QTxqKvP.js +0 -60
- package/dist/client/assets/prod-BiYPMR1i.js +0 -177
- package/dist/client/assets/prod-VxdGZ5Ly.js +0 -1
- package/dist/client/assets/pt-BR-LOX7MLGD-DLueHSyZ.js +0 -10
- package/dist/client/assets/pt-PT-CZ2U2RFQ-BJ-GAEm6.js +0 -12
- package/dist/client/assets/quick-switcher-controller-CaEjEtq_.js +0 -1
- package/dist/client/assets/railroadDiagram-O6MQD6OU-BPifP0MB.js +0 -1
- package/dist/client/assets/ro-RO-2HECL2X6-CJUvKAf0.js +0 -12
- package/dist/client/assets/ru-RU-HAYNXO46-BWSlvTrt.js +0 -10
- package/dist/client/assets/runtime-config-BLrEKVO1.js +0 -1
- package/dist/client/assets/si-LK-W5KNS4H6-DGGCsn7k.js +0 -1
- package/dist/client/assets/sk-SK-7K2CFGDV-CY4uTYgQ.js +0 -7
- package/dist/client/assets/sl-SI-OXV2QZWW-2-weqaBY.js +0 -6
- package/dist/client/assets/stateDiagram-v2-4QOOHH4V-B--gjrit.js +0 -1
- package/dist/client/assets/sv-SE-JTOBZRGL-9-IUtVkO.js +0 -12
- package/dist/client/assets/swimlanesDiagram-VK2B7HYN-DO8XNXEg.js +0 -8
- package/dist/client/assets/ta-IN-KFAVKXGT-gHO6Q_DH.js +0 -6
- package/dist/client/assets/th-TH-VDMSCPDL-BvJuw6PJ.js +0 -1
- package/dist/client/assets/tr-TR-CEZ6GX45-CG6UU3Su.js +0 -4
- package/dist/client/assets/uk-UA-Q3H3OXQC-CSuIg_DY.js +0 -6
- package/dist/client/assets/uz-UZ-NGCSWWPX-mom7rxSP.js +0 -1
- package/dist/client/assets/vault-api-client-BkwdFjx0.js +0 -6
- package/dist/client/assets/vault-utils-DvoSftJT.js +0 -22
- package/dist/client/assets/vi-VN-P3NDEVPS-BB0Fu9ck.js +0 -7
- package/dist/client/assets/yjs-provider-reset-guard-DE0vINDP.js +0 -4
- package/dist/client/assets/zh-CN-SS3O57GA-Bj8wsiMe.js +0 -11
- package/dist/client/assets/zh-HK-LWJT3VCF-DOTquTCh.js +0 -1
- package/dist/client/assets/zh-TW-VJXC72RT-B48PRo-l.js +0 -13
- package/src/client/app/drawio-editor-entry.js +0 -1
- package/src/client/app/excalidraw-editor-entry.js +0 -1
- package/src/client/excalidraw-mermaid-stub.js +0 -7
- package/src/client/main.js +0 -16
- /package/dist/client/assets/{vault-api-client-C3mlS_4N.css → auth-gate-C3mlS_4N.css} +0 -0
- /package/dist/client/assets/{drawio-editor-UQQ8XHou.css → drawioEditor-UQQ8XHou.css} +0 -0
- /package/dist/client/assets/{base-BYODPHdS.js → github.min-DBihDoic.js} +0 -0
- /package/dist/client/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateNKeysBetween,
|
|
3
|
+
validateOrderKey,
|
|
4
|
+
} from '@excalidraw/fractional-indexing';
|
|
5
|
+
|
|
6
|
+
const ELEMENT_TYPES = new Set([
|
|
7
|
+
'arrow',
|
|
8
|
+
'diamond',
|
|
9
|
+
'ellipse',
|
|
10
|
+
'freedraw',
|
|
11
|
+
'line',
|
|
12
|
+
'rectangle',
|
|
13
|
+
'text',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const LINEAR_TYPES = new Set(['arrow', 'freedraw', 'line']);
|
|
17
|
+
// Matches Excalidraw's DEFAULT_FONT_FAMILY (Excalifont).
|
|
18
|
+
const DEFAULT_TEXT_FONT_FAMILY = 5;
|
|
19
|
+
const TEXT_LAYOUT_CONTAINER_TYPES = new Set(['diamond', 'ellipse', 'rectangle']);
|
|
20
|
+
const TEXT_METRIC_FIELDS = new Set([
|
|
21
|
+
'autoResize',
|
|
22
|
+
'containerId',
|
|
23
|
+
'fontFamily',
|
|
24
|
+
'fontSize',
|
|
25
|
+
'lineHeight',
|
|
26
|
+
'text',
|
|
27
|
+
]);
|
|
28
|
+
const TEXT_GEOMETRY_FIELDS = new Set(['height', 'width', 'x', 'y']);
|
|
29
|
+
|
|
30
|
+
function invalid(message) {
|
|
31
|
+
const error = new Error(message);
|
|
32
|
+
error.code = 'EXCALIDRAW_SCENE_INVALID';
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function stableNumber(value) {
|
|
37
|
+
let hash = 2166136261;
|
|
38
|
+
for (const character of value) {
|
|
39
|
+
hash ^= character.codePointAt(0);
|
|
40
|
+
hash = Math.imul(hash, 16777619);
|
|
41
|
+
}
|
|
42
|
+
return (hash >>> 0) || 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function requireObject(value, name) {
|
|
46
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
47
|
+
throw invalid(`${name} must be an object`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function requireNumber(value, name) {
|
|
53
|
+
if (!Number.isFinite(value)) throw invalid(`${name} must be a finite number`);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function normalizePoints(points, type) {
|
|
58
|
+
if (!LINEAR_TYPES.has(type)) return points;
|
|
59
|
+
const source = points ?? [[0, 0], [100, 0]];
|
|
60
|
+
if (!Array.isArray(source) || source.length < 2 || source.length > 1_000) {
|
|
61
|
+
throw invalid(`${type} points must contain 2 to 1000 coordinate pairs`);
|
|
62
|
+
}
|
|
63
|
+
return source.map((point) => {
|
|
64
|
+
if (!Array.isArray(point) || point.length !== 2) {
|
|
65
|
+
throw invalid(`${type} points must be [x, y] coordinate pairs`);
|
|
66
|
+
}
|
|
67
|
+
return [requireNumber(point[0], `${type} point x`), requireNumber(point[1], `${type} point y`)];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function normalizePointGeometry(points, x, y, type) {
|
|
72
|
+
const [offsetX, offsetY] = points[0];
|
|
73
|
+
const normalizedPoints = points.map(([pointX, pointY]) => [
|
|
74
|
+
pointX - offsetX,
|
|
75
|
+
pointY - offsetY,
|
|
76
|
+
]);
|
|
77
|
+
const xs = normalizedPoints.map(([pointX]) => pointX);
|
|
78
|
+
const ys = normalizedPoints.map(([, pointY]) => pointY);
|
|
79
|
+
const width = Math.max(...xs) - Math.min(...xs);
|
|
80
|
+
const height = Math.max(...ys) - Math.min(...ys);
|
|
81
|
+
if (width === 0 && height === 0) {
|
|
82
|
+
throw invalid(`${type} points must span a non-zero distance`);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
height,
|
|
86
|
+
points: normalizedPoints,
|
|
87
|
+
width,
|
|
88
|
+
x: x + offsetX,
|
|
89
|
+
y: y + offsetY,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function readElementGeometry(raw, id, type) {
|
|
94
|
+
const x = requireNumber(raw.x, `Element ${id} x`);
|
|
95
|
+
const y = requireNumber(raw.y, `Element ${id} y`);
|
|
96
|
+
const points = normalizePoints(raw.points, type);
|
|
97
|
+
if (points) {
|
|
98
|
+
return {
|
|
99
|
+
...normalizePointGeometry(points, x, y, type),
|
|
100
|
+
fontSize: raw.fontSize,
|
|
101
|
+
text: raw.text,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const fontSize = type === 'text'
|
|
106
|
+
? requireNumber(raw.fontSize ?? 20, `Element ${id} fontSize`)
|
|
107
|
+
: raw.fontSize;
|
|
108
|
+
if (type === 'text' && fontSize <= 0) throw invalid(`Element ${id} fontSize must be positive`);
|
|
109
|
+
const text = type === 'text' ? String(raw.text ?? '') : raw.text;
|
|
110
|
+
const lineHeight = type === 'text'
|
|
111
|
+
? requireNumber(raw.lineHeight ?? 1.25, `Element ${id} lineHeight`)
|
|
112
|
+
: null;
|
|
113
|
+
if (type === 'text' && lineHeight <= 0) throw invalid(`Element ${id} lineHeight must be positive`);
|
|
114
|
+
const defaultWidth = type === 'text'
|
|
115
|
+
? Math.max(1, ...text.split('\n').map((line) => line.length)) * fontSize * 0.6
|
|
116
|
+
: 100;
|
|
117
|
+
const defaultHeight = type === 'text'
|
|
118
|
+
? Math.max(1, text.split('\n').length) * fontSize * lineHeight
|
|
119
|
+
: 100;
|
|
120
|
+
const width = requireNumber(raw.width ?? defaultWidth, `Element ${id} width`);
|
|
121
|
+
const height = requireNumber(raw.height ?? defaultHeight, `Element ${id} height`);
|
|
122
|
+
if (width <= 0 || height <= 0) {
|
|
123
|
+
throw invalid(`Element ${id} width and height must be positive`);
|
|
124
|
+
}
|
|
125
|
+
return { fontSize, height, points, text, width, x, y };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createBaseElement(raw, {
|
|
129
|
+
height,
|
|
130
|
+
id,
|
|
131
|
+
now,
|
|
132
|
+
type,
|
|
133
|
+
width,
|
|
134
|
+
x,
|
|
135
|
+
y,
|
|
136
|
+
}) {
|
|
137
|
+
const rest = { ...raw };
|
|
138
|
+
delete rest.afterElementId;
|
|
139
|
+
delete rest.beforeElementId;
|
|
140
|
+
delete rest.endElementId;
|
|
141
|
+
delete rest.startElementId;
|
|
142
|
+
return {
|
|
143
|
+
...rest,
|
|
144
|
+
angle: raw.angle ?? 0,
|
|
145
|
+
backgroundColor: raw.backgroundColor ?? 'transparent',
|
|
146
|
+
boundElements: raw.boundElements ?? null,
|
|
147
|
+
fillStyle: raw.fillStyle ?? 'solid',
|
|
148
|
+
frameId: raw.frameId ?? null,
|
|
149
|
+
groupIds: raw.groupIds ?? [],
|
|
150
|
+
height,
|
|
151
|
+
id,
|
|
152
|
+
index: raw.index ?? null,
|
|
153
|
+
isDeleted: false,
|
|
154
|
+
link: raw.link ?? null,
|
|
155
|
+
locked: raw.locked ?? false,
|
|
156
|
+
opacity: raw.opacity ?? 100,
|
|
157
|
+
roughness: raw.roughness ?? 1,
|
|
158
|
+
roundness: raw.roundness ?? (['diamond', 'ellipse', 'rectangle'].includes(type) ? { type: 3 } : null),
|
|
159
|
+
seed: raw.seed ?? stableNumber(`${id}:seed`),
|
|
160
|
+
strokeColor: raw.strokeColor ?? '#1e1e1e',
|
|
161
|
+
strokeStyle: raw.strokeStyle ?? 'solid',
|
|
162
|
+
strokeWidth: raw.strokeWidth ?? 2,
|
|
163
|
+
type,
|
|
164
|
+
updated: raw.updated ?? now,
|
|
165
|
+
version: raw.version ?? 1,
|
|
166
|
+
versionNonce: raw.versionNonce ?? stableNumber(`${id}:nonce`),
|
|
167
|
+
width,
|
|
168
|
+
x,
|
|
169
|
+
y,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function addLinearElementFields(element, raw) {
|
|
174
|
+
const startBinding = raw.startElementId
|
|
175
|
+
? { elementId: raw.startElementId, fixedPoint: null, focus: 0, gap: 4 }
|
|
176
|
+
: raw.startBinding ?? null;
|
|
177
|
+
const endBinding = raw.endElementId
|
|
178
|
+
? { elementId: raw.endElementId, fixedPoint: null, focus: 0, gap: 4 }
|
|
179
|
+
: raw.endBinding ?? null;
|
|
180
|
+
element.endBinding = endBinding;
|
|
181
|
+
element.lastCommittedPoint = raw.lastCommittedPoint ?? null;
|
|
182
|
+
element.startBinding = startBinding;
|
|
183
|
+
if (element.type === 'arrow') {
|
|
184
|
+
element.endArrowhead = raw.endArrowhead ?? 'arrow';
|
|
185
|
+
element.startArrowhead = raw.startArrowhead ?? null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function addFreeDrawElementFields(element, raw) {
|
|
190
|
+
element.pressures = Array.isArray(raw.pressures) ? raw.pressures : [];
|
|
191
|
+
element.simulatePressure = raw.simulatePressure ?? true;
|
|
192
|
+
element.strokeOptions = raw.strokeOptions ?? {
|
|
193
|
+
streamline: 0.5,
|
|
194
|
+
variability: 'variable',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function addTextElementFields(element, raw, { fontSize, text }) {
|
|
199
|
+
element.autoResize = raw.autoResize ?? true;
|
|
200
|
+
element.containerId = raw.containerId ?? null;
|
|
201
|
+
element.fontFamily = raw.fontFamily ?? DEFAULT_TEXT_FONT_FAMILY;
|
|
202
|
+
element.fontSize = fontSize;
|
|
203
|
+
element.lineHeight = raw.lineHeight ?? 1.25;
|
|
204
|
+
element.originalText = raw.originalText ?? text;
|
|
205
|
+
element.text = text;
|
|
206
|
+
element.textAlign = raw.textAlign ?? 'center';
|
|
207
|
+
element.verticalAlign = raw.verticalAlign ?? 'middle';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function normalizeElement(rawElement, now) {
|
|
211
|
+
const raw = requireObject(rawElement, 'Element');
|
|
212
|
+
const id = String(raw.id ?? '').trim();
|
|
213
|
+
if (!id || id.length > 128) throw invalid('Element id must contain 1 to 128 characters');
|
|
214
|
+
if (!ELEMENT_TYPES.has(raw.type)) throw invalid(`Unsupported Excalidraw element type: ${raw.type}`);
|
|
215
|
+
|
|
216
|
+
const type = raw.type;
|
|
217
|
+
const geometry = readElementGeometry(raw, id, type);
|
|
218
|
+
const element = createBaseElement(raw, { ...geometry, id, now, type });
|
|
219
|
+
if (geometry.points) element.points = geometry.points;
|
|
220
|
+
if (type === 'arrow' || type === 'line') addLinearElementFields(element, raw);
|
|
221
|
+
if (type === 'freedraw') addFreeDrawElementFields(element, raw);
|
|
222
|
+
if (type === 'text') addTextElementFields(element, raw, geometry);
|
|
223
|
+
return element;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function bumpElementVersion(element, now, reason) {
|
|
227
|
+
const version = (Number(element.version) || 0) + 1;
|
|
228
|
+
return {
|
|
229
|
+
...element,
|
|
230
|
+
updated: now,
|
|
231
|
+
version,
|
|
232
|
+
versionNonce: stableNumber(`${element.id}:${reason}:${version}:${now}`),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function moveElement(elements, id, directive, name) {
|
|
237
|
+
const { action, afterElementId, beforeElementId } = directive ?? {};
|
|
238
|
+
const instructions = [action, beforeElementId, afterElementId].filter((value) => value !== undefined);
|
|
239
|
+
if (instructions.length === 0) return;
|
|
240
|
+
if (instructions.length !== 1) {
|
|
241
|
+
throw invalid(`${name} must specify exactly one action, beforeElementId, or afterElementId`);
|
|
242
|
+
}
|
|
243
|
+
if (action !== undefined && !['bringToFront', 'sendToBack'].includes(action)) {
|
|
244
|
+
throw invalid(`${name} uses unsupported action ${action}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const currentIndex = elements.findIndex((element) => element.id === id && !element.isDeleted);
|
|
248
|
+
if (currentIndex < 0) throw invalid(`Excalidraw element not found: ${id}`);
|
|
249
|
+
const [element] = elements.splice(currentIndex, 1);
|
|
250
|
+
let targetIndex;
|
|
251
|
+
if (action === 'sendToBack') {
|
|
252
|
+
targetIndex = elements.findIndex((candidate) => !candidate.isDeleted);
|
|
253
|
+
if (targetIndex < 0) targetIndex = elements.length;
|
|
254
|
+
} else if (action === 'bringToFront') {
|
|
255
|
+
const lastActiveIndex = elements.findLastIndex((candidate) => !candidate.isDeleted);
|
|
256
|
+
targetIndex = lastActiveIndex < 0 ? elements.length : lastActiveIndex + 1;
|
|
257
|
+
} else {
|
|
258
|
+
const targetId = beforeElementId ?? afterElementId;
|
|
259
|
+
if (targetId === id) throw invalid(`${name} cannot target its own element`);
|
|
260
|
+
const referenceIndex = elements.findIndex((candidate) => (
|
|
261
|
+
candidate.id === targetId && !candidate.isDeleted
|
|
262
|
+
));
|
|
263
|
+
if (referenceIndex < 0) {
|
|
264
|
+
throw invalid(`${name} targets missing element ${targetId}`);
|
|
265
|
+
}
|
|
266
|
+
targetIndex = beforeElementId ? referenceIndex : referenceIndex + 1;
|
|
267
|
+
}
|
|
268
|
+
elements.splice(targetIndex, 0, element);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function hasValidElementOrder(elements) {
|
|
272
|
+
let previousIndex = null;
|
|
273
|
+
for (const element of elements) {
|
|
274
|
+
if (element.isDeleted) continue;
|
|
275
|
+
if (typeof element.index !== 'string') return false;
|
|
276
|
+
try {
|
|
277
|
+
validateOrderKey(element.index);
|
|
278
|
+
} catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (previousIndex !== null && element.index <= previousIndex) return false;
|
|
282
|
+
previousIndex = element.index;
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function normalizeElementOrder(elements, now, alreadyVersionedIds = new Set()) {
|
|
288
|
+
if (hasValidElementOrder(elements)) return elements;
|
|
289
|
+
const activeElements = elements.filter((element) => !element.isDeleted);
|
|
290
|
+
const indices = generateNKeysBetween(null, null, activeElements.length);
|
|
291
|
+
let activeIndex = 0;
|
|
292
|
+
return elements.map((element) => {
|
|
293
|
+
if (element.isDeleted) return element;
|
|
294
|
+
const index = indices[activeIndex];
|
|
295
|
+
activeIndex += 1;
|
|
296
|
+
if (element.index === index) return element;
|
|
297
|
+
if (alreadyVersionedIds.has(element.id)) {
|
|
298
|
+
return { ...element, index };
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
...bumpElementVersion(element, now, `index:${index}`),
|
|
302
|
+
index,
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function refreshArrowBindings(elements) {
|
|
308
|
+
const activeById = new Map(elements.filter((element) => !element.isDeleted).map((element) => [element.id, element]));
|
|
309
|
+
for (const element of activeById.values()) {
|
|
310
|
+
if (Array.isArray(element.boundElements)) {
|
|
311
|
+
element.boundElements = element.boundElements.filter(({ type }) => type !== 'arrow' && type !== 'text');
|
|
312
|
+
if (element.boundElements.length === 0) element.boundElements = null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
for (const element of activeById.values()) {
|
|
316
|
+
if (element.type === 'text' && element.containerId) {
|
|
317
|
+
const container = activeById.get(element.containerId);
|
|
318
|
+
if (!container) throw invalid(`Element ${element.id} binds to missing container ${element.containerId}`);
|
|
319
|
+
container.boundElements = [...(container.boundElements ?? []), { id: element.id, type: 'text' }];
|
|
320
|
+
}
|
|
321
|
+
if (element.type !== 'arrow' && element.type !== 'line') continue;
|
|
322
|
+
for (const binding of [element.startBinding, element.endBinding]) {
|
|
323
|
+
if (!binding?.elementId) continue;
|
|
324
|
+
const target = activeById.get(binding.elementId);
|
|
325
|
+
if (!target) throw invalid(`Element ${element.id} binds to missing element ${binding.elementId}`);
|
|
326
|
+
target.boundElements = [...(target.boundElements ?? []), { id: element.id, type: 'arrow' }];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function validateUniqueIds(elements) {
|
|
332
|
+
const ids = new Set();
|
|
333
|
+
for (const element of elements) {
|
|
334
|
+
if (ids.has(element.id)) throw invalid(`Duplicate Excalidraw element id: ${element.id}`);
|
|
335
|
+
ids.add(element.id);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function resolveTranslationIds(elements, requestedIds) {
|
|
340
|
+
const resolved = new Set(requestedIds);
|
|
341
|
+
for (const id of resolved) {
|
|
342
|
+
const element = elements.find((candidate) => candidate.id === id && !candidate.isDeleted);
|
|
343
|
+
if (!element) throw invalid(`Excalidraw element not found: ${id}`);
|
|
344
|
+
if (element.containerId) resolved.add(element.containerId);
|
|
345
|
+
const groupIds = Array.isArray(element.groupIds) ? element.groupIds : [];
|
|
346
|
+
for (const candidate of elements) {
|
|
347
|
+
if (candidate.isDeleted) continue;
|
|
348
|
+
const sharesTranslationGroup = Array.isArray(candidate.groupIds)
|
|
349
|
+
&& candidate.groupIds.some((groupId) => groupIds.includes(groupId));
|
|
350
|
+
if (candidate.containerId === id || sharesTranslationGroup) resolved.add(candidate.id);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return [...resolved];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function textHeight(element) {
|
|
357
|
+
const text = String(element.text ?? '');
|
|
358
|
+
const lineCount = Math.max(1, text.split('\n').length);
|
|
359
|
+
const fontSize = requireNumber(element.fontSize ?? 20, `Element ${element.id} fontSize`);
|
|
360
|
+
const lineHeight = requireNumber(element.lineHeight ?? 1.25, `Element ${element.id} lineHeight`);
|
|
361
|
+
return lineCount * fontSize * lineHeight;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function sameNumber(left, right) {
|
|
365
|
+
return Math.abs(left - right) < 0.001;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function reflowBoundText(elements, ids, now, alreadyVersionedIds) {
|
|
369
|
+
const activeById = new Map(
|
|
370
|
+
elements.filter((element) => !element.isDeleted).map((element) => [element.id, element]),
|
|
371
|
+
);
|
|
372
|
+
let reflowed = 0;
|
|
373
|
+
|
|
374
|
+
ids.forEach((id) => {
|
|
375
|
+
const text = activeById.get(id);
|
|
376
|
+
if (text?.type !== 'text' || !text.containerId) return;
|
|
377
|
+
|
|
378
|
+
const container = activeById.get(text.containerId);
|
|
379
|
+
if (
|
|
380
|
+
!container
|
|
381
|
+
|| !TEXT_LAYOUT_CONTAINER_TYPES.has(container.type)
|
|
382
|
+
|| Number(container.angle ?? 0) !== 0
|
|
383
|
+
) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const width = requireNumber(text.width, `Element ${id} width`);
|
|
388
|
+
const height = textHeight(text);
|
|
389
|
+
const x = requireNumber(container.x, `Element ${text.containerId} x`)
|
|
390
|
+
+ ((requireNumber(container.width, `Element ${text.containerId} width`) - width) / 2);
|
|
391
|
+
const y = requireNumber(container.y, `Element ${text.containerId} y`)
|
|
392
|
+
+ ((requireNumber(container.height, `Element ${text.containerId} height`) - height) / 2);
|
|
393
|
+
|
|
394
|
+
if (
|
|
395
|
+
sameNumber(text.x, x)
|
|
396
|
+
&& sameNumber(text.y, y)
|
|
397
|
+
&& sameNumber(text.height, height)
|
|
398
|
+
) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const positioned = { ...text, height, x, y };
|
|
403
|
+
const next = alreadyVersionedIds.has(id)
|
|
404
|
+
? positioned
|
|
405
|
+
: bumpElementVersion(positioned, now, 'bound-text-layout');
|
|
406
|
+
const elementIndex = elements.indexOf(text);
|
|
407
|
+
elements[elementIndex] = next;
|
|
408
|
+
activeById.set(id, next);
|
|
409
|
+
alreadyVersionedIds.add(id);
|
|
410
|
+
reflowed += 1;
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
return reflowed;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export function createAgentExcalidrawScene(rawElements) {
|
|
417
|
+
if (!Array.isArray(rawElements) || rawElements.length < 1 || rawElements.length > 200) {
|
|
418
|
+
throw invalid('Excalidraw scene must contain 1 to 200 elements');
|
|
419
|
+
}
|
|
420
|
+
const now = Date.now();
|
|
421
|
+
let elements = rawElements.map((element) => normalizeElement(element, now));
|
|
422
|
+
validateUniqueIds(elements);
|
|
423
|
+
rawElements.forEach((rawElement) => {
|
|
424
|
+
moveElement(
|
|
425
|
+
elements,
|
|
426
|
+
String(rawElement?.id ?? '').trim(),
|
|
427
|
+
rawElement,
|
|
428
|
+
`Element ${rawElement?.id ?? ''} layer placement`,
|
|
429
|
+
);
|
|
430
|
+
});
|
|
431
|
+
elements = normalizeElementOrder(elements, now, new Set(elements.map(({ id }) => id)));
|
|
432
|
+
refreshArrowBindings(elements);
|
|
433
|
+
return {
|
|
434
|
+
appState: {
|
|
435
|
+
gridSize: null,
|
|
436
|
+
viewBackgroundColor: '#ffffff',
|
|
437
|
+
},
|
|
438
|
+
elements,
|
|
439
|
+
files: {},
|
|
440
|
+
source: 'collabmd',
|
|
441
|
+
type: 'excalidraw',
|
|
442
|
+
version: 2,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export function applyAgentExcalidrawEdits(scene, edits = {}) {
|
|
447
|
+
return applyAgentExcalidrawEditsWithSummary(scene, edits).scene;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export function applyAgentExcalidrawEditsWithSummary(scene, edits = {}) {
|
|
451
|
+
requireObject(scene, 'Excalidraw scene');
|
|
452
|
+
if (scene.type !== 'excalidraw' || !Array.isArray(scene.elements)) {
|
|
453
|
+
throw invalid('Document is not a valid Excalidraw scene');
|
|
454
|
+
}
|
|
455
|
+
requireObject(edits, 'Excalidraw edits');
|
|
456
|
+
const create = edits.create ?? [];
|
|
457
|
+
const update = edits.update ?? [];
|
|
458
|
+
const replace = edits.replace ?? [];
|
|
459
|
+
const remove = edits.delete ?? [];
|
|
460
|
+
const reorder = edits.reorder ?? [];
|
|
461
|
+
const translate = edits.translate ?? null;
|
|
462
|
+
const normalizeTextPlacement = edits.normalizeTextPlacement;
|
|
463
|
+
const operations = [create, update, replace, remove, reorder];
|
|
464
|
+
if (!operations.every(Array.isArray)) {
|
|
465
|
+
throw invalid('Excalidraw edit operations must be arrays');
|
|
466
|
+
}
|
|
467
|
+
if (normalizeTextPlacement !== undefined && normalizeTextPlacement !== true) {
|
|
468
|
+
throw invalid('normalizeTextPlacement must be true when provided');
|
|
469
|
+
}
|
|
470
|
+
let translatedIds = [];
|
|
471
|
+
let translateDx = 0;
|
|
472
|
+
let translateDy = 0;
|
|
473
|
+
if (translate !== null) {
|
|
474
|
+
const operation = requireObject(translate, 'Translate operation');
|
|
475
|
+
if (!Array.isArray(operation.ids) || operation.ids.length === 0) {
|
|
476
|
+
throw invalid('Translate operation must include at least one element id');
|
|
477
|
+
}
|
|
478
|
+
translatedIds = operation.ids.map((id) => String(id ?? '').trim());
|
|
479
|
+
if (translatedIds.some((id) => !id) || new Set(translatedIds).size !== translatedIds.length) {
|
|
480
|
+
throw invalid('Translate operation element ids must be non-empty and unique');
|
|
481
|
+
}
|
|
482
|
+
translateDx = requireNumber(operation.dx, 'Translate dx');
|
|
483
|
+
translateDy = requireNumber(operation.dy, 'Translate dy');
|
|
484
|
+
if (translateDx === 0 && translateDy === 0) {
|
|
485
|
+
throw invalid('Translate operation must move elements');
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const normalizationOperationCount = normalizeTextPlacement ? 1 : 0;
|
|
489
|
+
const operationCount = operations.reduce(
|
|
490
|
+
(count, entries) => count + entries.length,
|
|
491
|
+
translatedIds.length + normalizationOperationCount,
|
|
492
|
+
);
|
|
493
|
+
if (operationCount < 1) {
|
|
494
|
+
throw invalid('Excalidraw edits must include at least one operation');
|
|
495
|
+
}
|
|
496
|
+
if (operationCount > 200) {
|
|
497
|
+
throw invalid('Excalidraw edits cannot exceed 200 operations');
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
const now = Date.now();
|
|
501
|
+
let elements = scene.elements.map((element) => ({ ...element }));
|
|
502
|
+
const byId = new Map(elements.map((element) => [element.id, element]));
|
|
503
|
+
const alreadyVersionedIds = new Set();
|
|
504
|
+
const autoReflowIds = new Set();
|
|
505
|
+
const createdElements = create.map((raw) => {
|
|
506
|
+
const element = normalizeElement(raw, now);
|
|
507
|
+
if (byId.has(element.id)) throw invalid(`Excalidraw element already exists: ${element.id}`);
|
|
508
|
+
elements.push(element);
|
|
509
|
+
byId.set(element.id, element);
|
|
510
|
+
alreadyVersionedIds.add(element.id);
|
|
511
|
+
return { element, raw };
|
|
512
|
+
});
|
|
513
|
+
createdElements.forEach(({ element, raw }) => {
|
|
514
|
+
moveElement(elements, element.id, raw, `Element ${element.id} layer placement`);
|
|
515
|
+
});
|
|
516
|
+
update.forEach((operation) => {
|
|
517
|
+
requireObject(operation, 'Update operation');
|
|
518
|
+
const id = String(operation.id ?? '').trim();
|
|
519
|
+
const current = byId.get(id);
|
|
520
|
+
if (!current || current.isDeleted) throw invalid(`Excalidraw element not found: ${id}`);
|
|
521
|
+
const set = requireObject(operation.set, `Update ${id} set`);
|
|
522
|
+
if (
|
|
523
|
+
['id', 'index', 'isDeleted', 'type', 'version', 'versionNonce']
|
|
524
|
+
.some((field) => Object.hasOwn(set, field))
|
|
525
|
+
) {
|
|
526
|
+
throw invalid(`Update ${id} cannot change identity, type, deletion, version, or layer fields`);
|
|
527
|
+
}
|
|
528
|
+
const raw = { ...current, ...set };
|
|
529
|
+
if (current.type === 'text' && Object.hasOwn(set, 'text') && !Object.hasOwn(set, 'originalText')) {
|
|
530
|
+
raw.originalText = String(set.text ?? '');
|
|
531
|
+
}
|
|
532
|
+
const resizesStandaloneText = current.type === 'text'
|
|
533
|
+
&& !raw.containerId
|
|
534
|
+
&& raw.autoResize !== false
|
|
535
|
+
&& [...TEXT_METRIC_FIELDS].some((field) => Object.hasOwn(set, field));
|
|
536
|
+
if (resizesStandaloneText) {
|
|
537
|
+
delete raw.width;
|
|
538
|
+
delete raw.height;
|
|
539
|
+
}
|
|
540
|
+
const next = bumpElementVersion(normalizeElement(raw, now), now, 'update');
|
|
541
|
+
elements[elements.indexOf(current)] = next;
|
|
542
|
+
byId.set(id, next);
|
|
543
|
+
alreadyVersionedIds.add(id);
|
|
544
|
+
const changesTextMetrics = current.type === 'text'
|
|
545
|
+
&& [...TEXT_METRIC_FIELDS].some((field) => Object.hasOwn(set, field));
|
|
546
|
+
const changesTextGeometry = [...TEXT_GEOMETRY_FIELDS].some((field) => Object.hasOwn(set, field));
|
|
547
|
+
if (changesTextMetrics && !changesTextGeometry) {
|
|
548
|
+
autoReflowIds.add(id);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
replace.forEach((operation) => {
|
|
552
|
+
requireObject(operation, 'Replace operation');
|
|
553
|
+
const id = String(operation.id ?? '').trim();
|
|
554
|
+
const current = byId.get(id);
|
|
555
|
+
if (!current || current.isDeleted) throw invalid(`Excalidraw element not found: ${id}`);
|
|
556
|
+
const rawElement = requireObject(operation.element, `Replace ${id} element`);
|
|
557
|
+
if (rawElement.id !== undefined && String(rawElement.id) !== id) {
|
|
558
|
+
throw invalid(`Replace ${id} element id must match the replaced element`);
|
|
559
|
+
}
|
|
560
|
+
const next = bumpElementVersion(normalizeElement({
|
|
561
|
+
...rawElement,
|
|
562
|
+
id,
|
|
563
|
+
index: current.index,
|
|
564
|
+
updated: current.updated,
|
|
565
|
+
version: current.version,
|
|
566
|
+
versionNonce: current.versionNonce,
|
|
567
|
+
}, now), now, 'replace');
|
|
568
|
+
elements[elements.indexOf(current)] = next;
|
|
569
|
+
byId.set(id, next);
|
|
570
|
+
alreadyVersionedIds.add(id);
|
|
571
|
+
});
|
|
572
|
+
if (translatedIds.length > 0) {
|
|
573
|
+
translatedIds = resolveTranslationIds(elements, translatedIds);
|
|
574
|
+
const expandedOperationCount = operations.reduce(
|
|
575
|
+
(count, entries) => count + entries.length,
|
|
576
|
+
translatedIds.length + normalizationOperationCount,
|
|
577
|
+
);
|
|
578
|
+
if (expandedOperationCount > 200) {
|
|
579
|
+
throw invalid('Excalidraw edits cannot exceed 200 operations including related translations');
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
translatedIds.forEach((id) => {
|
|
583
|
+
const current = byId.get(id);
|
|
584
|
+
if (!current || current.isDeleted) throw invalid(`Excalidraw element not found: ${id}`);
|
|
585
|
+
const next = bumpElementVersion({
|
|
586
|
+
...current,
|
|
587
|
+
x: requireNumber(current.x, `Element ${id} x`) + translateDx,
|
|
588
|
+
y: requireNumber(current.y, `Element ${id} y`) + translateDy,
|
|
589
|
+
}, now, 'translate');
|
|
590
|
+
elements[elements.indexOf(current)] = next;
|
|
591
|
+
byId.set(id, next);
|
|
592
|
+
alreadyVersionedIds.add(id);
|
|
593
|
+
});
|
|
594
|
+
remove.forEach((rawId) => {
|
|
595
|
+
const id = String(rawId ?? '').trim();
|
|
596
|
+
const current = byId.get(id);
|
|
597
|
+
if (!current || current.isDeleted) throw invalid(`Excalidraw element not found: ${id}`);
|
|
598
|
+
const deleted = {
|
|
599
|
+
...bumpElementVersion(current, now, 'deleted'),
|
|
600
|
+
isDeleted: true,
|
|
601
|
+
};
|
|
602
|
+
elements[elements.indexOf(current)] = deleted;
|
|
603
|
+
byId.set(id, deleted);
|
|
604
|
+
alreadyVersionedIds.add(id);
|
|
605
|
+
});
|
|
606
|
+
reorder.forEach((operation) => {
|
|
607
|
+
requireObject(operation, 'Reorder operation');
|
|
608
|
+
const id = String(operation.id ?? '').trim();
|
|
609
|
+
moveElement(elements, id, operation, `Reorder ${id}`);
|
|
610
|
+
});
|
|
611
|
+
const reflowIds = normalizeTextPlacement
|
|
612
|
+
? elements
|
|
613
|
+
.filter((element) => element.type === 'text' && !element.isDeleted && element.containerId)
|
|
614
|
+
.map((element) => element.id)
|
|
615
|
+
: [...autoReflowIds];
|
|
616
|
+
const reflowed = reflowBoundText(elements, reflowIds, now, alreadyVersionedIds);
|
|
617
|
+
validateUniqueIds(elements);
|
|
618
|
+
elements = normalizeElementOrder(elements, now, alreadyVersionedIds);
|
|
619
|
+
refreshArrowBindings(elements);
|
|
620
|
+
return {
|
|
621
|
+
reflowed,
|
|
622
|
+
scene: { ...scene, elements },
|
|
623
|
+
};
|
|
624
|
+
}
|