@clevertask/scribe 0.1.24 → 0.1.26

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 (54) hide show
  1. package/README.md +48 -0
  2. package/dist/{BarMenu-DW95OBe1.js → BarMenu-BGWT4Oyk.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +1 -1
  5. package/dist/components/Menu/BubbleMenu.js +2 -2
  6. package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
  7. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  8. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  9. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  10. package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
  11. package/dist/components/Scribe/extension/callout.js +1 -1
  12. package/dist/components/Scribe/extension/emoji/suggest.js +2 -2
  13. package/dist/components/Scribe/extension/extension-link.js +1 -1
  14. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  15. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  16. package/dist/components/Scribe/extension/external-link-preview/commands.js +1 -1
  17. package/dist/components/Scribe/extension/external-link-preview/index.js +1 -1
  18. package/dist/components/Scribe/extension/external-link-preview/node-view.js +1 -1
  19. package/dist/components/Scribe/extension/external-link-preview/render-html.js +1 -1
  20. package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
  21. package/dist/components/Scribe/extension/index.js +1 -1
  22. package/dist/components/Scribe/extension/resizable-table.d.ts +2 -0
  23. package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
  24. package/dist/components/Scribe/extension/resizable-table.js +2 -2
  25. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  26. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/slashCommand/items.js +35 -33
  28. package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
  29. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  30. package/dist/components/Scribe/index.js +4 -4
  31. package/dist/{dist-_L8dTDsy.js → dist-BiognBi4.js} +3 -2
  32. package/dist/{dist-Cer8ra_P.js → dist-Dk0fXvrc.js} +1 -1
  33. package/dist/{dist-ClNucvAM.js → dist-xjmWZ-oh.js} +785 -785
  34. package/dist/{extension-B7i7CZ1Y.js → extension-BFPlsViw.js} +1 -1
  35. package/dist/{extension-link-BQrkQZHi.js → extension-link-DmM_EJTn.js} +1 -1
  36. package/dist/{html-to-markdown-CKpceHDk.js → html-to-markdown-BpR-7GtJ.js} +1 -1
  37. package/dist/main.js +2 -2
  38. package/dist/{markdown-to-html-zj2j0HLf.js → markdown-to-html-BoK5O_j-.js} +183 -143
  39. package/dist/{menus-BhM4ctz2.js → menus-BDXjZsFU.js} +2 -2
  40. package/dist/{purify.es-CpMrJENN.js → purify.es-q6CUdJQi.js} +251 -190
  41. package/dist/{resizable-table-DgMCiXeO.js → resizable-table-JZOaj_L3.js} +88 -78
  42. package/dist/{schema-extensions-ggKYCkRf.js → schema-extensions-BryyErmk.js} +6 -6
  43. package/dist/schema-extensions.js +1 -1
  44. package/dist/schema.d.ts +1 -0
  45. package/dist/schema.d.ts.map +1 -1
  46. package/dist/schema.js +5 -4
  47. package/dist/table-transforms.d.ts +58 -0
  48. package/dist/table-transforms.d.ts.map +1 -0
  49. package/dist/table-transforms.js +166 -0
  50. package/dist/{tippy.esm-8vSV0zL7.js → tippy.esm-MjWnmeEn.js} +0 -3
  51. package/dist/utils/html-to-markdown.js +1 -1
  52. package/dist/utils/index.js +4 -4
  53. package/dist/utils/markdown-to-html.js +1 -1
  54. package/package.json +11 -11
@@ -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 };
@@ -1600,7 +1600,6 @@ function on(e, t) {
1600
1600
  clearTimeout(r), clearTimeout(i), cancelAnimationFrame(a);
1601
1601
  }
1602
1602
  function pe(t) {
1603
- /* istanbul ignore else */
1604
1603
  if (process.env.NODE_ENV !== "production" && Q(y.state.isDestroyed, Ft("setProps")), !y.state.isDestroyed) {
1605
1604
  N("onBeforeUpdate", [y, t]), G();
1606
1605
  var n = y.props, r = Jt(e, Object.assign({}, n, gt(t), { ignoreAttributes: !0 }));
@@ -1653,7 +1652,6 @@ function on(e, t) {
1653
1652
  process.env.NODE_ENV !== "production" && Q(y.state.isDestroyed, Ft("hideWithInteractivity")), k().addEventListener("mousemove", m), ft(rn, m), m(e);
1654
1653
  }
1655
1654
  function X() {
1656
- /* istanbul ignore else */
1657
1655
  process.env.NODE_ENV !== "production" && Q(y.state.isDestroyed, Ft("unmount")), y.state.isVisible && y.hide(), y.state.isMounted && (se(), q().forEach(function(e) {
1658
1656
  e._tippy.unmount();
1659
1657
  }), x.parentNode && x.parentNode.removeChild(x), an = an.filter(function(e) {
@@ -1661,7 +1659,6 @@ function on(e, t) {
1661
1659
  }), y.state.isMounted = !1, N("onHidden", [y]));
1662
1660
  }
1663
1661
  function _e() {
1664
- /* istanbul ignore else */
1665
1662
  process.env.NODE_ENV !== "production" && Q(y.state.isDestroyed, Ft("destroy")), !y.state.isDestroyed && (y.clearDelayTimeouts(), y.unmount(), G(), delete e._tippy, y.state.isDestroyed = !0, N("onDestroy", [y]));
1666
1663
  }
1667
1664
  }
@@ -1,2 +1,2 @@
1
- import { t as e } from "../html-to-markdown-CKpceHDk.js";
1
+ import { t as e } from "../html-to-markdown-BpR-7GtJ.js";
2
2
  export { e as html2md };
@@ -1,9 +1,9 @@
1
- import { t as e } from "../dist-ClNucvAM.js";
2
- import { t } from "../html-to-markdown-CKpceHDk.js";
3
- import { t as n } from "../markdown-to-html-zj2j0HLf.js";
1
+ import { t as e } from "../dist-xjmWZ-oh.js";
2
+ import { t } from "../html-to-markdown-BpR-7GtJ.js";
3
+ import { t as n } from "../markdown-to-html-BoK5O_j-.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-BFPlsViw.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({
@@ -1,2 +1,2 @@
1
- import { t as e } from "../markdown-to-html-zj2j0HLf.js";
1
+ import { t as e } from "../markdown-to-html-BoK5O_j-.js";
2
2
  export { e as md2html };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
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": [
@@ -56,16 +56,16 @@
56
56
  "@tiptap/react": "3.31.3",
57
57
  "@tiptap/suggestion": "3.31.3",
58
58
  "clsx": "^2.1.1",
59
- "dompurify": "^3.4.15",
60
- "katex": "^0.18.7",
61
- "marked": "^18.0.12",
59
+ "dompurify": "^3.4.16",
60
+ "katex": "^0.18.9",
61
+ "marked": "^18.0.14",
62
62
  "tippy.js": "^6.3.7",
63
63
  "turndown": "^7.2.4"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@playwright/test": "^1.63.0",
67
67
  "@radix-ui/themes": "^3.3.0",
68
- "@testing-library/dom": "^10.4.1",
68
+ "@testing-library/dom": "^10.4.2",
69
69
  "@testing-library/jest-dom": "^7.0.1",
70
70
  "@testing-library/react": "^16.3.3",
71
71
  "@tiptap/extension-blockquote": "3.31.3",
@@ -107,20 +107,20 @@
107
107
  "@tiptap/pm": "3.31.3",
108
108
  "@tiptap/starter-kit": "3.31.3",
109
109
  "@types/lodash": "^4.17.25",
110
- "@types/node": "^24.13.4",
110
+ "@types/node": "^24.19.0",
111
111
  "@types/react": "^19.3.0",
112
112
  "@types/react-dom": "^19.3.0",
113
113
  "@types/turndown": "^5.0.6",
114
114
  "@vitejs/plugin-react": "^6.1.1",
115
115
  "glob": "^13.0.6",
116
- "jsdom": "^30.0.1",
116
+ "jsdom": "^30.1.1",
117
117
  "lodash": "^4.18.1",
118
- "oxfmt": "^0.67.0",
119
- "oxlint": "^1.82.0",
118
+ "oxfmt": "^0.70.0",
119
+ "oxlint": "^1.85.0",
120
120
  "typescript": "~7.0.2",
121
- "vite": "^8.3.0",
121
+ "vite": "^8.3.1",
122
122
  "vite-plugin-lib-inject-css": "^2.2.2",
123
- "vitest": "^5.0.0"
123
+ "vitest": "^5.0.2"
124
124
  },
125
125
  "peerDependencies": {
126
126
  "@radix-ui/themes": ">=3.3.0",