@clevertask/scribe 0.1.26 → 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.
Files changed (37) hide show
  1. package/README.md +9 -1
  2. package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
  3. package/dist/components/Menu/TableBubbleMenu.js +174 -134
  4. package/dist/components/Menu/TableHeightSettings.d.ts +11 -0
  5. package/dist/components/Menu/TableHeightSettings.d.ts.map +1 -0
  6. package/dist/components/Menu/TableHeightSettings.js +156 -0
  7. package/dist/components/Menu/TableLayoutOptions.d.ts +24 -0
  8. package/dist/components/Menu/TableLayoutOptions.d.ts.map +1 -0
  9. package/dist/components/Menu/TableLayoutOptions.js +126 -0
  10. package/dist/components/Scribe/extension/index.js +1 -1
  11. package/dist/components/Scribe/extension/resizable-table.d.ts +13 -1
  12. package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
  13. package/dist/components/Scribe/extension/resizable-table.js +165 -2
  14. package/dist/components/Scribe/extension/slashCommand/items.js +1 -1
  15. package/dist/components/Scribe/extension/table-layout.d.ts +31 -0
  16. package/dist/components/Scribe/extension/table-layout.d.ts.map +1 -0
  17. package/dist/components/Scribe/extension/table-layout.js +2 -0
  18. package/dist/components/Scribe/extension/table-sticky-header.d.ts +7 -0
  19. package/dist/components/Scribe/extension/table-sticky-header.d.ts.map +1 -0
  20. package/dist/components/Scribe/extension/table-sticky-header.js +106 -0
  21. package/dist/components/Scribe/index.js +2 -2
  22. package/dist/document-node-capabilities.d.ts.map +1 -1
  23. package/dist/document-node-capabilities.js +80 -68
  24. package/dist/{extension-BFPlsViw.js → extension-BU2USLV1.js} +1 -1
  25. package/dist/{html-to-markdown-BpR-7GtJ.js → html-to-markdown-DF93it73.js} +1 -1
  26. package/dist/main.css +47 -0
  27. package/dist/main.d.ts +1 -0
  28. package/dist/main.d.ts.map +1 -1
  29. package/dist/main.js +1 -1
  30. package/dist/{schema-extensions-BryyErmk.js → schema-extensions-DyCk1Goa.js} +10 -9
  31. package/dist/schema-extensions.js +1 -1
  32. package/dist/schema.js +1 -1
  33. package/dist/{resizable-table-JZOaj_L3.js → table-layout-BoDS50DR.js} +140 -110
  34. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  35. package/dist/utils/html-to-markdown.js +1 -1
  36. package/dist/utils/index.js +2 -2
  37. package/package.json +1 -1
@@ -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 };
@@ -0,0 +1,24 @@
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
+ maxHeight: number | null;
9
+ stickyHeaderRow: boolean;
10
+ hasHeaderRow: boolean;
11
+ canSetLayout: boolean;
12
+ canSetHeightLimit: boolean;
13
+ hasMaxHeightCommand: boolean;
14
+ canSetMaxHeight: boolean;
15
+ hasStickyHeaderCommand: boolean;
16
+ canSetStickyHeaderRow: boolean;
17
+ open: boolean;
18
+ onOpenChange: (open: boolean) => void;
19
+ heightSettingsOpen: boolean;
20
+ onHeightSettingsOpenChange: (open: boolean) => void;
21
+ }
22
+ declare const TableLayoutOptions: FC<TableLayoutOptionsProps>;
23
+ export default TableLayoutOptions;
24
+ //# 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;AAG7E,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,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;IACtC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,0BAA0B,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACrD;AAQD,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoKnD,CAAC;eAEa,kBAAkB"}
@@ -0,0 +1,126 @@
1
+ import { getPopupMountTarget as e } from "../Scribe/extension/getPopupMountTarget.js";
2
+ import t from "./TableHeightSettings.js";
3
+ import { DropdownMenu as n, IconButton as r } from "@radix-ui/themes";
4
+ import { useId as i, useRef as a } from "react";
5
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ //#region lib/components/Menu/TableLayoutOptions.tsx
7
+ var l = [
8
+ {
9
+ value: "auto",
10
+ label: "Auto"
11
+ },
12
+ {
13
+ value: "fit",
14
+ label: "Fit to width"
15
+ },
16
+ {
17
+ value: "scroll",
18
+ label: "Scroll horizontally"
19
+ }
20
+ ], u = ({ editor: u, layout: d, limitHeight: f, maxHeight: p, stickyHeaderRow: m, hasHeaderRow: h, canSetLayout: g, canSetHeightLimit: _, hasMaxHeightCommand: v, canSetMaxHeight: y, hasStickyHeaderCommand: b, canSetStickyHeaderRow: x, open: S, onOpenChange: C, heightSettingsOpen: w, onHeightSettingsOpenChange: T }) => {
21
+ let E = a(!1), D = a(!1), O = u.isDestroyed ? void 0 : e(u), k = i(), A = h ? void 0 : "Requires a header row.";
22
+ return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c(n.Root, {
23
+ modal: !1,
24
+ open: S,
25
+ onOpenChange: (e) => {
26
+ e && (E.current = !1), C(e);
27
+ },
28
+ children: [/* @__PURE__ */ s(n.Trigger, { children: /* @__PURE__ */ s(r, {
29
+ type: "button",
30
+ size: "1",
31
+ radius: "medium",
32
+ color: "gray",
33
+ variant: S ? "soft" : "ghost",
34
+ "aria-label": "Table layout",
35
+ title: "Table layout",
36
+ children: /* @__PURE__ */ s("svg", {
37
+ "aria-hidden": "true",
38
+ fill: "none",
39
+ height: "18",
40
+ viewBox: "0 0 20 20",
41
+ width: "18",
42
+ children: /* @__PURE__ */ s("path", {
43
+ 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",
44
+ stroke: "currentColor",
45
+ strokeLinecap: "round",
46
+ strokeLinejoin: "round",
47
+ strokeWidth: "1.35"
48
+ })
49
+ })
50
+ }) }), /* @__PURE__ */ c(n.Content, {
51
+ "aria-label": "Table layout",
52
+ container: O,
53
+ size: "2",
54
+ side: "bottom",
55
+ align: "start",
56
+ collisionPadding: 8,
57
+ onKeyDown: (e) => e.stopPropagation(),
58
+ onEscapeKeyDown: (e) => {
59
+ e.stopPropagation(), E.current = !0;
60
+ },
61
+ onCloseAutoFocus: (e) => {
62
+ if (D.current) {
63
+ e.preventDefault(), D.current = !1;
64
+ return;
65
+ }
66
+ E.current && !u.isDestroyed && (e.preventDefault(), u.chain().focus().run());
67
+ },
68
+ children: [
69
+ /* @__PURE__ */ s(n.Label, { children: "Width" }),
70
+ /* @__PURE__ */ s(n.RadioGroup, {
71
+ "aria-label": "Table width",
72
+ value: d,
73
+ onValueChange: (e) => {
74
+ let t = l.find((t) => t.value === e)?.value;
75
+ t && (E.current = !0, u.commands.setTableLayout(t));
76
+ },
77
+ children: l.map((e) => /* @__PURE__ */ s(n.RadioItem, {
78
+ value: e.value,
79
+ disabled: !g,
80
+ children: e.label
81
+ }, e.value))
82
+ }),
83
+ /* @__PURE__ */ s(n.Separator, {}),
84
+ /* @__PURE__ */ s(n.CheckboxItem, {
85
+ checked: f,
86
+ disabled: !_,
87
+ onCheckedChange: (e) => {
88
+ E.current = !0, u.commands.setTableHeightLimit(e);
89
+ },
90
+ children: "Limit height"
91
+ }),
92
+ v ? /* @__PURE__ */ s(n.Item, {
93
+ disabled: !y,
94
+ onSelect: () => {
95
+ D.current = !0, T(!0);
96
+ },
97
+ children: "Maximum height…"
98
+ }) : null,
99
+ b ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(n.CheckboxItem, {
100
+ checked: m,
101
+ disabled: !x,
102
+ "aria-describedby": A ? k : void 0,
103
+ onCheckedChange: (e) => {
104
+ E.current = !0, u.commands.setTableStickyHeaderRow(e);
105
+ },
106
+ children: "Sticky header row"
107
+ }), A ? /* @__PURE__ */ s(n.Label, {
108
+ id: k,
109
+ style: {
110
+ height: "auto",
111
+ maxWidth: 220,
112
+ whiteSpace: "normal"
113
+ },
114
+ children: A
115
+ }) : null] }) : null
116
+ ]
117
+ })]
118
+ }), w ? /* @__PURE__ */ s(t, {
119
+ editor: u,
120
+ maxHeight: p,
121
+ canSetMaxHeight: y,
122
+ onClose: () => T(!1)
123
+ }) : null] });
124
+ };
125
+ //#endregion
126
+ export { u as default };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../../extension-BFPlsViw.js";
1
+ import { t as e } from "../../../extension-BU2USLV1.js";
2
2
  export { e as initExtensions };
@@ -1,4 +1,16 @@
1
- import type { Selection } from "@tiptap/pm/state";
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
+ setTableMaxHeight: (height: number | null) => ReturnType;
10
+ setTableStickyHeaderRow: (sticky: boolean) => ReturnType;
11
+ };
12
+ }
13
+ }
2
14
  export declare const selectionHasTableAncestor: (selection: Selection) => boolean;
3
15
  /**
4
16
  * 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":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAalD,eAAO,MAAM,yBAAyB,cAAe,SAAS,YACwB,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kFAqDtB,CAAC"}
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,EASL,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,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,UAAU,CAAC;YACzD,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,kFA0QtB,CAAC"}
@@ -1,2 +1,165 @@
1
- import { n as e, t } from "../../../resizable-table-JZOaj_L3.js";
2
- export { t as ScribeTable, e as selectionHasTableAncestor };
1
+ import { I as e } from "../../../dist-xjmWZ-oh.js";
2
+ import { c as t, f as n, i as r, l as i, o as a, p as o, s, u as c } from "../../../table-layout-BoDS50DR.js";
3
+ import { createStickyTableHeaderPlugin as l } from "./table-sticky-header.js";
4
+ import { NodeSelection as u } from "@tiptap/pm/state";
5
+ import { columnResizing as d, columnResizingPluginKey as f, tableEditing as p } from "@tiptap/pm/tables";
6
+ //#region lib/components/Scribe/extension/resizable-table.ts
7
+ var m = (e) => {
8
+ if (e.selection instanceof u && e.selection.node.type.spec.tableRole === "table") return {
9
+ node: e.selection.node,
10
+ position: e.selection.from
11
+ };
12
+ let { $from: t } = e.selection;
13
+ for (let e = t.depth; e > 0; e--) if (t.node(e).type.spec.tableRole === "table") return {
14
+ node: t.node(e),
15
+ position: t.before(e)
16
+ };
17
+ return null;
18
+ }, h = (e) => e.target?.closest?.("table")?.getAttribute("data-table-layout"), g = (e) => {
19
+ for (let t = e.depth; t > 0; --t) if (e.node(t).type.spec.tableRole === "table") return !0;
20
+ return !1;
21
+ }, _ = (e) => g(e.$from) || g(e.$to), v = o.extend({
22
+ addAttributes() {
23
+ return {
24
+ ...this.parent?.(),
25
+ tableLayout: {
26
+ default: "auto",
27
+ parseHTML: (e) => s(e.getAttribute("data-table-layout")),
28
+ renderHTML: ({ tableLayout: e }) => s(e) === "auto" ? {} : { "data-table-layout": s(e) }
29
+ },
30
+ limitHeight: {
31
+ default: !1,
32
+ parseHTML: (e) => e.getAttribute("data-table-limit-height") === "true",
33
+ renderHTML: ({ limitHeight: e }) => e === !0 ? { "data-table-limit-height": "true" } : {}
34
+ },
35
+ maxHeight: {
36
+ default: null,
37
+ parseHTML: (e) => t(e.getAttribute("data-table-max-height")),
38
+ renderHTML: ({ maxHeight: e }) => {
39
+ let n = t(e);
40
+ return n === null ? {} : { "data-table-max-height": String(n) };
41
+ }
42
+ },
43
+ stickyHeaderRow: {
44
+ default: !1,
45
+ parseHTML: (e) => e.getAttribute("data-table-sticky-header-row") === "true",
46
+ renderHTML: ({ stickyHeaderRow: e }) => e === !0 ? { "data-table-sticky-header-row": "true" } : {}
47
+ }
48
+ };
49
+ },
50
+ renderHTML(r) {
51
+ let a = this.parent(r), o = t(r.node.attrs.maxHeight);
52
+ if (r.node.attrs.tableLayout === "scroll") {
53
+ let { width: t, colgroup: n } = i(r.node, this.options.cellMinWidth);
54
+ a = [
55
+ "table",
56
+ e(this.options.HTMLAttributes, r.HTMLAttributes, { style: `width: ${t}px; min-width: ${t}px` }),
57
+ n,
58
+ ["tbody", 0]
59
+ ];
60
+ }
61
+ return r.node.attrs.tableLayout !== "auto" || r.node.attrs.limitHeight || r.node.attrs.stickyHeaderRow || o !== null ? [
62
+ "div",
63
+ {
64
+ class: "tableWrapper",
65
+ ...n(r.node),
66
+ ...o === null ? {} : { style: `--scribe-table-custom-max-height: ${o}px` }
67
+ },
68
+ a
69
+ ] : a;
70
+ },
71
+ addCommands() {
72
+ let e = this.parent?.();
73
+ return {
74
+ ...e,
75
+ setTableLayout: (e) => ({ editor: t, state: n, tr: i, dispatch: a }) => {
76
+ let o = m(n);
77
+ return !t.isEditable || !o || !r.includes(e) ? !1 : (a && o.node.attrs.tableLayout !== e && (i.setNodeMarkup(o.position, void 0, {
78
+ ...o.node.attrs,
79
+ tableLayout: e
80
+ }), e === "fit" && i.setMeta(f, { setHandle: -1 })), !0);
81
+ },
82
+ setTableHeightLimit: (e) => ({ editor: t, state: n, tr: r, dispatch: i }) => {
83
+ let a = m(n);
84
+ return !t.isEditable || !a || typeof e != "boolean" ? !1 : (i && a.node.attrs.limitHeight !== e && r.setNodeMarkup(a.position, void 0, {
85
+ ...a.node.attrs,
86
+ limitHeight: e
87
+ }), !0);
88
+ },
89
+ setTableMaxHeight: (e) => ({ editor: n, tr: r, dispatch: i }) => {
90
+ let a = m(r);
91
+ if (!n.isEditable || !a || e !== null && (typeof e != "number" || t(e) === null)) return !1;
92
+ if (i && a.node.attrs.maxHeight !== e) {
93
+ let t = r.selection instanceof u && r.selection.node === a.node;
94
+ r.setNodeMarkup(a.position, void 0, {
95
+ ...a.node.attrs,
96
+ maxHeight: e
97
+ }), t && r.setSelection(u.create(r.doc, a.position));
98
+ }
99
+ return !0;
100
+ },
101
+ setTableStickyHeaderRow: (e) => ({ editor: t, state: n, tr: r, dispatch: i }) => {
102
+ let a = m(n);
103
+ return !t.isEditable || !a || typeof e != "boolean" || e && !c(a.node) ? !1 : (i && a.node.attrs.stickyHeaderRow !== e && r.setNodeMarkup(a.position, void 0, {
104
+ ...a.node.attrs,
105
+ stickyHeaderRow: e
106
+ }), !0);
107
+ },
108
+ insertTable: (t = {}) => (n) => {
109
+ if (_(n.state.selection)) return !1;
110
+ let r = e?.insertTable?.(t)(n) ?? !1;
111
+ if (r && n.dispatch) {
112
+ let e = m(n.tr);
113
+ e && c(e.node) && n.tr.setNodeMarkup(e.position, void 0, {
114
+ ...e.node.attrs,
115
+ stickyHeaderRow: !0
116
+ });
117
+ }
118
+ return r;
119
+ }
120
+ };
121
+ },
122
+ onUpdate() {
123
+ if (this.editor.isEditable) return;
124
+ let e = f.getState(this.editor.state);
125
+ e && (e.activeHandle > -1 || e.dragging) && this.editor.view.dispatch(this.editor.state.tr.setMeta(f, { setHandle: -1 }));
126
+ },
127
+ addProseMirrorPlugins() {
128
+ let e = {
129
+ handleWidth: this.options.handleWidth,
130
+ cellMinWidth: this.options.cellMinWidth,
131
+ defaultCellMinWidth: this.options.cellMinWidth,
132
+ View: this.options.View,
133
+ lastColumnResizable: this.options.lastColumnResizable
134
+ }, t = d(e), n = t.props.handleDOMEvents, r = d({
135
+ ...e,
136
+ defaultCellMinWidth: 128
137
+ }), i = r.props.handleDOMEvents.mousedown;
138
+ return t.props.handleDOMEvents = {
139
+ ...n,
140
+ mousemove: (e, r) => {
141
+ if (h(r) === "fit") {
142
+ let t = f.getState(e.state);
143
+ return t && t.activeHandle > -1 && !t.dragging && e.dispatch(e.state.tr.setMeta(f, { setHandle: -1 })), !1;
144
+ }
145
+ return n.mousemove?.call(t, e, r);
146
+ },
147
+ mousedown: (e, a) => {
148
+ let o = h(a);
149
+ return o === "fit" ? !1 : o === "scroll" ? i.call(r, e, a) : n.mousedown?.call(t, e, a);
150
+ }
151
+ }, [
152
+ t,
153
+ p({ allowTableNodeSelection: this.options.allowTableNodeSelection }),
154
+ l()
155
+ ];
156
+ },
157
+ addNodeView() {
158
+ return null;
159
+ }
160
+ }).configure({
161
+ resizable: !0,
162
+ View: a
163
+ });
164
+ //#endregion
165
+ export { v as ScribeTable, _ as selectionHasTableAncestor };
@@ -1,4 +1,4 @@
1
- import { n as e } from "../../../../resizable-table-JZOaj_L3.js";
1
+ import { selectionHasTableAncestor as e } from "../resizable-table.js";
2
2
  import { CalloutIcon as t } from "../../../../icons/CalloutIcon.js";
3
3
  import { jsx as n } from "react/jsx-runtime";
4
4
  //#region lib/components/Scribe/extension/slashCommand/items.tsx
@@ -0,0 +1,31 @@
1
+ import { TableView } from "@tiptap/extension-table";
2
+ import type { DOMOutputSpec, Node as ProseMirrorNode } from "@tiptap/pm/model";
3
+ import type { EditorView } from "@tiptap/pm/view";
4
+ export declare const SCRIBE_TABLE_LAYOUTS: readonly ["auto", "fit", "scroll"];
5
+ export type ScribeTableLayout = (typeof SCRIBE_TABLE_LAYOUTS)[number];
6
+ export declare const SCROLL_TABLE_COLUMN_WIDTH = 128;
7
+ export declare const MIN_TABLE_MAX_HEIGHT = 120;
8
+ export declare const MAX_TABLE_MAX_HEIGHT = 2000;
9
+ export declare const DEFAULT_TABLE_MAX_HEIGHT = 360;
10
+ export declare const normalizeTableMaxHeight: (value: unknown) => number | null;
11
+ export declare const normalizeTableLayout: (value: unknown) => ScribeTableLayout;
12
+ export declare const tableHasHeaderRow: (table: ProseMirrorNode) => boolean;
13
+ export declare const tableHasStickyHeader: (node: ProseMirrorNode) => boolean;
14
+ export declare const tableLayoutAttributes: (node: ProseMirrorNode) => {
15
+ "data-table-layout": "auto" | "fit" | "scroll";
16
+ "data-table-limit-height": string;
17
+ "data-table-sticky-header-row": string;
18
+ "data-table-sticky-header-active": string;
19
+ "data-table-max-height"?: string | undefined;
20
+ };
21
+ export declare const scrollTablePresentation: (node: ProseMirrorNode, cellMinWidth: number) => {
22
+ width: number;
23
+ colgroup: DOMOutputSpec;
24
+ };
25
+ /** Keep native column resizing, cell selection and the editable tbody intact. */
26
+ export declare class ScribeTableView extends TableView {
27
+ constructor(node: ProseMirrorNode, cellMinWidth: number, view?: EditorView);
28
+ update(node: ProseMirrorNode): boolean;
29
+ private applyLayout;
30
+ }
31
+ //# sourceMappingURL=table-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-layout.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/table-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,oBAAoB,YAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAC;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,MAAM,GAAG,IASjE,CAAC;AAEF,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,iBACE,CAAC;AAEzD,eAAO,MAAM,iBAAiB,UAAW,eAAe,YAevD,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,eAAe,YACM,CAAC;AAEjE,eAAO,MAAM,qBAAqB,SAAU,eAAe;;;;;;CAU1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAAU,eAAe,gBAAgB,MAAM;;cAmBvB,aAAa;CACxE,CAAC;AAEF,iFAAiF;AACjF,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,YAAY,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,EAGzE;IAED,MAAM,CAAC,IAAI,EAAE,eAAe,WAO3B;IAED,OAAO,CAAC,WAAW;CA8CpB"}
@@ -0,0 +1,2 @@
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../../../table-layout-BoDS50DR.js";
2
+ export { u as DEFAULT_TABLE_MAX_HEIGHT, o as MAX_TABLE_MAX_HEIGHT, c as MIN_TABLE_MAX_HEIGHT, i as SCRIBE_TABLE_LAYOUTS, e as SCROLL_TABLE_COLUMN_WIDTH, s as ScribeTableView, l as normalizeTableLayout, t as normalizeTableMaxHeight, a as scrollTablePresentation, d as tableHasHeaderRow, n as tableHasStickyHeader, r as tableLayoutAttributes };
@@ -0,0 +1,7 @@
1
+ import { Plugin } from "@tiptap/pm/state";
2
+ import type { EditorView } from "@tiptap/pm/view";
3
+ /** Keep native selection scrolling, with clearance for the actual pinned row. */
4
+ export declare const scrollSelectionBelowStickyHeader: (view: EditorView) => boolean;
5
+ /** Move the original header cells; no extra editable DOM or document state. */
6
+ export declare const createStickyTableHeaderPlugin: () => Plugin<any>;
7
+ //# sourceMappingURL=table-sticky-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-sticky-header.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/table-sticky-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0FlD,iFAAiF;AACjF,eAAO,MAAM,gCAAgC,SAAU,UAAU,YAuEhE,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,mBAsFtC,CAAC"}