@clevertask/scribe 0.1.4 → 0.1.5

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 (85) hide show
  1. package/README.md +3 -0
  2. package/dist/BarMenu-V1uRL3bt.js +272 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/BarMenu.js +2 -10
  6. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  7. package/dist/components/Menu/BubbleMenu.js +165 -1023
  8. package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
  9. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
  10. package/dist/components/Menu/LinkBubbleMenu.js +78 -0
  11. package/dist/components/Menu/LinkEditor.d.ts +14 -0
  12. package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
  13. package/dist/components/Menu/LinkEditor.js +140 -0
  14. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
  16. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
  17. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
  18. package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
  19. package/dist/components/Menu/linkUrl.d.ts +2 -0
  20. package/dist/components/Menu/linkUrl.d.ts.map +1 -0
  21. package/dist/components/Menu/linkUrl.js +21 -0
  22. package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
  23. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
  24. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
  26. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/extension-link.js +2 -4
  28. package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
  29. package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
  30. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
  32. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
  33. package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
  34. package/dist/components/Scribe/extension/index.d.ts +4 -4
  35. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/extension/index.js +2 -39521
  37. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
  38. package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
  39. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  40. package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
  41. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  42. package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
  43. package/dist/components/Scribe/extension/tableOfContents.js +153 -180
  44. package/dist/components/Scribe/index.d.ts.map +1 -1
  45. package/dist/components/Scribe/index.js +113 -153
  46. package/dist/dist-BQjH-i-q.js +7016 -0
  47. package/dist/dist-CnXCIcnl.js +3506 -0
  48. package/dist/dist-RuuEA1GJ.js +686 -0
  49. package/dist/extension-CZOsheCI.js +56236 -0
  50. package/dist/extension-link-DZID_SYl.js +908 -0
  51. package/dist/floating-ui.dom-rih69525.js +928 -0
  52. package/dist/html-to-markdown-CrNOkSye.js +497 -0
  53. package/dist/icons/ToolbarIcons.d.ts.map +1 -1
  54. package/dist/icons/ToolbarIcons.js +76 -135
  55. package/dist/main.css +10 -0
  56. package/dist/main.js +7 -15
  57. package/dist/markdown-to-html-DEczPfuq.js +1458 -0
  58. package/dist/menus-CzX7kyXn.js +633 -0
  59. package/dist/purify.es-DF9CW1cl.js +767 -0
  60. package/dist/rolldown-runtime-B8UxIWdF.js +7 -0
  61. package/dist/slashCommand-B7CRIaKG.js +429 -0
  62. package/dist/tables-CjOC70rm.js +1345 -0
  63. package/dist/tippy.esm-D9LL2xiE.js +1713 -0
  64. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
  65. package/dist/utils/convert-legacy-math-delimiters.js +7 -13
  66. package/dist/utils/create-scribe-editor.js +2 -31
  67. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  68. package/dist/utils/html-to-markdown.js +2 -600
  69. package/dist/utils/index.js +24 -12
  70. package/dist/utils/is-in-viewport.d.ts.map +1 -1
  71. package/dist/utils/is-in-viewport.js +6 -6
  72. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  73. package/dist/utils/markdown-to-html.js +2 -5
  74. package/dist/vite-env.d.js +0 -1
  75. package/package.json +36 -34
  76. package/dist/BarMenu-BNk2I0zi.js +0 -327
  77. package/dist/extension-link-P1rro4zO.js +0 -1059
  78. package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
  79. package/dist/index-BMISMQrG.js +0 -855
  80. package/dist/index-ByyiiYsp.js +0 -1410
  81. package/dist/index-CnKS-BY2.js +0 -13834
  82. package/dist/index-CnQHDObA.js +0 -539
  83. package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
  84. package/dist/purify.es-DC1iJOxX.js +0 -864
  85. package/dist/tippy.esm-DLHdsnfG.js +0 -1711
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  A versatile, block-based rich text editor for diverse applications, built with Tiptap and inspired by Notion's intuitive interface. `@clevertask/scribe` allows you to seamlessly view, create, and edit rich text content, with added support for Markdown parsing.
4
4
 
5
+ > [!WARNING]
6
+ > Scribe is experimental and has not reached version 1.0. Its APIs, default extensions, editor behavior, and built-in UI can change between releases, including minor releases. Pin an exact package version and test each upgrade before deployment. Forks and contributions are welcome.
7
+
5
8
  ## Features
6
9
 
7
10
  - **Block-based Editing:** Enjoy a familiar and intuitive Notion-style editing experience.
@@ -0,0 +1,272 @@
1
+ import { i as e } from "./dist-RuuEA1GJ.js";
2
+ import { getPopupMountTarget as t } from "./components/Scribe/extension/getPopupMountTarget.js";
3
+ import n from "./components/Menu/LinkEditor.js";
4
+ import { hideLinkBubbleMenu as r } from "./components/Menu/linkBubbleMenuPlugin.js";
5
+ import { BlockQuoteIcon as i, BoldIcon as a, CodeBlockIcon as o, HighlightIcon as s, HorizontalLineIcon as c, ImageIcon as l, InlineCodeIcon as u, ItalicIcon as d, LinkIcon as f, OrderedListIcon as p, StrikeIcon as m, UnorderedListIcon as h } from "./icons/ToolbarIcons.js";
6
+ import { Box as g, Button as _, Flex as v, IconButton as y, Popover as b, Separator as x, Text as S, TextField as C } from "@radix-ui/themes";
7
+ import { Fragment as w, useCallback as T, useState as E } from "react";
8
+ import { jsx as D, jsxs as O } from "react/jsx-runtime";
9
+ //#region node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
10
+ function k(e) {
11
+ var t, n, r = "";
12
+ if (typeof e == "string" || typeof e == "number") r += e;
13
+ else if (typeof e == "object") if (Array.isArray(e)) {
14
+ var i = e.length;
15
+ for (t = 0; t < i; t++) e[t] && (n = k(e[t])) && (r && (r += " "), r += n);
16
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
17
+ return r;
18
+ }
19
+ function A() {
20
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = k(e)) && (r && (r += " "), r += t);
21
+ return r;
22
+ }
23
+ //#endregion
24
+ //#region lib/components/Menu/BarMenu.tsx
25
+ var j = ({ editor: k }) => {
26
+ let [j, M] = E(!1), [N, P] = E(!1), [F, I] = E(""), [L, R] = E(""), z = t(k), B = e({
27
+ editor: k,
28
+ selector: ({ editor: e }) => e ? {
29
+ isBold: e.isActive("bold"),
30
+ isItalic: e.isActive("italic"),
31
+ isStrike: e.isActive("strike"),
32
+ isCode: e.isActive("code"),
33
+ isHighlight: e.isActive("highlight"),
34
+ isBulletList: e.isActive("bulletList"),
35
+ isOrderedList: e.isActive("orderedList"),
36
+ isLink: e.isActive("link"),
37
+ isImage: e.isActive("image"),
38
+ isCodeBlock: e.isActive("codeBlock"),
39
+ isBlockquote: e.isActive("blockquote")
40
+ } : null
41
+ }), V = T((e) => {
42
+ if (e) {
43
+ r(k);
44
+ let e = k.getAttributes("link").href ?? "";
45
+ I(e), P(!1);
46
+ }
47
+ M(e);
48
+ }, [k]), H = T((e) => {
49
+ if (e) {
50
+ r(k);
51
+ let e = k.getAttributes("image").src ?? "";
52
+ R(e), M(!1);
53
+ }
54
+ P(e);
55
+ }, [k]), U = T(() => {
56
+ let e = L.trim();
57
+ e && (k.chain().focus().setImage({ src: e }).run(), P(!1));
58
+ }, [k, L]), W = T((e, t) => {
59
+ e.preventDefault(), t();
60
+ }, []), G = T((e) => {
61
+ e.preventDefault();
62
+ }, []), K = T(({ target: { value: e } }) => {
63
+ R(e);
64
+ }, []), q = [
65
+ [
66
+ {
67
+ name: "bold",
68
+ icon: a,
69
+ command: () => k.chain().focus().toggleBold().run(),
70
+ isActive: () => !!B?.isBold
71
+ },
72
+ {
73
+ name: "italic",
74
+ icon: d,
75
+ command: () => k.chain().focus().toggleItalic().run(),
76
+ isActive: () => !!B?.isItalic
77
+ },
78
+ {
79
+ name: "strike",
80
+ icon: m,
81
+ command: () => k.chain().focus().toggleStrike().run(),
82
+ isActive: () => !!B?.isStrike
83
+ }
84
+ ],
85
+ [{
86
+ name: "inline-code",
87
+ icon: u,
88
+ command: () => k.chain().focus().toggleCode().run(),
89
+ isActive: () => !!B?.isCode
90
+ }, {
91
+ name: "highlight",
92
+ icon: s,
93
+ command: () => k.chain().focus().toggleHighlight().run(),
94
+ isActive: () => !!B?.isHighlight
95
+ }],
96
+ [{
97
+ name: "unordered-list",
98
+ icon: h,
99
+ command: () => k.chain().focus().toggleBulletList().run(),
100
+ isActive: () => !!B?.isBulletList
101
+ }, {
102
+ name: "ordered-list",
103
+ icon: p,
104
+ command: () => k.chain().focus().toggleOrderedList().run(),
105
+ isActive: () => !!B?.isOrderedList
106
+ }],
107
+ [
108
+ {
109
+ name: "link",
110
+ icon: f,
111
+ isActive: () => !!B?.isLink,
112
+ popover: "link"
113
+ },
114
+ {
115
+ name: "image",
116
+ icon: l,
117
+ isActive: () => !!B?.isImage,
118
+ disabled: !1,
119
+ popover: "image"
120
+ },
121
+ {
122
+ name: "code-block",
123
+ icon: o,
124
+ command: () => k.chain().focus().toggleCodeBlock().run(),
125
+ isActive: () => !!B?.isCodeBlock
126
+ },
127
+ {
128
+ name: "block-quote",
129
+ icon: i,
130
+ command: () => k.chain().focus().toggleBlockquote().run(),
131
+ isActive: () => !!B?.isBlockquote
132
+ },
133
+ {
134
+ name: "horizontal-line",
135
+ icon: c,
136
+ command: () => k.chain().focus().setHorizontalRule().run(),
137
+ isActive: () => !1
138
+ }
139
+ ]
140
+ ];
141
+ return /* @__PURE__ */ D(g, {
142
+ className: "scribe-toolbar",
143
+ children: /* @__PURE__ */ D(v, {
144
+ align: "center",
145
+ gap: "3",
146
+ wrap: "wrap",
147
+ children: q.map((e, t) => /* @__PURE__ */ O(w, { children: [/* @__PURE__ */ D(v, {
148
+ align: "center",
149
+ gap: "2",
150
+ wrap: "wrap",
151
+ children: e.map((e, t) => e.popover === "link" ? /* @__PURE__ */ O(b.Root, {
152
+ open: j,
153
+ onOpenChange: V,
154
+ children: [/* @__PURE__ */ D(b.Trigger, { children: /* @__PURE__ */ D(y, {
155
+ type: "button",
156
+ radius: "medium",
157
+ color: "gray",
158
+ variant: e.isActive() ? "soft" : "ghost",
159
+ disabled: e.disabled || !k.isEditable,
160
+ title: e.name,
161
+ onMouseDown: G,
162
+ className: A(e.disabled && "scribe-toolbar-button--disabled"),
163
+ children: /* @__PURE__ */ D(e.icon, { className: "scribe-toolbar-icon" })
164
+ }) }), /* @__PURE__ */ D(b.Content, {
165
+ container: z,
166
+ size: "2",
167
+ side: "bottom",
168
+ align: "start",
169
+ style: {
170
+ maxWidth: "calc(100vw - 32px)",
171
+ width: 320
172
+ },
173
+ children: /* @__PURE__ */ D(n, {
174
+ editor: k,
175
+ existingHref: k.getAttributes("link").href ?? "",
176
+ onClose: () => M(!1),
177
+ onValueChange: I,
178
+ selectTextblockEndAfterSave: !0,
179
+ value: F
180
+ })
181
+ })]
182
+ }, `${e.name}-${t}`) : e.popover === "image" ? /* @__PURE__ */ O(b.Root, {
183
+ open: N,
184
+ onOpenChange: H,
185
+ children: [/* @__PURE__ */ D(b.Trigger, { children: /* @__PURE__ */ D(y, {
186
+ type: "button",
187
+ radius: "medium",
188
+ color: "gray",
189
+ variant: e.isActive() ? "soft" : "ghost",
190
+ disabled: e.disabled || !k.isEditable,
191
+ title: e.name,
192
+ onMouseDown: G,
193
+ className: A(e.disabled && "scribe-toolbar-button--disabled"),
194
+ children: /* @__PURE__ */ D(e.icon, { className: "scribe-toolbar-icon" })
195
+ }) }), /* @__PURE__ */ D(b.Content, {
196
+ container: z,
197
+ size: "2",
198
+ side: "bottom",
199
+ align: "start",
200
+ style: {
201
+ maxWidth: "calc(100vw - 32px)",
202
+ width: 320
203
+ },
204
+ children: /* @__PURE__ */ O(v, {
205
+ direction: "column",
206
+ gap: "4",
207
+ children: [
208
+ /* @__PURE__ */ O(g, { children: [/* @__PURE__ */ D(S, {
209
+ as: "p",
210
+ size: "3",
211
+ weight: "medium",
212
+ children: "Image"
213
+ }), /* @__PURE__ */ D(S, {
214
+ as: "p",
215
+ size: "2",
216
+ color: "gray",
217
+ children: "Insert an image from a URL."
218
+ })] }),
219
+ /* @__PURE__ */ D("label", { children: /* @__PURE__ */ O(v, {
220
+ direction: "column",
221
+ gap: "2",
222
+ children: [/* @__PURE__ */ D(S, {
223
+ as: "span",
224
+ size: "2",
225
+ weight: "medium",
226
+ children: "Image URL"
227
+ }), /* @__PURE__ */ D(C.Root, {
228
+ autoFocus: !0,
229
+ placeholder: "https://example.com/image.png",
230
+ value: L,
231
+ onChange: K
232
+ })]
233
+ }) }),
234
+ /* @__PURE__ */ O(v, {
235
+ justify: "end",
236
+ gap: "2",
237
+ children: [/* @__PURE__ */ D(b.Close, { children: /* @__PURE__ */ D(_, {
238
+ type: "button",
239
+ variant: "soft",
240
+ color: "gray",
241
+ children: "Cancel"
242
+ }) }), /* @__PURE__ */ D(_, {
243
+ type: "button",
244
+ disabled: L.trim().length === 0,
245
+ onClick: U,
246
+ children: "Save"
247
+ })]
248
+ })
249
+ ]
250
+ })
251
+ })]
252
+ }, `${e.name}-${t}`) : /* @__PURE__ */ D(y, {
253
+ type: "button",
254
+ radius: "medium",
255
+ color: "gray",
256
+ variant: e.isActive() ? "soft" : "ghost",
257
+ disabled: e.disabled || !k.isEditable,
258
+ title: e.name,
259
+ onMouseDown: (t) => W(t, e.command),
260
+ className: A(e.disabled && "scribe-toolbar-button--disabled"),
261
+ children: /* @__PURE__ */ D(e.icon, { className: "scribe-toolbar-icon" })
262
+ }, `${e.name}-${t}`))
263
+ }), t === q.length - 1 ? null : /* @__PURE__ */ D(x, {
264
+ orientation: "vertical",
265
+ decorative: !0,
266
+ style: { height: 20 }
267
+ })] }, `format-group-${t}`))
268
+ })
269
+ });
270
+ };
271
+ //#endregion
272
+ export { A as n, j as t };