@aquera/nile-elements 1.9.8 → 1.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/{index-249de90a.esm.js → index-289706c7.esm.js} +1 -1
- package/dist/{index-df196058.cjs.js → index-d7e6f1c6.cjs.js} +2 -2
- package/dist/index-d7e6f1c6.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1577 -1275
- package/dist/katex-44476ab4.esm.js +1 -0
- package/dist/katex-f4186f87.cjs.js +2 -0
- package/dist/katex-f4186f87.cjs.js.map +1 -0
- package/dist/nile-color-picker/index.cjs.js +1 -1
- package/dist/nile-color-picker/index.esm.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js.map +1 -1
- package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +22 -3
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +7 -6
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +33 -54
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +83 -95
- package/dist/nile-wysiwyg-editor/types.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/types.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/types.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +23 -15
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +3 -3
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +2 -2
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +0 -3
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/preview.esm.js +8 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +225 -24
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +9 -9
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +115 -13
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +13 -12
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-color-picker/nile-color-picker.d.ts +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js +3 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.d.ts +19 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js +23 -18
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.d.ts +8 -3
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js +41 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.d.ts +17 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js +174 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +33 -2
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +49 -8
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +12 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +76 -8
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.js +154 -2
- package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/index.d.ts +5 -0
- package/dist/src/nile-wysiwyg-editor/index.js +3 -0
- package/dist/src/nile-wysiwyg-editor/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.d.ts +38 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js +40 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +22 -3
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +36 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +125 -8
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +5 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.d.ts +55 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js +79 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +33 -54
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.d.ts +50 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js +158 -102
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/types.d.ts +4 -2
- package/dist/src/nile-wysiwyg-editor/types.js +2 -2
- package/dist/src/nile-wysiwyg-editor/types.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.d.ts +48 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js +69 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.d.ts +17 -2
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +128 -35
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.d.ts +2 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +4 -3
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +0 -3
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/preview.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js +44 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.d.ts +35 -3
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js +337 -24
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +9 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.d.ts +13 -2
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +166 -10
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +10 -8
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/xml-25c4108a.esm.js +1 -0
- package/dist/xml-90fd974e.cjs.js +2 -0
- package/dist/xml-90fd974e.cjs.js.map +1 -0
- package/package.json +2 -1
- package/rollup.config.js +1 -0
- package/src/index.ts +8 -0
- package/src/nile-color-picker/nile-color-picker.ts +1 -0
- package/src/nile-wysiwyg-editor/engine/index.ts +1 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embed-view.ts +3 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embeds.ts +26 -20
- package/src/nile-wysiwyg-editor/engine/plugins/math-view.ts +45 -4
- package/src/nile-wysiwyg-editor/engine/plugins/style-block-view.ts +178 -0
- package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +34 -2
- package/src/nile-wysiwyg-editor/engine/pm.test.ts +58 -8
- package/src/nile-wysiwyg-editor/engine/sanitize.ts +71 -8
- package/src/nile-wysiwyg-editor/engine/schema.ts +158 -7
- package/src/nile-wysiwyg-editor/index.ts +5 -0
- package/src/nile-wysiwyg-editor/math/katex-renderer.ts +59 -0
- package/src/nile-wysiwyg-editor/math/katex.d.ts +17 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +22 -3
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +5 -2
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +142 -7
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.ts +2 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.ts +68 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +33 -54
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.ts +202 -108
- package/src/nile-wysiwyg-editor/types.ts +6 -4
- package/src/nile-wysiwyg-editor/ui/bubble-item.ts +60 -0
- package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +147 -40
- package/src/nile-wysiwyg-editor/ui/embed-panel.ts +4 -3
- package/src/nile-wysiwyg-editor/ui/math-panel.ts +0 -3
- package/src/nile-wysiwyg-editor/ui/preview.ts +42 -0
- package/src/nile-wysiwyg-editor/ui/source-view.ts +339 -31
- package/src/nile-wysiwyg-editor/ui/suggest-list.ts +10 -0
- package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +160 -10
- package/src/nile-wysiwyg-editor/ui/table-menu.ts +10 -8
- package/vscode-html-custom-data.json +75 -6
- package/dist/index-df196058.cjs.js.map +0 -1
package/README.md
CHANGED
|
@@ -79,6 +79,9 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
|
79
79
|
|
|
80
80
|
In this section, you can find the updates for each release of `nile-elements`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
|
|
81
81
|
|
|
82
|
+
#### Version 1.9.9 (July 20, 2026)
|
|
83
|
+
- Nile WYSIWYG Editor: Updates in Editor related to Bubble Menu and Source View (UIF-1307)
|
|
84
|
+
|
|
82
85
|
#### Version 1.9.8 (July 16, 2026)
|
|
83
86
|
- Nile Virtual Select: Added Parts for Nile Option in Nile Virtual Select (UIF-1306)
|
|
84
87
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t,P as n,S as e,k as o,T as r,F as i,d as l,c as s,m as c}from"./index-6f3fa4ab.esm.js";import{D as f,a as u}from"./index-353172ed.esm.js";import{k as a,b as h}from"./index-920675c4.esm.js";const w="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function p(t){let n,e,o,r,i=t.split(/-(?!$)/),l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;t++){let l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))e=!0;else if(/^s(hift)?$/i.test(l))o=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);w?r=!0:e=!0}}return n&&(l="Alt-"+l),e&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l}function m(t,n,e=!0){return n.altKey&&(t="Alt-"+t),n.ctrlKey&&(t="Ctrl-"+t),n.metaKey&&(t="Meta-"+t),e&&n.shiftKey&&(t="Shift-"+t),t}function g(n){return new t({props:{handleKeyDown:b(n)}})}function b(t){let n=function(t){let n=Object.create(null);for(let e in t)n[p(e)]=t[e];return n}(t);return function(t,e){let o,r=a(e),i=n[m(r,e)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(e.shiftKey){let o=n[m(r,e,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((e.altKey||e.metaKey||e.ctrlKey)&&!(d&&e.ctrlKey&&e.altKey)&&(o=h[e.keyCode])&&o!=r){let r=n[m(o,e)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}let v,M;if("undefined"!=typeof WeakMap){let t=new WeakMap;v=n=>t.get(n),M=(n,e)=>(t.set(n,e),e)}else{const t=[],n=10;let e=0;v=n=>{for(let e=0;e<t.length;e+=2)if(t[e]==n)return t[e+1]},M=(o,r)=>(e==n&&(e=0),t[e++]=o,t[e++]=r)}var y=class{constructor(t,n,e,o){this.width=t,this.height=n,this.map=e,this.problems=o}findCell(t){for(let n=0;n<this.map.length;n++){const e=this.map[n];if(e!=t)continue;const o=n%this.width,r=n/this.width|0;let i=o+1,l=r+1;for(let t=1;i<this.width&&this.map[n+t]==e;t++)i++;for(let t=1;l<this.height&&this.map[n+this.width*t]==e;t++)l++;return{left:o,top:r,right:i,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let n=0;n<this.map.length;n++)if(this.map[n]==t)return n%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,n,e){const{left:o,right:r,top:i,bottom:l}=this.findCell(t);return"horiz"==n?(e<0?0==o:r==this.width)?null:this.map[i*this.width+(e<0?o-1:r)]:(e<0?0==i:l==this.height)?null:this.map[o+this.width*(e<0?i-1:l)]}rectBetween(t,n){const{left:e,right:o,top:r,bottom:i}=this.findCell(t),{left:l,right:s,top:c,bottom:f}=this.findCell(n);return{left:Math.min(e,l),top:Math.min(r,c),right:Math.max(o,s),bottom:Math.max(i,f)}}cellsInRect(t){const n=[],e={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,l=this.map[i];e[l]||(e[l]=!0,r==t.left&&r&&this.map[i-1]==l||o==t.top&&o&&this.map[i-this.width]==l||n.push(l))}return n}positionAt(t,n,e){for(let o=0,r=0;;o++){const i=r+e.child(o).nodeSize;if(o==t){let e=n+t*this.width;const o=(t+1)*this.width;for(;e<o&&this.map[e]<r;)e++;return e==o?i-1:this.map[e]}r=i}}static get(t){return v(t)||M(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const n=function(t){let n=-1,e=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(e)for(let n=0;n<o;n++){const e=t.child(n);for(let t=0;t<e.childCount;t++){const r=e.child(t);n+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const n=r.child(t);i+=n.attrs.colspan,n.attrs.rowspan>1&&(e=!0)}-1==n?n=i:n!=i&&(n=Math.max(n,i))}return n}(t),e=t.childCount,o=[];let r=0,i=null;const l=[];for(let t=0,r=n*e;t<r;t++)o[t]=0;for(let s=0,c=0;s<e;s++){const f=t.child(s);c++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==f.childCount)break;const u=f.child(t),{colspan:a,rowspan:h,colwidth:w}=u.attrs;for(let t=0;t<h;t++){if(t+s>=e){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:h-t});break}const f=r+t*n;for(let t=0;t<a;t++){0==o[f+t]?o[f+t]=c:(i||(i=[])).push({type:"collision",row:s,pos:c,n:a-t});const e=w&&w[t];if(e){const o=(f+t)%n*2,r=l[o];null==r||r!=e&&1==l[o+1]?(l[o]=e,l[o+1]=1):r==e&&l[o+1]++}}}r+=a,c+=u.nodeSize}const u=(s+1)*n;let a=0;for(;r<u;)0==o[r++]&&a++;a&&(i||(i=[])).push({type:"missing",row:s,n:a}),c++}0!==n&&0!==e||(i||(i=[])).push({type:"zero_sized"});const s=new y(n,e,o,i);let c=!1;for(let t=0;!c&&t<l.length;t+=2)null!=l[t]&&l[t+1]<e&&(c=!0);c&&function(t,n,e){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const l=e.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let s=null;const c=l.attrs;for(let e=0;e<c.colspan;e++){const o=n[(r+e)%t.width*2];null==o||c.colwidth&&c.colwidth[e]==o||((s||(s=D(c)))[e]=o)}s&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}(s,l,t);return s}(t))}};function D(t){if(t.colwidth)return t.colwidth.slice();const n=[];for(let e=0;e<t.colspan;e++)n.push(0);return n}function S(t,n){if("string"==typeof t)return{};const e=t.getAttribute("data-colwidth"),o=e&&/^\d+(,\d+)*$/.test(e)?e.split(",").map((t=>Number(t))):null,r=Number(t.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const e in n){const o=n[e].getFromDOM,r=o&&o(t);null!=r&&(i[e]=r)}return i}function $(t,n){const e={};1!=t.attrs.colspan&&(e.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(e.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(e["data-colwidth"]=t.attrs.colwidth.join(","));for(const o in n){const r=n[o].setDOMAttr;r&&r(t.attrs[o],e)}return e}function E(t){if(null!==t){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");for(const n of t)if("number"!=typeof n)throw new TypeError("colwidth must be null or an array of numbers")}}function R(t){const n=t.cellAttributes||{},e={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:E}};for(const t in n)e[t]={default:n[t].default,validate:n[t].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:e,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>S(t,n)}],toDOM:t=>["td",$(t,n),0]},table_header:{content:t.cellContent,attrs:e,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>S(t,n)}],toDOM:t=>["th",$(t,n),0]}}}function _(t){let n=t.cached.tableNodeTypes;if(!n){n=t.cached.tableNodeTypes={};for(const e in t.nodes){const o=t.nodes[e],r=o.spec.tableRole;r&&(n[r]=o)}}return n}const N=new n("selectingCells");function z(t){for(let n=t.depth-1;n>0;n--)if("row"==t.node(n).type.spec.tableRole)return t.node(0).resolve(t.before(n+1));return null}function k(t){const n=t.selection.$head;for(let t=n.depth;t>0;t--)if("row"==n.node(t).type.spec.tableRole)return!0;return!1}function A(t){const n=t.selection;if("$anchorCell"in n&&n.$anchorCell)return n.$anchorCell.pos>n.$headCell.pos?n.$anchorCell:n.$headCell;if("node"in n&&n.node&&"cell"==n.node.type.spec.tableRole)return n.$anchor;const e=z(n.$head)||function(t){for(let n=t.nodeAfter,e=t.pos;n;n=n.firstChild,e++){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e)}for(let n=t.nodeBefore,e=t.pos;n;n=n.lastChild,e--){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e-n.nodeSize)}}(n.$head);if(e)return e;throw new RangeError(`No cell found around position ${n.head}`)}function C(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function O(t,n){return t.depth==n.depth&&t.pos>=n.start(-1)&&t.pos<=n.end(-1)}function x(t,n,e){const o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.nextCell(t.pos-i,n,e);return null==l?null:t.node(0).resolve(i+l)}function T(t,n,e=1){const o={...t,colspan:t.colspan-e};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(n,e),o.colwidth.some((t=>t>0))||(o.colwidth=null)),o}function W(t,n,e=1){const o={...t,colspan:t.colspan+e};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<e;t++)o.colwidth.splice(n,0,0)}return o}var L=class t extends e{constructor(t,n=t){const e=t.node(-1),r=y.get(e),i=t.start(-1),l=r.rectBetween(t.pos-i,n.pos-i),s=t.node(0),c=r.cellsInRect(l).filter((t=>t!=n.pos-i));c.unshift(n.pos-i);const f=c.map((t=>{const n=e.nodeAt(t);if(!n)throw new RangeError(`No cell with offset ${t} found`);const r=i+t+1;return new o(s.resolve(r),s.resolve(r+n.content.size))}));super(f[0].$from,f[0].$to,f),this.$anchorCell=t,this.$headCell=n}map(n,e){const o=n.resolve(e.map(this.$anchorCell.pos)),i=n.resolve(e.map(this.$headCell.pos));if(C(o)&&C(i)&&O(o,i)){const n=this.$anchorCell.node(-1)!=o.node(-1);return n&&this.isRowSelection()?t.rowSelection(o,i):n&&this.isColSelection()?t.colSelection(o,i):new t(o,i)}return r.between(o,i)}content(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-e,this.$headCell.pos-e),r={},s=[];for(let e=o.top;e<o.bottom;e++){const l=[];for(let i=e*n.width+o.left,s=o.left;s<o.right;s++,i++){const e=n.map[i];if(r[e])continue;r[e]=!0;const s=n.findCell(e);let c=t.nodeAt(e);if(!c)throw new RangeError(`No cell with offset ${e} found`);const f=o.left-s.left,u=s.right-o.right;if(f>0||u>0){let t=c.attrs;if(f>0&&(t=T(t,0,f)),u>0&&(t=T(t,t.colspan-u,u)),s.left<o.left){if(c=c.type.createAndFill(t),!c)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else c=c.type.create(t,c.content)}if(s.top<o.top||s.bottom>o.bottom){const t={...c.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};c=s.top<o.top?c.type.createAndFill(t):c.type.create(t,c.content)}l.push(c)}s.push(t.child(e).copy(i.from(l)))}const c=this.isColSelection()&&this.isRowSelection()?t:s;return new l(i.from(c),1,1)}replace(t,n=l.empty){const o=t.steps.length,r=this.ranges;for(let e=0;e<r.length;e++){const{$from:i,$to:s}=r[e],c=t.mapping.slice(o);t.replace(c.map(i.pos),c.map(s.pos),e?l.empty:n)}const i=e.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new l(i.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),e=y.get(n),o=this.$anchorCell.start(-1),r=e.cellsInRect(e.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let e=0;e<r.length;e++)t(n.nodeAt(r[e]),o+r[e])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const e=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(e,o)==this.$headCell.node(-1).childCount}static colSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.top<=s.top?(l.top>0&&(n=c.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=c.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(e=c.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=c.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new t(n,e)}isRowSelection(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-e),r=n.colCount(this.$headCell.pos-e);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width}eq(n){return n instanceof t&&n.$anchorCell.pos==this.$anchorCell.pos&&n.$headCell.pos==this.$headCell.pos}static rowSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.left<=s.left?(l.left>0&&(n=c.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=c.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(e=c.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=c.resolve(i+r.map[r.width*(l.top+1)-1]))),new t(n,e)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(n,e){return new t(n.resolve(e.anchor),n.resolve(e.head))}static create(n,e,o=e){return new t(n.resolve(e),n.resolve(o))}getBookmark(){return new B(this.$anchorCell.pos,this.$headCell.pos)}};L.prototype.visible=!1,e.jsonID("cell",L);var B=class t{constructor(t,n){this.anchor=t,this.head=n}map(n){return new t(n.map(this.anchor),n.map(this.head))}resolve(t){const n=t.resolve(this.anchor),o=t.resolve(this.head);return"row"==n.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&O(n,o)?new L(n,o):e.near(o,1)}};function j(t){if(!(t.selection instanceof L))return null;const n=[];return t.selection.forEachCell(((t,e)=>{n.push(u.node(e,e+t.nodeSize,{class:"selectedCell"}))})),f.create(t.doc,n)}const P=new n("fix-tables");function H(t,n,e,o){const r=t.childCount,i=n.childCount;t:for(let l=0,s=0;l<i;l++){const i=n.child(l);for(let n=s,o=Math.min(r,l+3);n<o;n++)if(t.child(n)==i){s=n+1,e+=i.nodeSize;continue t}o(i,e),s<r&&t.child(s).sameMarkup(i)?H(t.child(s),i,e+1,o):i.nodesBetween(0,i.content.size,o,e+1),e+=i.nodeSize}}function J(t,n){let e;const o=(n,o)=>{"table"==n.type.spec.tableRole&&(e=function(t,n,e,o){const r=y.get(n);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const l=r.problems[t];if("collision"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[l.row+t]+=l.n;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,T(r,r.colspan-l.n,l.n))}else if("missing"==l.type)i[l.row]+=l.n;else if("overlong_rowspan"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if("colwidth mismatch"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if("zero_sized"==l.type){const t=o.mapping.map(e);o.delete(t,t+n.nodeSize)}}let l,s;for(let t=0;t<i.length;t++)i[t]&&(null==l&&(l=t),s=t);for(let c=0,f=e+1;c<r.height;c++){const e=n.child(c),r=f+e.nodeSize,u=i[c];if(u>0){let n="cell";e.firstChild&&(n=e.firstChild.type.spec.tableRole);const i=[];for(let e=0;e<u;e++){const e=_(t.schema)[n].createAndFill();e&&i.push(e)}const a=0!=c&&l!=c-1||s!=c?r-1:f+1;o.insert(o.mapping.map(a),i)}f=r}return o.setMeta(P,{fixTables:!0})}(t,n,o,e))};return n?n.doc!=t.doc&&H(n.doc,t.doc,0,o):t.doc.descendants(o),e}function U(t){const n=t.selection,e=A(t),o=e.node(-1),r=e.start(-1),i=y.get(o);return{...n instanceof L?i.rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r):i.findCell(e.pos-r),tableStart:r,map:i,table:o}}function K(t,{map:n,tableStart:e,table:o},r){let i=r>0?-1:0;(function(t,n,e){const o=_(n.type.schema).header_cell;for(let r=0;r<t.height;r++)if(n.nodeAt(t.map[e+r*t.width]).type!=o)return!1;return!0})(n,o,r+i)&&(i=0==r||r==n.width?null:0);for(let l=0;l<n.height;l++){const s=l*n.width+r;if(r>0&&r<n.width&&n.map[s-1]==n.map[s]){const i=n.map[s],c=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(e+i),null,W(c.attrs,r-n.colCount(i))),l+=c.attrs.rowspan-1}else{const c=null==i?_(o.type.schema).cell:o.nodeAt(n.map[s+i]).type,f=n.positionAt(l,r,o);t.insert(t.mapping.map(e+f),c.createAndFill())}}return t}function V(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.left))}return!0}function q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.right))}return!0}function F(t,{map:n,table:e,tableStart:o},r){const i=t.mapping.maps.length;for(let l=0;l<n.height;){const s=l*n.width+r,c=n.map[s],f=e.nodeAt(c),u=f.attrs;if(r>0&&n.map[s-1]==c||r<n.width-1&&n.map[s+1]==c)t.setNodeMarkup(t.mapping.slice(i).map(o+c),null,T(u,r-n.colCount(c)));else{const n=t.mapping.slice(i).map(o+c);t.delete(n,n+f.nodeSize)}l+=u.rowspan}}function I(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.left&&e.right==e.map.width)return!1;for(let t=e.right-1;F(o,e,t),t!=e.left;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(t)}n(o)}return!0}function X(t,{map:n,tableStart:e,table:o},r){let i=e;for(let t=0;t<r;t++)i+=o.child(t).nodeSize;const l=[];let s=r>0?-1:0;(function(t,n,e){var o;const r=_(n.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null===(o=n.nodeAt(t.map[i+e*t.width]))||void 0===o?void 0:o.type)!=r)return!1;return!0})(n,o,r+s)&&(s=0==r||r==n.height?null:0);for(let i=0,f=n.width*r;i<n.width;i++,f++)if(r>0&&r<n.height&&n.map[f]==n.map[f-n.width]){const r=n.map[f],l=o.nodeAt(r).attrs;t.setNodeMarkup(e+r,null,{...l,rowspan:l.rowspan+1}),i+=l.colspan-1}else{var c;const t=null==s?_(o.type.schema).cell:null===(c=o.nodeAt(n.map[f+s*n.width]))||void 0===c?void 0:c.type,e=null==t?void 0:t.createAndFill();e&&l.push(e)}return t.insert(i,_(o.type.schema).row.create(null,l)),t}function G(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.top))}return!0}function Q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.bottom))}return!0}function Y(t,{map:n,table:e,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=e.child(t).nodeSize;const l=i+e.child(r).nodeSize,s=t.mapping.maps.length;t.delete(i+o,l+o);const c=new Set;for(let i=0,l=r*n.width;i<n.width;i++,l++){const f=n.map[l];if(!c.has(f))if(c.add(f),r>0&&f==n.map[l-n.width]){const n=e.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(s).map(f+o),null,{...n,rowspan:n.rowspan-1}),i+=n.colspan-1}else if(r<n.height&&f==n.map[l+n.width]){const l=e.nodeAt(f),c=l.attrs,u=l.type.create({...c,rowspan:l.attrs.rowspan-1},l.content),a=n.positionAt(r+1,i,e);t.insert(t.mapping.slice(s).map(o+a),u),i+=c.colspan-1}}}function Z(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.top&&e.bottom==e.map.height)return!1;for(let t=e.bottom-1;Y(o,e,t),t!=e.top;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(e.table)}n(o)}return!0}function tt(t){const n=t.content;return 1==n.childCount&&n.child(0).isTextblock&&0==n.child(0).childCount}function nt(t,n){const e=t.selection;if(!(e instanceof L)||e.$anchorCell.pos==e.$headCell.pos)return!1;const o=U(t),{map:r}=o;if(function({width:t,height:n,map:e},o){let r=o.top*t+o.left,i=r,l=(o.bottom-1)*t+o.left,s=r+(o.right-o.left-1);for(let n=o.top;n<o.bottom;n++){if(o.left>0&&e[i]==e[i-1]||o.right<t&&e[s]==e[s+1])return!0;i+=t,s+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&e[r]==e[r-t]||o.bottom<n&&e[l]==e[l+t])return!0;r++,l++}return!1}(r,o))return!1;if(n){const e=t.tr,l={};let s,c,f=i.empty;for(let t=o.top;t<o.bottom;t++)for(let n=o.left;n<o.right;n++){const i=r.map[t*r.width+n],u=o.table.nodeAt(i);if(!l[i]&&u)if(l[i]=!0,null==s)s=i,c=u;else{tt(u)||(f=f.append(u.content));const t=e.mapping.map(i+o.tableStart);e.delete(t,t+u.nodeSize)}}if(null==s||null==c)return!0;if(e.setNodeMarkup(s+o.tableStart,null,{...W(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),f.size>0){const t=s+1+c.content.size,n=tt(c)?s+1:t;e.replaceWith(n+o.tableStart,t+o.tableStart,f)}e.setSelection(new L(e.doc.resolve(s+o.tableStart))),n(e)}return!0}function et(t,n){const e=_(t.schema);return(o=({node:t})=>e[t.type.spec.tableRole],(t,n)=>{const e=t.selection;let r,i;if(e instanceof L){if(e.$anchorCell.pos!=e.$headCell.pos)return!1;r=e.$anchorCell.nodeAfter,i=e.$anchorCell.pos}else{var l;if(r=function(t){for(let n=t.depth;n>0;n--){const e=t.node(n).type.spec.tableRole;if("cell"===e||"header_cell"===e)return t.node(n)}return null}(e.$from),!r)return!1;i=null===(l=z(e.$from))||void 0===l?void 0:l.pos}if(null==r||null==i)return!1;if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){let l=r.attrs;const s=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const f=U(t),u=t.tr;for(let t=0;t<f.right-f.left;t++)s.push(c?{...l,colwidth:c&&c[t]?[c[t]]:null}:l);let a;for(let t=f.top;t<f.bottom;t++){let n=f.map.positionAt(t,f.left,f.table);t==f.top&&(n+=r.nodeSize);for(let e=f.left,i=0;e<f.right;e++,i++)e==f.left&&t==f.top||u.insert(a=u.mapping.map(n+f.tableStart,1),o({node:r,row:t,col:e}).createAndFill(s[i]))}u.setNodeMarkup(i,o({node:r,row:f.top,col:f.left}),s[0]),e instanceof L&&u.setSelection(new L(u.doc.resolve(e.$anchorCell.pos),a?u.doc.resolve(a):void 0)),n(u)}return!0})(t,n);var o}function ot(t,n,e){const o=n.map.cellsInRect({left:0,top:0,right:"row"==t?n.map.width:1,bottom:"column"==t?n.map.height:1});for(let t=0;t<o.length;t++){const r=n.table.nodeAt(o[t]);if(r&&r.type!==e.header_cell)return!1}return!0}function rt(t,n){return(n=n||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),s=l.map((t=>r.table.nodeAt(t)));for(let t=0;t<l.length;t++)s[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+l[t],o.cell,s[t].attrs);if(0===i.steps.length)for(let t=0;t<l.length;t++)i.setNodeMarkup(r.tableStart+l[t],o.header_cell,s[t].attrs);e(i)}return!0}}(t):function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=ot("row",r,o),s=ot("column",r,o),c=("column"===t?l:"row"===t&&s)?1:0,f="column"==t?{left:0,top:c,right:1,bottom:r.map.height}:"row"==t?{left:c,top:0,right:r.map.width,bottom:1}:r,u="column"==t?s?o.cell:o.header_cell:"row"==t?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(f).forEach((t=>{const n=t+r.tableStart,e=i.doc.nodeAt(n);e&&i.setNodeMarkup(n,u,e.attrs)})),e(i)}return!0}}const it=rt("row",{useDeprecatedLogic:!0});function lt(t,n){const e=t.selection.$anchor;for(let o=e.depth;o>0;o--)if("table"==e.node(o).type.spec.tableRole)return n&&n(t.tr.delete(e.before(o),e.after(o)).scrollIntoView()),!0;return!1}function st(t,n){const e=t.selection;if(!(e instanceof L))return!1;if(n){const o=t.tr,r=_(t.schema).cell.createAndFill().content;e.forEachCell(((t,n)=>{t.content.eq(r)||o.replace(o.mapping.map(n+1),o.mapping.map(n+t.nodeSize-1),new l(r,0,0))})),o.docChanged&&n(o)}return!0}function ct(t){if(0===t.size)return null;let{content:n,openStart:e,openEnd:o}=t;for(;1==n.childCount&&(e>0&&o>0||"table"==n.child(0).type.spec.tableRole);)e--,o--,n=n.child(0).content;const r=n.child(0),s=r.type.spec.tableRole,c=r.type.schema,f=[];if("row"==s)for(let t=0;t<n.childCount;t++){let r=n.child(t).content;const i=t?0:Math.max(0,e-1),s=t<n.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=ft(_(c).row,new l(r,i,s)).content),f.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;f.push(e||o?ft(_(c).row,new l(n,e,o)).content:n)}return function(t,n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];for(let n=o.childCount-1;n>=0;n--){const{rowspan:r,colspan:i}=o.child(n).attrs;for(let n=t;n<t+r;n++)e[n]=(e[n]||0)+i}}let o=0;for(let t=0;t<e.length;t++)o=Math.max(o,e[t]);for(let r=0;r<e.length;r++)if(r>=n.length&&n.push(i.empty),e[r]<o){const l=_(t).cell.createAndFill(),s=[];for(let t=e[r];t<o;t++)s.push(l);n[r]=n[r].append(i.from(s))}return{height:n.length,width:o,rows:n}}(c,f)}function ft(t,n){const e=t.createAndFill();return new c(e).replace(0,e.content.size,n).doc}function ut(t,n,e,o,r,i,l,s){if(0==l||l==n.height)return!1;let c=!1;for(let f=r;f<i;f++){const r=l*n.width+f,i=n.map[r];if(n.map[r-n.width]==i){c=!0;const r=e.nodeAt(i),{top:u,left:a}=n.findCell(i);t.setNodeMarkup(t.mapping.slice(s).map(i+o),null,{...r.attrs,rowspan:l-u}),t.insert(t.mapping.slice(s).map(n.positionAt(l,a,e)),r.type.createAndFill({...r.attrs,rowspan:u+r.attrs.rowspan-l})),f+=r.attrs.colspan-1}}return c}function at(t,n,e,o,r,i,l,s){if(0==l||l==n.width)return!1;let c=!1;for(let f=r;f<i;f++){const r=f*n.width+l,i=n.map[r];if(n.map[r-1]==i){c=!0;const r=e.nodeAt(i),u=n.colCount(i),a=t.mapping.slice(s).map(i+o);t.setNodeMarkup(a,null,T(r.attrs,l-u,r.attrs.colspan-(l-u))),t.insert(a+r.nodeSize,r.type.createAndFill(T(r.attrs,0,l-u))),f+=r.attrs.rowspan-1}}return c}function ht(t,n,e,o,r){let s=e?t.doc.nodeAt(e-1):t.doc;if(!s)throw new Error("No table found");let c=y.get(s);const{top:f,left:u}=o,a=u+r.width,h=f+r.height,w=t.tr;let d=0;function p(){if(s=e?w.doc.nodeAt(e-1):w.doc,!s)throw new Error("No table found");c=y.get(s),d=w.mapping.maps.length}(function(t,n,e,o,r,l,s){const c=_(t.doc.type.schema);let f,u;if(r>n.width)for(let i=0,l=0;i<n.height;i++){const a=e.child(i);l+=a.nodeSize;const h=[];let w;w=null==a.lastChild||a.lastChild.type==c.cell?f||(f=c.cell.createAndFill()):u||(u=c.header_cell.createAndFill());for(let t=n.width;t<r;t++)h.push(w);t.insert(t.mapping.slice(s).map(l-1+o),h)}if(l>n.height){const a=[];for(let t=0,o=(n.height-1)*n.width;t<Math.max(n.width,r);t++){const r=!(t>=n.width)&&e.nodeAt(n.map[o+t]).type==c.header_cell;a.push(r?u||(u=c.header_cell.createAndFill()):f||(f=c.cell.createAndFill()))}const h=c.row.create(null,i.from(a)),w=[];for(let t=n.height;t<l;t++)w.push(h);t.insert(t.mapping.slice(s).map(o+e.nodeSize-2),w)}return!(!f&&!u)})(w,c,s,e,a,h,d)&&p(),ut(w,c,s,e,u,a,f,d)&&p(),ut(w,c,s,e,u,a,h,d)&&p(),at(w,c,s,e,f,h,u,d)&&p(),at(w,c,s,e,f,h,a,d)&&p();for(let t=f;t<h;t++){const n=c.positionAt(t,u,s),o=c.positionAt(t,a,s);w.replace(w.mapping.slice(d).map(n+e),w.mapping.slice(d).map(o+e),new l(r.rows[t-f],0,0))}p(),w.setSelection(new L(w.doc.resolve(e+c.positionAt(f,u,s)),w.doc.resolve(e+c.positionAt(h-1,a-1,s)))),n(w)}rt("column",{useDeprecatedLogic:!0}),rt("cell",{useDeprecatedLogic:!0});const wt=b({ArrowLeft:pt("horiz",-1),ArrowRight:pt("horiz",1),ArrowUp:pt("vert",-1),ArrowDown:pt("vert",1),"Shift-ArrowLeft":mt("horiz",-1),"Shift-ArrowRight":mt("horiz",1),"Shift-ArrowUp":mt("vert",-1),"Shift-ArrowDown":mt("vert",1),Backspace:st,"Mod-Backspace":st,Delete:st,"Mod-Delete":st});function dt(t,n,e){return!e.eq(t.selection)&&(n&&n(t.tr.setSelection(e).scrollIntoView()),!0)}function pt(t,n){return(o,r,i)=>{if(!i)return!1;const l=o.selection;if(l instanceof L)return dt(o,r,e.near(l.$headCell,n));if("horiz"!=t&&!l.empty)return!1;const s=Mt(i,t,n);if(null==s)return!1;if("horiz"==t)return dt(o,r,e.near(o.doc.resolve(l.head+n),n));{const i=o.doc.resolve(s),l=x(i,t,n);let c;return c=l?e.near(l,1):n<0?e.near(o.doc.resolve(i.before(-1)),-1):e.near(o.doc.resolve(i.after(-1)),1),dt(o,r,c)}}}function mt(t,n){return(e,o,r)=>{if(!r)return!1;const i=e.selection;let l;if(i instanceof L)l=i;else{const o=Mt(r,t,n);if(null==o)return!1;l=new L(e.doc.resolve(o))}const s=x(l.$headCell,t,n);return!!s&&dt(e,o,new L(l.$anchorCell,s))}}function gt(t,n){const e=z(t.state.doc.resolve(n));return!!e&&(t.dispatch(t.state.tr.setSelection(new L(e))),!0)}function bt(t,n,e){if(!k(t.state))return!1;let o=ct(e);const r=t.state.selection;if(r instanceof L){o||(o={width:1,height:1,rows:[i.from(ft(_(t.state.schema).cell,e))]});const n=r.$anchorCell.node(-1),l=r.$anchorCell.start(-1),s=y.get(n).rectBetween(r.$anchorCell.pos-l,r.$headCell.pos-l);return o=function({width:t,height:n,rows:e},o,r){if(t!=o){const n=[],r=[];for(let t=0;t<e.length;t++){const l=e[t],s=[];for(let e=n[t]||0,r=0;e<o;r++){let i=l.child(r%l.childCount);e+i.attrs.colspan>o&&(i=i.type.createChecked(T(i.attrs,i.attrs.colspan,e+i.attrs.colspan-o),i.content)),s.push(i),e+=i.attrs.colspan;for(let e=1;e<i.attrs.rowspan;e++)n[t+e]=(n[t+e]||0)+i.attrs.colspan}r.push(i.from(s))}e=r,t=o}if(n!=r){const t=[];for(let o=0,l=0;o<r;o++,l++){const s=[],c=e[l%n];for(let t=0;t<c.childCount;t++){let n=c.child(t);o+n.attrs.rowspan>r&&(n=n.type.create({...n.attrs,rowspan:Math.max(1,r-n.attrs.rowspan)},n.content)),s.push(n)}t.push(i.from(s))}e=t,n=r}return{width:t,height:n,rows:e}}(o,s.right-s.left,s.bottom-s.top),ht(t.state,t.dispatch,l,s,o),!0}if(o){const n=A(t.state),e=n.start(-1);return ht(t.state,t.dispatch,e,y.get(n.node(-1)).findCell(n.pos-e),o),!0}return!1}function vt(t,n){var e;if(0!=n.button)return;if(n.ctrlKey||n.metaKey)return;const o=yt(t,n.target);let r;if(n.shiftKey&&t.state.selection instanceof L)i(t.state.selection.$anchorCell,n),n.preventDefault();else if(n.shiftKey&&o&&null!=(r=z(t.state.selection.$anchor))&&(null===(e=Dt(t,n))||void 0===e?void 0:e.pos)!=r.pos)i(r,n),n.preventDefault();else if(!o)return;function i(n,e){let o=Dt(t,e);const r=null==N.getState(t.state);if(!o||!O(n,o)){if(!r)return;o=n}const i=new L(n,o);if(r||!t.state.selection.eq(i)){const e=t.state.tr.setSelection(i);r&&e.setMeta(N,n.pos),t.dispatch(e)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",s),null!=N.getState(t.state)&&t.dispatch(t.state.tr.setMeta(N,-1))}function s(e){const r=e,s=N.getState(t.state);let c;if(null!=s)c=t.state.doc.resolve(s);else if(yt(t,r.target)!=o&&(c=Dt(t,n),!c))return l();c&&i(c,r)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",s)}function Mt(t,n,e){if(!(t.state.selection instanceof r))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((e<0?o.index(r):o.indexAfter(r))!=(e<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),l="vert"==n?e>0?"down":"up":e>0?"right":"left";return t.endOfTextblock(l)?i:null}}return null}function yt(t,n){for(;n&&n!=t.dom;n=n.parentNode)if("TD"==n.nodeName||"TH"==n.nodeName)return n;return null}function Dt(t,n){const e=t.posAtCoords({left:n.clientX,top:n.clientY});if(!e)return null;let{inside:o,pos:r}=e;return o>=0&&z(t.state.doc.resolve(o))||z(t.state.doc.resolve(r))}var St=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$t(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,$t(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function $t(t,n,e,o,r,i){let l=0,s=!0,c=n.firstChild;const f=t.firstChild;if(f){for(let t=0,e=0;t<f.childCount;t++){const{colspan:u,colwidth:a}=f.child(t).attrs;for(let t=0;t<u;t++,e++){const f=r==e?i:a&&a[t],u=f?f+"px":"";if(l+=f||o,f||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=u,n.appendChild(t)}}}for(;c;){var u;const t=c.nextSibling;null===(u=c.parentNode)||void 0===u||u.removeChild(c),c=t}s?(e.style.width=l+"px",e.style.minWidth=""):(e.style.width="",e.style.minWidth=l+"px")}}const Et=new n("tableColumnResizing");function Rt({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:r=St,lastColumnResizable:i=!0}={}){const l=new t({key:Et,state:{init(t,n){var e;const i=null===(e=l.spec)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.nodeViews,s=_(n.schema).table.name;return r&&i&&(i[s]=(t,n)=>new r(t,o,n)),new _t(-1,!1)},apply:(t,n)=>n.apply(t)},props:{attributes:t=>{const n=Et.getState(t);return n&&n.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,e)=>{!function(t,n,e,o){if(!t.editable)return;const r=Et.getState(t.state);if(!r)return;if(!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(n.target);let l=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();n.clientX-o<=e?l=Nt(t,n,"left",e):r-n.clientX<=e&&(l=Nt(t,n,"right",e))}if(l!=r.activeHandle){if(!o&&-1!==l){const n=t.state.doc.resolve(l),e=n.node(-1),o=y.get(e),r=n.start(-1);if(o.colCount(n.pos-r)+n.nodeAfter.attrs.colspan-1==o.width-1)return}kt(t,l)}}}(t,e,n,i)},mouseleave:t=>{!function(t){if(!t.editable)return;const n=Et.getState(t.state);n&&n.activeHandle>-1&&!n.dragging&&kt(t,-1)}(t)},mousedown:(t,n)=>{!function(t,n,e,o){var r;if(!t.editable)return!1;const i=null!==(r=t.dom.ownerDocument.defaultView)&&void 0!==r?r:window,l=Et.getState(t.state);if(!l||-1==l.activeHandle||l.dragging)return!1;const s=t.state.doc.nodeAt(l.activeHandle),c=function(t,n,{colspan:e,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(n);let l=i.node.childNodes[i.offset].offsetWidth,s=e;if(o)for(let t=0;t<e;t++)o[t]&&(l-=o[t],s--);return l/s}(t,l.activeHandle,s.attrs);function f(n){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",u);const o=Et.getState(t.state);(null==o?void 0:o.dragging)&&(!function(t,n,e){const o=t.state.doc.resolve(n),r=o.node(-1),i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let t=0;t<i.height;t++){const n=t*i.width+s;if(t&&i.map[n]==i.map[n-i.width])continue;const o=i.map[n],f=r.nodeAt(o).attrs,u=1==f.colspan?0:s-i.colCount(o);if(f.colwidth&&f.colwidth[u]==e)continue;const a=f.colwidth?f.colwidth.slice():Ct(f.colspan);a[u]=e,c.setNodeMarkup(l+o,null,{...f,colwidth:a})}c.docChanged&&t.dispatch(c)}(t,o.activeHandle,zt(o.dragging,n,e)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})))}function u(n){if(!n.which)return f(n);const r=Et.getState(t.state);if(r&&r.dragging){const i=zt(r.dragging,n,e);At(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:n.clientX,startWidth:c}})),At(t,l.activeHandle,c,o),i.addEventListener("mouseup",f),i.addEventListener("mousemove",u),n.preventDefault()}(t,n,e,o)}},decorations:t=>{const n=Et.getState(t);if(n&&n.activeHandle>-1)return function(t,n){const e=[],o=t.doc.resolve(n),r=o.node(-1);if(!r)return f.empty;const i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let n=0;n<i.height;n++){const o=s+n*i.width;if(!(s!=i.width-1&&i.map[o]==i.map[o+1]||0!=n&&i.map[o]==i.map[o-i.width])){var c;const n=i.map[o],s=l+n+r.nodeAt(n).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(null===(c=Et.getState(t))||void 0===c?void 0:c.dragging)&&e.push(u.node(l+n,l+n+r.nodeAt(n).nodeSize,{class:"column-resize-dragging"})),e.push(u.widget(s,f))}}return f.create(t.doc,e)}(t,n.activeHandle)},nodeViews:{}}});return l}var _t=class t{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(n){const e=this,o=n.getMeta(Et);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(e.activeHandle,o.setDragging);if(e.activeHandle>-1&&n.docChanged){let o=n.mapping.map(e.activeHandle,-1);return C(n.doc.resolve(o))||(o=-1),new t(o,e.dragging)}return e}};function Nt(t,n,e,o){const r="right"==e?-o:o,i=t.posAtCoords({left:n.clientX+r,top:n.clientY});if(!i)return-1;const{pos:l}=i,s=z(t.state.doc.resolve(l));if(!s)return-1;if("right"==e)return s.pos;const c=y.get(s.node(-1)),f=s.start(-1),u=c.map.indexOf(s.pos-f);return u%c.width==0?-1:f+c.map[u-1]}function zt(t,n,e){const o=n.clientX-t.startX;return Math.max(e,t.startWidth+o)}function kt(t,n){t.dispatch(t.state.tr.setMeta(Et,{setHandle:n}))}function At(t,n,e,o){const r=t.state.doc.resolve(n),i=r.node(-1),l=r.start(-1),s=y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;let c=t.domAtPos(r.start(-1)).node;for(;c&&"TABLE"!=c.nodeName;)c=c.parentNode;c&&$t(i,c.firstChild,c,o,s,e)}function Ct(t){return Array(t).fill(0)}function Ot({allowTableNodeSelection:n=!1}={}){return new t({key:N,state:{init:()=>null,apply(t,n){const e=t.getMeta(N);if(null!=e)return-1==e?null:e;if(null==n||!t.docChanged)return n;const{deleted:o,pos:r}=t.mapping.mapResult(n);return o?null:r}},props:{decorations:j,handleDOMEvents:{mousedown:vt},createSelectionBetween:t=>null!=N.getState(t.state)?t.state.selection:null,handleTripleClick:gt,handleKeyDown:wt,handlePaste:bt},appendTransaction:(t,e,o)=>function(t,n,e){const o=(n||t).selection,i=(n||t).doc;let l,c;if(o instanceof s&&(c=o.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)l=L.create(i,o.from);else if("row"==c){const t=i.resolve(o.from+1);l=L.rowSelection(t,t)}else if(!e){const t=y.get(o.node),n=o.from+1,e=n+t.map[t.width*t.height-1];l=L.create(i,n+1,e)}}else o instanceof r&&function({$from:t,$to:n}){if(t.pos==n.pos||t.pos<n.pos-6)return!1;let e=t.pos,o=n.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,e++);for(let t=n.depth;t>=0&&!(n.before(t+1)>n.start(t));t--,o--);return e==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?l=r.create(i,o.from):o instanceof r&&function({$from:t,$to:n}){let e,o;for(let n=t.depth;n>0;n--){const o=t.node(n);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){e=o;break}}for(let t=n.depth;t>0;t--){const e=n.node(t);if("cell"===e.type.spec.tableRole||"header_cell"===e.type.spec.tableRole){o=e;break}}return e!==o&&0===n.parentOffset}(o)&&(l=r.create(i,o.$from.start(),o.$from.end()));return l&&(n||(n=t.tr)).setSelection(l),n}(o,J(o,e),n)})}export{R as a,b,Rt as c,lt as d,it as e,I as f,Z as g,q as h,V as i,Q as j,g as k,G as l,nt as m,et as s,Ot as t};
|
|
1
|
+
import{b as t,P as n,S as e,k as o,T as r,F as i,d as l,c as s,m as c}from"./index-6f3fa4ab.esm.js";import{D as f,a as u}from"./index-353172ed.esm.js";import{k as a,b as h}from"./index-920675c4.esm.js";const w="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function p(t){let n,e,o,r,i=t.split(/-(?!$)/),l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;t++){let l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))e=!0;else if(/^s(hift)?$/i.test(l))o=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);w?r=!0:e=!0}}return n&&(l="Alt-"+l),e&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l}function m(t,n,e=!0){return n.altKey&&(t="Alt-"+t),n.ctrlKey&&(t="Ctrl-"+t),n.metaKey&&(t="Meta-"+t),e&&n.shiftKey&&(t="Shift-"+t),t}function g(n){return new t({props:{handleKeyDown:b(n)}})}function b(t){let n=function(t){let n=Object.create(null);for(let e in t)n[p(e)]=t[e];return n}(t);return function(t,e){let o,r=a(e),i=n[m(r,e)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(e.shiftKey){let o=n[m(r,e,!1)];if(o&&o(t.state,t.dispatch,t))return!0}if((e.altKey||e.metaKey||e.ctrlKey)&&!(d&&e.ctrlKey&&e.altKey)&&(o=h[e.keyCode])&&o!=r){let r=n[m(o,e)];if(r&&r(t.state,t.dispatch,t))return!0}}return!1}}let v,M;if("undefined"!=typeof WeakMap){let t=new WeakMap;v=n=>t.get(n),M=(n,e)=>(t.set(n,e),e)}else{const t=[],n=10;let e=0;v=n=>{for(let e=0;e<t.length;e+=2)if(t[e]==n)return t[e+1]},M=(o,r)=>(e==n&&(e=0),t[e++]=o,t[e++]=r)}var y=class{constructor(t,n,e,o){this.width=t,this.height=n,this.map=e,this.problems=o}findCell(t){for(let n=0;n<this.map.length;n++){const e=this.map[n];if(e!=t)continue;const o=n%this.width,r=n/this.width|0;let i=o+1,l=r+1;for(let t=1;i<this.width&&this.map[n+t]==e;t++)i++;for(let t=1;l<this.height&&this.map[n+this.width*t]==e;t++)l++;return{left:o,top:r,right:i,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let n=0;n<this.map.length;n++)if(this.map[n]==t)return n%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,n,e){const{left:o,right:r,top:i,bottom:l}=this.findCell(t);return"horiz"==n?(e<0?0==o:r==this.width)?null:this.map[i*this.width+(e<0?o-1:r)]:(e<0?0==i:l==this.height)?null:this.map[o+this.width*(e<0?i-1:l)]}rectBetween(t,n){const{left:e,right:o,top:r,bottom:i}=this.findCell(t),{left:l,right:s,top:c,bottom:f}=this.findCell(n);return{left:Math.min(e,l),top:Math.min(r,c),right:Math.max(o,s),bottom:Math.max(i,f)}}cellsInRect(t){const n=[],e={};for(let o=t.top;o<t.bottom;o++)for(let r=t.left;r<t.right;r++){const i=o*this.width+r,l=this.map[i];e[l]||(e[l]=!0,r==t.left&&r&&this.map[i-1]==l||o==t.top&&o&&this.map[i-this.width]==l||n.push(l))}return n}positionAt(t,n,e){for(let o=0,r=0;;o++){const i=r+e.child(o).nodeSize;if(o==t){let e=n+t*this.width;const o=(t+1)*this.width;for(;e<o&&this.map[e]<r;)e++;return e==o?i-1:this.map[e]}r=i}}static get(t){return v(t)||M(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const n=function(t){let n=-1,e=!1;for(let o=0;o<t.childCount;o++){const r=t.child(o);let i=0;if(e)for(let n=0;n<o;n++){const e=t.child(n);for(let t=0;t<e.childCount;t++){const r=e.child(t);n+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let t=0;t<r.childCount;t++){const n=r.child(t);i+=n.attrs.colspan,n.attrs.rowspan>1&&(e=!0)}-1==n?n=i:n!=i&&(n=Math.max(n,i))}return n}(t),e=t.childCount,o=[];let r=0,i=null;const l=[];for(let t=0,r=n*e;t<r;t++)o[t]=0;for(let s=0,c=0;s<e;s++){const f=t.child(s);c++;for(let t=0;;t++){for(;r<o.length&&0!=o[r];)r++;if(t==f.childCount)break;const u=f.child(t),{colspan:a,rowspan:h,colwidth:w}=u.attrs;for(let t=0;t<h;t++){if(t+s>=e){(i||(i=[])).push({type:"overlong_rowspan",pos:c,n:h-t});break}const f=r+t*n;for(let t=0;t<a;t++){0==o[f+t]?o[f+t]=c:(i||(i=[])).push({type:"collision",row:s,pos:c,n:a-t});const e=w&&w[t];if(e){const o=(f+t)%n*2,r=l[o];null==r||r!=e&&1==l[o+1]?(l[o]=e,l[o+1]=1):r==e&&l[o+1]++}}}r+=a,c+=u.nodeSize}const u=(s+1)*n;let a=0;for(;r<u;)0==o[r++]&&a++;a&&(i||(i=[])).push({type:"missing",row:s,n:a}),c++}0!==n&&0!==e||(i||(i=[])).push({type:"zero_sized"});const s=new y(n,e,o,i);let c=!1;for(let t=0;!c&&t<l.length;t+=2)null!=l[t]&&l[t+1]<e&&(c=!0);c&&function(t,n,e){t.problems||(t.problems=[]);const o={};for(let r=0;r<t.map.length;r++){const i=t.map[r];if(o[i])continue;o[i]=!0;const l=e.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let s=null;const c=l.attrs;for(let e=0;e<c.colspan;e++){const o=n[(r+e)%t.width*2];null==o||c.colwidth&&c.colwidth[e]==o||((s||(s=D(c)))[e]=o)}s&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}(s,l,t);return s}(t))}};function D(t){if(t.colwidth)return t.colwidth.slice();const n=[];for(let e=0;e<t.colspan;e++)n.push(0);return n}function S(t,n){if("string"==typeof t)return{};const e=t.getAttribute("data-colwidth"),o=e&&/^\d+(,\d+)*$/.test(e)?e.split(",").map((t=>Number(t))):null,r=Number(t.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const e in n){const o=n[e].getFromDOM,r=o&&o(t);null!=r&&(i[e]=r)}return i}function $(t,n){const e={};1!=t.attrs.colspan&&(e.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(e.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(e["data-colwidth"]=t.attrs.colwidth.join(","));for(const o in n){const r=n[o].setDOMAttr;r&&r(t.attrs[o],e)}return e}function E(t){if(null!==t){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");for(const n of t)if("number"!=typeof n)throw new TypeError("colwidth must be null or an array of numbers")}}function R(t){const n=t.cellAttributes||{},e={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:E}};for(const t in n)e[t]={default:n[t].default,validate:n[t].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:e,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>S(t,n)}],toDOM:t=>["td",$(t,n),0]},table_header:{content:t.cellContent,attrs:e,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>S(t,n)}],toDOM:t=>["th",$(t,n),0]}}}function _(t){let n=t.cached.tableNodeTypes;if(!n){n=t.cached.tableNodeTypes={};for(const e in t.nodes){const o=t.nodes[e],r=o.spec.tableRole;r&&(n[r]=o)}}return n}const N=new n("selectingCells");function z(t){for(let n=t.depth-1;n>0;n--)if("row"==t.node(n).type.spec.tableRole)return t.node(0).resolve(t.before(n+1));return null}function k(t){const n=t.selection.$head;for(let t=n.depth;t>0;t--)if("row"==n.node(t).type.spec.tableRole)return!0;return!1}function A(t){const n=t.selection;if("$anchorCell"in n&&n.$anchorCell)return n.$anchorCell.pos>n.$headCell.pos?n.$anchorCell:n.$headCell;if("node"in n&&n.node&&"cell"==n.node.type.spec.tableRole)return n.$anchor;const e=z(n.$head)||function(t){for(let n=t.nodeAfter,e=t.pos;n;n=n.firstChild,e++){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e)}for(let n=t.nodeBefore,e=t.pos;n;n=n.lastChild,e--){const o=n.type.spec.tableRole;if("cell"==o||"header_cell"==o)return t.doc.resolve(e-n.nodeSize)}}(n.$head);if(e)return e;throw new RangeError(`No cell found around position ${n.head}`)}function C(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function O(t,n){return t.depth==n.depth&&t.pos>=n.start(-1)&&t.pos<=n.end(-1)}function T(t,n,e){const o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.nextCell(t.pos-i,n,e);return null==l?null:t.node(0).resolve(i+l)}function x(t,n,e=1){const o={...t,colspan:t.colspan-e};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(n,e),o.colwidth.some((t=>t>0))||(o.colwidth=null)),o}function W(t,n,e=1){const o={...t,colspan:t.colspan+e};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let t=0;t<e;t++)o.colwidth.splice(n,0,0)}return o}var L=class t extends e{constructor(t,n=t){const e=t.node(-1),r=y.get(e),i=t.start(-1),l=r.rectBetween(t.pos-i,n.pos-i),s=t.node(0),c=r.cellsInRect(l).filter((t=>t!=n.pos-i));c.unshift(n.pos-i);const f=c.map((t=>{const n=e.nodeAt(t);if(!n)throw new RangeError(`No cell with offset ${t} found`);const r=i+t+1;return new o(s.resolve(r),s.resolve(r+n.content.size))}));super(f[0].$from,f[0].$to,f),this.$anchorCell=t,this.$headCell=n}map(n,e){const o=n.resolve(e.map(this.$anchorCell.pos)),i=n.resolve(e.map(this.$headCell.pos));if(C(o)&&C(i)&&O(o,i)){const n=this.$anchorCell.node(-1)!=o.node(-1);return n&&this.isRowSelection()?t.rowSelection(o,i):n&&this.isColSelection()?t.colSelection(o,i):new t(o,i)}return r.between(o,i)}content(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-e,this.$headCell.pos-e),r={},s=[];for(let e=o.top;e<o.bottom;e++){const l=[];for(let i=e*n.width+o.left,s=o.left;s<o.right;s++,i++){const e=n.map[i];if(r[e])continue;r[e]=!0;const s=n.findCell(e);let c=t.nodeAt(e);if(!c)throw new RangeError(`No cell with offset ${e} found`);const f=o.left-s.left,u=s.right-o.right;if(f>0||u>0){let t=c.attrs;if(f>0&&(t=x(t,0,f)),u>0&&(t=x(t,t.colspan-u,u)),s.left<o.left){if(c=c.type.createAndFill(t),!c)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else c=c.type.create(t,c.content)}if(s.top<o.top||s.bottom>o.bottom){const t={...c.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};c=s.top<o.top?c.type.createAndFill(t):c.type.create(t,c.content)}l.push(c)}s.push(t.child(e).copy(i.from(l)))}const c=this.isColSelection()&&this.isRowSelection()?t:s;return new l(i.from(c),1,1)}replace(t,n=l.empty){const o=t.steps.length,r=this.ranges;for(let e=0;e<r.length;e++){const{$from:i,$to:s}=r[e],c=t.mapping.slice(o);t.replace(c.map(i.pos),c.map(s.pos),e?l.empty:n)}const i=e.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new l(i.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),e=y.get(n),o=this.$anchorCell.start(-1),r=e.cellsInRect(e.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let e=0;e<r.length;e++)t(n.nodeAt(r[e]),o+r[e])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const e=t+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(e,o)==this.$headCell.node(-1).childCount}static colSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.top<=s.top?(l.top>0&&(n=c.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=c.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(e=c.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=c.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new t(n,e)}isRowSelection(){const t=this.$anchorCell.node(-1),n=y.get(t),e=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-e),r=n.colCount(this.$headCell.pos-e);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width}eq(n){return n instanceof t&&n.$anchorCell.pos==this.$anchorCell.pos&&n.$headCell.pos==this.$headCell.pos}static rowSelection(n,e=n){const o=n.node(-1),r=y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.left<=s.left?(l.left>0&&(n=c.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=c.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(e=c.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=c.resolve(i+r.map[r.width*(l.top+1)-1]))),new t(n,e)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(n,e){return new t(n.resolve(e.anchor),n.resolve(e.head))}static create(n,e,o=e){return new t(n.resolve(e),n.resolve(o))}getBookmark(){return new B(this.$anchorCell.pos,this.$headCell.pos)}};L.prototype.visible=!1,e.jsonID("cell",L);var B=class t{constructor(t,n){this.anchor=t,this.head=n}map(n){return new t(n.map(this.anchor),n.map(this.head))}resolve(t){const n=t.resolve(this.anchor),o=t.resolve(this.head);return"row"==n.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&O(n,o)?new L(n,o):e.near(o,1)}};function j(t){if(!(t.selection instanceof L))return null;const n=[];return t.selection.forEachCell(((t,e)=>{n.push(u.node(e,e+t.nodeSize,{class:"selectedCell"}))})),f.create(t.doc,n)}const P=new n("fix-tables");function H(t,n,e,o){const r=t.childCount,i=n.childCount;t:for(let l=0,s=0;l<i;l++){const i=n.child(l);for(let n=s,o=Math.min(r,l+3);n<o;n++)if(t.child(n)==i){s=n+1,e+=i.nodeSize;continue t}o(i,e),s<r&&t.child(s).sameMarkup(i)?H(t.child(s),i,e+1,o):i.nodesBetween(0,i.content.size,o,e+1),e+=i.nodeSize}}function J(t,n){let e;const o=(n,o)=>{"table"==n.type.spec.tableRole&&(e=function(t,n,e,o){const r=y.get(n);if(!r.problems)return o;o||(o=t.tr);const i=[];for(let t=0;t<r.height;t++)i.push(0);for(let t=0;t<r.problems.length;t++){const l=r.problems[t];if("collision"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;const r=t.attrs;for(let t=0;t<r.rowspan;t++)i[l.row+t]+=l.n;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,x(r,r.colspan-l.n,l.n))}else if("missing"==l.type)i[l.row]+=l.n;else if("overlong_rowspan"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if("colwidth mismatch"==l.type){const t=n.nodeAt(l.pos);if(!t)continue;o.setNodeMarkup(o.mapping.map(e+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if("zero_sized"==l.type){const t=o.mapping.map(e);o.delete(t,t+n.nodeSize)}}let l,s;for(let t=0;t<i.length;t++)i[t]&&(null==l&&(l=t),s=t);for(let c=0,f=e+1;c<r.height;c++){const e=n.child(c),r=f+e.nodeSize,u=i[c];if(u>0){let n="cell";e.firstChild&&(n=e.firstChild.type.spec.tableRole);const i=[];for(let e=0;e<u;e++){const e=_(t.schema)[n].createAndFill();e&&i.push(e)}const a=0!=c&&l!=c-1||s!=c?r-1:f+1;o.insert(o.mapping.map(a),i)}f=r}return o.setMeta(P,{fixTables:!0})}(t,n,o,e))};return n?n.doc!=t.doc&&H(n.doc,t.doc,0,o):t.doc.descendants(o),e}function U(t){const n=t.selection,e=A(t),o=e.node(-1),r=e.start(-1),i=y.get(o);return{...n instanceof L?i.rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r):i.findCell(e.pos-r),tableStart:r,map:i,table:o}}function K(t,{map:n,tableStart:e,table:o},r){let i=r>0?-1:0;(function(t,n,e){const o=_(n.type.schema).header_cell;for(let r=0;r<t.height;r++)if(n.nodeAt(t.map[e+r*t.width]).type!=o)return!1;return!0})(n,o,r+i)&&(i=0==r||r==n.width?null:0);for(let l=0;l<n.height;l++){const s=l*n.width+r;if(r>0&&r<n.width&&n.map[s-1]==n.map[s]){const i=n.map[s],c=o.nodeAt(i);t.setNodeMarkup(t.mapping.map(e+i),null,W(c.attrs,r-n.colCount(i))),l+=c.attrs.rowspan-1}else{const c=null==i?_(o.type.schema).cell:o.nodeAt(n.map[s+i]).type,f=n.positionAt(l,r,o);t.insert(t.mapping.map(e+f),c.createAndFill())}}return t}function V(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.left))}return!0}function q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(K(t.tr,e,e.right))}return!0}function F(t,{map:n,table:e,tableStart:o},r){const i=t.mapping.maps.length;for(let l=0;l<n.height;){const s=l*n.width+r,c=n.map[s],f=e.nodeAt(c),u=f.attrs;if(r>0&&n.map[s-1]==c||r<n.width-1&&n.map[s+1]==c)t.setNodeMarkup(t.mapping.slice(i).map(o+c),null,x(u,r-n.colCount(c)));else{const n=t.mapping.slice(i).map(o+c);t.delete(n,n+f.nodeSize)}l+=u.rowspan}}function I(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.left&&e.right==e.map.width)return!1;for(let t=e.right-1;F(o,e,t),t!=e.left;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(t)}n(o)}return!0}function X(t,{map:n,tableStart:e,table:o},r){let i=e;for(let t=0;t<r;t++)i+=o.child(t).nodeSize;const l=[];let s=r>0?-1:0;(function(t,n,e){var o;const r=_(n.type.schema).header_cell;for(let i=0;i<t.width;i++)if((null===(o=n.nodeAt(t.map[i+e*t.width]))||void 0===o?void 0:o.type)!=r)return!1;return!0})(n,o,r+s)&&(s=0==r||r==n.height?null:0);for(let i=0,f=n.width*r;i<n.width;i++,f++)if(r>0&&r<n.height&&n.map[f]==n.map[f-n.width]){const r=n.map[f],l=o.nodeAt(r).attrs;t.setNodeMarkup(e+r,null,{...l,rowspan:l.rowspan+1}),i+=l.colspan-1}else{var c;const t=null==s?_(o.type.schema).cell:null===(c=o.nodeAt(n.map[f+s*n.width]))||void 0===c?void 0:c.type,e=null==t?void 0:t.createAndFill();e&&l.push(e)}return t.insert(i,_(o.type.schema).row.create(null,l)),t}function G(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.top))}return!0}function Q(t,n){if(!k(t))return!1;if(n){const e=U(t);n(X(t.tr,e,e.bottom))}return!0}function Y(t,{map:n,table:e,tableStart:o},r){let i=0;for(let t=0;t<r;t++)i+=e.child(t).nodeSize;const l=i+e.child(r).nodeSize,s=t.mapping.maps.length;t.delete(i+o,l+o);const c=new Set;for(let i=0,l=r*n.width;i<n.width;i++,l++){const f=n.map[l];if(!c.has(f))if(c.add(f),r>0&&f==n.map[l-n.width]){const n=e.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(s).map(f+o),null,{...n,rowspan:n.rowspan-1}),i+=n.colspan-1}else if(r<n.height&&f==n.map[l+n.width]){const l=e.nodeAt(f),c=l.attrs,u=l.type.create({...c,rowspan:l.attrs.rowspan-1},l.content),a=n.positionAt(r+1,i,e);t.insert(t.mapping.slice(s).map(o+a),u),i+=c.colspan-1}}}function Z(t,n){if(!k(t))return!1;if(n){const e=U(t),o=t.tr;if(0==e.top&&e.bottom==e.map.height)return!1;for(let t=e.bottom-1;Y(o,e,t),t!=e.top;t--){const t=e.tableStart?o.doc.nodeAt(e.tableStart-1):o.doc;if(!t)throw new RangeError("No table found");e.table=t,e.map=y.get(e.table)}n(o)}return!0}function tt(t){const n=t.content;return 1==n.childCount&&n.child(0).isTextblock&&0==n.child(0).childCount}function nt(t,n){const e=t.selection;if(!(e instanceof L)||e.$anchorCell.pos==e.$headCell.pos)return!1;const o=U(t),{map:r}=o;if(function({width:t,height:n,map:e},o){let r=o.top*t+o.left,i=r,l=(o.bottom-1)*t+o.left,s=r+(o.right-o.left-1);for(let n=o.top;n<o.bottom;n++){if(o.left>0&&e[i]==e[i-1]||o.right<t&&e[s]==e[s+1])return!0;i+=t,s+=t}for(let i=o.left;i<o.right;i++){if(o.top>0&&e[r]==e[r-t]||o.bottom<n&&e[l]==e[l+t])return!0;r++,l++}return!1}(r,o))return!1;if(n){const e=t.tr,l={};let s,c,f=i.empty;for(let t=o.top;t<o.bottom;t++)for(let n=o.left;n<o.right;n++){const i=r.map[t*r.width+n],u=o.table.nodeAt(i);if(!l[i]&&u)if(l[i]=!0,null==s)s=i,c=u;else{tt(u)||(f=f.append(u.content));const t=e.mapping.map(i+o.tableStart);e.delete(t,t+u.nodeSize)}}if(null==s||null==c)return!0;if(e.setNodeMarkup(s+o.tableStart,null,{...W(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),f.size>0){const t=s+1+c.content.size,n=tt(c)?s+1:t;e.replaceWith(n+o.tableStart,t+o.tableStart,f)}e.setSelection(new L(e.doc.resolve(s+o.tableStart))),n(e)}return!0}function et(t,n){const e=_(t.schema);return(o=({node:t})=>e[t.type.spec.tableRole],(t,n)=>{const e=t.selection;let r,i;if(e instanceof L){if(e.$anchorCell.pos!=e.$headCell.pos)return!1;r=e.$anchorCell.nodeAfter,i=e.$anchorCell.pos}else{var l;if(r=function(t){for(let n=t.depth;n>0;n--){const e=t.node(n).type.spec.tableRole;if("cell"===e||"header_cell"===e)return t.node(n)}return null}(e.$from),!r)return!1;i=null===(l=z(e.$from))||void 0===l?void 0:l.pos}if(null==r||null==i)return!1;if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){let l=r.attrs;const s=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const f=U(t),u=t.tr;for(let t=0;t<f.right-f.left;t++)s.push(c?{...l,colwidth:c&&c[t]?[c[t]]:null}:l);let a;for(let t=f.top;t<f.bottom;t++){let n=f.map.positionAt(t,f.left,f.table);t==f.top&&(n+=r.nodeSize);for(let e=f.left,i=0;e<f.right;e++,i++)e==f.left&&t==f.top||u.insert(a=u.mapping.map(n+f.tableStart,1),o({node:r,row:t,col:e}).createAndFill(s[i]))}u.setNodeMarkup(i,o({node:r,row:f.top,col:f.left}),s[0]),e instanceof L&&u.setSelection(new L(u.doc.resolve(e.$anchorCell.pos),a?u.doc.resolve(a):void 0)),n(u)}return!0})(t,n);var o}function ot(t,n,e){const o=n.map.cellsInRect({left:0,top:0,right:"row"==t?n.map.width:1,bottom:"column"==t?n.map.height:1});for(let t=0;t<o.length;t++){const r=n.table.nodeAt(o[t]);if(r&&r.type!==e.header_cell)return!1}return!0}function rt(t,n){return(n=n||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=r.map.cellsInRect("column"==t?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==t?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),s=l.map((t=>r.table.nodeAt(t)));for(let t=0;t<l.length;t++)s[t].type==o.header_cell&&i.setNodeMarkup(r.tableStart+l[t],o.cell,s[t].attrs);if(0===i.steps.length)for(let t=0;t<l.length;t++)i.setNodeMarkup(r.tableStart+l[t],o.header_cell,s[t].attrs);e(i)}return!0}}(t):function(n,e){if(!k(n))return!1;if(e){const o=_(n.schema),r=U(n),i=n.tr,l=ot("row",r,o),s=ot("column",r,o),c=("column"===t?l:"row"===t&&s)?1:0,f="column"==t?{left:0,top:c,right:1,bottom:r.map.height}:"row"==t?{left:c,top:0,right:r.map.width,bottom:1}:r,u="column"==t?s?o.cell:o.header_cell:"row"==t?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(f).forEach((t=>{const n=t+r.tableStart,e=i.doc.nodeAt(n);e&&i.setNodeMarkup(n,u,e.attrs)})),e(i)}return!0}}const it=rt("row",{useDeprecatedLogic:!0});function lt(t,n){const e=t.selection.$anchor;for(let o=e.depth;o>0;o--)if("table"==e.node(o).type.spec.tableRole)return n&&n(t.tr.delete(e.before(o),e.after(o)).scrollIntoView()),!0;return!1}function st(t,n){const e=t.selection;if(!(e instanceof L))return!1;if(n){const o=t.tr,r=_(t.schema).cell.createAndFill().content;e.forEachCell(((t,n)=>{t.content.eq(r)||o.replace(o.mapping.map(n+1),o.mapping.map(n+t.nodeSize-1),new l(r,0,0))})),o.docChanged&&n(o)}return!0}function ct(t){if(0===t.size)return null;let{content:n,openStart:e,openEnd:o}=t;for(;1==n.childCount&&(e>0&&o>0||"table"==n.child(0).type.spec.tableRole);)e--,o--,n=n.child(0).content;const r=n.child(0),s=r.type.spec.tableRole,c=r.type.schema,f=[];if("row"==s)for(let t=0;t<n.childCount;t++){let r=n.child(t).content;const i=t?0:Math.max(0,e-1),s=t<n.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=ft(_(c).row,new l(r,i,s)).content),f.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;f.push(e||o?ft(_(c).row,new l(n,e,o)).content:n)}return function(t,n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];for(let n=o.childCount-1;n>=0;n--){const{rowspan:r,colspan:i}=o.child(n).attrs;for(let n=t;n<t+r;n++)e[n]=(e[n]||0)+i}}let o=0;for(let t=0;t<e.length;t++)o=Math.max(o,e[t]);for(let r=0;r<e.length;r++)if(r>=n.length&&n.push(i.empty),e[r]<o){const l=_(t).cell.createAndFill(),s=[];for(let t=e[r];t<o;t++)s.push(l);n[r]=n[r].append(i.from(s))}return{height:n.length,width:o,rows:n}}(c,f)}function ft(t,n){const e=t.createAndFill();return new c(e).replace(0,e.content.size,n).doc}function ut(t,n,e,o,r,i,l,s){if(0==l||l==n.height)return!1;let c=!1;for(let f=r;f<i;f++){const r=l*n.width+f,i=n.map[r];if(n.map[r-n.width]==i){c=!0;const r=e.nodeAt(i),{top:u,left:a}=n.findCell(i);t.setNodeMarkup(t.mapping.slice(s).map(i+o),null,{...r.attrs,rowspan:l-u}),t.insert(t.mapping.slice(s).map(n.positionAt(l,a,e)),r.type.createAndFill({...r.attrs,rowspan:u+r.attrs.rowspan-l})),f+=r.attrs.colspan-1}}return c}function at(t,n,e,o,r,i,l,s){if(0==l||l==n.width)return!1;let c=!1;for(let f=r;f<i;f++){const r=f*n.width+l,i=n.map[r];if(n.map[r-1]==i){c=!0;const r=e.nodeAt(i),u=n.colCount(i),a=t.mapping.slice(s).map(i+o);t.setNodeMarkup(a,null,x(r.attrs,l-u,r.attrs.colspan-(l-u))),t.insert(a+r.nodeSize,r.type.createAndFill(x(r.attrs,0,l-u))),f+=r.attrs.rowspan-1}}return c}function ht(t,n,e,o,r){let s=e?t.doc.nodeAt(e-1):t.doc;if(!s)throw new Error("No table found");let c=y.get(s);const{top:f,left:u}=o,a=u+r.width,h=f+r.height,w=t.tr;let d=0;function p(){if(s=e?w.doc.nodeAt(e-1):w.doc,!s)throw new Error("No table found");c=y.get(s),d=w.mapping.maps.length}(function(t,n,e,o,r,l,s){const c=_(t.doc.type.schema);let f,u;if(r>n.width)for(let i=0,l=0;i<n.height;i++){const a=e.child(i);l+=a.nodeSize;const h=[];let w;w=null==a.lastChild||a.lastChild.type==c.cell?f||(f=c.cell.createAndFill()):u||(u=c.header_cell.createAndFill());for(let t=n.width;t<r;t++)h.push(w);t.insert(t.mapping.slice(s).map(l-1+o),h)}if(l>n.height){const a=[];for(let t=0,o=(n.height-1)*n.width;t<Math.max(n.width,r);t++){const r=!(t>=n.width)&&e.nodeAt(n.map[o+t]).type==c.header_cell;a.push(r?u||(u=c.header_cell.createAndFill()):f||(f=c.cell.createAndFill()))}const h=c.row.create(null,i.from(a)),w=[];for(let t=n.height;t<l;t++)w.push(h);t.insert(t.mapping.slice(s).map(o+e.nodeSize-2),w)}return!(!f&&!u)})(w,c,s,e,a,h,d)&&p(),ut(w,c,s,e,u,a,f,d)&&p(),ut(w,c,s,e,u,a,h,d)&&p(),at(w,c,s,e,f,h,u,d)&&p(),at(w,c,s,e,f,h,a,d)&&p();for(let t=f;t<h;t++){const n=c.positionAt(t,u,s),o=c.positionAt(t,a,s);w.replace(w.mapping.slice(d).map(n+e),w.mapping.slice(d).map(o+e),new l(r.rows[t-f],0,0))}p(),w.setSelection(new L(w.doc.resolve(e+c.positionAt(f,u,s)),w.doc.resolve(e+c.positionAt(h-1,a-1,s)))),n(w)}rt("column",{useDeprecatedLogic:!0}),rt("cell",{useDeprecatedLogic:!0});const wt=b({ArrowLeft:pt("horiz",-1),ArrowRight:pt("horiz",1),ArrowUp:pt("vert",-1),ArrowDown:pt("vert",1),"Shift-ArrowLeft":mt("horiz",-1),"Shift-ArrowRight":mt("horiz",1),"Shift-ArrowUp":mt("vert",-1),"Shift-ArrowDown":mt("vert",1),Backspace:st,"Mod-Backspace":st,Delete:st,"Mod-Delete":st});function dt(t,n,e){return!e.eq(t.selection)&&(n&&n(t.tr.setSelection(e).scrollIntoView()),!0)}function pt(t,n){return(o,r,i)=>{if(!i)return!1;const l=o.selection;if(l instanceof L)return dt(o,r,e.near(l.$headCell,n));if("horiz"!=t&&!l.empty)return!1;const s=Mt(i,t,n);if(null==s)return!1;if("horiz"==t)return dt(o,r,e.near(o.doc.resolve(l.head+n),n));{const i=o.doc.resolve(s),l=T(i,t,n);let c;return c=l?e.near(l,1):n<0?e.near(o.doc.resolve(i.before(-1)),-1):e.near(o.doc.resolve(i.after(-1)),1),dt(o,r,c)}}}function mt(t,n){return(e,o,r)=>{if(!r)return!1;const i=e.selection;let l;if(i instanceof L)l=i;else{const o=Mt(r,t,n);if(null==o)return!1;l=new L(e.doc.resolve(o))}const s=T(l.$headCell,t,n);return!!s&&dt(e,o,new L(l.$anchorCell,s))}}function gt(t,n){const e=z(t.state.doc.resolve(n));return!!e&&(t.dispatch(t.state.tr.setSelection(new L(e))),!0)}function bt(t,n,e){if(!k(t.state))return!1;let o=ct(e);const r=t.state.selection;if(r instanceof L){o||(o={width:1,height:1,rows:[i.from(ft(_(t.state.schema).cell,e))]});const n=r.$anchorCell.node(-1),l=r.$anchorCell.start(-1),s=y.get(n).rectBetween(r.$anchorCell.pos-l,r.$headCell.pos-l);return o=function({width:t,height:n,rows:e},o,r){if(t!=o){const n=[],r=[];for(let t=0;t<e.length;t++){const l=e[t],s=[];for(let e=n[t]||0,r=0;e<o;r++){let i=l.child(r%l.childCount);e+i.attrs.colspan>o&&(i=i.type.createChecked(x(i.attrs,i.attrs.colspan,e+i.attrs.colspan-o),i.content)),s.push(i),e+=i.attrs.colspan;for(let e=1;e<i.attrs.rowspan;e++)n[t+e]=(n[t+e]||0)+i.attrs.colspan}r.push(i.from(s))}e=r,t=o}if(n!=r){const t=[];for(let o=0,l=0;o<r;o++,l++){const s=[],c=e[l%n];for(let t=0;t<c.childCount;t++){let n=c.child(t);o+n.attrs.rowspan>r&&(n=n.type.create({...n.attrs,rowspan:Math.max(1,r-n.attrs.rowspan)},n.content)),s.push(n)}t.push(i.from(s))}e=t,n=r}return{width:t,height:n,rows:e}}(o,s.right-s.left,s.bottom-s.top),ht(t.state,t.dispatch,l,s,o),!0}if(o){const n=A(t.state),e=n.start(-1);return ht(t.state,t.dispatch,e,y.get(n.node(-1)).findCell(n.pos-e),o),!0}return!1}function vt(t,n){var e;if(0!=n.button)return;if(n.ctrlKey||n.metaKey)return;const o=yt(t,n.target);let r;if(n.shiftKey&&t.state.selection instanceof L)i(t.state.selection.$anchorCell,n),n.preventDefault();else if(n.shiftKey&&o&&null!=(r=z(t.state.selection.$anchor))&&(null===(e=Dt(t,n))||void 0===e?void 0:e.pos)!=r.pos)i(r,n),n.preventDefault();else if(!o)return;function i(n,e){let o=Dt(t,e);const r=null==N.getState(t.state);if(!o||!O(n,o)){if(!r)return;o=n}const i=new L(n,o);if(r||!t.state.selection.eq(i)){const e=t.state.tr.setSelection(i);r&&e.setMeta(N,n.pos),t.dispatch(e)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",s),null!=N.getState(t.state)&&t.dispatch(t.state.tr.setMeta(N,-1))}function s(e){const r=e,s=N.getState(t.state);let c;if(null!=s)c=t.state.doc.resolve(s);else if(yt(t,r.target)!=o&&(c=Dt(t,n),!c))return l();c&&i(c,r)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",s)}function Mt(t,n,e){if(!(t.state.selection instanceof r))return null;const{$head:o}=t.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((e<0?o.index(r):o.indexAfter(r))!=(e<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),l="vert"==n?e>0?"down":"up":e>0?"right":"left";return t.endOfTextblock(l)?i:null}}return null}function yt(t,n){for(;n&&n!=t.dom;n=n.parentNode)if("TD"==n.nodeName||"TH"==n.nodeName)return n;return null}function Dt(t,n){const e=t.posAtCoords({left:n.clientX,top:n.clientY});if(!e)return null;let{inside:o,pos:r}=e;return o>=0&&z(t.state.doc.resolve(o))||z(t.state.doc.resolve(r))}var St=class{constructor(t,n){this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$t(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,$t(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function $t(t,n,e,o,r,i){let l=0,s=!0,c=n.firstChild;const f=t.firstChild;if(f){for(let t=0,e=0;t<f.childCount;t++){const{colspan:u,colwidth:a}=f.child(t).attrs;for(let t=0;t<u;t++,e++){const f=r==e?i:a&&a[t],u=f?f+"px":"";if(l+=f||o,f||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{const t=document.createElement("col");t.style.width=u,n.appendChild(t)}}}for(;c;){var u;const t=c.nextSibling;null===(u=c.parentNode)||void 0===u||u.removeChild(c),c=t}s?(e.style.width=l+"px",e.style.minWidth=""):(e.style.width="",e.style.minWidth=l+"px")}}const Et=new n("tableColumnResizing");function Rt({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:r=St,lastColumnResizable:i=!0}={}){const l=new t({key:Et,state:{init(t,n){var e;const i=null===(e=l.spec)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.nodeViews,s=_(n.schema).table.name;return r&&i&&(i[s]=(t,n)=>new r(t,o,n)),new _t(-1,!1)},apply:(t,n)=>n.apply(t)},props:{attributes:t=>{const n=Et.getState(t);return n&&n.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,e)=>{!function(t,n,e,o){if(!t.editable)return;const r=Et.getState(t.state);if(!r)return;if(!r.dragging){const i=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(n.target);let l=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();n.clientX-o<=e?l=Nt(t,n,"left",e):r-n.clientX<=e&&(l=Nt(t,n,"right",e))}if(l!=r.activeHandle){if(!o&&-1!==l){const n=t.state.doc.resolve(l),e=n.node(-1),o=y.get(e),r=n.start(-1);if(o.colCount(n.pos-r)+n.nodeAfter.attrs.colspan-1==o.width-1)return}kt(t,l)}}}(t,e,n,i)},mouseleave:t=>{!function(t){if(!t.editable)return;const n=Et.getState(t.state);n&&n.activeHandle>-1&&!n.dragging&&kt(t,-1)}(t)},mousedown:(t,n)=>{!function(t,n,e,o){var r;if(!t.editable)return!1;const i=null!==(r=t.dom.ownerDocument.defaultView)&&void 0!==r?r:window,l=Et.getState(t.state);if(!l||-1==l.activeHandle||l.dragging)return!1;const s=t.state.doc.nodeAt(l.activeHandle),c=function(t,n,{colspan:e,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=t.domAtPos(n);let l=i.node.childNodes[i.offset].offsetWidth,s=e;if(o)for(let t=0;t<e;t++)o[t]&&(l-=o[t],s--);return l/s}(t,l.activeHandle,s.attrs);function f(n){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",u);const o=Et.getState(t.state);(null==o?void 0:o.dragging)&&(!function(t,n,e){const o=t.state.doc.resolve(n),r=o.node(-1),i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let t=0;t<i.height;t++){const n=t*i.width+s;if(t&&i.map[n]==i.map[n-i.width])continue;const o=i.map[n],f=r.nodeAt(o).attrs,u=1==f.colspan?0:s-i.colCount(o);if(f.colwidth&&f.colwidth[u]==e)continue;const a=f.colwidth?f.colwidth.slice():Ct(f.colspan);a[u]=e,c.setNodeMarkup(l+o,null,{...f,colwidth:a})}c.docChanged&&t.dispatch(c)}(t,o.activeHandle,zt(o.dragging,n,e)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})))}function u(n){if(!n.which)return f(n);const r=Et.getState(t.state);if(r&&r.dragging){const i=zt(r.dragging,n,e);At(t,r.activeHandle,i,o)}}t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:n.clientX,startWidth:c}})),At(t,l.activeHandle,c,o),i.addEventListener("mouseup",f),i.addEventListener("mousemove",u),n.preventDefault()}(t,n,e,o)}},decorations:t=>{const n=Et.getState(t);if(n&&n.activeHandle>-1)return function(t,n){const e=[],o=t.doc.resolve(n),r=o.node(-1);if(!r)return f.empty;const i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let n=0;n<i.height;n++){const o=s+n*i.width;if(!(s!=i.width-1&&i.map[o]==i.map[o+1]||0!=n&&i.map[o]==i.map[o-i.width])){var c;const n=i.map[o],s=l+n+r.nodeAt(n).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(null===(c=Et.getState(t))||void 0===c?void 0:c.dragging)&&e.push(u.node(l+n,l+n+r.nodeAt(n).nodeSize,{class:"column-resize-dragging"})),e.push(u.widget(s,f))}}return f.create(t.doc,e)}(t,n.activeHandle)},nodeViews:{}}});return l}var _t=class t{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(n){const e=this,o=n.getMeta(Et);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(e.activeHandle,o.setDragging);if(e.activeHandle>-1&&n.docChanged){let o=n.mapping.map(e.activeHandle,-1);return C(n.doc.resolve(o))||(o=-1),new t(o,e.dragging)}return e}};function Nt(t,n,e,o){const r="right"==e?-o:o,i=t.posAtCoords({left:n.clientX+r,top:n.clientY});if(!i)return-1;const{pos:l}=i,s=z(t.state.doc.resolve(l));if(!s)return-1;if("right"==e)return s.pos;const c=y.get(s.node(-1)),f=s.start(-1),u=c.map.indexOf(s.pos-f);return u%c.width==0?-1:f+c.map[u-1]}function zt(t,n,e){const o=n.clientX-t.startX;return Math.max(e,t.startWidth+o)}function kt(t,n){t.dispatch(t.state.tr.setMeta(Et,{setHandle:n}))}function At(t,n,e,o){const r=t.state.doc.resolve(n),i=r.node(-1),l=r.start(-1),s=y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;let c=t.domAtPos(r.start(-1)).node;for(;c&&"TABLE"!=c.nodeName;)c=c.parentNode;c&&$t(i,c.firstChild,c,o,s,e)}function Ct(t){return Array(t).fill(0)}function Ot({allowTableNodeSelection:n=!1}={}){return new t({key:N,state:{init:()=>null,apply(t,n){const e=t.getMeta(N);if(null!=e)return-1==e?null:e;if(null==n||!t.docChanged)return n;const{deleted:o,pos:r}=t.mapping.mapResult(n);return o?null:r}},props:{decorations:j,handleDOMEvents:{mousedown:vt},createSelectionBetween:t=>null!=N.getState(t.state)?t.state.selection:null,handleTripleClick:gt,handleKeyDown:wt,handlePaste:bt},appendTransaction:(t,e,o)=>function(t,n,e){const o=(n||t).selection,i=(n||t).doc;let l,c;if(o instanceof s&&(c=o.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)l=L.create(i,o.from);else if("row"==c){const t=i.resolve(o.from+1);l=L.rowSelection(t,t)}else if(!e){const t=y.get(o.node),n=o.from+1,e=n+t.map[t.width*t.height-1];l=L.create(i,n+1,e)}}else o instanceof r&&function({$from:t,$to:n}){if(t.pos==n.pos||t.pos<n.pos-6)return!1;let e=t.pos,o=n.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,e++);for(let t=n.depth;t>=0&&!(n.before(t+1)>n.start(t));t--,o--);return e==o&&/row|table/.test(t.node(r).type.spec.tableRole)}(o)?l=r.create(i,o.from):o instanceof r&&function({$from:t,$to:n}){let e,o;for(let n=t.depth;n>0;n--){const o=t.node(n);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){e=o;break}}for(let t=n.depth;t>0;t--){const e=n.node(t);if("cell"===e.type.spec.tableRole||"header_cell"===e.type.spec.tableRole){o=e;break}}return e!==o&&0===n.parentOffset}(o)&&(l=r.create(i,o.$from.start(),o.$from.end()));return l&&(n||(n=t.tr)).setSelection(l),n}(o,J(o,e),n)})}export{St as T,R as a,b,Rt as c,lt as d,it as e,I as f,Z as g,q as h,V as i,Q as j,g as k,G as l,nt as m,et as s,Ot as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./index-89c520e9.cjs.js","./index-cc1385e0.cjs.js","./index-178e1e57.cjs.js"],function(_export,_context){"use strict";var t,n,e,o,r,i,l,s,c,f,u,a,h,w,d,v,M,_t3,_t4,_n,_e2,_y,N,j,L,P,it,wt,St,Et,_t;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n33){function n(){return _n33.apply(this,arguments);}n.toString=function(){return _n33.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function p(t){var n,e,o,r,i=t.split(/-(?!$)/),l=i[i.length-1];"Space"==l&&(l=" ");for(var _t2=0;_t2<i.length-1;_t2++){var _l=i[_t2];if(/^(cmd|meta|m)$/i.test(_l))r=!0;else if(/^a(lt)?$/i.test(_l))n=!0;else if(/^(c|ctrl|control)$/i.test(_l))e=!0;else if(/^s(hift)?$/i.test(_l))o=!0;else{if(!/^mod$/i.test(_l))throw new Error("Unrecognized modifier name: "+_l);w?r=!0:e=!0;}}return n&&(l="Alt-"+l),e&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l;}function m(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;return n.altKey&&(t="Alt-"+t),n.ctrlKey&&(t="Ctrl-"+t),n.metaKey&&(t="Meta-"+t),e&&n.shiftKey&&(t="Shift-"+t),t;}function g(n){return new t({props:{handleKeyDown:b(n)}});}function b(t){var n=function(t){var n=Object.create(null);for(var _e in t)n[p(_e)]=t[_e];return n;}(t);return function(t,e){var o,r=a(e),i=n[m(r,e)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(e.shiftKey){var _o=n[m(r,e,!1)];if(_o&&_o(t.state,t.dispatch,t))return!0;}if((e.altKey||e.metaKey||e.ctrlKey)&&!(d&&e.ctrlKey&&e.altKey)&&(o=h[e.keyCode])&&o!=r){var _r=n[m(o,e)];if(_r&&_r(t.state,t.dispatch,t))return!0;}}return!1;};}function D(t){if(t.colwidth)return t.colwidth.slice();var n=[];for(var _e9=0;_e9<t.colspan;_e9++)n.push(0);return n;}function S(t,n){if("string"==typeof t)return{};var e=t.getAttribute("data-colwidth"),o=e&&/^\d+(,\d+)*$/.test(e)?e.split(",").map(function(t){return Number(t);}):null,r=Number(t.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(var _e10 in n){var _o9=n[_e10].getFromDOM,_r10=_o9&&_o9(t);null!=_r10&&(i[_e10]=_r10);}return i;}function $(t,n){var e={};1!=t.attrs.colspan&&(e.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(e.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(e["data-colwidth"]=t.attrs.colwidth.join(","));for(var _o10 in n){var _r11=n[_o10].setDOMAttr;_r11&&_r11(t.attrs[_o10],e);}return e;}function E(t){if(null!==t){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");var _iterator=_createForOfIteratorHelper(t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _n6=_step.value;if("number"!=typeof _n6)throw new TypeError("colwidth must be null or an array of numbers");}}catch(err){_iterator.e(err);}finally{_iterator.f();}}}function R(t){var n=t.cellAttributes||{},e={colspan:{"default":1,validate:"number"},rowspan:{"default":1,validate:"number"},colwidth:{"default":null,validate:E}};for(var _t14 in n)e[_t14]={"default":n[_t14]["default"],validate:n[_t14].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:function toDOM(){return["table",["tbody",0]];}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:function toDOM(){return["tr",0];}},table_cell:{content:t.cellContent,attrs:e,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:function getAttrs(t){return S(t,n);}}],toDOM:function toDOM(t){return["td",$(t,n),0];}},table_header:{content:t.cellContent,attrs:e,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:function getAttrs(t){return S(t,n);}}],toDOM:function toDOM(t){return["th",$(t,n),0];}}};}function _(t){var n=t.cached.tableNodeTypes;if(!n){n=t.cached.tableNodeTypes={};for(var _e11 in t.nodes){var _o11=t.nodes[_e11],_r12=_o11.spec.tableRole;_r12&&(n[_r12]=_o11);}}return n;}function z(t){for(var _n7=t.depth-1;_n7>0;_n7--)if("row"==t.node(_n7).type.spec.tableRole)return t.node(0).resolve(t.before(_n7+1));return null;}function k(t){var n=t.selection.$head;for(var _t15=n.depth;_t15>0;_t15--)if("row"==n.node(_t15).type.spec.tableRole)return!0;return!1;}function A(t){var n=t.selection;if("$anchorCell"in n&&n.$anchorCell)return n.$anchorCell.pos>n.$headCell.pos?n.$anchorCell:n.$headCell;if("node"in n&&n.node&&"cell"==n.node.type.spec.tableRole)return n.$anchor;var e=z(n.$head)||function(t){for(var _n8=t.nodeAfter,_e12=t.pos;_n8;_n8=_n8.firstChild,_e12++){var _o12=_n8.type.spec.tableRole;if("cell"==_o12||"header_cell"==_o12)return t.doc.resolve(_e12);}for(var _n9=t.nodeBefore,_e13=t.pos;_n9;_n9=_n9.lastChild,_e13--){var _o13=_n9.type.spec.tableRole;if("cell"==_o13||"header_cell"==_o13)return t.doc.resolve(_e13-_n9.nodeSize);}}(n.$head);if(e)return e;throw new RangeError("No cell found around position ".concat(n.head));}function C(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter;}function O(t,n){return t.depth==n.depth&&t.pos>=n.start(-1)&&t.pos<=n.end(-1);}function x(t,n,e){var o=t.node(-1),r=_y.get(o),i=t.start(-1),l=r.nextCell(t.pos-i,n,e);return null==l?null:t.node(0).resolve(i+l);}function T(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var o=_objectSpread(_objectSpread({},t),{},{colspan:t.colspan-e});return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(n,e),o.colwidth.some(function(t){return t>0;})||(o.colwidth=null)),o;}function W(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var o=_objectSpread(_objectSpread({},t),{},{colspan:t.colspan+e});if(o.colwidth){o.colwidth=o.colwidth.slice();for(var _t16=0;_t16<e;_t16++)o.colwidth.splice(n,0,0);}return o;}function B(t){if(!(t.selection instanceof j))return null;var n=[];return t.selection.forEachCell(function(t,e){n.push(u.node(e,e+t.nodeSize,{"class":"selectedCell"}));}),f.create(t.doc,n);}function H(t,n,e,o){var r=t.childCount,i=n.childCount;t:for(var _l6=0,_s6=0;_l6<i;_l6++){var _i8=n.child(_l6);for(var _n11=_s6,_o14=Math.min(r,_l6+3);_n11<_o14;_n11++)if(t.child(_n11)==_i8){_s6=_n11+1,e+=_i8.nodeSize;continue t;}o(_i8,e),_s6<r&&t.child(_s6).sameMarkup(_i8)?H(t.child(_s6),_i8,e+1,o):_i8.nodesBetween(0,_i8.content.size,o,e+1),e+=_i8.nodeSize;}}function J(t,n){var e;var o=function o(n,_o15){"table"==n.type.spec.tableRole&&(e=function(t,n,e,o){var r=_y.get(n);if(!r.problems)return o;o||(o=t.tr);var i=[];for(var _t30=0;_t30<r.height;_t30++)i.push(0);for(var _t31=0;_t31<r.problems.length;_t31++){var _l7=r.problems[_t31];if("collision"==_l7.type){var _t32=n.nodeAt(_l7.pos);if(!_t32)continue;var _r13=_t32.attrs;for(var _t33=0;_t33<_r13.rowspan;_t33++)i[_l7.row+_t33]+=_l7.n;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,T(_r13,_r13.colspan-_l7.n,_l7.n));}else if("missing"==_l7.type)i[_l7.row]+=_l7.n;else if("overlong_rowspan"==_l7.type){var _t34=n.nodeAt(_l7.pos);if(!_t34)continue;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,_objectSpread(_objectSpread({},_t34.attrs),{},{rowspan:_t34.attrs.rowspan-_l7.n}));}else if("colwidth mismatch"==_l7.type){var _t35=n.nodeAt(_l7.pos);if(!_t35)continue;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,_objectSpread(_objectSpread({},_t35.attrs),{},{colwidth:_l7.colwidth}));}else if("zero_sized"==_l7.type){var _t36=o.mapping.map(e);o["delete"](_t36,_t36+n.nodeSize);}}var l,s;for(var _t37=0;_t37<i.length;_t37++)i[_t37]&&(null==l&&(l=_t37),s=_t37);for(var _c5=0,_f4=e+1;_c5<r.height;_c5++){var _e19=n.child(_c5),_r14=_f4+_e19.nodeSize,_u4=i[_c5];if(_u4>0){var _n12="cell";_e19.firstChild&&(_n12=_e19.firstChild.type.spec.tableRole);var _i9=[];for(var _e20=0;_e20<_u4;_e20++){var _e21=_(t.schema)[_n12].createAndFill();_e21&&_i9.push(_e21);}var _a3=0!=_c5&&l!=_c5-1||s!=_c5?_r14-1:_f4+1;o.insert(o.mapping.map(_a3),_i9);}_f4=_r14;}return o.setMeta(P,{fixTables:!0});}(t,n,_o15,e));};return n?n.doc!=t.doc&&H(n.doc,t.doc,0,o):t.doc.descendants(o),e;}function U(t){var n=t.selection,e=A(t),o=e.node(-1),r=e.start(-1),i=_y.get(o);return _objectSpread(_objectSpread({},n instanceof j?i.rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r):i.findCell(e.pos-r)),{},{tableStart:r,map:i,table:o});}function K(t,_ref,r){var n=_ref.map,e=_ref.tableStart,o=_ref.table;var i=r>0?-1:0;(function(t,n,e){var o=_(n.type.schema).header_cell;for(var _r15=0;_r15<t.height;_r15++)if(n.nodeAt(t.map[e+_r15*t.width]).type!=o)return!1;return!0;})(n,o,r+i)&&(i=0==r||r==n.width?null:0);for(var _l8=0;_l8<n.height;_l8++){var _s7=_l8*n.width+r;if(r>0&&r<n.width&&n.map[_s7-1]==n.map[_s7]){var _i10=n.map[_s7],_c6=o.nodeAt(_i10);t.setNodeMarkup(t.mapping.map(e+_i10),null,W(_c6.attrs,r-n.colCount(_i10))),_l8+=_c6.attrs.rowspan-1;}else{var _c7=null==i?_(o.type.schema).cell:o.nodeAt(n.map[_s7+i]).type,_f5=n.positionAt(_l8,r,o);t.insert(t.mapping.map(e+_f5),_c7.createAndFill());}}return t;}function V(t,n){if(!k(t))return!1;if(n){var _e22=U(t);n(K(t.tr,_e22,_e22.left));}return!0;}function q(t,n){if(!k(t))return!1;if(n){var _e23=U(t);n(K(t.tr,_e23,_e23.right));}return!0;}function F(t,_ref2,r){var n=_ref2.map,e=_ref2.table,o=_ref2.tableStart;var i=t.mapping.maps.length;for(var _l9=0;_l9<n.height;){var _s8=_l9*n.width+r,_c8=n.map[_s8],_f6=e.nodeAt(_c8),_u5=_f6.attrs;if(r>0&&n.map[_s8-1]==_c8||r<n.width-1&&n.map[_s8+1]==_c8)t.setNodeMarkup(t.mapping.slice(i).map(o+_c8),null,T(_u5,r-n.colCount(_c8)));else{var _n13=t.mapping.slice(i).map(o+_c8);t["delete"](_n13,_n13+_f6.nodeSize);}_l9+=_u5.rowspan;}}function I(t,n){if(!k(t))return!1;if(n){var _e24=U(t),_o16=t.tr;if(0==_e24.left&&_e24.right==_e24.map.width)return!1;for(var _t38=_e24.right-1;F(_o16,_e24,_t38),_t38!=_e24.left;_t38--){var _t39=_e24.tableStart?_o16.doc.nodeAt(_e24.tableStart-1):_o16.doc;if(!_t39)throw new RangeError("No table found");_e24.table=_t39,_e24.map=_y.get(_t39);}n(_o16);}return!0;}function X(t,_ref3,r){var n=_ref3.map,e=_ref3.tableStart,o=_ref3.table;var i=e;for(var _t40=0;_t40<r;_t40++)i+=o.child(_t40).nodeSize;var l=[];var s=r>0?-1:0;(function(t,n,e){var o;var r=_(n.type.schema).header_cell;for(var _i11=0;_i11<t.width;_i11++)if((null===(o=n.nodeAt(t.map[_i11+e*t.width]))||void 0===o?void 0:o.type)!=r)return!1;return!0;})(n,o,r+s)&&(s=0==r||r==n.height?null:0);for(var _i12=0,_f7=n.width*r;_i12<n.width;_i12++,_f7++)if(r>0&&r<n.height&&n.map[_f7]==n.map[_f7-n.width]){var _r16=n.map[_f7],_l10=o.nodeAt(_r16).attrs;t.setNodeMarkup(e+_r16,null,_objectSpread(_objectSpread({},_l10),{},{rowspan:_l10.rowspan+1})),_i12+=_l10.colspan-1;}else{var c;var _t41=null==s?_(o.type.schema).cell:null===(c=o.nodeAt(n.map[_f7+s*n.width]))||void 0===c?void 0:c.type,_e25=null==_t41?void 0:_t41.createAndFill();_e25&&l.push(_e25);}return t.insert(i,_(o.type.schema).row.create(null,l)),t;}function G(t,n){if(!k(t))return!1;if(n){var _e26=U(t);n(X(t.tr,_e26,_e26.top));}return!0;}function Q(t,n){if(!k(t))return!1;if(n){var _e27=U(t);n(X(t.tr,_e27,_e27.bottom));}return!0;}function Y(t,_ref4,r){var n=_ref4.map,e=_ref4.table,o=_ref4.tableStart;var i=0;for(var _t42=0;_t42<r;_t42++)i+=e.child(_t42).nodeSize;var l=i+e.child(r).nodeSize,s=t.mapping.maps.length;t["delete"](i+o,l+o);var c=new Set();for(var _i13=0,_l11=r*n.width;_i13<n.width;_i13++,_l11++){var _f8=n.map[_l11];if(!c.has(_f8))if(c.add(_f8),r>0&&_f8==n.map[_l11-n.width]){var _n14=e.nodeAt(_f8).attrs;t.setNodeMarkup(t.mapping.slice(s).map(_f8+o),null,_objectSpread(_objectSpread({},_n14),{},{rowspan:_n14.rowspan-1})),_i13+=_n14.colspan-1;}else if(r<n.height&&_f8==n.map[_l11+n.width]){var _l12=e.nodeAt(_f8),_c9=_l12.attrs,_u6=_l12.type.create(_objectSpread(_objectSpread({},_c9),{},{rowspan:_l12.attrs.rowspan-1}),_l12.content),_a4=n.positionAt(r+1,_i13,e);t.insert(t.mapping.slice(s).map(o+_a4),_u6),_i13+=_c9.colspan-1;}}}function Z(t,n){if(!k(t))return!1;if(n){var _e28=U(t),_o17=t.tr;if(0==_e28.top&&_e28.bottom==_e28.map.height)return!1;for(var _t43=_e28.bottom-1;Y(_o17,_e28,_t43),_t43!=_e28.top;_t43--){var _t44=_e28.tableStart?_o17.doc.nodeAt(_e28.tableStart-1):_o17.doc;if(!_t44)throw new RangeError("No table found");_e28.table=_t44,_e28.map=_y.get(_e28.table);}n(_o17);}return!0;}function tt(t){var n=t.content;return 1==n.childCount&&n.child(0).isTextblock&&0==n.child(0).childCount;}function nt(t,n){var e=t.selection;if(!(e instanceof j)||e.$anchorCell.pos==e.$headCell.pos)return!1;var o=U(t),r=o.map;if(function(_ref5,o){var t=_ref5.width,n=_ref5.height,e=_ref5.map;var r=o.top*t+o.left,i=r,l=(o.bottom-1)*t+o.left,s=r+(o.right-o.left-1);for(var _n15=o.top;_n15<o.bottom;_n15++){if(o.left>0&&e[i]==e[i-1]||o.right<t&&e[s]==e[s+1])return!0;i+=t,s+=t;}for(var _i14=o.left;_i14<o.right;_i14++){if(o.top>0&&e[r]==e[r-t]||o.bottom<n&&e[l]==e[l+t])return!0;r++,l++;}return!1;}(r,o))return!1;if(n){var _e29=t.tr,_l13={};var _s9,_c10,_f9=i.empty;for(var _t45=o.top;_t45<o.bottom;_t45++)for(var _n16=o.left;_n16<o.right;_n16++){var _i15=r.map[_t45*r.width+_n16],_u7=o.table.nodeAt(_i15);if(!_l13[_i15]&&_u7)if(_l13[_i15]=!0,null==_s9)_s9=_i15,_c10=_u7;else{tt(_u7)||(_f9=_f9.append(_u7.content));var _t46=_e29.mapping.map(_i15+o.tableStart);_e29["delete"](_t46,_t46+_u7.nodeSize);}}if(null==_s9||null==_c10)return!0;if(_e29.setNodeMarkup(_s9+o.tableStart,null,_objectSpread(_objectSpread({},W(_c10.attrs,_c10.attrs.colspan,o.right-o.left-_c10.attrs.colspan)),{},{rowspan:o.bottom-o.top})),_f9.size>0){var _t47=_s9+1+_c10.content.size,_n17=tt(_c10)?_s9+1:_t47;_e29.replaceWith(_n17+o.tableStart,_t47+o.tableStart,_f9);}_e29.setSelection(new j(_e29.doc.resolve(_s9+o.tableStart))),n(_e29);}return!0;}function et(t,n){var e=_(t.schema);return(o=function o(_ref6){var t=_ref6.node;return e[t.type.spec.tableRole];},function(t,n){var e=t.selection;var r,i;if(e instanceof j){if(e.$anchorCell.pos!=e.$headCell.pos)return!1;r=e.$anchorCell.nodeAfter,i=e.$anchorCell.pos;}else{var l;if(r=function(t){for(var _n18=t.depth;_n18>0;_n18--){var _e30=t.node(_n18).type.spec.tableRole;if("cell"===_e30||"header_cell"===_e30)return t.node(_n18);}return null;}(e.$from),!r)return!1;i=null===(l=z(e.$from))||void 0===l?void 0:l.pos;}if(null==r||null==i)return!1;if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){var _l14=r.attrs;var _s10=[],_c11=_l14.colwidth;_l14.rowspan>1&&(_l14=_objectSpread(_objectSpread({},_l14),{},{rowspan:1})),_l14.colspan>1&&(_l14=_objectSpread(_objectSpread({},_l14),{},{colspan:1}));var _f10=U(t),_u8=t.tr;for(var _t48=0;_t48<_f10.right-_f10.left;_t48++)_s10.push(_c11?_objectSpread(_objectSpread({},_l14),{},{colwidth:_c11&&_c11[_t48]?[_c11[_t48]]:null}):_l14);var _a5;for(var _t49=_f10.top;_t49<_f10.bottom;_t49++){var _n19=_f10.map.positionAt(_t49,_f10.left,_f10.table);_t49==_f10.top&&(_n19+=r.nodeSize);for(var _e31=_f10.left,_i16=0;_e31<_f10.right;_e31++,_i16++)_e31==_f10.left&&_t49==_f10.top||_u8.insert(_a5=_u8.mapping.map(_n19+_f10.tableStart,1),o({node:r,row:_t49,col:_e31}).createAndFill(_s10[_i16]));}_u8.setNodeMarkup(i,o({node:r,row:_f10.top,col:_f10.left}),_s10[0]),e instanceof j&&_u8.setSelection(new j(_u8.doc.resolve(e.$anchorCell.pos),_a5?_u8.doc.resolve(_a5):void 0)),n(_u8);}return!0;})(t,n);var o;}function ot(t,n,e){var o=n.map.cellsInRect({left:0,top:0,right:"row"==t?n.map.width:1,bottom:"column"==t?n.map.height:1});for(var _t50=0;_t50<o.length;_t50++){var _r17=n.table.nodeAt(o[_t50]);if(_r17&&_r17.type!==e.header_cell)return!1;}return!0;}function rt(t,n){return(n=n||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(n,e){if(!k(n))return!1;if(e){var _o18=_(n.schema),_r18=U(n),_i17=n.tr,_l15=_r18.map.cellsInRect("column"==t?{left:_r18.left,top:0,right:_r18.right,bottom:_r18.map.height}:"row"==t?{left:0,top:_r18.top,right:_r18.map.width,bottom:_r18.bottom}:_r18),_s11=_l15.map(function(t){return _r18.table.nodeAt(t);});for(var _t51=0;_t51<_l15.length;_t51++)_s11[_t51].type==_o18.header_cell&&_i17.setNodeMarkup(_r18.tableStart+_l15[_t51],_o18.cell,_s11[_t51].attrs);if(0===_i17.steps.length)for(var _t52=0;_t52<_l15.length;_t52++)_i17.setNodeMarkup(_r18.tableStart+_l15[_t52],_o18.header_cell,_s11[_t52].attrs);e(_i17);}return!0;};}(t):function(n,e){if(!k(n))return!1;if(e){var _o19=_(n.schema),_r19=U(n),_i18=n.tr,_l16=ot("row",_r19,_o19),_s12=ot("column",_r19,_o19),_c12=("column"===t?_l16:"row"===t&&_s12)?1:0,_f11="column"==t?{left:0,top:_c12,right:1,bottom:_r19.map.height}:"row"==t?{left:_c12,top:0,right:_r19.map.width,bottom:1}:_r19,_u9="column"==t?_s12?_o19.cell:_o19.header_cell:"row"==t?_l16?_o19.cell:_o19.header_cell:_o19.cell;_r19.map.cellsInRect(_f11).forEach(function(t){var n=t+_r19.tableStart,e=_i18.doc.nodeAt(n);e&&_i18.setNodeMarkup(n,_u9,e.attrs);}),e(_i18);}return!0;};}function lt(t,n){var e=t.selection.$anchor;for(var _o20=e.depth;_o20>0;_o20--)if("table"==e.node(_o20).type.spec.tableRole)return n&&n(t.tr["delete"](e.before(_o20),e.after(_o20)).scrollIntoView()),!0;return!1;}function st(t,n){var e=t.selection;if(!(e instanceof j))return!1;if(n){var _o21=t.tr,_r20=_(t.schema).cell.createAndFill().content;e.forEachCell(function(t,n){t.content.eq(_r20)||_o21.replace(_o21.mapping.map(n+1),_o21.mapping.map(n+t.nodeSize-1),new l(_r20,0,0));}),_o21.docChanged&&n(_o21);}return!0;}function ct(t){if(0===t.size)return null;var n=t.content,e=t.openStart,o=t.openEnd;for(;1==n.childCount&&(e>0&&o>0||"table"==n.child(0).type.spec.tableRole);)e--,o--,n=n.child(0).content;var r=n.child(0),s=r.type.spec.tableRole,c=r.type.schema,f=[];if("row"==s)for(var _t53=0;_t53<n.childCount;_t53++){var _r21=n.child(_t53).content;var _i19=_t53?0:Math.max(0,e-1),_s13=_t53<n.childCount-1?0:Math.max(0,o-1);(_i19||_s13)&&(_r21=ft(_(c).row,new l(_r21,_i19,_s13)).content),f.push(_r21);}else{if("cell"!=s&&"header_cell"!=s)return null;f.push(e||o?ft(_(c).row,new l(n,e,o)).content:n);}return function(t,n){var e=[];for(var _t54=0;_t54<n.length;_t54++){var _o22=n[_t54];for(var _n20=_o22.childCount-1;_n20>=0;_n20--){var _o22$child$attrs=_o22.child(_n20).attrs,_r22=_o22$child$attrs.rowspan,_i20=_o22$child$attrs.colspan;for(var _n21=_t54;_n21<_t54+_r22;_n21++)e[_n21]=(e[_n21]||0)+_i20;}}var o=0;for(var _t55=0;_t55<e.length;_t55++)o=Math.max(o,e[_t55]);for(var _r23=0;_r23<e.length;_r23++)if(_r23>=n.length&&n.push(i.empty),e[_r23]<o){var _l17=_(t).cell.createAndFill(),_s14=[];for(var _t56=e[_r23];_t56<o;_t56++)_s14.push(_l17);n[_r23]=n[_r23].append(i.from(_s14));}return{height:n.length,width:o,rows:n};}(c,f);}function ft(t,n){var e=t.createAndFill();return new c(e).replace(0,e.content.size,n).doc;}function ut(t,n,e,o,r,i,l,s){if(0==l||l==n.height)return!1;var c=!1;for(var _f12=r;_f12<i;_f12++){var _r24=l*n.width+_f12,_i21=n.map[_r24];if(n.map[_r24-n.width]==_i21){c=!0;var _r25=e.nodeAt(_i21),_n$findCell=n.findCell(_i21),_u10=_n$findCell.top,_a6=_n$findCell.left;t.setNodeMarkup(t.mapping.slice(s).map(_i21+o),null,_objectSpread(_objectSpread({},_r25.attrs),{},{rowspan:l-_u10})),t.insert(t.mapping.slice(s).map(n.positionAt(l,_a6,e)),_r25.type.createAndFill(_objectSpread(_objectSpread({},_r25.attrs),{},{rowspan:_u10+_r25.attrs.rowspan-l}))),_f12+=_r25.attrs.colspan-1;}}return c;}function at(t,n,e,o,r,i,l,s){if(0==l||l==n.width)return!1;var c=!1;for(var _f13=r;_f13<i;_f13++){var _r26=_f13*n.width+l,_i22=n.map[_r26];if(n.map[_r26-1]==_i22){c=!0;var _r27=e.nodeAt(_i22),_u11=n.colCount(_i22),_a7=t.mapping.slice(s).map(_i22+o);t.setNodeMarkup(_a7,null,T(_r27.attrs,l-_u11,_r27.attrs.colspan-(l-_u11))),t.insert(_a7+_r27.nodeSize,_r27.type.createAndFill(T(_r27.attrs,0,l-_u11))),_f13+=_r27.attrs.rowspan-1;}}return c;}function ht(t,n,e,o,r){var s=e?t.doc.nodeAt(e-1):t.doc;if(!s)throw new Error("No table found");var c=_y.get(s);var f=o.top,u=o.left,a=u+r.width,h=f+r.height,w=t.tr;var d=0;function p(){if(s=e?w.doc.nodeAt(e-1):w.doc,!s)throw new Error("No table found");c=_y.get(s),d=w.mapping.maps.length;}(function(t,n,e,o,r,l,s){var c=_(t.doc.type.schema);var f,u;if(r>n.width)for(var _i23=0,_l18=0;_i23<n.height;_i23++){var _a8=e.child(_i23);_l18+=_a8.nodeSize;var _h2=[];var _w2=void 0;_w2=null==_a8.lastChild||_a8.lastChild.type==c.cell?f||(f=c.cell.createAndFill()):u||(u=c.header_cell.createAndFill());for(var _t57=n.width;_t57<r;_t57++)_h2.push(_w2);t.insert(t.mapping.slice(s).map(_l18-1+o),_h2);}if(l>n.height){var _a9=[];for(var _t58=0,_o23=(n.height-1)*n.width;_t58<Math.max(n.width,r);_t58++){var _r28=!(_t58>=n.width)&&e.nodeAt(n.map[_o23+_t58]).type==c.header_cell;_a9.push(_r28?u||(u=c.header_cell.createAndFill()):f||(f=c.cell.createAndFill()));}var _h3=c.row.create(null,i.from(_a9)),_w3=[];for(var _t59=n.height;_t59<l;_t59++)_w3.push(_h3);t.insert(t.mapping.slice(s).map(o+e.nodeSize-2),_w3);}return!(!f&&!u);})(w,c,s,e,a,h,d)&&p(),ut(w,c,s,e,u,a,f,d)&&p(),ut(w,c,s,e,u,a,h,d)&&p(),at(w,c,s,e,f,h,u,d)&&p(),at(w,c,s,e,f,h,a,d)&&p();for(var _t60=f;_t60<h;_t60++){var _n22=c.positionAt(_t60,u,s),_o24=c.positionAt(_t60,a,s);w.replace(w.mapping.slice(d).map(_n22+e),w.mapping.slice(d).map(_o24+e),new l(r.rows[_t60-f],0,0));}p(),w.setSelection(new j(w.doc.resolve(e+c.positionAt(f,u,s)),w.doc.resolve(e+c.positionAt(h-1,a-1,s)))),n(w);}function dt(t,n,e){return!e.eq(t.selection)&&(n&&n(t.tr.setSelection(e).scrollIntoView()),!0);}function pt(t,n){return function(o,r,i){if(!i)return!1;var l=o.selection;if(l instanceof j)return dt(o,r,e.near(l.$headCell,n));if("horiz"!=t&&!l.empty)return!1;var s=Mt(i,t,n);if(null==s)return!1;if("horiz"==t)return dt(o,r,e.near(o.doc.resolve(l.head+n),n));{var _i24=o.doc.resolve(s),_l19=x(_i24,t,n);var _c13;return _c13=_l19?e.near(_l19,1):n<0?e.near(o.doc.resolve(_i24.before(-1)),-1):e.near(o.doc.resolve(_i24.after(-1)),1),dt(o,r,_c13);}};}function mt(t,n){return function(e,o,r){if(!r)return!1;var i=e.selection;var l;if(i instanceof j)l=i;else{var _o25=Mt(r,t,n);if(null==_o25)return!1;l=new j(e.doc.resolve(_o25));}var s=x(l.$headCell,t,n);return!!s&&dt(e,o,new j(l.$anchorCell,s));};}function gt(t,n){var e=z(t.state.doc.resolve(n));return!!e&&(t.dispatch(t.state.tr.setSelection(new j(e))),!0);}function bt(t,n,e){if(!k(t.state))return!1;var o=ct(e);var r=t.state.selection;if(r instanceof j){o||(o={width:1,height:1,rows:[i.from(ft(_(t.state.schema).cell,e))]});var _n23=r.$anchorCell.node(-1),_l20=r.$anchorCell.start(-1),_s15=_y.get(_n23).rectBetween(r.$anchorCell.pos-_l20,r.$headCell.pos-_l20);return o=function(_ref7,o,r){var t=_ref7.width,n=_ref7.height,e=_ref7.rows;if(t!=o){var _n24=[],_r29=[];for(var _t61=0;_t61<e.length;_t61++){var _l21=e[_t61],_s16=[];for(var _e32=_n24[_t61]||0,_r30=0;_e32<o;_r30++){var _i25=_l21.child(_r30%_l21.childCount);_e32+_i25.attrs.colspan>o&&(_i25=_i25.type.createChecked(T(_i25.attrs,_i25.attrs.colspan,_e32+_i25.attrs.colspan-o),_i25.content)),_s16.push(_i25),_e32+=_i25.attrs.colspan;for(var _e33=1;_e33<_i25.attrs.rowspan;_e33++)_n24[_t61+_e33]=(_n24[_t61+_e33]||0)+_i25.attrs.colspan;}_r29.push(i.from(_s16));}e=_r29,t=o;}if(n!=r){var _t62=[];for(var _o26=0,_l22=0;_o26<r;_o26++,_l22++){var _s17=[],_c14=e[_l22%n];for(var _t63=0;_t63<_c14.childCount;_t63++){var _n25=_c14.child(_t63);_o26+_n25.attrs.rowspan>r&&(_n25=_n25.type.create(_objectSpread(_objectSpread({},_n25.attrs),{},{rowspan:Math.max(1,r-_n25.attrs.rowspan)}),_n25.content)),_s17.push(_n25);}_t62.push(i.from(_s17));}e=_t62,n=r;}return{width:t,height:n,rows:e};}(o,_s15.right-_s15.left,_s15.bottom-_s15.top),ht(t.state,t.dispatch,_l20,_s15,o),!0;}if(o){var _n26=A(t.state),_e34=_n26.start(-1);return ht(t.state,t.dispatch,_e34,_y.get(_n26.node(-1)).findCell(_n26.pos-_e34),o),!0;}return!1;}function vt(t,n){var e;if(0!=n.button)return;if(n.ctrlKey||n.metaKey)return;var o=yt(t,n.target);var r;if(n.shiftKey&&t.state.selection instanceof j)i(t.state.selection.$anchorCell,n),n.preventDefault();else if(n.shiftKey&&o&&null!=(r=z(t.state.selection.$anchor))&&(null===(e=Dt(t,n))||void 0===e?void 0:e.pos)!=r.pos)i(r,n),n.preventDefault();else if(!o)return;function i(n,e){var o=Dt(t,e);var r=null==N.getState(t.state);if(!o||!O(n,o)){if(!r)return;o=n;}var i=new j(n,o);if(r||!t.state.selection.eq(i)){var _e35=t.state.tr.setSelection(i);r&&_e35.setMeta(N,n.pos),t.dispatch(_e35);}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",s),null!=N.getState(t.state)&&t.dispatch(t.state.tr.setMeta(N,-1));}function s(e){var r=e,s=N.getState(t.state);var c;if(null!=s)c=t.state.doc.resolve(s);else if(yt(t,r.target)!=o&&(c=Dt(t,n),!c))return l();c&&i(c,r);}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",s);}function Mt(t,n,e){if(!(t.state.selection instanceof r))return null;var o=t.state.selection.$head;for(var _r31=o.depth-1;_r31>=0;_r31--){var _i26=o.node(_r31);if((e<0?o.index(_r31):o.indexAfter(_r31))!=(e<0?0:_i26.childCount))return null;if("cell"==_i26.type.spec.tableRole||"header_cell"==_i26.type.spec.tableRole){var _i27=o.before(_r31),_l23="vert"==n?e>0?"down":"up":e>0?"right":"left";return t.endOfTextblock(_l23)?_i27:null;}}return null;}function yt(t,n){for(;n&&n!=t.dom;n=n.parentNode)if("TD"==n.nodeName||"TH"==n.nodeName)return n;return null;}function Dt(t,n){var e=t.posAtCoords({left:n.clientX,top:n.clientY});if(!e)return null;var o=e.inside,r=e.pos;return o>=0&&z(t.state.doc.resolve(o))||z(t.state.doc.resolve(r));}function $t(t,n,e,o,r,i){var l=0,s=!0,c=n.firstChild;var f=t.firstChild;if(f){for(var _t64=0,_e36=0;_t64<f.childCount;_t64++){var _f$child$attrs=f.child(_t64).attrs,_u12=_f$child$attrs.colspan,_a10=_f$child$attrs.colwidth;for(var _t65=0;_t65<_u12;_t65++,_e36++){var _f14=r==_e36?i:_a10&&_a10[_t65],_u13=_f14?_f14+"px":"";if(l+=_f14||o,_f14||(s=!1),c)c.style.width!=_u13&&(c.style.width=_u13),c=c.nextSibling;else{var _t66=document.createElement("col");_t66.style.width=_u13,n.appendChild(_t66);}}}for(;c;){var u;var _t67=c.nextSibling;null===(u=c.parentNode)||void 0===u||u.removeChild(c),c=_t67;}s?(e.style.width=l+"px",e.style.minWidth=""):(e.style.width="",e.style.minWidth=l+"px");}}function Rt(){var _ref8=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref8$handleWidth=_ref8.handleWidth,n=_ref8$handleWidth===void 0?5:_ref8$handleWidth,_ref8$cellMinWidth=_ref8.cellMinWidth,e=_ref8$cellMinWidth===void 0?25:_ref8$cellMinWidth,_ref8$defaultCellMinW=_ref8.defaultCellMinWidth,o=_ref8$defaultCellMinW===void 0?100:_ref8$defaultCellMinW,_ref8$View=_ref8.View,r=_ref8$View===void 0?St:_ref8$View,_ref8$lastColumnResiz=_ref8.lastColumnResizable,i=_ref8$lastColumnResiz===void 0?!0:_ref8$lastColumnResiz;var l=new t({key:Et,state:{init:function init(t,n){var e;var i=null===(e=l.spec)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.nodeViews,s=_(n.schema).table.name;return r&&i&&(i[s]=function(t,n){return new r(t,o,n);}),new _t(-1,!1);},apply:function apply(t,n){return n.apply(t);}},props:{attributes:function attributes(t){var n=Et.getState(t);return n&&n.activeHandle>-1?{"class":"resize-cursor"}:{};},handleDOMEvents:{mousemove:function mousemove(t,e){!function(t,n,e,o){if(!t.editable)return;var r=Et.getState(t.state);if(!r)return;if(!r.dragging){var _i28=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t;}(n.target);var _l24=-1;if(_i28){var _i28$getBoundingClien=_i28.getBoundingClientRect(),_o27=_i28$getBoundingClien.left,_r32=_i28$getBoundingClien.right;n.clientX-_o27<=e?_l24=Nt(t,n,"left",e):_r32-n.clientX<=e&&(_l24=Nt(t,n,"right",e));}if(_l24!=r.activeHandle){if(!o&&-1!==_l24){var _n27=t.state.doc.resolve(_l24),_e37=_n27.node(-1),_o28=_y.get(_e37),_r33=_n27.start(-1);if(_o28.colCount(_n27.pos-_r33)+_n27.nodeAfter.attrs.colspan-1==_o28.width-1)return;}kt(t,_l24);}}}(t,e,n,i);},mouseleave:function mouseleave(t){!function(t){if(!t.editable)return;var n=Et.getState(t.state);n&&n.activeHandle>-1&&!n.dragging&&kt(t,-1);}(t);},mousedown:function mousedown(t,n){!function(t,n,e,o){var r;if(!t.editable)return!1;var i=null!==(r=t.dom.ownerDocument.defaultView)&&void 0!==r?r:window,l=Et.getState(t.state);if(!l||-1==l.activeHandle||l.dragging)return!1;var s=t.state.doc.nodeAt(l.activeHandle),c=function(t,n,_ref9){var e=_ref9.colspan,o=_ref9.colwidth;var r=o&&o[o.length-1];if(r)return r;var i=t.domAtPos(n);var l=i.node.childNodes[i.offset].offsetWidth,s=e;if(o)for(var _t68=0;_t68<e;_t68++)o[_t68]&&(l-=o[_t68],s--);return l/s;}(t,l.activeHandle,s.attrs);function f(n){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",u);var o=Et.getState(t.state);(null==o?void 0:o.dragging)&&(!function(t,n,e){var o=t.state.doc.resolve(n),r=o.node(-1),i=_y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(var _t69=0;_t69<i.height;_t69++){var _n28=_t69*i.width+s;if(_t69&&i.map[_n28]==i.map[_n28-i.width])continue;var _o29=i.map[_n28],_f15=r.nodeAt(_o29).attrs,_u14=1==_f15.colspan?0:s-i.colCount(_o29);if(_f15.colwidth&&_f15.colwidth[_u14]==e)continue;var _a11=_f15.colwidth?_f15.colwidth.slice():Ct(_f15.colspan);_a11[_u14]=e,c.setNodeMarkup(l+_o29,null,_objectSpread(_objectSpread({},_f15),{},{colwidth:_a11}));}c.docChanged&&t.dispatch(c);}(t,o.activeHandle,zt(o.dragging,n,e)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})));}function u(n){if(!n.which)return f(n);var r=Et.getState(t.state);if(r&&r.dragging){var _i29=zt(r.dragging,n,e);At(t,r.activeHandle,_i29,o);}}t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:n.clientX,startWidth:c}})),At(t,l.activeHandle,c,o),i.addEventListener("mouseup",f),i.addEventListener("mousemove",u),n.preventDefault();}(t,n,e,o);}},decorations:function decorations(t){var n=Et.getState(t);if(n&&n.activeHandle>-1)return function(t,n){var e=[],o=t.doc.resolve(n),r=o.node(-1);if(!r)return f.empty;var i=_y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(var _n29=0;_n29<i.height;_n29++){var _o30=s+_n29*i.width;if(!(s!=i.width-1&&i.map[_o30]==i.map[_o30+1]||0!=_n29&&i.map[_o30]==i.map[_o30-i.width])){var c;var _n30=i.map[_o30],_s18=l+_n30+r.nodeAt(_n30).nodeSize-1,_f16=document.createElement("div");_f16.className="column-resize-handle",(null===(c=Et.getState(t))||void 0===c?void 0:c.dragging)&&e.push(u.node(l+_n30,l+_n30+r.nodeAt(_n30).nodeSize,{"class":"column-resize-dragging"})),e.push(u.widget(_s18,_f16));}}return f.create(t.doc,e);}(t,n.activeHandle);},nodeViews:{}}});return l;}function Nt(t,n,e,o){var r="right"==e?-o:o,i=t.posAtCoords({left:n.clientX+r,top:n.clientY});if(!i)return-1;var l=i.pos,s=z(t.state.doc.resolve(l));if(!s)return-1;if("right"==e)return s.pos;var c=_y.get(s.node(-1)),f=s.start(-1),u=c.map.indexOf(s.pos-f);return u%c.width==0?-1:f+c.map[u-1];}function zt(t,n,e){var o=n.clientX-t.startX;return Math.max(e,t.startWidth+o);}function kt(t,n){t.dispatch(t.state.tr.setMeta(Et,{setHandle:n}));}function At(t,n,e,o){var r=t.state.doc.resolve(n),i=r.node(-1),l=r.start(-1),s=_y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;var c=t.domAtPos(r.start(-1)).node;for(;c&&"TABLE"!=c.nodeName;)c=c.parentNode;c&&$t(i,c.firstChild,c,o,s,e);}function Ct(t){return Array(t).fill(0);}function Ot(){var _ref10=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref10$allowTableNode=_ref10.allowTableNodeSelection,n=_ref10$allowTableNode===void 0?!1:_ref10$allowTableNode;return new t({key:N,state:{init:function init(){return null;},apply:function apply(t,n){var e=t.getMeta(N);if(null!=e)return-1==e?null:e;if(null==n||!t.docChanged)return n;var _t$mapping$mapResult=t.mapping.mapResult(n),o=_t$mapping$mapResult.deleted,r=_t$mapping$mapResult.pos;return o?null:r;}},props:{decorations:B,handleDOMEvents:{mousedown:vt},createSelectionBetween:function createSelectionBetween(t){return null!=N.getState(t.state)?t.state.selection:null;},handleTripleClick:gt,handleKeyDown:wt,handlePaste:bt},appendTransaction:function appendTransaction(t,e,o){return function(t,n,e){var o=(n||t).selection,i=(n||t).doc;var l,c;if(o instanceof s&&(c=o.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)l=j.create(i,o.from);else if("row"==c){var _t71=i.resolve(o.from+1);l=j.rowSelection(_t71,_t71);}else if(!e){var _t72=_y.get(o.node),_n31=o.from+1,_e38=_n31+_t72.map[_t72.width*_t72.height-1];l=j.create(i,_n31+1,_e38);}}else o instanceof r&&function(_ref11){var t=_ref11.$from,n=_ref11.$to;if(t.pos==n.pos||t.pos<n.pos-6)return!1;var e=t.pos,o=n.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,e++);for(var _t73=n.depth;_t73>=0&&!(n.before(_t73+1)>n.start(_t73));_t73--,o--);return e==o&&/row|table/.test(t.node(r).type.spec.tableRole);}(o)?l=r.create(i,o.from):o instanceof r&&function(_ref12){var t=_ref12.$from,n=_ref12.$to;var e,o;for(var _n32=t.depth;_n32>0;_n32--){var _o32=t.node(_n32);if("cell"===_o32.type.spec.tableRole||"header_cell"===_o32.type.spec.tableRole){e=_o32;break;}}for(var _t74=n.depth;_t74>0;_t74--){var _e39=n.node(_t74);if("cell"===_e39.type.spec.tableRole||"header_cell"===_e39.type.spec.tableRole){o=_e39;break;}}return e!==o&&0===n.parentOffset;}(o)&&(l=r.create(i,o.$from.start(),o.$from.end()));return l&&(n||(n=t.tr)).setSelection(l),n;}(o,J(o,e),n);}});}_export({a:R,b:b,c:Rt,d:lt,f:I,g:Z,h:q,i:V,j:Q,k:g,l:G,m:nt,s:et,t:Ot});return{setters:[function(_index00aCjsJs){t=_index00aCjsJs.b;n=_index00aCjsJs.P;e=_index00aCjsJs.S;o=_index00aCjsJs.k;r=_index00aCjsJs.T;i=_index00aCjsJs.F;l=_index00aCjsJs.d;s=_index00aCjsJs.c;c=_index00aCjsJs.m;},function(_index009CjsJs){f=_index009CjsJs.D;u=_index009CjsJs.a;},function(_index007CjsJs){a=_index007CjsJs.k;h=_index007CjsJs.b;}],execute:function execute(){w="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);if("undefined"!=typeof WeakMap){_t3=new WeakMap();v=function v(n){return _t3.get(n);},M=function M(n,e){return _t3.set(n,e),e;};}else{_t4=[],_n=10;_e2=0;v=function v(n){for(var _e3=0;_e3<_t4.length;_e3+=2)if(_t4[_e3]==n)return _t4[_e3+1];},M=function M(o,r){return _e2==_n&&(_e2=0),_t4[_e2++]=o,_t4[_e2++]=r;};}_y=/*#__PURE__*/function(){function y(t,n,e,o){_classCallCheck(this,y);this.width=t,this.height=n,this.map=e,this.problems=o;}return _createClass(y,[{key:"findCell",value:function findCell(t){for(var _n2=0;_n2<this.map.length;_n2++){var _e4=this.map[_n2];if(_e4!=t)continue;var _o2=_n2%this.width,_r2=_n2/this.width|0;var _i=_o2+1,_l2=_r2+1;for(var _t5=1;_i<this.width&&this.map[_n2+_t5]==_e4;_t5++)_i++;for(var _t6=1;_l2<this.height&&this.map[_n2+this.width*_t6]==_e4;_t6++)_l2++;return{left:_o2,top:_r2,right:_i,bottom:_l2};}throw new RangeError("No cell with offset ".concat(t," found"));}},{key:"colCount",value:function colCount(t){for(var _n3=0;_n3<this.map.length;_n3++)if(this.map[_n3]==t)return _n3%this.width;throw new RangeError("No cell with offset ".concat(t," found"));}},{key:"nextCell",value:function nextCell(t,n,e){var _this$findCell=this.findCell(t),o=_this$findCell.left,r=_this$findCell.right,i=_this$findCell.top,l=_this$findCell.bottom;return"horiz"==n?(e<0?0==o:r==this.width)?null:this.map[i*this.width+(e<0?o-1:r)]:(e<0?0==i:l==this.height)?null:this.map[o+this.width*(e<0?i-1:l)];}},{key:"rectBetween",value:function rectBetween(t,n){var _this$findCell2=this.findCell(t),e=_this$findCell2.left,o=_this$findCell2.right,r=_this$findCell2.top,i=_this$findCell2.bottom,_this$findCell3=this.findCell(n),l=_this$findCell3.left,s=_this$findCell3.right,c=_this$findCell3.top,f=_this$findCell3.bottom;return{left:Math.min(e,l),top:Math.min(r,c),right:Math.max(o,s),bottom:Math.max(i,f)};}},{key:"cellsInRect",value:function cellsInRect(t){var n=[],e={};for(var _o3=t.top;_o3<t.bottom;_o3++)for(var _r3=t.left;_r3<t.right;_r3++){var _i2=_o3*this.width+_r3,_l3=this.map[_i2];e[_l3]||(e[_l3]=!0,_r3==t.left&&_r3&&this.map[_i2-1]==_l3||_o3==t.top&&_o3&&this.map[_i2-this.width]==_l3||n.push(_l3));}return n;}},{key:"positionAt",value:function positionAt(t,n,e){for(var _o4=0,_r4=0;;_o4++){var _i3=_r4+e.child(_o4).nodeSize;if(_o4==t){var _e5=n+t*this.width;var _o5=(t+1)*this.width;for(;_e5<_o5&&this.map[_e5]<_r4;)_e5++;return _e5==_o5?_i3-1:this.map[_e5];}_r4=_i3;}}}],[{key:"get",value:function get(t){return v(t)||M(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);var n=function(t){var n=-1,e=!1;for(var _o6=0;_o6<t.childCount;_o6++){var _r5=t.child(_o6);var _i4=0;if(e)for(var _n4=0;_n4<_o6;_n4++){var _e6=t.child(_n4);for(var _t7=0;_t7<_e6.childCount;_t7++){var _r6=_e6.child(_t7);_n4+_r6.attrs.rowspan>_o6&&(_i4+=_r6.attrs.colspan);}}for(var _t8=0;_t8<_r5.childCount;_t8++){var _n5=_r5.child(_t8);_i4+=_n5.attrs.colspan,_n5.attrs.rowspan>1&&(e=!0);}-1==n?n=_i4:n!=_i4&&(n=Math.max(n,_i4));}return n;}(t),e=t.childCount,o=[];var r=0,i=null;var l=[];for(var _t9=0,_r7=n*e;_t9<_r7;_t9++)o[_t9]=0;for(var _s=0,_c=0;_s<e;_s++){var _f=t.child(_s);_c++;for(var _t10=0;;_t10++){for(;r<o.length&&0!=o[r];)r++;if(_t10==_f.childCount)break;var _u=_f.child(_t10),_u$attrs=_u.attrs,_a=_u$attrs.colspan,_h=_u$attrs.rowspan,_w=_u$attrs.colwidth;for(var _t11=0;_t11<_h;_t11++){if(_t11+_s>=e){(i||(i=[])).push({type:"overlong_rowspan",pos:_c,n:_h-_t11});break;}var _f2=r+_t11*n;for(var _t12=0;_t12<_a;_t12++){0==o[_f2+_t12]?o[_f2+_t12]=_c:(i||(i=[])).push({type:"collision",row:_s,pos:_c,n:_a-_t12});var _e7=_w&&_w[_t12];if(_e7){var _o7=(_f2+_t12)%n*2,_r8=l[_o7];null==_r8||_r8!=_e7&&1==l[_o7+1]?(l[_o7]=_e7,l[_o7+1]=1):_r8==_e7&&l[_o7+1]++;}}}r+=_a,_c+=_u.nodeSize;}var _u2=(_s+1)*n;var _a2=0;for(;r<_u2;)0==o[r++]&&_a2++;_a2&&(i||(i=[])).push({type:"missing",row:_s,n:_a2}),_c++;}0!==n&&0!==e||(i||(i=[])).push({type:"zero_sized"});var s=new _y(n,e,o,i);var c=!1;for(var _t13=0;!c&&_t13<l.length;_t13+=2)null!=l[_t13]&&l[_t13+1]<e&&(c=!0);c&&function(t,n,e){t.problems||(t.problems=[]);var o={};for(var _r9=0;_r9<t.map.length;_r9++){var _i5=t.map[_r9];if(o[_i5])continue;o[_i5]=!0;var _l4=e.nodeAt(_i5);if(!_l4)throw new RangeError("No cell with offset ".concat(_i5," found"));var _s2=null;var _c2=_l4.attrs;for(var _e8=0;_e8<_c2.colspan;_e8++){var _o8=n[(_r9+_e8)%t.width*2];null==_o8||_c2.colwidth&&_c2.colwidth[_e8]==_o8||((_s2||(_s2=D(_c2)))[_e8]=_o8);}_s2&&t.problems.unshift({type:"colwidth mismatch",pos:_i5,colwidth:_s2});}}(s,l,t);return s;}(t));}}]);}();N=new n("selectingCells");j=/*#__PURE__*/function(_e14){function t(_t17){var _this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_t17;_classCallCheck(this,t);var e=_t17.node(-1),r=_y.get(e),i=_t17.start(-1),l=r.rectBetween(_t17.pos-i,n.pos-i),s=_t17.node(0),c=r.cellsInRect(l).filter(function(_t18){return _t18!=n.pos-i;});c.unshift(n.pos-i);var f=c.map(function(_t19){var n=e.nodeAt(_t19);if(!n)throw new RangeError("No cell with offset ".concat(_t19," found"));var r=i+_t19+1;return new o(s.resolve(r),s.resolve(r+n.content.size));});_this=_callSuper(this,t,[f[0].$from,f[0].$to,f]),_this.$anchorCell=_t17,_this.$headCell=n;return _this;}_inherits(t,_e14);return _createClass(t,[{key:"map",value:function map(n,e){var o=n.resolve(e.map(this.$anchorCell.pos)),i=n.resolve(e.map(this.$headCell.pos));if(C(o)&&C(i)&&O(o,i)){var _n10=this.$anchorCell.node(-1)!=o.node(-1);return _n10&&this.isRowSelection()?t.rowSelection(o,i):_n10&&this.isColSelection()?t.colSelection(o,i):new t(o,i);}return r.between(o,i);}},{key:"content",value:function content(){var _t20=this.$anchorCell.node(-1),n=_y.get(_t20),e=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-e,this.$headCell.pos-e),r={},s=[];for(var _e15=o.top;_e15<o.bottom;_e15++){var _l5=[];for(var _i6=_e15*n.width+o.left,_s3=o.left;_s3<o.right;_s3++,_i6++){var _e16=n.map[_i6];if(r[_e16])continue;r[_e16]=!0;var _s4=n.findCell(_e16);var _c3=_t20.nodeAt(_e16);if(!_c3)throw new RangeError("No cell with offset ".concat(_e16," found"));var _f3=o.left-_s4.left,_u3=_s4.right-o.right;if(_f3>0||_u3>0){var _t21=_c3.attrs;if(_f3>0&&(_t21=T(_t21,0,_f3)),_u3>0&&(_t21=T(_t21,_t21.colspan-_u3,_u3)),_s4.left<o.left){if(_c3=_c3.type.createAndFill(_t21),!_c3)throw new RangeError("Could not create cell with attrs ".concat(JSON.stringify(_t21)));}else _c3=_c3.type.create(_t21,_c3.content);}if(_s4.top<o.top||_s4.bottom>o.bottom){var _t22=_objectSpread(_objectSpread({},_c3.attrs),{},{rowspan:Math.min(_s4.bottom,o.bottom)-Math.max(_s4.top,o.top)});_c3=_s4.top<o.top?_c3.type.createAndFill(_t22):_c3.type.create(_t22,_c3.content);}_l5.push(_c3);}s.push(_t20.child(_e15).copy(i.from(_l5)));}var c=this.isColSelection()&&this.isRowSelection()?_t20:s;return new l(i.from(c),1,1);}},{key:"replace",value:function replace(_t23){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:l.empty;var o=_t23.steps.length,r=this.ranges;for(var _e17=0;_e17<r.length;_e17++){var _r$_e=r[_e17],_i7=_r$_e.$from,_s5=_r$_e.$to,_c4=_t23.mapping.slice(o);_t23.replace(_c4.map(_i7.pos),_c4.map(_s5.pos),_e17?l.empty:n);}var i=e.findFrom(_t23.doc.resolve(_t23.mapping.slice(o).map(this.to)),-1);i&&_t23.setSelection(i);}},{key:"replaceWith",value:function replaceWith(_t24,n){this.replace(_t24,new l(i.from(n),0,0));}},{key:"forEachCell",value:function forEachCell(_t25){var n=this.$anchorCell.node(-1),e=_y.get(n),o=this.$anchorCell.start(-1),r=e.cellsInRect(e.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(var _e18=0;_e18<r.length;_e18++)_t25(n.nodeAt(r[_e18]),o+r[_e18]);}},{key:"isColSelection",value:function isColSelection(){var _t26=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(_t26,n)>0)return!1;var e=_t26+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(e,o)==this.$headCell.node(-1).childCount;}},{key:"isRowSelection",value:function isRowSelection(){var _t27=this.$anchorCell.node(-1),n=_y.get(_t27),e=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-e),r=n.colCount(this.$headCell.pos-e);if(Math.min(o,r)>0)return!1;var i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width;}},{key:"eq",value:function eq(n){return n instanceof t&&n.$anchorCell.pos==this.$anchorCell.pos&&n.$headCell.pos==this.$headCell.pos;}},{key:"toJSON",value:function toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos};}},{key:"getBookmark",value:function getBookmark(){return new L(this.$anchorCell.pos,this.$headCell.pos);}}],[{key:"colSelection",value:function colSelection(n){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n;var o=n.node(-1),r=_y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.top<=s.top?(l.top>0&&(n=c.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=c.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(e=c.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=c.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new t(n,e);}},{key:"rowSelection",value:function rowSelection(n){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n;var o=n.node(-1),r=_y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.left<=s.left?(l.left>0&&(n=c.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=c.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(e=c.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=c.resolve(i+r.map[r.width*(l.top+1)-1]))),new t(n,e);}},{key:"fromJSON",value:function fromJSON(n,e){return new t(n.resolve(e.anchor),n.resolve(e.head));}},{key:"create",value:function create(n,e){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:e;return new t(n.resolve(e),n.resolve(o));}}]);}(e);j.prototype.visible=!1,e.jsonID("cell",j);L=/*#__PURE__*/function(){function t(_t28,n){_classCallCheck(this,t);this.anchor=_t28,this.head=n;}return _createClass(t,[{key:"map",value:function map(n){return new t(n.map(this.anchor),n.map(this.head));}},{key:"resolve",value:function resolve(_t29){var n=_t29.resolve(this.anchor),o=_t29.resolve(this.head);return"row"==n.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&O(n,o)?new j(n,o):e.near(o,1);}}]);}();P=new n("fix-tables");_export("e",it=rt("row",{useDeprecatedLogic:!0}));rt("column",{useDeprecatedLogic:!0}),rt("cell",{useDeprecatedLogic:!0});wt=b({ArrowLeft:pt("horiz",-1),ArrowRight:pt("horiz",1),ArrowUp:pt("vert",-1),ArrowDown:pt("vert",1),"Shift-ArrowLeft":mt("horiz",-1),"Shift-ArrowRight":mt("horiz",1),"Shift-ArrowUp":mt("vert",-1),"Shift-ArrowDown":mt("vert",1),Backspace:st,"Mod-Backspace":st,Delete:st,"Mod-Delete":st});St=/*#__PURE__*/function(){function St(t,n){_classCallCheck(this,St);this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width","".concat(n,"px")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$t(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"));}return _createClass(St,[{key:"update",value:function update(t){return t.type==this.node.type&&(this.node=t,$t(t,this.colgroup,this.table,this.defaultCellMinWidth),!0);}},{key:"ignoreMutation",value:function ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target));}}]);}();Et=new n("tableColumnResizing");_t=/*#__PURE__*/function(){function t(_t70,n){_classCallCheck(this,t);this.activeHandle=_t70,this.dragging=n;}return _createClass(t,[{key:"apply",value:function apply(n){var e=this,o=n.getMeta(Et);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(e.activeHandle,o.setDragging);if(e.activeHandle>-1&&n.docChanged){var _o31=n.mapping.map(e.activeHandle,-1);return C(n.doc.resolve(_o31))||(_o31=-1),new t(_o31,e.dragging);}return e;}}]);}();}};});
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
System.register(["./index-89c520e9.cjs.js","./index-cc1385e0.cjs.js","./index-178e1e57.cjs.js"],function(_export,_context){"use strict";var t,n,e,o,r,i,l,s,c,f,u,a,h,w,d,v,M,_t3,_t4,_n,_e2,_y,N,j,L,P,it,wt,St,Et,_t;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n33){function n(){return _n33.apply(this,arguments);}n.toString=function(){return _n33.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function p(t){var n,e,o,r,i=t.split(/-(?!$)/),l=i[i.length-1];"Space"==l&&(l=" ");for(var _t2=0;_t2<i.length-1;_t2++){var _l=i[_t2];if(/^(cmd|meta|m)$/i.test(_l))r=!0;else if(/^a(lt)?$/i.test(_l))n=!0;else if(/^(c|ctrl|control)$/i.test(_l))e=!0;else if(/^s(hift)?$/i.test(_l))o=!0;else{if(!/^mod$/i.test(_l))throw new Error("Unrecognized modifier name: "+_l);w?r=!0:e=!0;}}return n&&(l="Alt-"+l),e&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l;}function m(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;return n.altKey&&(t="Alt-"+t),n.ctrlKey&&(t="Ctrl-"+t),n.metaKey&&(t="Meta-"+t),e&&n.shiftKey&&(t="Shift-"+t),t;}function g(n){return new t({props:{handleKeyDown:b(n)}});}function b(t){var n=function(t){var n=Object.create(null);for(var _e in t)n[p(_e)]=t[_e];return n;}(t);return function(t,e){var o,r=a(e),i=n[m(r,e)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==r.length&&" "!=r){if(e.shiftKey){var _o=n[m(r,e,!1)];if(_o&&_o(t.state,t.dispatch,t))return!0;}if((e.altKey||e.metaKey||e.ctrlKey)&&!(d&&e.ctrlKey&&e.altKey)&&(o=h[e.keyCode])&&o!=r){var _r=n[m(o,e)];if(_r&&_r(t.state,t.dispatch,t))return!0;}}return!1;};}function D(t){if(t.colwidth)return t.colwidth.slice();var n=[];for(var _e9=0;_e9<t.colspan;_e9++)n.push(0);return n;}function S(t,n){if("string"==typeof t)return{};var e=t.getAttribute("data-colwidth"),o=e&&/^\d+(,\d+)*$/.test(e)?e.split(",").map(function(t){return Number(t);}):null,r=Number(t.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(var _e10 in n){var _o9=n[_e10].getFromDOM,_r10=_o9&&_o9(t);null!=_r10&&(i[_e10]=_r10);}return i;}function $(t,n){var e={};1!=t.attrs.colspan&&(e.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(e.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(e["data-colwidth"]=t.attrs.colwidth.join(","));for(var _o10 in n){var _r11=n[_o10].setDOMAttr;_r11&&_r11(t.attrs[_o10],e);}return e;}function E(t){if(null!==t){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");var _iterator=_createForOfIteratorHelper(t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _n6=_step.value;if("number"!=typeof _n6)throw new TypeError("colwidth must be null or an array of numbers");}}catch(err){_iterator.e(err);}finally{_iterator.f();}}}function R(t){var n=t.cellAttributes||{},e={colspan:{"default":1,validate:"number"},rowspan:{"default":1,validate:"number"},colwidth:{"default":null,validate:E}};for(var _t14 in n)e[_t14]={"default":n[_t14]["default"],validate:n[_t14].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:function toDOM(){return["table",["tbody",0]];}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:function toDOM(){return["tr",0];}},table_cell:{content:t.cellContent,attrs:e,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:function getAttrs(t){return S(t,n);}}],toDOM:function toDOM(t){return["td",$(t,n),0];}},table_header:{content:t.cellContent,attrs:e,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:function getAttrs(t){return S(t,n);}}],toDOM:function toDOM(t){return["th",$(t,n),0];}}};}function _(t){var n=t.cached.tableNodeTypes;if(!n){n=t.cached.tableNodeTypes={};for(var _e11 in t.nodes){var _o11=t.nodes[_e11],_r12=_o11.spec.tableRole;_r12&&(n[_r12]=_o11);}}return n;}function z(t){for(var _n7=t.depth-1;_n7>0;_n7--)if("row"==t.node(_n7).type.spec.tableRole)return t.node(0).resolve(t.before(_n7+1));return null;}function k(t){var n=t.selection.$head;for(var _t15=n.depth;_t15>0;_t15--)if("row"==n.node(_t15).type.spec.tableRole)return!0;return!1;}function A(t){var n=t.selection;if("$anchorCell"in n&&n.$anchorCell)return n.$anchorCell.pos>n.$headCell.pos?n.$anchorCell:n.$headCell;if("node"in n&&n.node&&"cell"==n.node.type.spec.tableRole)return n.$anchor;var e=z(n.$head)||function(t){for(var _n8=t.nodeAfter,_e12=t.pos;_n8;_n8=_n8.firstChild,_e12++){var _o12=_n8.type.spec.tableRole;if("cell"==_o12||"header_cell"==_o12)return t.doc.resolve(_e12);}for(var _n9=t.nodeBefore,_e13=t.pos;_n9;_n9=_n9.lastChild,_e13--){var _o13=_n9.type.spec.tableRole;if("cell"==_o13||"header_cell"==_o13)return t.doc.resolve(_e13-_n9.nodeSize);}}(n.$head);if(e)return e;throw new RangeError("No cell found around position ".concat(n.head));}function C(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter;}function O(t,n){return t.depth==n.depth&&t.pos>=n.start(-1)&&t.pos<=n.end(-1);}function T(t,n,e){var o=t.node(-1),r=_y.get(o),i=t.start(-1),l=r.nextCell(t.pos-i,n,e);return null==l?null:t.node(0).resolve(i+l);}function x(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var o=_objectSpread(_objectSpread({},t),{},{colspan:t.colspan-e});return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(n,e),o.colwidth.some(function(t){return t>0;})||(o.colwidth=null)),o;}function W(t,n){var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var o=_objectSpread(_objectSpread({},t),{},{colspan:t.colspan+e});if(o.colwidth){o.colwidth=o.colwidth.slice();for(var _t16=0;_t16<e;_t16++)o.colwidth.splice(n,0,0);}return o;}function B(t){if(!(t.selection instanceof j))return null;var n=[];return t.selection.forEachCell(function(t,e){n.push(u.node(e,e+t.nodeSize,{"class":"selectedCell"}));}),f.create(t.doc,n);}function H(t,n,e,o){var r=t.childCount,i=n.childCount;t:for(var _l6=0,_s6=0;_l6<i;_l6++){var _i8=n.child(_l6);for(var _n11=_s6,_o14=Math.min(r,_l6+3);_n11<_o14;_n11++)if(t.child(_n11)==_i8){_s6=_n11+1,e+=_i8.nodeSize;continue t;}o(_i8,e),_s6<r&&t.child(_s6).sameMarkup(_i8)?H(t.child(_s6),_i8,e+1,o):_i8.nodesBetween(0,_i8.content.size,o,e+1),e+=_i8.nodeSize;}}function J(t,n){var e;var o=function o(n,_o15){"table"==n.type.spec.tableRole&&(e=function(t,n,e,o){var r=_y.get(n);if(!r.problems)return o;o||(o=t.tr);var i=[];for(var _t30=0;_t30<r.height;_t30++)i.push(0);for(var _t31=0;_t31<r.problems.length;_t31++){var _l7=r.problems[_t31];if("collision"==_l7.type){var _t32=n.nodeAt(_l7.pos);if(!_t32)continue;var _r13=_t32.attrs;for(var _t33=0;_t33<_r13.rowspan;_t33++)i[_l7.row+_t33]+=_l7.n;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,x(_r13,_r13.colspan-_l7.n,_l7.n));}else if("missing"==_l7.type)i[_l7.row]+=_l7.n;else if("overlong_rowspan"==_l7.type){var _t34=n.nodeAt(_l7.pos);if(!_t34)continue;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,_objectSpread(_objectSpread({},_t34.attrs),{},{rowspan:_t34.attrs.rowspan-_l7.n}));}else if("colwidth mismatch"==_l7.type){var _t35=n.nodeAt(_l7.pos);if(!_t35)continue;o.setNodeMarkup(o.mapping.map(e+1+_l7.pos),null,_objectSpread(_objectSpread({},_t35.attrs),{},{colwidth:_l7.colwidth}));}else if("zero_sized"==_l7.type){var _t36=o.mapping.map(e);o["delete"](_t36,_t36+n.nodeSize);}}var l,s;for(var _t37=0;_t37<i.length;_t37++)i[_t37]&&(null==l&&(l=_t37),s=_t37);for(var _c5=0,_f4=e+1;_c5<r.height;_c5++){var _e19=n.child(_c5),_r14=_f4+_e19.nodeSize,_u4=i[_c5];if(_u4>0){var _n12="cell";_e19.firstChild&&(_n12=_e19.firstChild.type.spec.tableRole);var _i9=[];for(var _e20=0;_e20<_u4;_e20++){var _e21=_(t.schema)[_n12].createAndFill();_e21&&_i9.push(_e21);}var _a3=0!=_c5&&l!=_c5-1||s!=_c5?_r14-1:_f4+1;o.insert(o.mapping.map(_a3),_i9);}_f4=_r14;}return o.setMeta(P,{fixTables:!0});}(t,n,_o15,e));};return n?n.doc!=t.doc&&H(n.doc,t.doc,0,o):t.doc.descendants(o),e;}function U(t){var n=t.selection,e=A(t),o=e.node(-1),r=e.start(-1),i=_y.get(o);return _objectSpread(_objectSpread({},n instanceof j?i.rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r):i.findCell(e.pos-r)),{},{tableStart:r,map:i,table:o});}function K(t,_ref,r){var n=_ref.map,e=_ref.tableStart,o=_ref.table;var i=r>0?-1:0;(function(t,n,e){var o=_(n.type.schema).header_cell;for(var _r15=0;_r15<t.height;_r15++)if(n.nodeAt(t.map[e+_r15*t.width]).type!=o)return!1;return!0;})(n,o,r+i)&&(i=0==r||r==n.width?null:0);for(var _l8=0;_l8<n.height;_l8++){var _s7=_l8*n.width+r;if(r>0&&r<n.width&&n.map[_s7-1]==n.map[_s7]){var _i10=n.map[_s7],_c6=o.nodeAt(_i10);t.setNodeMarkup(t.mapping.map(e+_i10),null,W(_c6.attrs,r-n.colCount(_i10))),_l8+=_c6.attrs.rowspan-1;}else{var _c7=null==i?_(o.type.schema).cell:o.nodeAt(n.map[_s7+i]).type,_f5=n.positionAt(_l8,r,o);t.insert(t.mapping.map(e+_f5),_c7.createAndFill());}}return t;}function V(t,n){if(!k(t))return!1;if(n){var _e22=U(t);n(K(t.tr,_e22,_e22.left));}return!0;}function q(t,n){if(!k(t))return!1;if(n){var _e23=U(t);n(K(t.tr,_e23,_e23.right));}return!0;}function F(t,_ref2,r){var n=_ref2.map,e=_ref2.table,o=_ref2.tableStart;var i=t.mapping.maps.length;for(var _l9=0;_l9<n.height;){var _s8=_l9*n.width+r,_c8=n.map[_s8],_f6=e.nodeAt(_c8),_u5=_f6.attrs;if(r>0&&n.map[_s8-1]==_c8||r<n.width-1&&n.map[_s8+1]==_c8)t.setNodeMarkup(t.mapping.slice(i).map(o+_c8),null,x(_u5,r-n.colCount(_c8)));else{var _n13=t.mapping.slice(i).map(o+_c8);t["delete"](_n13,_n13+_f6.nodeSize);}_l9+=_u5.rowspan;}}function I(t,n){if(!k(t))return!1;if(n){var _e24=U(t),_o16=t.tr;if(0==_e24.left&&_e24.right==_e24.map.width)return!1;for(var _t38=_e24.right-1;F(_o16,_e24,_t38),_t38!=_e24.left;_t38--){var _t39=_e24.tableStart?_o16.doc.nodeAt(_e24.tableStart-1):_o16.doc;if(!_t39)throw new RangeError("No table found");_e24.table=_t39,_e24.map=_y.get(_t39);}n(_o16);}return!0;}function X(t,_ref3,r){var n=_ref3.map,e=_ref3.tableStart,o=_ref3.table;var i=e;for(var _t40=0;_t40<r;_t40++)i+=o.child(_t40).nodeSize;var l=[];var s=r>0?-1:0;(function(t,n,e){var o;var r=_(n.type.schema).header_cell;for(var _i11=0;_i11<t.width;_i11++)if((null===(o=n.nodeAt(t.map[_i11+e*t.width]))||void 0===o?void 0:o.type)!=r)return!1;return!0;})(n,o,r+s)&&(s=0==r||r==n.height?null:0);for(var _i12=0,_f7=n.width*r;_i12<n.width;_i12++,_f7++)if(r>0&&r<n.height&&n.map[_f7]==n.map[_f7-n.width]){var _r16=n.map[_f7],_l10=o.nodeAt(_r16).attrs;t.setNodeMarkup(e+_r16,null,_objectSpread(_objectSpread({},_l10),{},{rowspan:_l10.rowspan+1})),_i12+=_l10.colspan-1;}else{var c;var _t41=null==s?_(o.type.schema).cell:null===(c=o.nodeAt(n.map[_f7+s*n.width]))||void 0===c?void 0:c.type,_e25=null==_t41?void 0:_t41.createAndFill();_e25&&l.push(_e25);}return t.insert(i,_(o.type.schema).row.create(null,l)),t;}function G(t,n){if(!k(t))return!1;if(n){var _e26=U(t);n(X(t.tr,_e26,_e26.top));}return!0;}function Q(t,n){if(!k(t))return!1;if(n){var _e27=U(t);n(X(t.tr,_e27,_e27.bottom));}return!0;}function Y(t,_ref4,r){var n=_ref4.map,e=_ref4.table,o=_ref4.tableStart;var i=0;for(var _t42=0;_t42<r;_t42++)i+=e.child(_t42).nodeSize;var l=i+e.child(r).nodeSize,s=t.mapping.maps.length;t["delete"](i+o,l+o);var c=new Set();for(var _i13=0,_l11=r*n.width;_i13<n.width;_i13++,_l11++){var _f8=n.map[_l11];if(!c.has(_f8))if(c.add(_f8),r>0&&_f8==n.map[_l11-n.width]){var _n14=e.nodeAt(_f8).attrs;t.setNodeMarkup(t.mapping.slice(s).map(_f8+o),null,_objectSpread(_objectSpread({},_n14),{},{rowspan:_n14.rowspan-1})),_i13+=_n14.colspan-1;}else if(r<n.height&&_f8==n.map[_l11+n.width]){var _l12=e.nodeAt(_f8),_c9=_l12.attrs,_u6=_l12.type.create(_objectSpread(_objectSpread({},_c9),{},{rowspan:_l12.attrs.rowspan-1}),_l12.content),_a4=n.positionAt(r+1,_i13,e);t.insert(t.mapping.slice(s).map(o+_a4),_u6),_i13+=_c9.colspan-1;}}}function Z(t,n){if(!k(t))return!1;if(n){var _e28=U(t),_o17=t.tr;if(0==_e28.top&&_e28.bottom==_e28.map.height)return!1;for(var _t43=_e28.bottom-1;Y(_o17,_e28,_t43),_t43!=_e28.top;_t43--){var _t44=_e28.tableStart?_o17.doc.nodeAt(_e28.tableStart-1):_o17.doc;if(!_t44)throw new RangeError("No table found");_e28.table=_t44,_e28.map=_y.get(_e28.table);}n(_o17);}return!0;}function tt(t){var n=t.content;return 1==n.childCount&&n.child(0).isTextblock&&0==n.child(0).childCount;}function nt(t,n){var e=t.selection;if(!(e instanceof j)||e.$anchorCell.pos==e.$headCell.pos)return!1;var o=U(t),r=o.map;if(function(_ref5,o){var t=_ref5.width,n=_ref5.height,e=_ref5.map;var r=o.top*t+o.left,i=r,l=(o.bottom-1)*t+o.left,s=r+(o.right-o.left-1);for(var _n15=o.top;_n15<o.bottom;_n15++){if(o.left>0&&e[i]==e[i-1]||o.right<t&&e[s]==e[s+1])return!0;i+=t,s+=t;}for(var _i14=o.left;_i14<o.right;_i14++){if(o.top>0&&e[r]==e[r-t]||o.bottom<n&&e[l]==e[l+t])return!0;r++,l++;}return!1;}(r,o))return!1;if(n){var _e29=t.tr,_l13={};var _s9,_c10,_f9=i.empty;for(var _t45=o.top;_t45<o.bottom;_t45++)for(var _n16=o.left;_n16<o.right;_n16++){var _i15=r.map[_t45*r.width+_n16],_u7=o.table.nodeAt(_i15);if(!_l13[_i15]&&_u7)if(_l13[_i15]=!0,null==_s9)_s9=_i15,_c10=_u7;else{tt(_u7)||(_f9=_f9.append(_u7.content));var _t46=_e29.mapping.map(_i15+o.tableStart);_e29["delete"](_t46,_t46+_u7.nodeSize);}}if(null==_s9||null==_c10)return!0;if(_e29.setNodeMarkup(_s9+o.tableStart,null,_objectSpread(_objectSpread({},W(_c10.attrs,_c10.attrs.colspan,o.right-o.left-_c10.attrs.colspan)),{},{rowspan:o.bottom-o.top})),_f9.size>0){var _t47=_s9+1+_c10.content.size,_n17=tt(_c10)?_s9+1:_t47;_e29.replaceWith(_n17+o.tableStart,_t47+o.tableStart,_f9);}_e29.setSelection(new j(_e29.doc.resolve(_s9+o.tableStart))),n(_e29);}return!0;}function et(t,n){var e=_(t.schema);return(o=function o(_ref6){var t=_ref6.node;return e[t.type.spec.tableRole];},function(t,n){var e=t.selection;var r,i;if(e instanceof j){if(e.$anchorCell.pos!=e.$headCell.pos)return!1;r=e.$anchorCell.nodeAfter,i=e.$anchorCell.pos;}else{var l;if(r=function(t){for(var _n18=t.depth;_n18>0;_n18--){var _e30=t.node(_n18).type.spec.tableRole;if("cell"===_e30||"header_cell"===_e30)return t.node(_n18);}return null;}(e.$from),!r)return!1;i=null===(l=z(e.$from))||void 0===l?void 0:l.pos;}if(null==r||null==i)return!1;if(1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){var _l14=r.attrs;var _s10=[],_c11=_l14.colwidth;_l14.rowspan>1&&(_l14=_objectSpread(_objectSpread({},_l14),{},{rowspan:1})),_l14.colspan>1&&(_l14=_objectSpread(_objectSpread({},_l14),{},{colspan:1}));var _f10=U(t),_u8=t.tr;for(var _t48=0;_t48<_f10.right-_f10.left;_t48++)_s10.push(_c11?_objectSpread(_objectSpread({},_l14),{},{colwidth:_c11&&_c11[_t48]?[_c11[_t48]]:null}):_l14);var _a5;for(var _t49=_f10.top;_t49<_f10.bottom;_t49++){var _n19=_f10.map.positionAt(_t49,_f10.left,_f10.table);_t49==_f10.top&&(_n19+=r.nodeSize);for(var _e31=_f10.left,_i16=0;_e31<_f10.right;_e31++,_i16++)_e31==_f10.left&&_t49==_f10.top||_u8.insert(_a5=_u8.mapping.map(_n19+_f10.tableStart,1),o({node:r,row:_t49,col:_e31}).createAndFill(_s10[_i16]));}_u8.setNodeMarkup(i,o({node:r,row:_f10.top,col:_f10.left}),_s10[0]),e instanceof j&&_u8.setSelection(new j(_u8.doc.resolve(e.$anchorCell.pos),_a5?_u8.doc.resolve(_a5):void 0)),n(_u8);}return!0;})(t,n);var o;}function ot(t,n,e){var o=n.map.cellsInRect({left:0,top:0,right:"row"==t?n.map.width:1,bottom:"column"==t?n.map.height:1});for(var _t50=0;_t50<o.length;_t50++){var _r17=n.table.nodeAt(o[_t50]);if(_r17&&_r17.type!==e.header_cell)return!1;}return!0;}function rt(t,n){return(n=n||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(n,e){if(!k(n))return!1;if(e){var _o18=_(n.schema),_r18=U(n),_i17=n.tr,_l15=_r18.map.cellsInRect("column"==t?{left:_r18.left,top:0,right:_r18.right,bottom:_r18.map.height}:"row"==t?{left:0,top:_r18.top,right:_r18.map.width,bottom:_r18.bottom}:_r18),_s11=_l15.map(function(t){return _r18.table.nodeAt(t);});for(var _t51=0;_t51<_l15.length;_t51++)_s11[_t51].type==_o18.header_cell&&_i17.setNodeMarkup(_r18.tableStart+_l15[_t51],_o18.cell,_s11[_t51].attrs);if(0===_i17.steps.length)for(var _t52=0;_t52<_l15.length;_t52++)_i17.setNodeMarkup(_r18.tableStart+_l15[_t52],_o18.header_cell,_s11[_t52].attrs);e(_i17);}return!0;};}(t):function(n,e){if(!k(n))return!1;if(e){var _o19=_(n.schema),_r19=U(n),_i18=n.tr,_l16=ot("row",_r19,_o19),_s12=ot("column",_r19,_o19),_c12=("column"===t?_l16:"row"===t&&_s12)?1:0,_f11="column"==t?{left:0,top:_c12,right:1,bottom:_r19.map.height}:"row"==t?{left:_c12,top:0,right:_r19.map.width,bottom:1}:_r19,_u9="column"==t?_s12?_o19.cell:_o19.header_cell:"row"==t?_l16?_o19.cell:_o19.header_cell:_o19.cell;_r19.map.cellsInRect(_f11).forEach(function(t){var n=t+_r19.tableStart,e=_i18.doc.nodeAt(n);e&&_i18.setNodeMarkup(n,_u9,e.attrs);}),e(_i18);}return!0;};}function lt(t,n){var e=t.selection.$anchor;for(var _o20=e.depth;_o20>0;_o20--)if("table"==e.node(_o20).type.spec.tableRole)return n&&n(t.tr["delete"](e.before(_o20),e.after(_o20)).scrollIntoView()),!0;return!1;}function st(t,n){var e=t.selection;if(!(e instanceof j))return!1;if(n){var _o21=t.tr,_r20=_(t.schema).cell.createAndFill().content;e.forEachCell(function(t,n){t.content.eq(_r20)||_o21.replace(_o21.mapping.map(n+1),_o21.mapping.map(n+t.nodeSize-1),new l(_r20,0,0));}),_o21.docChanged&&n(_o21);}return!0;}function ct(t){if(0===t.size)return null;var n=t.content,e=t.openStart,o=t.openEnd;for(;1==n.childCount&&(e>0&&o>0||"table"==n.child(0).type.spec.tableRole);)e--,o--,n=n.child(0).content;var r=n.child(0),s=r.type.spec.tableRole,c=r.type.schema,f=[];if("row"==s)for(var _t53=0;_t53<n.childCount;_t53++){var _r21=n.child(_t53).content;var _i19=_t53?0:Math.max(0,e-1),_s13=_t53<n.childCount-1?0:Math.max(0,o-1);(_i19||_s13)&&(_r21=ft(_(c).row,new l(_r21,_i19,_s13)).content),f.push(_r21);}else{if("cell"!=s&&"header_cell"!=s)return null;f.push(e||o?ft(_(c).row,new l(n,e,o)).content:n);}return function(t,n){var e=[];for(var _t54=0;_t54<n.length;_t54++){var _o22=n[_t54];for(var _n20=_o22.childCount-1;_n20>=0;_n20--){var _o22$child$attrs=_o22.child(_n20).attrs,_r22=_o22$child$attrs.rowspan,_i20=_o22$child$attrs.colspan;for(var _n21=_t54;_n21<_t54+_r22;_n21++)e[_n21]=(e[_n21]||0)+_i20;}}var o=0;for(var _t55=0;_t55<e.length;_t55++)o=Math.max(o,e[_t55]);for(var _r23=0;_r23<e.length;_r23++)if(_r23>=n.length&&n.push(i.empty),e[_r23]<o){var _l17=_(t).cell.createAndFill(),_s14=[];for(var _t56=e[_r23];_t56<o;_t56++)_s14.push(_l17);n[_r23]=n[_r23].append(i.from(_s14));}return{height:n.length,width:o,rows:n};}(c,f);}function ft(t,n){var e=t.createAndFill();return new c(e).replace(0,e.content.size,n).doc;}function ut(t,n,e,o,r,i,l,s){if(0==l||l==n.height)return!1;var c=!1;for(var _f12=r;_f12<i;_f12++){var _r24=l*n.width+_f12,_i21=n.map[_r24];if(n.map[_r24-n.width]==_i21){c=!0;var _r25=e.nodeAt(_i21),_n$findCell=n.findCell(_i21),_u10=_n$findCell.top,_a6=_n$findCell.left;t.setNodeMarkup(t.mapping.slice(s).map(_i21+o),null,_objectSpread(_objectSpread({},_r25.attrs),{},{rowspan:l-_u10})),t.insert(t.mapping.slice(s).map(n.positionAt(l,_a6,e)),_r25.type.createAndFill(_objectSpread(_objectSpread({},_r25.attrs),{},{rowspan:_u10+_r25.attrs.rowspan-l}))),_f12+=_r25.attrs.colspan-1;}}return c;}function at(t,n,e,o,r,i,l,s){if(0==l||l==n.width)return!1;var c=!1;for(var _f13=r;_f13<i;_f13++){var _r26=_f13*n.width+l,_i22=n.map[_r26];if(n.map[_r26-1]==_i22){c=!0;var _r27=e.nodeAt(_i22),_u11=n.colCount(_i22),_a7=t.mapping.slice(s).map(_i22+o);t.setNodeMarkup(_a7,null,x(_r27.attrs,l-_u11,_r27.attrs.colspan-(l-_u11))),t.insert(_a7+_r27.nodeSize,_r27.type.createAndFill(x(_r27.attrs,0,l-_u11))),_f13+=_r27.attrs.rowspan-1;}}return c;}function ht(t,n,e,o,r){var s=e?t.doc.nodeAt(e-1):t.doc;if(!s)throw new Error("No table found");var c=_y.get(s);var f=o.top,u=o.left,a=u+r.width,h=f+r.height,w=t.tr;var d=0;function p(){if(s=e?w.doc.nodeAt(e-1):w.doc,!s)throw new Error("No table found");c=_y.get(s),d=w.mapping.maps.length;}(function(t,n,e,o,r,l,s){var c=_(t.doc.type.schema);var f,u;if(r>n.width)for(var _i23=0,_l18=0;_i23<n.height;_i23++){var _a8=e.child(_i23);_l18+=_a8.nodeSize;var _h2=[];var _w2=void 0;_w2=null==_a8.lastChild||_a8.lastChild.type==c.cell?f||(f=c.cell.createAndFill()):u||(u=c.header_cell.createAndFill());for(var _t57=n.width;_t57<r;_t57++)_h2.push(_w2);t.insert(t.mapping.slice(s).map(_l18-1+o),_h2);}if(l>n.height){var _a9=[];for(var _t58=0,_o23=(n.height-1)*n.width;_t58<Math.max(n.width,r);_t58++){var _r28=!(_t58>=n.width)&&e.nodeAt(n.map[_o23+_t58]).type==c.header_cell;_a9.push(_r28?u||(u=c.header_cell.createAndFill()):f||(f=c.cell.createAndFill()));}var _h3=c.row.create(null,i.from(_a9)),_w3=[];for(var _t59=n.height;_t59<l;_t59++)_w3.push(_h3);t.insert(t.mapping.slice(s).map(o+e.nodeSize-2),_w3);}return!(!f&&!u);})(w,c,s,e,a,h,d)&&p(),ut(w,c,s,e,u,a,f,d)&&p(),ut(w,c,s,e,u,a,h,d)&&p(),at(w,c,s,e,f,h,u,d)&&p(),at(w,c,s,e,f,h,a,d)&&p();for(var _t60=f;_t60<h;_t60++){var _n22=c.positionAt(_t60,u,s),_o24=c.positionAt(_t60,a,s);w.replace(w.mapping.slice(d).map(_n22+e),w.mapping.slice(d).map(_o24+e),new l(r.rows[_t60-f],0,0));}p(),w.setSelection(new j(w.doc.resolve(e+c.positionAt(f,u,s)),w.doc.resolve(e+c.positionAt(h-1,a-1,s)))),n(w);}function dt(t,n,e){return!e.eq(t.selection)&&(n&&n(t.tr.setSelection(e).scrollIntoView()),!0);}function pt(t,n){return function(o,r,i){if(!i)return!1;var l=o.selection;if(l instanceof j)return dt(o,r,e.near(l.$headCell,n));if("horiz"!=t&&!l.empty)return!1;var s=Mt(i,t,n);if(null==s)return!1;if("horiz"==t)return dt(o,r,e.near(o.doc.resolve(l.head+n),n));{var _i24=o.doc.resolve(s),_l19=T(_i24,t,n);var _c13;return _c13=_l19?e.near(_l19,1):n<0?e.near(o.doc.resolve(_i24.before(-1)),-1):e.near(o.doc.resolve(_i24.after(-1)),1),dt(o,r,_c13);}};}function mt(t,n){return function(e,o,r){if(!r)return!1;var i=e.selection;var l;if(i instanceof j)l=i;else{var _o25=Mt(r,t,n);if(null==_o25)return!1;l=new j(e.doc.resolve(_o25));}var s=T(l.$headCell,t,n);return!!s&&dt(e,o,new j(l.$anchorCell,s));};}function gt(t,n){var e=z(t.state.doc.resolve(n));return!!e&&(t.dispatch(t.state.tr.setSelection(new j(e))),!0);}function bt(t,n,e){if(!k(t.state))return!1;var o=ct(e);var r=t.state.selection;if(r instanceof j){o||(o={width:1,height:1,rows:[i.from(ft(_(t.state.schema).cell,e))]});var _n23=r.$anchorCell.node(-1),_l20=r.$anchorCell.start(-1),_s15=_y.get(_n23).rectBetween(r.$anchorCell.pos-_l20,r.$headCell.pos-_l20);return o=function(_ref7,o,r){var t=_ref7.width,n=_ref7.height,e=_ref7.rows;if(t!=o){var _n24=[],_r29=[];for(var _t61=0;_t61<e.length;_t61++){var _l21=e[_t61],_s16=[];for(var _e32=_n24[_t61]||0,_r30=0;_e32<o;_r30++){var _i25=_l21.child(_r30%_l21.childCount);_e32+_i25.attrs.colspan>o&&(_i25=_i25.type.createChecked(x(_i25.attrs,_i25.attrs.colspan,_e32+_i25.attrs.colspan-o),_i25.content)),_s16.push(_i25),_e32+=_i25.attrs.colspan;for(var _e33=1;_e33<_i25.attrs.rowspan;_e33++)_n24[_t61+_e33]=(_n24[_t61+_e33]||0)+_i25.attrs.colspan;}_r29.push(i.from(_s16));}e=_r29,t=o;}if(n!=r){var _t62=[];for(var _o26=0,_l22=0;_o26<r;_o26++,_l22++){var _s17=[],_c14=e[_l22%n];for(var _t63=0;_t63<_c14.childCount;_t63++){var _n25=_c14.child(_t63);_o26+_n25.attrs.rowspan>r&&(_n25=_n25.type.create(_objectSpread(_objectSpread({},_n25.attrs),{},{rowspan:Math.max(1,r-_n25.attrs.rowspan)}),_n25.content)),_s17.push(_n25);}_t62.push(i.from(_s17));}e=_t62,n=r;}return{width:t,height:n,rows:e};}(o,_s15.right-_s15.left,_s15.bottom-_s15.top),ht(t.state,t.dispatch,_l20,_s15,o),!0;}if(o){var _n26=A(t.state),_e34=_n26.start(-1);return ht(t.state,t.dispatch,_e34,_y.get(_n26.node(-1)).findCell(_n26.pos-_e34),o),!0;}return!1;}function vt(t,n){var e;if(0!=n.button)return;if(n.ctrlKey||n.metaKey)return;var o=yt(t,n.target);var r;if(n.shiftKey&&t.state.selection instanceof j)i(t.state.selection.$anchorCell,n),n.preventDefault();else if(n.shiftKey&&o&&null!=(r=z(t.state.selection.$anchor))&&(null===(e=Dt(t,n))||void 0===e?void 0:e.pos)!=r.pos)i(r,n),n.preventDefault();else if(!o)return;function i(n,e){var o=Dt(t,e);var r=null==N.getState(t.state);if(!o||!O(n,o)){if(!r)return;o=n;}var i=new j(n,o);if(r||!t.state.selection.eq(i)){var _e35=t.state.tr.setSelection(i);r&&_e35.setMeta(N,n.pos),t.dispatch(_e35);}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",s),null!=N.getState(t.state)&&t.dispatch(t.state.tr.setMeta(N,-1));}function s(e){var r=e,s=N.getState(t.state);var c;if(null!=s)c=t.state.doc.resolve(s);else if(yt(t,r.target)!=o&&(c=Dt(t,n),!c))return l();c&&i(c,r);}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",s);}function Mt(t,n,e){if(!(t.state.selection instanceof r))return null;var o=t.state.selection.$head;for(var _r31=o.depth-1;_r31>=0;_r31--){var _i26=o.node(_r31);if((e<0?o.index(_r31):o.indexAfter(_r31))!=(e<0?0:_i26.childCount))return null;if("cell"==_i26.type.spec.tableRole||"header_cell"==_i26.type.spec.tableRole){var _i27=o.before(_r31),_l23="vert"==n?e>0?"down":"up":e>0?"right":"left";return t.endOfTextblock(_l23)?_i27:null;}}return null;}function yt(t,n){for(;n&&n!=t.dom;n=n.parentNode)if("TD"==n.nodeName||"TH"==n.nodeName)return n;return null;}function Dt(t,n){var e=t.posAtCoords({left:n.clientX,top:n.clientY});if(!e)return null;var o=e.inside,r=e.pos;return o>=0&&z(t.state.doc.resolve(o))||z(t.state.doc.resolve(r));}function $t(t,n,e,o,r,i){var l=0,s=!0,c=n.firstChild;var f=t.firstChild;if(f){for(var _t64=0,_e36=0;_t64<f.childCount;_t64++){var _f$child$attrs=f.child(_t64).attrs,_u12=_f$child$attrs.colspan,_a10=_f$child$attrs.colwidth;for(var _t65=0;_t65<_u12;_t65++,_e36++){var _f14=r==_e36?i:_a10&&_a10[_t65],_u13=_f14?_f14+"px":"";if(l+=_f14||o,_f14||(s=!1),c)c.style.width!=_u13&&(c.style.width=_u13),c=c.nextSibling;else{var _t66=document.createElement("col");_t66.style.width=_u13,n.appendChild(_t66);}}}for(;c;){var u;var _t67=c.nextSibling;null===(u=c.parentNode)||void 0===u||u.removeChild(c),c=_t67;}s?(e.style.width=l+"px",e.style.minWidth=""):(e.style.width="",e.style.minWidth=l+"px");}}function Rt(){var _ref8=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref8$handleWidth=_ref8.handleWidth,n=_ref8$handleWidth===void 0?5:_ref8$handleWidth,_ref8$cellMinWidth=_ref8.cellMinWidth,e=_ref8$cellMinWidth===void 0?25:_ref8$cellMinWidth,_ref8$defaultCellMinW=_ref8.defaultCellMinWidth,o=_ref8$defaultCellMinW===void 0?100:_ref8$defaultCellMinW,_ref8$View=_ref8.View,r=_ref8$View===void 0?St:_ref8$View,_ref8$lastColumnResiz=_ref8.lastColumnResizable,i=_ref8$lastColumnResiz===void 0?!0:_ref8$lastColumnResiz;var l=new t({key:Et,state:{init:function init(t,n){var e;var i=null===(e=l.spec)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.nodeViews,s=_(n.schema).table.name;return r&&i&&(i[s]=function(t,n){return new r(t,o,n);}),new _t(-1,!1);},apply:function apply(t,n){return n.apply(t);}},props:{attributes:function attributes(t){var n=Et.getState(t);return n&&n.activeHandle>-1?{"class":"resize-cursor"}:{};},handleDOMEvents:{mousemove:function mousemove(t,e){!function(t,n,e,o){if(!t.editable)return;var r=Et.getState(t.state);if(!r)return;if(!r.dragging){var _i28=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t;}(n.target);var _l24=-1;if(_i28){var _i28$getBoundingClien=_i28.getBoundingClientRect(),_o27=_i28$getBoundingClien.left,_r32=_i28$getBoundingClien.right;n.clientX-_o27<=e?_l24=Nt(t,n,"left",e):_r32-n.clientX<=e&&(_l24=Nt(t,n,"right",e));}if(_l24!=r.activeHandle){if(!o&&-1!==_l24){var _n27=t.state.doc.resolve(_l24),_e37=_n27.node(-1),_o28=_y.get(_e37),_r33=_n27.start(-1);if(_o28.colCount(_n27.pos-_r33)+_n27.nodeAfter.attrs.colspan-1==_o28.width-1)return;}kt(t,_l24);}}}(t,e,n,i);},mouseleave:function mouseleave(t){!function(t){if(!t.editable)return;var n=Et.getState(t.state);n&&n.activeHandle>-1&&!n.dragging&&kt(t,-1);}(t);},mousedown:function mousedown(t,n){!function(t,n,e,o){var r;if(!t.editable)return!1;var i=null!==(r=t.dom.ownerDocument.defaultView)&&void 0!==r?r:window,l=Et.getState(t.state);if(!l||-1==l.activeHandle||l.dragging)return!1;var s=t.state.doc.nodeAt(l.activeHandle),c=function(t,n,_ref9){var e=_ref9.colspan,o=_ref9.colwidth;var r=o&&o[o.length-1];if(r)return r;var i=t.domAtPos(n);var l=i.node.childNodes[i.offset].offsetWidth,s=e;if(o)for(var _t68=0;_t68<e;_t68++)o[_t68]&&(l-=o[_t68],s--);return l/s;}(t,l.activeHandle,s.attrs);function f(n){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",u);var o=Et.getState(t.state);(null==o?void 0:o.dragging)&&(!function(t,n,e){var o=t.state.doc.resolve(n),r=o.node(-1),i=_y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(var _t69=0;_t69<i.height;_t69++){var _n28=_t69*i.width+s;if(_t69&&i.map[_n28]==i.map[_n28-i.width])continue;var _o29=i.map[_n28],_f15=r.nodeAt(_o29).attrs,_u14=1==_f15.colspan?0:s-i.colCount(_o29);if(_f15.colwidth&&_f15.colwidth[_u14]==e)continue;var _a11=_f15.colwidth?_f15.colwidth.slice():Ct(_f15.colspan);_a11[_u14]=e,c.setNodeMarkup(l+_o29,null,_objectSpread(_objectSpread({},_f15),{},{colwidth:_a11}));}c.docChanged&&t.dispatch(c);}(t,o.activeHandle,zt(o.dragging,n,e)),t.dispatch(t.state.tr.setMeta(Et,{setDragging:null})));}function u(n){if(!n.which)return f(n);var r=Et.getState(t.state);if(r&&r.dragging){var _i29=zt(r.dragging,n,e);At(t,r.activeHandle,_i29,o);}}t.dispatch(t.state.tr.setMeta(Et,{setDragging:{startX:n.clientX,startWidth:c}})),At(t,l.activeHandle,c,o),i.addEventListener("mouseup",f),i.addEventListener("mousemove",u),n.preventDefault();}(t,n,e,o);}},decorations:function decorations(t){var n=Et.getState(t);if(n&&n.activeHandle>-1)return function(t,n){var e=[],o=t.doc.resolve(n),r=o.node(-1);if(!r)return f.empty;var i=_y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(var _n29=0;_n29<i.height;_n29++){var _o30=s+_n29*i.width;if(!(s!=i.width-1&&i.map[_o30]==i.map[_o30+1]||0!=_n29&&i.map[_o30]==i.map[_o30-i.width])){var c;var _n30=i.map[_o30],_s18=l+_n30+r.nodeAt(_n30).nodeSize-1,_f16=document.createElement("div");_f16.className="column-resize-handle",(null===(c=Et.getState(t))||void 0===c?void 0:c.dragging)&&e.push(u.node(l+_n30,l+_n30+r.nodeAt(_n30).nodeSize,{"class":"column-resize-dragging"})),e.push(u.widget(_s18,_f16));}}return f.create(t.doc,e);}(t,n.activeHandle);},nodeViews:{}}});return l;}function Nt(t,n,e,o){var r="right"==e?-o:o,i=t.posAtCoords({left:n.clientX+r,top:n.clientY});if(!i)return-1;var l=i.pos,s=z(t.state.doc.resolve(l));if(!s)return-1;if("right"==e)return s.pos;var c=_y.get(s.node(-1)),f=s.start(-1),u=c.map.indexOf(s.pos-f);return u%c.width==0?-1:f+c.map[u-1];}function zt(t,n,e){var o=n.clientX-t.startX;return Math.max(e,t.startWidth+o);}function kt(t,n){t.dispatch(t.state.tr.setMeta(Et,{setHandle:n}));}function At(t,n,e,o){var r=t.state.doc.resolve(n),i=r.node(-1),l=r.start(-1),s=_y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;var c=t.domAtPos(r.start(-1)).node;for(;c&&"TABLE"!=c.nodeName;)c=c.parentNode;c&&$t(i,c.firstChild,c,o,s,e);}function Ct(t){return Array(t).fill(0);}function Ot(){var _ref10=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref10$allowTableNode=_ref10.allowTableNodeSelection,n=_ref10$allowTableNode===void 0?!1:_ref10$allowTableNode;return new t({key:N,state:{init:function init(){return null;},apply:function apply(t,n){var e=t.getMeta(N);if(null!=e)return-1==e?null:e;if(null==n||!t.docChanged)return n;var _t$mapping$mapResult=t.mapping.mapResult(n),o=_t$mapping$mapResult.deleted,r=_t$mapping$mapResult.pos;return o?null:r;}},props:{decorations:B,handleDOMEvents:{mousedown:vt},createSelectionBetween:function createSelectionBetween(t){return null!=N.getState(t.state)?t.state.selection:null;},handleTripleClick:gt,handleKeyDown:wt,handlePaste:bt},appendTransaction:function appendTransaction(t,e,o){return function(t,n,e){var o=(n||t).selection,i=(n||t).doc;var l,c;if(o instanceof s&&(c=o.node.type.spec.tableRole)){if("cell"==c||"header_cell"==c)l=j.create(i,o.from);else if("row"==c){var _t71=i.resolve(o.from+1);l=j.rowSelection(_t71,_t71);}else if(!e){var _t72=_y.get(o.node),_n31=o.from+1,_e38=_n31+_t72.map[_t72.width*_t72.height-1];l=j.create(i,_n31+1,_e38);}}else o instanceof r&&function(_ref11){var t=_ref11.$from,n=_ref11.$to;if(t.pos==n.pos||t.pos<n.pos-6)return!1;var e=t.pos,o=n.pos,r=t.depth;for(;r>=0&&!(t.after(r+1)<t.end(r));r--,e++);for(var _t73=n.depth;_t73>=0&&!(n.before(_t73+1)>n.start(_t73));_t73--,o--);return e==o&&/row|table/.test(t.node(r).type.spec.tableRole);}(o)?l=r.create(i,o.from):o instanceof r&&function(_ref12){var t=_ref12.$from,n=_ref12.$to;var e,o;for(var _n32=t.depth;_n32>0;_n32--){var _o32=t.node(_n32);if("cell"===_o32.type.spec.tableRole||"header_cell"===_o32.type.spec.tableRole){e=_o32;break;}}for(var _t74=n.depth;_t74>0;_t74--){var _e39=n.node(_t74);if("cell"===_e39.type.spec.tableRole||"header_cell"===_e39.type.spec.tableRole){o=_e39;break;}}return e!==o&&0===n.parentOffset;}(o)&&(l=r.create(i,o.$from.start(),o.$from.end()));return l&&(n||(n=t.tr)).setSelection(l),n;}(o,J(o,e),n);}});}_export({a:R,b:b,c:Rt,d:lt,f:I,g:Z,h:q,i:V,j:Q,k:g,l:G,m:nt,s:et,t:Ot});return{setters:[function(_index00aCjsJs){t=_index00aCjsJs.b;n=_index00aCjsJs.P;e=_index00aCjsJs.S;o=_index00aCjsJs.k;r=_index00aCjsJs.T;i=_index00aCjsJs.F;l=_index00aCjsJs.d;s=_index00aCjsJs.c;c=_index00aCjsJs.m;},function(_index009CjsJs){f=_index009CjsJs.D;u=_index009CjsJs.a;},function(_index007CjsJs){a=_index007CjsJs.k;h=_index007CjsJs.b;}],execute:function execute(){w="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);if("undefined"!=typeof WeakMap){_t3=new WeakMap();v=function v(n){return _t3.get(n);},M=function M(n,e){return _t3.set(n,e),e;};}else{_t4=[],_n=10;_e2=0;v=function v(n){for(var _e3=0;_e3<_t4.length;_e3+=2)if(_t4[_e3]==n)return _t4[_e3+1];},M=function M(o,r){return _e2==_n&&(_e2=0),_t4[_e2++]=o,_t4[_e2++]=r;};}_y=/*#__PURE__*/function(){function y(t,n,e,o){_classCallCheck(this,y);this.width=t,this.height=n,this.map=e,this.problems=o;}return _createClass(y,[{key:"findCell",value:function findCell(t){for(var _n2=0;_n2<this.map.length;_n2++){var _e4=this.map[_n2];if(_e4!=t)continue;var _o2=_n2%this.width,_r2=_n2/this.width|0;var _i=_o2+1,_l2=_r2+1;for(var _t5=1;_i<this.width&&this.map[_n2+_t5]==_e4;_t5++)_i++;for(var _t6=1;_l2<this.height&&this.map[_n2+this.width*_t6]==_e4;_t6++)_l2++;return{left:_o2,top:_r2,right:_i,bottom:_l2};}throw new RangeError("No cell with offset ".concat(t," found"));}},{key:"colCount",value:function colCount(t){for(var _n3=0;_n3<this.map.length;_n3++)if(this.map[_n3]==t)return _n3%this.width;throw new RangeError("No cell with offset ".concat(t," found"));}},{key:"nextCell",value:function nextCell(t,n,e){var _this$findCell=this.findCell(t),o=_this$findCell.left,r=_this$findCell.right,i=_this$findCell.top,l=_this$findCell.bottom;return"horiz"==n?(e<0?0==o:r==this.width)?null:this.map[i*this.width+(e<0?o-1:r)]:(e<0?0==i:l==this.height)?null:this.map[o+this.width*(e<0?i-1:l)];}},{key:"rectBetween",value:function rectBetween(t,n){var _this$findCell2=this.findCell(t),e=_this$findCell2.left,o=_this$findCell2.right,r=_this$findCell2.top,i=_this$findCell2.bottom,_this$findCell3=this.findCell(n),l=_this$findCell3.left,s=_this$findCell3.right,c=_this$findCell3.top,f=_this$findCell3.bottom;return{left:Math.min(e,l),top:Math.min(r,c),right:Math.max(o,s),bottom:Math.max(i,f)};}},{key:"cellsInRect",value:function cellsInRect(t){var n=[],e={};for(var _o3=t.top;_o3<t.bottom;_o3++)for(var _r3=t.left;_r3<t.right;_r3++){var _i2=_o3*this.width+_r3,_l3=this.map[_i2];e[_l3]||(e[_l3]=!0,_r3==t.left&&_r3&&this.map[_i2-1]==_l3||_o3==t.top&&_o3&&this.map[_i2-this.width]==_l3||n.push(_l3));}return n;}},{key:"positionAt",value:function positionAt(t,n,e){for(var _o4=0,_r4=0;;_o4++){var _i3=_r4+e.child(_o4).nodeSize;if(_o4==t){var _e5=n+t*this.width;var _o5=(t+1)*this.width;for(;_e5<_o5&&this.map[_e5]<_r4;)_e5++;return _e5==_o5?_i3-1:this.map[_e5];}_r4=_i3;}}}],[{key:"get",value:function get(t){return v(t)||M(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);var n=function(t){var n=-1,e=!1;for(var _o6=0;_o6<t.childCount;_o6++){var _r5=t.child(_o6);var _i4=0;if(e)for(var _n4=0;_n4<_o6;_n4++){var _e6=t.child(_n4);for(var _t7=0;_t7<_e6.childCount;_t7++){var _r6=_e6.child(_t7);_n4+_r6.attrs.rowspan>_o6&&(_i4+=_r6.attrs.colspan);}}for(var _t8=0;_t8<_r5.childCount;_t8++){var _n5=_r5.child(_t8);_i4+=_n5.attrs.colspan,_n5.attrs.rowspan>1&&(e=!0);}-1==n?n=_i4:n!=_i4&&(n=Math.max(n,_i4));}return n;}(t),e=t.childCount,o=[];var r=0,i=null;var l=[];for(var _t9=0,_r7=n*e;_t9<_r7;_t9++)o[_t9]=0;for(var _s=0,_c=0;_s<e;_s++){var _f=t.child(_s);_c++;for(var _t10=0;;_t10++){for(;r<o.length&&0!=o[r];)r++;if(_t10==_f.childCount)break;var _u=_f.child(_t10),_u$attrs=_u.attrs,_a=_u$attrs.colspan,_h=_u$attrs.rowspan,_w=_u$attrs.colwidth;for(var _t11=0;_t11<_h;_t11++){if(_t11+_s>=e){(i||(i=[])).push({type:"overlong_rowspan",pos:_c,n:_h-_t11});break;}var _f2=r+_t11*n;for(var _t12=0;_t12<_a;_t12++){0==o[_f2+_t12]?o[_f2+_t12]=_c:(i||(i=[])).push({type:"collision",row:_s,pos:_c,n:_a-_t12});var _e7=_w&&_w[_t12];if(_e7){var _o7=(_f2+_t12)%n*2,_r8=l[_o7];null==_r8||_r8!=_e7&&1==l[_o7+1]?(l[_o7]=_e7,l[_o7+1]=1):_r8==_e7&&l[_o7+1]++;}}}r+=_a,_c+=_u.nodeSize;}var _u2=(_s+1)*n;var _a2=0;for(;r<_u2;)0==o[r++]&&_a2++;_a2&&(i||(i=[])).push({type:"missing",row:_s,n:_a2}),_c++;}0!==n&&0!==e||(i||(i=[])).push({type:"zero_sized"});var s=new _y(n,e,o,i);var c=!1;for(var _t13=0;!c&&_t13<l.length;_t13+=2)null!=l[_t13]&&l[_t13+1]<e&&(c=!0);c&&function(t,n,e){t.problems||(t.problems=[]);var o={};for(var _r9=0;_r9<t.map.length;_r9++){var _i5=t.map[_r9];if(o[_i5])continue;o[_i5]=!0;var _l4=e.nodeAt(_i5);if(!_l4)throw new RangeError("No cell with offset ".concat(_i5," found"));var _s2=null;var _c2=_l4.attrs;for(var _e8=0;_e8<_c2.colspan;_e8++){var _o8=n[(_r9+_e8)%t.width*2];null==_o8||_c2.colwidth&&_c2.colwidth[_e8]==_o8||((_s2||(_s2=D(_c2)))[_e8]=_o8);}_s2&&t.problems.unshift({type:"colwidth mismatch",pos:_i5,colwidth:_s2});}}(s,l,t);return s;}(t));}}]);}();N=new n("selectingCells");j=/*#__PURE__*/function(_e14){function t(_t17){var _this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_t17;_classCallCheck(this,t);var e=_t17.node(-1),r=_y.get(e),i=_t17.start(-1),l=r.rectBetween(_t17.pos-i,n.pos-i),s=_t17.node(0),c=r.cellsInRect(l).filter(function(_t18){return _t18!=n.pos-i;});c.unshift(n.pos-i);var f=c.map(function(_t19){var n=e.nodeAt(_t19);if(!n)throw new RangeError("No cell with offset ".concat(_t19," found"));var r=i+_t19+1;return new o(s.resolve(r),s.resolve(r+n.content.size));});_this=_callSuper(this,t,[f[0].$from,f[0].$to,f]),_this.$anchorCell=_t17,_this.$headCell=n;return _this;}_inherits(t,_e14);return _createClass(t,[{key:"map",value:function map(n,e){var o=n.resolve(e.map(this.$anchorCell.pos)),i=n.resolve(e.map(this.$headCell.pos));if(C(o)&&C(i)&&O(o,i)){var _n10=this.$anchorCell.node(-1)!=o.node(-1);return _n10&&this.isRowSelection()?t.rowSelection(o,i):_n10&&this.isColSelection()?t.colSelection(o,i):new t(o,i);}return r.between(o,i);}},{key:"content",value:function content(){var _t20=this.$anchorCell.node(-1),n=_y.get(_t20),e=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-e,this.$headCell.pos-e),r={},s=[];for(var _e15=o.top;_e15<o.bottom;_e15++){var _l5=[];for(var _i6=_e15*n.width+o.left,_s3=o.left;_s3<o.right;_s3++,_i6++){var _e16=n.map[_i6];if(r[_e16])continue;r[_e16]=!0;var _s4=n.findCell(_e16);var _c3=_t20.nodeAt(_e16);if(!_c3)throw new RangeError("No cell with offset ".concat(_e16," found"));var _f3=o.left-_s4.left,_u3=_s4.right-o.right;if(_f3>0||_u3>0){var _t21=_c3.attrs;if(_f3>0&&(_t21=x(_t21,0,_f3)),_u3>0&&(_t21=x(_t21,_t21.colspan-_u3,_u3)),_s4.left<o.left){if(_c3=_c3.type.createAndFill(_t21),!_c3)throw new RangeError("Could not create cell with attrs ".concat(JSON.stringify(_t21)));}else _c3=_c3.type.create(_t21,_c3.content);}if(_s4.top<o.top||_s4.bottom>o.bottom){var _t22=_objectSpread(_objectSpread({},_c3.attrs),{},{rowspan:Math.min(_s4.bottom,o.bottom)-Math.max(_s4.top,o.top)});_c3=_s4.top<o.top?_c3.type.createAndFill(_t22):_c3.type.create(_t22,_c3.content);}_l5.push(_c3);}s.push(_t20.child(_e15).copy(i.from(_l5)));}var c=this.isColSelection()&&this.isRowSelection()?_t20:s;return new l(i.from(c),1,1);}},{key:"replace",value:function replace(_t23){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:l.empty;var o=_t23.steps.length,r=this.ranges;for(var _e17=0;_e17<r.length;_e17++){var _r$_e=r[_e17],_i7=_r$_e.$from,_s5=_r$_e.$to,_c4=_t23.mapping.slice(o);_t23.replace(_c4.map(_i7.pos),_c4.map(_s5.pos),_e17?l.empty:n);}var i=e.findFrom(_t23.doc.resolve(_t23.mapping.slice(o).map(this.to)),-1);i&&_t23.setSelection(i);}},{key:"replaceWith",value:function replaceWith(_t24,n){this.replace(_t24,new l(i.from(n),0,0));}},{key:"forEachCell",value:function forEachCell(_t25){var n=this.$anchorCell.node(-1),e=_y.get(n),o=this.$anchorCell.start(-1),r=e.cellsInRect(e.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(var _e18=0;_e18<r.length;_e18++)_t25(n.nodeAt(r[_e18]),o+r[_e18]);}},{key:"isColSelection",value:function isColSelection(){var _t26=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(_t26,n)>0)return!1;var e=_t26+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(e,o)==this.$headCell.node(-1).childCount;}},{key:"isRowSelection",value:function isRowSelection(){var _t27=this.$anchorCell.node(-1),n=_y.get(_t27),e=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-e),r=n.colCount(this.$headCell.pos-e);if(Math.min(o,r)>0)return!1;var i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width;}},{key:"eq",value:function eq(n){return n instanceof t&&n.$anchorCell.pos==this.$anchorCell.pos&&n.$headCell.pos==this.$headCell.pos;}},{key:"toJSON",value:function toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos};}},{key:"getBookmark",value:function getBookmark(){return new L(this.$anchorCell.pos,this.$headCell.pos);}}],[{key:"colSelection",value:function colSelection(n){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n;var o=n.node(-1),r=_y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.top<=s.top?(l.top>0&&(n=c.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=c.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(e=c.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=c.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new t(n,e);}},{key:"rowSelection",value:function rowSelection(n){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:n;var o=n.node(-1),r=_y.get(o),i=n.start(-1),l=r.findCell(n.pos-i),s=r.findCell(e.pos-i),c=n.node(0);return l.left<=s.left?(l.left>0&&(n=c.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=c.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(e=c.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=c.resolve(i+r.map[r.width*(l.top+1)-1]))),new t(n,e);}},{key:"fromJSON",value:function fromJSON(n,e){return new t(n.resolve(e.anchor),n.resolve(e.head));}},{key:"create",value:function create(n,e){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:e;return new t(n.resolve(e),n.resolve(o));}}]);}(e);j.prototype.visible=!1,e.jsonID("cell",j);L=/*#__PURE__*/function(){function t(_t28,n){_classCallCheck(this,t);this.anchor=_t28,this.head=n;}return _createClass(t,[{key:"map",value:function map(n){return new t(n.map(this.anchor),n.map(this.head));}},{key:"resolve",value:function resolve(_t29){var n=_t29.resolve(this.anchor),o=_t29.resolve(this.head);return"row"==n.parent.type.spec.tableRole&&"row"==o.parent.type.spec.tableRole&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&O(n,o)?new j(n,o):e.near(o,1);}}]);}();P=new n("fix-tables");_export("e",it=rt("row",{useDeprecatedLogic:!0}));rt("column",{useDeprecatedLogic:!0}),rt("cell",{useDeprecatedLogic:!0});wt=b({ArrowLeft:pt("horiz",-1),ArrowRight:pt("horiz",1),ArrowUp:pt("vert",-1),ArrowDown:pt("vert",1),"Shift-ArrowLeft":mt("horiz",-1),"Shift-ArrowRight":mt("horiz",1),"Shift-ArrowUp":mt("vert",-1),"Shift-ArrowDown":mt("vert",1),Backspace:st,"Mod-Backspace":st,Delete:st,"Mod-Delete":st});_export("T",St=/*#__PURE__*/function(){function St(t,n){_classCallCheck(this,St);this.node=t,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width","".concat(n,"px")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$t(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"));}return _createClass(St,[{key:"update",value:function update(t){return t.type==this.node.type&&(this.node=t,$t(t,this.colgroup,this.table,this.defaultCellMinWidth),!0);}},{key:"ignoreMutation",value:function ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target));}}]);}());Et=new n("tableColumnResizing");_t=/*#__PURE__*/function(){function t(_t70,n){_classCallCheck(this,t);this.activeHandle=_t70,this.dragging=n;}return _createClass(t,[{key:"apply",value:function apply(n){var e=this,o=n.getMeta(Et);if(o&&null!=o.setHandle)return new t(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new t(e.activeHandle,o.setDragging);if(e.activeHandle>-1&&n.docChanged){var _o31=n.mapping.map(e.activeHandle,-1);return C(n.doc.resolve(_o31))||(_o31=-1),new t(_o31,e.dragging);}return e;}}]);}();}};});
|
|
2
|
+
//# sourceMappingURL=index-d7e6f1c6.cjs.js.map
|