@notectl/core 1.0.6 → 1.0.8
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 +78 -56
- package/custom-elements.json +344 -0
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
- package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
- package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
- package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
- package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
- package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
- package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
- package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-sJTiZr-S.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
- package/dist/chunks/index-BAk1EG1x.mjs +541 -0
- package/dist/chunks/index-BAk1EG1x.mjs.map +1 -0
- package/dist/chunks/index-BRYzYOYC.mjs +63 -0
- package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
- package/dist/chunks/index-BSFLNveF.mjs +953 -0
- package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
- package/dist/chunks/index-BYgspns5.mjs +209 -0
- package/dist/chunks/index-BYgspns5.mjs.map +1 -0
- package/dist/chunks/index-B_3qDrUN.mjs +64 -0
- package/dist/chunks/index-B_3qDrUN.mjs.map +1 -0
- package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
- package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
- package/dist/chunks/index-C-YWHOcC.mjs +100 -0
- package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
- package/dist/chunks/index-C2GQoHot.mjs +92 -0
- package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
- package/dist/chunks/index-CT3HGdQt.mjs +39 -0
- package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
- package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
- package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
- package/dist/chunks/index-CxiWyUho.mjs +191 -0
- package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
- package/dist/chunks/index-D3CQWJiw.mjs +200 -0
- package/dist/chunks/index-D3CQWJiw.mjs.map +1 -0
- package/dist/chunks/index-DC1EK22F.mjs +41 -0
- package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
- package/dist/chunks/index-Dh76rR13.mjs +196 -0
- package/dist/chunks/index-Dh76rR13.mjs.map +1 -0
- package/dist/chunks/index-o6hDR07y.mjs +41 -0
- package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
- package/dist/chunks/index-uTnc9y7M.mjs +62 -0
- package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
- package/dist/editor/NotectlEditor.d.ts +10 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts +27 -0
- package/dist/editor/PaperLayoutController.d.ts.map +1 -0
- package/dist/editor/PaperSize.d.ts +35 -0
- package/dist/editor/PaperSize.d.ts.map +1 -0
- package/dist/editor/styles/color-picker.d.ts +1 -1
- package/dist/editor/styles/color-picker.d.ts.map +1 -1
- package/dist/editor/styles/paper.d.ts +3 -0
- package/dist/editor/styles/paper.d.ts.map +1 -0
- package/dist/editor/styles/table.d.ts +1 -1
- package/dist/editor/styles/table.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/editor/styles.d.ts.map +1 -1
- package/dist/i18n/Locale.d.ts +17 -0
- package/dist/i18n/Locale.d.ts.map +1 -0
- package/dist/i18n/LocaleService.d.ts +8 -0
- package/dist/i18n/LocaleService.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/resolvePluginLocale.d.ts +3 -0
- package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/notectl-core.mjs +2126 -1952
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +2002 -1544
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/PluginManager.d.ts +5 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
- package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +3 -89
- package/dist/plugins/alignment.mjs.map +1 -1
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
- package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
- package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
- package/dist/plugins/blockquote.mjs +2 -55
- package/dist/plugins/blockquote.mjs.map +1 -1
- package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
- package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block/CodeBlockTypes.d.ts +2 -0
- package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +3 -3
- package/dist/plugins/font/FontLocale.d.ts +15 -0
- package/dist/plugins/font/FontLocale.d.ts.map +1 -0
- package/dist/plugins/font/FontPlugin.d.ts +3 -0
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
- package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts +3 -0
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePopup.d.ts +2 -0
- package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +2 -201
- package/dist/plugins/font-size.mjs.map +1 -1
- package/dist/plugins/font.mjs +2 -183
- package/dist/plugins/font.mjs.map +1 -1
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
- package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -184
- package/dist/plugins/heading.mjs.map +1 -1
- package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
- package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
- package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +2 -123
- package/dist/plugins/highlight.mjs.map +1 -1
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
- package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
- package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/horizontal-rule.mjs +2 -56
- package/dist/plugins/horizontal-rule.mjs.map +1 -1
- package/dist/plugins/image/ImageLocale.d.ts +25 -0
- package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts +1 -0
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image/ImageUpload.d.ts +3 -0
- package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
- package/dist/plugins/image.mjs +4 -378
- package/dist/plugins/image.mjs.map +1 -1
- package/dist/plugins/link/LinkLocale.d.ts +23 -0
- package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
- package/dist/plugins/link/LinkPlugin.d.ts +3 -0
- package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
- package/dist/plugins/link.mjs +2 -124
- package/dist/plugins/link.mjs.map +1 -1
- package/dist/plugins/list/ListLocale.d.ts +18 -0
- package/dist/plugins/list/ListLocale.d.ts.map +1 -0
- package/dist/plugins/list/ListPlugin.d.ts +4 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +2 -190
- package/dist/plugins/list.mjs.map +1 -1
- package/dist/plugins/print/PrintLocale.d.ts +16 -0
- package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts +1 -0
- package/dist/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/dist/plugins/print/PrintStyleCollector.d.ts +7 -0
- package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -1
- package/dist/plugins/print/PrintTypes.d.ts +5 -0
- package/dist/plugins/print/PrintTypes.d.ts.map +1 -1
- package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
- package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
- package/dist/plugins/shared/ColorNames.d.ts +22 -0
- package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
- package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
- package/dist/plugins/shared/ColorValidation.d.ts +14 -0
- package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
- package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +2 -32
- package/dist/plugins/strikethrough.mjs.map +1 -1
- package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
- package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +2 -78
- package/dist/plugins/super-sub.mjs.map +1 -1
- package/dist/plugins/table/TableBorderColor.d.ts +24 -0
- package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
- package/dist/plugins/table/TableCommands.d.ts +9 -8
- package/dist/plugins/table/TableCommands.d.ts.map +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts +14 -0
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
- package/dist/plugins/table/TableControls.d.ts +3 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableLocale.d.ts +48 -0
- package/dist/plugins/table/TableLocale.d.ts.map +1 -0
- package/dist/plugins/table/TableNavigation.d.ts +2 -1
- package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts +3 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table/TablePlugin.d.ts +7 -1
- package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
- package/dist/plugins/table/index.d.ts +3 -0
- package/dist/plugins/table/index.d.ts.map +1 -1
- package/dist/plugins/table.mjs +18 -660
- package/dist/plugins/table.mjs.map +1 -1
- package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
- package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
- package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +2 -123
- package/dist/plugins/text-color.mjs.map +1 -1
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
- package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +2 -49
- package/dist/plugins/text-formatting.mjs.map +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +14 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/EditorState.d.ts +4 -1
- package/dist/state/EditorState.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
- package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
- package/dist/chunks/ToolbarPlugin-sJTiZr-S.mjs.map +0 -1
- package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
- package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
- package/dist/chunks/index-QvKiO9_4.mjs +0 -538
- package/dist/chunks/index-QvKiO9_4.mjs.map +0 -1
package/dist/plugins/table.mjs
CHANGED
|
@@ -1,663 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as r, b as i, c as l, d as s, g as a } from "../chunks/Document-CI3iCwEP.mjs";
|
|
3
|
-
import { n as c } from "../chunks/TypeBrands-C09nE2qO.mjs";
|
|
4
|
-
import { S as d } from "../chunks/Plugin-B9OZ6Y4c.mjs";
|
|
5
|
-
function u() {
|
|
6
|
-
const t2 = l(c("paragraph"), [s("")], i());
|
|
7
|
-
return l(c("table_cell"), [t2], i());
|
|
8
|
-
}
|
|
9
|
-
function b(t2, e2) {
|
|
10
|
-
const n2 = t2.getNodePath(e2);
|
|
11
|
-
if (!n2) return null;
|
|
12
|
-
let o2 = null, i2 = null, l2 = null, s2 = null;
|
|
13
|
-
for (const e3 of n2) {
|
|
14
|
-
const n3 = t2.getBlock(e3);
|
|
15
|
-
n3 && ("table" === n3.type ? (o2 = e3, i2 = n3) : "table_row" === n3.type ? l2 = e3 : "table_cell" === n3.type && (s2 = e3));
|
|
16
|
-
}
|
|
17
|
-
const a2 = t2.getBlock(e2);
|
|
18
|
-
if ("table_cell" === a2?.type && (s2 = e2), !(o2 && i2 && s2 && l2)) return null;
|
|
19
|
-
const c2 = t2.doc.children.findIndex((t3) => t3.id === o2), d2 = r(i2), u2 = d2.findIndex((t3) => t3.id === l2);
|
|
20
|
-
if (-1 === u2) return null;
|
|
21
|
-
const b2 = d2[u2];
|
|
22
|
-
if (!b2) return null;
|
|
23
|
-
const h2 = r(b2), p2 = h2.findIndex((t3) => t3.id === s2);
|
|
24
|
-
if (-1 === p2) return null;
|
|
25
|
-
const f2 = h2.length, m2 = d2.length;
|
|
26
|
-
return { tableId: o2, tableIndex: c2, rowId: l2, rowIndex: u2, cellId: s2, colIndex: p2, totalRows: m2, totalCols: f2 };
|
|
27
|
-
}
|
|
28
|
-
function h(t2, e2, n2, o2) {
|
|
29
|
-
const i2 = t2.getBlock(e2);
|
|
30
|
-
if (!i2) return null;
|
|
31
|
-
const l2 = r(i2)[n2];
|
|
32
|
-
if (!l2) return null;
|
|
33
|
-
const s2 = r(l2)[o2];
|
|
34
|
-
return s2?.id ?? null;
|
|
35
|
-
}
|
|
36
|
-
function p(t2, e2) {
|
|
37
|
-
const n2 = t2.getBlock(e2);
|
|
38
|
-
if (!n2) return e2;
|
|
39
|
-
const o2 = r(n2)[0];
|
|
40
|
-
if (!o2) return e2;
|
|
41
|
-
let i2 = o2;
|
|
42
|
-
for (; ; ) {
|
|
43
|
-
const t3 = r(i2)[0];
|
|
44
|
-
if (!t3) return i2.id;
|
|
45
|
-
i2 = t3;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function f(t2, e2) {
|
|
49
|
-
const n2 = t2.getBlock(e2);
|
|
50
|
-
if (!n2) return e2;
|
|
51
|
-
const o2 = r(n2), i2 = o2[o2.length - 1];
|
|
52
|
-
if (!i2) return e2;
|
|
53
|
-
let l2 = i2;
|
|
54
|
-
for (; ; ) {
|
|
55
|
-
const t3 = r(l2), e3 = t3[t3.length - 1];
|
|
56
|
-
if (!e3) return l2.id;
|
|
57
|
-
l2 = e3;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function m(t2, e2) {
|
|
61
|
-
const n2 = t2.getNodePath(e2);
|
|
62
|
-
if (!n2) return false;
|
|
63
|
-
for (const e3 of n2) {
|
|
64
|
-
const n3 = t2.getBlock(e3);
|
|
65
|
-
if ("table" === n3?.type) return true;
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
function g(t2, n2, o2) {
|
|
70
|
-
const s2 = t2.getBlock(n2);
|
|
71
|
-
if (!s2) return null;
|
|
72
|
-
const a2 = r(s2), d2 = a2[0] ? r(a2[0]).length : 0;
|
|
73
|
-
if (0 === d2) return null;
|
|
74
|
-
const b2 = (function(t3) {
|
|
75
|
-
const e2 = [];
|
|
76
|
-
for (let n3 = 0; n3 < t3; n3++) e2.push(u());
|
|
77
|
-
return l(c("table_row"), e2, i());
|
|
78
|
-
})(d2), h2 = t2.transaction("command").insertNode([n2], o2, b2), p2 = r(b2)[0], f2 = p2 ? r(p2)[0] : void 0;
|
|
79
|
-
return f2 ? h2.setSelection(e(f2.id, 0)) : p2 && h2.setSelection(e(p2.id, 0)), h2.build();
|
|
80
|
-
}
|
|
81
|
-
function v(t2, e2, n2) {
|
|
82
|
-
const o2 = t2.getBlock(e2);
|
|
83
|
-
if (!o2) return null;
|
|
84
|
-
const i2 = r(o2), l2 = t2.transaction("command");
|
|
85
|
-
for (const t3 of i2) {
|
|
86
|
-
const o3 = u();
|
|
87
|
-
l2.insertNode([e2, t3.id], n2, o3);
|
|
88
|
-
}
|
|
89
|
-
return l2.setSelection(t2.selection), l2.build();
|
|
90
|
-
}
|
|
91
|
-
function w(t2, n2, o2, i2 = 0) {
|
|
92
|
-
const l2 = t2.getBlock(n2);
|
|
93
|
-
if (!l2) return null;
|
|
94
|
-
if (r(l2).length <= 1) return I(t2, n2);
|
|
95
|
-
const s2 = t2.transaction("command").removeNode([n2], o2), a2 = h(t2, n2, o2 > 0 ? o2 - 1 : 1, i2);
|
|
96
|
-
if (a2) {
|
|
97
|
-
const n3 = p(t2, a2);
|
|
98
|
-
s2.setSelection(e(n3, 0));
|
|
99
|
-
}
|
|
100
|
-
return s2.build();
|
|
101
|
-
}
|
|
102
|
-
function x(t2, n2, o2, i2 = 0) {
|
|
103
|
-
const l2 = t2.getBlock(n2);
|
|
104
|
-
if (!l2) return null;
|
|
105
|
-
const s2 = r(l2);
|
|
106
|
-
if ((s2[0] ? r(s2[0]).length : 0) <= 1) return I(t2, n2);
|
|
107
|
-
const a2 = t2.transaction("command");
|
|
108
|
-
for (let t3 = s2.length - 1; t3 >= 0; t3--) {
|
|
109
|
-
const e2 = s2[t3];
|
|
110
|
-
e2 && a2.removeNode([n2, e2.id], o2);
|
|
111
|
-
}
|
|
112
|
-
const c2 = h(t2, n2, i2, o2 > 0 ? o2 - 1 : 1);
|
|
113
|
-
if (c2) {
|
|
114
|
-
const n3 = p(t2, c2);
|
|
115
|
-
a2.setSelection(e(n3, 0));
|
|
116
|
-
}
|
|
117
|
-
return a2.build();
|
|
118
|
-
}
|
|
119
|
-
function I(t2, n2) {
|
|
120
|
-
const o2 = t2.doc.children.findIndex((t3) => t3.id === n2);
|
|
121
|
-
if (-1 === o2) return null;
|
|
122
|
-
const r2 = t2.transaction("command").removeNode([], o2), i2 = t2.doc.children[o2 + 1];
|
|
123
|
-
if (i2) return r2.setSelection(e(i2.id, 0)), r2.build();
|
|
124
|
-
const l2 = t2.doc.children[o2 - 1];
|
|
125
|
-
return l2 && r2.setSelection(e(l2.id, 0)), r2.build();
|
|
126
|
-
}
|
|
127
|
-
function y(n2, o2, s2) {
|
|
128
|
-
const a2 = n2.getState(), d2 = a2.selection;
|
|
129
|
-
if (t(d2)) return false;
|
|
130
|
-
const b2 = d2.anchor.blockId;
|
|
131
|
-
let h2 = -1;
|
|
132
|
-
for (let t2 = 0; t2 < a2.doc.children.length; t2++) {
|
|
133
|
-
const e2 = a2.doc.children[t2];
|
|
134
|
-
if (!e2) continue;
|
|
135
|
-
if (e2.id === b2) {
|
|
136
|
-
h2 = t2;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
const n3 = a2.getNodePath(b2);
|
|
140
|
-
if (n3 && n3[0] === e2.id) {
|
|
141
|
-
h2 = t2;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
-1 === h2 && (h2 = a2.doc.children.length - 1);
|
|
146
|
-
const p2 = (function(t2, e2) {
|
|
147
|
-
const n3 = i(), o3 = [];
|
|
148
|
-
for (let n4 = 0; n4 < t2; n4++) {
|
|
149
|
-
const t3 = [];
|
|
150
|
-
for (let n5 = 0; n5 < e2; n5++) t3.push(u());
|
|
151
|
-
o3.push(l(c("table_row"), t3, i()));
|
|
152
|
-
}
|
|
153
|
-
return l(c("table"), o3, n3);
|
|
154
|
-
})(o2, s2), f2 = l(c("paragraph")), m2 = h2 + 1, g2 = a2.transaction("command").insertNode([], m2, p2).insertNode([], m2 + 1, f2), v2 = r(p2)[0], w2 = v2 ? r(v2)[0] : void 0, x2 = w2 ? r(w2)[0] : void 0;
|
|
155
|
-
return x2 ? g2.setSelection(e(x2.id, 0)) : w2 && g2.setSelection(e(w2.id, 0)), n2.dispatch(g2.build()), true;
|
|
156
|
-
}
|
|
157
|
-
function k(e2) {
|
|
158
|
-
const n2 = e2.getState();
|
|
159
|
-
if (t(n2.selection)) return false;
|
|
160
|
-
const o2 = b(n2, n2.selection.anchor.blockId);
|
|
161
|
-
if (!o2) return false;
|
|
162
|
-
const r2 = g(n2, o2.tableId, o2.rowIndex + 1);
|
|
163
|
-
return !!r2 && (e2.dispatch(r2), true);
|
|
164
|
-
}
|
|
165
|
-
function S(e2, n2) {
|
|
166
|
-
const o2 = e2.getState();
|
|
167
|
-
if (t(o2.selection)) return false;
|
|
168
|
-
const r2 = b(o2, o2.selection.anchor.blockId);
|
|
169
|
-
if (!r2) return false;
|
|
170
|
-
const i2 = "left" === n2 ? r2.colIndex : r2.colIndex + 1, l2 = v(o2, r2.tableId, i2);
|
|
171
|
-
return !!l2 && (e2.dispatch(l2), true);
|
|
172
|
-
}
|
|
173
|
-
function C(e2) {
|
|
174
|
-
e2.registerCommand("insertTable", () => y(e2, 3, 3)), e2.registerCommand("addRowAbove", () => (function(e3) {
|
|
175
|
-
const n2 = e3.getState();
|
|
176
|
-
if (t(n2.selection)) return false;
|
|
177
|
-
const o2 = b(n2, n2.selection.anchor.blockId);
|
|
178
|
-
if (!o2) return false;
|
|
179
|
-
const r2 = g(n2, o2.tableId, o2.rowIndex);
|
|
180
|
-
return !!r2 && (e3.dispatch(r2), true);
|
|
181
|
-
})(e2)), e2.registerCommand("addRowBelow", () => k(e2)), e2.registerCommand("addColumnLeft", () => (function(t2) {
|
|
182
|
-
return S(t2, "left");
|
|
183
|
-
})(e2)), e2.registerCommand("addColumnRight", () => (function(t2) {
|
|
184
|
-
return S(t2, "right");
|
|
185
|
-
})(e2)), e2.registerCommand("deleteRow", () => (function(e3) {
|
|
186
|
-
const n2 = e3.getState();
|
|
187
|
-
if (t(n2.selection)) return false;
|
|
188
|
-
const o2 = b(n2, n2.selection.anchor.blockId);
|
|
189
|
-
if (!o2) return false;
|
|
190
|
-
const r2 = w(n2, o2.tableId, o2.rowIndex, o2.colIndex);
|
|
191
|
-
return !!r2 && (e3.dispatch(r2), true);
|
|
192
|
-
})(e2)), e2.registerCommand("deleteColumn", () => (function(e3) {
|
|
193
|
-
const n2 = e3.getState();
|
|
194
|
-
if (t(n2.selection)) return false;
|
|
195
|
-
const o2 = b(n2, n2.selection.anchor.blockId);
|
|
196
|
-
if (!o2) return false;
|
|
197
|
-
const r2 = x(n2, o2.tableId, o2.colIndex, o2.rowIndex);
|
|
198
|
-
return !!r2 && (e3.dispatch(r2), true);
|
|
199
|
-
})(e2)), e2.registerCommand("selectTable", () => (function(e3) {
|
|
200
|
-
const o2 = e3.getState(), r2 = o2.selection;
|
|
201
|
-
if (t(r2)) {
|
|
202
|
-
const t2 = o2.getBlock(r2.nodeId);
|
|
203
|
-
return "table" === t2?.type;
|
|
204
|
-
}
|
|
205
|
-
const i2 = b(o2, r2.anchor.blockId);
|
|
206
|
-
if (!i2) return false;
|
|
207
|
-
const l2 = o2.getNodePath(i2.tableId);
|
|
208
|
-
if (!l2) return false;
|
|
209
|
-
const s2 = o2.transaction("command").setSelection(n(i2.tableId, l2)).build();
|
|
210
|
-
return e3.dispatch(s2), true;
|
|
211
|
-
})(e2)), e2.registerCommand("deleteTable", () => (function(e3) {
|
|
212
|
-
const n2 = e3.getState(), o2 = (function(e4) {
|
|
213
|
-
if (t(e4.selection)) {
|
|
214
|
-
const t2 = e4.getBlock(e4.selection.nodeId);
|
|
215
|
-
return "table" !== t2?.type ? null : { tableId: t2.id };
|
|
216
|
-
}
|
|
217
|
-
const n3 = b(e4, e4.selection.anchor.blockId);
|
|
218
|
-
return n3 ? { tableId: n3.tableId } : null;
|
|
219
|
-
})(n2);
|
|
220
|
-
if (!o2) return false;
|
|
221
|
-
const r2 = I(n2, o2.tableId);
|
|
222
|
-
return !!r2 && (e3.dispatch(r2), true);
|
|
223
|
-
})(e2));
|
|
224
|
-
}
|
|
225
|
-
function L(e2, n2) {
|
|
226
|
-
const o2 = e2.getState();
|
|
227
|
-
if (t(o2.selection)) return false;
|
|
228
|
-
const r2 = o2.selection, i2 = b(o2, r2.anchor.blockId);
|
|
229
|
-
return !!i2 && n2(o2, r2, i2);
|
|
230
|
-
}
|
|
231
|
-
function R(t2) {
|
|
232
|
-
return L(t2, (n2, o2, r2) => {
|
|
233
|
-
const i2 = r2.tableIndex + 1;
|
|
234
|
-
if (i2 >= n2.doc.children.length) return false;
|
|
235
|
-
const l2 = n2.doc.children[i2];
|
|
236
|
-
if (!l2) return false;
|
|
237
|
-
const s2 = n2.transaction("command").setSelection(e(l2.id, 0)).build();
|
|
238
|
-
return t2.dispatch(s2), true;
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function A(t2, n2, o2, r2) {
|
|
242
|
-
const i2 = t2.getState(), l2 = h(i2, n2, o2, r2);
|
|
243
|
-
if (!l2) return false;
|
|
244
|
-
const s2 = p(i2, l2), a2 = i2.transaction("command").setSelection(e(s2, 0)).build();
|
|
245
|
-
return t2.dispatch(a2), true;
|
|
246
|
-
}
|
|
247
|
-
function E(t2, n2, o2, r2) {
|
|
248
|
-
const i2 = t2.getState(), l2 = h(i2, n2, o2, r2);
|
|
249
|
-
if (!l2) return false;
|
|
250
|
-
const s2 = f(i2, l2), c2 = i2.getBlock(s2);
|
|
251
|
-
if (!c2) return false;
|
|
252
|
-
const d2 = a(c2), u2 = i2.transaction("command").setSelection(e(s2, d2)).build();
|
|
253
|
-
return t2.dispatch(u2), true;
|
|
254
|
-
}
|
|
255
|
-
function B(t2, e2) {
|
|
256
|
-
const o2 = t2.getState(), r2 = o2.getNodePath(e2);
|
|
257
|
-
if (!r2) return false;
|
|
258
|
-
const i2 = o2.transaction("input").setSelection(n(e2, r2)).build();
|
|
259
|
-
return t2.dispatch(i2), true;
|
|
260
|
-
}
|
|
261
|
-
const T = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 1v10M1 6h10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';
|
|
262
|
-
function N(t2, e2, n2) {
|
|
263
|
-
const o2 = document.createElement("button");
|
|
264
|
-
return o2.className = t2, o2.innerHTML = e2, o2.title = n2, o2.type = "button", o2.setAttribute("aria-label", n2), o2.setAttribute("contenteditable", "false"), o2.addEventListener("mousedown", (t3) => {
|
|
265
|
-
t3.preventDefault(), t3.stopPropagation();
|
|
266
|
-
}), o2;
|
|
267
|
-
}
|
|
268
|
-
function M(t2) {
|
|
269
|
-
const e2 = document.createElement("div");
|
|
270
|
-
e2.className = `ntbl-insert-line ntbl-insert-line--${t2}`, e2.setAttribute("contenteditable", "false"), e2.setAttribute("data-notectl-no-print", "");
|
|
271
|
-
const n2 = N("ntbl-insert-btn", T, "horizontal" === t2 ? "Insert row" : "Insert column");
|
|
272
|
-
return e2.appendChild(n2), e2;
|
|
273
|
-
}
|
|
274
|
-
function H(t2, e2) {
|
|
275
|
-
const n2 = document.createElement("button");
|
|
276
|
-
n2.className = `ntbl-add-zone ${t2}`, n2.type = "button", n2.setAttribute("contenteditable", "false"), n2.setAttribute("aria-label", e2), n2.setAttribute("data-notectl-no-print", ""), n2.title = e2;
|
|
277
|
-
const o2 = document.createElement("span");
|
|
278
|
-
return o2.className = "ntbl-add-icon", o2.innerHTML = T, n2.appendChild(o2), n2.addEventListener("mousedown", (t3) => {
|
|
279
|
-
t3.preventDefault(), t3.stopPropagation();
|
|
280
|
-
}), n2;
|
|
281
|
-
}
|
|
282
|
-
function z(t2) {
|
|
283
|
-
const e2 = document.createElement("div");
|
|
284
|
-
return e2.className = t2, e2.setAttribute("contenteditable", "false"), e2.setAttribute("data-notectl-no-print", ""), e2;
|
|
285
|
-
}
|
|
286
|
-
function V(t2, e2, n2, o2) {
|
|
287
|
-
const r2 = document.createElement("div");
|
|
288
|
-
r2.className = `ntbl-handle ${t2}`, r2.dataset.index = String(e2);
|
|
289
|
-
const i2 = N("ntbl-handle-delete", '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 2l6 6M8 2l-6 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', n2);
|
|
290
|
-
return i2.addEventListener("click", (t3) => {
|
|
291
|
-
t3.preventDefault(), t3.stopPropagation(), o2(e2);
|
|
292
|
-
}), r2.appendChild(i2), r2;
|
|
293
|
-
}
|
|
294
|
-
function $(t2, e2) {
|
|
295
|
-
let n2 = 0, o2 = 0, r2 = t2;
|
|
296
|
-
for (; r2 && r2 !== e2; ) n2 += r2.offsetTop, o2 += r2.offsetLeft, r2 = r2.offsetParent;
|
|
297
|
-
return { top: n2, left: o2 };
|
|
298
|
-
}
|
|
299
|
-
class _ {
|
|
300
|
-
tableId;
|
|
301
|
-
numRows;
|
|
302
|
-
numCols;
|
|
303
|
-
activeRowIndex = -1;
|
|
304
|
-
activeColIndex = -1;
|
|
305
|
-
colBar;
|
|
306
|
-
rowBar;
|
|
307
|
-
insertLineH;
|
|
308
|
-
insertLineV;
|
|
309
|
-
addRowZone;
|
|
310
|
-
addColZone;
|
|
311
|
-
deleteTableBtn;
|
|
312
|
-
observer;
|
|
313
|
-
container;
|
|
314
|
-
tableEl;
|
|
315
|
-
getState;
|
|
316
|
-
dispatchFn;
|
|
317
|
-
onMouseMove = (t2) => {
|
|
318
|
-
const e2 = this.tableEl.getBoundingClientRect(), n2 = t2.clientX - e2.left, o2 = t2.clientY - e2.top;
|
|
319
|
-
if (!(n2 >= -10 && n2 <= e2.width + 10 && o2 >= -10 && o2 <= e2.height + 10)) return void this.hideInsertLines();
|
|
320
|
-
const r2 = (function(t3, e3, n3, o3) {
|
|
321
|
-
let r3 = Number.POSITIVE_INFINITY, i2 = null;
|
|
322
|
-
for (const t4 of n3) {
|
|
323
|
-
const n4 = Math.abs(e3 - t4.position);
|
|
324
|
-
n4 < r3 && n4 < 10 && (r3 = n4, i2 = t4);
|
|
325
|
-
}
|
|
326
|
-
let l2 = Number.POSITIVE_INFINITY, s2 = null;
|
|
327
|
-
for (const e4 of o3) {
|
|
328
|
-
const n4 = Math.abs(t3 - e4.position);
|
|
329
|
-
n4 < l2 && n4 < 10 && (l2 = n4, s2 = e4);
|
|
330
|
-
}
|
|
331
|
-
return i2 && (!s2 || r3 <= l2) ? { type: "row", border: i2 } : s2 ? { type: "col", border: s2 } : { type: "none", border: null };
|
|
332
|
-
})(n2, o2, (function(t3) {
|
|
333
|
-
const e3 = t3.querySelectorAll(":scope > tbody > tr"), n3 = t3.offsetTop, o3 = [];
|
|
334
|
-
for (let t4 = 1; t4 < e3.length; t4++) {
|
|
335
|
-
const r3 = e3[t4];
|
|
336
|
-
r3 && o3.push({ position: r3.offsetTop - n3, index: t4 });
|
|
337
|
-
}
|
|
338
|
-
return o3;
|
|
339
|
-
})(this.tableEl), (function(t3, e3) {
|
|
340
|
-
if (e3 <= 1) return [];
|
|
341
|
-
const n3 = t3 / e3, o3 = [];
|
|
342
|
-
for (let t4 = 1; t4 < e3; t4++) o3.push({ position: Math.round(n3 * t4), index: t4 });
|
|
343
|
-
return o3;
|
|
344
|
-
})(this.tableEl.offsetWidth, this.numCols));
|
|
345
|
-
"row" === r2.type && r2.border ? (this.showHorizontalLine(r2.border), this.hideVerticalLine()) : "col" === r2.type && r2.border ? (this.showVerticalLine(r2.border), this.hideHorizontalLine()) : this.hideInsertLines();
|
|
346
|
-
};
|
|
347
|
-
onMouseLeave = () => {
|
|
348
|
-
this.hideInsertLines();
|
|
349
|
-
};
|
|
350
|
-
constructor(t2, e2, n2, o2, i2) {
|
|
351
|
-
this.container = t2, this.tableEl = e2, this.getState = o2, this.dispatchFn = i2, this.tableId = n2.id, this.numRows = r(n2).length, this.numCols = this.countCols(n2), this.colBar = z("ntbl-col-bar"), this.rowBar = z("ntbl-row-bar"), this.insertLineH = M("horizontal"), this.insertLineV = M("vertical"), this.addRowZone = H("ntbl-add-row", "Add row"), this.addColZone = H("ntbl-add-col", "Add column"), this.deleteTableBtn = N("ntbl-delete-table-btn", '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M9 3h6m-9 4h12M10 11v6m4-6v6m-9 3h14l-1-13H6L5 20z" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>', "Delete table"), this.deleteTableBtn.setAttribute("data-notectl-no-print", ""), t2.append(this.colBar, this.rowBar, this.insertLineH, this.insertLineV, this.addRowZone, this.addColZone, this.deleteTableBtn), this.rebuildColHandles(), this.rebuildRowHandles(), this.bindEventListeners(), this.observer = new ResizeObserver(() => {
|
|
352
|
-
this.positionControls();
|
|
353
|
-
}), this.observer.observe(e2), requestAnimationFrame(() => this.positionControls());
|
|
354
|
-
}
|
|
355
|
-
update(t2) {
|
|
356
|
-
this.tableId = t2.id;
|
|
357
|
-
const e2 = r(t2).length, n2 = this.countCols(t2);
|
|
358
|
-
e2 === this.numRows && n2 === this.numCols || (this.numRows = e2, this.numCols = n2, this.rebuildColHandles(), this.rebuildRowHandles()), requestAnimationFrame(() => this.positionControls());
|
|
359
|
-
}
|
|
360
|
-
destroy() {
|
|
361
|
-
this.observer.disconnect(), this.container.removeEventListener("mousemove", this.onMouseMove), this.container.removeEventListener("mouseleave", this.onMouseLeave), this.colBar.remove(), this.rowBar.remove(), this.insertLineH.remove(), this.insertLineV.remove(), this.addRowZone.remove(), this.addColZone.remove(), this.deleteTableBtn.remove();
|
|
362
|
-
}
|
|
363
|
-
bindEventListeners() {
|
|
364
|
-
const t2 = this.insertLineH.querySelector(".ntbl-insert-btn"), e2 = this.insertLineV.querySelector(".ntbl-insert-btn");
|
|
365
|
-
t2.addEventListener("click", () => {
|
|
366
|
-
this.activeRowIndex >= 0 && this.dispatchTransaction(g(this.getState(), this.tableId, this.activeRowIndex));
|
|
367
|
-
}), e2.addEventListener("click", () => {
|
|
368
|
-
this.activeColIndex >= 0 && this.dispatchTransaction(v(this.getState(), this.tableId, this.activeColIndex));
|
|
369
|
-
}), this.addRowZone.addEventListener("click", () => {
|
|
370
|
-
this.dispatchTransaction(g(this.getState(), this.tableId, this.numRows));
|
|
371
|
-
}), this.addColZone.addEventListener("click", () => {
|
|
372
|
-
this.dispatchTransaction(v(this.getState(), this.tableId, this.numCols));
|
|
373
|
-
}), this.deleteTableBtn.addEventListener("click", () => {
|
|
374
|
-
this.dispatchTransaction(I(this.getState(), this.tableId));
|
|
375
|
-
}), this.container.addEventListener("mousemove", this.onMouseMove), this.container.addEventListener("mouseleave", this.onMouseLeave);
|
|
376
|
-
}
|
|
377
|
-
dispatchTransaction(t2) {
|
|
378
|
-
t2 && this.dispatchFn(t2);
|
|
379
|
-
}
|
|
380
|
-
countCols(t2) {
|
|
381
|
-
const e2 = r(t2);
|
|
382
|
-
return e2[0] ? r(e2[0]).length : 0;
|
|
383
|
-
}
|
|
384
|
-
positionControls() {
|
|
385
|
-
!(function(t2, e2, n2) {
|
|
386
|
-
const o2 = t2.children;
|
|
387
|
-
if (0 === o2.length) return;
|
|
388
|
-
const r2 = e2 / n2;
|
|
389
|
-
for (let t3 = 0; t3 < o2.length; t3++) {
|
|
390
|
-
const e3 = o2[t3];
|
|
391
|
-
e3.style.left = `${Math.round(r2 * t3)}px`, e3.style.width = `${Math.round(r2)}px`;
|
|
392
|
-
}
|
|
393
|
-
t2.style.width = `${e2}px`;
|
|
394
|
-
})(this.colBar, this.tableEl.offsetWidth, this.numCols), (function(t2, e2) {
|
|
395
|
-
const n2 = t2.children;
|
|
396
|
-
if (0 === n2.length) return;
|
|
397
|
-
const o2 = e2.querySelectorAll(":scope > tbody > tr"), r2 = e2.offsetTop;
|
|
398
|
-
let i2 = 0;
|
|
399
|
-
for (let t3 = 0; t3 < n2.length; t3++) {
|
|
400
|
-
const e3 = n2[t3], l2 = o2[t3];
|
|
401
|
-
if (l2) {
|
|
402
|
-
const t4 = l2.offsetTop - r2, n3 = l2.offsetHeight;
|
|
403
|
-
e3.style.top = `${t4}px`, e3.style.height = `${n3}px`, i2 = t4 + n3;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
t2.style.height = `${i2}px`;
|
|
407
|
-
})(this.rowBar, this.tableEl), (function(t2, e2, n2, o2) {
|
|
408
|
-
const r2 = $(n2, o2), i2 = n2.offsetHeight, l2 = n2.offsetWidth;
|
|
409
|
-
t2.style.width = `${l2}px`, t2.style.left = `${r2.left}px`, e2.style.height = `${i2}px`, e2.style.top = `${r2.top}px`;
|
|
410
|
-
})(this.addRowZone, this.addColZone, this.tableEl, this.container);
|
|
411
|
-
}
|
|
412
|
-
showHorizontalLine(t2) {
|
|
413
|
-
this.activeRowIndex = t2.index;
|
|
414
|
-
const e2 = $(this.tableEl, this.container);
|
|
415
|
-
this.insertLineH.style.top = e2.top + t2.position - 1 + "px", this.insertLineH.style.left = `${e2.left}px`, this.insertLineH.style.width = `${this.tableEl.offsetWidth}px`, this.insertLineH.classList.add("ntbl-insert-line--visible");
|
|
416
|
-
}
|
|
417
|
-
showVerticalLine(t2) {
|
|
418
|
-
this.activeColIndex = t2.index;
|
|
419
|
-
const e2 = $(this.tableEl, this.container);
|
|
420
|
-
this.insertLineV.style.left = e2.left + t2.position - 1 + "px", this.insertLineV.style.top = `${e2.top}px`, this.insertLineV.style.height = `${this.tableEl.offsetHeight}px`, this.insertLineV.classList.add("ntbl-insert-line--visible");
|
|
421
|
-
}
|
|
422
|
-
hideInsertLines() {
|
|
423
|
-
this.hideHorizontalLine(), this.hideVerticalLine();
|
|
424
|
-
}
|
|
425
|
-
hideHorizontalLine() {
|
|
426
|
-
this.insertLineH.classList.remove("ntbl-insert-line--visible"), this.activeRowIndex = -1;
|
|
427
|
-
}
|
|
428
|
-
hideVerticalLine() {
|
|
429
|
-
this.insertLineV.classList.remove("ntbl-insert-line--visible"), this.activeColIndex = -1;
|
|
430
|
-
}
|
|
431
|
-
rebuildColHandles() {
|
|
432
|
-
this.colBar.innerHTML = "";
|
|
433
|
-
for (let t2 = 0; t2 < this.numCols; t2++) {
|
|
434
|
-
const e2 = V("ntbl-col-handle", t2, "Delete column", (t3) => {
|
|
435
|
-
this.dispatchTransaction(x(this.getState(), this.tableId, t3));
|
|
436
|
-
});
|
|
437
|
-
this.colBar.appendChild(e2);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
rebuildRowHandles() {
|
|
441
|
-
this.rowBar.innerHTML = "";
|
|
442
|
-
for (let t2 = 0; t2 < this.numRows; t2++) {
|
|
443
|
-
const e2 = V("ntbl-row-handle", t2, "Delete row", (t3) => {
|
|
444
|
-
this.dispatchTransaction(w(this.getState(), this.tableId, t3));
|
|
445
|
-
});
|
|
446
|
-
this.rowBar.appendChild(e2);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
const D = new d("tableSelection");
|
|
451
|
-
const P = { maxPickerRows: 8, maxPickerCols: 8 };
|
|
452
|
-
class Z {
|
|
453
|
-
id = "table";
|
|
454
|
-
name = "Table";
|
|
455
|
-
priority = 40;
|
|
456
|
-
config;
|
|
457
|
-
selectionService = null;
|
|
458
|
-
cleanupMouseSelection = null;
|
|
459
|
-
context = null;
|
|
460
|
-
constructor(t2) {
|
|
461
|
-
this.config = { ...P, ...t2 };
|
|
462
|
-
}
|
|
463
|
-
init(e2) {
|
|
464
|
-
e2.registerStyleSheet("\n/* Table */\n.notectl-table-wrapper {\n margin: 8px 0;\n overflow-x: auto;\n position: relative;\n}\n\n.notectl-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n\n.notectl-table td {\n border: 1px solid var(--notectl-border);\n padding: 8px 12px;\n min-width: 60px;\n vertical-align: top;\n min-height: 1.6em;\n}\n\n.notectl-table td:focus-within {\n outline: 2px solid var(--notectl-primary);\n outline-offset: -2px;\n}\n\n.notectl-table-cell--selected {\n background: var(--notectl-primary-muted);\n}\n\n/* Table Context Menu */\n.notectl-table-context-menu {\n position: fixed;\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px var(--notectl-shadow);\n padding: 4px 0;\n min-width: 180px;\n z-index: 10000;\n}\n\n.notectl-table-context-menu button {\n display: block;\n width: 100%;\n padding: 8px 12px;\n text-align: left;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 14px;\n color: var(--notectl-fg);\n font-family: inherit;\n}\n\n.notectl-table-context-menu button:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-table-context-menu hr {\n border: none;\n border-top: 1px solid var(--notectl-border);\n margin: 4px 0;\n}\n\n/* === Table Controls === */\n\n/* Outer container for table + controls */\n.ntbl-container {\n position: relative;\n margin: 8px 0;\n padding: 24px 0 0 24px;\n}\n\n.ntbl-container .notectl-table-wrapper {\n margin: 0;\n}\n\n.ntbl-container.notectl-table--selected .notectl-table-wrapper {\n outline: 2px solid var(--notectl-primary-fg);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* --- Column Handle Bar --- */\n.ntbl-col-bar {\n position: absolute;\n top: 0;\n left: 24px;\n height: 20px;\n display: flex;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-col-bar,\n.ntbl-container:focus-within .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-col-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Row Handle Bar --- */\n.ntbl-row-bar {\n position: absolute;\n top: 24px;\n left: 0;\n width: 20px;\n display: flex;\n flex-direction: column;\n opacity: 0;\n transition: opacity 0.2s ease;\n z-index: 3;\n pointer-events: none;\n}\n\n.ntbl-container:hover .ntbl-row-bar,\n.ntbl-container:focus-within .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-row-bar {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* --- Handle (shared base) --- */\n.ntbl-handle {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n transition: background 0.15s ease;\n border-radius: 3px;\n}\n\n.ntbl-col-handle {\n height: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 4px 0 0;\n}\n\n.ntbl-col-handle:hover {\n background: var(--notectl-border);\n}\n\n.ntbl-row-handle {\n width: 100%;\n background: var(--notectl-hover-bg);\n border-radius: 4px 0 0 4px;\n}\n\n.ntbl-row-handle:hover {\n background: var(--notectl-border);\n}\n\n/* --- Handle Delete Button --- */\n.ntbl-handle-delete {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n border: none;\n background: transparent;\n color: var(--notectl-fg-muted);\n cursor: pointer;\n border-radius: 3px;\n padding: 0;\n opacity: 0;\n transform: scale(0.7);\n transition: opacity 0.15s, transform 0.15s,\n background 0.15s, color 0.15s;\n}\n\n.ntbl-handle:hover .ntbl-handle-delete,\n.ntbl-handle:focus-within .ntbl-handle-delete {\n opacity: 1;\n transform: scale(1);\n}\n\n.ntbl-handle-delete:hover,\n.ntbl-handle-delete:focus-visible {\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n.ntbl-handle-delete:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n/* --- Insert Lines --- */\n.ntbl-insert-line {\n position: absolute;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: 6;\n}\n\n.ntbl-insert-line--visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ntbl-insert-line--horizontal {\n height: 2px;\n background: linear-gradient(\n 90deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--vertical {\n width: 2px;\n background: linear-gradient(\n 180deg,\n transparent,\n var(--notectl-primary) 8%,\n var(--notectl-primary) 92%,\n transparent\n );\n box-shadow: 0 0 6px var(--notectl-focus-ring);\n}\n\n/* --- Insert Button on Line --- */\n.ntbl-insert-btn {\n position: absolute;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n color: var(--notectl-primary);\n cursor: pointer;\n pointer-events: all;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n box-shadow: 0 2px 8px var(--notectl-focus-ring);\n transition: background 0.15s, color 0.15s,\n transform 0.15s, box-shadow 0.15s;\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn {\n left: 50%;\n top: -9px;\n transform: translateX(-50%);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn {\n top: 50%;\n left: -9px;\n transform: translateY(-50%);\n}\n\n.ntbl-insert-btn:hover,\n.ntbl-insert-btn:focus-visible {\n background: var(--notectl-primary);\n color: var(--notectl-bg);\n box-shadow: 0 2px 12px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-insert-line--horizontal .ntbl-insert-btn:hover {\n transform: translateX(-50%) scale(1.2);\n}\n\n.ntbl-insert-line--vertical .ntbl-insert-btn:hover {\n transform: translateY(-50%) scale(1.2);\n}\n\n/* --- Add Row / Add Column Zones --- */\n.ntbl-add-zone {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.2s ease,\n border-color 0.2s ease;\n}\n\n.ntbl-container:hover .ntbl-add-zone,\n.ntbl-container:focus-within .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-container.notectl-table--selected .ntbl-add-zone {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn {\n position: absolute;\n top: 0;\n left: 0;\n width: 20px;\n height: 20px;\n border: 1px solid var(--notectl-danger);\n border-radius: 4px;\n background: var(--notectl-bg);\n color: var(--notectl-danger);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s ease, background 0.15s, border-color 0.15s;\n z-index: 7;\n}\n\n.ntbl-container:hover .ntbl-delete-table-btn,\n.ntbl-container:focus-within .ntbl-delete-table-btn,\n.ntbl-container.notectl-table--selected .ntbl-delete-table-btn {\n opacity: 1;\n}\n\n.ntbl-delete-table-btn:hover,\n.ntbl-delete-table-btn:focus-visible {\n background: var(--notectl-danger-muted);\n border-color: var(--notectl-danger);\n}\n\n.ntbl-delete-table-btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-row {\n bottom: 0;\n height: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 0 6px 6px;\n border-top: none;\n color: var(--notectl-fg-muted);\n transform: translateY(100%);\n}\n\n.ntbl-add-row:hover,\n.ntbl-add-row:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-row:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-col {\n right: 0;\n top: 24px;\n width: 24px;\n border: 1px dashed var(--notectl-border);\n border-radius: 0 6px 6px 0;\n border-left: none;\n color: var(--notectl-fg-muted);\n transform: translateX(100%);\n}\n\n.ntbl-add-col:hover,\n.ntbl-add-col:focus-visible {\n background: var(--notectl-primary-muted);\n border-color: var(--notectl-primary);\n color: var(--notectl-primary);\n}\n\n.ntbl-add-col:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--notectl-focus-ring);\n}\n\n.ntbl-add-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.2s ease;\n}\n\n.ntbl-add-zone:hover .ntbl-add-icon {\n transform: scale(1.15);\n}\n"), this.context = e2, this.registerNodeSpecs(e2), this.registerNodeViews(e2), C(e2), (function(e3) {
|
|
465
|
-
const n2 = { Tab: () => (function(t2) {
|
|
466
|
-
return L(t2, (e4, n3, o2) => o2.colIndex < o2.totalCols - 1 ? A(t2, o2.tableId, o2.rowIndex, o2.colIndex + 1) : o2.rowIndex < o2.totalRows - 1 ? A(t2, o2.tableId, o2.rowIndex + 1, 0) : (k(t2), true));
|
|
467
|
-
})(e3), "Shift-Tab": () => (function(t2) {
|
|
468
|
-
return L(t2, (e4, n3, o2) => o2.colIndex > 0 ? A(t2, o2.tableId, o2.rowIndex, o2.colIndex - 1) : !(o2.rowIndex > 0) || A(t2, o2.tableId, o2.rowIndex - 1, o2.totalCols - 1));
|
|
469
|
-
})(e3), Enter: () => (function(e4) {
|
|
470
|
-
const n3 = e4.getState();
|
|
471
|
-
if (t(n3.selection)) return false;
|
|
472
|
-
const o2 = n3.getBlock(n3.selection.anchor.blockId);
|
|
473
|
-
if (o2 && "paragraph" !== o2.type) return false;
|
|
474
|
-
const r2 = b(n3, n3.selection.anchor.blockId);
|
|
475
|
-
return !!r2 && (!(r2.rowIndex < r2.totalRows - 1) || A(e4, r2.tableId, r2.rowIndex + 1, r2.colIndex));
|
|
476
|
-
})(e3), Backspace: () => (function(t2) {
|
|
477
|
-
return L(t2, (e4, n3, r2) => {
|
|
478
|
-
if (!o(n3)) return false;
|
|
479
|
-
if (0 !== n3.anchor.offset) return false;
|
|
480
|
-
if (0 !== r2.rowIndex || 0 !== r2.colIndex) return false;
|
|
481
|
-
const i2 = p(e4, r2.cellId);
|
|
482
|
-
return n3.anchor.blockId === i2 && B(t2, r2.tableId);
|
|
483
|
-
});
|
|
484
|
-
})(e3), Delete: () => (function(t2) {
|
|
485
|
-
return L(t2, (e4, n3, r2) => {
|
|
486
|
-
if (!o(n3)) return false;
|
|
487
|
-
const i2 = e4.getBlock(n3.anchor.blockId);
|
|
488
|
-
if (!i2) return false;
|
|
489
|
-
const l2 = a(i2);
|
|
490
|
-
if (n3.anchor.offset !== l2) return false;
|
|
491
|
-
if (r2.rowIndex !== r2.totalRows - 1 || r2.colIndex !== r2.totalCols - 1) return false;
|
|
492
|
-
const s2 = f(e4, r2.cellId);
|
|
493
|
-
return n3.anchor.blockId === s2 && B(t2, r2.tableId);
|
|
494
|
-
});
|
|
495
|
-
})(e3), ArrowDown: () => (function(t2) {
|
|
496
|
-
return L(t2, (e4, n3, o2) => {
|
|
497
|
-
const r2 = f(e4, o2.cellId);
|
|
498
|
-
return n3.anchor.blockId === r2 && (o2.rowIndex >= o2.totalRows - 1 ? R(t2) : A(t2, o2.tableId, o2.rowIndex + 1, o2.colIndex));
|
|
499
|
-
});
|
|
500
|
-
})(e3), ArrowUp: () => (function(t2) {
|
|
501
|
-
return L(t2, (e4, n3, o2) => {
|
|
502
|
-
const r2 = p(e4, o2.cellId);
|
|
503
|
-
return n3.anchor.blockId === r2 && !(o2.rowIndex <= 0) && A(t2, o2.tableId, o2.rowIndex - 1, o2.colIndex);
|
|
504
|
-
});
|
|
505
|
-
})(e3), ArrowRight: () => (function(t2) {
|
|
506
|
-
return L(t2, (e4, n3, r2) => {
|
|
507
|
-
if (!o(n3)) return false;
|
|
508
|
-
const i2 = e4.getBlock(n3.anchor.blockId);
|
|
509
|
-
if (!i2) return false;
|
|
510
|
-
const l2 = a(i2);
|
|
511
|
-
if (n3.anchor.offset !== l2) return false;
|
|
512
|
-
const s2 = f(e4, r2.cellId);
|
|
513
|
-
return n3.anchor.blockId === s2 && (r2.colIndex < r2.totalCols - 1 ? A(t2, r2.tableId, r2.rowIndex, r2.colIndex + 1) : !(r2.rowIndex < r2.totalRows - 1) || A(t2, r2.tableId, r2.rowIndex + 1, 0));
|
|
514
|
-
});
|
|
515
|
-
})(e3), ArrowLeft: () => (function(t2) {
|
|
516
|
-
return L(t2, (e4, n3, r2) => {
|
|
517
|
-
if (!o(n3)) return false;
|
|
518
|
-
if (0 !== n3.anchor.offset) return false;
|
|
519
|
-
const i2 = p(e4, r2.cellId);
|
|
520
|
-
return n3.anchor.blockId === i2 && (r2.colIndex > 0 ? E(t2, r2.tableId, r2.rowIndex, r2.colIndex - 1) : !(r2.rowIndex > 0) || E(t2, r2.tableId, r2.rowIndex - 1, r2.totalCols - 1));
|
|
521
|
-
});
|
|
522
|
-
})(e3), Escape: () => R(e3) };
|
|
523
|
-
e3.registerKeymap(n2);
|
|
524
|
-
})(e2), this.registerToolbarItem(e2), this.selectionService = (function(t2) {
|
|
525
|
-
let e3 = null, n2 = [], o2 = /* @__PURE__ */ new Set();
|
|
526
|
-
const r2 = { getSelectedRange: () => e3, setSelectedRange(r3) {
|
|
527
|
-
e3 = r3, (function() {
|
|
528
|
-
if (!e3) return n2 = [], void (o2 = /* @__PURE__ */ new Set());
|
|
529
|
-
const r4 = t2.getState(), i2 = [], l2 = Math.min(e3.fromRow, e3.toRow), s2 = Math.max(e3.fromRow, e3.toRow), a2 = Math.min(e3.fromCol, e3.toCol), c2 = Math.max(e3.fromCol, e3.toCol);
|
|
530
|
-
for (let t3 = l2; t3 <= s2; t3++) for (let n3 = a2; n3 <= c2; n3++) {
|
|
531
|
-
const o3 = h(r4, e3.tableId, t3, n3);
|
|
532
|
-
o3 && i2.push(o3);
|
|
533
|
-
}
|
|
534
|
-
n2 = i2, o2 = new Set(i2);
|
|
535
|
-
})(), (function(t3, e4) {
|
|
536
|
-
const n3 = t3.getContainer().querySelectorAll("td[data-block-id]");
|
|
537
|
-
for (const t4 of n3) {
|
|
538
|
-
const n4 = t4.getAttribute("data-block-id");
|
|
539
|
-
e4.has(n4) ? t4.classList.add("notectl-table-cell--selected") : t4.classList.remove("notectl-table-cell--selected");
|
|
540
|
-
}
|
|
541
|
-
})(t2, o2);
|
|
542
|
-
}, getSelectedCellIds: () => n2, isSelected: (t3) => o2.has(t3) };
|
|
543
|
-
return t2.registerService(D, r2), r2;
|
|
544
|
-
})(e2);
|
|
545
|
-
}
|
|
546
|
-
onReady() {
|
|
547
|
-
this.context && this.selectionService && (this.cleanupMouseSelection = (function(t2, e2) {
|
|
548
|
-
const n2 = t2.getContainer();
|
|
549
|
-
let o2 = null, r2 = false;
|
|
550
|
-
function i2(n3) {
|
|
551
|
-
const i3 = n3.target.closest("td[data-block-id]");
|
|
552
|
-
if (i3) if (n3.shiftKey) {
|
|
553
|
-
if (o2) {
|
|
554
|
-
const r3 = b(t2.getState(), i3.getAttribute("data-block-id"));
|
|
555
|
-
if (!r3 || r3.tableId !== o2.tableId) return;
|
|
556
|
-
n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: r3.rowIndex, toCol: r3.colIndex });
|
|
557
|
-
}
|
|
558
|
-
} else {
|
|
559
|
-
e2.setSelectedRange(null);
|
|
560
|
-
const n4 = b(t2.getState(), i3.getAttribute("data-block-id"));
|
|
561
|
-
if (!n4) return;
|
|
562
|
-
o2 = { tableId: n4.tableId, row: n4.rowIndex, col: n4.colIndex }, r2 = true;
|
|
563
|
-
}
|
|
564
|
-
else e2.setSelectedRange(null);
|
|
565
|
-
}
|
|
566
|
-
function l2(n3) {
|
|
567
|
-
if (!r2 || !o2) return;
|
|
568
|
-
const i3 = n3.target.closest("td[data-block-id]");
|
|
569
|
-
if (!i3) return;
|
|
570
|
-
const l3 = b(t2.getState(), i3.getAttribute("data-block-id"));
|
|
571
|
-
l3 && l3.tableId === o2.tableId && (l3.rowIndex === o2.row && l3.colIndex === o2.col || (n3.preventDefault(), e2.setSelectedRange({ tableId: o2.tableId, fromRow: o2.row, fromCol: o2.col, toRow: l3.rowIndex, toCol: l3.colIndex })));
|
|
572
|
-
}
|
|
573
|
-
function s2() {
|
|
574
|
-
r2 = false;
|
|
575
|
-
}
|
|
576
|
-
return n2.addEventListener("mousedown", i2), n2.addEventListener("mousemove", l2), document.addEventListener("mouseup", s2), () => {
|
|
577
|
-
n2.removeEventListener("mousedown", i2), n2.removeEventListener("mousemove", l2), document.removeEventListener("mouseup", s2);
|
|
578
|
-
};
|
|
579
|
-
})(this.context, this.selectionService));
|
|
580
|
-
}
|
|
581
|
-
destroy() {
|
|
582
|
-
this.cleanupMouseSelection?.(), this.cleanupMouseSelection = null, this.selectionService = null, this.context = null;
|
|
583
|
-
}
|
|
584
|
-
onStateChange(e2, n2, o2) {
|
|
585
|
-
if (this.selectionService?.getSelectedRange()) {
|
|
586
|
-
const e3 = n2.selection;
|
|
587
|
-
!t(e3) && m(n2, e3.anchor.blockId) || this.selectionService.setSelectedRange(null);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
registerNodeSpecs(t2) {
|
|
591
|
-
t2.registerNodeSpec({ type: "table", group: "block", content: { allow: ["table_row"], min: 1 }, isolating: true, selectable: true, toDOM(t3) {
|
|
592
|
-
const e2 = document.createElement("div");
|
|
593
|
-
return e2.className = "notectl-table-wrapper", e2.setAttribute("data-block-id", t3.id), e2;
|
|
594
|
-
} }), t2.registerNodeSpec({ type: "table_row", group: "table_content", content: { allow: ["table_cell"], min: 1 }, toDOM(t3) {
|
|
595
|
-
const e2 = document.createElement("tr");
|
|
596
|
-
return e2.setAttribute("data-block-id", t3.id), e2.setAttribute("role", "row"), e2;
|
|
597
|
-
} }), t2.registerNodeSpec({ type: "table_cell", group: "table_content", content: { allow: ["paragraph", "list_item", "heading", "blockquote", "image", "horizontal_rule"] }, isolating: true, toDOM(t3) {
|
|
598
|
-
const e2 = document.createElement("td");
|
|
599
|
-
return e2.setAttribute("data-block-id", t3.id), e2.setAttribute("role", "cell"), e2;
|
|
600
|
-
} });
|
|
601
|
-
}
|
|
602
|
-
registerNodeViews(t2) {
|
|
603
|
-
t2.getSchemaRegistry(), t2.registerNodeView("table", (t3, e2, n2) => {
|
|
604
|
-
const o2 = document.createElement("div");
|
|
605
|
-
o2.className = "ntbl-container", o2.setAttribute("data-block-id", t3.id), o2.setAttribute("data-selectable", "true");
|
|
606
|
-
const i2 = document.createElement("div");
|
|
607
|
-
i2.className = "notectl-table-wrapper";
|
|
608
|
-
const l2 = document.createElement("table");
|
|
609
|
-
l2.className = "notectl-table", l2.setAttribute("role", "table");
|
|
610
|
-
const s2 = r(t3), a2 = s2.length, c2 = s2[0] ? r(s2[0]).length : 0;
|
|
611
|
-
l2.setAttribute("aria-label", `Table with ${a2} rows and ${c2} columns`);
|
|
612
|
-
const d2 = document.createElement("tbody");
|
|
613
|
-
l2.appendChild(d2), i2.appendChild(l2), o2.appendChild(i2);
|
|
614
|
-
const u2 = document.createElement("div");
|
|
615
|
-
u2.className = "notectl-sr-only", u2.setAttribute("aria-live", "polite"), u2.setAttribute("aria-atomic", "true"), o2.appendChild(u2);
|
|
616
|
-
const b2 = (function(t4, e3, n3, o3, r2) {
|
|
617
|
-
return new _(t4, e3, n3, o3, r2);
|
|
618
|
-
})(o2, l2, t3, e2, n2);
|
|
619
|
-
return { dom: o2, contentDOM: d2, update(t4) {
|
|
620
|
-
if ("table" !== t4.type) return false;
|
|
621
|
-
o2.setAttribute("data-block-id", t4.id), o2.setAttribute("data-selectable", "true");
|
|
622
|
-
const e3 = r(t4), n3 = e3.length, i3 = e3[0] ? r(e3[0]).length : 0;
|
|
623
|
-
return l2.setAttribute("aria-label", `Table with ${n3} rows and ${i3} columns`), b2.update(t4), false;
|
|
624
|
-
}, destroy() {
|
|
625
|
-
b2.destroy();
|
|
626
|
-
}, selectNode() {
|
|
627
|
-
o2.classList.add("notectl-table--selected");
|
|
628
|
-
}, deselectNode() {
|
|
629
|
-
o2.classList.remove("notectl-table--selected");
|
|
630
|
-
} };
|
|
631
|
-
}), t2.registerNodeView("table_row", (t3, e2, n2) => {
|
|
632
|
-
const o2 = document.createElement("tr");
|
|
633
|
-
return o2.setAttribute("data-block-id", t3.id), o2.setAttribute("role", "row"), { dom: o2, contentDOM: o2, update: (t4) => ("table_row" !== t4.type || o2.setAttribute("data-block-id", t4.id), false), destroy() {
|
|
634
|
-
} };
|
|
635
|
-
}), t2.registerNodeView("table_cell", (t3, e2, n2) => {
|
|
636
|
-
const o2 = document.createElement("td");
|
|
637
|
-
o2.setAttribute("data-block-id", t3.id), o2.setAttribute("role", "cell");
|
|
638
|
-
const r2 = t3.attrs?.colspan ?? 1, i2 = t3.attrs?.rowspan ?? 1;
|
|
639
|
-
r2 > 1 && (o2.colSpan = r2), i2 > 1 && (o2.rowSpan = i2);
|
|
640
|
-
const l2 = t3.attrs?.align;
|
|
641
|
-
return l2 && "left" !== l2 && (o2.style.textAlign = l2), { dom: o2, contentDOM: o2, update(t4) {
|
|
642
|
-
if ("table_cell" !== t4.type) return false;
|
|
643
|
-
o2.setAttribute("data-block-id", t4.id);
|
|
644
|
-
const e3 = t4.attrs?.colspan ?? 1, n3 = t4.attrs?.rowspan ?? 1;
|
|
645
|
-
return e3 > 1 ? o2.colSpan = e3 : o2.removeAttribute("colspan"), n3 > 1 ? o2.rowSpan = n3 : o2.removeAttribute("rowspan"), false;
|
|
646
|
-
}, destroy() {
|
|
647
|
-
} };
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
registerToolbarItem(e2) {
|
|
651
|
-
const n2 = this.config.maxPickerRows ?? 8, o2 = this.config.maxPickerCols ?? 8;
|
|
652
|
-
e2.registerToolbarItem({ id: "table", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 3h18v18H3V3zm2 2v4h6V5H5zm8 0v4h6V5h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6zm-8 6v4h6v-4H5zm8 0v4h6v-4h-6z"/></svg>', label: "Insert Table", tooltip: "Insert Table", command: "insertTable", priority: 80, separatorAfter: this.config.separatorAfter, popupType: "gridPicker", popupConfig: { maxRows: n2, maxCols: o2, onSelect: (t2, n3) => {
|
|
653
|
-
y(e2, t2, n3);
|
|
654
|
-
} }, isActive: (e3) => !t(e3.selection) && m(e3, e3.selection.anchor.blockId) });
|
|
655
|
-
}
|
|
656
|
-
}
|
|
1
|
+
import { B, a, b, c, d, e, f, g, h, i, j, m, k, n, l, r, s } from "../chunks/index-BSFLNveF.mjs";
|
|
657
2
|
export {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
b as
|
|
661
|
-
|
|
3
|
+
B as BORDER_COLOR_PALETTE,
|
|
4
|
+
a as TABLE_LOCALE_AR,
|
|
5
|
+
b as TABLE_LOCALE_DE,
|
|
6
|
+
c as TABLE_LOCALE_EN,
|
|
7
|
+
d as TABLE_LOCALE_ES,
|
|
8
|
+
e as TABLE_LOCALE_FR,
|
|
9
|
+
f as TABLE_LOCALE_HI,
|
|
10
|
+
g as TABLE_LOCALE_RU,
|
|
11
|
+
h as TABLE_LOCALE_ZH,
|
|
12
|
+
i as TablePlugin,
|
|
13
|
+
j as TableSelectionServiceKey,
|
|
14
|
+
m as createTableContextMenu,
|
|
15
|
+
k as findTableContext,
|
|
16
|
+
n as getTableBorderColor,
|
|
17
|
+
l as isInsideTable,
|
|
18
|
+
r as resetTableBorderColor,
|
|
19
|
+
s as setTableBorderColor
|
|
662
20
|
};
|
|
663
21
|
//# sourceMappingURL=table.mjs.map
|