@vc-shell/framework 1.1.46 → 1.1.48
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/CHANGELOG.md +8 -0
- package/core/plugins/modularity/loader.ts +126 -97
- package/dist/assets/042c75b764bc78a7.svg +1 -0
- package/dist/assets/0ba156439a339f2a.svg +1 -0
- package/dist/assets/0be560bfb22d0e72.woff2 +0 -0
- package/dist/assets/0f590f8a94577092.svg +1 -0
- package/dist/assets/0fc5820f8be53a1b.svg +1 -0
- package/dist/assets/10768e2cc79fc60b.svg +1 -0
- package/dist/assets/11b3d25a56fd9a21.woff2 +0 -0
- package/dist/assets/157b8721e0600ea8.svg +1 -0
- package/dist/assets/15e91cdd649cde9a.svg +1 -0
- package/dist/assets/1a3e84b2457f709a.woff +0 -0
- package/dist/assets/1de63eb118636cce.svg +1 -0
- package/dist/assets/1ea01de36eb5491b.svg +1 -0
- package/dist/assets/204eaf512fde2023.svg +1 -0
- package/dist/assets/2088983edf42e153.svg +1 -0
- package/dist/assets/208f810a9321a327.svg +1 -0
- package/dist/assets/21220a9d10e6c558.svg +1 -0
- package/dist/assets/220db345a102045d.woff2 +0 -0
- package/dist/assets/225da11d23968333.svg +1 -0
- package/dist/assets/226f862dd81bdc13.woff2 +0 -0
- package/dist/assets/23a2d53395ddb14f.woff +0 -0
- package/dist/assets/259e6ad461a52ad7.svg +1 -0
- package/dist/assets/261e6dec4d53b9ac.woff +0 -0
- package/dist/assets/262f46a0b6d94bb6.svg +1 -0
- package/dist/assets/2857c513073467da.svg +1 -0
- package/dist/assets/2b3be7889467d98f.woff +0 -0
- package/dist/assets/2d4e6190eec72737.svg +1 -0
- package/dist/assets/2eba973185078bc8.woff +0 -0
- package/dist/assets/327511cd4a7ba7f9.woff +0 -0
- package/dist/assets/334d3f6bc766c516.woff +0 -0
- package/dist/assets/34ff7dd0c2285956.svg +1 -0
- package/dist/assets/3d26b7c1ab78bbe2.woff +0 -0
- package/dist/assets/3f8c4cc8099e34b6.woff2 +0 -0
- package/dist/assets/40a0e53b79ce63c6.woff2 +0 -0
- package/dist/assets/41275bcb979cb650.svg +1 -0
- package/dist/assets/42df4e2d6fa3fd2a.woff2 +0 -0
- package/dist/assets/434f7982590e462f.woff +0 -0
- package/dist/assets/4ae5f23e0ca888e7.woff2 +0 -0
- package/dist/assets/4d7a77b0e5373992.svg +1 -0
- package/dist/assets/4e43c74354534fb3.svg +1 -0
- package/dist/assets/4fe75f5117100705.svg +1 -0
- package/dist/assets/52610491f372cb0c.woff2 +0 -0
- package/dist/assets/52e261a005074e1b.woff +0 -0
- package/dist/assets/5304c3d05a5f9789.woff2 +0 -0
- package/dist/assets/572bb1bb4156a9c1.svg +1 -0
- package/dist/assets/5b3661be8be679d0.woff2 +0 -0
- package/dist/assets/5d96cfcc5bedd917.woff2 +0 -0
- package/dist/assets/6075995d7e74da46.woff2 +0 -0
- package/dist/assets/617c4736236e199e.woff +0 -0
- package/dist/assets/6619e9e10beea0e7.woff2 +0 -0
- package/dist/assets/67230f05dc94a265.svg +1 -0
- package/dist/assets/6798e4dd4add9b48.svg +1 -0
- package/dist/assets/698ec6c722d4cb05.woff2 +0 -0
- package/dist/assets/6a3e73faf406cf33.svg +1 -0
- package/dist/assets/72de3a63bc0b70dd.svg +1 -0
- package/dist/assets/74c6a6ab81bb6340.woff2 +0 -0
- package/dist/assets/74ed5f8a78e71106.svg +1 -0
- package/dist/assets/7ce0c166fd6a1204.woff +0 -0
- package/dist/assets/7d55399c2a7bc985.svg +1 -0
- package/dist/assets/7d970675c69fca1d.woff +0 -0
- package/dist/assets/7eda727273fd98d3.svg +1 -0
- package/dist/assets/7f6ebfd707b76ca2.woff +0 -0
- package/dist/assets/7fa898d213fcc7bc.woff2 +0 -0
- package/dist/assets/861e6b7192b3b6c7.woff +0 -0
- package/dist/assets/8bbcde81ba21ecb2.woff2 +0 -0
- package/dist/assets/8f6657e5e0b8d3e4.woff +0 -0
- package/dist/assets/910b0d99b9e26568.svg +1 -0
- package/dist/assets/91eee1aa81f72683.woff +0 -0
- package/dist/assets/92508f8707159b51.svg +1 -0
- package/dist/assets/9392bf1d591e1abb.svg +1 -0
- package/dist/assets/97e8d4984ba0713a.woff2 +0 -0
- package/dist/assets/9cb83236f6bb7ab1.svg +1 -0
- package/dist/assets/9d37314695c0b68d.woff +0 -0
- package/dist/assets/a18404194e3f9047.svg +1 -0
- package/dist/assets/a2017fe7f0a26510.svg +1 -0
- package/dist/assets/a47034e65dbcc3d7.woff +0 -0
- package/dist/assets/a617e11804bbacb7.woff +0 -0
- package/dist/assets/ab6e7190bb1492d5.woff2 +0 -0
- package/dist/assets/abf88f301a0730f4.svg +1 -0
- package/dist/assets/aed17cb6fdad2ada.woff2 +0 -0
- package/dist/assets/b1a596e31ad1185a.svg +1 -0
- package/dist/assets/b27767411c8427be.woff +0 -0
- package/dist/assets/b291dc35a17511f7.woff +0 -0
- package/dist/assets/b325adcae33bbe7a.svg +1 -0
- package/dist/assets/b372390551ca2fa1.svg +1 -0
- package/dist/assets/b5bb1e8fc975decd.svg +1 -0
- package/dist/assets/b645a4a2181b9dc1.svg +1 -0
- package/dist/assets/b6499ddce0a4ef7d.svg +1 -0
- package/dist/assets/b94421fadd23b0f2.svg +1 -0
- package/dist/assets/bb28fb0f27f1c11b.svg +1 -0
- package/dist/assets/bfbe205759295eca.woff2 +0 -0
- package/dist/assets/ca791c5ca5848a03.svg +1 -0
- package/dist/assets/cb32840ce330103f.woff +0 -0
- package/dist/assets/d084bda16abe8a56.svg +1 -0
- package/dist/assets/d32b129cae2fffd6.svg +1 -0
- package/dist/assets/d35a4c7113315758.woff2 +0 -0
- package/dist/assets/d3f792f54ae4c307.svg +1 -0
- package/dist/assets/d5a5b8630120073d.svg +1 -0
- package/dist/assets/d5f9664ebbfb104b.svg +1 -0
- package/dist/assets/d80b05788e407de7.woff2 +0 -0
- package/dist/assets/d84247b59449dd88.woff2 +0 -0
- package/dist/assets/dd05d43ff0df2fc7.svg +1 -0
- package/dist/assets/e38acaa1757232e0.svg +1 -0
- package/dist/assets/e4a8550f1c7ffe36.svg +1 -0
- package/dist/assets/e5adb5ae3a3698f6.svg +1 -0
- package/dist/assets/e61a1889bac955f4.woff2 +0 -0
- package/dist/assets/e72bb11356af94c7.svg +1 -0
- package/dist/assets/e98196a9f8dcb2f0.svg +1 -0
- package/dist/assets/ebec912a42ad49ff.woff +0 -0
- package/dist/assets/f09d89268e4c0317.svg +1 -0
- package/dist/assets/f276d55184e05a07.woff +0 -0
- package/dist/assets/f5722262b6e7214e.woff2 +0 -0
- package/dist/assets/f7fc8bf46089d8b2.svg +1 -0
- package/dist/assets/fcb1c1ffb5640194.woff +0 -0
- package/dist/assets/fe141d99763f5d2b.woff +0 -0
- package/dist/assets/fed13b0d59903483.svg +1 -0
- package/dist/assets/fed757d2c2344ead.woff2 +0 -0
- package/dist/assets/ffc438f20e79ce73.woff +0 -0
- package/dist/core/plugins/modularity/loader.d.ts.map +1 -1
- package/dist/framework.js +16544 -25878
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts.map +1 -1
- package/dist/vendor-boolbase-Bgn9I6iN.js +21 -0
- package/dist/vendor-cheerio-CleDsuQZ.js +1053 -0
- package/dist/vendor-cheerio-select-CVkYl3Z-.js +191 -0
- package/dist/vendor-css-select-CtIzVIiG.js +622 -0
- package/dist/vendor-css-what-CZZaquJM.js +267 -0
- package/dist/vendor-cypress-signalr-mock-CdKwIhWw.js +769 -0
- package/dist/vendor-date-fns-CdFbeoHV.js +2989 -0
- package/dist/vendor-dom-serializer-CugO0RdN.js +213 -0
- package/dist/vendor-dom7-wvIUV9pT.js +529 -0
- package/dist/vendor-domelementtype-B3sFIGaC.js +21 -0
- package/dist/vendor-domhandler-CL40eeX9.js +311 -0
- package/dist/vendor-dompurify-eYFoHPwR.js +528 -0
- package/dist/vendor-domutils-D3Y2YQFR.js +386 -0
- package/dist/vendor-entities-v26HW8wW.js +363 -0
- package/dist/vendor-floating-ui-core-C9uEvi1M.js +349 -0
- package/dist/vendor-floating-ui-dom-CZkYGmv4.js +393 -0
- package/dist/vendor-floating-ui-utils-Bx3BTd6_.js +259 -0
- package/dist/vendor-floating-ui-vue-CLOiVYP7.js +107 -0
- package/dist/vendor-headlessui-vue-Dg0Llidi.js +961 -0
- package/dist/vendor-htmlparser2-CXL_uhMI.js +735 -0
- package/dist/vendor-iconify-vue-D4fihzvl.js +1205 -0
- package/dist/vendor-intlify-core-base-Bvt2vJFV.js +1129 -0
- package/dist/vendor-intlify-message-compiler-1VxNzq21.js +945 -0
- package/dist/vendor-intlify-shared-D7kiPMOG.js +130 -0
- package/dist/vendor-iso-639-1-dVGfSUIM.js +781 -0
- package/dist/vendor-linkify-it-LzoUhj6C.js +199 -0
- package/dist/vendor-linkifyjs-DTu7SY_Y.js +705 -0
- package/dist/vendor-lodash-es-CrYlgAi8.js +4816 -0
- package/dist/vendor-markdown-it-4AJoRTAg.js +2263 -0
- package/dist/vendor-markdown-it-task-lists-Byg1-ms9.js +69 -0
- package/dist/vendor-mdurl-DZFDNdqC.js +192 -0
- package/dist/vendor-microsoft-applicationinsights-analytics-js-DA-ctcAL.js +1105 -0
- package/dist/vendor-microsoft-applicationinsights-cfgsync-js-COfRj-2q.js +261 -0
- package/dist/vendor-microsoft-applicationinsights-channel-js-MTPYhH-I.js +1809 -0
- package/dist/vendor-microsoft-applicationinsights-common-CDVnJ6MR.js +1921 -0
- package/dist/vendor-microsoft-applicationinsights-core-js-D7Aicf8S.js +4127 -0
- package/dist/vendor-microsoft-applicationinsights-dependencies-js-CvQWWraU.js +1399 -0
- package/dist/vendor-microsoft-applicationinsights-properties-js-C0Iv1cZE.js +572 -0
- package/dist/vendor-microsoft-applicationinsights-shims-CxtPYiwp.js +43 -0
- package/dist/vendor-microsoft-applicationinsights-web-BRuQAzjU.js +487 -0
- package/dist/vendor-microsoft-dynamicproto-js-DSkQkH3T.js +147 -0
- package/dist/vendor-microsoft-signalr-qIrag5xx.js +1761 -0
- package/dist/vendor-moment-CwOqp704.js +2589 -0
- package/dist/vendor-nevware21-ts-async-FAyg3c9V.js +260 -0
- package/dist/vendor-nevware21-ts-utils-Dy41wRhA.js +853 -0
- package/dist/vendor-nth-check-BE7AeBMg.js +45 -0
- package/dist/vendor-orderedmap-B3SOk52B.js +103 -0
- package/dist/vendor-parse5-DqztJOGh.js +5747 -0
- package/dist/vendor-parse5-htmlparser2-tree-adapter-CNubfdOP.js +143 -0
- package/dist/vendor-popperjs-core-LGjf7Wza.js +905 -0
- package/dist/vendor-prettier-D8C9GG-0.js +4858 -0
- package/dist/vendor-prosemirror-commands-BqYcdumy.js +344 -0
- package/dist/vendor-prosemirror-dropcursor-zknUsW5x.js +86 -0
- package/dist/vendor-prosemirror-gapcursor-DjOZhP78.js +200 -0
- package/dist/vendor-prosemirror-history-l8l3CFac.js +248 -0
- package/dist/vendor-prosemirror-keymap-C17r08p-.js +62 -0
- package/dist/vendor-prosemirror-markdown-WJEDhc-w.js +650 -0
- package/dist/vendor-prosemirror-model-BN5TnJD_.js +2736 -0
- package/dist/vendor-prosemirror-schema-list-CR0gi7aY.js +87 -0
- package/dist/vendor-prosemirror-state-B0bFP8WI.js +821 -0
- package/dist/vendor-prosemirror-tables-B1txTKlC.js +1711 -0
- package/dist/vendor-prosemirror-transform-Bo7kNPme.js +1507 -0
- package/dist/vendor-prosemirror-view--C7TZvmQ.js +3746 -0
- package/dist/vendor-punycode-js-CNI-zL6U.js +133 -0
- package/dist/vendor-rope-sequence-sEGCUMi8.js +100 -0
- package/dist/vendor-semver-BoKYtkQw.js +1021 -0
- package/dist/vendor-ssr-window-D4k3p53c.js +133 -0
- package/dist/vendor-swiper-CMVLTGu0.js +2825 -0
- package/dist/vendor-tippy-js-BGdgwGX-.js +812 -0
- package/dist/vendor-tiptap-core-BRY37Sb2.js +2806 -0
- package/dist/vendor-tiptap-extension-blockquote-CPd5qv-9.js +43 -0
- package/dist/vendor-tiptap-extension-bold-B0GwBNks.js +71 -0
- package/dist/vendor-tiptap-extension-bubble-menu-B0sZZld7.js +128 -0
- package/dist/vendor-tiptap-extension-bullet-list-CQm4ReOu.js +53 -0
- package/dist/vendor-tiptap-extension-code-C8cy6bRj.js +51 -0
- package/dist/vendor-tiptap-extension-code-block-BqTchNEf.js +133 -0
- package/dist/vendor-tiptap-extension-document-Dka1Uu0g.js +9 -0
- package/dist/vendor-tiptap-extension-dropcursor-CFSh-BuE.js +20 -0
- package/dist/vendor-tiptap-extension-floating-menu-H8PB4zeI.js +99 -0
- package/dist/vendor-tiptap-extension-gapcursor-CzwfD_IT.js +24 -0
- package/dist/vendor-tiptap-extension-hard-break-Rm6aVcrK.js +55 -0
- package/dist/vendor-tiptap-extension-heading-CavI6u1v.js +54 -0
- package/dist/vendor-tiptap-extension-history-WEN1_74D.js +35 -0
- package/dist/vendor-tiptap-extension-horizontal-rule-DZkUEL6s.js +58 -0
- package/dist/vendor-tiptap-extension-image-B67_mxGM.js +64 -0
- package/dist/vendor-tiptap-extension-italic-BshxBFou.js +70 -0
- package/dist/vendor-tiptap-extension-link-CJAQIgui.js +262 -0
- package/dist/vendor-tiptap-extension-list-item-DF-iMpqO.js +33 -0
- package/dist/vendor-tiptap-extension-ordered-list-CN8MF-kN.js +71 -0
- package/dist/vendor-tiptap-extension-paragraph-DI577lM5.js +33 -0
- package/dist/vendor-tiptap-extension-placeholder-DwAtlfAF.js +52 -0
- package/dist/vendor-tiptap-extension-strike-CIty09KN.js +61 -0
- package/dist/vendor-tiptap-extension-table-C5nv-GUb.js +213 -0
- package/dist/vendor-tiptap-extension-table-cell-DXbBhJW3.js +40 -0
- package/dist/vendor-tiptap-extension-table-header-rtggsYXA.js +40 -0
- package/dist/vendor-tiptap-extension-table-row-67khjMDt.js +22 -0
- package/dist/vendor-tiptap-extension-text-D1OHb_a1.js +8 -0
- package/dist/vendor-tiptap-extension-underline-IqWixw3m.js +40 -0
- package/dist/vendor-tiptap-markdown-DVxB1hbO.js +825 -0
- package/dist/vendor-tiptap-starter-kit-CPH9gu2X.js +29 -0
- package/dist/vendor-tiptap-vue-3-CkBe4_xM.js +225 -0
- package/dist/vendor-truncate-html-Bx1HJzRq.js +145 -0
- package/dist/vendor-uc-micro-4lbSaZOs.js +17 -0
- package/dist/vendor-vee-validate-i18n-zT8NxX3R.js +93 -0
- package/dist/vendor-vee-validate-rules-DDeNM2Gc.js +314 -0
- package/dist/vendor-vue-currency-input-DxWnS-HB.js +315 -0
- package/dist/vendor-vue-devtools-api-aVYGocXp.js +93 -0
- package/dist/vendor-vue-i18n-DPtOLen3.js +1359 -0
- package/dist/vendor-vue3-application-insights-dAGGfA_M.js +69 -0
- package/dist/vendor-vue3-touch-events-8Pa3HHlV.js +169 -0
- package/dist/vendor-vuepic-vue-datepicker-DglsiNYa.js +4997 -0
- package/dist/vendor-vueuse-components-DtK_mxpP.js +219 -0
- package/dist/vendor-vueuse-core-cB-c7DzH.js +5129 -0
- package/dist/vendor-vueuse-shared-Dg7PMM0z.js +1169 -0
- package/dist/vendor-w3c-keyname-CLxH8j-f.js +92 -0
- package/dist/vendor-whatwg-fetch-l0sNRNKZ.js +1 -0
- package/package.json +5 -4
- package/ui/components/atoms/vc-icon/vc-lucide-icon.vue +2 -1
- package/dist/vendor-boolbase-Cp9L0GAZ.js +0 -25
- package/dist/vendor-cheerio-HN9zIPZn.js +0 -3135
- package/dist/vendor-cheerio-select-5Ry0HvBq.js +0 -306
- package/dist/vendor-css-select-DRIZ9kfZ.js +0 -966
- package/dist/vendor-css-what-DuPJ1HEF.js +0 -448
- package/dist/vendor-cypress-signalr-mock-BKdBJpdt.js +0 -778
- package/dist/vendor-date-fns-515YWkk-.js +0 -6724
- package/dist/vendor-dom-serializer-nQMsqjYW.js +0 -286
- package/dist/vendor-dom7-CJLPMwy5.js +0 -941
- package/dist/vendor-domelementtype-CjSzQey5.js +0 -53
- package/dist/vendor-domhandler-9z8cS16a.js +0 -484
- package/dist/vendor-dompurify-CRFzu7ib.js +0 -1336
- package/dist/vendor-domutils-Bc-Opz-v.js +0 -981
- package/dist/vendor-entities-Bfsx4xOQ.js +0 -636
- package/dist/vendor-floating-ui-core-wV8u8QP4.js +0 -511
- package/dist/vendor-floating-ui-dom-DDnRPs17.js +0 -706
- package/dist/vendor-floating-ui-utils-OMIFy1QU.js +0 -296
- package/dist/vendor-floating-ui-vue-D-tCDAMm.js +0 -167
- package/dist/vendor-fontsource-plus-jakarta-sans.css +0 -1
- package/dist/vendor-headlessui-vue-CY9FRgTb.js +0 -83
- package/dist/vendor-htmlparser2-B1dhFPOs.js +0 -1426
- package/dist/vendor-iconify-vue-DfRGgyNu.js +0 -1840
- package/dist/vendor-intlify-core-base-BuknsFQe.js +0 -1876
- package/dist/vendor-intlify-message-compiler-CuOQDWx1.js +0 -1508
- package/dist/vendor-intlify-shared-Cz4YRMuC.js +0 -241
- package/dist/vendor-iso-639-1-BJCk9DvE.js +0 -819
- package/dist/vendor-linkify-it-CKUf4vsc.js +0 -830
- package/dist/vendor-linkifyjs-BfyGgbCh.js +0 -1756
- package/dist/vendor-lodash-es-BySUOlwf.js +0 -18333
- package/dist/vendor-markdown-it-D-apazHa.js +0 -6000
- package/dist/vendor-markdown-it-task-lists-rxMVH6Ku.js +0 -131
- package/dist/vendor-mdurl-BNh2CCgT.js +0 -537
- package/dist/vendor-microsoft-applicationinsights-analytics-js-kG3lLg8X.js +0 -1275
- package/dist/vendor-microsoft-applicationinsights-cfgsync-js-C0uQkiQq.js +0 -591
- package/dist/vendor-microsoft-applicationinsights-channel-js-Dyd_PXA3.js +0 -2153
- package/dist/vendor-microsoft-applicationinsights-common-CfmP1_Qr.js +0 -2470
- package/dist/vendor-microsoft-applicationinsights-core-js-Cq4YSEvZ.js +0 -6589
- package/dist/vendor-microsoft-applicationinsights-dependencies-js-C56OBFr4.js +0 -1510
- package/dist/vendor-microsoft-applicationinsights-properties-js-CBJTBawx.js +0 -761
- package/dist/vendor-microsoft-applicationinsights-shims-CX8sJgar.js +0 -70
- package/dist/vendor-microsoft-applicationinsights-web-pim2ri-g.js +0 -667
- package/dist/vendor-microsoft-dynamicproto-js-CFBBUu9p.js +0 -520
- package/dist/vendor-microsoft-signalr-dUnlRsGm.js +0 -3339
- package/dist/vendor-moment-Mki5YqAR.js +0 -5679
- package/dist/vendor-nevware21-ts-async-CLMApQ9E.js +0 -395
- package/dist/vendor-nevware21-ts-utils-e8v8Jty3.js +0 -1160
- package/dist/vendor-nth-check-Bx8TxtJt.js +0 -157
- package/dist/vendor-orderedmap-dGG6uMFJ.js +0 -137
- package/dist/vendor-parse5-Bt2NhSzR.js +0 -8432
- package/dist/vendor-parse5-htmlparser2-tree-adapter-BUUtKzf8.js +0 -216
- package/dist/vendor-popperjs-core-Cr2byIky.js +0 -1790
- package/dist/vendor-prettier-B4PaeWRQ.js +0 -98
- package/dist/vendor-prosemirror-commands-BH9lWGpW.js +0 -561
- package/dist/vendor-prosemirror-dropcursor-CeyPcxrA.js +0 -146
- package/dist/vendor-prosemirror-gapcursor-U8UoUJII.js +0 -236
- package/dist/vendor-prosemirror-history-BDaJkvNx.js +0 -414
- package/dist/vendor-prosemirror-keymap-BbWvIWmH.js +0 -128
- package/dist/vendor-prosemirror-markdown-gB0PXBbz.js +0 -866
- package/dist/vendor-prosemirror-model-BZu3WVcD.js +0 -3463
- package/dist/vendor-prosemirror-schema-list-Bl9NpKA7.js +0 -158
- package/dist/vendor-prosemirror-state-BvL9Pxph.js +0 -1003
- package/dist/vendor-prosemirror-tables-17qAnviK.js +0 -2159
- package/dist/vendor-prosemirror-transform-CE9VV3qg.js +0 -2156
- package/dist/vendor-prosemirror-view-CU2WTHT7.js +0 -5811
- package/dist/vendor-punycode-js-iAs5RxMf.js +0 -441
- package/dist/vendor-rope-sequence-BdXDKoGt.js +0 -207
- package/dist/vendor-semver-CVLMK-S4.js +0 -2702
- package/dist/vendor-ssr-window-s6OpKa3O.js +0 -150
- package/dist/vendor-swiper-CdiyNHVt.js +0 -5679
- package/dist/vendor-tippy-js-DWFe2TfK.js +0 -1647
- package/dist/vendor-tiptap-core-NfwGfaQk.js +0 -4910
- package/dist/vendor-tiptap-extension-blockquote-jmWBTtsI.js +0 -57
- package/dist/vendor-tiptap-extension-bold-p5frh4ak.js +0 -97
- package/dist/vendor-tiptap-extension-bubble-menu-KUhZSfrs.js +0 -218
- package/dist/vendor-tiptap-extension-bullet-list-COmZRoSB.js +0 -73
- package/dist/vendor-tiptap-extension-code-block-DyTARZss.js +0 -221
- package/dist/vendor-tiptap-extension-code-jVv6CXpX.js +0 -75
- package/dist/vendor-tiptap-extension-document-DssuotYs.js +0 -13
- package/dist/vendor-tiptap-extension-dropcursor-BoO0Qv91.js +0 -26
- package/dist/vendor-tiptap-extension-floating-menu-CrO8CN5w.js +0 -165
- package/dist/vendor-tiptap-extension-gapcursor-KpsWEoMD.js +0 -30
- package/dist/vendor-tiptap-extension-hard-break-ldOzhSvf.js +0 -68
- package/dist/vendor-tiptap-extension-heading-CKz2llX0.js +0 -77
- package/dist/vendor-tiptap-extension-history-DeKZ2VQ9.js +0 -48
- package/dist/vendor-tiptap-extension-horizontal-rule-CAjWRyDS.js +0 -92
- package/dist/vendor-tiptap-extension-image-ZagcEYuk.js +0 -76
- package/dist/vendor-tiptap-extension-italic-CM4xdznY.js +0 -96
- package/dist/vendor-tiptap-extension-link-Z-AMC4Ri.js +0 -414
- package/dist/vendor-tiptap-extension-list-item-BJi5QpXc.js +0 -37
- package/dist/vendor-tiptap-extension-ordered-list-C_TMrfBE.js +0 -97
- package/dist/vendor-tiptap-extension-paragraph-CQw0E0Au.js +0 -39
- package/dist/vendor-tiptap-extension-placeholder-BBNVKfa_.js +0 -66
- package/dist/vendor-tiptap-extension-strike-DUyMYX1Z.js +0 -79
- package/dist/vendor-tiptap-extension-table-cell-CoDIMPA5.js +0 -47
- package/dist/vendor-tiptap-extension-table-header-DvbGHnmw.js +0 -47
- package/dist/vendor-tiptap-extension-table-row-D1uqN5Aj.js +0 -26
- package/dist/vendor-tiptap-extension-table-tKS4MOM4.js +0 -354
- package/dist/vendor-tiptap-extension-text-DtRBhKB2.js +0 -12
- package/dist/vendor-tiptap-extension-underline-DqaSFp_P.js +0 -50
- package/dist/vendor-tiptap-markdown-7-PCADTU.js +0 -1017
- package/dist/vendor-tiptap-starter-kit-CDSV_Zuu.js +0 -88
- package/dist/vendor-tiptap-vue-3-DZg2fjq_.js +0 -268
- package/dist/vendor-truncate-html-3qQY0Djo.js +0 -196
- package/dist/vendor-uc-micro-jjt6LQ65.js +0 -23
- package/dist/vendor-vee-validate-i18n-v_gHjRmD.js +0 -154
- package/dist/vendor-vee-validate-rules-DzV3VY3N.js +0 -536
- package/dist/vendor-vue-currency-input-DGAkEFBO.js +0 -545
- package/dist/vendor-vue-devtools-api-DXYR8qBG.js +0 -169
- package/dist/vendor-vue-i18n-Co752uk3.js +0 -1897
- package/dist/vendor-vue3-application-insights-CYWFCr_J.js +0 -119
- package/dist/vendor-vue3-touch-events-BJEAiSa3.js +0 -416
- package/dist/vendor-vuepic-vue-datepicker-BSWXRSiu.js +0 -5019
- package/dist/vendor-vueuse-components-l1bL12mE.js +0 -339
- package/dist/vendor-vueuse-core-DGcJOmwG.js +0 -7743
- package/dist/vendor-vueuse-shared-_mOXsFuM.js +0 -1568
- package/dist/vendor-w3c-keyname-BOm2dtJm.js +0 -121
|
@@ -1,2159 +0,0 @@
|
|
|
1
|
-
import { P as Plugin, a as PluginKey, S as Selection, b as SelectionRange, T as TextSelection, N as NodeSelection } from './vendor-prosemirror-state-BvL9Pxph.js';
|
|
2
|
-
import { F as Fragment, S as Slice } from './vendor-prosemirror-model-BZu3WVcD.js';
|
|
3
|
-
import { D as DecorationSet, a as Decoration } from './vendor-prosemirror-view-CU2WTHT7.js';
|
|
4
|
-
import { k as keydownHandler } from './vendor-prosemirror-keymap-BbWvIWmH.js';
|
|
5
|
-
import { T as Transform } from './vendor-prosemirror-transform-CE9VV3qg.js';
|
|
6
|
-
|
|
7
|
-
// src/index.ts
|
|
8
|
-
|
|
9
|
-
// src/tablemap.ts
|
|
10
|
-
var readFromCache;
|
|
11
|
-
var addToCache;
|
|
12
|
-
if (typeof WeakMap != "undefined") {
|
|
13
|
-
let cache = /* @__PURE__ */ new WeakMap();
|
|
14
|
-
readFromCache = (key) => cache.get(key);
|
|
15
|
-
addToCache = (key, value) => {
|
|
16
|
-
cache.set(key, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
} else {
|
|
20
|
-
const cache = [];
|
|
21
|
-
const cacheSize = 10;
|
|
22
|
-
let cachePos = 0;
|
|
23
|
-
readFromCache = (key) => {
|
|
24
|
-
for (let i = 0; i < cache.length; i += 2)
|
|
25
|
-
if (cache[i] == key) return cache[i + 1];
|
|
26
|
-
};
|
|
27
|
-
addToCache = (key, value) => {
|
|
28
|
-
if (cachePos == cacheSize) cachePos = 0;
|
|
29
|
-
cache[cachePos++] = key;
|
|
30
|
-
return cache[cachePos++] = value;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
var TableMap = class {
|
|
34
|
-
constructor(width, height, map, problems) {
|
|
35
|
-
this.width = width;
|
|
36
|
-
this.height = height;
|
|
37
|
-
this.map = map;
|
|
38
|
-
this.problems = problems;
|
|
39
|
-
}
|
|
40
|
-
// Find the dimensions of the cell at the given position.
|
|
41
|
-
findCell(pos) {
|
|
42
|
-
for (let i = 0; i < this.map.length; i++) {
|
|
43
|
-
const curPos = this.map[i];
|
|
44
|
-
if (curPos != pos) continue;
|
|
45
|
-
const left = i % this.width;
|
|
46
|
-
const top = i / this.width | 0;
|
|
47
|
-
let right = left + 1;
|
|
48
|
-
let bottom = top + 1;
|
|
49
|
-
for (let j = 1; right < this.width && this.map[i + j] == curPos; j++) {
|
|
50
|
-
right++;
|
|
51
|
-
}
|
|
52
|
-
for (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) {
|
|
53
|
-
bottom++;
|
|
54
|
-
}
|
|
55
|
-
return { left, top, right, bottom };
|
|
56
|
-
}
|
|
57
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
58
|
-
}
|
|
59
|
-
// Find the left side of the cell at the given position.
|
|
60
|
-
colCount(pos) {
|
|
61
|
-
for (let i = 0; i < this.map.length; i++) {
|
|
62
|
-
if (this.map[i] == pos) {
|
|
63
|
-
return i % this.width;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
67
|
-
}
|
|
68
|
-
// Find the next cell in the given direction, starting from the cell
|
|
69
|
-
// at `pos`, if any.
|
|
70
|
-
nextCell(pos, axis, dir) {
|
|
71
|
-
const { left, right, top, bottom } = this.findCell(pos);
|
|
72
|
-
if (axis == "horiz") {
|
|
73
|
-
if (dir < 0 ? left == 0 : right == this.width) return null;
|
|
74
|
-
return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
|
|
75
|
-
} else {
|
|
76
|
-
if (dir < 0 ? top == 0 : bottom == this.height) return null;
|
|
77
|
-
return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Get the rectangle spanning the two given cells.
|
|
81
|
-
rectBetween(a, b) {
|
|
82
|
-
const {
|
|
83
|
-
left: leftA,
|
|
84
|
-
right: rightA,
|
|
85
|
-
top: topA,
|
|
86
|
-
bottom: bottomA
|
|
87
|
-
} = this.findCell(a);
|
|
88
|
-
const {
|
|
89
|
-
left: leftB,
|
|
90
|
-
right: rightB,
|
|
91
|
-
top: topB,
|
|
92
|
-
bottom: bottomB
|
|
93
|
-
} = this.findCell(b);
|
|
94
|
-
return {
|
|
95
|
-
left: Math.min(leftA, leftB),
|
|
96
|
-
top: Math.min(topA, topB),
|
|
97
|
-
right: Math.max(rightA, rightB),
|
|
98
|
-
bottom: Math.max(bottomA, bottomB)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
// Return the position of all cells that have the top left corner in
|
|
102
|
-
// the given rectangle.
|
|
103
|
-
cellsInRect(rect) {
|
|
104
|
-
const result = [];
|
|
105
|
-
const seen = {};
|
|
106
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
107
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
108
|
-
const index = row * this.width + col;
|
|
109
|
-
const pos = this.map[index];
|
|
110
|
-
if (seen[pos]) continue;
|
|
111
|
-
seen[pos] = true;
|
|
112
|
-
if (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
result.push(pos);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
// Return the position at which the cell at the given row and column
|
|
121
|
-
// starts, or would start, if a cell started there.
|
|
122
|
-
positionAt(row, col, table) {
|
|
123
|
-
for (let i = 0, rowStart = 0; ; i++) {
|
|
124
|
-
const rowEnd = rowStart + table.child(i).nodeSize;
|
|
125
|
-
if (i == row) {
|
|
126
|
-
let index = col + row * this.width;
|
|
127
|
-
const rowEndIndex = (row + 1) * this.width;
|
|
128
|
-
while (index < rowEndIndex && this.map[index] < rowStart) index++;
|
|
129
|
-
return index == rowEndIndex ? rowEnd - 1 : this.map[index];
|
|
130
|
-
}
|
|
131
|
-
rowStart = rowEnd;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Find the table map for the given table node.
|
|
135
|
-
static get(table) {
|
|
136
|
-
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
function computeMap(table) {
|
|
140
|
-
if (table.type.spec.tableRole != "table")
|
|
141
|
-
throw new RangeError("Not a table node: " + table.type.name);
|
|
142
|
-
const width = findWidth(table), height = table.childCount;
|
|
143
|
-
const map = [];
|
|
144
|
-
let mapPos = 0;
|
|
145
|
-
let problems = null;
|
|
146
|
-
const colWidths = [];
|
|
147
|
-
for (let i = 0, e = width * height; i < e; i++) map[i] = 0;
|
|
148
|
-
for (let row = 0, pos = 0; row < height; row++) {
|
|
149
|
-
const rowNode = table.child(row);
|
|
150
|
-
pos++;
|
|
151
|
-
for (let i = 0; ; i++) {
|
|
152
|
-
while (mapPos < map.length && map[mapPos] != 0) mapPos++;
|
|
153
|
-
if (i == rowNode.childCount) break;
|
|
154
|
-
const cellNode = rowNode.child(i);
|
|
155
|
-
const { colspan, rowspan, colwidth } = cellNode.attrs;
|
|
156
|
-
for (let h = 0; h < rowspan; h++) {
|
|
157
|
-
if (h + row >= height) {
|
|
158
|
-
(problems || (problems = [])).push({
|
|
159
|
-
type: "overlong_rowspan",
|
|
160
|
-
pos,
|
|
161
|
-
n: rowspan - h
|
|
162
|
-
});
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
const start = mapPos + h * width;
|
|
166
|
-
for (let w = 0; w < colspan; w++) {
|
|
167
|
-
if (map[start + w] == 0) map[start + w] = pos;
|
|
168
|
-
else
|
|
169
|
-
(problems || (problems = [])).push({
|
|
170
|
-
type: "collision",
|
|
171
|
-
row,
|
|
172
|
-
pos,
|
|
173
|
-
n: colspan - w
|
|
174
|
-
});
|
|
175
|
-
const colW = colwidth && colwidth[w];
|
|
176
|
-
if (colW) {
|
|
177
|
-
const widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];
|
|
178
|
-
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
179
|
-
colWidths[widthIndex] = colW;
|
|
180
|
-
colWidths[widthIndex + 1] = 1;
|
|
181
|
-
} else if (prev == colW) {
|
|
182
|
-
colWidths[widthIndex + 1]++;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
mapPos += colspan;
|
|
188
|
-
pos += cellNode.nodeSize;
|
|
189
|
-
}
|
|
190
|
-
const expectedPos = (row + 1) * width;
|
|
191
|
-
let missing = 0;
|
|
192
|
-
while (mapPos < expectedPos) if (map[mapPos++] == 0) missing++;
|
|
193
|
-
if (missing)
|
|
194
|
-
(problems || (problems = [])).push({ type: "missing", row, n: missing });
|
|
195
|
-
pos++;
|
|
196
|
-
}
|
|
197
|
-
if (width === 0 || height === 0)
|
|
198
|
-
(problems || (problems = [])).push({ type: "zero_sized" });
|
|
199
|
-
const tableMap = new TableMap(width, height, map, problems);
|
|
200
|
-
let badWidths = false;
|
|
201
|
-
for (let i = 0; !badWidths && i < colWidths.length; i += 2)
|
|
202
|
-
if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
203
|
-
if (badWidths) findBadColWidths(tableMap, colWidths, table);
|
|
204
|
-
return tableMap;
|
|
205
|
-
}
|
|
206
|
-
function findWidth(table) {
|
|
207
|
-
let width = -1;
|
|
208
|
-
let hasRowSpan = false;
|
|
209
|
-
for (let row = 0; row < table.childCount; row++) {
|
|
210
|
-
const rowNode = table.child(row);
|
|
211
|
-
let rowWidth = 0;
|
|
212
|
-
if (hasRowSpan)
|
|
213
|
-
for (let j = 0; j < row; j++) {
|
|
214
|
-
const prevRow = table.child(j);
|
|
215
|
-
for (let i = 0; i < prevRow.childCount; i++) {
|
|
216
|
-
const cell = prevRow.child(i);
|
|
217
|
-
if (j + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
for (let i = 0; i < rowNode.childCount; i++) {
|
|
221
|
-
const cell = rowNode.child(i);
|
|
222
|
-
rowWidth += cell.attrs.colspan;
|
|
223
|
-
if (cell.attrs.rowspan > 1) hasRowSpan = true;
|
|
224
|
-
}
|
|
225
|
-
if (width == -1) width = rowWidth;
|
|
226
|
-
else if (width != rowWidth) width = Math.max(width, rowWidth);
|
|
227
|
-
}
|
|
228
|
-
return width;
|
|
229
|
-
}
|
|
230
|
-
function findBadColWidths(map, colWidths, table) {
|
|
231
|
-
if (!map.problems) map.problems = [];
|
|
232
|
-
const seen = {};
|
|
233
|
-
for (let i = 0; i < map.map.length; i++) {
|
|
234
|
-
const pos = map.map[i];
|
|
235
|
-
if (seen[pos]) continue;
|
|
236
|
-
seen[pos] = true;
|
|
237
|
-
const node = table.nodeAt(pos);
|
|
238
|
-
if (!node) {
|
|
239
|
-
throw new RangeError(`No cell with offset ${pos} found`);
|
|
240
|
-
}
|
|
241
|
-
let updated = null;
|
|
242
|
-
const attrs = node.attrs;
|
|
243
|
-
for (let j = 0; j < attrs.colspan; j++) {
|
|
244
|
-
const col = (i + j) % map.width;
|
|
245
|
-
const colWidth = colWidths[col * 2];
|
|
246
|
-
if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth))
|
|
247
|
-
(updated || (updated = freshColWidth(attrs)))[j] = colWidth;
|
|
248
|
-
}
|
|
249
|
-
if (updated)
|
|
250
|
-
map.problems.unshift({
|
|
251
|
-
type: "colwidth mismatch",
|
|
252
|
-
pos,
|
|
253
|
-
colwidth: updated
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function freshColWidth(attrs) {
|
|
258
|
-
if (attrs.colwidth) return attrs.colwidth.slice();
|
|
259
|
-
const result = [];
|
|
260
|
-
for (let i = 0; i < attrs.colspan; i++) result.push(0);
|
|
261
|
-
return result;
|
|
262
|
-
}
|
|
263
|
-
function tableNodeTypes(schema) {
|
|
264
|
-
let result = schema.cached.tableNodeTypes;
|
|
265
|
-
if (!result) {
|
|
266
|
-
result = schema.cached.tableNodeTypes = {};
|
|
267
|
-
for (const name in schema.nodes) {
|
|
268
|
-
const type = schema.nodes[name], role = type.spec.tableRole;
|
|
269
|
-
if (role) result[role] = type;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return result;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// src/util.ts
|
|
276
|
-
var tableEditingKey = new PluginKey("selectingCells");
|
|
277
|
-
function cellAround($pos) {
|
|
278
|
-
for (let d = $pos.depth - 1; d > 0; d--)
|
|
279
|
-
if ($pos.node(d).type.spec.tableRole == "row")
|
|
280
|
-
return $pos.node(0).resolve($pos.before(d + 1));
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
function cellWrapping($pos) {
|
|
284
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
285
|
-
const role = $pos.node(d).type.spec.tableRole;
|
|
286
|
-
if (role === "cell" || role === "header_cell") return $pos.node(d);
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
function isInTable(state) {
|
|
291
|
-
const $head = state.selection.$head;
|
|
292
|
-
for (let d = $head.depth; d > 0; d--)
|
|
293
|
-
if ($head.node(d).type.spec.tableRole == "row") return true;
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
function selectionCell(state) {
|
|
297
|
-
const sel = state.selection;
|
|
298
|
-
if ("$anchorCell" in sel && sel.$anchorCell) {
|
|
299
|
-
return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
300
|
-
} else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") {
|
|
301
|
-
return sel.$anchor;
|
|
302
|
-
}
|
|
303
|
-
const $cell = cellAround(sel.$head) || cellNear(sel.$head);
|
|
304
|
-
if ($cell) {
|
|
305
|
-
return $cell;
|
|
306
|
-
}
|
|
307
|
-
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
308
|
-
}
|
|
309
|
-
function cellNear($pos) {
|
|
310
|
-
for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
|
|
311
|
-
const role = after.type.spec.tableRole;
|
|
312
|
-
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos);
|
|
313
|
-
}
|
|
314
|
-
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
315
|
-
const role = before.type.spec.tableRole;
|
|
316
|
-
if (role == "cell" || role == "header_cell")
|
|
317
|
-
return $pos.doc.resolve(pos - before.nodeSize);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function pointsAtCell($pos) {
|
|
321
|
-
return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
|
|
322
|
-
}
|
|
323
|
-
function moveCellForward($pos) {
|
|
324
|
-
return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);
|
|
325
|
-
}
|
|
326
|
-
function inSameTable($cellA, $cellB) {
|
|
327
|
-
return $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);
|
|
328
|
-
}
|
|
329
|
-
function nextCell($pos, axis, dir) {
|
|
330
|
-
const table = $pos.node(-1);
|
|
331
|
-
const map = TableMap.get(table);
|
|
332
|
-
const tableStart = $pos.start(-1);
|
|
333
|
-
const moved = map.nextCell($pos.pos - tableStart, axis, dir);
|
|
334
|
-
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
335
|
-
}
|
|
336
|
-
function removeColSpan(attrs, pos, n = 1) {
|
|
337
|
-
const result = { ...attrs, colspan: attrs.colspan - n };
|
|
338
|
-
if (result.colwidth) {
|
|
339
|
-
result.colwidth = result.colwidth.slice();
|
|
340
|
-
result.colwidth.splice(pos, n);
|
|
341
|
-
if (!result.colwidth.some((w) => w > 0)) result.colwidth = null;
|
|
342
|
-
}
|
|
343
|
-
return result;
|
|
344
|
-
}
|
|
345
|
-
function addColSpan(attrs, pos, n = 1) {
|
|
346
|
-
const result = { ...attrs, colspan: attrs.colspan + n };
|
|
347
|
-
if (result.colwidth) {
|
|
348
|
-
result.colwidth = result.colwidth.slice();
|
|
349
|
-
for (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);
|
|
350
|
-
}
|
|
351
|
-
return result;
|
|
352
|
-
}
|
|
353
|
-
function columnIsHeader(map, table, col) {
|
|
354
|
-
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
355
|
-
for (let row = 0; row < map.height; row++)
|
|
356
|
-
if (table.nodeAt(map.map[col + row * map.width]).type != headerCell)
|
|
357
|
-
return false;
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// src/cellselection.ts
|
|
362
|
-
var CellSelection = class _CellSelection extends Selection {
|
|
363
|
-
// A table selection is identified by its anchor and head cells. The
|
|
364
|
-
// positions given to this constructor should point _before_ two
|
|
365
|
-
// cells in the same table. They may be the same, to select a single
|
|
366
|
-
// cell.
|
|
367
|
-
constructor($anchorCell, $headCell = $anchorCell) {
|
|
368
|
-
const table = $anchorCell.node(-1);
|
|
369
|
-
const map = TableMap.get(table);
|
|
370
|
-
const tableStart = $anchorCell.start(-1);
|
|
371
|
-
const rect = map.rectBetween(
|
|
372
|
-
$anchorCell.pos - tableStart,
|
|
373
|
-
$headCell.pos - tableStart
|
|
374
|
-
);
|
|
375
|
-
const doc = $anchorCell.node(0);
|
|
376
|
-
const cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);
|
|
377
|
-
cells.unshift($headCell.pos - tableStart);
|
|
378
|
-
const ranges = cells.map((pos) => {
|
|
379
|
-
const cell = table.nodeAt(pos);
|
|
380
|
-
if (!cell) {
|
|
381
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
382
|
-
}
|
|
383
|
-
const from = tableStart + pos + 1;
|
|
384
|
-
return new SelectionRange(
|
|
385
|
-
doc.resolve(from),
|
|
386
|
-
doc.resolve(from + cell.content.size)
|
|
387
|
-
);
|
|
388
|
-
});
|
|
389
|
-
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
390
|
-
this.$anchorCell = $anchorCell;
|
|
391
|
-
this.$headCell = $headCell;
|
|
392
|
-
}
|
|
393
|
-
map(doc, mapping) {
|
|
394
|
-
const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
395
|
-
const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
|
|
396
|
-
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
397
|
-
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
398
|
-
if (tableChanged && this.isRowSelection())
|
|
399
|
-
return _CellSelection.rowSelection($anchorCell, $headCell);
|
|
400
|
-
else if (tableChanged && this.isColSelection())
|
|
401
|
-
return _CellSelection.colSelection($anchorCell, $headCell);
|
|
402
|
-
else return new _CellSelection($anchorCell, $headCell);
|
|
403
|
-
}
|
|
404
|
-
return TextSelection.between($anchorCell, $headCell);
|
|
405
|
-
}
|
|
406
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
407
|
-
// cells.
|
|
408
|
-
content() {
|
|
409
|
-
const table = this.$anchorCell.node(-1);
|
|
410
|
-
const map = TableMap.get(table);
|
|
411
|
-
const tableStart = this.$anchorCell.start(-1);
|
|
412
|
-
const rect = map.rectBetween(
|
|
413
|
-
this.$anchorCell.pos - tableStart,
|
|
414
|
-
this.$headCell.pos - tableStart
|
|
415
|
-
);
|
|
416
|
-
const seen = {};
|
|
417
|
-
const rows = [];
|
|
418
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
419
|
-
const rowContent = [];
|
|
420
|
-
for (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
|
|
421
|
-
const pos = map.map[index];
|
|
422
|
-
if (seen[pos]) continue;
|
|
423
|
-
seen[pos] = true;
|
|
424
|
-
const cellRect = map.findCell(pos);
|
|
425
|
-
let cell = table.nodeAt(pos);
|
|
426
|
-
if (!cell) {
|
|
427
|
-
throw RangeError(`No cell with offset ${pos} found`);
|
|
428
|
-
}
|
|
429
|
-
const extraLeft = rect.left - cellRect.left;
|
|
430
|
-
const extraRight = cellRect.right - rect.right;
|
|
431
|
-
if (extraLeft > 0 || extraRight > 0) {
|
|
432
|
-
let attrs = cell.attrs;
|
|
433
|
-
if (extraLeft > 0) {
|
|
434
|
-
attrs = removeColSpan(attrs, 0, extraLeft);
|
|
435
|
-
}
|
|
436
|
-
if (extraRight > 0) {
|
|
437
|
-
attrs = removeColSpan(
|
|
438
|
-
attrs,
|
|
439
|
-
attrs.colspan - extraRight,
|
|
440
|
-
extraRight
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
if (cellRect.left < rect.left) {
|
|
444
|
-
cell = cell.type.createAndFill(attrs);
|
|
445
|
-
if (!cell) {
|
|
446
|
-
throw RangeError(
|
|
447
|
-
`Could not create cell with attrs ${JSON.stringify(attrs)}`
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
} else {
|
|
451
|
-
cell = cell.type.create(attrs, cell.content);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
455
|
-
const attrs = {
|
|
456
|
-
...cell.attrs,
|
|
457
|
-
rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
|
|
458
|
-
};
|
|
459
|
-
if (cellRect.top < rect.top) {
|
|
460
|
-
cell = cell.type.createAndFill(attrs);
|
|
461
|
-
} else {
|
|
462
|
-
cell = cell.type.create(attrs, cell.content);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
rowContent.push(cell);
|
|
466
|
-
}
|
|
467
|
-
rows.push(table.child(row).copy(Fragment.from(rowContent)));
|
|
468
|
-
}
|
|
469
|
-
const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
|
|
470
|
-
return new Slice(Fragment.from(fragment), 1, 1);
|
|
471
|
-
}
|
|
472
|
-
replace(tr, content = Slice.empty) {
|
|
473
|
-
const mapFrom = tr.steps.length, ranges = this.ranges;
|
|
474
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
475
|
-
const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
|
|
476
|
-
tr.replace(
|
|
477
|
-
mapping.map($from.pos),
|
|
478
|
-
mapping.map($to.pos),
|
|
479
|
-
i ? Slice.empty : content
|
|
480
|
-
);
|
|
481
|
-
}
|
|
482
|
-
const sel = Selection.findFrom(
|
|
483
|
-
tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)),
|
|
484
|
-
-1
|
|
485
|
-
);
|
|
486
|
-
if (sel) tr.setSelection(sel);
|
|
487
|
-
}
|
|
488
|
-
replaceWith(tr, node) {
|
|
489
|
-
this.replace(tr, new Slice(Fragment.from(node), 0, 0));
|
|
490
|
-
}
|
|
491
|
-
forEachCell(f) {
|
|
492
|
-
const table = this.$anchorCell.node(-1);
|
|
493
|
-
const map = TableMap.get(table);
|
|
494
|
-
const tableStart = this.$anchorCell.start(-1);
|
|
495
|
-
const cells = map.cellsInRect(
|
|
496
|
-
map.rectBetween(
|
|
497
|
-
this.$anchorCell.pos - tableStart,
|
|
498
|
-
this.$headCell.pos - tableStart
|
|
499
|
-
)
|
|
500
|
-
);
|
|
501
|
-
for (let i = 0; i < cells.length; i++) {
|
|
502
|
-
f(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
// True if this selection goes all the way from the top to the
|
|
506
|
-
// bottom of the table.
|
|
507
|
-
isColSelection() {
|
|
508
|
-
const anchorTop = this.$anchorCell.index(-1);
|
|
509
|
-
const headTop = this.$headCell.index(-1);
|
|
510
|
-
if (Math.min(anchorTop, headTop) > 0) return false;
|
|
511
|
-
const anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
512
|
-
const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
513
|
-
return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
|
|
514
|
-
}
|
|
515
|
-
// Returns the smallest column selection that covers the given anchor
|
|
516
|
-
// and head cell.
|
|
517
|
-
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
518
|
-
const table = $anchorCell.node(-1);
|
|
519
|
-
const map = TableMap.get(table);
|
|
520
|
-
const tableStart = $anchorCell.start(-1);
|
|
521
|
-
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
522
|
-
const headRect = map.findCell($headCell.pos - tableStart);
|
|
523
|
-
const doc = $anchorCell.node(0);
|
|
524
|
-
if (anchorRect.top <= headRect.top) {
|
|
525
|
-
if (anchorRect.top > 0)
|
|
526
|
-
$anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);
|
|
527
|
-
if (headRect.bottom < map.height)
|
|
528
|
-
$headCell = doc.resolve(
|
|
529
|
-
tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]
|
|
530
|
-
);
|
|
531
|
-
} else {
|
|
532
|
-
if (headRect.top > 0)
|
|
533
|
-
$headCell = doc.resolve(tableStart + map.map[headRect.left]);
|
|
534
|
-
if (anchorRect.bottom < map.height)
|
|
535
|
-
$anchorCell = doc.resolve(
|
|
536
|
-
tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
return new _CellSelection($anchorCell, $headCell);
|
|
540
|
-
}
|
|
541
|
-
// True if this selection goes all the way from the left to the
|
|
542
|
-
// right of the table.
|
|
543
|
-
isRowSelection() {
|
|
544
|
-
const table = this.$anchorCell.node(-1);
|
|
545
|
-
const map = TableMap.get(table);
|
|
546
|
-
const tableStart = this.$anchorCell.start(-1);
|
|
547
|
-
const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);
|
|
548
|
-
const headLeft = map.colCount(this.$headCell.pos - tableStart);
|
|
549
|
-
if (Math.min(anchorLeft, headLeft) > 0) return false;
|
|
550
|
-
const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
551
|
-
const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
552
|
-
return Math.max(anchorRight, headRight) == map.width;
|
|
553
|
-
}
|
|
554
|
-
eq(other) {
|
|
555
|
-
return other instanceof _CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
|
|
556
|
-
}
|
|
557
|
-
// Returns the smallest row selection that covers the given anchor
|
|
558
|
-
// and head cell.
|
|
559
|
-
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
560
|
-
const table = $anchorCell.node(-1);
|
|
561
|
-
const map = TableMap.get(table);
|
|
562
|
-
const tableStart = $anchorCell.start(-1);
|
|
563
|
-
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
564
|
-
const headRect = map.findCell($headCell.pos - tableStart);
|
|
565
|
-
const doc = $anchorCell.node(0);
|
|
566
|
-
if (anchorRect.left <= headRect.left) {
|
|
567
|
-
if (anchorRect.left > 0)
|
|
568
|
-
$anchorCell = doc.resolve(
|
|
569
|
-
tableStart + map.map[anchorRect.top * map.width]
|
|
570
|
-
);
|
|
571
|
-
if (headRect.right < map.width)
|
|
572
|
-
$headCell = doc.resolve(
|
|
573
|
-
tableStart + map.map[map.width * (headRect.top + 1) - 1]
|
|
574
|
-
);
|
|
575
|
-
} else {
|
|
576
|
-
if (headRect.left > 0)
|
|
577
|
-
$headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);
|
|
578
|
-
if (anchorRect.right < map.width)
|
|
579
|
-
$anchorCell = doc.resolve(
|
|
580
|
-
tableStart + map.map[map.width * (anchorRect.top + 1) - 1]
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
return new _CellSelection($anchorCell, $headCell);
|
|
584
|
-
}
|
|
585
|
-
toJSON() {
|
|
586
|
-
return {
|
|
587
|
-
type: "cell",
|
|
588
|
-
anchor: this.$anchorCell.pos,
|
|
589
|
-
head: this.$headCell.pos
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
static fromJSON(doc, json) {
|
|
593
|
-
return new _CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
594
|
-
}
|
|
595
|
-
static create(doc, anchorCell, headCell = anchorCell) {
|
|
596
|
-
return new _CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
|
|
597
|
-
}
|
|
598
|
-
getBookmark() {
|
|
599
|
-
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
CellSelection.prototype.visible = false;
|
|
603
|
-
Selection.jsonID("cell", CellSelection);
|
|
604
|
-
var CellBookmark = class _CellBookmark {
|
|
605
|
-
constructor(anchor, head) {
|
|
606
|
-
this.anchor = anchor;
|
|
607
|
-
this.head = head;
|
|
608
|
-
}
|
|
609
|
-
map(mapping) {
|
|
610
|
-
return new _CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
611
|
-
}
|
|
612
|
-
resolve(doc) {
|
|
613
|
-
const $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
|
|
614
|
-
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell))
|
|
615
|
-
return new CellSelection($anchorCell, $headCell);
|
|
616
|
-
else return Selection.near($headCell, 1);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
function drawCellSelection(state) {
|
|
620
|
-
if (!(state.selection instanceof CellSelection)) return null;
|
|
621
|
-
const cells = [];
|
|
622
|
-
state.selection.forEachCell((node, pos) => {
|
|
623
|
-
cells.push(
|
|
624
|
-
Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" })
|
|
625
|
-
);
|
|
626
|
-
});
|
|
627
|
-
return DecorationSet.create(state.doc, cells);
|
|
628
|
-
}
|
|
629
|
-
function isCellBoundarySelection({ $from, $to }) {
|
|
630
|
-
if ($from.pos == $to.pos || $from.pos < $to.pos - 6) return false;
|
|
631
|
-
let afterFrom = $from.pos;
|
|
632
|
-
let beforeTo = $to.pos;
|
|
633
|
-
let depth = $from.depth;
|
|
634
|
-
for (; depth >= 0; depth--, afterFrom++)
|
|
635
|
-
if ($from.after(depth + 1) < $from.end(depth)) break;
|
|
636
|
-
for (let d = $to.depth; d >= 0; d--, beforeTo--)
|
|
637
|
-
if ($to.before(d + 1) > $to.start(d)) break;
|
|
638
|
-
return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
|
|
639
|
-
}
|
|
640
|
-
function isTextSelectionAcrossCells({ $from, $to }) {
|
|
641
|
-
let fromCellBoundaryNode;
|
|
642
|
-
let toCellBoundaryNode;
|
|
643
|
-
for (let i = $from.depth; i > 0; i--) {
|
|
644
|
-
const node = $from.node(i);
|
|
645
|
-
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
646
|
-
fromCellBoundaryNode = node;
|
|
647
|
-
break;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
for (let i = $to.depth; i > 0; i--) {
|
|
651
|
-
const node = $to.node(i);
|
|
652
|
-
if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
|
|
653
|
-
toCellBoundaryNode = node;
|
|
654
|
-
break;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
658
|
-
}
|
|
659
|
-
function normalizeSelection(state, tr, allowTableNodeSelection) {
|
|
660
|
-
const sel = (tr || state).selection;
|
|
661
|
-
const doc = (tr || state).doc;
|
|
662
|
-
let normalize;
|
|
663
|
-
let role;
|
|
664
|
-
if (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {
|
|
665
|
-
if (role == "cell" || role == "header_cell") {
|
|
666
|
-
normalize = CellSelection.create(doc, sel.from);
|
|
667
|
-
} else if (role == "row") {
|
|
668
|
-
const $cell = doc.resolve(sel.from + 1);
|
|
669
|
-
normalize = CellSelection.rowSelection($cell, $cell);
|
|
670
|
-
} else if (!allowTableNodeSelection) {
|
|
671
|
-
const map = TableMap.get(sel.node);
|
|
672
|
-
const start = sel.from + 1;
|
|
673
|
-
const lastCell = start + map.map[map.width * map.height - 1];
|
|
674
|
-
normalize = CellSelection.create(doc, start + 1, lastCell);
|
|
675
|
-
}
|
|
676
|
-
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
677
|
-
normalize = TextSelection.create(doc, sel.from);
|
|
678
|
-
} else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
|
|
679
|
-
normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
680
|
-
}
|
|
681
|
-
if (normalize) (tr || (tr = state.tr)).setSelection(normalize);
|
|
682
|
-
return tr;
|
|
683
|
-
}
|
|
684
|
-
var fixTablesKey = new PluginKey("fix-tables");
|
|
685
|
-
function changedDescendants(old, cur, offset, f) {
|
|
686
|
-
const oldSize = old.childCount, curSize = cur.childCount;
|
|
687
|
-
outer: for (let i = 0, j = 0; i < curSize; i++) {
|
|
688
|
-
const child = cur.child(i);
|
|
689
|
-
for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
690
|
-
if (old.child(scan) == child) {
|
|
691
|
-
j = scan + 1;
|
|
692
|
-
offset += child.nodeSize;
|
|
693
|
-
continue outer;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
f(child, offset);
|
|
697
|
-
if (j < oldSize && old.child(j).sameMarkup(child))
|
|
698
|
-
changedDescendants(old.child(j), child, offset + 1, f);
|
|
699
|
-
else child.nodesBetween(0, child.content.size, f, offset + 1);
|
|
700
|
-
offset += child.nodeSize;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
function fixTables(state, oldState) {
|
|
704
|
-
let tr;
|
|
705
|
-
const check = (node, pos) => {
|
|
706
|
-
if (node.type.spec.tableRole == "table")
|
|
707
|
-
tr = fixTable(state, node, pos, tr);
|
|
708
|
-
};
|
|
709
|
-
if (!oldState) state.doc.descendants(check);
|
|
710
|
-
else if (oldState.doc != state.doc)
|
|
711
|
-
changedDescendants(oldState.doc, state.doc, 0, check);
|
|
712
|
-
return tr;
|
|
713
|
-
}
|
|
714
|
-
function fixTable(state, table, tablePos, tr) {
|
|
715
|
-
const map = TableMap.get(table);
|
|
716
|
-
if (!map.problems) return tr;
|
|
717
|
-
if (!tr) tr = state.tr;
|
|
718
|
-
const mustAdd = [];
|
|
719
|
-
for (let i = 0; i < map.height; i++) mustAdd.push(0);
|
|
720
|
-
for (let i = 0; i < map.problems.length; i++) {
|
|
721
|
-
const prob = map.problems[i];
|
|
722
|
-
if (prob.type == "collision") {
|
|
723
|
-
const cell = table.nodeAt(prob.pos);
|
|
724
|
-
if (!cell) continue;
|
|
725
|
-
const attrs = cell.attrs;
|
|
726
|
-
for (let j = 0; j < attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n;
|
|
727
|
-
tr.setNodeMarkup(
|
|
728
|
-
tr.mapping.map(tablePos + 1 + prob.pos),
|
|
729
|
-
null,
|
|
730
|
-
removeColSpan(attrs, attrs.colspan - prob.n, prob.n)
|
|
731
|
-
);
|
|
732
|
-
} else if (prob.type == "missing") {
|
|
733
|
-
mustAdd[prob.row] += prob.n;
|
|
734
|
-
} else if (prob.type == "overlong_rowspan") {
|
|
735
|
-
const cell = table.nodeAt(prob.pos);
|
|
736
|
-
if (!cell) continue;
|
|
737
|
-
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
738
|
-
...cell.attrs,
|
|
739
|
-
rowspan: cell.attrs.rowspan - prob.n
|
|
740
|
-
});
|
|
741
|
-
} else if (prob.type == "colwidth mismatch") {
|
|
742
|
-
const cell = table.nodeAt(prob.pos);
|
|
743
|
-
if (!cell) continue;
|
|
744
|
-
tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
|
|
745
|
-
...cell.attrs,
|
|
746
|
-
colwidth: prob.colwidth
|
|
747
|
-
});
|
|
748
|
-
} else if (prob.type == "zero_sized") {
|
|
749
|
-
const pos = tr.mapping.map(tablePos);
|
|
750
|
-
tr.delete(pos, pos + table.nodeSize);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
let first, last;
|
|
754
|
-
for (let i = 0; i < mustAdd.length; i++)
|
|
755
|
-
if (mustAdd[i]) {
|
|
756
|
-
if (first == null) first = i;
|
|
757
|
-
last = i;
|
|
758
|
-
}
|
|
759
|
-
for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
|
|
760
|
-
const row = table.child(i);
|
|
761
|
-
const end = pos + row.nodeSize;
|
|
762
|
-
const add = mustAdd[i];
|
|
763
|
-
if (add > 0) {
|
|
764
|
-
let role = "cell";
|
|
765
|
-
if (row.firstChild) {
|
|
766
|
-
role = row.firstChild.type.spec.tableRole;
|
|
767
|
-
}
|
|
768
|
-
const nodes = [];
|
|
769
|
-
for (let j = 0; j < add; j++) {
|
|
770
|
-
const node = tableNodeTypes(state.schema)[role].createAndFill();
|
|
771
|
-
if (node) nodes.push(node);
|
|
772
|
-
}
|
|
773
|
-
const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;
|
|
774
|
-
tr.insert(tr.mapping.map(side), nodes);
|
|
775
|
-
}
|
|
776
|
-
pos = end;
|
|
777
|
-
}
|
|
778
|
-
return tr.setMeta(fixTablesKey, { fixTables: true });
|
|
779
|
-
}
|
|
780
|
-
function selectedRect(state) {
|
|
781
|
-
const sel = state.selection;
|
|
782
|
-
const $pos = selectionCell(state);
|
|
783
|
-
const table = $pos.node(-1);
|
|
784
|
-
const tableStart = $pos.start(-1);
|
|
785
|
-
const map = TableMap.get(table);
|
|
786
|
-
const rect = sel instanceof CellSelection ? map.rectBetween(
|
|
787
|
-
sel.$anchorCell.pos - tableStart,
|
|
788
|
-
sel.$headCell.pos - tableStart
|
|
789
|
-
) : map.findCell($pos.pos - tableStart);
|
|
790
|
-
return { ...rect, tableStart, map, table };
|
|
791
|
-
}
|
|
792
|
-
function addColumn(tr, { map, tableStart, table }, col) {
|
|
793
|
-
let refColumn = col > 0 ? -1 : 0;
|
|
794
|
-
if (columnIsHeader(map, table, col + refColumn)) {
|
|
795
|
-
refColumn = col == 0 || col == map.width ? null : 0;
|
|
796
|
-
}
|
|
797
|
-
for (let row = 0; row < map.height; row++) {
|
|
798
|
-
const index = row * map.width + col;
|
|
799
|
-
if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {
|
|
800
|
-
const pos = map.map[index];
|
|
801
|
-
const cell = table.nodeAt(pos);
|
|
802
|
-
tr.setNodeMarkup(
|
|
803
|
-
tr.mapping.map(tableStart + pos),
|
|
804
|
-
null,
|
|
805
|
-
addColSpan(cell.attrs, col - map.colCount(pos))
|
|
806
|
-
);
|
|
807
|
-
row += cell.attrs.rowspan - 1;
|
|
808
|
-
} else {
|
|
809
|
-
const type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;
|
|
810
|
-
const pos = map.positionAt(row, col, table);
|
|
811
|
-
tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
return tr;
|
|
815
|
-
}
|
|
816
|
-
function addColumnBefore(state, dispatch) {
|
|
817
|
-
if (!isInTable(state)) return false;
|
|
818
|
-
if (dispatch) {
|
|
819
|
-
const rect = selectedRect(state);
|
|
820
|
-
dispatch(addColumn(state.tr, rect, rect.left));
|
|
821
|
-
}
|
|
822
|
-
return true;
|
|
823
|
-
}
|
|
824
|
-
function addColumnAfter(state, dispatch) {
|
|
825
|
-
if (!isInTable(state)) return false;
|
|
826
|
-
if (dispatch) {
|
|
827
|
-
const rect = selectedRect(state);
|
|
828
|
-
dispatch(addColumn(state.tr, rect, rect.right));
|
|
829
|
-
}
|
|
830
|
-
return true;
|
|
831
|
-
}
|
|
832
|
-
function removeColumn(tr, { map, table, tableStart }, col) {
|
|
833
|
-
const mapStart = tr.mapping.maps.length;
|
|
834
|
-
for (let row = 0; row < map.height; ) {
|
|
835
|
-
const index = row * map.width + col;
|
|
836
|
-
const pos = map.map[index];
|
|
837
|
-
const cell = table.nodeAt(pos);
|
|
838
|
-
const attrs = cell.attrs;
|
|
839
|
-
if (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) {
|
|
840
|
-
tr.setNodeMarkup(
|
|
841
|
-
tr.mapping.slice(mapStart).map(tableStart + pos),
|
|
842
|
-
null,
|
|
843
|
-
removeColSpan(attrs, col - map.colCount(pos))
|
|
844
|
-
);
|
|
845
|
-
} else {
|
|
846
|
-
const start = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
847
|
-
tr.delete(start, start + cell.nodeSize);
|
|
848
|
-
}
|
|
849
|
-
row += attrs.rowspan;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
function deleteColumn(state, dispatch) {
|
|
853
|
-
if (!isInTable(state)) return false;
|
|
854
|
-
if (dispatch) {
|
|
855
|
-
const rect = selectedRect(state);
|
|
856
|
-
const tr = state.tr;
|
|
857
|
-
if (rect.left == 0 && rect.right == rect.map.width) return false;
|
|
858
|
-
for (let i = rect.right - 1; ; i--) {
|
|
859
|
-
removeColumn(tr, rect, i);
|
|
860
|
-
if (i == rect.left) break;
|
|
861
|
-
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
862
|
-
if (!table) {
|
|
863
|
-
throw RangeError("No table found");
|
|
864
|
-
}
|
|
865
|
-
rect.table = table;
|
|
866
|
-
rect.map = TableMap.get(table);
|
|
867
|
-
}
|
|
868
|
-
dispatch(tr);
|
|
869
|
-
}
|
|
870
|
-
return true;
|
|
871
|
-
}
|
|
872
|
-
function rowIsHeader(map, table, row) {
|
|
873
|
-
var _a;
|
|
874
|
-
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
875
|
-
for (let col = 0; col < map.width; col++)
|
|
876
|
-
if (((_a = table.nodeAt(map.map[col + row * map.width])) == null ? void 0 : _a.type) != headerCell)
|
|
877
|
-
return false;
|
|
878
|
-
return true;
|
|
879
|
-
}
|
|
880
|
-
function addRow(tr, { map, tableStart, table }, row) {
|
|
881
|
-
var _a;
|
|
882
|
-
let rowPos = tableStart;
|
|
883
|
-
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
884
|
-
const cells = [];
|
|
885
|
-
let refRow = row > 0 ? -1 : 0;
|
|
886
|
-
if (rowIsHeader(map, table, row + refRow))
|
|
887
|
-
refRow = row == 0 || row == map.height ? null : 0;
|
|
888
|
-
for (let col = 0, index = map.width * row; col < map.width; col++, index++) {
|
|
889
|
-
if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {
|
|
890
|
-
const pos = map.map[index];
|
|
891
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
892
|
-
tr.setNodeMarkup(tableStart + pos, null, {
|
|
893
|
-
...attrs,
|
|
894
|
-
rowspan: attrs.rowspan + 1
|
|
895
|
-
});
|
|
896
|
-
col += attrs.colspan - 1;
|
|
897
|
-
} else {
|
|
898
|
-
const type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_a = table.nodeAt(map.map[index + refRow * map.width])) == null ? void 0 : _a.type;
|
|
899
|
-
const node = type == null ? void 0 : type.createAndFill();
|
|
900
|
-
if (node) cells.push(node);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
904
|
-
return tr;
|
|
905
|
-
}
|
|
906
|
-
function addRowBefore(state, dispatch) {
|
|
907
|
-
if (!isInTable(state)) return false;
|
|
908
|
-
if (dispatch) {
|
|
909
|
-
const rect = selectedRect(state);
|
|
910
|
-
dispatch(addRow(state.tr, rect, rect.top));
|
|
911
|
-
}
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
|
-
function addRowAfter(state, dispatch) {
|
|
915
|
-
if (!isInTable(state)) return false;
|
|
916
|
-
if (dispatch) {
|
|
917
|
-
const rect = selectedRect(state);
|
|
918
|
-
dispatch(addRow(state.tr, rect, rect.bottom));
|
|
919
|
-
}
|
|
920
|
-
return true;
|
|
921
|
-
}
|
|
922
|
-
function removeRow(tr, { map, table, tableStart }, row) {
|
|
923
|
-
let rowPos = 0;
|
|
924
|
-
for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
|
|
925
|
-
const nextRow = rowPos + table.child(row).nodeSize;
|
|
926
|
-
const mapFrom = tr.mapping.maps.length;
|
|
927
|
-
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
928
|
-
const seen = /* @__PURE__ */ new Set();
|
|
929
|
-
for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
|
|
930
|
-
const pos = map.map[index];
|
|
931
|
-
if (seen.has(pos)) continue;
|
|
932
|
-
seen.add(pos);
|
|
933
|
-
if (row > 0 && pos == map.map[index - map.width]) {
|
|
934
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
935
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {
|
|
936
|
-
...attrs,
|
|
937
|
-
rowspan: attrs.rowspan - 1
|
|
938
|
-
});
|
|
939
|
-
col += attrs.colspan - 1;
|
|
940
|
-
} else if (row < map.height && pos == map.map[index + map.width]) {
|
|
941
|
-
const cell = table.nodeAt(pos);
|
|
942
|
-
const attrs = cell.attrs;
|
|
943
|
-
const copy = cell.type.create(
|
|
944
|
-
{ ...attrs, rowspan: cell.attrs.rowspan - 1 },
|
|
945
|
-
cell.content
|
|
946
|
-
);
|
|
947
|
-
const newPos = map.positionAt(row + 1, col, table);
|
|
948
|
-
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
949
|
-
col += attrs.colspan - 1;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
function deleteRow(state, dispatch) {
|
|
954
|
-
if (!isInTable(state)) return false;
|
|
955
|
-
if (dispatch) {
|
|
956
|
-
const rect = selectedRect(state), tr = state.tr;
|
|
957
|
-
if (rect.top == 0 && rect.bottom == rect.map.height) return false;
|
|
958
|
-
for (let i = rect.bottom - 1; ; i--) {
|
|
959
|
-
removeRow(tr, rect, i);
|
|
960
|
-
if (i == rect.top) break;
|
|
961
|
-
const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
962
|
-
if (!table) {
|
|
963
|
-
throw RangeError("No table found");
|
|
964
|
-
}
|
|
965
|
-
rect.table = table;
|
|
966
|
-
rect.map = TableMap.get(rect.table);
|
|
967
|
-
}
|
|
968
|
-
dispatch(tr);
|
|
969
|
-
}
|
|
970
|
-
return true;
|
|
971
|
-
}
|
|
972
|
-
function isEmpty(cell) {
|
|
973
|
-
const c = cell.content;
|
|
974
|
-
return c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;
|
|
975
|
-
}
|
|
976
|
-
function cellsOverlapRectangle({ width, height, map }, rect) {
|
|
977
|
-
let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
|
|
978
|
-
let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
|
|
979
|
-
for (let i = rect.top; i < rect.bottom; i++) {
|
|
980
|
-
if (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1])
|
|
981
|
-
return true;
|
|
982
|
-
indexLeft += width;
|
|
983
|
-
indexRight += width;
|
|
984
|
-
}
|
|
985
|
-
for (let i = rect.left; i < rect.right; i++) {
|
|
986
|
-
if (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width])
|
|
987
|
-
return true;
|
|
988
|
-
indexTop++;
|
|
989
|
-
indexBottom++;
|
|
990
|
-
}
|
|
991
|
-
return false;
|
|
992
|
-
}
|
|
993
|
-
function mergeCells(state, dispatch) {
|
|
994
|
-
const sel = state.selection;
|
|
995
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)
|
|
996
|
-
return false;
|
|
997
|
-
const rect = selectedRect(state), { map } = rect;
|
|
998
|
-
if (cellsOverlapRectangle(map, rect)) return false;
|
|
999
|
-
if (dispatch) {
|
|
1000
|
-
const tr = state.tr;
|
|
1001
|
-
const seen = {};
|
|
1002
|
-
let content = Fragment.empty;
|
|
1003
|
-
let mergedPos;
|
|
1004
|
-
let mergedCell;
|
|
1005
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
1006
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
1007
|
-
const cellPos = map.map[row * map.width + col];
|
|
1008
|
-
const cell = rect.table.nodeAt(cellPos);
|
|
1009
|
-
if (seen[cellPos] || !cell) continue;
|
|
1010
|
-
seen[cellPos] = true;
|
|
1011
|
-
if (mergedPos == null) {
|
|
1012
|
-
mergedPos = cellPos;
|
|
1013
|
-
mergedCell = cell;
|
|
1014
|
-
} else {
|
|
1015
|
-
if (!isEmpty(cell)) content = content.append(cell.content);
|
|
1016
|
-
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
1017
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
if (mergedPos == null || mergedCell == null) {
|
|
1022
|
-
return true;
|
|
1023
|
-
}
|
|
1024
|
-
tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
|
|
1025
|
-
...addColSpan(
|
|
1026
|
-
mergedCell.attrs,
|
|
1027
|
-
mergedCell.attrs.colspan,
|
|
1028
|
-
rect.right - rect.left - mergedCell.attrs.colspan
|
|
1029
|
-
),
|
|
1030
|
-
rowspan: rect.bottom - rect.top
|
|
1031
|
-
});
|
|
1032
|
-
if (content.size) {
|
|
1033
|
-
const end = mergedPos + 1 + mergedCell.content.size;
|
|
1034
|
-
const start = isEmpty(mergedCell) ? mergedPos + 1 : end;
|
|
1035
|
-
tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
|
|
1036
|
-
}
|
|
1037
|
-
tr.setSelection(
|
|
1038
|
-
new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart))
|
|
1039
|
-
);
|
|
1040
|
-
dispatch(tr);
|
|
1041
|
-
}
|
|
1042
|
-
return true;
|
|
1043
|
-
}
|
|
1044
|
-
function splitCell(state, dispatch) {
|
|
1045
|
-
const nodeTypes = tableNodeTypes(state.schema);
|
|
1046
|
-
return splitCellWithType(({ node }) => {
|
|
1047
|
-
return nodeTypes[node.type.spec.tableRole];
|
|
1048
|
-
})(state, dispatch);
|
|
1049
|
-
}
|
|
1050
|
-
function splitCellWithType(getCellType) {
|
|
1051
|
-
return (state, dispatch) => {
|
|
1052
|
-
var _a;
|
|
1053
|
-
const sel = state.selection;
|
|
1054
|
-
let cellNode;
|
|
1055
|
-
let cellPos;
|
|
1056
|
-
if (!(sel instanceof CellSelection)) {
|
|
1057
|
-
cellNode = cellWrapping(sel.$from);
|
|
1058
|
-
if (!cellNode) return false;
|
|
1059
|
-
cellPos = (_a = cellAround(sel.$from)) == null ? void 0 : _a.pos;
|
|
1060
|
-
} else {
|
|
1061
|
-
if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
|
|
1062
|
-
cellNode = sel.$anchorCell.nodeAfter;
|
|
1063
|
-
cellPos = sel.$anchorCell.pos;
|
|
1064
|
-
}
|
|
1065
|
-
if (cellNode == null || cellPos == null) {
|
|
1066
|
-
return false;
|
|
1067
|
-
}
|
|
1068
|
-
if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {
|
|
1069
|
-
return false;
|
|
1070
|
-
}
|
|
1071
|
-
if (dispatch) {
|
|
1072
|
-
let baseAttrs = cellNode.attrs;
|
|
1073
|
-
const attrs = [];
|
|
1074
|
-
const colwidth = baseAttrs.colwidth;
|
|
1075
|
-
if (baseAttrs.rowspan > 1) baseAttrs = { ...baseAttrs, rowspan: 1 };
|
|
1076
|
-
if (baseAttrs.colspan > 1) baseAttrs = { ...baseAttrs, colspan: 1 };
|
|
1077
|
-
const rect = selectedRect(state), tr = state.tr;
|
|
1078
|
-
for (let i = 0; i < rect.right - rect.left; i++)
|
|
1079
|
-
attrs.push(
|
|
1080
|
-
colwidth ? {
|
|
1081
|
-
...baseAttrs,
|
|
1082
|
-
colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
|
|
1083
|
-
} : baseAttrs
|
|
1084
|
-
);
|
|
1085
|
-
let lastCell;
|
|
1086
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
1087
|
-
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
1088
|
-
if (row == rect.top) pos += cellNode.nodeSize;
|
|
1089
|
-
for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
|
|
1090
|
-
if (col == rect.left && row == rect.top) continue;
|
|
1091
|
-
tr.insert(
|
|
1092
|
-
lastCell = tr.mapping.map(pos + rect.tableStart, 1),
|
|
1093
|
-
getCellType({ node: cellNode, row, col }).createAndFill(attrs[i])
|
|
1094
|
-
);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
tr.setNodeMarkup(
|
|
1098
|
-
cellPos,
|
|
1099
|
-
getCellType({ node: cellNode, row: rect.top, col: rect.left }),
|
|
1100
|
-
attrs[0]
|
|
1101
|
-
);
|
|
1102
|
-
if (sel instanceof CellSelection)
|
|
1103
|
-
tr.setSelection(
|
|
1104
|
-
new CellSelection(
|
|
1105
|
-
tr.doc.resolve(sel.$anchorCell.pos),
|
|
1106
|
-
lastCell ? tr.doc.resolve(lastCell) : void 0
|
|
1107
|
-
)
|
|
1108
|
-
);
|
|
1109
|
-
dispatch(tr);
|
|
1110
|
-
}
|
|
1111
|
-
return true;
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
function setCellAttr(name, value) {
|
|
1115
|
-
return function(state, dispatch) {
|
|
1116
|
-
if (!isInTable(state)) return false;
|
|
1117
|
-
const $cell = selectionCell(state);
|
|
1118
|
-
if ($cell.nodeAfter.attrs[name] === value) return false;
|
|
1119
|
-
if (dispatch) {
|
|
1120
|
-
const tr = state.tr;
|
|
1121
|
-
if (state.selection instanceof CellSelection)
|
|
1122
|
-
state.selection.forEachCell((node, pos) => {
|
|
1123
|
-
if (node.attrs[name] !== value)
|
|
1124
|
-
tr.setNodeMarkup(pos, null, {
|
|
1125
|
-
...node.attrs,
|
|
1126
|
-
[name]: value
|
|
1127
|
-
});
|
|
1128
|
-
});
|
|
1129
|
-
else
|
|
1130
|
-
tr.setNodeMarkup($cell.pos, null, {
|
|
1131
|
-
...$cell.nodeAfter.attrs,
|
|
1132
|
-
[name]: value
|
|
1133
|
-
});
|
|
1134
|
-
dispatch(tr);
|
|
1135
|
-
}
|
|
1136
|
-
return true;
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
function deprecated_toggleHeader(type) {
|
|
1140
|
-
return function(state, dispatch) {
|
|
1141
|
-
if (!isInTable(state)) return false;
|
|
1142
|
-
if (dispatch) {
|
|
1143
|
-
const types = tableNodeTypes(state.schema);
|
|
1144
|
-
const rect = selectedRect(state), tr = state.tr;
|
|
1145
|
-
const cells = rect.map.cellsInRect(
|
|
1146
|
-
type == "column" ? {
|
|
1147
|
-
left: rect.left,
|
|
1148
|
-
top: 0,
|
|
1149
|
-
right: rect.right,
|
|
1150
|
-
bottom: rect.map.height
|
|
1151
|
-
} : type == "row" ? {
|
|
1152
|
-
left: 0,
|
|
1153
|
-
top: rect.top,
|
|
1154
|
-
right: rect.map.width,
|
|
1155
|
-
bottom: rect.bottom
|
|
1156
|
-
} : rect
|
|
1157
|
-
);
|
|
1158
|
-
const nodes = cells.map((pos) => rect.table.nodeAt(pos));
|
|
1159
|
-
for (let i = 0; i < cells.length; i++)
|
|
1160
|
-
if (nodes[i].type == types.header_cell)
|
|
1161
|
-
tr.setNodeMarkup(
|
|
1162
|
-
rect.tableStart + cells[i],
|
|
1163
|
-
types.cell,
|
|
1164
|
-
nodes[i].attrs
|
|
1165
|
-
);
|
|
1166
|
-
if (tr.steps.length == 0)
|
|
1167
|
-
for (let i = 0; i < cells.length; i++)
|
|
1168
|
-
tr.setNodeMarkup(
|
|
1169
|
-
rect.tableStart + cells[i],
|
|
1170
|
-
types.header_cell,
|
|
1171
|
-
nodes[i].attrs
|
|
1172
|
-
);
|
|
1173
|
-
dispatch(tr);
|
|
1174
|
-
}
|
|
1175
|
-
return true;
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
function isHeaderEnabledByType(type, rect, types) {
|
|
1179
|
-
const cellPositions = rect.map.cellsInRect({
|
|
1180
|
-
left: 0,
|
|
1181
|
-
top: 0,
|
|
1182
|
-
right: type == "row" ? rect.map.width : 1,
|
|
1183
|
-
bottom: type == "column" ? rect.map.height : 1
|
|
1184
|
-
});
|
|
1185
|
-
for (let i = 0; i < cellPositions.length; i++) {
|
|
1186
|
-
const cell = rect.table.nodeAt(cellPositions[i]);
|
|
1187
|
-
if (cell && cell.type !== types.header_cell) {
|
|
1188
|
-
return false;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
return true;
|
|
1192
|
-
}
|
|
1193
|
-
function toggleHeader(type, options) {
|
|
1194
|
-
options = options || { useDeprecatedLogic: false };
|
|
1195
|
-
if (options.useDeprecatedLogic) return deprecated_toggleHeader(type);
|
|
1196
|
-
return function(state, dispatch) {
|
|
1197
|
-
if (!isInTable(state)) return false;
|
|
1198
|
-
if (dispatch) {
|
|
1199
|
-
const types = tableNodeTypes(state.schema);
|
|
1200
|
-
const rect = selectedRect(state), tr = state.tr;
|
|
1201
|
-
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
|
|
1202
|
-
const isHeaderColumnEnabled = isHeaderEnabledByType(
|
|
1203
|
-
"column",
|
|
1204
|
-
rect,
|
|
1205
|
-
types
|
|
1206
|
-
);
|
|
1207
|
-
const isHeaderEnabled = type === "column" ? isHeaderRowEnabled : type === "row" ? isHeaderColumnEnabled : false;
|
|
1208
|
-
const selectionStartsAt = isHeaderEnabled ? 1 : 0;
|
|
1209
|
-
const cellsRect = type == "column" ? {
|
|
1210
|
-
left: 0,
|
|
1211
|
-
top: selectionStartsAt,
|
|
1212
|
-
right: 1,
|
|
1213
|
-
bottom: rect.map.height
|
|
1214
|
-
} : type == "row" ? {
|
|
1215
|
-
left: selectionStartsAt,
|
|
1216
|
-
top: 0,
|
|
1217
|
-
right: rect.map.width,
|
|
1218
|
-
bottom: 1
|
|
1219
|
-
} : rect;
|
|
1220
|
-
const newType = type == "column" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == "row" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;
|
|
1221
|
-
rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
|
|
1222
|
-
const cellPos = relativeCellPos + rect.tableStart;
|
|
1223
|
-
const cell = tr.doc.nodeAt(cellPos);
|
|
1224
|
-
if (cell) {
|
|
1225
|
-
tr.setNodeMarkup(cellPos, newType, cell.attrs);
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
dispatch(tr);
|
|
1229
|
-
}
|
|
1230
|
-
return true;
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
|
-
toggleHeader("row", {
|
|
1234
|
-
useDeprecatedLogic: true
|
|
1235
|
-
});
|
|
1236
|
-
toggleHeader("column", {
|
|
1237
|
-
useDeprecatedLogic: true
|
|
1238
|
-
});
|
|
1239
|
-
var toggleHeaderCell = toggleHeader("cell", {
|
|
1240
|
-
useDeprecatedLogic: true
|
|
1241
|
-
});
|
|
1242
|
-
function findNextCell($cell, dir) {
|
|
1243
|
-
if (dir < 0) {
|
|
1244
|
-
const before = $cell.nodeBefore;
|
|
1245
|
-
if (before) return $cell.pos - before.nodeSize;
|
|
1246
|
-
for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
|
|
1247
|
-
const rowNode = $cell.node(-1).child(row);
|
|
1248
|
-
const lastChild = rowNode.lastChild;
|
|
1249
|
-
if (lastChild) {
|
|
1250
|
-
return rowEnd - 1 - lastChild.nodeSize;
|
|
1251
|
-
}
|
|
1252
|
-
rowEnd -= rowNode.nodeSize;
|
|
1253
|
-
}
|
|
1254
|
-
} else {
|
|
1255
|
-
if ($cell.index() < $cell.parent.childCount - 1) {
|
|
1256
|
-
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
1257
|
-
}
|
|
1258
|
-
const table = $cell.node(-1);
|
|
1259
|
-
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
|
|
1260
|
-
const rowNode = table.child(row);
|
|
1261
|
-
if (rowNode.childCount) return rowStart + 1;
|
|
1262
|
-
rowStart += rowNode.nodeSize;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
return null;
|
|
1266
|
-
}
|
|
1267
|
-
function goToNextCell(direction) {
|
|
1268
|
-
return function(state, dispatch) {
|
|
1269
|
-
if (!isInTable(state)) return false;
|
|
1270
|
-
const cell = findNextCell(selectionCell(state), direction);
|
|
1271
|
-
if (cell == null) return false;
|
|
1272
|
-
if (dispatch) {
|
|
1273
|
-
const $cell = state.doc.resolve(cell);
|
|
1274
|
-
dispatch(
|
|
1275
|
-
state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView()
|
|
1276
|
-
);
|
|
1277
|
-
}
|
|
1278
|
-
return true;
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
function deleteTable(state, dispatch) {
|
|
1282
|
-
const $pos = state.selection.$anchor;
|
|
1283
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
1284
|
-
const node = $pos.node(d);
|
|
1285
|
-
if (node.type.spec.tableRole == "table") {
|
|
1286
|
-
if (dispatch)
|
|
1287
|
-
dispatch(
|
|
1288
|
-
state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView()
|
|
1289
|
-
);
|
|
1290
|
-
return true;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
return false;
|
|
1294
|
-
}
|
|
1295
|
-
function deleteCellSelection(state, dispatch) {
|
|
1296
|
-
const sel = state.selection;
|
|
1297
|
-
if (!(sel instanceof CellSelection)) return false;
|
|
1298
|
-
if (dispatch) {
|
|
1299
|
-
const tr = state.tr;
|
|
1300
|
-
const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
|
|
1301
|
-
sel.forEachCell((cell, pos) => {
|
|
1302
|
-
if (!cell.content.eq(baseContent))
|
|
1303
|
-
tr.replace(
|
|
1304
|
-
tr.mapping.map(pos + 1),
|
|
1305
|
-
tr.mapping.map(pos + cell.nodeSize - 1),
|
|
1306
|
-
new Slice(baseContent, 0, 0)
|
|
1307
|
-
);
|
|
1308
|
-
});
|
|
1309
|
-
if (tr.docChanged) dispatch(tr);
|
|
1310
|
-
}
|
|
1311
|
-
return true;
|
|
1312
|
-
}
|
|
1313
|
-
function pastedCells(slice) {
|
|
1314
|
-
if (!slice.size) return null;
|
|
1315
|
-
let { content, openStart, openEnd } = slice;
|
|
1316
|
-
while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
|
|
1317
|
-
openStart--;
|
|
1318
|
-
openEnd--;
|
|
1319
|
-
content = content.child(0).content;
|
|
1320
|
-
}
|
|
1321
|
-
const first = content.child(0);
|
|
1322
|
-
const role = first.type.spec.tableRole;
|
|
1323
|
-
const schema = first.type.schema, rows = [];
|
|
1324
|
-
if (role == "row") {
|
|
1325
|
-
for (let i = 0; i < content.childCount; i++) {
|
|
1326
|
-
let cells = content.child(i).content;
|
|
1327
|
-
const left = i ? 0 : Math.max(0, openStart - 1);
|
|
1328
|
-
const right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
|
|
1329
|
-
if (left || right)
|
|
1330
|
-
cells = fitSlice(
|
|
1331
|
-
tableNodeTypes(schema).row,
|
|
1332
|
-
new Slice(cells, left, right)
|
|
1333
|
-
).content;
|
|
1334
|
-
rows.push(cells);
|
|
1335
|
-
}
|
|
1336
|
-
} else if (role == "cell" || role == "header_cell") {
|
|
1337
|
-
rows.push(
|
|
1338
|
-
openStart || openEnd ? fitSlice(
|
|
1339
|
-
tableNodeTypes(schema).row,
|
|
1340
|
-
new Slice(content, openStart, openEnd)
|
|
1341
|
-
).content : content
|
|
1342
|
-
);
|
|
1343
|
-
} else {
|
|
1344
|
-
return null;
|
|
1345
|
-
}
|
|
1346
|
-
return ensureRectangular(schema, rows);
|
|
1347
|
-
}
|
|
1348
|
-
function ensureRectangular(schema, rows) {
|
|
1349
|
-
const widths = [];
|
|
1350
|
-
for (let i = 0; i < rows.length; i++) {
|
|
1351
|
-
const row = rows[i];
|
|
1352
|
-
for (let j = row.childCount - 1; j >= 0; j--) {
|
|
1353
|
-
const { rowspan, colspan } = row.child(j).attrs;
|
|
1354
|
-
for (let r = i; r < i + rowspan; r++)
|
|
1355
|
-
widths[r] = (widths[r] || 0) + colspan;
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
let width = 0;
|
|
1359
|
-
for (let r = 0; r < widths.length; r++) width = Math.max(width, widths[r]);
|
|
1360
|
-
for (let r = 0; r < widths.length; r++) {
|
|
1361
|
-
if (r >= rows.length) rows.push(Fragment.empty);
|
|
1362
|
-
if (widths[r] < width) {
|
|
1363
|
-
const empty = tableNodeTypes(schema).cell.createAndFill();
|
|
1364
|
-
const cells = [];
|
|
1365
|
-
for (let i = widths[r]; i < width; i++) {
|
|
1366
|
-
cells.push(empty);
|
|
1367
|
-
}
|
|
1368
|
-
rows[r] = rows[r].append(Fragment.from(cells));
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
return { height: rows.length, width, rows };
|
|
1372
|
-
}
|
|
1373
|
-
function fitSlice(nodeType, slice) {
|
|
1374
|
-
const node = nodeType.createAndFill();
|
|
1375
|
-
const tr = new Transform(node).replace(0, node.content.size, slice);
|
|
1376
|
-
return tr.doc;
|
|
1377
|
-
}
|
|
1378
|
-
function clipCells({ width, height, rows }, newWidth, newHeight) {
|
|
1379
|
-
if (width != newWidth) {
|
|
1380
|
-
const added = [];
|
|
1381
|
-
const newRows = [];
|
|
1382
|
-
for (let row = 0; row < rows.length; row++) {
|
|
1383
|
-
const frag = rows[row], cells = [];
|
|
1384
|
-
for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
|
|
1385
|
-
let cell = frag.child(i % frag.childCount);
|
|
1386
|
-
if (col + cell.attrs.colspan > newWidth)
|
|
1387
|
-
cell = cell.type.createChecked(
|
|
1388
|
-
removeColSpan(
|
|
1389
|
-
cell.attrs,
|
|
1390
|
-
cell.attrs.colspan,
|
|
1391
|
-
col + cell.attrs.colspan - newWidth
|
|
1392
|
-
),
|
|
1393
|
-
cell.content
|
|
1394
|
-
);
|
|
1395
|
-
cells.push(cell);
|
|
1396
|
-
col += cell.attrs.colspan;
|
|
1397
|
-
for (let j = 1; j < cell.attrs.rowspan; j++)
|
|
1398
|
-
added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;
|
|
1399
|
-
}
|
|
1400
|
-
newRows.push(Fragment.from(cells));
|
|
1401
|
-
}
|
|
1402
|
-
rows = newRows;
|
|
1403
|
-
width = newWidth;
|
|
1404
|
-
}
|
|
1405
|
-
if (height != newHeight) {
|
|
1406
|
-
const newRows = [];
|
|
1407
|
-
for (let row = 0, i = 0; row < newHeight; row++, i++) {
|
|
1408
|
-
const cells = [], source = rows[i % height];
|
|
1409
|
-
for (let j = 0; j < source.childCount; j++) {
|
|
1410
|
-
let cell = source.child(j);
|
|
1411
|
-
if (row + cell.attrs.rowspan > newHeight)
|
|
1412
|
-
cell = cell.type.create(
|
|
1413
|
-
{
|
|
1414
|
-
...cell.attrs,
|
|
1415
|
-
rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
|
|
1416
|
-
},
|
|
1417
|
-
cell.content
|
|
1418
|
-
);
|
|
1419
|
-
cells.push(cell);
|
|
1420
|
-
}
|
|
1421
|
-
newRows.push(Fragment.from(cells));
|
|
1422
|
-
}
|
|
1423
|
-
rows = newRows;
|
|
1424
|
-
height = newHeight;
|
|
1425
|
-
}
|
|
1426
|
-
return { width, height, rows };
|
|
1427
|
-
}
|
|
1428
|
-
function growTable(tr, map, table, start, width, height, mapFrom) {
|
|
1429
|
-
const schema = tr.doc.type.schema;
|
|
1430
|
-
const types = tableNodeTypes(schema);
|
|
1431
|
-
let empty;
|
|
1432
|
-
let emptyHead;
|
|
1433
|
-
if (width > map.width) {
|
|
1434
|
-
for (let row = 0, rowEnd = 0; row < map.height; row++) {
|
|
1435
|
-
const rowNode = table.child(row);
|
|
1436
|
-
rowEnd += rowNode.nodeSize;
|
|
1437
|
-
const cells = [];
|
|
1438
|
-
let add;
|
|
1439
|
-
if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell)
|
|
1440
|
-
add = empty || (empty = types.cell.createAndFill());
|
|
1441
|
-
else add = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
1442
|
-
for (let i = map.width; i < width; i++) cells.push(add);
|
|
1443
|
-
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
if (height > map.height) {
|
|
1447
|
-
const cells = [];
|
|
1448
|
-
for (let i = 0, start2 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {
|
|
1449
|
-
const header = i >= map.width ? false : table.nodeAt(map.map[start2 + i]).type == types.header_cell;
|
|
1450
|
-
cells.push(
|
|
1451
|
-
header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill())
|
|
1452
|
-
);
|
|
1453
|
-
}
|
|
1454
|
-
const emptyRow = types.row.create(null, Fragment.from(cells)), rows = [];
|
|
1455
|
-
for (let i = map.height; i < height; i++) rows.push(emptyRow);
|
|
1456
|
-
tr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);
|
|
1457
|
-
}
|
|
1458
|
-
return !!(empty || emptyHead);
|
|
1459
|
-
}
|
|
1460
|
-
function isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {
|
|
1461
|
-
if (top == 0 || top == map.height) return false;
|
|
1462
|
-
let found = false;
|
|
1463
|
-
for (let col = left; col < right; col++) {
|
|
1464
|
-
const index = top * map.width + col, pos = map.map[index];
|
|
1465
|
-
if (map.map[index - map.width] == pos) {
|
|
1466
|
-
found = true;
|
|
1467
|
-
const cell = table.nodeAt(pos);
|
|
1468
|
-
const { top: cellTop, left: cellLeft } = map.findCell(pos);
|
|
1469
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {
|
|
1470
|
-
...cell.attrs,
|
|
1471
|
-
rowspan: top - cellTop
|
|
1472
|
-
});
|
|
1473
|
-
tr.insert(
|
|
1474
|
-
tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)),
|
|
1475
|
-
cell.type.createAndFill({
|
|
1476
|
-
...cell.attrs,
|
|
1477
|
-
rowspan: cellTop + cell.attrs.rowspan - top
|
|
1478
|
-
})
|
|
1479
|
-
);
|
|
1480
|
-
col += cell.attrs.colspan - 1;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
return found;
|
|
1484
|
-
}
|
|
1485
|
-
function isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {
|
|
1486
|
-
if (left == 0 || left == map.width) return false;
|
|
1487
|
-
let found = false;
|
|
1488
|
-
for (let row = top; row < bottom; row++) {
|
|
1489
|
-
const index = row * map.width + left, pos = map.map[index];
|
|
1490
|
-
if (map.map[index - 1] == pos) {
|
|
1491
|
-
found = true;
|
|
1492
|
-
const cell = table.nodeAt(pos);
|
|
1493
|
-
const cellLeft = map.colCount(pos);
|
|
1494
|
-
const updatePos = tr.mapping.slice(mapFrom).map(pos + start);
|
|
1495
|
-
tr.setNodeMarkup(
|
|
1496
|
-
updatePos,
|
|
1497
|
-
null,
|
|
1498
|
-
removeColSpan(
|
|
1499
|
-
cell.attrs,
|
|
1500
|
-
left - cellLeft,
|
|
1501
|
-
cell.attrs.colspan - (left - cellLeft)
|
|
1502
|
-
)
|
|
1503
|
-
);
|
|
1504
|
-
tr.insert(
|
|
1505
|
-
updatePos + cell.nodeSize,
|
|
1506
|
-
cell.type.createAndFill(
|
|
1507
|
-
removeColSpan(cell.attrs, 0, left - cellLeft)
|
|
1508
|
-
)
|
|
1509
|
-
);
|
|
1510
|
-
row += cell.attrs.rowspan - 1;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
return found;
|
|
1514
|
-
}
|
|
1515
|
-
function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
1516
|
-
let table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;
|
|
1517
|
-
if (!table) {
|
|
1518
|
-
throw new Error("No table found");
|
|
1519
|
-
}
|
|
1520
|
-
let map = TableMap.get(table);
|
|
1521
|
-
const { top, left } = rect;
|
|
1522
|
-
const right = left + cells.width, bottom = top + cells.height;
|
|
1523
|
-
const tr = state.tr;
|
|
1524
|
-
let mapFrom = 0;
|
|
1525
|
-
function recomp() {
|
|
1526
|
-
table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
1527
|
-
if (!table) {
|
|
1528
|
-
throw new Error("No table found");
|
|
1529
|
-
}
|
|
1530
|
-
map = TableMap.get(table);
|
|
1531
|
-
mapFrom = tr.mapping.maps.length;
|
|
1532
|
-
}
|
|
1533
|
-
if (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) recomp();
|
|
1534
|
-
if (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom))
|
|
1535
|
-
recomp();
|
|
1536
|
-
if (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom))
|
|
1537
|
-
recomp();
|
|
1538
|
-
if (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom))
|
|
1539
|
-
recomp();
|
|
1540
|
-
if (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom))
|
|
1541
|
-
recomp();
|
|
1542
|
-
for (let row = top; row < bottom; row++) {
|
|
1543
|
-
const from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);
|
|
1544
|
-
tr.replace(
|
|
1545
|
-
tr.mapping.slice(mapFrom).map(from + tableStart),
|
|
1546
|
-
tr.mapping.slice(mapFrom).map(to + tableStart),
|
|
1547
|
-
new Slice(cells.rows[row - top], 0, 0)
|
|
1548
|
-
);
|
|
1549
|
-
}
|
|
1550
|
-
recomp();
|
|
1551
|
-
tr.setSelection(
|
|
1552
|
-
new CellSelection(
|
|
1553
|
-
tr.doc.resolve(tableStart + map.positionAt(top, left, table)),
|
|
1554
|
-
tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))
|
|
1555
|
-
)
|
|
1556
|
-
);
|
|
1557
|
-
dispatch(tr);
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
// src/input.ts
|
|
1561
|
-
var handleKeyDown = keydownHandler({
|
|
1562
|
-
ArrowLeft: arrow("horiz", -1),
|
|
1563
|
-
ArrowRight: arrow("horiz", 1),
|
|
1564
|
-
ArrowUp: arrow("vert", -1),
|
|
1565
|
-
ArrowDown: arrow("vert", 1),
|
|
1566
|
-
"Shift-ArrowLeft": shiftArrow("horiz", -1),
|
|
1567
|
-
"Shift-ArrowRight": shiftArrow("horiz", 1),
|
|
1568
|
-
"Shift-ArrowUp": shiftArrow("vert", -1),
|
|
1569
|
-
"Shift-ArrowDown": shiftArrow("vert", 1),
|
|
1570
|
-
Backspace: deleteCellSelection,
|
|
1571
|
-
"Mod-Backspace": deleteCellSelection,
|
|
1572
|
-
Delete: deleteCellSelection,
|
|
1573
|
-
"Mod-Delete": deleteCellSelection
|
|
1574
|
-
});
|
|
1575
|
-
function maybeSetSelection(state, dispatch, selection) {
|
|
1576
|
-
if (selection.eq(state.selection)) return false;
|
|
1577
|
-
if (dispatch) dispatch(state.tr.setSelection(selection).scrollIntoView());
|
|
1578
|
-
return true;
|
|
1579
|
-
}
|
|
1580
|
-
function arrow(axis, dir) {
|
|
1581
|
-
return (state, dispatch, view) => {
|
|
1582
|
-
if (!view) return false;
|
|
1583
|
-
const sel = state.selection;
|
|
1584
|
-
if (sel instanceof CellSelection) {
|
|
1585
|
-
return maybeSetSelection(
|
|
1586
|
-
state,
|
|
1587
|
-
dispatch,
|
|
1588
|
-
Selection.near(sel.$headCell, dir)
|
|
1589
|
-
);
|
|
1590
|
-
}
|
|
1591
|
-
if (axis != "horiz" && !sel.empty) return false;
|
|
1592
|
-
const end = atEndOfCell(view, axis, dir);
|
|
1593
|
-
if (end == null) return false;
|
|
1594
|
-
if (axis == "horiz") {
|
|
1595
|
-
return maybeSetSelection(
|
|
1596
|
-
state,
|
|
1597
|
-
dispatch,
|
|
1598
|
-
Selection.near(state.doc.resolve(sel.head + dir), dir)
|
|
1599
|
-
);
|
|
1600
|
-
} else {
|
|
1601
|
-
const $cell = state.doc.resolve(end);
|
|
1602
|
-
const $next = nextCell($cell, axis, dir);
|
|
1603
|
-
let newSel;
|
|
1604
|
-
if ($next) newSel = Selection.near($next, 1);
|
|
1605
|
-
else if (dir < 0)
|
|
1606
|
-
newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1);
|
|
1607
|
-
else newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1);
|
|
1608
|
-
return maybeSetSelection(state, dispatch, newSel);
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
|
-
function shiftArrow(axis, dir) {
|
|
1613
|
-
return (state, dispatch, view) => {
|
|
1614
|
-
if (!view) return false;
|
|
1615
|
-
const sel = state.selection;
|
|
1616
|
-
let cellSel;
|
|
1617
|
-
if (sel instanceof CellSelection) {
|
|
1618
|
-
cellSel = sel;
|
|
1619
|
-
} else {
|
|
1620
|
-
const end = atEndOfCell(view, axis, dir);
|
|
1621
|
-
if (end == null) return false;
|
|
1622
|
-
cellSel = new CellSelection(state.doc.resolve(end));
|
|
1623
|
-
}
|
|
1624
|
-
const $head = nextCell(cellSel.$headCell, axis, dir);
|
|
1625
|
-
if (!$head) return false;
|
|
1626
|
-
return maybeSetSelection(
|
|
1627
|
-
state,
|
|
1628
|
-
dispatch,
|
|
1629
|
-
new CellSelection(cellSel.$anchorCell, $head)
|
|
1630
|
-
);
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function handleTripleClick(view, pos) {
|
|
1634
|
-
const doc = view.state.doc, $cell = cellAround(doc.resolve(pos));
|
|
1635
|
-
if (!$cell) return false;
|
|
1636
|
-
view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
|
|
1637
|
-
return true;
|
|
1638
|
-
}
|
|
1639
|
-
function handlePaste(view, _, slice) {
|
|
1640
|
-
if (!isInTable(view.state)) return false;
|
|
1641
|
-
let cells = pastedCells(slice);
|
|
1642
|
-
const sel = view.state.selection;
|
|
1643
|
-
if (sel instanceof CellSelection) {
|
|
1644
|
-
if (!cells)
|
|
1645
|
-
cells = {
|
|
1646
|
-
width: 1,
|
|
1647
|
-
height: 1,
|
|
1648
|
-
rows: [
|
|
1649
|
-
Fragment.from(
|
|
1650
|
-
fitSlice(tableNodeTypes(view.state.schema).cell, slice)
|
|
1651
|
-
)
|
|
1652
|
-
]
|
|
1653
|
-
};
|
|
1654
|
-
const table = sel.$anchorCell.node(-1);
|
|
1655
|
-
const start = sel.$anchorCell.start(-1);
|
|
1656
|
-
const rect = TableMap.get(table).rectBetween(
|
|
1657
|
-
sel.$anchorCell.pos - start,
|
|
1658
|
-
sel.$headCell.pos - start
|
|
1659
|
-
);
|
|
1660
|
-
cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
|
|
1661
|
-
insertCells(view.state, view.dispatch, start, rect, cells);
|
|
1662
|
-
return true;
|
|
1663
|
-
} else if (cells) {
|
|
1664
|
-
const $cell = selectionCell(view.state);
|
|
1665
|
-
const start = $cell.start(-1);
|
|
1666
|
-
insertCells(
|
|
1667
|
-
view.state,
|
|
1668
|
-
view.dispatch,
|
|
1669
|
-
start,
|
|
1670
|
-
TableMap.get($cell.node(-1)).findCell($cell.pos - start),
|
|
1671
|
-
cells
|
|
1672
|
-
);
|
|
1673
|
-
return true;
|
|
1674
|
-
} else {
|
|
1675
|
-
return false;
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
function handleMouseDown(view, startEvent) {
|
|
1679
|
-
var _a;
|
|
1680
|
-
if (startEvent.ctrlKey || startEvent.metaKey) return;
|
|
1681
|
-
const startDOMCell = domInCell(view, startEvent.target);
|
|
1682
|
-
let $anchor;
|
|
1683
|
-
if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
|
|
1684
|
-
setCellSelection(view.state.selection.$anchorCell, startEvent);
|
|
1685
|
-
startEvent.preventDefault();
|
|
1686
|
-
} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_a = cellUnderMouse(view, startEvent)) == null ? void 0 : _a.pos) != $anchor.pos) {
|
|
1687
|
-
setCellSelection($anchor, startEvent);
|
|
1688
|
-
startEvent.preventDefault();
|
|
1689
|
-
} else if (!startDOMCell) {
|
|
1690
|
-
return;
|
|
1691
|
-
}
|
|
1692
|
-
function setCellSelection($anchor2, event) {
|
|
1693
|
-
let $head = cellUnderMouse(view, event);
|
|
1694
|
-
const starting = tableEditingKey.getState(view.state) == null;
|
|
1695
|
-
if (!$head || !inSameTable($anchor2, $head)) {
|
|
1696
|
-
if (starting) $head = $anchor2;
|
|
1697
|
-
else return;
|
|
1698
|
-
}
|
|
1699
|
-
const selection = new CellSelection($anchor2, $head);
|
|
1700
|
-
if (starting || !view.state.selection.eq(selection)) {
|
|
1701
|
-
const tr = view.state.tr.setSelection(selection);
|
|
1702
|
-
if (starting) tr.setMeta(tableEditingKey, $anchor2.pos);
|
|
1703
|
-
view.dispatch(tr);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
function stop() {
|
|
1707
|
-
view.root.removeEventListener("mouseup", stop);
|
|
1708
|
-
view.root.removeEventListener("dragstart", stop);
|
|
1709
|
-
view.root.removeEventListener("mousemove", move);
|
|
1710
|
-
if (tableEditingKey.getState(view.state) != null)
|
|
1711
|
-
view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
|
|
1712
|
-
}
|
|
1713
|
-
function move(_event) {
|
|
1714
|
-
const event = _event;
|
|
1715
|
-
const anchor = tableEditingKey.getState(view.state);
|
|
1716
|
-
let $anchor2;
|
|
1717
|
-
if (anchor != null) {
|
|
1718
|
-
$anchor2 = view.state.doc.resolve(anchor);
|
|
1719
|
-
} else if (domInCell(view, event.target) != startDOMCell) {
|
|
1720
|
-
$anchor2 = cellUnderMouse(view, startEvent);
|
|
1721
|
-
if (!$anchor2) return stop();
|
|
1722
|
-
}
|
|
1723
|
-
if ($anchor2) setCellSelection($anchor2, event);
|
|
1724
|
-
}
|
|
1725
|
-
view.root.addEventListener("mouseup", stop);
|
|
1726
|
-
view.root.addEventListener("dragstart", stop);
|
|
1727
|
-
view.root.addEventListener("mousemove", move);
|
|
1728
|
-
}
|
|
1729
|
-
function atEndOfCell(view, axis, dir) {
|
|
1730
|
-
if (!(view.state.selection instanceof TextSelection)) return null;
|
|
1731
|
-
const { $head } = view.state.selection;
|
|
1732
|
-
for (let d = $head.depth - 1; d >= 0; d--) {
|
|
1733
|
-
const parent = $head.node(d), index = dir < 0 ? $head.index(d) : $head.indexAfter(d);
|
|
1734
|
-
if (index != (dir < 0 ? 0 : parent.childCount)) return null;
|
|
1735
|
-
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
|
|
1736
|
-
const cellPos = $head.before(d);
|
|
1737
|
-
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
|
|
1738
|
-
return view.endOfTextblock(dirStr) ? cellPos : null;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
return null;
|
|
1742
|
-
}
|
|
1743
|
-
function domInCell(view, dom) {
|
|
1744
|
-
for (; dom && dom != view.dom; dom = dom.parentNode) {
|
|
1745
|
-
if (dom.nodeName == "TD" || dom.nodeName == "TH") {
|
|
1746
|
-
return dom;
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
return null;
|
|
1750
|
-
}
|
|
1751
|
-
function cellUnderMouse(view, event) {
|
|
1752
|
-
const mousePos = view.posAtCoords({
|
|
1753
|
-
left: event.clientX,
|
|
1754
|
-
top: event.clientY
|
|
1755
|
-
});
|
|
1756
|
-
if (!mousePos) return null;
|
|
1757
|
-
return mousePos ? cellAround(view.state.doc.resolve(mousePos.pos)) : null;
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
// src/tableview.ts
|
|
1761
|
-
var TableView = class {
|
|
1762
|
-
constructor(node, defaultCellMinWidth) {
|
|
1763
|
-
this.node = node;
|
|
1764
|
-
this.defaultCellMinWidth = defaultCellMinWidth;
|
|
1765
|
-
this.dom = document.createElement("div");
|
|
1766
|
-
this.dom.className = "tableWrapper";
|
|
1767
|
-
this.table = this.dom.appendChild(document.createElement("table"));
|
|
1768
|
-
this.table.style.setProperty(
|
|
1769
|
-
"--default-cell-min-width",
|
|
1770
|
-
`${defaultCellMinWidth}px`
|
|
1771
|
-
);
|
|
1772
|
-
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
1773
|
-
updateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);
|
|
1774
|
-
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
1775
|
-
}
|
|
1776
|
-
update(node) {
|
|
1777
|
-
if (node.type != this.node.type) return false;
|
|
1778
|
-
this.node = node;
|
|
1779
|
-
updateColumnsOnResize(
|
|
1780
|
-
node,
|
|
1781
|
-
this.colgroup,
|
|
1782
|
-
this.table,
|
|
1783
|
-
this.defaultCellMinWidth
|
|
1784
|
-
);
|
|
1785
|
-
return true;
|
|
1786
|
-
}
|
|
1787
|
-
ignoreMutation(record) {
|
|
1788
|
-
return record.type == "attributes" && (record.target == this.table || this.colgroup.contains(record.target));
|
|
1789
|
-
}
|
|
1790
|
-
};
|
|
1791
|
-
function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {
|
|
1792
|
-
var _a;
|
|
1793
|
-
let totalWidth = 0;
|
|
1794
|
-
let fixedWidth = true;
|
|
1795
|
-
let nextDOM = colgroup.firstChild;
|
|
1796
|
-
const row = node.firstChild;
|
|
1797
|
-
if (!row) return;
|
|
1798
|
-
for (let i = 0, col = 0; i < row.childCount; i++) {
|
|
1799
|
-
const { colspan, colwidth } = row.child(i).attrs;
|
|
1800
|
-
for (let j = 0; j < colspan; j++, col++) {
|
|
1801
|
-
const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];
|
|
1802
|
-
const cssWidth = hasWidth ? hasWidth + "px" : "";
|
|
1803
|
-
totalWidth += hasWidth || defaultCellMinWidth;
|
|
1804
|
-
if (!hasWidth) fixedWidth = false;
|
|
1805
|
-
if (!nextDOM) {
|
|
1806
|
-
const col2 = document.createElement("col");
|
|
1807
|
-
col2.style.width = cssWidth;
|
|
1808
|
-
colgroup.appendChild(col2);
|
|
1809
|
-
} else {
|
|
1810
|
-
if (nextDOM.style.width != cssWidth) {
|
|
1811
|
-
nextDOM.style.width = cssWidth;
|
|
1812
|
-
}
|
|
1813
|
-
nextDOM = nextDOM.nextSibling;
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
while (nextDOM) {
|
|
1818
|
-
const after = nextDOM.nextSibling;
|
|
1819
|
-
(_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);
|
|
1820
|
-
nextDOM = after;
|
|
1821
|
-
}
|
|
1822
|
-
if (fixedWidth) {
|
|
1823
|
-
table.style.width = totalWidth + "px";
|
|
1824
|
-
table.style.minWidth = "";
|
|
1825
|
-
} else {
|
|
1826
|
-
table.style.width = "";
|
|
1827
|
-
table.style.minWidth = totalWidth + "px";
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
// src/columnresizing.ts
|
|
1832
|
-
var columnResizingPluginKey = new PluginKey(
|
|
1833
|
-
"tableColumnResizing"
|
|
1834
|
-
);
|
|
1835
|
-
function columnResizing({
|
|
1836
|
-
handleWidth = 5,
|
|
1837
|
-
cellMinWidth = 25,
|
|
1838
|
-
defaultCellMinWidth = 100,
|
|
1839
|
-
View = TableView,
|
|
1840
|
-
lastColumnResizable = true
|
|
1841
|
-
} = {}) {
|
|
1842
|
-
const plugin = new Plugin({
|
|
1843
|
-
key: columnResizingPluginKey,
|
|
1844
|
-
state: {
|
|
1845
|
-
init(_, state) {
|
|
1846
|
-
var _a, _b;
|
|
1847
|
-
const nodeViews = (_b = (_a = plugin.spec) == null ? void 0 : _a.props) == null ? void 0 : _b.nodeViews;
|
|
1848
|
-
const tableName = tableNodeTypes(state.schema).table.name;
|
|
1849
|
-
if (View && nodeViews) {
|
|
1850
|
-
nodeViews[tableName] = (node, view) => {
|
|
1851
|
-
return new View(node, defaultCellMinWidth, view);
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
return new ResizeState(-1, false);
|
|
1855
|
-
},
|
|
1856
|
-
apply(tr, prev) {
|
|
1857
|
-
return prev.apply(tr);
|
|
1858
|
-
}
|
|
1859
|
-
},
|
|
1860
|
-
props: {
|
|
1861
|
-
attributes: (state) => {
|
|
1862
|
-
const pluginState = columnResizingPluginKey.getState(state);
|
|
1863
|
-
return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
1864
|
-
},
|
|
1865
|
-
handleDOMEvents: {
|
|
1866
|
-
mousemove: (view, event) => {
|
|
1867
|
-
handleMouseMove(view, event, handleWidth, lastColumnResizable);
|
|
1868
|
-
},
|
|
1869
|
-
mouseleave: (view) => {
|
|
1870
|
-
handleMouseLeave(view);
|
|
1871
|
-
},
|
|
1872
|
-
mousedown: (view, event) => {
|
|
1873
|
-
handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth);
|
|
1874
|
-
}
|
|
1875
|
-
},
|
|
1876
|
-
decorations: (state) => {
|
|
1877
|
-
const pluginState = columnResizingPluginKey.getState(state);
|
|
1878
|
-
if (pluginState && pluginState.activeHandle > -1) {
|
|
1879
|
-
return handleDecorations(state, pluginState.activeHandle);
|
|
1880
|
-
}
|
|
1881
|
-
},
|
|
1882
|
-
nodeViews: {}
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
return plugin;
|
|
1886
|
-
}
|
|
1887
|
-
var ResizeState = class _ResizeState {
|
|
1888
|
-
constructor(activeHandle, dragging) {
|
|
1889
|
-
this.activeHandle = activeHandle;
|
|
1890
|
-
this.dragging = dragging;
|
|
1891
|
-
}
|
|
1892
|
-
apply(tr) {
|
|
1893
|
-
const state = this;
|
|
1894
|
-
const action = tr.getMeta(columnResizingPluginKey);
|
|
1895
|
-
if (action && action.setHandle != null)
|
|
1896
|
-
return new _ResizeState(action.setHandle, false);
|
|
1897
|
-
if (action && action.setDragging !== void 0)
|
|
1898
|
-
return new _ResizeState(state.activeHandle, action.setDragging);
|
|
1899
|
-
if (state.activeHandle > -1 && tr.docChanged) {
|
|
1900
|
-
let handle = tr.mapping.map(state.activeHandle, -1);
|
|
1901
|
-
if (!pointsAtCell(tr.doc.resolve(handle))) {
|
|
1902
|
-
handle = -1;
|
|
1903
|
-
}
|
|
1904
|
-
return new _ResizeState(handle, state.dragging);
|
|
1905
|
-
}
|
|
1906
|
-
return state;
|
|
1907
|
-
}
|
|
1908
|
-
};
|
|
1909
|
-
function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
1910
|
-
if (!view.editable) return;
|
|
1911
|
-
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
1912
|
-
if (!pluginState) return;
|
|
1913
|
-
if (!pluginState.dragging) {
|
|
1914
|
-
const target = domCellAround(event.target);
|
|
1915
|
-
let cell = -1;
|
|
1916
|
-
if (target) {
|
|
1917
|
-
const { left, right } = target.getBoundingClientRect();
|
|
1918
|
-
if (event.clientX - left <= handleWidth)
|
|
1919
|
-
cell = edgeCell(view, event, "left", handleWidth);
|
|
1920
|
-
else if (right - event.clientX <= handleWidth)
|
|
1921
|
-
cell = edgeCell(view, event, "right", handleWidth);
|
|
1922
|
-
}
|
|
1923
|
-
if (cell != pluginState.activeHandle) {
|
|
1924
|
-
if (!lastColumnResizable && cell !== -1) {
|
|
1925
|
-
const $cell = view.state.doc.resolve(cell);
|
|
1926
|
-
const table = $cell.node(-1);
|
|
1927
|
-
const map = TableMap.get(table);
|
|
1928
|
-
const tableStart = $cell.start(-1);
|
|
1929
|
-
const col = map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1;
|
|
1930
|
-
if (col == map.width - 1) {
|
|
1931
|
-
return;
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
updateHandle(view, cell);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
function handleMouseLeave(view) {
|
|
1939
|
-
if (!view.editable) return;
|
|
1940
|
-
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
1941
|
-
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)
|
|
1942
|
-
updateHandle(view, -1);
|
|
1943
|
-
}
|
|
1944
|
-
function handleMouseDown2(view, event, cellMinWidth, defaultCellMinWidth) {
|
|
1945
|
-
var _a;
|
|
1946
|
-
if (!view.editable) return false;
|
|
1947
|
-
const win = (_a = view.dom.ownerDocument.defaultView) != null ? _a : window;
|
|
1948
|
-
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
1949
|
-
if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)
|
|
1950
|
-
return false;
|
|
1951
|
-
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
1952
|
-
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
|
|
1953
|
-
view.dispatch(
|
|
1954
|
-
view.state.tr.setMeta(columnResizingPluginKey, {
|
|
1955
|
-
setDragging: { startX: event.clientX, startWidth: width }
|
|
1956
|
-
})
|
|
1957
|
-
);
|
|
1958
|
-
function finish(event2) {
|
|
1959
|
-
win.removeEventListener("mouseup", finish);
|
|
1960
|
-
win.removeEventListener("mousemove", move);
|
|
1961
|
-
const pluginState2 = columnResizingPluginKey.getState(view.state);
|
|
1962
|
-
if (pluginState2 == null ? void 0 : pluginState2.dragging) {
|
|
1963
|
-
updateColumnWidth(
|
|
1964
|
-
view,
|
|
1965
|
-
pluginState2.activeHandle,
|
|
1966
|
-
draggedWidth(pluginState2.dragging, event2, cellMinWidth)
|
|
1967
|
-
);
|
|
1968
|
-
view.dispatch(
|
|
1969
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })
|
|
1970
|
-
);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
function move(event2) {
|
|
1974
|
-
if (!event2.which) return finish(event2);
|
|
1975
|
-
const pluginState2 = columnResizingPluginKey.getState(view.state);
|
|
1976
|
-
if (!pluginState2) return;
|
|
1977
|
-
if (pluginState2.dragging) {
|
|
1978
|
-
const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth);
|
|
1979
|
-
displayColumnWidth(
|
|
1980
|
-
view,
|
|
1981
|
-
pluginState2.activeHandle,
|
|
1982
|
-
dragged,
|
|
1983
|
-
defaultCellMinWidth
|
|
1984
|
-
);
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
displayColumnWidth(
|
|
1988
|
-
view,
|
|
1989
|
-
pluginState.activeHandle,
|
|
1990
|
-
width,
|
|
1991
|
-
defaultCellMinWidth
|
|
1992
|
-
);
|
|
1993
|
-
win.addEventListener("mouseup", finish);
|
|
1994
|
-
win.addEventListener("mousemove", move);
|
|
1995
|
-
event.preventDefault();
|
|
1996
|
-
return true;
|
|
1997
|
-
}
|
|
1998
|
-
function currentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
1999
|
-
const width = colwidth && colwidth[colwidth.length - 1];
|
|
2000
|
-
if (width) return width;
|
|
2001
|
-
const dom = view.domAtPos(cellPos);
|
|
2002
|
-
const node = dom.node.childNodes[dom.offset];
|
|
2003
|
-
let domWidth = node.offsetWidth, parts = colspan;
|
|
2004
|
-
if (colwidth) {
|
|
2005
|
-
for (let i = 0; i < colspan; i++)
|
|
2006
|
-
if (colwidth[i]) {
|
|
2007
|
-
domWidth -= colwidth[i];
|
|
2008
|
-
parts--;
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
return domWidth / parts;
|
|
2012
|
-
}
|
|
2013
|
-
function domCellAround(target) {
|
|
2014
|
-
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
2015
|
-
target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
2016
|
-
return target;
|
|
2017
|
-
}
|
|
2018
|
-
function edgeCell(view, event, side, handleWidth) {
|
|
2019
|
-
const offset = side == "right" ? -handleWidth : handleWidth;
|
|
2020
|
-
const found = view.posAtCoords({
|
|
2021
|
-
left: event.clientX + offset,
|
|
2022
|
-
top: event.clientY
|
|
2023
|
-
});
|
|
2024
|
-
if (!found) return -1;
|
|
2025
|
-
const { pos } = found;
|
|
2026
|
-
const $cell = cellAround(view.state.doc.resolve(pos));
|
|
2027
|
-
if (!$cell) return -1;
|
|
2028
|
-
if (side == "right") return $cell.pos;
|
|
2029
|
-
const map = TableMap.get($cell.node(-1)), start = $cell.start(-1);
|
|
2030
|
-
const index = map.map.indexOf($cell.pos - start);
|
|
2031
|
-
return index % map.width == 0 ? -1 : start + map.map[index - 1];
|
|
2032
|
-
}
|
|
2033
|
-
function draggedWidth(dragging, event, resizeMinWidth) {
|
|
2034
|
-
const offset = event.clientX - dragging.startX;
|
|
2035
|
-
return Math.max(resizeMinWidth, dragging.startWidth + offset);
|
|
2036
|
-
}
|
|
2037
|
-
function updateHandle(view, value) {
|
|
2038
|
-
view.dispatch(
|
|
2039
|
-
view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })
|
|
2040
|
-
);
|
|
2041
|
-
}
|
|
2042
|
-
function updateColumnWidth(view, cell, width) {
|
|
2043
|
-
const $cell = view.state.doc.resolve(cell);
|
|
2044
|
-
const table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
|
|
2045
|
-
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
2046
|
-
const tr = view.state.tr;
|
|
2047
|
-
for (let row = 0; row < map.height; row++) {
|
|
2048
|
-
const mapIndex = row * map.width + col;
|
|
2049
|
-
if (row && map.map[mapIndex] == map.map[mapIndex - map.width]) continue;
|
|
2050
|
-
const pos = map.map[mapIndex];
|
|
2051
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
2052
|
-
const index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);
|
|
2053
|
-
if (attrs.colwidth && attrs.colwidth[index] == width) continue;
|
|
2054
|
-
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
|
|
2055
|
-
colwidth[index] = width;
|
|
2056
|
-
tr.setNodeMarkup(start + pos, null, { ...attrs, colwidth });
|
|
2057
|
-
}
|
|
2058
|
-
if (tr.docChanged) view.dispatch(tr);
|
|
2059
|
-
}
|
|
2060
|
-
function displayColumnWidth(view, cell, width, defaultCellMinWidth) {
|
|
2061
|
-
const $cell = view.state.doc.resolve(cell);
|
|
2062
|
-
const table = $cell.node(-1), start = $cell.start(-1);
|
|
2063
|
-
const col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
2064
|
-
let dom = view.domAtPos($cell.start(-1)).node;
|
|
2065
|
-
while (dom && dom.nodeName != "TABLE") {
|
|
2066
|
-
dom = dom.parentNode;
|
|
2067
|
-
}
|
|
2068
|
-
if (!dom) return;
|
|
2069
|
-
updateColumnsOnResize(
|
|
2070
|
-
table,
|
|
2071
|
-
dom.firstChild,
|
|
2072
|
-
dom,
|
|
2073
|
-
defaultCellMinWidth,
|
|
2074
|
-
col,
|
|
2075
|
-
width
|
|
2076
|
-
);
|
|
2077
|
-
}
|
|
2078
|
-
function zeroes(n) {
|
|
2079
|
-
return Array(n).fill(0);
|
|
2080
|
-
}
|
|
2081
|
-
function handleDecorations(state, cell) {
|
|
2082
|
-
var _a;
|
|
2083
|
-
const decorations = [];
|
|
2084
|
-
const $cell = state.doc.resolve(cell);
|
|
2085
|
-
const table = $cell.node(-1);
|
|
2086
|
-
if (!table) {
|
|
2087
|
-
return DecorationSet.empty;
|
|
2088
|
-
}
|
|
2089
|
-
const map = TableMap.get(table);
|
|
2090
|
-
const start = $cell.start(-1);
|
|
2091
|
-
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
2092
|
-
for (let row = 0; row < map.height; row++) {
|
|
2093
|
-
const index = col + row * map.width;
|
|
2094
|
-
if ((col == map.width - 1 || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index] != map.map[index - map.width])) {
|
|
2095
|
-
const cellPos = map.map[index];
|
|
2096
|
-
const pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
2097
|
-
const dom = document.createElement("div");
|
|
2098
|
-
dom.className = "column-resize-handle";
|
|
2099
|
-
if ((_a = columnResizingPluginKey.getState(state)) == null ? void 0 : _a.dragging) {
|
|
2100
|
-
decorations.push(
|
|
2101
|
-
Decoration.node(
|
|
2102
|
-
start + cellPos,
|
|
2103
|
-
start + cellPos + table.nodeAt(cellPos).nodeSize,
|
|
2104
|
-
{
|
|
2105
|
-
class: "column-resize-dragging"
|
|
2106
|
-
}
|
|
2107
|
-
)
|
|
2108
|
-
);
|
|
2109
|
-
}
|
|
2110
|
-
decorations.push(Decoration.widget(pos, dom));
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return DecorationSet.create(state.doc, decorations);
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
// src/index.ts
|
|
2117
|
-
function tableEditing({
|
|
2118
|
-
allowTableNodeSelection = false
|
|
2119
|
-
} = {}) {
|
|
2120
|
-
return new Plugin({
|
|
2121
|
-
key: tableEditingKey,
|
|
2122
|
-
// This piece of state is used to remember when a mouse-drag
|
|
2123
|
-
// cell-selection is happening, so that it can continue even as
|
|
2124
|
-
// transactions (which might move its anchor cell) come in.
|
|
2125
|
-
state: {
|
|
2126
|
-
init() {
|
|
2127
|
-
return null;
|
|
2128
|
-
},
|
|
2129
|
-
apply(tr, cur) {
|
|
2130
|
-
const set = tr.getMeta(tableEditingKey);
|
|
2131
|
-
if (set != null) return set == -1 ? null : set;
|
|
2132
|
-
if (cur == null || !tr.docChanged) return cur;
|
|
2133
|
-
const { deleted, pos } = tr.mapping.mapResult(cur);
|
|
2134
|
-
return deleted ? null : pos;
|
|
2135
|
-
}
|
|
2136
|
-
},
|
|
2137
|
-
props: {
|
|
2138
|
-
decorations: drawCellSelection,
|
|
2139
|
-
handleDOMEvents: {
|
|
2140
|
-
mousedown: handleMouseDown
|
|
2141
|
-
},
|
|
2142
|
-
createSelectionBetween(view) {
|
|
2143
|
-
return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
|
|
2144
|
-
},
|
|
2145
|
-
handleTripleClick,
|
|
2146
|
-
handleKeyDown,
|
|
2147
|
-
handlePaste
|
|
2148
|
-
},
|
|
2149
|
-
appendTransaction(_, oldState, state) {
|
|
2150
|
-
return normalizeSelection(
|
|
2151
|
-
state,
|
|
2152
|
-
fixTables(state, oldState),
|
|
2153
|
-
allowTableNodeSelection
|
|
2154
|
-
);
|
|
2155
|
-
}
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
export { CellSelection as C, splitCell as a, toggleHeaderCell as b, columnResizing as c, toggleHeader as d, deleteTable as e, fixTables as f, goToNextCell as g, deleteRow as h, addRowAfter as i, addRowBefore as j, deleteColumn as k, addColumnAfter as l, mergeCells as m, addColumnBefore as n, setCellAttr as s, tableEditing as t };
|