@clevertask/scribe 0.1.23 → 0.1.25

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 (47) hide show
  1. package/README.md +53 -0
  2. package/dist/{BarMenu-DW95OBe1.js → BarMenu-CP5BJhc-.js} +1 -1
  3. package/dist/components/Menu/BarMenu.js +1 -1
  4. package/dist/components/Menu/BubbleMenu.js +2 -2
  5. package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
  6. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  7. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  8. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  9. package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
  10. package/dist/components/Scribe/extension/callout.js +1 -1
  11. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  12. package/dist/components/Scribe/extension/extension-link.js +1 -1
  13. package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
  14. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  15. package/dist/components/Scribe/extension/external-link-preview/commands.js +1 -1
  16. package/dist/components/Scribe/extension/external-link-preview/index.js +1 -1
  17. package/dist/components/Scribe/extension/external-link-preview/node-view.js +1 -1
  18. package/dist/components/Scribe/extension/external-link-preview/render-html.js +1 -1
  19. package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
  20. package/dist/components/Scribe/extension/index.js +1 -1
  21. package/dist/components/Scribe/extension/resizable-table.d.ts +2 -0
  22. package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
  23. package/dist/components/Scribe/extension/resizable-table.js +2 -2
  24. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  25. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  26. package/dist/components/Scribe/extension/slashCommand/items.js +35 -33
  27. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  28. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  29. package/dist/components/Scribe/index.js +3 -3
  30. package/dist/{dist-_L8dTDsy.js → dist-Cwbl2Okw.js} +1 -1
  31. package/dist/{dist-Cer8ra_P.js → dist-Dk0fXvrc.js} +1 -1
  32. package/dist/{dist-ClNucvAM.js → dist-xjmWZ-oh.js} +785 -785
  33. package/dist/document-node-capabilities.js +4 -1
  34. package/dist/{extension-B7i7CZ1Y.js → extension-9Oc-QD39.js} +1 -1
  35. package/dist/{extension-link-BQrkQZHi.js → extension-link-DmM_EJTn.js} +1 -1
  36. package/dist/{menus-BhM4ctz2.js → menus-B0uyLVhs.js} +2 -2
  37. package/dist/{resizable-table-DgMCiXeO.js → resizable-table-JZOaj_L3.js} +88 -78
  38. package/dist/{schema-extensions-ggKYCkRf.js → schema-extensions-LzyMpyWW.js} +4 -4
  39. package/dist/schema-extensions.js +1 -1
  40. package/dist/schema.d.ts +1 -0
  41. package/dist/schema.d.ts.map +1 -1
  42. package/dist/schema.js +5 -4
  43. package/dist/table-transforms.d.ts +58 -0
  44. package/dist/table-transforms.d.ts.map +1 -0
  45. package/dist/table-transforms.js +166 -0
  46. package/dist/utils/index.js +2 -2
  47. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import { EditorState as e } from "@tiptap/pm/state";
2
+ import { CellSelection as t, TableMap as n, addColumn as r, addRow as i, mergeCells as a, removeColumn as o, removeRow as s, splitCell as c } from "@tiptap/pm/tables";
3
+ //#region lib/table-transforms.ts
4
+ var l = class extends Error {
5
+ code;
6
+ cause;
7
+ constructor(e, t, n) {
8
+ super(t), this.name = "ScribeTableTransformError", this.code = e, this.cause = n;
9
+ }
10
+ }, u = (e, t, n) => {
11
+ throw new l(e, t, n);
12
+ }, d = (e) => typeof e == "object" && !!e && !Array.isArray(e), f = (e, t) => {
13
+ let n = Object.keys(e).sort(), r = [...t].sort();
14
+ return n.length === r.length && n.every((e, t) => e === r[t]);
15
+ }, p = (e, t, n) => {
16
+ f(e, t) || u("invalid_input", `${n} must contain exactly: ${t.join(", ")}.`);
17
+ }, m = (e, t, n, r) => {
18
+ (typeof e != "number" || !Number.isInteger(e) || e < t || e > n) && u("invalid_input", `${r} must be an integer from ${t} to ${n}.`);
19
+ }, h = (e) => {
20
+ d(e) || u("invalid_input", "The table operation must be an object with a supported type.");
21
+ let t = e;
22
+ if (typeof t.type != "string" && u("invalid_input", "The table operation must be an object with a supported type."), t.type === "insert_row" || t.type === "delete_row" || t.type === "insert_column" || t.type === "delete_column") return p(t, ["type", "index"], "The table operation"), typeof t.index != "number" && u("invalid_input", "The table operation index must be a number."), {
23
+ type: t.type,
24
+ index: t.index
25
+ };
26
+ if (t.type === "merge_cells") {
27
+ p(t, ["type", "rectangle"], "The merge operation"), d(t.rectangle) || u("invalid_input", "The merge rectangle must be an object.");
28
+ let e = t.rectangle;
29
+ p(e, [
30
+ "topRow",
31
+ "leftColumn",
32
+ "bottomRowExclusive",
33
+ "rightColumnExclusive"
34
+ ], "The merge rectangle");
35
+ let { topRow: n, leftColumn: r, bottomRowExclusive: i, rightColumnExclusive: a } = e;
36
+ return (typeof n != "number" || typeof r != "number" || typeof i != "number" || typeof a != "number") && u("invalid_input", "Every merge rectangle coordinate must be a number."), {
37
+ type: "merge_cells",
38
+ rectangle: {
39
+ topRow: n,
40
+ leftColumn: r,
41
+ bottomRowExclusive: i,
42
+ rightColumnExclusive: a
43
+ }
44
+ };
45
+ }
46
+ return t.type === "split_cell" ? (p(t, [
47
+ "type",
48
+ "row",
49
+ "column"
50
+ ], "The split operation"), (typeof t.row != "number" || typeof t.column != "number") && u("invalid_input", "The split cell row and column must be numbers."), {
51
+ type: "split_cell",
52
+ row: t.row,
53
+ column: t.column
54
+ }) : u("invalid_input", `Unsupported table operation type: ${String(t.type)}.`);
55
+ }, g = (e) => {
56
+ (typeof e != "object" || !e || typeof e.check != "function" || typeof e.nodeAt != "function" || typeof e.resolve != "function") && u("invalid_input", "The document must be a ProseMirror document node.");
57
+ try {
58
+ e.check();
59
+ } catch (e) {
60
+ u("unsupported_structure", "The document has an invalid ProseMirror structure.", e);
61
+ }
62
+ }, _ = (e) => {
63
+ let t = !1;
64
+ e.descendants((e) => {
65
+ if (e.type.spec.tableRole === "table") return t = !0, !1;
66
+ }), t && u("unsupported_structure", "The target table contains a nested table.");
67
+ }, v = (e, t) => {
68
+ (!Number.isInteger(t) || t < 0 || t > e.content.size) && u("invalid_target", `Table position must be an integer from 0 to ${e.content.size}.`);
69
+ let r = e.nodeAt(t);
70
+ r?.type.spec.tableRole !== "table" && u("invalid_target", "The target position does not point to a table.");
71
+ let i = r, a = e.resolve(t);
72
+ for (let e = a.depth; e > 0; --e) a.node(e).type.spec.tableRole === "table" && u("unsupported_structure", "A nested table cannot be transformed.");
73
+ _(i);
74
+ let o;
75
+ try {
76
+ o = n.get(i);
77
+ } catch (e) {
78
+ u("unsupported_structure", "The target table geometry could not be resolved.", e);
79
+ }
80
+ o || u("unsupported_structure", "The target table geometry could not be resolved.");
81
+ let s = o;
82
+ return s.problems && s.problems.length > 0 && u("unsupported_structure", "The target table has malformed geometry."), {
83
+ table: i,
84
+ map: s,
85
+ tableStart: t + 1,
86
+ top: 0,
87
+ left: 0,
88
+ bottom: s.height,
89
+ right: s.width
90
+ };
91
+ }, y = (e) => {
92
+ let t = 0;
93
+ return e.forEach((e) => {
94
+ t += e.childCount;
95
+ }), t;
96
+ }, b = (e, t) => ({
97
+ rows: t.height,
98
+ columns: t.width,
99
+ physicalCells: y(e)
100
+ }), x = (e, t, n) => e.map[t * e.width + n], S = (e, n, r, i = r) => e.apply(e.tr.setSelection(t.create(e.doc, n + r, n + i))), C = (e, t, n) => {
101
+ let r, i = !1;
102
+ try {
103
+ i = e(t, (e) => {
104
+ r = e;
105
+ });
106
+ } catch (e) {
107
+ u("invalid_result", "The table command failed while producing a transaction.", e);
108
+ }
109
+ return (!i || !r?.docChanged) && u("operation_not_applicable", n), r;
110
+ }, w = (e) => ({
111
+ top: e.topRow,
112
+ left: e.leftColumn,
113
+ bottom: e.bottomRowExclusive,
114
+ right: e.rightColumnExclusive
115
+ }), T = (e, t) => (m(e.topRow, 0, t.height - 1, "Merge top row"), m(e.leftColumn, 0, t.width - 1, "Merge left column"), m(e.bottomRowExclusive, 1, t.height, "Merge exclusive bottom row"), m(e.rightColumnExclusive, 1, t.width, "Merge exclusive right column"), (e.bottomRowExclusive <= e.topRow || e.rightColumnExclusive <= e.leftColumn) && u("invalid_input", "The merge rectangle must have a positive width and height."), w(e)), E = (e, t) => e.top === t.top && e.left === t.left && e.bottom === t.bottom && e.right === t.right, D = (e, t, n, r, i) => {
116
+ let o = T(i, n), s = x(n, o.top, o.left), c = x(n, o.bottom - 1, o.right - 1);
117
+ E(o, n.rectBetween(s, c)) || u("operation_not_applicable", "The merge rectangle partially crosses an existing cell span.");
118
+ let l = n.cellsInRect(o);
119
+ l.length < 2 && u("operation_not_applicable", "The merge rectangle must contain at least two cells.");
120
+ let d = /* @__PURE__ */ new Set();
121
+ for (let e of l) {
122
+ let n = t.nodeAt(e);
123
+ n || u("unsupported_structure", "The merge rectangle contains an unresolved cell."), d.add(String(n.type.spec.tableRole));
124
+ }
125
+ d.size !== 1 && u("operation_not_applicable", "Header and body cells cannot be merged together.");
126
+ let f = S(e, r, s, c);
127
+ return C(a, f, "The selected cells do not form a mergeable rectangle.");
128
+ }, O = (e, t, n, r, i, a) => {
129
+ m(i, 0, n.height - 1, "Split cell row"), m(a, 0, n.width - 1, "Split cell column");
130
+ let o = x(n, i, a), s = n.findCell(o);
131
+ (s.top !== i || s.left !== a) && u("operation_not_applicable", "A merged cell must be split from its top-left coordinate."), s.bottom - s.top === 1 && s.right - s.left === 1 && u("operation_not_applicable", "The selected cell is not merged and cannot be split."), t.nodeAt(o) || u("unsupported_structure", "The selected merged cell could not be resolved.");
132
+ let l = S(e, r, o);
133
+ return C(c, l, "The selected cell is not merged and cannot be split.");
134
+ }, k = (e, t, n) => {
135
+ let r = t.rows, i = t.columns;
136
+ e.type === "insert_row" && (r += 1), e.type === "delete_row" && --r, e.type === "insert_column" && (i += 1), e.type === "delete_column" && --i, (n.rows !== r || n.columns !== i) && u("invalid_result", "The table transform produced unexpected logical geometry."), n.physicalCells < 1 && u("invalid_result", "The table transform produced a table without cells."), e.type === "merge_cells" && n.physicalCells >= t.physicalCells && u("invalid_result", "The merge did not reduce the number of physical cells."), e.type === "split_cell" && n.physicalCells <= t.physicalCells && u("invalid_result", "The split did not increase the number of physical cells.");
137
+ }, A = (t, n, a) => {
138
+ g(t);
139
+ let c = h(a), l = e.create({
140
+ schema: t.type.schema,
141
+ doc: t
142
+ }), { map: d, table: f, tableStart: p } = v(t, n), _ = {
143
+ map: d,
144
+ table: f,
145
+ tableStart: p,
146
+ top: 0,
147
+ left: 0,
148
+ bottom: d.height,
149
+ right: d.width
150
+ }, y = b(f, d), x;
151
+ c.type === "insert_row" ? (m(c.index, 0, d.height, "Row insertion index"), x = i(l.tr, _, c.index)) : c.type === "delete_row" ? (m(c.index, 0, d.height - 1, "Row index"), d.height === 1 && u("operation_not_applicable", "The last table row cannot be deleted."), x = l.tr, s(x, _, c.index)) : c.type === "insert_column" ? (m(c.index, 0, d.width, "Column insertion index"), x = r(l.tr, _, c.index)) : c.type === "delete_column" ? (m(c.index, 0, d.width - 1, "Column index"), d.width === 1 && u("operation_not_applicable", "The last table column cannot be deleted."), x = l.tr, o(x, _, c.index)) : x = c.type === "merge_cells" ? D(l, f, d, p, c.rectangle) : O(l, f, d, p, c.row, c.column), x.docChanged || u("invalid_result", "The table transform did not change the document.");
152
+ try {
153
+ x.doc.check();
154
+ } catch (e) {
155
+ u("invalid_result", "The table transform produced an invalid document.", e);
156
+ }
157
+ let S = x.mapping.map(n, -1), C = v(x.doc, S), w = b(C.table, C.map);
158
+ return k(c, y, w), {
159
+ document: x.doc,
160
+ tablePosition: S,
161
+ before: y,
162
+ after: w
163
+ };
164
+ };
165
+ //#endregion
166
+ export { l as ScribeTableTransformError, A as applyScribeTableTransform };
@@ -1,9 +1,9 @@
1
- import { t as e } from "../dist-ClNucvAM.js";
1
+ import { t as e } from "../dist-xjmWZ-oh.js";
2
2
  import { t } from "../html-to-markdown-CKpceHDk.js";
3
3
  import { t as n } from "../markdown-to-html-zj2j0HLf.js";
4
4
  import { isInViewport as r } from "./is-in-viewport.js";
5
5
  import { convertLegacyMathDelimiters as i } from "./convert-legacy-math-delimiters.js";
6
- import { t as a } from "../extension-B7i7CZ1Y.js";
6
+ import { t as a } from "../extension-9Oc-QD39.js";
7
7
  //#region lib/utils/create-scribe-editor.ts
8
8
  function o({ content: n = "", editable: r = !1, enableUndoRedo: i, externalLinkPreview: o, onContentChange: s }) {
9
9
  return new e({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "private": false,
5
5
  "description": "A Radix-based Tiptap rich text editor with a Notion-style block interface for viewing and creating content. Perfect for diverse needs like notes, documents, AI chat, Markdown parsing, and comments.",
6
6
  "keywords": [