@clevertask/scribe 0.1.11 → 0.1.12

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 (38) hide show
  1. package/dist/components/Menu/CalloutBubbleMenu.d.ts +7 -0
  2. package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
  3. package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
  4. package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/TableBubbleMenu.js +97 -96
  6. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
  7. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
  8. package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
  9. package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
  10. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
  11. package/dist/components/Menu/contextualMenuOwner.js +9 -0
  12. package/dist/components/Scribe/extension/callout.d.ts +32 -0
  13. package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
  14. package/dist/components/Scribe/extension/callout.js +118 -0
  15. package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
  16. package/dist/components/Scribe/extension/index.d.ts +1 -1
  17. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  18. package/dist/components/Scribe/extension/index.js +1 -1
  19. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  20. package/dist/components/Scribe/extension/slashCommand/items.js +48 -28
  21. package/dist/components/Scribe/index.d.ts.map +1 -1
  22. package/dist/components/Scribe/index.js +126 -124
  23. package/dist/{extension-Dy6hHSvD.js → extension-_8uh0Ik9.js} +1234 -1232
  24. package/dist/{html-to-markdown-B6Uhn7ok.js → html-to-markdown-C920nQtn.js} +101 -60
  25. package/dist/icons/CalloutIcon.d.ts +9 -0
  26. package/dist/icons/CalloutIcon.d.ts.map +1 -0
  27. package/dist/icons/CalloutIcon.js +72 -0
  28. package/dist/main.css +119 -1
  29. package/dist/main.d.ts +1 -0
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/main.js +9 -8
  32. package/dist/{markdown-to-html-WmeDaJXP.js → markdown-to-html-CW0Nb9Ye.js} +32 -2
  33. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  34. package/dist/utils/html-to-markdown.js +1 -1
  35. package/dist/utils/index.js +3 -3
  36. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  37. package/dist/utils/markdown-to-html.js +1 -1
  38. package/package.json +42 -19
@@ -1,143 +1,144 @@
1
1
  import { n as e, t } from "../../BarMenu-5M9g9Y1j.js";
2
2
  import { i as n, t as r } from "../../dist-Dw4STOPE.js";
3
- import i from "../Menu/LinkBubbleMenu.js";
4
- import a from "../Menu/TableBubbleMenu.js";
5
- import { t as o } from "../../html-to-markdown-B6Uhn7ok.js";
6
- import { t as s } from "../../extension-Dy6hHSvD.js";
7
- import { SuggestionItemType as c } from "./extension/slashCommand/items.js";
3
+ import i from "../Menu/CalloutBubbleMenu.js";
4
+ import a from "../Menu/LinkBubbleMenu.js";
5
+ import o from "../Menu/TableBubbleMenu.js";
6
+ import { t as s } from "../../html-to-markdown-C920nQtn.js";
7
+ import { t as c } from "../../extension-_8uh0Ik9.js";
8
+ import { SuggestionItemType as l } from "./extension/slashCommand/items.js";
8
9
  import "./extension/tableOfContents.js";
9
10
  import "../../utils/index.js";
10
- import { ListOptionBar as l } from "../Menu/Mobile/ListOptionBar.js";
11
- import { forwardRef as u, useCallback as d, useEffect as f, useImperativeHandle as p, useRef as m, useState as h } from "react";
12
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
11
+ import { ListOptionBar as u } from "../Menu/Mobile/ListOptionBar.js";
12
+ import { forwardRef as d, useCallback as f, useEffect as p, useImperativeHandle as m, useRef as h, useState as g } from "react";
13
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
14
  import '../../assets/index.css';//#region lib/components/Scribe/index.tsx
14
- var v = "Rich text editor", y = [
15
+ var y = "Rich text editor", b = [
15
16
  "role",
16
17
  "aria-label",
17
18
  "aria-multiline",
18
19
  "aria-readonly"
19
- ], b = (t, n, r) => {
20
+ ], x = (t, n, r) => {
20
21
  let i = t.role ?? "textbox";
21
22
  return {
22
23
  ...t,
23
24
  role: i,
24
25
  class: e("scribe", t.class),
25
- "aria-label": n ?? t["aria-label"] ?? v,
26
+ "aria-label": n ?? t["aria-label"] ?? y,
26
27
  ...i === "textbox" ? {
27
28
  "aria-multiline": "true",
28
29
  "aria-readonly": String(!r)
29
30
  } : {}
30
31
  };
31
- }, x = (e) => {
32
- let t = m([]), n = m(e);
33
- return f(() => {
32
+ }, S = (e) => {
33
+ let t = h([]), n = h(e);
34
+ return p(() => {
34
35
  n.current = e;
35
36
  }, [e]), {
36
- handleTableOfContentsChange: d((e, r) => {
37
+ handleTableOfContentsChange: f((e, r) => {
37
38
  t.current = e, n.current?.(e, r);
38
39
  }, []),
39
40
  tableOfContentsItemsRef: t
40
41
  };
41
- }, S = u((n, s) => {
42
- let { ariaLabel: c, autoFocus: u = !1, content: h, editable: v = !0, editor: x, editorProps: S, externalEditor: C, initialContentWasApplied: w, onContentChange: T, showBarMenu: E = !0, editorContentStyle: D, editorContentClassName: O, mainContainerStyle: k, mainContainerClassName: A, onKeyDown: j, mobile: M, tableOfContentsItemsRef: N } = n, P = m({
43
- ariaLabel: c,
44
- editable: v
45
- }), F = m(null);
46
- P.current = {
47
- ariaLabel: c,
48
- editable: v
42
+ }, C = d((n, c) => {
43
+ let { ariaLabel: l, autoFocus: d = !1, content: g, editable: y = !0, editor: S, editorProps: C, externalEditor: w, initialContentWasApplied: T, onContentChange: E, showBarMenu: D = !0, editorContentStyle: O, editorContentClassName: k, mainContainerStyle: A, mainContainerClassName: j, onKeyDown: M, mobile: N, tableOfContentsItemsRef: P } = n, F = h({
44
+ ariaLabel: l,
45
+ editable: y
46
+ }), I = h(null);
47
+ F.current = {
48
+ ariaLabel: l,
49
+ editable: y
49
50
  };
50
- let I = m(w && h !== void 0), L = d(({ editor: e, transaction: t }) => {
51
+ let L = h(T && g !== void 0), R = f(({ editor: e, transaction: t }) => {
51
52
  if (t.getMeta("scribeTableOfContents")) return;
52
- let n = e.getHTML(), r = e.getJSON(), i = !v;
53
- T && T({
53
+ let n = e.getHTML(), r = e.getJSON(), i = !y;
54
+ E && E({
54
55
  jsonContent: e.isEmpty ? "" : r,
55
56
  htmlContent: e.isEmpty ? "" : n,
56
- markdownContent: e.isEmpty ? "" : o(n),
57
+ markdownContent: e.isEmpty ? "" : s(n),
57
58
  source: i ? "programmatic" : "user"
58
59
  });
59
- }, [v, T]), R = d(() => {
60
- x.commands.setContent("");
61
- }, [x]), z = d((e) => x.isEmpty ? "" : {
62
- html: () => x.getHTML(),
63
- json: () => x.getJSON(),
64
- markdown: () => o(x.getHTML())
65
- }[e]?.(), [x]), B = d((e) => {
66
- x.commands.setContent(e);
67
- }, [x]), V = d((e) => {
68
- let t = typeof e == "string" ? e : e.id, n = N.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
69
- if (!n || x.isDestroyed) return;
70
- let r = x.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
71
- if (x.isEditable) {
72
- let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, x.state.doc.content.size));
73
- x.commands.focus(e, { scrollIntoView: !1 });
60
+ }, [y, E]), z = f(() => {
61
+ S.commands.setContent("");
62
+ }, [S]), B = f((e) => S.isEmpty ? "" : {
63
+ html: () => S.getHTML(),
64
+ json: () => S.getJSON(),
65
+ markdown: () => s(S.getHTML())
66
+ }[e]?.(), [S]), V = f((e) => {
67
+ S.commands.setContent(e);
68
+ }, [S]), H = f((e) => {
69
+ let t = typeof e == "string" ? e : e.id, n = P.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
70
+ if (!n || S.isDestroyed) return;
71
+ let r = S.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
72
+ if (S.isEditable) {
73
+ let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, S.state.doc.content.size));
74
+ S.commands.focus(e, { scrollIntoView: !1 });
74
75
  }
75
76
  i.scrollIntoView({
76
77
  behavior: "smooth",
77
78
  block: "start"
78
79
  });
79
- }, [x, N]);
80
- return p(s, () => ({
81
- resetContent: R,
82
- setContent: B,
83
- getContent: z,
84
- scrollToTableOfContentsItem: V,
85
- editor: x
80
+ }, [S, P]);
81
+ return m(c, () => ({
82
+ resetContent: z,
83
+ setContent: V,
84
+ getContent: B,
85
+ scrollToTableOfContentsItem: H,
86
+ editor: S
86
87
  }), [
87
- x,
88
+ S,
89
+ B,
88
90
  z,
89
- R,
90
- V,
91
- B
92
- ]), f(() => {
93
- if (h !== void 0) {
94
- if (I.current) {
95
- I.current = !1;
91
+ H,
92
+ V
93
+ ]), p(() => {
94
+ if (g !== void 0) {
95
+ if (L.current) {
96
+ L.current = !1;
96
97
  return;
97
98
  }
98
- x.commands.setContent(h, { emitUpdate: !1 });
99
+ S.commands.setContent(g, { emitUpdate: !1 });
99
100
  }
100
- }, [h, x]), f(() => {
101
- if (!C) {
102
- F.current = null;
101
+ }, [g, S]), p(() => {
102
+ if (!w) {
103
+ I.current = null;
103
104
  return;
104
105
  }
105
- let e = x.view.dom, t = Object.fromEntries(y.map((t) => [t, e.getAttribute(t)])), n = x.options.editable, r = x.options.editorProps ?? {}, i = r.attributes, a = /* @__PURE__ */ new Set(), o = (e, t) => {
106
+ let e = S.view.dom, t = Object.fromEntries(b.map((t) => [t, e.getAttribute(t)])), n = S.options.editable, r = S.options.editorProps ?? {}, i = r.attributes, a = /* @__PURE__ */ new Set(), o = (e, t) => {
106
107
  let n = typeof i == "function" ? i.call(t, e) : i;
107
108
  return Object.keys(n ?? {}).forEach((e) => a.add(e)), n ?? {};
108
109
  }, s = (e, n) => {
109
110
  let r = o(e, n), i = {};
110
- return y.forEach((e) => {
111
+ return b.forEach((e) => {
111
112
  let n = t[e];
112
113
  !a.has(e) && n !== null && (i[e] = n);
113
114
  }), {
114
115
  ...i,
115
116
  ...r
116
117
  };
117
- }, c = s(x.state, r);
118
- F.current = {
119
- editor: x,
118
+ }, c = s(S.state, r);
119
+ I.current = {
120
+ editor: S,
120
121
  attributes: c
121
122
  };
122
123
  let l = function(e) {
123
124
  let t = s(e, this);
124
- F.current?.editor === x && (F.current.attributes = t);
125
- let n = P.current;
126
- return b(t, n.ariaLabel, n.editable);
125
+ I.current?.editor === S && (I.current.attributes = t);
126
+ let n = F.current;
127
+ return x(t, n.ariaLabel, n.editable);
127
128
  };
128
- return x.setOptions({ editorProps: {
129
+ return S.setOptions({ editorProps: {
129
130
  ...r,
130
131
  attributes: l
131
132
  } }), () => {
132
- if (!x.isDestroyed) {
133
- let s = x.options.editorProps ?? {}, c = s.attributes === l;
133
+ if (!S.isDestroyed) {
134
+ let s = S.options.editorProps ?? {}, c = s.attributes === l;
134
135
  if (c) {
135
136
  let e = { ...s };
136
- i === void 0 ? delete e.attributes : e.attributes = i, x.setOptions({ editorProps: e });
137
+ i === void 0 ? delete e.attributes : e.attributes = i, S.setOptions({ editorProps: e });
137
138
  }
138
- x.setEditable(!!n, !1);
139
- let u = c ? o(x.state, r) : null;
140
- u && y.forEach((n) => {
139
+ S.setEditable(!!n, !1);
140
+ let u = c ? o(S.state, r) : null;
141
+ u && b.forEach((n) => {
141
142
  let r = n in u ? u[n] : a.has(n) ? null : t[n];
142
143
  if (r == null) {
143
144
  e.removeAttribute(n);
@@ -146,12 +147,12 @@ var v = "Rich text editor", y = [
146
147
  e.setAttribute(n, r);
147
148
  });
148
149
  }
149
- F.current?.editor === x && (F.current = null);
150
+ I.current?.editor === S && (I.current = null);
150
151
  };
151
- }, [x, C]), f(() => {
152
- x.setEditable(!!v);
153
- let e = x.view.dom, t = b((C ? F.current?.attributes : typeof S?.editorProps?.attributes == "function" ? S.editorProps.attributes.call(S.editorProps, x.state) : S?.editorProps?.attributes) ?? {}, c, v);
154
- y.forEach((n) => {
152
+ }, [S, w]), p(() => {
153
+ S.setEditable(!!y);
154
+ let e = S.view.dom, t = x((w ? I.current?.attributes : typeof C?.editorProps?.attributes == "function" ? C.editorProps.attributes.call(C.editorProps, S.state) : C?.editorProps?.attributes) ?? {}, l, y);
155
+ b.forEach((n) => {
155
156
  let r = t[n];
156
157
  if (r === void 0) {
157
158
  e.removeAttribute(n);
@@ -160,46 +161,47 @@ var v = "Rich text editor", y = [
160
161
  e.setAttribute(n, r);
161
162
  });
162
163
  }, [
163
- c,
164
- v,
165
- x,
164
+ l,
165
+ y,
166
166
  S,
167
- C
168
- ]), f(() => (x.off("update"), x.on("update", L), () => {
169
- x.off("update", L);
170
- }), [x, L]), f(() => {
171
- u && x.commands.focus("end");
172
- }, [u, x]), /* @__PURE__ */ _("div", {
173
- className: e("scribe-wrapper", "scribe-root", A),
167
+ C,
168
+ w
169
+ ]), p(() => (S.off("update"), S.on("update", R), () => {
170
+ S.off("update", R);
171
+ }), [S, R]), p(() => {
172
+ d && S.commands.focus("end");
173
+ }, [d, S]), /* @__PURE__ */ v("div", {
174
+ className: e("scribe-wrapper", "scribe-root", j),
174
175
  "data-scribe-root": !0,
175
- style: k,
176
- children: [/* @__PURE__ */ _("div", {
177
- className: e("scribe-frame", v && "scribe-frame--editable"),
176
+ style: A,
177
+ children: [/* @__PURE__ */ v("div", {
178
+ className: e("scribe-frame", y && "scribe-frame--editable"),
178
179
  children: [
179
- x && E ? /* @__PURE__ */ g(t, { editor: x }) : null,
180
- /* @__PURE__ */ _("div", {
181
- className: e("scribe-content", v && "scribe-content--editable", O),
182
- style: D,
180
+ S && D ? /* @__PURE__ */ _(t, { editor: S }) : null,
181
+ /* @__PURE__ */ v("div", {
182
+ className: e("scribe-content", y && "scribe-content--editable", k),
183
+ style: O,
183
184
  children: [
184
- /* @__PURE__ */ g(r, {
185
- editor: x,
186
- onKeyDown: j
185
+ /* @__PURE__ */ _(r, {
186
+ editor: S,
187
+ onKeyDown: M
187
188
  }),
188
- v ? /* @__PURE__ */ g(i, { editor: x }) : null,
189
- v && x.schema.nodes.table ? /* @__PURE__ */ g(a, { editor: x }) : null
189
+ y ? /* @__PURE__ */ _(a, { editor: S }) : null,
190
+ y && S.schema.nodes.callout ? /* @__PURE__ */ _(i, { editor: S }) : null,
191
+ y && S.schema.nodes.table ? /* @__PURE__ */ _(o, { editor: S }) : null
190
192
  ]
191
193
  }),
192
- M ? /* @__PURE__ */ g(l, { editor: x }) : null
194
+ N ? /* @__PURE__ */ _(u, { editor: S }) : null
193
195
  ]
194
- }), /* @__PURE__ */ g("div", {
196
+ }), /* @__PURE__ */ _("div", {
195
197
  className: "scribe-popup-root",
196
198
  "data-scribe-popup-root": !0
197
199
  })]
198
200
  });
199
201
  });
200
- S.displayName = "ScribeEditor";
201
- var C = u((e, t) => {
202
- let { ariaLabel: r, content: i, editable: a = !0, editorProps: o, extensions: c, onTableOfContentsChange: l } = e, { handleTableOfContentsChange: u, tableOfContentsItemsRef: d } = x(l), f = o?.editorProps?.attributes, p = m({
202
+ C.displayName = "ScribeEditor";
203
+ var w = d((e, t) => {
204
+ let { ariaLabel: r, content: i, editable: a = !0, editorProps: o, extensions: s, onTableOfContentsChange: l } = e, { handleTableOfContentsChange: u, tableOfContentsItemsRef: d } = S(l), f = o?.editorProps?.attributes, p = h({
203
205
  ariaLabel: r,
204
206
  editable: a
205
207
  });
@@ -207,24 +209,24 @@ var C = u((e, t) => {
207
209
  ariaLabel: r,
208
210
  editable: a
209
211
  };
210
- let _ = typeof f == "function" ? function(e) {
212
+ let m = typeof f == "function" ? function(e) {
211
213
  let t = p.current;
212
- return b(f.call(this, e), t.ariaLabel, t.editable);
213
- } : b(f ?? {}, r, a), [v] = h(() => ({
214
+ return x(f.call(this, e), t.ariaLabel, t.editable);
215
+ } : x(f ?? {}, r, a), [v] = g(() => ({
214
216
  ...o,
215
217
  content: i ?? o?.content,
216
218
  editable: a,
217
- extensions: [...s({
219
+ extensions: [...c({
218
220
  ...e,
219
221
  onTableOfContentsChange: u
220
- }), ...c ?? []],
222
+ }), ...s ?? []],
221
223
  editorProps: {
222
224
  ...o?.editorProps,
223
- attributes: _
225
+ attributes: m
224
226
  },
225
227
  shouldRerenderOnTransaction: o?.shouldRerenderOnTransaction ?? !1
226
228
  })), y = n(v);
227
- return y ? /* @__PURE__ */ g(S, {
229
+ return y ? /* @__PURE__ */ _(C, {
228
230
  ...e,
229
231
  ref: t,
230
232
  editor: y,
@@ -232,10 +234,10 @@ var C = u((e, t) => {
232
234
  tableOfContentsItemsRef: d
233
235
  }) : null;
234
236
  });
235
- C.displayName = "OwnedScribe";
236
- var w = u((e, t) => {
237
- let { externalEditor: n, onTableOfContentsChange: r } = e, { tableOfContentsItemsRef: i } = x(r);
238
- return n ? /* @__PURE__ */ g(S, {
237
+ w.displayName = "OwnedScribe";
238
+ var T = d((e, t) => {
239
+ let { externalEditor: n, onTableOfContentsChange: r } = e, { tableOfContentsItemsRef: i } = S(r);
240
+ return n ? /* @__PURE__ */ _(C, {
239
241
  ...e,
240
242
  ref: t,
241
243
  editor: n,
@@ -243,14 +245,14 @@ var w = u((e, t) => {
243
245
  tableOfContentsItemsRef: i
244
246
  }) : null;
245
247
  });
246
- w.displayName = "ExternalScribe";
247
- var T = u((e, t) => e.externalEditor ? /* @__PURE__ */ g(w, {
248
+ T.displayName = "ExternalScribe";
249
+ var E = d((e, t) => e.externalEditor ? /* @__PURE__ */ _(T, {
248
250
  ...e,
249
251
  ref: t
250
- }) : /* @__PURE__ */ g(C, {
252
+ }) : /* @__PURE__ */ _(w, {
251
253
  ...e,
252
254
  ref: t
253
255
  }));
254
- T.displayName = "Scribe";
256
+ E.displayName = "Scribe";
255
257
  //#endregion
256
- export { T as Scribe, c as SuggestionItemType };
258
+ export { E as Scribe, l as SuggestionItemType };