@clevertask/scribe 0.1.26 → 0.1.27
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 +7 -1
- package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +161 -134
- package/dist/components/Menu/TableLayoutOptions.d.ts +19 -0
- package/dist/components/Menu/TableLayoutOptions.d.ts.map +1 -0
- package/dist/components/Menu/TableLayoutOptions.js +109 -0
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.d.ts +12 -1
- package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +144 -2
- package/dist/components/Scribe/extension/slashCommand/items.js +1 -1
- package/dist/components/Scribe/extension/table-layout.d.ts +26 -0
- package/dist/components/Scribe/extension/table-layout.d.ts.map +1 -0
- package/dist/components/Scribe/extension/table-layout.js +2 -0
- package/dist/components/Scribe/extension/table-sticky-header.d.ts +7 -0
- package/dist/components/Scribe/extension/table-sticky-header.d.ts.map +1 -0
- package/dist/components/Scribe/extension/table-sticky-header.js +106 -0
- package/dist/components/Scribe/index.js +2 -2
- package/dist/document-node-capabilities.d.ts.map +1 -1
- package/dist/document-node-capabilities.js +76 -68
- package/dist/{extension-BFPlsViw.js → extension-CBOxOV0e.js} +1 -1
- package/dist/{html-to-markdown-BpR-7GtJ.js → html-to-markdown-DZ83bZ9I.js} +1 -1
- package/dist/main.css +46 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/{schema-extensions-BryyErmk.js → schema-extensions-BXyGPwMf.js} +10 -9
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/{resizable-table-JZOaj_L3.js → table-layout-B3sPDpEF.js} +132 -110
- 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
|
@@ -221,9 +221,15 @@ function App() {
|
|
|
221
221
|
|
|
222
222
|
Type `/table` to insert a 3 × 3 table with a header row. Selecting a table cell opens nearby controls for adding or deleting rows and columns, toggling the header row, and deleting the table. Drag a column boundary to resize it.
|
|
223
223
|
|
|
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
|
+
|
|
226
|
+
**Limit height** is an independent option that caps the table at 360px and enables vertical scrolling. Override `--scribe-table-max-height` on the editor's container to change the cap. 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 also use `editor.commands.setTableLayout("scroll")` (accepts `"auto"`, `"fit"`, or `"scroll"`) and `editor.commands.setTableHeightLimit(true)` (accepts a boolean) while the selection is inside the table.
|
|
227
|
+
|
|
228
|
+
**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
|
+
|
|
224
230
|
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.
|
|
225
231
|
|
|
226
|
-
Simple headed tables serialize as GFM Markdown. Tables with 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.
|
|
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.
|
|
227
233
|
|
|
228
234
|
Scribe's `insertTable` command and `/table` action do not create a table while the selection is
|
|
229
235
|
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":"
|
|
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;AAsJD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA4X7C,CAAC;eAEa,eAAe"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
1
|
+
import { o as e } from "../../table-layout-B3sPDpEF.js";
|
|
2
|
+
import { s as t } from "../../dist-BiognBi4.js";
|
|
3
|
+
import { getPopupMountTarget as n } from "../Scribe/extension/getPopupMountTarget.js";
|
|
4
|
+
import { t as r } from "../../menus-BDXjZsFU.js";
|
|
5
|
+
import { getSelectionTableContext as i, tableBubbleMenuPluginKey as a } from "./tableBubbleMenuPlugin.js";
|
|
6
|
+
import { getSelectionContextualMenuOwner as o } from "./contextualMenuOwner.js";
|
|
7
|
+
import s from "./TableLayoutOptions.js";
|
|
8
|
+
import { Flex as c, IconButton as l, Separator as u } from "@radix-ui/themes";
|
|
9
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
10
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
9
11
|
//#region lib/components/Menu/TableBubbleMenu.tsx
|
|
10
|
-
var
|
|
12
|
+
var y = [
|
|
11
13
|
"addColumnAfter",
|
|
12
14
|
"addColumnBefore",
|
|
13
15
|
"addRowAfter",
|
|
@@ -16,7 +18,7 @@ var g = [
|
|
|
16
18
|
"deleteRow",
|
|
17
19
|
"deleteTable",
|
|
18
20
|
"toggleHeaderRow"
|
|
19
|
-
],
|
|
21
|
+
], b = {
|
|
20
22
|
canAddColumnAfter: !1,
|
|
21
23
|
canAddColumnBefore: !1,
|
|
22
24
|
canAddRowAfter: !1,
|
|
@@ -25,24 +27,23 @@ var g = [
|
|
|
25
27
|
canDeleteRow: !1,
|
|
26
28
|
canDeleteTable: !1,
|
|
27
29
|
canToggleHeaderRow: !1,
|
|
28
|
-
hasHeaderRow: !1
|
|
29
|
-
|
|
30
|
+
hasHeaderRow: !1,
|
|
31
|
+
canSetTableLayout: !1,
|
|
32
|
+
canSetTableHeightLimit: !1,
|
|
33
|
+
canSetTableStickyHeaderRow: !1,
|
|
34
|
+
tableLayout: "auto",
|
|
35
|
+
limitHeight: !1,
|
|
36
|
+
stickyHeaderRow: !1
|
|
37
|
+
}, x = /auto|overlay|scroll/, S = (e) => {
|
|
30
38
|
let t = e.ownerDocument.defaultView;
|
|
31
39
|
if (!t) return [];
|
|
32
40
|
let n = [], r = e.parentElement;
|
|
33
41
|
for (; r && r !== e.ownerDocument.body && r !== e.ownerDocument.documentElement;) {
|
|
34
42
|
let e = t.getComputedStyle(r);
|
|
35
|
-
|
|
43
|
+
x.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
|
|
36
44
|
}
|
|
37
45
|
return n;
|
|
38
|
-
},
|
|
39
|
-
let t = e.firstChild;
|
|
40
|
-
if (!t || t.childCount === 0) return !1;
|
|
41
|
-
let n = !0;
|
|
42
|
-
return t.forEach((e) => {
|
|
43
|
-
e.type.name !== "tableHeader" && (n = !1);
|
|
44
|
-
}), n;
|
|
45
|
-
}, x = ({ name: e }) => {
|
|
46
|
+
}, C = ({ name: e }) => {
|
|
46
47
|
let t = {
|
|
47
48
|
"aria-hidden": !0,
|
|
48
49
|
fill: "none",
|
|
@@ -57,12 +58,12 @@ var g = [
|
|
|
57
58
|
};
|
|
58
59
|
if (e === "add-row-above" || e === "add-row-below") {
|
|
59
60
|
let r = e === "add-row-above" ? 3.5 : 16.5;
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ v("svg", {
|
|
61
62
|
...t,
|
|
62
|
-
children: [/* @__PURE__ */
|
|
63
|
+
children: [/* @__PURE__ */ _("path", {
|
|
63
64
|
d: "M3.5 6.5h13v7h-13zM3.5 10h13M10 6.5v7",
|
|
64
65
|
...n
|
|
65
|
-
}), /* @__PURE__ */
|
|
66
|
+
}), /* @__PURE__ */ _("path", {
|
|
66
67
|
d: `M7.75 ${r}h4.5M10 ${r - 2.25}v4.5`,
|
|
67
68
|
...n
|
|
68
69
|
})]
|
|
@@ -70,92 +71,98 @@ var g = [
|
|
|
70
71
|
}
|
|
71
72
|
if (e === "add-column-before" || e === "add-column-after") {
|
|
72
73
|
let r = e === "add-column-before" ? 3.5 : 16.5;
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ v("svg", {
|
|
74
75
|
...t,
|
|
75
|
-
children: [/* @__PURE__ */
|
|
76
|
+
children: [/* @__PURE__ */ _("path", {
|
|
76
77
|
d: "M6.5 3.5h7v13h-7zM10 3.5v13M6.5 10h7",
|
|
77
78
|
...n
|
|
78
|
-
}), /* @__PURE__ */
|
|
79
|
+
}), /* @__PURE__ */ _("path", {
|
|
79
80
|
d: `M${r - 2.25} 10h4.5M${r} 7.75v4.5`,
|
|
80
81
|
...n
|
|
81
82
|
})]
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
|
-
return e === "delete-row" ? /* @__PURE__ */
|
|
85
|
+
return e === "delete-row" ? /* @__PURE__ */ v("svg", {
|
|
85
86
|
...t,
|
|
86
|
-
children: [/* @__PURE__ */
|
|
87
|
+
children: [/* @__PURE__ */ _("path", {
|
|
87
88
|
d: "M3.5 4h13v12h-13zM3.5 8h13M3.5 12h13M10 4v12",
|
|
88
89
|
...n
|
|
89
|
-
}), /* @__PURE__ */
|
|
90
|
+
}), /* @__PURE__ */ _("path", {
|
|
90
91
|
d: "M6.75 10h6.5",
|
|
91
92
|
stroke: "currentColor",
|
|
92
93
|
strokeWidth: "2.2"
|
|
93
94
|
})]
|
|
94
|
-
}) : e === "delete-column" ? /* @__PURE__ */
|
|
95
|
+
}) : e === "delete-column" ? /* @__PURE__ */ v("svg", {
|
|
95
96
|
...t,
|
|
96
|
-
children: [/* @__PURE__ */
|
|
97
|
+
children: [/* @__PURE__ */ _("path", {
|
|
97
98
|
d: "M4 3.5h12v13h-12zM8 3.5v13M12 3.5v13M4 10h12",
|
|
98
99
|
...n
|
|
99
|
-
}), /* @__PURE__ */
|
|
100
|
+
}), /* @__PURE__ */ _("path", {
|
|
100
101
|
d: "M10 6.75v6.5",
|
|
101
102
|
stroke: "currentColor",
|
|
102
103
|
strokeWidth: "2.2"
|
|
103
104
|
})]
|
|
104
|
-
}) : e === "toggle-header-row" ? /* @__PURE__ */
|
|
105
|
+
}) : e === "toggle-header-row" ? /* @__PURE__ */ v("svg", {
|
|
105
106
|
...t,
|
|
106
|
-
children: [/* @__PURE__ */
|
|
107
|
+
children: [/* @__PURE__ */ _("path", {
|
|
107
108
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
108
109
|
...n
|
|
109
|
-
}), /* @__PURE__ */
|
|
110
|
+
}), /* @__PURE__ */ _("path", {
|
|
110
111
|
d: "M4.2 4.7h11.6v2.6H4.2z",
|
|
111
112
|
fill: "currentColor",
|
|
112
113
|
opacity: "0.45"
|
|
113
114
|
})]
|
|
114
|
-
}) : /* @__PURE__ */
|
|
115
|
+
}) : /* @__PURE__ */ v("svg", {
|
|
115
116
|
...t,
|
|
116
|
-
children: [/* @__PURE__ */
|
|
117
|
+
children: [/* @__PURE__ */ _("path", {
|
|
117
118
|
d: "M3.5 4h13v12h-13zM3.5 8h13M10 4v12",
|
|
118
119
|
...n
|
|
119
|
-
}), /* @__PURE__ */
|
|
120
|
+
}), /* @__PURE__ */ _("path", {
|
|
120
121
|
d: "m6.75 7 6.5 6.5m0-6.5-6.5 6.5",
|
|
121
122
|
stroke: "currentColor",
|
|
122
123
|
strokeWidth: "1.8"
|
|
123
124
|
})]
|
|
124
125
|
});
|
|
125
|
-
},
|
|
126
|
-
let
|
|
127
|
-
editor:
|
|
128
|
-
selector: ({ editor:
|
|
129
|
-
if (!
|
|
130
|
-
let
|
|
126
|
+
}, w = ({ editor: x }) => {
|
|
127
|
+
let w = m(null), [T, E] = h(null), [D, O] = h(!1), k = p(() => y.every((e) => typeof x.commands[e] == "function"), [x]), A = p(() => typeof x.commands.setTableLayout == "function" && typeof x.commands.setTableHeightLimit == "function", [x]), j = p(() => typeof x.commands.setTableStickyHeaderRow == "function", [x]), M = t({
|
|
128
|
+
editor: x,
|
|
129
|
+
selector: ({ editor: t }) => {
|
|
130
|
+
if (!k) return b;
|
|
131
|
+
let n = i(t.state), r = t.can(), a = n ? e(n.node) : !1, o = n?.node.attrs.limitHeight === !0, s = n?.node.attrs.stickyHeaderRow === !0;
|
|
131
132
|
return {
|
|
132
|
-
canAddColumnAfter:
|
|
133
|
-
canAddColumnBefore:
|
|
134
|
-
canAddRowAfter:
|
|
135
|
-
canAddRowBefore:
|
|
136
|
-
canDeleteColumn:
|
|
137
|
-
canDeleteRow:
|
|
138
|
-
canDeleteTable:
|
|
139
|
-
canToggleHeaderRow:
|
|
140
|
-
hasHeaderRow:
|
|
133
|
+
canAddColumnAfter: r.addColumnAfter(),
|
|
134
|
+
canAddColumnBefore: r.addColumnBefore(),
|
|
135
|
+
canAddRowAfter: r.addRowAfter(),
|
|
136
|
+
canAddRowBefore: r.addRowBefore(),
|
|
137
|
+
canDeleteColumn: r.deleteColumn(),
|
|
138
|
+
canDeleteRow: r.deleteRow(),
|
|
139
|
+
canDeleteTable: r.deleteTable(),
|
|
140
|
+
canToggleHeaderRow: r.toggleHeaderRow(),
|
|
141
|
+
hasHeaderRow: a,
|
|
142
|
+
canSetTableLayout: A && r.setTableLayout("auto"),
|
|
143
|
+
canSetTableHeightLimit: A && r.setTableHeightLimit(!0),
|
|
144
|
+
canSetTableStickyHeaderRow: t.isEditable && j && a && r.setTableStickyHeaderRow(!s),
|
|
145
|
+
tableLayout: n?.node.attrs.tableLayout ?? "auto",
|
|
146
|
+
limitHeight: o,
|
|
147
|
+
stickyHeaderRow: s
|
|
141
148
|
};
|
|
142
149
|
}
|
|
143
|
-
}),
|
|
144
|
-
let i = r.hasFocus() || t.contains(t.ownerDocument.activeElement);
|
|
145
|
-
return
|
|
146
|
-
}, [
|
|
147
|
-
if (
|
|
148
|
-
let e =
|
|
150
|
+
}), N = d(({ editor: e, element: t, state: n, view: r }) => {
|
|
151
|
+
let i = D || r.hasFocus() || t.contains(t.ownerDocument.activeElement);
|
|
152
|
+
return k && e.isEditable && i && o(n) === "table";
|
|
153
|
+
}, [k, D]), P = d(() => {
|
|
154
|
+
if (x.isDestroyed) return null;
|
|
155
|
+
let e = i(x.state);
|
|
149
156
|
if (!e) return null;
|
|
150
|
-
let t =
|
|
157
|
+
let t = x.view.nodeDOM(e.position);
|
|
151
158
|
return t instanceof HTMLElement ? t.closest(".tableWrapper") ?? t.querySelector(".tableWrapper") ?? t : null;
|
|
152
|
-
}, [
|
|
153
|
-
|
|
154
|
-
let e =
|
|
159
|
+
}, [x]), F = d(() => n(x), [x]);
|
|
160
|
+
f(() => {
|
|
161
|
+
let e = x.view.dom.ownerDocument.defaultView;
|
|
155
162
|
if (!e) return;
|
|
156
|
-
let t =
|
|
163
|
+
let t = S(x.view.dom), n = null, r = () => {
|
|
157
164
|
n === null && (n = e.requestAnimationFrame(() => {
|
|
158
|
-
n = null,
|
|
165
|
+
n = null, x.isDestroyed || x.view.dispatch(x.state.tr.setMeta(a, "updatePosition"));
|
|
159
166
|
}));
|
|
160
167
|
};
|
|
161
168
|
return t.forEach((e) => {
|
|
@@ -165,27 +172,27 @@ var g = [
|
|
|
165
172
|
e.removeEventListener("scroll", r);
|
|
166
173
|
});
|
|
167
174
|
};
|
|
168
|
-
}, [
|
|
169
|
-
let e =
|
|
175
|
+
}, [x]), f(() => {
|
|
176
|
+
let e = x.view.dom.closest("[data-scribe-root]"), t = x.view.dom.ownerDocument.defaultView;
|
|
170
177
|
if (!e || !t) return;
|
|
171
178
|
let n = () => {
|
|
172
179
|
let t = e.getBoundingClientRect().width;
|
|
173
|
-
|
|
180
|
+
E(t > 0 ? Math.max(t - 16, 0) : null);
|
|
174
181
|
};
|
|
175
182
|
if (n(), !t.ResizeObserver) return;
|
|
176
183
|
let r = new t.ResizeObserver(n);
|
|
177
184
|
return r.observe(e), () => r.disconnect();
|
|
178
|
-
}, [
|
|
179
|
-
let e =
|
|
180
|
-
if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !
|
|
181
|
-
let t =
|
|
185
|
+
}, [x]), f(() => {
|
|
186
|
+
let e = x.view.dom, t = (e) => {
|
|
187
|
+
if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !x.isEditable || o(x.state) !== "table") return;
|
|
188
|
+
let t = w.current?.querySelector("button:not(:disabled)");
|
|
182
189
|
t && (e.preventDefault(), t.focus());
|
|
183
190
|
};
|
|
184
191
|
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
185
|
-
}, [
|
|
186
|
-
let
|
|
192
|
+
}, [x]);
|
|
193
|
+
let I = d((e) => {
|
|
187
194
|
if (e.key === "Escape") {
|
|
188
|
-
e.preventDefault(),
|
|
195
|
+
e.preventDefault(), x.chain().focus().run();
|
|
189
196
|
return;
|
|
190
197
|
}
|
|
191
198
|
if (![
|
|
@@ -198,109 +205,129 @@ var g = [
|
|
|
198
205
|
if (t.length === 0) return;
|
|
199
206
|
let n = e.currentTarget.ownerDocument.activeElement, r = t.findIndex((e) => e === n), i = r;
|
|
200
207
|
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();
|
|
201
|
-
}, [
|
|
208
|
+
}, [x]), L = p(() => ({
|
|
202
209
|
strategy: "fixed",
|
|
203
210
|
placement: "top-start",
|
|
204
211
|
offset: 8,
|
|
205
212
|
flip: {},
|
|
206
213
|
shift: { padding: 8 }
|
|
207
|
-
}), []),
|
|
214
|
+
}), []), R = p(() => [
|
|
208
215
|
[
|
|
209
216
|
{
|
|
210
217
|
label: "Add row above",
|
|
211
|
-
command: () =>
|
|
212
|
-
disabled: !
|
|
213
|
-
icon: /* @__PURE__ */
|
|
218
|
+
command: () => x.chain().focus().addRowBefore().run(),
|
|
219
|
+
disabled: !M.canAddRowBefore,
|
|
220
|
+
icon: /* @__PURE__ */ _(C, { name: "add-row-above" })
|
|
214
221
|
},
|
|
215
222
|
{
|
|
216
223
|
label: "Add row below",
|
|
217
|
-
command: () =>
|
|
218
|
-
disabled: !
|
|
219
|
-
icon: /* @__PURE__ */
|
|
224
|
+
command: () => x.chain().focus().addRowAfter().run(),
|
|
225
|
+
disabled: !M.canAddRowAfter,
|
|
226
|
+
icon: /* @__PURE__ */ _(C, { name: "add-row-below" })
|
|
220
227
|
},
|
|
221
228
|
{
|
|
222
229
|
label: "Delete row",
|
|
223
|
-
command: () =>
|
|
224
|
-
disabled: !
|
|
225
|
-
icon: /* @__PURE__ */
|
|
230
|
+
command: () => x.chain().focus().deleteRow().run(),
|
|
231
|
+
disabled: !M.canDeleteRow,
|
|
232
|
+
icon: /* @__PURE__ */ _(C, { name: "delete-row" })
|
|
226
233
|
}
|
|
227
234
|
],
|
|
228
235
|
[
|
|
229
236
|
{
|
|
230
237
|
label: "Add column before",
|
|
231
|
-
command: () =>
|
|
232
|
-
disabled: !
|
|
233
|
-
icon: /* @__PURE__ */
|
|
238
|
+
command: () => x.chain().focus().addColumnBefore().run(),
|
|
239
|
+
disabled: !M.canAddColumnBefore,
|
|
240
|
+
icon: /* @__PURE__ */ _(C, { name: "add-column-before" })
|
|
234
241
|
},
|
|
235
242
|
{
|
|
236
243
|
label: "Add column after",
|
|
237
|
-
command: () =>
|
|
238
|
-
disabled: !
|
|
239
|
-
icon: /* @__PURE__ */
|
|
244
|
+
command: () => x.chain().focus().addColumnAfter().run(),
|
|
245
|
+
disabled: !M.canAddColumnAfter,
|
|
246
|
+
icon: /* @__PURE__ */ _(C, { name: "add-column-after" })
|
|
240
247
|
},
|
|
241
248
|
{
|
|
242
249
|
label: "Delete column",
|
|
243
|
-
command: () =>
|
|
244
|
-
disabled: !
|
|
245
|
-
icon: /* @__PURE__ */
|
|
250
|
+
command: () => x.chain().focus().deleteColumn().run(),
|
|
251
|
+
disabled: !M.canDeleteColumn,
|
|
252
|
+
icon: /* @__PURE__ */ _(C, { name: "delete-column" })
|
|
246
253
|
}
|
|
247
254
|
],
|
|
248
255
|
[{
|
|
249
256
|
label: "Toggle header row",
|
|
250
|
-
command: () =>
|
|
251
|
-
disabled: !
|
|
252
|
-
icon: /* @__PURE__ */
|
|
253
|
-
ariaPressed:
|
|
257
|
+
command: () => x.chain().focus().toggleHeaderRow().run(),
|
|
258
|
+
disabled: !M.canToggleHeaderRow,
|
|
259
|
+
icon: /* @__PURE__ */ _(C, { name: "toggle-header-row" }),
|
|
260
|
+
ariaPressed: M.hasHeaderRow
|
|
254
261
|
}],
|
|
255
262
|
[{
|
|
256
263
|
label: "Delete table",
|
|
257
|
-
command: () =>
|
|
258
|
-
disabled: !
|
|
259
|
-
icon: /* @__PURE__ */
|
|
264
|
+
command: () => x.chain().focus().deleteTable().run(),
|
|
265
|
+
disabled: !M.canDeleteTable,
|
|
266
|
+
icon: /* @__PURE__ */ _(C, { name: "delete-table" })
|
|
260
267
|
}]
|
|
261
|
-
], [
|
|
262
|
-
return /* @__PURE__ */
|
|
263
|
-
editor:
|
|
264
|
-
pluginKey:
|
|
268
|
+
], [x, M]);
|
|
269
|
+
return /* @__PURE__ */ _(r, {
|
|
270
|
+
editor: x,
|
|
271
|
+
pluginKey: a,
|
|
265
272
|
updateDelay: 0,
|
|
266
273
|
resizeDelay: 0,
|
|
267
|
-
appendTo:
|
|
268
|
-
shouldShow:
|
|
269
|
-
getReferencedVirtualElement:
|
|
270
|
-
options:
|
|
271
|
-
children: /* @__PURE__ */
|
|
272
|
-
ref:
|
|
274
|
+
appendTo: F,
|
|
275
|
+
shouldShow: N,
|
|
276
|
+
getReferencedVirtualElement: P,
|
|
277
|
+
options: L,
|
|
278
|
+
children: /* @__PURE__ */ _(c, {
|
|
279
|
+
ref: w,
|
|
273
280
|
className: "scribe-table-bubble-menu",
|
|
274
281
|
role: "toolbar",
|
|
275
282
|
"aria-label": "Table controls",
|
|
276
283
|
"aria-keyshortcuts": "Alt+F10",
|
|
277
284
|
align: "center",
|
|
278
285
|
gap: "2",
|
|
279
|
-
onKeyDown:
|
|
280
|
-
style:
|
|
281
|
-
children:
|
|
286
|
+
onKeyDown: I,
|
|
287
|
+
style: T === null ? void 0 : { maxWidth: T },
|
|
288
|
+
children: R.map((e, t) => /* @__PURE__ */ v(c, {
|
|
282
289
|
align: "center",
|
|
283
290
|
gap: "1",
|
|
284
|
-
children: [
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
291
|
+
children: [
|
|
292
|
+
t > 0 ? /* @__PURE__ */ _(u, {
|
|
293
|
+
orientation: "vertical",
|
|
294
|
+
decorative: !0,
|
|
295
|
+
style: { height: 20 }
|
|
296
|
+
}) : null,
|
|
297
|
+
t === R.length - 1 && A ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(s, {
|
|
298
|
+
editor: x,
|
|
299
|
+
layout: M.tableLayout,
|
|
300
|
+
limitHeight: M.limitHeight,
|
|
301
|
+
stickyHeaderRow: M.stickyHeaderRow,
|
|
302
|
+
hasHeaderRow: M.hasHeaderRow,
|
|
303
|
+
canSetLayout: M.canSetTableLayout,
|
|
304
|
+
canSetHeightLimit: M.canSetTableHeightLimit,
|
|
305
|
+
hasStickyHeaderCommand: j,
|
|
306
|
+
canSetStickyHeaderRow: M.canSetTableStickyHeaderRow,
|
|
307
|
+
open: D,
|
|
308
|
+
onOpenChange: O
|
|
309
|
+
}), /* @__PURE__ */ _(u, {
|
|
310
|
+
orientation: "vertical",
|
|
311
|
+
decorative: !0,
|
|
312
|
+
style: { height: 20 }
|
|
313
|
+
})] }) : null,
|
|
314
|
+
e.map((e) => /* @__PURE__ */ _(l, {
|
|
315
|
+
type: "button",
|
|
316
|
+
size: "1",
|
|
317
|
+
radius: "medium",
|
|
318
|
+
color: e.label === "Delete table" ? "red" : "gray",
|
|
319
|
+
variant: e.ariaPressed ? "soft" : "ghost",
|
|
320
|
+
"aria-label": e.label,
|
|
321
|
+
"aria-pressed": e.ariaPressed,
|
|
322
|
+
disabled: e.disabled,
|
|
323
|
+
title: e.label,
|
|
324
|
+
onClick: e.command,
|
|
325
|
+
children: e.icon
|
|
326
|
+
}, e.label))
|
|
327
|
+
]
|
|
301
328
|
}, e[0]?.label))
|
|
302
329
|
})
|
|
303
330
|
});
|
|
304
331
|
};
|
|
305
332
|
//#endregion
|
|
306
|
-
export {
|
|
333
|
+
export { w as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
import type { ScribeTableLayout } from "../Scribe/extension/resizable-table";
|
|
4
|
+
interface TableLayoutOptionsProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
layout: ScribeTableLayout;
|
|
7
|
+
limitHeight: boolean;
|
|
8
|
+
stickyHeaderRow: boolean;
|
|
9
|
+
hasHeaderRow: boolean;
|
|
10
|
+
canSetLayout: boolean;
|
|
11
|
+
canSetHeightLimit: boolean;
|
|
12
|
+
hasStickyHeaderCommand: boolean;
|
|
13
|
+
canSetStickyHeaderRow: boolean;
|
|
14
|
+
open: boolean;
|
|
15
|
+
onOpenChange: (open: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const TableLayoutOptions: FC<TableLayoutOptionsProps>;
|
|
18
|
+
export default TableLayoutOptions;
|
|
19
|
+
//# sourceMappingURL=TableLayoutOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableLayoutOptions.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/TableLayoutOptions.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,EAAE,EAAiB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAQD,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAiInD,CAAC;eAEa,kBAAkB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getPopupMountTarget as e } from "../Scribe/extension/getPopupMountTarget.js";
|
|
2
|
+
import { DropdownMenu as t, IconButton as n } from "@radix-ui/themes";
|
|
3
|
+
import { useId as r, useRef as i } from "react";
|
|
4
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/components/Menu/TableLayoutOptions.tsx
|
|
6
|
+
var c = [
|
|
7
|
+
{
|
|
8
|
+
value: "auto",
|
|
9
|
+
label: "Auto"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
value: "fit",
|
|
13
|
+
label: "Fit to width"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
value: "scroll",
|
|
17
|
+
label: "Scroll horizontally"
|
|
18
|
+
}
|
|
19
|
+
], l = ({ editor: l, layout: u, limitHeight: d, stickyHeaderRow: f, hasHeaderRow: p, canSetLayout: m, canSetHeightLimit: h, hasStickyHeaderCommand: g, canSetStickyHeaderRow: _, open: v, onOpenChange: y }) => {
|
|
20
|
+
let b = i(!1), x = r(), S = p ? void 0 : "Requires a header row.";
|
|
21
|
+
return /* @__PURE__ */ s(t.Root, {
|
|
22
|
+
modal: !1,
|
|
23
|
+
open: v,
|
|
24
|
+
onOpenChange: (e) => {
|
|
25
|
+
e && (b.current = !1), y(e);
|
|
26
|
+
},
|
|
27
|
+
children: [/* @__PURE__ */ o(t.Trigger, { children: /* @__PURE__ */ o(n, {
|
|
28
|
+
type: "button",
|
|
29
|
+
size: "1",
|
|
30
|
+
radius: "medium",
|
|
31
|
+
color: "gray",
|
|
32
|
+
variant: v ? "soft" : "ghost",
|
|
33
|
+
"aria-label": "Table layout",
|
|
34
|
+
title: "Table layout",
|
|
35
|
+
children: /* @__PURE__ */ o("svg", {
|
|
36
|
+
"aria-hidden": "true",
|
|
37
|
+
fill: "none",
|
|
38
|
+
height: "18",
|
|
39
|
+
viewBox: "0 0 20 20",
|
|
40
|
+
width: "18",
|
|
41
|
+
children: /* @__PURE__ */ o("path", {
|
|
42
|
+
d: "M3.5 3.5h13v8h-13zM3.5 7.5h13M8 3.5v8M12 3.5v8M3.5 16h13M5.5 14l-2 2 2 2M14.5 14l2 2-2 2",
|
|
43
|
+
stroke: "currentColor",
|
|
44
|
+
strokeLinecap: "round",
|
|
45
|
+
strokeLinejoin: "round",
|
|
46
|
+
strokeWidth: "1.35"
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}) }), /* @__PURE__ */ s(t.Content, {
|
|
50
|
+
"aria-label": "Table layout",
|
|
51
|
+
container: e(l),
|
|
52
|
+
size: "2",
|
|
53
|
+
side: "bottom",
|
|
54
|
+
align: "start",
|
|
55
|
+
collisionPadding: 8,
|
|
56
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
57
|
+
onEscapeKeyDown: (e) => {
|
|
58
|
+
e.stopPropagation(), b.current = !0;
|
|
59
|
+
},
|
|
60
|
+
onCloseAutoFocus: (e) => {
|
|
61
|
+
b.current && !l.isDestroyed && (e.preventDefault(), l.chain().focus().run());
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ o(t.Label, { children: "Width" }),
|
|
65
|
+
/* @__PURE__ */ o(t.RadioGroup, {
|
|
66
|
+
"aria-label": "Table width",
|
|
67
|
+
value: u,
|
|
68
|
+
onValueChange: (e) => {
|
|
69
|
+
let t = c.find((t) => t.value === e)?.value;
|
|
70
|
+
t && (b.current = !0, l.commands.setTableLayout(t));
|
|
71
|
+
},
|
|
72
|
+
children: c.map((e) => /* @__PURE__ */ o(t.RadioItem, {
|
|
73
|
+
value: e.value,
|
|
74
|
+
disabled: !m,
|
|
75
|
+
children: e.label
|
|
76
|
+
}, e.value))
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ o(t.Separator, {}),
|
|
79
|
+
/* @__PURE__ */ o(t.CheckboxItem, {
|
|
80
|
+
checked: d,
|
|
81
|
+
disabled: !h,
|
|
82
|
+
onCheckedChange: (e) => {
|
|
83
|
+
b.current = !0, l.commands.setTableHeightLimit(e);
|
|
84
|
+
},
|
|
85
|
+
children: "Limit height"
|
|
86
|
+
}),
|
|
87
|
+
g ? /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(t.CheckboxItem, {
|
|
88
|
+
checked: f,
|
|
89
|
+
disabled: !_,
|
|
90
|
+
"aria-describedby": S ? x : void 0,
|
|
91
|
+
onCheckedChange: (e) => {
|
|
92
|
+
b.current = !0, l.commands.setTableStickyHeaderRow(e);
|
|
93
|
+
},
|
|
94
|
+
children: "Sticky header row"
|
|
95
|
+
}), S ? /* @__PURE__ */ o(t.Label, {
|
|
96
|
+
id: x,
|
|
97
|
+
style: {
|
|
98
|
+
height: "auto",
|
|
99
|
+
maxWidth: 220,
|
|
100
|
+
whiteSpace: "normal"
|
|
101
|
+
},
|
|
102
|
+
children: S
|
|
103
|
+
}) : null] }) : null
|
|
104
|
+
]
|
|
105
|
+
})]
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { l as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../../extension-
|
|
1
|
+
import { t as e } from "../../../extension-CBOxOV0e.js";
|
|
2
2
|
export { e as initExtensions };
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Selection } from "@tiptap/pm/state";
|
|
2
|
+
import { type ScribeTableLayout } from "./table-layout";
|
|
3
|
+
export type { ScribeTableLayout } from "./table-layout";
|
|
4
|
+
declare module "@tiptap/core" {
|
|
5
|
+
interface Commands<ReturnType> {
|
|
6
|
+
scribeTableLayout: {
|
|
7
|
+
setTableLayout: (layout: ScribeTableLayout) => ReturnType;
|
|
8
|
+
setTableHeightLimit: (limit: boolean) => ReturnType;
|
|
9
|
+
setTableStickyHeaderRow: (sticky: boolean) => ReturnType;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
2
13
|
export declare const selectionHasTableAncestor: (selection: Selection) => boolean;
|
|
3
14
|
/**
|
|
4
15
|
* Tiptap only registers its column-resizing plugin when the editor is editable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable-table.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/resizable-table.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resizable-table.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/resizable-table.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAQL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,iBAAiB,EAAE;YACjB,cAAc,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,UAAU,CAAC;YAC1D,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,UAAU,CAAC;YACpD,uBAAuB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;SAC1D,CAAC;KACH;CACF;AAoCD,eAAO,MAAM,yBAAyB,cAAe,SAAS,YACwB,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kFAyNtB,CAAC"}
|