@clevertask/scribe 0.1.10 → 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 (66) hide show
  1. package/README.md +11 -1
  2. package/dist/{BarMenu-5S2vKAtc.js → BarMenu-5M9g9Y1j.js} +7 -5
  3. package/dist/components/Menu/BarMenu.js +1 -1
  4. package/dist/components/Menu/BubbleMenu.js +2 -2
  5. package/dist/components/Menu/CalloutBubbleMenu.d.ts +7 -0
  6. package/dist/components/Menu/CalloutBubbleMenu.d.ts.map +1 -0
  7. package/dist/components/Menu/CalloutBubbleMenu.js +156 -0
  8. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  9. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  10. package/dist/components/Menu/TableBubbleMenu.d.ts +8 -0
  11. package/dist/components/Menu/TableBubbleMenu.d.ts.map +1 -0
  12. package/dist/components/Menu/TableBubbleMenu.js +306 -0
  13. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts +10 -0
  14. package/dist/components/Menu/calloutBubbleMenuPlugin.d.ts.map +1 -0
  15. package/dist/components/Menu/calloutBubbleMenuPlugin.js +22 -0
  16. package/dist/components/Menu/contextualMenuOwner.d.ts +4 -0
  17. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -0
  18. package/dist/components/Menu/contextualMenuOwner.js +9 -0
  19. package/dist/components/Menu/tableBubbleMenuPlugin.d.ts +11 -0
  20. package/dist/components/Menu/tableBubbleMenuPlugin.d.ts.map +1 -0
  21. package/dist/components/Menu/tableBubbleMenuPlugin.js +22 -0
  22. package/dist/components/Scribe/extension/callout.d.ts +32 -0
  23. package/dist/components/Scribe/extension/callout.d.ts.map +1 -0
  24. package/dist/components/Scribe/extension/callout.js +118 -0
  25. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  26. package/dist/components/Scribe/extension/extension-link.js +1 -1
  27. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  28. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  29. package/dist/components/Scribe/extension/index.d.ts +1 -1
  30. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/index.js +1 -1
  32. package/dist/components/Scribe/extension/resizable-table.d.ts +8 -0
  33. package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -0
  34. package/dist/components/Scribe/extension/resizable-table.js +2 -0
  35. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +1390 -1390
  36. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  37. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  38. package/dist/components/Scribe/extension/slashCommand/items.js +73 -26
  39. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  40. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  41. package/dist/components/Scribe/index.d.ts +2 -1
  42. package/dist/components/Scribe/index.d.ts.map +1 -1
  43. package/dist/components/Scribe/index.js +140 -133
  44. package/dist/{dist-DErUltkU.js → dist-DFua_Xbu.js} +37 -31
  45. package/dist/{dist-wYqYXEOz.js → dist-Dw4STOPE.js} +1 -1
  46. package/dist/{extension-6I5t1ZxQ.js → extension-_8uh0Ik9.js} +1323 -1780
  47. package/dist/{extension-link-DJy7XDoj.js → extension-link-CjfUZ90W.js} +1 -1
  48. package/dist/{html-to-markdown-Cta7-ssO.js → html-to-markdown-C920nQtn.js} +155 -56
  49. package/dist/icons/CalloutIcon.d.ts +9 -0
  50. package/dist/icons/CalloutIcon.d.ts.map +1 -0
  51. package/dist/icons/CalloutIcon.js +72 -0
  52. package/dist/main.css +170 -1
  53. package/dist/main.d.ts +1 -0
  54. package/dist/main.d.ts.map +1 -1
  55. package/dist/main.js +9 -8
  56. package/dist/{markdown-to-html-DwSNqq2i.js → markdown-to-html-CW0Nb9Ye.js} +103 -60
  57. package/dist/{menus-m_EkiaUN.js → menus-_EXlLMjz.js} +2 -2
  58. package/dist/{purify.es-CFiLaBu1.js → purify.es-BES4pJF7.js} +267 -260
  59. package/dist/resizable-table-Ddw3l6DJ.js +489 -0
  60. package/dist/{slashCommand-DuSH9sXJ.js → slashCommand-CxX07Nbk.js} +24 -22
  61. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  62. package/dist/utils/html-to-markdown.js +1 -1
  63. package/dist/utils/index.js +4 -4
  64. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  65. package/dist/utils/markdown-to-html.js +1 -1
  66. package/package.json +47 -24
@@ -1,142 +1,144 @@
1
- import { n as e, t } from "../../BarMenu-5S2vKAtc.js";
2
- import { i as n, t as r } from "../../dist-wYqYXEOz.js";
3
- import i from "../Menu/LinkBubbleMenu.js";
4
- import { t as a } from "../../html-to-markdown-Cta7-ssO.js";
5
- import { t as o } from "../../extension-6I5t1ZxQ.js";
6
- import { SuggestionItemType as s } from "./extension/slashCommand/items.js";
1
+ import { n as e, t } from "../../BarMenu-5M9g9Y1j.js";
2
+ import { i as n, t as r } from "../../dist-Dw4STOPE.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";
7
9
  import "./extension/tableOfContents.js";
8
10
  import "../../utils/index.js";
9
- import { ListOptionBar as c } from "../Menu/Mobile/ListOptionBar.js";
10
- import { forwardRef as l, useCallback as u, useEffect as d, useImperativeHandle as f, useRef as p, useState as m } from "react";
11
- import { jsx as h, jsxs as g } 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";
12
14
  import '../../assets/index.css';//#region lib/components/Scribe/index.tsx
13
- var _ = "Rich text editor", v = [
15
+ var y = "Rich text editor", b = [
14
16
  "role",
15
17
  "aria-label",
16
18
  "aria-multiline",
17
19
  "aria-readonly"
18
- ], y = (t, n, r) => {
20
+ ], x = (t, n, r) => {
19
21
  let i = t.role ?? "textbox";
20
22
  return {
21
23
  ...t,
22
24
  role: i,
23
25
  class: e("scribe", t.class),
24
- "aria-label": n ?? t["aria-label"] ?? _,
26
+ "aria-label": n ?? t["aria-label"] ?? y,
25
27
  ...i === "textbox" ? {
26
28
  "aria-multiline": "true",
27
29
  "aria-readonly": String(!r)
28
30
  } : {}
29
31
  };
30
- }, b = (e) => {
31
- let t = p([]), n = p(e);
32
- return d(() => {
32
+ }, S = (e) => {
33
+ let t = h([]), n = h(e);
34
+ return p(() => {
33
35
  n.current = e;
34
36
  }, [e]), {
35
- handleTableOfContentsChange: u((e, r) => {
37
+ handleTableOfContentsChange: f((e, r) => {
36
38
  t.current = e, n.current?.(e, r);
37
39
  }, []),
38
40
  tableOfContentsItemsRef: t
39
41
  };
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: _
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
48
50
  };
49
- let F = p(C && m !== void 0), I = u(({ editor: e, transaction: t }) => {
51
+ let L = h(T && g !== void 0), R = f(({ editor: e, transaction: t }) => {
50
52
  if (t.getMeta("scribeTableOfContents")) return;
51
- let n = e.getHTML(), r = e.getJSON(), i = !_;
52
- w && w({
53
+ let n = e.getHTML(), r = e.getJSON(), i = !y;
54
+ E && E({
53
55
  jsonContent: e.isEmpty ? "" : r,
54
56
  htmlContent: e.isEmpty ? "" : n,
55
- markdownContent: e.isEmpty ? "" : a(n),
57
+ markdownContent: e.isEmpty ? "" : s(n),
56
58
  source: i ? "programmatic" : "user"
57
59
  });
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 });
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 });
73
75
  }
74
76
  i.scrollIntoView({
75
77
  behavior: "smooth",
76
78
  block: "start"
77
79
  });
78
- }, [b, M]);
79
- return f(o, () => ({
80
- resetContent: L,
81
- setContent: z,
82
- getContent: R,
83
- scrollToTableOfContentsItem: B,
84
- editor: b
80
+ }, [S, P]);
81
+ return m(c, () => ({
82
+ resetContent: z,
83
+ setContent: V,
84
+ getContent: B,
85
+ scrollToTableOfContentsItem: H,
86
+ editor: S
85
87
  }), [
86
- b,
87
- R,
88
- L,
88
+ S,
89
89
  B,
90
- z
91
- ]), d(() => {
92
- if (m !== void 0) {
93
- if (F.current) {
94
- F.current = !1;
90
+ z,
91
+ H,
92
+ V
93
+ ]), p(() => {
94
+ if (g !== void 0) {
95
+ if (L.current) {
96
+ L.current = !1;
95
97
  return;
96
98
  }
97
- b.commands.setContent(m, { emitUpdate: !1 });
99
+ S.commands.setContent(g, { emitUpdate: !1 });
98
100
  }
99
- }, [m, b]), d(() => {
100
- if (!S) {
101
- P.current = null;
101
+ }, [g, S]), p(() => {
102
+ if (!w) {
103
+ I.current = null;
102
104
  return;
103
105
  }
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) => {
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) => {
105
107
  let n = typeof i == "function" ? i.call(t, e) : i;
106
108
  return Object.keys(n ?? {}).forEach((e) => a.add(e)), n ?? {};
107
109
  }, s = (e, n) => {
108
110
  let r = o(e, n), i = {};
109
- return v.forEach((e) => {
111
+ return b.forEach((e) => {
110
112
  let n = t[e];
111
113
  !a.has(e) && n !== null && (i[e] = n);
112
114
  }), {
113
115
  ...i,
114
116
  ...r
115
117
  };
116
- }, c = s(b.state, r);
117
- P.current = {
118
- editor: b,
118
+ }, c = s(S.state, r);
119
+ I.current = {
120
+ editor: S,
119
121
  attributes: c
120
122
  };
121
123
  let l = function(e) {
122
124
  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);
125
+ I.current?.editor === S && (I.current.attributes = t);
126
+ let n = F.current;
127
+ return x(t, n.ariaLabel, n.editable);
126
128
  };
127
- return b.setOptions({ editorProps: {
129
+ return S.setOptions({ editorProps: {
128
130
  ...r,
129
131
  attributes: l
130
132
  } }), () => {
131
- if (!b.isDestroyed) {
132
- let s = b.options.editorProps ?? {}, c = s.attributes === l;
133
+ if (!S.isDestroyed) {
134
+ let s = S.options.editorProps ?? {}, c = s.attributes === l;
133
135
  if (c) {
134
136
  let e = { ...s };
135
- i === void 0 ? delete e.attributes : e.attributes = i, b.setOptions({ editorProps: e });
137
+ i === void 0 ? delete e.attributes : e.attributes = i, S.setOptions({ editorProps: e });
136
138
  }
137
- b.setEditable(!!n, !1);
138
- let u = c ? o(b.state, r) : null;
139
- u && v.forEach((n) => {
139
+ S.setEditable(!!n, !1);
140
+ let u = c ? o(S.state, r) : null;
141
+ u && b.forEach((n) => {
140
142
  let r = n in u ? u[n] : a.has(n) ? null : t[n];
141
143
  if (r == null) {
142
144
  e.removeAttribute(n);
@@ -145,12 +147,12 @@ var _ = "Rich text editor", v = [
145
147
  e.setAttribute(n, r);
146
148
  });
147
149
  }
148
- P.current?.editor === b && (P.current = null);
150
+ I.current?.editor === S && (I.current = null);
149
151
  };
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) => {
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) => {
154
156
  let r = t[n];
155
157
  if (r === void 0) {
156
158
  e.removeAttribute(n);
@@ -159,78 +161,83 @@ var _ = "Rich text editor", v = [
159
161
  e.setAttribute(n, r);
160
162
  });
161
163
  }, [
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),
164
+ l,
165
+ y,
166
+ S,
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),
173
175
  "data-scribe-root": !0,
174
- style: O,
175
- children: [/* @__PURE__ */ g("div", {
176
- className: e("scribe-frame", _ && "scribe-frame--editable"),
176
+ style: A,
177
+ children: [/* @__PURE__ */ v("div", {
178
+ className: e("scribe-frame", y && "scribe-frame--editable"),
177
179
  children: [
178
- b && T ? /* @__PURE__ */ h(t, { editor: b }) : null,
179
- /* @__PURE__ */ g("div", {
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]
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,
184
+ children: [
185
+ /* @__PURE__ */ _(r, {
186
+ editor: S,
187
+ onKeyDown: M
188
+ }),
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
192
+ ]
186
193
  }),
187
- j ? /* @__PURE__ */ h(c, { editor: b }) : null
194
+ N ? /* @__PURE__ */ _(u, { editor: S }) : null
188
195
  ]
189
- }), /* @__PURE__ */ h("div", {
196
+ }), /* @__PURE__ */ _("div", {
190
197
  className: "scribe-popup-root",
191
198
  "data-scribe-popup-root": !0
192
199
  })]
193
200
  });
194
201
  });
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({
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({
198
205
  ariaLabel: r,
199
206
  editable: a
200
207
  });
201
- g.current = {
208
+ p.current = {
202
209
  ariaLabel: r,
203
210
  editable: a
204
211
  };
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,
212
+ let m = typeof f == "function" ? function(e) {
213
+ let t = p.current;
214
+ return x(f.call(this, e), t.ariaLabel, t.editable);
215
+ } : x(f ?? {}, r, a), [v] = g(() => ({
216
+ ...o,
217
+ content: i ?? o?.content,
211
218
  editable: a,
212
- extensions: [...o({
219
+ extensions: [...c({
213
220
  ...e,
214
221
  onTableOfContentsChange: u
215
- }), ...c ?? []],
222
+ }), ...s ?? []],
216
223
  editorProps: {
217
- ...s?.editorProps,
218
- attributes: _
224
+ ...o?.editorProps,
225
+ attributes: m
219
226
  },
220
- shouldRerenderOnTransaction: s?.shouldRerenderOnTransaction ?? !1
221
- })), S = n(v);
222
- return S ? /* @__PURE__ */ h(x, {
227
+ shouldRerenderOnTransaction: o?.shouldRerenderOnTransaction ?? !1
228
+ })), y = n(v);
229
+ return y ? /* @__PURE__ */ _(C, {
223
230
  ...e,
224
231
  ref: t,
225
- editor: S,
232
+ editor: y,
226
233
  initialContentWasApplied: !0,
227
234
  tableOfContentsItemsRef: d
228
235
  }) : null;
229
236
  });
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, {
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, {
234
241
  ...e,
235
242
  ref: t,
236
243
  editor: n,
@@ -238,14 +245,14 @@ var C = l((e, t) => {
238
245
  tableOfContentsItemsRef: i
239
246
  }) : null;
240
247
  });
241
- C.displayName = "ExternalScribe";
242
- var w = l((e, t) => e.externalEditor ? /* @__PURE__ */ h(C, {
248
+ T.displayName = "ExternalScribe";
249
+ var E = d((e, t) => e.externalEditor ? /* @__PURE__ */ _(T, {
243
250
  ...e,
244
251
  ref: t
245
- }) : /* @__PURE__ */ h(S, {
252
+ }) : /* @__PURE__ */ _(w, {
246
253
  ...e,
247
254
  ref: t
248
255
  }));
249
- w.displayName = "Scribe";
256
+ E.displayName = "Scribe";
250
257
  //#endregion
251
- export { w as Scribe, s as SuggestionItemType };
258
+ export { E as Scribe, l as SuggestionItemType };
@@ -1175,24 +1175,26 @@ function pn(e, t, n) {
1175
1175
  }
1176
1176
  var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1177
1177
  let { selection: a } = n, { empty: o, ranges: s } = a, c = N(e, r.schema);
1178
- if (i) if (o) {
1179
- let e = Tt(r, c);
1180
- n.addStoredMark(c.create({
1181
- ...e,
1182
- ...t
1183
- }));
1184
- } else s.forEach((e) => {
1185
- let i = e.$from.pos, a = e.$to.pos;
1186
- r.doc.nodesBetween(i, a, (e, r) => {
1187
- let o = Math.max(r, i), s = Math.min(r + e.nodeSize, a);
1188
- e.marks.find((e) => e.type === c) ? e.marks.forEach((e) => {
1189
- c === e.type && n.addMark(o, s, c.create({
1190
- ...e.attrs,
1191
- ...t
1192
- }));
1193
- }) : n.addMark(o, s, c.create(t));
1178
+ if (i) {
1179
+ if (o) {
1180
+ let e = Tt(r, c);
1181
+ n.addStoredMark(c.create({
1182
+ ...e,
1183
+ ...t
1184
+ }));
1185
+ } else s.forEach((e) => {
1186
+ let i = e.$from.pos, a = e.$to.pos;
1187
+ r.doc.nodesBetween(i, a, (e, r) => {
1188
+ let o = Math.max(r, i), s = Math.min(r + e.nodeSize, a);
1189
+ e.marks.find((e) => e.type === c) ? e.marks.forEach((e) => {
1190
+ c === e.type && n.addMark(o, s, c.create({
1191
+ ...e.attrs,
1192
+ ...t
1193
+ }));
1194
+ }) : n.addMark(o, s, c.create(t));
1195
+ });
1194
1196
  });
1195
- });
1197
+ }
1196
1198
  return pn(r, n, c);
1197
1199
  }, hn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), gn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
1198
1200
  let a = j(e, n.schema), o;
@@ -1635,14 +1637,16 @@ function Zn(e) {
1635
1637
  let a = g.slice(0, i);
1636
1638
  m = a.trim();
1637
1639
  let o = e.slice(0, p + i + n[0].length), c = [];
1638
- if (m) if (s === "block") for (c = r.blockTokens(a), c.forEach((e) => {
1639
- e.text && (!e.tokens || e.tokens.length === 0) && (e.tokens = r.inlineTokens(e.text));
1640
- }); c.length > 0;) {
1641
- let e = c[c.length - 1];
1642
- if (e.type === "paragraph" && (!e.text || e.text.trim() === "")) c.pop();
1643
- else break;
1640
+ if (m) {
1641
+ if (s === "block") for (c = r.blockTokens(a), c.forEach((e) => {
1642
+ e.text && (!e.tokens || e.tokens.length === 0) && (e.tokens = r.inlineTokens(e.text));
1643
+ }); c.length > 0;) {
1644
+ let e = c[c.length - 1];
1645
+ if (e.type === "paragraph" && (!e.text || e.text.trim() === "")) c.pop();
1646
+ else break;
1647
+ }
1648
+ else c = r.inlineTokens(m);
1644
1649
  }
1645
- else c = r.inlineTokens(m);
1646
1650
  return {
1647
1651
  type: t,
1648
1652
  raw: o,
@@ -2664,13 +2668,15 @@ var $ = class e extends sr {
2664
2668
  closest(e, t = {}) {
2665
2669
  let n = null, r = this.parent;
2666
2670
  for (; r && !n;) {
2667
- if (r.node.type.name === e) if (Object.keys(t).length > 0) {
2668
- let e = r.node.attrs, n = Object.keys(t);
2669
- for (let r = 0; r < n.length; r += 1) {
2670
- let i = n[r];
2671
- if (e[i] !== t[i]) break;
2672
- }
2673
- } else n = r;
2671
+ if (r.node.type.name === e) {
2672
+ if (Object.keys(t).length > 0) {
2673
+ let e = r.node.attrs, n = Object.keys(t);
2674
+ for (let r = 0; r < n.length; r += 1) {
2675
+ let i = n[r];
2676
+ if (e[i] !== t[i]) break;
2677
+ }
2678
+ } else n = r;
2679
+ }
2674
2680
  r = r.parent;
2675
2681
  }
2676
2682
  return n;
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./rolldown-runtime-CtkjhSXr.js";
2
- import { t } from "./dist-DErUltkU.js";
2
+ import { t } from "./dist-DFua_Xbu.js";
3
3
  import * as n from "react";
4
4
  import r, { createContext as i, forwardRef as a, useContext as o, useDebugValue as s, useEffect as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f, version as p } from "react";
5
5
  import m, { flushSync as h } from "react-dom";