@clevertask/scribe 0.1.27 → 0.1.28
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 +4 -2
- package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +145 -132
- package/dist/components/Menu/TableHeightSettings.d.ts +11 -0
- package/dist/components/Menu/TableHeightSettings.d.ts.map +1 -0
- package/dist/components/Menu/TableHeightSettings.js +156 -0
- package/dist/components/Menu/TableLayoutOptions.d.ts +5 -0
- package/dist/components/Menu/TableLayoutOptions.d.ts.map +1 -1
- package/dist/components/Menu/TableLayoutOptions.js +56 -39
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.d.ts +1 -0
- package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +63 -42
- package/dist/components/Scribe/extension/table-layout.d.ts +5 -0
- package/dist/components/Scribe/extension/table-layout.d.ts.map +1 -1
- package/dist/components/Scribe/extension/table-layout.js +2 -2
- package/dist/components/Scribe/index.js +2 -2
- package/dist/document-node-capabilities.d.ts.map +1 -1
- package/dist/document-node-capabilities.js +5 -1
- package/dist/{extension-CBOxOV0e.js → extension-BU2USLV1.js} +1 -1
- package/dist/{html-to-markdown-DZ83bZ9I.js → html-to-markdown-DF93it73.js} +1 -1
- package/dist/main.css +2 -1
- package/dist/main.js +1 -1
- package/dist/{schema-extensions-BXyGPwMf.js → schema-extensions-DyCk1Goa.js} +1 -1
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/{table-layout-B3sPDpEF.js → table-layout-BoDS50DR.js} +91 -83
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -223,13 +223,15 @@ Type `/table` to insert a 3 × 3 table with a header row. Selecting a table cell
|
|
|
223
223
|
|
|
224
224
|
The **Table layout** menu stores each table's explicit layout choice. **Auto** keeps the existing sizing behavior. **Fit to width** wraps the table into the available editor width and temporarily disables column resizing. **Scroll horizontally** retains authored column widths, gives columns without a saved width a readable 128px minimum, and scrolls inside the editor when the table needs more room. Switching layouts retains the table's saved column widths.
|
|
225
225
|
|
|
226
|
-
**Limit height**
|
|
226
|
+
**Limit height** caps the table and enables vertical scrolling; shorter tables stay compact. In **Table layout → Maximum height…**, enter a whole number from 120 to 2000 pixels and choose **Apply** to set that table's maximum. **Use default** clears its override and uses the host's `--scribe-table-max-height`, with a 360px fallback. Turning **Limit height** off retains the saved maximum for when it is enabled again. Changing the maximum leaves the limit toggle, width layout, and sticky header preference unchanged.
|
|
227
|
+
|
|
228
|
+
Layout and height choices apply in both editing and read-only views, and remain intact when content is saved and loaded as JSON, HTML, or Markdown. Hosts can use `editor.commands.setTableLayout("scroll")` (accepts `"auto"`, `"fit"`, or `"scroll"`), `editor.commands.setTableHeightLimit(true)` (accepts a boolean), and `editor.commands.setTableMaxHeight(600)` (accepts a whole number from 120 to 2000, or `null` to restore the default) while the selection is inside an editable table. The optional `maxHeight` table attribute is serialized as `data-table-max-height` in HTML; existing tables without it keep the host default.
|
|
227
229
|
|
|
228
230
|
**Sticky header row** keeps the first row visible while scrolling, independently of **Limit height**. New tables created with `/table` or `insertTable` start with it enabled when their entire first row contains header cells. Existing and imported tables retain their saved setting; tables without a saved sticky preference stay off. Toggle it in **Table layout**. With **Limit height** on, the header stays at the top of the table's own scroll area. With it off, the header follows the document's vertical scroll area until the table ends. This also works with horizontal scrolling and retains saved column widths. The preference stays saved if the header row is removed and becomes active again when it is restored. It works in editing and read-only views. Hosts can use `editor.commands.setTableStickyHeaderRow(true)` to enable it or `false` to clear it while the selection is inside an editable table. For document scrolling, set `--scribe-table-sticky-header-offset` on the editor's container to leave room above the header for a document toolbar; the default is `0px`.
|
|
229
231
|
|
|
230
232
|
Keyboard users can press `Alt + F10` while editing a table to focus its controls, use the arrow, Home, and End keys to move between actions, and press Escape to return to the active cell.
|
|
231
233
|
|
|
232
|
-
Simple headed tables without layout, height, or sticky-header preferences serialize as GFM Markdown. Tables with those preferences (including an inactive sticky preference), merged cells, multiple blocks in a cell, resized columns, or other structures that GFM cannot represent are kept as sanitized raw HTML inside the Markdown output so their structure is not silently lost.
|
|
234
|
+
Simple headed tables without layout, height, or sticky-header preferences serialize as GFM Markdown. Tables with those preferences (including a saved maximum while **Limit height** is off or an inactive sticky preference), merged cells, multiple blocks in a cell, resized columns, or other structures that GFM cannot represent are kept as sanitized raw HTML inside the Markdown output so their structure is not silently lost.
|
|
233
235
|
|
|
234
236
|
Scribe's `insertTable` command and `/table` action do not create a table while the selection is
|
|
235
237
|
already inside another table. Existing documents containing nested tables remain loadable so old
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EACL,EAAE,EAQH,MAAM,OAAO,CAAC;AAQf,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"TableBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EACL,EAAE,EAQH,MAAM,OAAO,CAAC;AAQf,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAwJD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA4Y7C,CAAC;eAEa,eAAe"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as
|
|
3
|
-
import { getPopupMountTarget as
|
|
4
|
-
import { t as
|
|
5
|
-
import { getSelectionTableContext as
|
|
6
|
-
import { getSelectionContextualMenuOwner as
|
|
7
|
-
import
|
|
8
|
-
import { Flex as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { Fragment as
|
|
1
|
+
import { c as e, u as t } from "../../table-layout-BoDS50DR.js";
|
|
2
|
+
import { s as n } from "../../dist-BiognBi4.js";
|
|
3
|
+
import { getPopupMountTarget as r } from "../Scribe/extension/getPopupMountTarget.js";
|
|
4
|
+
import { t as i } from "../../menus-BDXjZsFU.js";
|
|
5
|
+
import { getSelectionTableContext as a, tableBubbleMenuPluginKey as o } from "./tableBubbleMenuPlugin.js";
|
|
6
|
+
import { getSelectionContextualMenuOwner as s } from "./contextualMenuOwner.js";
|
|
7
|
+
import c from "./TableLayoutOptions.js";
|
|
8
|
+
import { Flex as l, IconButton as u, Separator as d } from "@radix-ui/themes";
|
|
9
|
+
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
10
|
+
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
11
11
|
//#region lib/components/Menu/TableBubbleMenu.tsx
|
|
12
|
-
var
|
|
12
|
+
var b = [
|
|
13
13
|
"addColumnAfter",
|
|
14
14
|
"addColumnBefore",
|
|
15
15
|
"addRowAfter",
|
|
@@ -18,7 +18,7 @@ var y = [
|
|
|
18
18
|
"deleteRow",
|
|
19
19
|
"deleteTable",
|
|
20
20
|
"toggleHeaderRow"
|
|
21
|
-
],
|
|
21
|
+
], x = {
|
|
22
22
|
canAddColumnAfter: !1,
|
|
23
23
|
canAddColumnBefore: !1,
|
|
24
24
|
canAddRowAfter: !1,
|
|
@@ -30,20 +30,22 @@ var y = [
|
|
|
30
30
|
hasHeaderRow: !1,
|
|
31
31
|
canSetTableLayout: !1,
|
|
32
32
|
canSetTableHeightLimit: !1,
|
|
33
|
+
canSetTableMaxHeight: !1,
|
|
33
34
|
canSetTableStickyHeaderRow: !1,
|
|
34
35
|
tableLayout: "auto",
|
|
35
36
|
limitHeight: !1,
|
|
37
|
+
maxHeight: null,
|
|
36
38
|
stickyHeaderRow: !1
|
|
37
|
-
},
|
|
39
|
+
}, S = /auto|overlay|scroll/, C = (e) => {
|
|
38
40
|
let t = e.ownerDocument.defaultView;
|
|
39
41
|
if (!t) return [];
|
|
40
42
|
let n = [], r = e.parentElement;
|
|
41
43
|
for (; r && r !== e.ownerDocument.body && r !== e.ownerDocument.documentElement;) {
|
|
42
44
|
let e = t.getComputedStyle(r);
|
|
43
|
-
|
|
45
|
+
S.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
|
|
44
46
|
}
|
|
45
47
|
return n;
|
|
46
|
-
},
|
|
48
|
+
}, w = ({ name: e }) => {
|
|
47
49
|
let t = {
|
|
48
50
|
"aria-hidden": !0,
|
|
49
51
|
fill: "none",
|
|
@@ -58,12 +60,12 @@ var y = [
|
|
|
58
60
|
};
|
|
59
61
|
if (e === "add-row-above" || e === "add-row-below") {
|
|
60
62
|
let r = e === "add-row-above" ? 3.5 : 16.5;
|
|
61
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ y("svg", {
|
|
62
64
|
...t,
|
|
63
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ v("path", {
|
|
64
66
|
d: "M3.5 6.5h13v7h-13zM3.5 10h13M10 6.5v7",
|
|
65
67
|
...n
|
|
66
|
-
}), /* @__PURE__ */
|
|
68
|
+
}), /* @__PURE__ */ v("path", {
|
|
67
69
|
d: `M7.75 ${r}h4.5M10 ${r - 2.25}v4.5`,
|
|
68
70
|
...n
|
|
69
71
|
})]
|
|
@@ -71,98 +73,104 @@ var y = [
|
|
|
71
73
|
}
|
|
72
74
|
if (e === "add-column-before" || e === "add-column-after") {
|
|
73
75
|
let r = e === "add-column-before" ? 3.5 : 16.5;
|
|
74
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ y("svg", {
|
|
75
77
|
...t,
|
|
76
|
-
children: [/* @__PURE__ */
|
|
78
|
+
children: [/* @__PURE__ */ v("path", {
|
|
77
79
|
d: "M6.5 3.5h7v13h-7zM10 3.5v13M6.5 10h7",
|
|
78
80
|
...n
|
|
79
|
-
}), /* @__PURE__ */
|
|
81
|
+
}), /* @__PURE__ */ v("path", {
|
|
80
82
|
d: `M${r - 2.25} 10h4.5M${r} 7.75v4.5`,
|
|
81
83
|
...n
|
|
82
84
|
})]
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
|
-
return e === "delete-row" ? /* @__PURE__ */
|
|
87
|
+
return e === "delete-row" ? /* @__PURE__ */ y("svg", {
|
|
86
88
|
...t,
|
|
87
|
-
children: [/* @__PURE__ */
|
|
89
|
+
children: [/* @__PURE__ */ v("path", {
|
|
88
90
|
d: "M3.5 4h13v12h-13zM3.5 8h13M3.5 12h13M10 4v12",
|
|
89
91
|
...n
|
|
90
|
-
}), /* @__PURE__ */
|
|
92
|
+
}), /* @__PURE__ */ v("path", {
|
|
91
93
|
d: "M6.75 10h6.5",
|
|
92
94
|
stroke: "currentColor",
|
|
93
95
|
strokeWidth: "2.2"
|
|
94
96
|
})]
|
|
95
|
-
}) : e === "delete-column" ? /* @__PURE__ */
|
|
97
|
+
}) : e === "delete-column" ? /* @__PURE__ */ y("svg", {
|
|
96
98
|
...t,
|
|
97
|
-
children: [/* @__PURE__ */
|
|
99
|
+
children: [/* @__PURE__ */ v("path", {
|
|
98
100
|
d: "M4 3.5h12v13h-12zM8 3.5v13M12 3.5v13M4 10h12",
|
|
99
101
|
...n
|
|
100
|
-
}), /* @__PURE__ */
|
|
102
|
+
}), /* @__PURE__ */ v("path", {
|
|
101
103
|
d: "M10 6.75v6.5",
|
|
102
104
|
stroke: "currentColor",
|
|
103
105
|
strokeWidth: "2.2"
|
|
104
106
|
})]
|
|
105
|
-
}) : e === "toggle-header-row" ? /* @__PURE__ */
|
|
107
|
+
}) : e === "toggle-header-row" ? /* @__PURE__ */ y("svg", {
|
|
106
108
|
...t,
|
|
107
|
-
children: [/* @__PURE__ */
|
|
109
|
+
children: [/* @__PURE__ */ v("path", {
|
|
108
110
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
109
111
|
...n
|
|
110
|
-
}), /* @__PURE__ */
|
|
112
|
+
}), /* @__PURE__ */ v("path", {
|
|
111
113
|
d: "M4.2 4.7h11.6v2.6H4.2z",
|
|
112
114
|
fill: "currentColor",
|
|
113
115
|
opacity: "0.45"
|
|
114
116
|
})]
|
|
115
|
-
}) : /* @__PURE__ */
|
|
117
|
+
}) : /* @__PURE__ */ y("svg", {
|
|
116
118
|
...t,
|
|
117
|
-
children: [/* @__PURE__ */
|
|
119
|
+
children: [/* @__PURE__ */ v("path", {
|
|
118
120
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
119
121
|
...n
|
|
120
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ v("path", {
|
|
121
123
|
d: "m6.75 7 6.5 6.5m0-6.5-6.5 6.5",
|
|
122
124
|
stroke: "currentColor",
|
|
123
125
|
strokeWidth: "1.8"
|
|
124
126
|
})]
|
|
125
127
|
});
|
|
126
|
-
},
|
|
127
|
-
let
|
|
128
|
-
editor:
|
|
129
|
-
selector: ({ editor:
|
|
130
|
-
if (!
|
|
131
|
-
let
|
|
128
|
+
}, T = ({ editor: S }) => {
|
|
129
|
+
let T = h(null), [E, D] = g(null), [O, k] = g(!1), [A, j] = g(!1), M = m(() => b.every((e) => typeof S.commands[e] == "function"), [S]), N = m(() => typeof S.commands.setTableLayout == "function" && typeof S.commands.setTableHeightLimit == "function", [S]), P = m(() => typeof S.commands.setTableStickyHeaderRow == "function", [S]), F = m(() => typeof S.commands.setTableMaxHeight == "function", [S]), I = n({
|
|
130
|
+
editor: S,
|
|
131
|
+
selector: ({ editor: n }) => {
|
|
132
|
+
if (!M || n.isDestroyed) return x;
|
|
133
|
+
let r = a(n.state), i = n.can(), o = r ? t(r.node) : !1, s = r?.node.attrs.limitHeight === !0, c = r?.node.attrs.stickyHeaderRow === !0;
|
|
132
134
|
return {
|
|
133
|
-
canAddColumnAfter:
|
|
134
|
-
canAddColumnBefore:
|
|
135
|
-
canAddRowAfter:
|
|
136
|
-
canAddRowBefore:
|
|
137
|
-
canDeleteColumn:
|
|
138
|
-
canDeleteRow:
|
|
139
|
-
canDeleteTable:
|
|
140
|
-
canToggleHeaderRow:
|
|
141
|
-
hasHeaderRow:
|
|
142
|
-
canSetTableLayout:
|
|
143
|
-
canSetTableHeightLimit:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
canAddColumnAfter: i.addColumnAfter(),
|
|
136
|
+
canAddColumnBefore: i.addColumnBefore(),
|
|
137
|
+
canAddRowAfter: i.addRowAfter(),
|
|
138
|
+
canAddRowBefore: i.addRowBefore(),
|
|
139
|
+
canDeleteColumn: i.deleteColumn(),
|
|
140
|
+
canDeleteRow: i.deleteRow(),
|
|
141
|
+
canDeleteTable: i.deleteTable(),
|
|
142
|
+
canToggleHeaderRow: i.toggleHeaderRow(),
|
|
143
|
+
hasHeaderRow: o,
|
|
144
|
+
canSetTableLayout: N && i.setTableLayout("auto"),
|
|
145
|
+
canSetTableHeightLimit: N && i.setTableHeightLimit(!0),
|
|
146
|
+
canSetTableMaxHeight: n.isEditable && F && i.setTableMaxHeight(null),
|
|
147
|
+
canSetTableStickyHeaderRow: n.isEditable && P && o && i.setTableStickyHeaderRow(!c),
|
|
148
|
+
tableLayout: r?.node.attrs.tableLayout ?? "auto",
|
|
149
|
+
limitHeight: s,
|
|
150
|
+
maxHeight: e(r?.node.attrs.maxHeight),
|
|
151
|
+
stickyHeaderRow: c
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
|
-
}),
|
|
151
|
-
let i =
|
|
152
|
-
return
|
|
153
|
-
}, [
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
}), L = f(({ editor: e, element: t, state: n, view: r }) => {
|
|
155
|
+
let i = O || A || r.hasFocus() || t.contains(t.ownerDocument.activeElement);
|
|
156
|
+
return M && e.isEditable && i && s(n) === "table";
|
|
157
|
+
}, [
|
|
158
|
+
M,
|
|
159
|
+
O,
|
|
160
|
+
A
|
|
161
|
+
]), R = f(() => {
|
|
162
|
+
if (S.isDestroyed) return null;
|
|
163
|
+
let e = a(S.state);
|
|
156
164
|
if (!e) return null;
|
|
157
|
-
let t =
|
|
165
|
+
let t = S.view.nodeDOM(e.position);
|
|
158
166
|
return t instanceof HTMLElement ? t.closest(".tableWrapper") ?? t.querySelector(".tableWrapper") ?? t : null;
|
|
159
|
-
}, [
|
|
160
|
-
|
|
161
|
-
let e =
|
|
167
|
+
}, [S]), z = f(() => r(S), [S]);
|
|
168
|
+
p(() => {
|
|
169
|
+
let e = S.view.dom.ownerDocument.defaultView;
|
|
162
170
|
if (!e) return;
|
|
163
|
-
let t = S
|
|
171
|
+
let t = C(S.view.dom), n = null, r = () => {
|
|
164
172
|
n === null && (n = e.requestAnimationFrame(() => {
|
|
165
|
-
n = null,
|
|
173
|
+
n = null, S.isDestroyed || S.view.dispatch(S.state.tr.setMeta(o, "updatePosition"));
|
|
166
174
|
}));
|
|
167
175
|
};
|
|
168
176
|
return t.forEach((e) => {
|
|
@@ -172,27 +180,27 @@ var y = [
|
|
|
172
180
|
e.removeEventListener("scroll", r);
|
|
173
181
|
});
|
|
174
182
|
};
|
|
175
|
-
}, [
|
|
176
|
-
let e =
|
|
183
|
+
}, [S]), p(() => {
|
|
184
|
+
let e = S.view.dom.closest("[data-scribe-root]"), t = S.view.dom.ownerDocument.defaultView;
|
|
177
185
|
if (!e || !t) return;
|
|
178
186
|
let n = () => {
|
|
179
187
|
let t = e.getBoundingClientRect().width;
|
|
180
|
-
|
|
188
|
+
D(t > 0 ? Math.max(t - 16, 0) : null);
|
|
181
189
|
};
|
|
182
190
|
if (n(), !t.ResizeObserver) return;
|
|
183
191
|
let r = new t.ResizeObserver(n);
|
|
184
192
|
return r.observe(e), () => r.disconnect();
|
|
185
|
-
}, [
|
|
186
|
-
let e =
|
|
187
|
-
if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !
|
|
188
|
-
let t =
|
|
193
|
+
}, [S]), p(() => {
|
|
194
|
+
let e = S.view.dom, t = (e) => {
|
|
195
|
+
if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !S.isEditable || s(S.state) !== "table") return;
|
|
196
|
+
let t = T.current?.querySelector("button:not(:disabled)");
|
|
189
197
|
t && (e.preventDefault(), t.focus());
|
|
190
198
|
};
|
|
191
199
|
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
192
|
-
}, [
|
|
193
|
-
let
|
|
200
|
+
}, [S]);
|
|
201
|
+
let B = f((e) => {
|
|
194
202
|
if (e.key === "Escape") {
|
|
195
|
-
e.preventDefault(),
|
|
203
|
+
e.preventDefault(), S.chain().focus().run();
|
|
196
204
|
return;
|
|
197
205
|
}
|
|
198
206
|
if (![
|
|
@@ -205,113 +213,118 @@ var y = [
|
|
|
205
213
|
if (t.length === 0) return;
|
|
206
214
|
let n = e.currentTarget.ownerDocument.activeElement, r = t.findIndex((e) => e === n), i = r;
|
|
207
215
|
i = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowLeft" ? r <= 0 ? t.length - 1 : r - 1 : r < 0 || r === t.length - 1 ? 0 : r + 1, e.preventDefault(), t[i]?.focus();
|
|
208
|
-
}, [
|
|
216
|
+
}, [S]), V = m(() => ({
|
|
209
217
|
strategy: "fixed",
|
|
210
218
|
placement: "top-start",
|
|
211
219
|
offset: 8,
|
|
212
220
|
flip: {},
|
|
213
221
|
shift: { padding: 8 }
|
|
214
|
-
}), []),
|
|
222
|
+
}), []), H = m(() => [
|
|
215
223
|
[
|
|
216
224
|
{
|
|
217
225
|
label: "Add row above",
|
|
218
|
-
command: () =>
|
|
219
|
-
disabled: !
|
|
220
|
-
icon: /* @__PURE__ */
|
|
226
|
+
command: () => S.chain().focus().addRowBefore().run(),
|
|
227
|
+
disabled: !I.canAddRowBefore,
|
|
228
|
+
icon: /* @__PURE__ */ v(w, { name: "add-row-above" })
|
|
221
229
|
},
|
|
222
230
|
{
|
|
223
231
|
label: "Add row below",
|
|
224
|
-
command: () =>
|
|
225
|
-
disabled: !
|
|
226
|
-
icon: /* @__PURE__ */
|
|
232
|
+
command: () => S.chain().focus().addRowAfter().run(),
|
|
233
|
+
disabled: !I.canAddRowAfter,
|
|
234
|
+
icon: /* @__PURE__ */ v(w, { name: "add-row-below" })
|
|
227
235
|
},
|
|
228
236
|
{
|
|
229
237
|
label: "Delete row",
|
|
230
|
-
command: () =>
|
|
231
|
-
disabled: !
|
|
232
|
-
icon: /* @__PURE__ */
|
|
238
|
+
command: () => S.chain().focus().deleteRow().run(),
|
|
239
|
+
disabled: !I.canDeleteRow,
|
|
240
|
+
icon: /* @__PURE__ */ v(w, { name: "delete-row" })
|
|
233
241
|
}
|
|
234
242
|
],
|
|
235
243
|
[
|
|
236
244
|
{
|
|
237
245
|
label: "Add column before",
|
|
238
|
-
command: () =>
|
|
239
|
-
disabled: !
|
|
240
|
-
icon: /* @__PURE__ */
|
|
246
|
+
command: () => S.chain().focus().addColumnBefore().run(),
|
|
247
|
+
disabled: !I.canAddColumnBefore,
|
|
248
|
+
icon: /* @__PURE__ */ v(w, { name: "add-column-before" })
|
|
241
249
|
},
|
|
242
250
|
{
|
|
243
251
|
label: "Add column after",
|
|
244
|
-
command: () =>
|
|
245
|
-
disabled: !
|
|
246
|
-
icon: /* @__PURE__ */
|
|
252
|
+
command: () => S.chain().focus().addColumnAfter().run(),
|
|
253
|
+
disabled: !I.canAddColumnAfter,
|
|
254
|
+
icon: /* @__PURE__ */ v(w, { name: "add-column-after" })
|
|
247
255
|
},
|
|
248
256
|
{
|
|
249
257
|
label: "Delete column",
|
|
250
|
-
command: () =>
|
|
251
|
-
disabled: !
|
|
252
|
-
icon: /* @__PURE__ */
|
|
258
|
+
command: () => S.chain().focus().deleteColumn().run(),
|
|
259
|
+
disabled: !I.canDeleteColumn,
|
|
260
|
+
icon: /* @__PURE__ */ v(w, { name: "delete-column" })
|
|
253
261
|
}
|
|
254
262
|
],
|
|
255
263
|
[{
|
|
256
264
|
label: "Toggle header row",
|
|
257
|
-
command: () =>
|
|
258
|
-
disabled: !
|
|
259
|
-
icon: /* @__PURE__ */
|
|
260
|
-
ariaPressed:
|
|
265
|
+
command: () => S.chain().focus().toggleHeaderRow().run(),
|
|
266
|
+
disabled: !I.canToggleHeaderRow,
|
|
267
|
+
icon: /* @__PURE__ */ v(w, { name: "toggle-header-row" }),
|
|
268
|
+
ariaPressed: I.hasHeaderRow
|
|
261
269
|
}],
|
|
262
270
|
[{
|
|
263
271
|
label: "Delete table",
|
|
264
|
-
command: () =>
|
|
265
|
-
disabled: !
|
|
266
|
-
icon: /* @__PURE__ */
|
|
272
|
+
command: () => S.chain().focus().deleteTable().run(),
|
|
273
|
+
disabled: !I.canDeleteTable,
|
|
274
|
+
icon: /* @__PURE__ */ v(w, { name: "delete-table" })
|
|
267
275
|
}]
|
|
268
|
-
], [
|
|
269
|
-
return /* @__PURE__ */
|
|
270
|
-
editor:
|
|
271
|
-
pluginKey:
|
|
276
|
+
], [S, I]);
|
|
277
|
+
return /* @__PURE__ */ v(i, {
|
|
278
|
+
editor: S,
|
|
279
|
+
pluginKey: o,
|
|
272
280
|
updateDelay: 0,
|
|
273
281
|
resizeDelay: 0,
|
|
274
|
-
appendTo:
|
|
275
|
-
shouldShow:
|
|
276
|
-
getReferencedVirtualElement:
|
|
277
|
-
options:
|
|
278
|
-
children: /* @__PURE__ */
|
|
279
|
-
ref:
|
|
282
|
+
appendTo: z,
|
|
283
|
+
shouldShow: L,
|
|
284
|
+
getReferencedVirtualElement: R,
|
|
285
|
+
options: V,
|
|
286
|
+
children: /* @__PURE__ */ v(l, {
|
|
287
|
+
ref: T,
|
|
280
288
|
className: "scribe-table-bubble-menu",
|
|
281
289
|
role: "toolbar",
|
|
282
290
|
"aria-label": "Table controls",
|
|
283
291
|
"aria-keyshortcuts": "Alt+F10",
|
|
284
292
|
align: "center",
|
|
285
293
|
gap: "2",
|
|
286
|
-
onKeyDown:
|
|
287
|
-
style:
|
|
288
|
-
children:
|
|
294
|
+
onKeyDown: B,
|
|
295
|
+
style: E === null ? void 0 : { maxWidth: E },
|
|
296
|
+
children: H.map((e, t) => /* @__PURE__ */ y(l, {
|
|
289
297
|
align: "center",
|
|
290
298
|
gap: "1",
|
|
291
299
|
children: [
|
|
292
|
-
t > 0 ? /* @__PURE__ */
|
|
300
|
+
t > 0 ? /* @__PURE__ */ v(d, {
|
|
293
301
|
orientation: "vertical",
|
|
294
302
|
decorative: !0,
|
|
295
303
|
style: { height: 20 }
|
|
296
304
|
}) : null,
|
|
297
|
-
t ===
|
|
298
|
-
editor:
|
|
299
|
-
layout:
|
|
300
|
-
limitHeight:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
305
|
+
t === H.length - 1 && N ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(c, {
|
|
306
|
+
editor: S,
|
|
307
|
+
layout: I.tableLayout,
|
|
308
|
+
limitHeight: I.limitHeight,
|
|
309
|
+
maxHeight: I.maxHeight,
|
|
310
|
+
stickyHeaderRow: I.stickyHeaderRow,
|
|
311
|
+
hasHeaderRow: I.hasHeaderRow,
|
|
312
|
+
canSetLayout: I.canSetTableLayout,
|
|
313
|
+
canSetHeightLimit: I.canSetTableHeightLimit,
|
|
314
|
+
hasMaxHeightCommand: F,
|
|
315
|
+
canSetMaxHeight: I.canSetTableMaxHeight,
|
|
316
|
+
hasStickyHeaderCommand: P,
|
|
317
|
+
canSetStickyHeaderRow: I.canSetTableStickyHeaderRow,
|
|
318
|
+
open: O,
|
|
319
|
+
onOpenChange: k,
|
|
320
|
+
heightSettingsOpen: A,
|
|
321
|
+
onHeightSettingsOpenChange: j
|
|
322
|
+
}), /* @__PURE__ */ v(d, {
|
|
310
323
|
orientation: "vertical",
|
|
311
324
|
decorative: !0,
|
|
312
325
|
style: { height: 20 }
|
|
313
326
|
})] }) : null,
|
|
314
|
-
e.map((e) => /* @__PURE__ */
|
|
327
|
+
e.map((e) => /* @__PURE__ */ v(u, {
|
|
315
328
|
type: "button",
|
|
316
329
|
size: "1",
|
|
317
330
|
radius: "medium",
|
|
@@ -330,4 +343,4 @@ var y = [
|
|
|
330
343
|
});
|
|
331
344
|
};
|
|
332
345
|
//#endregion
|
|
333
|
-
export {
|
|
346
|
+
export { T as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
interface TableHeightSettingsProps {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
maxHeight: number | null;
|
|
6
|
+
canSetMaxHeight: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const TableHeightSettings: FC<TableHeightSettingsProps>;
|
|
10
|
+
export default TableHeightSettings;
|
|
11
|
+
//# sourceMappingURL=TableHeightSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHeightSettings.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableHeightSettings.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,EAAE,EAA+C,MAAM,OAAO,CAAC;AASxE,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAqNrD,CAAC;eAEa,mBAAmB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { c as e, n as t } from "../../table-layout-BoDS50DR.js";
|
|
2
|
+
import { getPopupMountTarget as n } from "../Scribe/extension/getPopupMountTarget.js";
|
|
3
|
+
import { getSelectionTableContext as r } from "./tableBubbleMenuPlugin.js";
|
|
4
|
+
import { NodeSelection as i } from "@tiptap/pm/state";
|
|
5
|
+
import { Button as a, Dialog as o, Flex as s, Text as c, TextField as l } from "@radix-ui/themes";
|
|
6
|
+
import { useEffect as u, useId as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
7
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
//#region lib/components/Menu/TableHeightSettings.tsx
|
|
9
|
+
var _ = ({ editor: _, maxHeight: v, canSetMaxHeight: y, onClose: b }) => {
|
|
10
|
+
let [x, S] = m(() => v === null ? "" : String(v)), [C, w] = m(null), T = p(null), E = f(() => n(_), [_]), D = p(_.state.selection.getBookmark()), O = r(_.state)?.position ?? null, k = p(O), A = p(O === null ? null : O + 2), j = p(!0), M = p(_.state.selection instanceof i && _.state.selection.node.type.name === "table"), N = p(!0), P = d(), F = d(), I = d(), L = () => !j.current || _.isDestroyed || !_.isEditable ? !1 : r(_.state)?.position === k.current && D.current.resolve(_.state.doc).eq(_.state.selection);
|
|
11
|
+
u(() => {
|
|
12
|
+
let e = () => {
|
|
13
|
+
j.current = !1, N.current = !1, b();
|
|
14
|
+
}, t = () => {
|
|
15
|
+
_.isEditable || e();
|
|
16
|
+
}, n = ({ transaction: t }) => {
|
|
17
|
+
if (D.current = D.current.map(t.mapping), k.current !== null && (k.current = t.mapping.map(k.current)), A.current !== null) {
|
|
18
|
+
let n = t.mapping.mapResult(A.current);
|
|
19
|
+
if (A.current = n.pos, n.deleted) {
|
|
20
|
+
e();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
M.current && _.state.selection instanceof i && _.state.selection.from === k.current && (D.current = _.state.selection.getBookmark()), (!_.isEditable || r(_.state)?.position !== k.current || !D.current.resolve(_.state.doc).eq(_.state.selection)) && e();
|
|
25
|
+
};
|
|
26
|
+
return _.on("transaction", n), _.on("update", t), _.on("destroy", e), () => {
|
|
27
|
+
_.off("transaction", n), _.off("update", t), _.off("destroy", e);
|
|
28
|
+
};
|
|
29
|
+
}, [_, b]);
|
|
30
|
+
let R = (e) => {
|
|
31
|
+
if (!L()) {
|
|
32
|
+
N.current = !1, b();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
y && _.commands.setTableMaxHeight(e) && (D.current = _.state.selection.getBookmark(), N.current = !0, b());
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ h(o.Root, {
|
|
38
|
+
open: !0,
|
|
39
|
+
onOpenChange: (e) => !e && b(),
|
|
40
|
+
children: /* @__PURE__ */ g(o.Content, {
|
|
41
|
+
container: E,
|
|
42
|
+
size: "2",
|
|
43
|
+
style: {
|
|
44
|
+
width: "calc(100vw - 32px)",
|
|
45
|
+
maxWidth: 360
|
|
46
|
+
},
|
|
47
|
+
onOpenAutoFocus: (e) => {
|
|
48
|
+
e.preventDefault(), L() ? (T.current?.focus(), T.current?.select()) : (N.current = !1, b());
|
|
49
|
+
},
|
|
50
|
+
onCloseAutoFocus: (e) => {
|
|
51
|
+
e.preventDefault(), N.current && L() && _.chain().focus().run();
|
|
52
|
+
},
|
|
53
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ h(o.Title, { children: "Table height" }),
|
|
56
|
+
/* @__PURE__ */ h(o.Description, {
|
|
57
|
+
size: "2",
|
|
58
|
+
mb: "4",
|
|
59
|
+
children: "Set a maximum height. Limit height controls whether this cap is used."
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ g("form", {
|
|
62
|
+
noValidate: !0,
|
|
63
|
+
onKeyDown: (e) => {
|
|
64
|
+
e.key === "Enter" && e.target instanceof HTMLInputElement && (e.preventDefault(), e.currentTarget.requestSubmit());
|
|
65
|
+
},
|
|
66
|
+
onSubmit: (n) => {
|
|
67
|
+
if (n.preventDefault(), !L()) {
|
|
68
|
+
N.current = !1, b();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let r = e(x.trim());
|
|
72
|
+
if (r === null) {
|
|
73
|
+
w(`Enter a whole number from 120 to ${t}.`), T.current?.focus();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
R(r);
|
|
77
|
+
},
|
|
78
|
+
children: [/* @__PURE__ */ g(s, {
|
|
79
|
+
direction: "column",
|
|
80
|
+
gap: "2",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ h("label", {
|
|
83
|
+
htmlFor: P,
|
|
84
|
+
children: /* @__PURE__ */ h(c, {
|
|
85
|
+
size: "2",
|
|
86
|
+
weight: "medium",
|
|
87
|
+
children: "Maximum height (px)"
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ h(l.Root, {
|
|
91
|
+
ref: T,
|
|
92
|
+
id: P,
|
|
93
|
+
type: "text",
|
|
94
|
+
inputMode: "numeric",
|
|
95
|
+
autoComplete: "off",
|
|
96
|
+
placeholder: "Editor default",
|
|
97
|
+
value: x,
|
|
98
|
+
"aria-invalid": C ? !0 : void 0,
|
|
99
|
+
"aria-describedby": C ? `${F} ${I}` : F,
|
|
100
|
+
onChange: (e) => {
|
|
101
|
+
S(e.target.value), w(null);
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ g(c, {
|
|
105
|
+
id: F,
|
|
106
|
+
size: "1",
|
|
107
|
+
color: "gray",
|
|
108
|
+
children: [
|
|
109
|
+
120,
|
|
110
|
+
"–",
|
|
111
|
+
t,
|
|
112
|
+
" pixels. Use default follows the editor's configured height."
|
|
113
|
+
]
|
|
114
|
+
}),
|
|
115
|
+
C ? /* @__PURE__ */ h(c, {
|
|
116
|
+
id: I,
|
|
117
|
+
size: "1",
|
|
118
|
+
color: "red",
|
|
119
|
+
role: "alert",
|
|
120
|
+
children: C
|
|
121
|
+
}) : null
|
|
122
|
+
]
|
|
123
|
+
}), /* @__PURE__ */ g(s, {
|
|
124
|
+
mt: "4",
|
|
125
|
+
gap: "2",
|
|
126
|
+
justify: "between",
|
|
127
|
+
wrap: "wrap",
|
|
128
|
+
children: [/* @__PURE__ */ h(a, {
|
|
129
|
+
type: "button",
|
|
130
|
+
variant: "soft",
|
|
131
|
+
color: "gray",
|
|
132
|
+
disabled: !y,
|
|
133
|
+
onClick: () => R(null),
|
|
134
|
+
children: "Use default"
|
|
135
|
+
}), /* @__PURE__ */ g(s, {
|
|
136
|
+
gap: "2",
|
|
137
|
+
children: [/* @__PURE__ */ h(a, {
|
|
138
|
+
type: "button",
|
|
139
|
+
variant: "soft",
|
|
140
|
+
color: "gray",
|
|
141
|
+
onClick: b,
|
|
142
|
+
children: "Cancel"
|
|
143
|
+
}), /* @__PURE__ */ h(a, {
|
|
144
|
+
type: "submit",
|
|
145
|
+
disabled: !y,
|
|
146
|
+
children: "Apply"
|
|
147
|
+
})]
|
|
148
|
+
})]
|
|
149
|
+
})]
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { _ as default };
|