reactjs-tiptap-editor 1.0.6 → 1.0.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 (176) hide show
  1. package/lib/{ActionMenuButton-htJNI0Fa.js → ActionMenuButton-Cc0vy5hy.js} +10 -13
  2. package/lib/ActionMenuButton-t7e5GCJp.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +23 -25
  5. package/lib/Blockquote.cjs +2 -2
  6. package/lib/Blockquote.js +5 -6
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +5 -6
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +11 -12
  11. package/lib/Clear.cjs +1 -1
  12. package/lib/Clear.js +3 -3
  13. package/lib/Code.cjs +1 -1
  14. package/lib/Code.js +9 -10
  15. package/lib/CodeBlock.cjs +39 -39
  16. package/lib/CodeBlock.js +837 -946
  17. package/lib/CodeView.cjs +1 -1
  18. package/lib/CodeView.js +8 -9
  19. package/lib/Color.cjs +1 -1
  20. package/lib/Color.js +18 -19
  21. package/lib/Column.cjs +1 -1
  22. package/lib/Column.js +5 -6
  23. package/lib/{Drawer-1211urKj.js → Drawer-C6WTtcd0.js} +16 -17
  24. package/lib/Drawer-DRdsK4f_.cjs +1 -0
  25. package/lib/Drawer.cjs +1 -1
  26. package/lib/Drawer.js +3 -3
  27. package/lib/Emoji.cjs +1 -1
  28. package/lib/Emoji.js +15 -16
  29. package/lib/{Excalidraw-Du3hBR8t.js → Excalidraw-DjO5sCC_.js} +31 -32
  30. package/lib/Excalidraw-gJ99kWdS.cjs +1 -0
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +2 -2
  33. package/lib/ExportPdf.cjs +1 -1
  34. package/lib/ExportPdf.js +17 -18
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +5 -6
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +5 -5
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +5 -5
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +15 -15
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +7 -8
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +8 -10
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +5 -6
  49. package/lib/Icon-DHNSWrSX.cjs +1 -0
  50. package/lib/{Icon-C-qYUAS1.js → Icon-prdLEHMN.js} +3 -4
  51. package/lib/{Iframe-DTYTLQE6.js → Iframe-CERKUXQh.js} +13 -14
  52. package/lib/Iframe-CvymVtpM.cjs +1 -0
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +2 -2
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +48 -49
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +22 -23
  59. package/lib/ImportWord.cjs +2 -2
  60. package/lib/ImportWord.js +10 -11
  61. package/lib/{Indent-jOPn3eUM.js → Indent-BfEOOT5B.js} +24 -25
  62. package/lib/Indent-CE6kk62r.cjs +1 -0
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +2 -2
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +10 -11
  67. package/lib/{Katex-CERSrcTP.js → Katex-5KNTSK8T.js} +21 -22
  68. package/lib/Katex-CJ2Fmvut.cjs +4 -0
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +2 -2
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +14 -15
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-B5SdhOfa.js → LinkEditBlock-CFkyS2Ze.js} +55 -56
  76. package/lib/{LinkEditBlock-DaxljgJC.cjs → LinkEditBlock-D6z0Yohc.cjs} +2 -2
  77. package/lib/Mention.cjs +1 -1
  78. package/lib/Mention.js +138 -132
  79. package/lib/Mermaid.cjs +2 -2
  80. package/lib/Mermaid.js +20 -20
  81. package/lib/MoreMark.cjs +1 -1
  82. package/lib/MoreMark.js +22 -24
  83. package/lib/OrderedList.cjs +1 -1
  84. package/lib/OrderedList.js +5 -6
  85. package/lib/SearchAndReplace.cjs +1 -1
  86. package/lib/SearchAndReplace.js +18 -19
  87. package/lib/SlashCommand.cjs +1 -1
  88. package/lib/SlashCommand.js +13 -13
  89. package/lib/Strike.cjs +1 -1
  90. package/lib/Strike.js +5 -6
  91. package/lib/{Table-39OkCQbu.js → Table-CWbY_hqo.js} +7 -8
  92. package/lib/Table-D9pRzwFU.cjs +9 -0
  93. package/lib/Table.cjs +1 -1
  94. package/lib/Table.js +1 -1
  95. package/lib/TaskList.cjs +1 -1
  96. package/lib/TaskList.js +13 -14
  97. package/lib/TextAlign.cjs +1 -1
  98. package/lib/TextAlign.js +17 -19
  99. package/lib/TextDirection.cjs +1 -1
  100. package/lib/TextDirection.js +17 -19
  101. package/lib/TextUnderline.cjs +1 -1
  102. package/lib/TextUnderline.js +5 -6
  103. package/lib/{Twitter-D7PhLycr.js → Twitter-BV7HA-MO.js} +566 -525
  104. package/lib/Twitter-D7NK3MZe.cjs +1 -0
  105. package/lib/Twitter.cjs +1 -1
  106. package/lib/Twitter.js +2 -2
  107. package/lib/Video.cjs +1 -1
  108. package/lib/Video.js +24 -25
  109. package/lib/bubble.cjs +4 -4
  110. package/lib/bubble.js +433 -423
  111. package/lib/{button-Crm67hfl.js → button-0963_Pa8.js} +3 -4
  112. package/lib/button-Bxfjx9_Y.cjs +1 -0
  113. package/lib/{checkbox-DViVmgJ6.js → checkbox-D4p6-UMt.js} +1 -1
  114. package/lib/{checkbox-NQC2MdGT.cjs → checkbox-Q6FcMQW5.cjs} +1 -1
  115. package/lib/{dialog-Ce9Cjfft.js → dialog-B-9_Z5j2.js} +1 -1
  116. package/lib/{dialog-DaHBd2zw.cjs → dialog-D-oYxagG.cjs} +1 -1
  117. package/lib/{dropdown-menu-CQykJhBs.js → dropdown-menu-par18QL5.js} +1 -1
  118. package/lib/{dropdown-menu-CSCDQtq0.cjs → dropdown-menu-r8XibZQU.cjs} +1 -1
  119. package/lib/extensions/Mention/Mention.d.ts +3 -1
  120. package/lib/extensions/Mention/components/NodeViewMentionList.d.ts +7 -1
  121. package/lib/{index-DCJheRBq.cjs → index--nUS7Y66.cjs} +1 -1
  122. package/lib/{index-DLqogznp.cjs → index-BBNITgNi.cjs} +7 -7
  123. package/lib/index-BFXkgG1P.cjs +7 -0
  124. package/lib/{index-prphFVsp.js → index-BQ6ZdLsu.js} +1 -1
  125. package/lib/{index-DylewabB.cjs → index-BZ6DfR2r.cjs} +1 -1
  126. package/lib/{index-D-FhWysc.js → index-BimeTI7q.js} +1 -1
  127. package/lib/{index-TMqmkmT6.cjs → index-CApXPpjF.cjs} +1 -1
  128. package/lib/{index-nFjllrEl.js → index-CbIQPoF6.js} +19 -18
  129. package/lib/{index-BeUrdBxf.js → index-EKFybgpP.js} +1 -1
  130. package/lib/{index-DuZCJJSp.js → index-pgx8gyoC.js} +1118 -504
  131. package/lib/index.cjs +2 -2
  132. package/lib/index.js +8 -9
  133. package/lib/{input-tU3H__39.cjs → input-CZUkD6wF.cjs} +1 -1
  134. package/lib/{input-DfqFAyKo.js → input-cclJoUeC.js} +1 -1
  135. package/lib/{isNumber-CTm1pIvN.js → isNumber-8HKEgTkA.js} +1 -1
  136. package/lib/{isNumber-C2saEiG2.cjs → isNumber-Bv1Qhmw8.cjs} +1 -1
  137. package/lib/label-CFaBdRGz.cjs +1 -0
  138. package/lib/label-aveW7pdK.js +18 -0
  139. package/lib/{popover-CZWSQZ0q.cjs → popover-BWYZO_fD.cjs} +1 -1
  140. package/lib/{popover-CoepUobG.js → popover-D5YZPv2r.js} +1 -1
  141. package/lib/{separator-DCQD8P6s.cjs → separator-B978cwAm.cjs} +1 -1
  142. package/lib/{separator-6SnwzytZ.js → separator-BHjFVmZr.js} +18 -18
  143. package/lib/{store-726Zjszt.cjs → store-BsBiawfz.cjs} +1 -1
  144. package/lib/{store-ibARMQ3h.js → store-BsMMRKFd.js} +1 -1
  145. package/lib/style.css +1 -1
  146. package/lib/{tabs-DrkJL_C2.js → tabs-Bj8EvAkY.js} +1 -1
  147. package/lib/{tabs-B_ArrG09.cjs → tabs-CUMyiV80.cjs} +1 -1
  148. package/lib/{textarea-CmZVZKOo.cjs → textarea-BKb7LDw1.cjs} +1 -1
  149. package/lib/{textarea-CIs52G8B.js → textarea-CClyW-74.js} +1 -1
  150. package/lib/{throttle-CGM5M2yG.js → throttle-BIkZV3Y_.js} +1 -1
  151. package/lib/{throttle-DXN-aiH5.cjs → throttle-BM3Bmbf_.cjs} +1 -1
  152. package/lib/{updatePosition-DpMKxYdN.js → updatePosition-GLTrgcib.js} +1 -1
  153. package/lib/{updatePosition-C17CDdjq.cjs → updatePosition-u2mTh3mG.cjs} +1 -1
  154. package/lib/useButtonProps-B0riSJs9.cjs +1 -0
  155. package/lib/{useButtonProps-D0SrPzuG.js → useButtonProps-StwAz7Ha.js} +35 -47
  156. package/package.json +58 -54
  157. package/lib/ActionMenuButton-DYT5chmX.cjs +0 -1
  158. package/lib/Drawer-DUFUd5BW.cjs +0 -1
  159. package/lib/Excalidraw-CajgZDjU.cjs +0 -1
  160. package/lib/Icon-BjR_or8V.cjs +0 -1
  161. package/lib/Iframe-CM6mRQmv.cjs +0 -1
  162. package/lib/Indent-BmhiEb0S.cjs +0 -1
  163. package/lib/Katex-CUd3LxLh.cjs +0 -4
  164. package/lib/Table-3VstSlg4.cjs +0 -9
  165. package/lib/Twitter-DuHPeVW1.cjs +0 -1
  166. package/lib/button-xNppt_aK.cjs +0 -1
  167. package/lib/index-BQ17A_37.js +0 -393
  168. package/lib/index-CNzHZDls.cjs +0 -7
  169. package/lib/index-DmOTQudI.cjs +0 -1
  170. package/lib/label-DC33TZy_.js +0 -19
  171. package/lib/label-DkDE77kc.cjs +0 -1
  172. package/lib/toggle-DVCNvcqp.cjs +0 -1
  173. package/lib/toggle-xchtz-Kf.js +0 -92
  174. package/lib/tooltip-BTFcHrd9.js +0 -24
  175. package/lib/tooltip-DFjcKu9a.cjs +0 -1
  176. package/lib/useButtonProps-bei1vI37.cjs +0 -1
package/lib/Mention.js CHANGED
@@ -1,38 +1,37 @@
1
- import { N as w, B as v, m as c, C as g, G as T } from "./index-nFjllrEl.js";
2
- import { Node as L } from "@tiptap/pm/model";
3
- import { S as M, u as f } from "./updatePosition-DpMKxYdN.js";
4
- import { PluginKey as S } from "@tiptap/pm/state";
5
- import { jsx as m } from "react/jsx-runtime";
6
- import { forwardRef as H, useRef as A, useState as C, useEffect as p, useImperativeHandle as N } from "react";
7
- import $ from "scroll-into-view-if-needed";
8
- import { g as x } from "./dom-dataset-CIEeltF6.js";
9
- function k({
1
+ import { N as w, B as T, m as h, C as p, E as M, G as L } from "./index-CbIQPoF6.js";
2
+ import { Node as S } from "@tiptap/pm/model";
3
+ import { S as H, u as f } from "./updatePosition-GLTrgcib.js";
4
+ import { PluginKey as A } from "@tiptap/pm/state";
5
+ import { jsx as g, jsxs as C } from "react/jsx-runtime";
6
+ import { forwardRef as N, useRef as $, useState as k, useEffect as x, useImperativeHandle as E } from "react";
7
+ import K from "scroll-into-view-if-needed";
8
+ function _({
10
9
  editor: e,
11
10
  overrideSuggestionOptions: t,
12
- extensionName: r,
13
- char: n = "@"
11
+ extensionName: n,
12
+ char: r = "@"
14
13
  }) {
15
- const i = new S();
14
+ const o = new A();
16
15
  return {
17
16
  editor: e,
18
- char: n,
19
- pluginKey: i,
17
+ char: r,
18
+ pluginKey: o,
20
19
  command: ({ editor: s, range: a, props: l }) => {
21
- var u, o, d;
22
- const h = s.view.state.selection.$to.nodeAfter;
23
- ((u = h == null ? void 0 : h.text) == null ? void 0 : u.startsWith(" ")) && (a.to += 1), s.chain().focus().insertContentAt(a, [
20
+ var u, i, d;
21
+ const c = s.view.state.selection.$to.nodeAfter;
22
+ ((u = c == null ? void 0 : c.text) == null ? void 0 : u.startsWith(" ")) && (a.to += 1), s.chain().focus().insertContentAt(a, [
24
23
  {
25
- type: r,
26
- attrs: { ...l, mentionSuggestionChar: n }
24
+ type: n,
25
+ attrs: { ...l, mentionSuggestionChar: r }
27
26
  },
28
27
  {
29
28
  type: "text",
30
29
  text: " "
31
30
  }
32
- ]).run(), (d = (o = s.view.dom.ownerDocument.defaultView) == null ? void 0 : o.getSelection()) == null || d.collapseToEnd();
31
+ ]).run(), (d = (i = s.view.dom.ownerDocument.defaultView) == null ? void 0 : i.getSelection()) == null || d.collapseToEnd();
33
32
  },
34
33
  allow: ({ state: s, range: a }) => {
35
- const l = s.doc.resolve(a.from), u = s.schema.nodes[r];
34
+ const l = s.doc.resolve(a.from), u = s.schema.nodes[n];
36
35
  return !!l.parent.type.contentMatch.matchType(u);
37
36
  },
38
37
  ...t
@@ -40,7 +39,7 @@ function k({
40
39
  }
41
40
  function y(e) {
42
41
  return (e.options.suggestions.length ? e.options.suggestions : [e.options.suggestion]).map(
43
- (t) => k({
42
+ (t) => _({
44
43
  // @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
45
44
  editor: e.editor,
46
45
  overrideSuggestionOptions: t,
@@ -50,8 +49,8 @@ function y(e) {
50
49
  );
51
50
  }
52
51
  function b(e, t) {
53
- const r = y(e), n = r.find((i) => i.char === t);
54
- return n || (r.length ? r[0] : null);
52
+ const n = y(e), r = n.find((o) => o.char === t);
53
+ return r || (n.length ? n[0] : null);
55
54
  }
56
55
  var D = w.create({
57
56
  name: "mention",
@@ -60,16 +59,16 @@ var D = w.create({
60
59
  return {
61
60
  HTMLAttributes: {},
62
61
  renderText({ node: e, suggestion: t }) {
63
- var r, n;
64
- return `${(r = t == null ? void 0 : t.char) != null ? r : "@"}${(n = e.attrs.label) != null ? n : e.attrs.id}`;
62
+ var n, r;
63
+ return `${(n = t == null ? void 0 : t.char) != null ? n : "@"}${(r = e.attrs.label) != null ? r : e.attrs.id}`;
65
64
  },
66
65
  deleteTriggerWithBackspace: !1,
67
- renderHTML({ options: e, node: t, suggestion: r }) {
68
- var n, i;
66
+ renderHTML({ options: e, node: t, suggestion: n }) {
67
+ var r, o;
69
68
  return [
70
69
  "span",
71
- c(this.HTMLAttributes, e.HTMLAttributes),
72
- `${(n = r == null ? void 0 : r.char) != null ? n : "@"}${(i = t.attrs.label) != null ? i : t.attrs.id}`
70
+ h(this.HTMLAttributes, e.HTMLAttributes),
71
+ `${(r = n == null ? void 0 : n.char) != null ? r : "@"}${(o = t.attrs.label) != null ? o : t.attrs.id}`
73
72
  ];
74
73
  },
75
74
  suggestions: [],
@@ -114,45 +113,45 @@ var D = w.create({
114
113
  ];
115
114
  },
116
115
  renderHTML({ node: e, HTMLAttributes: t }) {
117
- const r = b(this, e.attrs.mentionSuggestionChar);
116
+ const n = b(this, e.attrs.mentionSuggestionChar);
118
117
  if (this.options.renderLabel !== void 0)
119
118
  return console.warn("renderLabel is deprecated use renderText and renderHTML instead"), [
120
119
  "span",
121
- c({ "data-type": this.name }, this.options.HTMLAttributes, t),
120
+ h({ "data-type": this.name }, this.options.HTMLAttributes, t),
122
121
  this.options.renderLabel({
123
122
  options: this.options,
124
123
  node: e,
125
- suggestion: r
124
+ suggestion: n
126
125
  })
127
126
  ];
128
- const n = { ...this.options };
129
- n.HTMLAttributes = c(
127
+ const r = { ...this.options };
128
+ r.HTMLAttributes = h(
130
129
  { "data-type": this.name },
131
130
  this.options.HTMLAttributes,
132
131
  t
133
132
  );
134
- const i = this.options.renderHTML({
135
- options: n,
133
+ const o = this.options.renderHTML({
134
+ options: r,
136
135
  node: e,
137
- suggestion: r
136
+ suggestion: n
138
137
  });
139
- return typeof i == "string" ? ["span", c({ "data-type": this.name }, this.options.HTMLAttributes, t), i] : i;
138
+ return typeof o == "string" ? ["span", h({ "data-type": this.name }, this.options.HTMLAttributes, t), o] : o;
140
139
  },
141
- ...v({
140
+ ...T({
142
141
  nodeName: "mention",
143
142
  name: "@",
144
143
  selfClosing: !0,
145
144
  allowedAttributes: ["id", "label", { name: "mentionSuggestionChar", skipIfDefault: "@" }],
146
145
  parseAttributes: (e) => {
147
- const t = {}, r = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
148
- let n = r.exec(e);
149
- for (; n !== null; ) {
150
- const [, i, s, a] = n, l = s ?? a;
151
- t[i === "char" ? "mentionSuggestionChar" : i] = l, n = r.exec(e);
146
+ const t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
147
+ let r = n.exec(e);
148
+ for (; r !== null; ) {
149
+ const [, o, s, a] = r, l = s ?? a;
150
+ t[o === "char" ? "mentionSuggestionChar" : o] = l, r = n.exec(e);
152
151
  }
153
152
  return t;
154
153
  },
155
- serializeAttributes: (e) => Object.entries(e).filter(([, t]) => t != null).map(([t, r]) => `${t === "mentionSuggestionChar" ? "char" : t}="${r}"`).join(" ")
154
+ serializeAttributes: (e) => Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => `${t === "mentionSuggestionChar" ? "char" : t}="${n}"`).join(" ")
156
155
  }),
157
156
  renderText({ node: e }) {
158
157
  const t = {
@@ -165,110 +164,117 @@ var D = w.create({
165
164
  addKeyboardShortcuts() {
166
165
  return {
167
166
  Backspace: () => this.editor.commands.command(({ tr: e, state: t }) => {
168
- let r = !1;
169
- const { selection: n } = t, { empty: i, anchor: s } = n;
170
- if (!i)
167
+ let n = !1;
168
+ const { selection: r } = t, { empty: o, anchor: s } = r;
169
+ if (!o)
171
170
  return !1;
172
- let a = new L(), l = 0;
173
- return t.doc.nodesBetween(s - 1, s, (u, o) => {
171
+ let a = new S(), l = 0;
172
+ return t.doc.nodesBetween(s - 1, s, (u, i) => {
174
173
  if (u.type.name === this.name)
175
- return r = !0, a = u, l = o, !1;
176
- }), r && e.insertText(
174
+ return n = !0, a = u, l = i, !1;
175
+ }), n && e.insertText(
177
176
  this.options.deleteTriggerWithBackspace ? "" : a.attrs.mentionSuggestionChar,
178
177
  l,
179
178
  l + a.nodeSize
180
- ), r;
179
+ ), n;
181
180
  })
182
181
  };
183
182
  },
184
183
  addProseMirrorPlugins() {
185
- return y(this).map(M);
184
+ return y(this).map(H);
186
185
  }
187
- }), K = D;
188
- const _ = H((e, t) => {
189
- const r = A(null), [n, i] = C(0), s = (o) => {
190
- const d = e.items[o];
191
- d && e.command({ id: d, label: d });
186
+ }), I = D;
187
+ const R = N((e, t) => {
188
+ const n = $(null), [r, o] = k(0), s = (i) => {
189
+ const d = e.items[i];
190
+ d && e.command(d);
192
191
  }, a = () => {
193
- i((n + e.items.length - 1) % e.items.length);
192
+ o((r + e.items.length - 1) % e.items.length);
194
193
  }, l = () => {
195
- i((n + 1) % e.items.length);
194
+ o((r + 1) % e.items.length);
196
195
  }, u = () => {
197
- s(n);
196
+ s(r);
198
197
  };
199
- return p(() => i(0), [e.items]), p(() => {
200
- if (Number.isNaN(n + 1))
198
+ return x(() => o(0), [e.items]), x(() => {
199
+ if (Number.isNaN(r + 1))
201
200
  return;
202
- const o = r.current.querySelector(`span:nth-of-type(${n + 1})`);
203
- o && $(o, { behavior: "smooth", scrollMode: "if-needed" });
204
- }, [n]), N(t, () => ({
205
- onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a(), !0) : o.key === "ArrowDown" ? (l(), !0) : o.key === "Enter" ? (u(), !0) : !1
206
- })), /* @__PURE__ */ m("div", { className: " !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none", children: /* @__PURE__ */ m("div", { ref: r, children: e.items.length > 0 ? e.items.map((o, d) => /* @__PURE__ */ m(
207
- "span",
201
+ const i = n.current.querySelector(`span:nth-of-type(${r + 1})`);
202
+ i && K(i, { behavior: "smooth", scrollMode: "if-needed" });
203
+ }, [r]), E(t, () => ({
204
+ onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a(), !0) : i.key === "ArrowDown" ? (l(), !0) : i.key === "Enter" ? (u(), !0) : !1
205
+ })), /* @__PURE__ */ g(
206
+ "div",
208
207
  {
209
- className: g("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ", { "bg-item-active": d === n }),
210
- onClick: () => s(d),
211
- children: o
208
+ className: " !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
209
+ "data-richtext-portal": !0,
210
+ ref: n,
211
+ children: /* @__PURE__ */ g("div", { children: e.items.length > 0 ? e.items.map((i, d) => {
212
+ var c;
213
+ return /* @__PURE__ */ C(
214
+ "span",
215
+ {
216
+ className: p("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ", { "bg-item-active": d === r }),
217
+ onClick: (m) => {
218
+ m.preventDefault(), s(d);
219
+ },
220
+ children: [
221
+ ((c = i == null ? void 0 : i.avatar) == null ? void 0 : c.src) && /* @__PURE__ */ g(
222
+ "img",
223
+ {
224
+ alt: i.label,
225
+ className: "richtext-size-5 richtext-rounded-full",
226
+ src: i.avatar.src
227
+ }
228
+ ),
229
+ i == null ? void 0 : i.label
230
+ ]
231
+ },
232
+ `mention-item-${i.id}`
233
+ );
234
+ }) : /* @__PURE__ */ g("div", { className: p("itemUserEmpty, richtext-text-foreground"), children: "Empty" }) })
235
+ }
236
+ );
237
+ });
238
+ function v() {
239
+ let e;
240
+ return {
241
+ onStart: (t) => {
242
+ t.clientRect && (e = new L(R, {
243
+ props: t,
244
+ editor: t.editor
245
+ }), e.element.style.position = "absolute", document.body.appendChild(e.element), f(t.editor, e.element));
212
246
  },
213
- d
214
- )) : /* @__PURE__ */ m("div", { className: g("itemUserEmpty, richtext-text-foreground"), children: "Empty" }) }) });
215
- }), E = [
216
- {
217
- id: "1",
218
- name: "John Doe"
219
- },
220
- {
221
- id: "2",
222
- name: "Jane Doe"
223
- },
224
- {
225
- id: "3",
226
- name: "Alice"
227
- },
228
- {
229
- id: "4",
230
- name: "Bob"
231
- }
232
- ], V = /* @__PURE__ */ K.extend({
233
- addAttributes() {
234
- return {
235
- id: {
236
- default: "",
237
- parseHTML: x("id")
238
- },
239
- label: {
240
- default: "",
241
- parseHTML: x("label")
242
- }
243
- };
244
- }
245
- }).configure({
246
- HTMLAttributes: {
247
- class: "mention"
248
- },
249
- suggestion: {
250
- items: async ({ query: e }) => E.map((r) => r.name).filter((r) => r.toLowerCase().startsWith(e.toLowerCase())),
251
- render: () => {
252
- let e;
253
- return {
254
- onStart: (t) => {
255
- t.clientRect && (e = new T(_, {
256
- props: t,
257
- editor: t.editor
258
- }), e.element.style.position = "absolute", document.body.appendChild(e.element), f(t.editor, e.element));
259
- },
260
- onUpdate(t) {
261
- e.updateProps(t), t.clientRect && f(t.editor, e.element);
262
- },
263
- onKeyDown(t) {
264
- var r;
265
- return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
266
- },
267
- onExit() {
268
- e.destroy(), e.element.remove();
269
- }
270
- };
247
+ onUpdate(t) {
248
+ e.updateProps(t), t.clientRect && f(t.editor, e.element);
249
+ },
250
+ onKeyDown(t) {
251
+ var n;
252
+ return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (n = e.ref) == null ? void 0 : n.onKeyDown(t);
253
+ },
254
+ onExit() {
255
+ e.destroy(), e.element.remove();
271
256
  }
257
+ };
258
+ }
259
+ const V = /* @__PURE__ */ M.create({
260
+ name: "richTextMentionWrapper",
261
+ addExtensions() {
262
+ var t, n, r, o;
263
+ const e = {
264
+ ...this.options
265
+ };
266
+ return (t = this.options) != null && t.suggestion && (e.suggestion = {
267
+ render: v,
268
+ ...this.options.suggestion
269
+ }), (r = (n = this.options) == null ? void 0 : n.suggestions) != null && r.length && (e.suggestions = (o = this.options.suggestions) == null ? void 0 : o.map((s) => ({
270
+ render: v,
271
+ ...s
272
+ }))), [I.configure({
273
+ HTMLAttributes: {
274
+ class: "mention"
275
+ },
276
+ ...e
277
+ })];
272
278
  }
273
279
  });
274
280
  export {
package/lib/Mermaid.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var X=Object.create;var G=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Z(e))!J.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=U(e,l))||a.enumerable});return t};var Q=(t,e,r)=>(r=t!=null?X(Y(t)):{},K(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-DLqogznp.cjs"),B=require("./throttle-DXN-aiH5.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),ee=require("./toggle-DVCNvcqp.cjs"),E=require("./dialog-DaHBd2zw.cjs"),te=require("./textarea-CmZVZKOo.cjs"),L=require("./index-FSRjMsxW.cjs"),z=require("./useButtonProps-bei1vI37.cjs"),re=require("./file-i7e4nQY2.cjs"),ie=require("./button-xNppt_aK.cjs"),se=`graph TB
2
- a-->b`;function ae(){const t=z.useEditorInstance(),e=z.useButtonProps(W.name),{tooltipOptions:r={},isActive:a=void 0,upload:l}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=z.useToggleActive(a),[d,C]=s.useState(se),[q,y]=s.useState(""),[c,_]=s.useState(!1),S=s.useRef(null),[h,k]=s.useState(null),[f,O]=s.useState(!0),D=s.useCallback(u=>{u&&import("mermaid").then(g=>{k(g.default)}).finally(()=>O(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},R=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&c&&R()},[h,c]),s.useEffect(()=>{!f&&h&&c&&I(d)},[h&&d]);const P=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:j}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(l){const i=re.dataURLtoFile(b,A);b=await l(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(d),width:g,height:j},!!d).run()}_(!1)}};return o.jsxs(E.Dialog,{onOpenChange:_,open:c,children:[o.jsx(E.DialogTrigger,{asChild:!0,children:o.jsx(ee.ActionButton,{disabled:T,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{T||_(!0)}})}),o.jsxs(E.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(E.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:D,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:f?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(te.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:u=>C(u.target.value),placeholder:"Text",required:!0,rows:10,value:d,style:{color:"hsl(var(--foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:q},ref:S,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(E.DialogFooter,{children:o.jsx(ie.Button,{disabled:!h,onClick:P,type:"button",children:"Save changes"})})]})]})}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ne({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[T,d]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[C,q]=s.useState({width:0,height:0}),[y]=s.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[c,_]=s.useState(!1),[S,h]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:k}=e==null?void 0:e.attrs,f=s.useMemo(()=>{const{src:i,alt:p,width:x,height:v}=e==null?void 0:e.attrs,w=N.isNumber(x)?`${x}px`:x,n=N.isNumber(v)?`${v}px`:v;return{src:i||void 0,alt:p||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),O=s.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function D(i){q({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const R=s.useCallback(B.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);d(p=>({...p,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function P(i,p){i.preventDefault(),i.stopPropagation();const x=C.width,v=C.height,w=x/v;let n=Number(e.attrs.width),M=Number(e.attrs.height);const m=T.width;n&&!M?(n=n>m?m:n,M=Math.round(n/w)):M&&!n?(n=Math.round(M*w),n=n>m?m:n):!n&&!M?(n=x>m?m:x,M=Math.round(n/w)):n=n>m?m:n,_(!0),h({x:i.clientX,y:i.clientY,w:n,h:M,dir:p})}const u=s.useCallback(B.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!c)return;const{x:p,w:x,dir:v}=S,w=(i.clientX-p)*(/l/.test(v)?-1:1),{width:n,height:M}=e==null?void 0:e.attrs,m=n/M,$=z.clamp(x+w,L.IMAGE_MIN_SIZE,T.width),V=Math.round($/m);r({width:$,height:V})},L.IMAGE_THROTTLE_WAIT_TIME),[c,S,T,r,e==null?void 0:e.attrs]),g=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),I())},[c,I]),j=s.useCallback(()=>{document==null||document.addEventListener("mousemove",u,!0),document==null||document.addEventListener("mouseup",g,!0)},[u,g]),A=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",u,!0),document==null||document.removeEventListener("mouseup",g,!0)},[u,g]);s.useEffect(()=>(c?j():A(),()=>{A()}),[c,j,A]);const b=s.useMemo(()=>new ResizeObserver(()=>R()),[R]);return s.useEffect(()=>(b.observe(t.view.dom),()=>{b.disconnect()}),[t.view.dom,b]),o.jsx(N.NodeViewWrapper,{className:"image-view",style:{...O,width:"100%",textAlign:k},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...O,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:D,src:f.src,style:f.style}),t.view.editable&&(l||c)&&o.jsx("div",{className:"image-resizer",children:y==null?void 0:y.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:p=>P(p,i)},`image-dir-${i}`))})]})})}const W=B.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:r,extension:a})=>{var l;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(l=a==null?void 0:a.options)==null?void 0:l.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return N.ReactNodeViewRenderer(ne)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",N.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=W;exports.RichTextMermaid=ae;
1
+ "use strict";var X=Object.create;var G=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Z(e))!J.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=U(e,l))||a.enumerable});return t};var Q=(t,e,r)=>(r=t!=null?X(Y(t)):{},K(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-BBNITgNi.cjs"),$=require("./throttle-BM3Bmbf_.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),ee=require("./index-BFXkgG1P.cjs"),te=require("./button-Bxfjx9_Y.cjs"),E=require("./dialog-D-oYxagG.cjs"),re=require("./textarea-BKb7LDw1.cjs"),L=require("./index-FSRjMsxW.cjs"),z=require("./useButtonProps-B0riSJs9.cjs"),ie=require("./file-i7e4nQY2.cjs"),se=`graph TB
2
+ a-->b`;function ae(){const t=z.useEditorInstance(),e=z.useButtonProps(W.name),{tooltipOptions:r={},isActive:a=void 0,upload:l}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=z.useToggleActive(a),[d,C]=s.useState(se),[q,y]=s.useState(""),[c,_]=s.useState(!1),S=s.useRef(null),[h,k]=s.useState(null),[f,O]=s.useState(!0),D=s.useCallback(u=>{u&&import("mermaid").then(g=>{k(g.default)}).finally(()=>O(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},R=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&c&&R()},[h,c]),s.useEffect(()=>{!f&&h&&c&&I(d)},[h&&d]);const P=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:j}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(l){const i=ie.dataURLtoFile(b,A);b=await l(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(d),width:g,height:j},!!d).run()}_(!1)}};return o.jsxs(E.Dialog,{onOpenChange:_,open:c,children:[o.jsx(E.DialogTrigger,{asChild:!0,children:o.jsx(ee.ActionButton,{disabled:T,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{T||_(!0)}})}),o.jsxs(E.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(E.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:D,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:f?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(re.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:u=>C(u.target.value),placeholder:"Text",required:!0,rows:10,value:d,style:{color:"hsl(var(--foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:q},ref:S,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(E.DialogFooter,{children:o.jsx(te.Button,{disabled:!h,onClick:P,type:"button",children:"Save changes"})})]})]})}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ne({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[T,d]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[C,q]=s.useState({width:0,height:0}),[y]=s.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[c,_]=s.useState(!1),[S,h]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:k}=e==null?void 0:e.attrs,f=s.useMemo(()=>{const{src:i,alt:p,width:x,height:v}=e==null?void 0:e.attrs,w=N.isNumber(x)?`${x}px`:x,n=N.isNumber(v)?`${v}px`:v;return{src:i||void 0,alt:p||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),O=s.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function D(i){q({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const R=s.useCallback($.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);d(p=>({...p,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function P(i,p){i.preventDefault(),i.stopPropagation();const x=C.width,v=C.height,w=x/v;let n=Number(e.attrs.width),M=Number(e.attrs.height);const m=T.width;n&&!M?(n=n>m?m:n,M=Math.round(n/w)):M&&!n?(n=Math.round(M*w),n=n>m?m:n):!n&&!M?(n=x>m?m:x,M=Math.round(n/w)):n=n>m?m:n,_(!0),h({x:i.clientX,y:i.clientY,w:n,h:M,dir:p})}const u=s.useCallback($.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!c)return;const{x:p,w:x,dir:v}=S,w=(i.clientX-p)*(/l/.test(v)?-1:1),{width:n,height:M}=e==null?void 0:e.attrs,m=n/M,B=z.clamp(x+w,L.IMAGE_MIN_SIZE,T.width),V=Math.round(B/m);r({width:B,height:V})},L.IMAGE_THROTTLE_WAIT_TIME),[c,S,T,r,e==null?void 0:e.attrs]),g=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),I())},[c,I]),j=s.useCallback(()=>{document==null||document.addEventListener("mousemove",u,!0),document==null||document.addEventListener("mouseup",g,!0)},[u,g]),A=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",u,!0),document==null||document.removeEventListener("mouseup",g,!0)},[u,g]);s.useEffect(()=>(c?j():A(),()=>{A()}),[c,j,A]);const b=s.useMemo(()=>new ResizeObserver(()=>R()),[R]);return s.useEffect(()=>(b.observe(t.view.dom),()=>{b.disconnect()}),[t.view.dom,b]),o.jsx(N.NodeViewWrapper,{className:"image-view",style:{...O,width:"100%",textAlign:k},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...O,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:D,src:f.src,style:f.style}),t.view.editable&&(l||c)&&o.jsx("div",{className:"image-resizer",children:y==null?void 0:y.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:p=>P(p,i)},`image-dir-${i}`))})]})})}const W=$.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:r,extension:a})=>{var l;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(l=a==null?void 0:a.options)==null?void 0:l.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return N.ReactNodeViewRenderer(ne)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",N.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=W;exports.RichTextMermaid=ae;
package/lib/Mermaid.js CHANGED
@@ -1,23 +1,23 @@
1
- import { s as U, u as G, m as X, R as Z } from "./index-nFjllrEl.js";
2
- import { a as q, c as Y } from "./throttle-CGM5M2yG.js";
1
+ import { s as U, u as G, m as X, R as Z } from "./index-CbIQPoF6.js";
2
+ import { a as q, c as Y } from "./throttle-BIkZV3Y_.js";
3
3
  import { jsxs as C, jsx as n, Fragment as J } from "react/jsx-runtime";
4
4
  import { useState as m, useRef as K, useCallback as A, useEffect as H, useMemo as P } from "react";
5
5
  import { s as Q, i as tt } from "./shortId-WJVkrvml.js";
6
- import { A as et } from "./toggle-xchtz-Kf.js";
7
- import { D as rt, a as it, b as at, c as st, d as nt } from "./dialog-Ce9Cjfft.js";
8
- import { T as ot } from "./textarea-CIs52G8B.js";
9
- import { I as V, j as W, k as lt } from "./index-0OnGZkVF.js";
10
- import { c as ct, u as dt, a as ut, i as ht } from "./useButtonProps-D0SrPzuG.js";
11
- import { d as mt } from "./file-BLas99n7.js";
12
- import { B as gt } from "./button-Crm67hfl.js";
6
+ import { A as et } from "./index-pgx8gyoC.js";
7
+ import { B as rt } from "./button-0963_Pa8.js";
8
+ import { D as it, a as at, b as st, c as nt, d as ot } from "./dialog-B-9_Z5j2.js";
9
+ import { T as lt } from "./textarea-CClyW-74.js";
10
+ import { I as V, j as W, k as ct } from "./index-0OnGZkVF.js";
11
+ import { c as dt, u as ut, a as ht, f as mt } from "./useButtonProps-StwAz7Ha.js";
12
+ import { d as gt } from "./file-BLas99n7.js";
13
13
  const pt = `graph TB
14
14
  a-->b`;
15
15
  function Ot() {
16
- const e = ct(), t = dt(vt.name), {
16
+ const e = dt(), t = ut(vt.name), {
17
17
  tooltipOptions: i = {},
18
18
  isActive: s = void 0,
19
19
  upload: w
20
- } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = ut(s), [c, S] = m(pt), [D, y] = m(""), [o, _] = m(!1), L = K(null), [d, k] = m(null), [g, O] = m(!0), B = A(
20
+ } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = ht(s), [c, S] = m(pt), [D, y] = m(""), [o, _] = m(!1), L = K(null), [d, k] = m(null), [g, O] = m(!0), B = A(
21
21
  (l) => {
22
22
  l && import("mermaid").then((u) => {
23
23
  k(u.default);
@@ -45,12 +45,12 @@ function Ot() {
45
45
  }, [d, o]), H(() => {
46
46
  !g && d && o && I(c);
47
47
  }, [d && c]), /* @__PURE__ */ C(
48
- rt,
48
+ it,
49
49
  {
50
50
  onOpenChange: _,
51
51
  open: o,
52
52
  children: [
53
- /* @__PURE__ */ n(it, { asChild: !0, children: /* @__PURE__ */ n(
53
+ /* @__PURE__ */ n(at, { asChild: !0, children: /* @__PURE__ */ n(
54
54
  et,
55
55
  {
56
56
  disabled: T,
@@ -62,8 +62,8 @@ function Ot() {
62
62
  }
63
63
  }
64
64
  ) }),
65
- /* @__PURE__ */ C(at, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
66
- /* @__PURE__ */ n(st, { children: "Mermaid" }),
65
+ /* @__PURE__ */ C(st, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
66
+ /* @__PURE__ */ n(nt, { children: "Mermaid" }),
67
67
  /* @__PURE__ */ n(
68
68
  "div",
69
69
  {
@@ -71,7 +71,7 @@ function Ot() {
71
71
  style: { height: "100%", border: "1px solid hsl(var(--border))" },
72
72
  children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(J, { children: /* @__PURE__ */ C("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
73
73
  /* @__PURE__ */ n(
74
- ot,
74
+ lt,
75
75
  {
76
76
  autoFocus: !0,
77
77
  className: "richtext-flex-1",
@@ -97,8 +97,8 @@ function Ot() {
97
97
  ] }) })
98
98
  }
99
99
  ),
100
- /* @__PURE__ */ n(nt, { children: /* @__PURE__ */ n(
101
- gt,
100
+ /* @__PURE__ */ n(ot, { children: /* @__PURE__ */ n(
101
+ rt,
102
102
  {
103
103
  disabled: !d,
104
104
  onClick: async () => {
@@ -107,7 +107,7 @@ function Ot() {
107
107
  const l = L.current.querySelector("svg"), { width: u, height: R } = l.getBoundingClientRect(), N = `mermaid-${Q()}.svg`;
108
108
  let M = tt(l.outerHTML);
109
109
  if (w) {
110
- const r = mt(M, N);
110
+ const r = gt(M, N);
111
111
  M = await w(r);
112
112
  }
113
113
  e == null || e.chain().focus().setMermaid(
@@ -209,7 +209,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
209
209
  q((r) => {
210
210
  if (r.preventDefault(), r.stopPropagation(), !o)
211
211
  return;
212
- const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ = ht(f + x, lt, T.width), j = Math.round($ / h);
212
+ const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ = mt(f + x, ct, T.width), j = Math.round($ / h);
213
213
  i({
214
214
  width: $,
215
215
  height: j
package/lib/MoreMark.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-DLqogznp.cjs"),r=require("react/jsx-runtime"),M=require("react"),x=require("./toggle-DVCNvcqp.cjs");require("./index-CNzHZDls.cjs");const h=require("./useButtonProps-bei1vI37.cjs"),p=require("./dropdown-menu-CSCDQtq0.cjs"),f=require("./index-DmOTQudI.cjs"),S=require("./Icon-BjR_or8V.cjs");var k=c.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),A=c.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function v(){const t=h.useButtonProps(b.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:u,dataState:o}=h.useActive(l),d=M.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(p.DropdownMenu,{children:[r.jsx(p.DropdownMenuTrigger,{asChild:!0,disabled:u,children:r.jsx(x.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(f.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(p.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,a)=>r.jsxs(p.DropdownMenuCheckboxItem,{checked:d===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(S.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:h.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${a}`))})]}):r.jsx(r.Fragment,{})}const b=c.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var a,g;const l=n.options.subscript,u=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((a=n.options.shortcutKeys)==null?void 0:a[0])??["mod","."]},d={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return l!==!1&&e.push(o),u!==!1&&e.push(d),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(m=>m.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(k.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(A.configure(this.options.superscript)),t}});exports.MoreMark=b;exports.RichTextMoreMark=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-BBNITgNi.cjs"),r=require("react/jsx-runtime"),x=require("react"),h=require("./index-BFXkgG1P.cjs"),p=require("./dropdown-menu-r8XibZQU.cjs"),b=require("./useButtonProps-B0riSJs9.cjs"),f=require("./Icon-DHNSWrSX.cjs");var S=c.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),k=c.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function A(){const t=b.useButtonProps(m.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:u,dataState:o}=b.useActive(l),d=x.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(p.DropdownMenu,{children:[r.jsx(p.DropdownMenuTrigger,{asChild:!0,disabled:u,children:r.jsx(h.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(h.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(p.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,a)=>r.jsxs(p.DropdownMenuCheckboxItem,{checked:d===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(f.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:h.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${a}`))})]}):r.jsx(r.Fragment,{})}const m=c.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var a,g;const l=n.options.subscript,u=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((a=n.options.shortcutKeys)==null?void 0:a[0])??["mod","."]},d={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return l!==!1&&e.push(o),u!==!1&&e.push(d),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(M=>M.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(S.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(k.configure(this.options.superscript)),t}});exports.MoreMark=m;exports.RichTextMoreMark=A;
package/lib/MoreMark.js CHANGED
@@ -1,12 +1,10 @@
1
- import { M as h, m, E as b } from "./index-nFjllrEl.js";
1
+ import { M as h, m, E as b } from "./index-CbIQPoF6.js";
2
2
  import { jsx as e, Fragment as f, jsxs as d } from "react/jsx-runtime";
3
3
  import { useMemo as M } from "react";
4
- import { A as x } from "./toggle-xchtz-Kf.js";
5
- import "./index-DuZCJJSp.js";
6
- import { u as A, b as S, g as k } from "./useButtonProps-D0SrPzuG.js";
7
- import { D as v, a as y, b as T, c as K } from "./dropdown-menu-CQykJhBs.js";
8
- import { M as w } from "./index-BQ17A_37.js";
9
- import { I as C } from "./Icon-C-qYUAS1.js";
4
+ import { A as x, M as A, g as S } from "./index-pgx8gyoC.js";
5
+ import { D as k, a as v, b as y, c as T } from "./dropdown-menu-par18QL5.js";
6
+ import { u as K, b as w } from "./useButtonProps-StwAz7Ha.js";
7
+ import { I as C } from "./Icon-prdLEHMN.js";
10
8
  var H = h.create({
11
9
  name: "subscript",
12
10
  addOptions() {
@@ -78,16 +76,16 @@ var H = h.create({
78
76
  };
79
77
  }
80
78
  });
81
- function $() {
82
- const t = A(D.name), {
79
+ function F() {
80
+ const t = K(D.name), {
83
81
  icon: s = void 0,
84
- tooltip: o = void 0,
82
+ tooltip: n = void 0,
85
83
  items: i = [],
86
84
  isActive: a = void 0
87
- } = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: n } = S(a), p = M(() => (n == null ? void 0 : n.title) || "", [n]);
88
- return t ? /* @__PURE__ */ d(v, { children: [
85
+ } = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } = w(a), p = M(() => (o == null ? void 0 : o.title) || "", [o]);
86
+ return t ? /* @__PURE__ */ d(k, { children: [
89
87
  /* @__PURE__ */ e(
90
- y,
88
+ v,
91
89
  {
92
90
  asChild: !0,
93
91
  disabled: c,
@@ -97,14 +95,14 @@ function $() {
97
95
  customClass: "!richtext-w-12 richtext-h-12",
98
96
  disabled: c,
99
97
  icon: s,
100
- tooltip: o,
101
- children: /* @__PURE__ */ e(w, { className: "richtext-size-3 richtext-text-gray-500" })
98
+ tooltip: n,
99
+ children: /* @__PURE__ */ e(A, { className: "richtext-size-3 richtext-text-gray-500" })
102
100
  }
103
101
  )
104
102
  }
105
103
  ),
106
- /* @__PURE__ */ e(T, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
107
- K,
104
+ /* @__PURE__ */ e(y, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
105
+ T,
108
106
  {
109
107
  checked: p === r.title,
110
108
  className: "richtext-flex richtext-items-center richtext-gap-3",
@@ -112,7 +110,7 @@ function $() {
112
110
  children: [
113
111
  /* @__PURE__ */ e(C, { name: r == null ? void 0 : r.icon }),
114
112
  /* @__PURE__ */ e("span", { className: "richtext-ml-1", children: r.title }),
115
- !!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children: k(r.shortcutKeys) })
113
+ !!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children: S(r.shortcutKeys) })
116
114
  ]
117
115
  },
118
116
  `more-mark-${u}`
@@ -127,24 +125,24 @@ const D = /* @__PURE__ */ b.create({
127
125
  var t;
128
126
  return {
129
127
  ...(t = this.parent) == null ? void 0 : t.call(this),
130
- button({ editor: s, extension: o, t: i }) {
128
+ button({ editor: s, extension: n, t: i }) {
131
129
  var u, l;
132
- const a = o.options.subscript, c = o.options.superscript, n = {
130
+ const a = n.options.subscript, c = n.options.superscript, o = {
133
131
  action: () => s.commands.toggleSubscript(),
134
132
  isActive: () => s.isActive("subscript") || !1,
135
133
  disabled: !s.can().toggleSubscript(),
136
134
  icon: "Subscript",
137
135
  title: i("editor.subscript.tooltip"),
138
- shortcutKeys: ((u = o.options.shortcutKeys) == null ? void 0 : u[0]) ?? ["mod", "."]
136
+ shortcutKeys: ((u = n.options.shortcutKeys) == null ? void 0 : u[0]) ?? ["mod", "."]
139
137
  }, p = {
140
138
  action: () => s.commands.toggleSuperscript(),
141
139
  isActive: () => s.isActive("superscript") || !1,
142
140
  disabled: !s.can().toggleSuperscript(),
143
141
  icon: "Superscript",
144
142
  title: i("editor.superscript.tooltip"),
145
- shortcutKeys: ((l = o.options.shortcutKeys) == null ? void 0 : l[1]) ?? ["mod", ","]
143
+ shortcutKeys: ((l = n.options.shortcutKeys) == null ? void 0 : l[1]) ?? ["mod", ","]
146
144
  }, r = [];
147
- return a !== !1 && r.push(n), c !== !1 && r.push(p), {
145
+ return a !== !1 && r.push(o), c !== !1 && r.push(p), {
148
146
  // component: ActionMoreButton,
149
147
  componentProps: {
150
148
  icon: "Type",
@@ -164,5 +162,5 @@ const D = /* @__PURE__ */ b.create({
164
162
  });
165
163
  export {
166
164
  D as MoreMark,
167
- $ as RichTextMoreMark
165
+ F as RichTextMoreMark
168
166
  };