@clevertask/scribe 0.1.6 → 0.1.8

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 (44) hide show
  1. package/README.md +6 -4
  2. package/dist/{BarMenu-CXaFlpRJ.js → BarMenu-BG_w4DVo.js} +53 -25
  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 +1 -1
  6. package/dist/components/Menu/BubbleMenu.js +2 -2
  7. package/dist/components/Menu/LinkBubbleMenu.js +13 -13
  8. package/dist/components/Menu/LinkEditor.js +4 -4
  9. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  10. package/dist/components/Menu/Mobile/ListOptionBar.js +11 -5
  11. package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
  12. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts.map +1 -1
  13. package/dist/components/Scribe/extension/emoji/EmojiList.js +6 -2
  14. package/dist/components/Scribe/extension/emoji/suggest.js +2 -2
  15. package/dist/components/Scribe/extension/extension-link.js +1 -1
  16. package/dist/components/Scribe/extension/extension-markdown-paste.js +14 -6
  17. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  18. package/dist/components/Scribe/extension/index.js +1 -1
  19. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts.map +1 -1
  20. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +948 -943
  21. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  22. package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
  23. package/dist/components/Scribe/extension/tableOfContents.js +2 -2
  24. package/dist/components/Scribe/index.d.ts +6 -0
  25. package/dist/components/Scribe/index.d.ts.map +1 -1
  26. package/dist/components/Scribe/index.js +213 -76
  27. package/dist/{dist-BQjH-i-q.js → dist-BMKyBtRa.js} +112 -105
  28. package/dist/{dist-Cp938P7P.js → dist-BgEySLwo.js} +283 -146
  29. package/dist/{dist-CnXCIcnl.js → dist-FrapLVQu.js} +16 -9
  30. package/dist/{extension-CZOsheCI.js → extension-BVGWENts.js} +1306 -1300
  31. package/dist/{extension-link-DZID_SYl.js → extension-link-CMRfHUc5.js} +5 -5
  32. package/dist/{floating-ui.dom-rih69525.js → floating-ui.dom-CmJ6iBdh.js} +4 -5
  33. package/dist/{html-to-markdown-CrNOkSye.js → html-to-markdown-Cta7-ssO.js} +3 -2
  34. package/dist/main.js +2 -2
  35. package/dist/{markdown-to-html-DEczPfuq.js → markdown-to-html-DwSNqq2i.js} +8 -6
  36. package/dist/{menus-CakIdDdY.js → menus-D9OsP28c.js} +8 -8
  37. package/dist/{purify.es-DF9CW1cl.js → purify.es-CFiLaBu1.js} +1 -1
  38. package/dist/{slashCommand-B7CRIaKG.js → slashCommand-B6Iz1i0d.js} +5 -8
  39. package/dist/{tables-CjOC70rm.js → tables-CXpUVKdw.js} +9 -7
  40. package/dist/{tippy.esm-D9LL2xiE.js → tippy.esm-DOXqN1Qm.js} +2 -7
  41. package/dist/utils/html-to-markdown.js +1 -1
  42. package/dist/utils/index.js +4 -4
  43. package/dist/utils/markdown-to-html.js +1 -1
  44. package/package.json +49 -34
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../../../../slashCommand-B7CRIaKG.js";
1
+ import { n as e, t } from "../../../../slashCommand-B6Iz1i0d.js";
2
2
  export { t as SlashCommand, e as slashMenuPluginKey };
@@ -1,6 +1,6 @@
1
- import { n as e } from "../../../../dist-Cp938P7P.js";
1
+ import { n as e } from "../../../../dist-BgEySLwo.js";
2
2
  import { getPopupMountTarget as t } from "../getPopupMountTarget.js";
3
- import { t as n } from "../../../../tippy.esm-D9LL2xiE.js";
3
+ import { t as n } from "../../../../tippy.esm-DOXqN1Qm.js";
4
4
  import { SlashCommandList as r } from "./SlashCommandList.js";
5
5
  //#region lib/components/Scribe/extension/slashCommand/renderItems.ts
6
6
  var i = () => {
@@ -1,5 +1,5 @@
1
- import { a as e, i as t } from "../../../dist-CnXCIcnl.js";
2
- import { n } from "../../../dist-BQjH-i-q.js";
1
+ import { a as e, i as t } from "../../../dist-FrapLVQu.js";
2
+ import { n } from "../../../dist-BMKyBtRa.js";
3
3
  //#region lib/components/Scribe/extension/tableOfContents.ts
4
4
  var r = "scribeTableOfContents", i = new e("scribeTableOfContents"), a = 10, o = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "heading", s = (e, t) => {
5
5
  let n = t[t.length - 1], r = [...t].reverse().find((t) => t.originalLevel <= e.node.attrs.level)?.level || 1;
@@ -28,9 +28,15 @@ export interface ScribeProps {
28
28
  * `ScribeRef.setContent` for programmatic updates after mount.
29
29
  */
30
30
  content?: string;
31
+ /** Accessible name for the rich-text editing surface. */
32
+ ariaLabel?: string;
31
33
  editable?: boolean;
32
34
  autoFocus?: boolean;
33
35
  extensions?: Extension[];
36
+ /**
37
+ * A caller-owned editor. Scribe attaches it without taking responsibility
38
+ * for destroying it.
39
+ */
34
40
  externalEditor?: Editor;
35
41
  editorProps?: UseEditorOptions;
36
42
  showBarMenu?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Scribe/index.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,KAAK,EACV,kCAAkC,EAElC,iCAAiC,EAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EACP,MAAM,EAGN,SAAS,EACT,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,oBAAoB,EAMrB,MAAM,OAAO,CAAC;AAGf,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,yBAA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,mGAMlB,CAAC"}
@@ -1,9 +1,8 @@
1
- import { n as e, t } from "../../BarMenu-CXaFlpRJ.js";
2
- import { t as n } from "../../dist-Cp938P7P.js";
3
- import { t as r } from "../../dist-BQjH-i-q.js";
1
+ import { n as e, t } from "../../BarMenu-BG_w4DVo.js";
2
+ import { i as n, t as r } from "../../dist-BgEySLwo.js";
4
3
  import i from "../Menu/LinkBubbleMenu.js";
5
- import { t as a } from "../../html-to-markdown-CrNOkSye.js";
6
- import { t as o } from "../../extension-CZOsheCI.js";
4
+ import { t as a } from "../../html-to-markdown-Cta7-ssO.js";
5
+ import { t as o } from "../../extension-BVGWENts.js";
7
6
  import { SuggestionItemType as s } from "./extension/slashCommand/items.js";
8
7
  import "./extension/tableOfContents.js";
9
8
  import "../../utils/index.js";
@@ -11,98 +10,181 @@ import { ListOptionBar as c } from "../Menu/Mobile/ListOptionBar.js";
11
10
  import { forwardRef as l, useCallback as u, useEffect as d, useImperativeHandle as f, useRef as p, useState as m } from "react";
12
11
  import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
12
  import '../../assets/index.css';//#region lib/components/Scribe/index.tsx
14
- var _ = l((s, l) => {
15
- let { autoFocus: _ = !1, content: v, editable: y = !0, editorProps: b, extensions: x, onContentChange: S, showBarMenu: C = !0, editorContentStyle: w, editorContentClassName: T, mainContainerStyle: E, mainContainerClassName: D, onKeyDown: O, externalEditor: k, mobile: A, onTableOfContentsChange: j } = s, M = p(!k && v !== void 0), N = p([]), P = p(j);
16
- d(() => {
17
- P.current = j;
18
- }, [j]);
19
- let F = u((e, t) => {
20
- N.current = e, P.current?.(e, t);
21
- }, []), I = u(({ editor: e, transaction: t }) => {
13
+ var _ = "Rich text editor", v = [
14
+ "role",
15
+ "aria-label",
16
+ "aria-multiline",
17
+ "aria-readonly"
18
+ ], y = (t, n, r) => {
19
+ let i = t.role ?? "textbox";
20
+ return {
21
+ ...t,
22
+ role: i,
23
+ class: e("scribe", t.class),
24
+ "aria-label": n ?? t["aria-label"] ?? _,
25
+ ...i === "textbox" ? {
26
+ "aria-multiline": "true",
27
+ "aria-readonly": String(!r)
28
+ } : {}
29
+ };
30
+ }, b = (e) => {
31
+ let t = p([]), n = p(e);
32
+ return d(() => {
33
+ n.current = e;
34
+ }, [e]), {
35
+ handleTableOfContentsChange: u((e, r) => {
36
+ t.current = e, n.current?.(e, r);
37
+ }, []),
38
+ tableOfContentsItemsRef: t
39
+ };
40
+ }, x = l((n, o) => {
41
+ let { ariaLabel: s, autoFocus: l = !1, content: m, editable: _ = !0, editor: b, editorProps: x, externalEditor: S, initialContentWasApplied: C, onContentChange: w, showBarMenu: T = !0, editorContentStyle: E, editorContentClassName: D, mainContainerStyle: O, mainContainerClassName: k, onKeyDown: A, mobile: j, tableOfContentsItemsRef: M } = n, N = p({
42
+ ariaLabel: s,
43
+ editable: _
44
+ }), P = p(null);
45
+ N.current = {
46
+ ariaLabel: s,
47
+ editable: _
48
+ };
49
+ let F = p(C && m !== void 0), I = u(({ editor: e, transaction: t }) => {
22
50
  if (t.getMeta("scribeTableOfContents")) return;
23
- let n = e.getHTML(), r = e.getJSON(), i = !y;
24
- S && S({
51
+ let n = e.getHTML(), r = e.getJSON(), i = !_;
52
+ w && w({
25
53
  jsonContent: e.isEmpty ? "" : r,
26
54
  htmlContent: e.isEmpty ? "" : n,
27
55
  markdownContent: e.isEmpty ? "" : a(n),
28
56
  source: i ? "programmatic" : "user"
29
57
  });
30
- }, [y, S]), [L] = m(() => k ?? new r({
31
- ...b,
32
- content: v ?? b?.content,
33
- editable: y,
34
- extensions: [...o({
35
- ...s,
36
- onTableOfContentsChange: F
37
- }), ...x ?? []],
38
- editorProps: {
39
- attributes: { class: "scribe" },
40
- ...b?.editorProps
41
- }
42
- })), R = u(() => {
43
- L.commands.setContent("");
44
- }, [L]), z = u((e) => L.isEmpty ? "" : {
45
- html: () => L.getHTML(),
46
- json: () => L.getJSON(),
47
- markdown: () => a(L.getHTML())
48
- }[e]?.(), [L]), B = u((e) => {
49
- L.commands.setContent(e);
50
- }, [L]), V = u((e) => {
51
- let t = typeof e == "string" ? e : e.id, n = N.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
52
- if (!n || L.isDestroyed) return;
53
- let r = L.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
54
- if (L.isEditable) {
55
- let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, L.state.doc.content.size));
56
- L.commands.focus(e, { scrollIntoView: !1 });
58
+ }, [_, w]), L = u(() => {
59
+ b.commands.setContent("");
60
+ }, [b]), R = u((e) => b.isEmpty ? "" : {
61
+ html: () => b.getHTML(),
62
+ json: () => b.getJSON(),
63
+ markdown: () => a(b.getHTML())
64
+ }[e]?.(), [b]), z = u((e) => {
65
+ b.commands.setContent(e);
66
+ }, [b]), B = u((e) => {
67
+ let t = typeof e == "string" ? e : e.id, n = M.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
68
+ if (!n || b.isDestroyed) return;
69
+ let r = b.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
70
+ if (b.isEditable) {
71
+ let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, b.state.doc.content.size));
72
+ b.commands.focus(e, { scrollIntoView: !1 });
57
73
  }
58
74
  i.scrollIntoView({
59
75
  behavior: "smooth",
60
76
  block: "start"
61
77
  });
62
- }, [L]);
63
- return f(l, () => ({
64
- resetContent: R,
65
- setContent: B,
66
- getContent: z,
67
- scrollToTableOfContentsItem: V,
68
- editor: L
78
+ }, [b, M]);
79
+ return f(o, () => ({
80
+ resetContent: L,
81
+ setContent: z,
82
+ getContent: R,
83
+ scrollToTableOfContentsItem: B,
84
+ editor: b
69
85
  }), [
70
- L,
71
- z,
86
+ b,
72
87
  R,
73
- V,
74
- B
88
+ L,
89
+ B,
90
+ z
75
91
  ]), d(() => {
76
- if (v !== void 0) {
77
- if (M.current) {
78
- M.current = !1;
92
+ if (m !== void 0) {
93
+ if (F.current) {
94
+ F.current = !1;
79
95
  return;
80
96
  }
81
- L.commands.setContent(v, { emitUpdate: !1 });
97
+ b.commands.setContent(m, { emitUpdate: !1 });
98
+ }
99
+ }, [m, b]), d(() => {
100
+ if (!S) {
101
+ P.current = null;
102
+ return;
82
103
  }
83
- }, [v, L]), d(() => {
84
- L.setEditable(!!y);
85
- }, [y, L]), d(() => (L.off("update"), L.on("update", I), () => {
86
- L.off("update", I);
87
- }), [L, I]), d(() => {
88
- _ && L.commands.focus("end");
89
- }, [_, L]), /* @__PURE__ */ g("div", {
90
- className: e("scribe-wrapper", "scribe-root", D),
104
+ let e = b.view.dom, t = Object.fromEntries(v.map((t) => [t, e.getAttribute(t)])), n = b.options.editable, r = b.options.editorProps ?? {}, i = r.attributes, a = /* @__PURE__ */ new Set(), o = (e, t) => {
105
+ let n = typeof i == "function" ? i.call(t, e) : i;
106
+ return Object.keys(n ?? {}).forEach((e) => a.add(e)), n ?? {};
107
+ }, s = (e, n) => {
108
+ let r = o(e, n), i = {};
109
+ return v.forEach((e) => {
110
+ let n = t[e];
111
+ !a.has(e) && n !== null && (i[e] = n);
112
+ }), {
113
+ ...i,
114
+ ...r
115
+ };
116
+ }, c = s(b.state, r);
117
+ P.current = {
118
+ editor: b,
119
+ attributes: c
120
+ };
121
+ let l = function(e) {
122
+ let t = s(e, this);
123
+ P.current?.editor === b && (P.current.attributes = t);
124
+ let n = N.current;
125
+ return y(t, n.ariaLabel, n.editable);
126
+ };
127
+ return b.setOptions({ editorProps: {
128
+ ...r,
129
+ attributes: l
130
+ } }), () => {
131
+ if (!b.isDestroyed) {
132
+ let s = b.options.editorProps ?? {}, c = s.attributes === l;
133
+ if (c) {
134
+ let e = { ...s };
135
+ i === void 0 ? delete e.attributes : e.attributes = i, b.setOptions({ editorProps: e });
136
+ }
137
+ b.setEditable(!!n, !1);
138
+ let u = c ? o(b.state, r) : null;
139
+ u && v.forEach((n) => {
140
+ let r = n in u ? u[n] : a.has(n) ? null : t[n];
141
+ if (r == null) {
142
+ e.removeAttribute(n);
143
+ return;
144
+ }
145
+ e.setAttribute(n, r);
146
+ });
147
+ }
148
+ P.current?.editor === b && (P.current = null);
149
+ };
150
+ }, [b, S]), d(() => {
151
+ b.setEditable(!!_);
152
+ let e = b.view.dom, t = y((S ? P.current?.attributes : typeof x?.editorProps?.attributes == "function" ? x.editorProps.attributes.call(x.editorProps, b.state) : x?.editorProps?.attributes) ?? {}, s, _);
153
+ v.forEach((n) => {
154
+ let r = t[n];
155
+ if (r === void 0) {
156
+ e.removeAttribute(n);
157
+ return;
158
+ }
159
+ e.setAttribute(n, r);
160
+ });
161
+ }, [
162
+ s,
163
+ _,
164
+ b,
165
+ x,
166
+ S
167
+ ]), d(() => (b.off("update"), b.on("update", I), () => {
168
+ b.off("update", I);
169
+ }), [b, I]), d(() => {
170
+ l && b.commands.focus("end");
171
+ }, [l, b]), /* @__PURE__ */ g("div", {
172
+ className: e("scribe-wrapper", "scribe-root", k),
91
173
  "data-scribe-root": !0,
92
- style: E,
174
+ style: O,
93
175
  children: [/* @__PURE__ */ g("div", {
94
- className: e("scribe-frame", y && "scribe-frame--editable"),
176
+ className: e("scribe-frame", _ && "scribe-frame--editable"),
95
177
  children: [
96
- L && C ? /* @__PURE__ */ h(t, { editor: L }) : null,
178
+ b && T ? /* @__PURE__ */ h(t, { editor: b }) : null,
97
179
  /* @__PURE__ */ g("div", {
98
- className: e("scribe-content", y && "scribe-content--editable", T),
99
- style: w,
100
- children: [/* @__PURE__ */ h(n, {
101
- editor: L,
102
- onKeyDown: O
103
- }), y ? /* @__PURE__ */ h(i, { editor: L }) : null]
180
+ className: e("scribe-content", _ && "scribe-content--editable", D),
181
+ style: E,
182
+ children: [/* @__PURE__ */ h(r, {
183
+ editor: b,
184
+ onKeyDown: A
185
+ }), _ ? /* @__PURE__ */ h(i, { editor: b }) : null]
104
186
  }),
105
- A ? /* @__PURE__ */ h(c, { editor: L }) : null
187
+ j ? /* @__PURE__ */ h(c, { editor: b }) : null
106
188
  ]
107
189
  }), /* @__PURE__ */ h("div", {
108
190
  className: "scribe-popup-root",
@@ -110,5 +192,60 @@ var _ = l((s, l) => {
110
192
  })]
111
193
  });
112
194
  });
195
+ x.displayName = "ScribeEditor";
196
+ var S = l((e, t) => {
197
+ let { ariaLabel: r, content: i, editable: a = !0, editorProps: s, extensions: c, onTableOfContentsChange: l } = e, { handleTableOfContentsChange: u, tableOfContentsItemsRef: d } = b(l), f = s?.editorProps?.attributes, g = p({
198
+ ariaLabel: r,
199
+ editable: a
200
+ });
201
+ g.current = {
202
+ ariaLabel: r,
203
+ editable: a
204
+ };
205
+ let _ = typeof f == "function" ? function(e) {
206
+ let t = g.current;
207
+ return y(f.call(this, e), t.ariaLabel, t.editable);
208
+ } : y(f ?? {}, r, a), [v] = m(() => ({
209
+ ...s,
210
+ content: i ?? s?.content,
211
+ editable: a,
212
+ extensions: [...o({
213
+ ...e,
214
+ onTableOfContentsChange: u
215
+ }), ...c ?? []],
216
+ editorProps: {
217
+ ...s?.editorProps,
218
+ attributes: _
219
+ },
220
+ shouldRerenderOnTransaction: s?.shouldRerenderOnTransaction ?? !1
221
+ })), S = n(v);
222
+ return S ? /* @__PURE__ */ h(x, {
223
+ ...e,
224
+ ref: t,
225
+ editor: S,
226
+ initialContentWasApplied: !0,
227
+ tableOfContentsItemsRef: d
228
+ }) : null;
229
+ });
230
+ S.displayName = "OwnedScribe";
231
+ var C = l((e, t) => {
232
+ let { externalEditor: n, onTableOfContentsChange: r } = e, { tableOfContentsItemsRef: i } = b(r);
233
+ return n ? /* @__PURE__ */ h(x, {
234
+ ...e,
235
+ ref: t,
236
+ editor: n,
237
+ initialContentWasApplied: !1,
238
+ tableOfContentsItemsRef: i
239
+ }) : null;
240
+ });
241
+ C.displayName = "ExternalScribe";
242
+ var w = l((e, t) => e.externalEditor ? /* @__PURE__ */ h(C, {
243
+ ...e,
244
+ ref: t
245
+ }) : /* @__PURE__ */ h(S, {
246
+ ...e,
247
+ ref: t
248
+ }));
249
+ w.displayName = "Scribe";
113
250
  //#endregion
114
- export { _ as Scribe, s as SuggestionItemType };
251
+ export { w as Scribe, s as SuggestionItemType };