reactjs-tiptap-editor 1.0.7 → 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 (157) hide show
  1. package/lib/{ActionMenuButton-fTe9ka2F.js → ActionMenuButton-Cc0vy5hy.js} +2 -2
  2. package/lib/{ActionMenuButton-wU6jxKJv.cjs → ActionMenuButton-t7e5GCJp.cjs} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +3 -3
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +3 -3
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +3 -3
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +3 -3
  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 +3 -3
  15. package/lib/CodeBlock.cjs +1 -1
  16. package/lib/CodeBlock.js +4 -4
  17. package/lib/CodeView.cjs +1 -1
  18. package/lib/CodeView.js +3 -3
  19. package/lib/Color.cjs +1 -1
  20. package/lib/Color.js +8 -8
  21. package/lib/Column.cjs +1 -1
  22. package/lib/Column.js +3 -3
  23. package/lib/{Drawer-DmtILKW4.js → Drawer-C6WTtcd0.js} +6 -6
  24. package/lib/{Drawer-BGSwHoka.cjs → Drawer-DRdsK4f_.cjs} +1 -1
  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 +5 -5
  29. package/lib/{Excalidraw-CrG8fW-7.js → Excalidraw-DjO5sCC_.js} +5 -5
  30. package/lib/{Excalidraw-BG2U9i30.cjs → Excalidraw-gJ99kWdS.cjs} +1 -1
  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 +3 -3
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +3 -3
  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 +5 -5
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +8 -8
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +4 -4
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +3 -3
  49. package/lib/{Icon-C3j4ls73.cjs → Icon-DHNSWrSX.cjs} +1 -1
  50. package/lib/{Icon-CysGlJkv.js → Icon-prdLEHMN.js} +1 -1
  51. package/lib/{Iframe-BmqguWbj.js → Iframe-CERKUXQh.js} +5 -5
  52. package/lib/{Iframe-CXDghI6m.cjs → Iframe-CvymVtpM.cjs} +1 -1
  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 +13 -13
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +7 -7
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +3 -3
  61. package/lib/{Indent-BhnGkEaY.js → Indent-BfEOOT5B.js} +3 -3
  62. package/lib/{Indent-B1glTHHl.cjs → Indent-CE6kk62r.cjs} +1 -1
  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 +3 -3
  67. package/lib/{Katex-D4eBjS34.js → Katex-5KNTSK8T.js} +6 -6
  68. package/lib/{Katex-BKL_6NWF.cjs → Katex-CJ2Fmvut.cjs} +1 -1
  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 +13 -13
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-D1eSM0kn.js → LinkEditBlock-CFkyS2Ze.js} +9 -9
  76. package/lib/{LinkEditBlock-DW17TyCA.cjs → LinkEditBlock-D6z0Yohc.cjs} +1 -1
  77. package/lib/Mention.cjs +1 -1
  78. package/lib/Mention.js +138 -132
  79. package/lib/Mermaid.cjs +1 -1
  80. package/lib/Mermaid.js +7 -7
  81. package/lib/MoreMark.cjs +1 -1
  82. package/lib/MoreMark.js +12 -12
  83. package/lib/OrderedList.cjs +1 -1
  84. package/lib/OrderedList.js +3 -3
  85. package/lib/SearchAndReplace.cjs +1 -1
  86. package/lib/SearchAndReplace.js +13 -13
  87. package/lib/SlashCommand.cjs +1 -1
  88. package/lib/SlashCommand.js +14 -14
  89. package/lib/Strike.cjs +1 -1
  90. package/lib/Strike.js +3 -3
  91. package/lib/{Table-BIZppoiY.js → Table-CWbY_hqo.js} +5 -5
  92. package/lib/{Table-CIzgfvr9.cjs → Table-D9pRzwFU.cjs} +1 -1
  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 +3 -3
  97. package/lib/TextAlign.cjs +1 -1
  98. package/lib/TextAlign.js +5 -5
  99. package/lib/TextDirection.cjs +1 -1
  100. package/lib/TextDirection.js +5 -5
  101. package/lib/TextUnderline.cjs +1 -1
  102. package/lib/TextUnderline.js +3 -3
  103. package/lib/{Twitter-DhczYjbR.js → Twitter-BV7HA-MO.js} +566 -524
  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 +7 -7
  109. package/lib/bubble.cjs +2 -2
  110. package/lib/bubble.js +35 -23
  111. package/lib/{button-C81t4pb1.js → button-0963_Pa8.js} +1 -1
  112. package/lib/{button-B6ukqDUf.cjs → button-Bxfjx9_Y.cjs} +1 -1
  113. package/lib/{checkbox-CUE9ex4D.js → checkbox-D4p6-UMt.js} +1 -1
  114. package/lib/{checkbox-ZdxysUFa.cjs → checkbox-Q6FcMQW5.cjs} +1 -1
  115. package/lib/{dialog-DMJStzBb.js → dialog-B-9_Z5j2.js} +1 -1
  116. package/lib/{dialog-Cfx8yjkr.cjs → dialog-D-oYxagG.cjs} +1 -1
  117. package/lib/{dropdown-menu-B8iyTZcP.js → dropdown-menu-par18QL5.js} +1 -1
  118. package/lib/{dropdown-menu-Busg3FNn.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-D42xFOzI.cjs → index-BFXkgG1P.cjs} +1 -1
  124. package/lib/{index-ccgHvIfu.js → index-BQ6ZdLsu.js} +1 -1
  125. package/lib/{index-DylewabB.cjs → index-BZ6DfR2r.cjs} +1 -1
  126. package/lib/{index-Dwt9--mS.js → index-BimeTI7q.js} +1 -1
  127. package/lib/{index-TMqmkmT6.cjs → index-CApXPpjF.cjs} +1 -1
  128. package/lib/{index-BvYjBPF9.js → index-CbIQPoF6.js} +12 -11
  129. package/lib/{index-RKufd2EL.js → index-EKFybgpP.js} +1 -1
  130. package/lib/{index--knBGB61.js → index-pgx8gyoC.js} +84 -84
  131. package/lib/index.cjs +1 -1
  132. package/lib/index.js +2 -2
  133. package/lib/{input-BxzQAIRv.cjs → input-CZUkD6wF.cjs} +1 -1
  134. package/lib/{input-DR_5pbuA.js → input-cclJoUeC.js} +1 -1
  135. package/lib/{isNumber-1y3eeW-y.js → isNumber-8HKEgTkA.js} +1 -1
  136. package/lib/{isNumber-C2saEiG2.cjs → isNumber-Bv1Qhmw8.cjs} +1 -1
  137. package/lib/{label-BfWfLggp.cjs → label-CFaBdRGz.cjs} +1 -1
  138. package/lib/{label-D-0oXKCn.js → label-aveW7pdK.js} +1 -1
  139. package/lib/{popover-sP8CwbV-.cjs → popover-BWYZO_fD.cjs} +1 -1
  140. package/lib/{popover-D3spkemr.js → popover-D5YZPv2r.js} +1 -1
  141. package/lib/{separator-yycaNdlI.cjs → separator-B978cwAm.cjs} +1 -1
  142. package/lib/{separator-rM48NeAo.js → separator-BHjFVmZr.js} +4 -4
  143. package/lib/{store-BajRl43v.cjs → store-BsBiawfz.cjs} +1 -1
  144. package/lib/{store-NKeQOve_.js → store-BsMMRKFd.js} +1 -1
  145. package/lib/style.css +1 -1
  146. package/lib/{tabs-Cb6Bmpbb.js → tabs-Bj8EvAkY.js} +1 -1
  147. package/lib/{tabs-D2nCIOVL.cjs → tabs-CUMyiV80.cjs} +1 -1
  148. package/lib/{textarea-Cbwi_h4h.cjs → textarea-BKb7LDw1.cjs} +1 -1
  149. package/lib/{textarea-BYZu1lUC.js → textarea-CClyW-74.js} +1 -1
  150. package/lib/{throttle-CjwXmkIY.js → throttle-BIkZV3Y_.js} +1 -1
  151. package/lib/{throttle-DXN-aiH5.cjs → throttle-BM3Bmbf_.cjs} +1 -1
  152. package/lib/{updatePosition-BAGpT34H.js → updatePosition-GLTrgcib.js} +1 -1
  153. package/lib/{updatePosition-C17CDdjq.cjs → updatePosition-u2mTh3mG.cjs} +1 -1
  154. package/lib/{useButtonProps-TfmRCM9r.cjs → useButtonProps-B0riSJs9.cjs} +1 -1
  155. package/lib/{useButtonProps-BIH_9bXT.js → useButtonProps-StwAz7Ha.js} +2 -2
  156. package/package.json +55 -55
  157. package/lib/Twitter-DwWVNAV5.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-BvYjBPF9.js";
2
- import { Node as L } from "@tiptap/pm/model";
3
- import { S as M, u as f } from "./updatePosition-BAGpT34H.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"),$=require("./throttle-DXN-aiH5.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),ee=require("./index-D42xFOzI.cjs"),te=require("./button-B6ukqDUf.cjs"),E=require("./dialog-Cfx8yjkr.cjs"),re=require("./textarea-Cbwi_h4h.cjs"),L=require("./index-FSRjMsxW.cjs"),z=require("./useButtonProps-TfmRCM9r.cjs"),ie=require("./file-i7e4nQY2.cjs"),se=`graph TB
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
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,14 +1,14 @@
1
- import { s as U, u as G, m as X, R as Z } from "./index-BvYjBPF9.js";
2
- import { a as q, c as Y } from "./throttle-CjwXmkIY.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 "./index--knBGB61.js";
7
- import { B as rt } from "./button-C81t4pb1.js";
8
- import { D as it, a as at, b as st, c as nt, d as ot } from "./dialog-DMJStzBb.js";
9
- import { T as lt } from "./textarea-BYZu1lUC.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
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-BIH_9bXT.js";
11
+ import { c as dt, u as ut, a as ht, f as mt } from "./useButtonProps-StwAz7Ha.js";
12
12
  import { d as gt } from "./file-BLas99n7.js";
13
13
  const pt = `graph TB
14
14
  a-->b`;
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"),x=require("react"),h=require("./index-D42xFOzI.cjs"),f=require("./Icon-C3j4ls73.cjs"),p=require("./dropdown-menu-Busg3FNn.cjs"),b=require("./useButtonProps-TfmRCM9r.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;
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,10 +1,10 @@
1
- import { M as h, m, E as b } from "./index-BvYjBPF9.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, M as A, g as S } from "./index--knBGB61.js";
5
- import { I as k } from "./Icon-CysGlJkv.js";
6
- import { D as v, a as y, b as T, c as K } from "./dropdown-menu-B8iyTZcP.js";
7
- import { u as w, b as C } from "./useButtonProps-BIH_9bXT.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";
8
8
  var H = h.create({
9
9
  name: "subscript",
10
10
  addOptions() {
@@ -77,15 +77,15 @@ var H = h.create({
77
77
  }
78
78
  });
79
79
  function F() {
80
- const t = w(D.name), {
80
+ const t = K(D.name), {
81
81
  icon: s = void 0,
82
82
  tooltip: n = void 0,
83
83
  items: i = [],
84
84
  isActive: a = void 0
85
- } = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } = C(a), p = M(() => (o == null ? void 0 : o.title) || "", [o]);
86
- 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: [
87
87
  /* @__PURE__ */ e(
88
- y,
88
+ v,
89
89
  {
90
90
  asChild: !0,
91
91
  disabled: c,
@@ -101,14 +101,14 @@ function F() {
101
101
  )
102
102
  }
103
103
  ),
104
- /* @__PURE__ */ e(T, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
105
- K,
104
+ /* @__PURE__ */ e(y, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
105
+ T,
106
106
  {
107
107
  checked: p === r.title,
108
108
  className: "richtext-flex richtext-items-center richtext-gap-3",
109
109
  onClick: r.action,
110
110
  children: [
111
- /* @__PURE__ */ e(k, { name: r == null ? void 0 : r.icon }),
111
+ /* @__PURE__ */ e(C, { name: r == null ? void 0 : r.icon }),
112
112
  /* @__PURE__ */ e("span", { className: "richtext-ml-1", children: r.title }),
113
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) })
114
114
  ]
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-TMqmkmT6.cjs"),r=require("react/jsx-runtime"),m=require("./index-D42xFOzI.cjs");require("react");const d=require("./useButtonProps-TfmRCM9r.cjs");function x(){const t=d.useButtonProps(c.name),{icon:e=void 0,tooltip:o=void 0,shortcutKeys:i=void 0,tooltipOptions:u={},action:s=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:n,update:l}=d.useToggleActive(a),v=()=>{n||s&&(s(),l())};return t?r.jsx(m.ActionButton,{action:v,dataState:p,disabled:n,icon:e,shortcutKeys:i,tooltip:o,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=O.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:o,extension:i})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:i.options.shortcutKeys??["mod","shift","7"],tooltip:o("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-CApXPpjF.cjs"),r=require("react/jsx-runtime"),m=require("./index-BFXkgG1P.cjs");require("react");const d=require("./useButtonProps-B0riSJs9.cjs");function x(){const t=d.useButtonProps(c.name),{icon:e=void 0,tooltip:o=void 0,shortcutKeys:i=void 0,tooltipOptions:u={},action:s=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:n,update:l}=d.useToggleActive(a),v=()=>{n||s&&(s(),l())};return t?r.jsx(m.ActionButton,{action:v,dataState:p,disabled:n,icon:e,shortcutKeys:i,tooltip:o,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=O.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:o,extension:i})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:i.options.shortcutKeys??["mod","shift","7"],tooltip:o("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=x;
@@ -1,8 +1,8 @@
1
- import { O as u } from "./index-Dwt9--mS.js";
1
+ import { O as u } from "./index-BimeTI7q.js";
2
2
  import { jsx as n, Fragment as f } from "react/jsx-runtime";
3
- import { A as l } from "./index--knBGB61.js";
3
+ import { A as l } from "./index-pgx8gyoC.js";
4
4
  import "react";
5
- import { u as v, a as O } from "./useButtonProps-BIH_9bXT.js";
5
+ import { u as v, a as O } from "./useButtonProps-StwAz7Ha.js";
6
6
  function K() {
7
7
  const t = v(A.name), {
8
8
  icon: o = void 0,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./index-DLqogznp.cjs"),F=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),f=require("react"),Z=require("./index-D42xFOzI.cjs"),M=require("./Icon-C3j4ls73.cjs"),j=require("./button-B6ukqDUf.cjs"),V=require("./input-BxzQAIRv.cjs"),k=require("./label-BfWfLggp.cjs"),$=require("./popover-sP8CwbV-.cjs"),_=require("./checkbox-ZdxysUFa.cjs"),B=require("./useButtonProps-TfmRCM9r.cjs"),ee=require("./index-FSRjMsxW.cjs");function te(){const{t}=ee.useLocale(),e=B.useEditorInstance(),s=B.useButtonProps(W.name),{icon:n=void 0,tooltip:u=void 0,shortcutKeys:o=void 0,tooltipOptions:c={},action:x=void 0,isActive:h=void 0}=(s==null?void 0:s.componentProps)??{},{disabled:i}=B.useActive(h),[g,d]=f.useState(!1),[p,A]=f.useState(""),[T,N]=f.useState(""),[I,H]=f.useState(!1),[U,E]=f.useState(""),w=()=>{var r,l,R,m;E(`${((l=(r=e==null?void 0:e.storage)==null?void 0:r.searchAndReplace)==null?void 0:l.resultIndex)+1}/${(m=(R=e==null?void 0:e.storage)==null?void 0:R.searchAndReplace)==null?void 0:m.results.length}`)};f.useEffect(()=>{e&&w()},[e]);const z=()=>{i||x&&x()},y=(r=!1)=>{var l,R,m,v,S,D,q,O;e&&(r&&((R=(l=e==null?void 0:e.commands)==null?void 0:l.resetIndex)==null||R.call(l)),(v=(m=e==null?void 0:e.commands)==null?void 0:m.setSearchTerm)==null||v.call(m,p),(D=(S=e==null?void 0:e.commands)==null?void 0:S.setReplaceTerm)==null||D.call(S,T),(O=(q=e==null?void 0:e.commands)==null?void 0:q.setCaseSensitive)==null||O.call(q,I),w())},P=()=>{var v,S;if(!e)return;const{results:r,resultIndex:l}=e.storage.searchAndReplace,R=r[l];if(!R)return;(S=(v=e==null?void 0:e.commands)==null?void 0:v.setTextSelection)==null||S.call(v,R);const{node:m}=e.view.domAtPos(e.state.selection.anchor);m instanceof HTMLElement&&m.scrollIntoView({behavior:"smooth",block:"center"}),w()};f.useEffect(()=>{p.trim()||L(),p.trim()&&y(!0)},[p]),f.useEffect(()=>{T.trim()&&y()},[T]),f.useEffect(()=>{y(!0)},[I]);const G=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replace)==null||l.call(r),P()},J=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.nextSearchResult)==null||l.call(r),P()},Q=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.previousSearchResult)==null||l.call(r),P()},L=()=>{var r,l;A(""),N(""),(l=(r=e==null?void 0:e.commands)==null?void 0:r.resetIndex)==null||l.call(r),w()},X=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replaceAll)==null||l.call(r),E("0/0")};return s?a.jsxs($.Popover,{onOpenChange:d,open:g,children:[a.jsx($.PopoverTrigger,{asChild:!0,disabled:i,children:a.jsx(Z.ActionButton,{action:z,disabled:i,icon:n,shortcutKeys:o,tooltip:u,tooltipOptions:c})}),a.jsxs($.PopoverContent,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:[a.jsxs("div",{className:"richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between",children:[a.jsx(k.Label,{children:t("editor.search.dialog.text")}),a.jsx("span",{className:"richtext-font-semibold",children:U})]}),a.jsxs("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:[a.jsx(V.Input,{autoFocus:!0,className:"richtext-w-full",onChange:r=>A(r.target.value),placeholder:"Text",required:!0,type:"text",value:p}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:Q,children:a.jsx(M.IconComponent,{name:"ChevronUp"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:J,children:a.jsx(M.IconComponent,{name:"ChevronDown"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:L,children:"Clear"})]}),a.jsx(k.Label,{className:"richtext-mb-[6px]",children:t("editor.replace.dialog.text")}),a.jsx("div",{className:"richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:a.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:a.jsx(V.Input,{className:"richtext-w-80",onChange:r=>N(r.target.value),placeholder:"Text",required:!0,type:"text",value:T})})}),a.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1",children:[a.jsx(_.Checkbox,{checked:I,onCheckedChange:r=>{H(r),e.commands.setCaseSensitive(r)}}),a.jsx(k.Label,{children:t("editor.replace.caseSensitive")})]}),a.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[a.jsx(j.Button,{className:"richtext-flex-1",onClick:G,children:t("editor.replace.dialog.text")}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:X,children:t("editor.replaceAll.dialog.text")})]})]})]}):a.jsx(a.Fragment,{})}const C=(t,e)=>e(t.tr);function se(t,e,s){return RegExp(e?t.replace(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`):t,s?"gu":"gui")}function re(t,e,s,n){const u=[],o=[];let c=[],x=0;if(!e)return{decorationsToReturn:b.DecorationSet.empty,results:[]};t==null||t.descendants((h,i)=>{h.isText?c[x]?c[x]={text:c[x].text+h.text,pos:c[x].pos}:c[x]={text:`${h.text}`,pos:i}:x+=1}),c=c.filter(Boolean);for(const h of c){const{text:i,pos:g}=h,d=Array.from(i.matchAll(e)).filter(([p])=>p.trim());for(const p of d){if(p[0]==="")break;p.index!==void 0&&o.push({from:g+p.index,to:g+p.index+p[0].length})}}for(const[h,i]of o.entries()){const g=h===n?`${s} ${s}-current`:s,d=b.Decoration.inline(i.from,i.to,{class:g});u.push(d)}return{decorationsToReturn:b.DecorationSet.create(t,u),results:o}}function K(t,e,{state:s,dispatch:n}){if(!e[0])return;const{from:o,to:c}=e[0];n&&n(s.tr.insertText(t,o,c))}function ne(t,e,s,n){const u=e+1;if(!n[u])return null;const{from:o,to:c}=n[e],x=c-o-t.length+s,{from:h,to:i}=n[u];return n[u]={to:i-x,from:h-x},[x,n]}function ce(t,e,{tr:s,dispatch:n}){let u=0,o=e.slice();if(o.length!==0){for(let c=0;c<o.length;c+=1){const{from:x,to:h}=o[c];s.insertText(t,x,h);const i=ne(t,c,u,o);i&&(u=i[0],o=i[1])}n(s)}}const W=Y.Extension.create({name:"searchAndReplace",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),searchTerm:"",replaceTerm:"",results:[],searchResultClass:"search-result",searchResultCurrentClass:"search-result-current",caseSensitive:!1,disableRegex:!0,onChange:()=>{},button:({editor:e,t:s})=>({componentProps:{action:()=>{},icon:"SearchAndReplace",tooltip:s("editor.searchAndReplace.tooltip"),isActive:()=>!0,editor:e}})}},addStorage(){return{searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}},addCommands(){return{setSearchTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.searchTerm=t,C(s,n),!1),setReplaceTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.replaceTerm=t,C(s,n),!1),setCaseSensitive:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.caseSensitive=t,C(s,n),!1),resetIndex:()=>({editor:t,state:e,dispatch:s})=>(t.storage.searchAndReplace.resultIndex=0,C(e,s),!1),nextSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s+1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s-1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=e.length-1,!1},replace:()=>({editor:t,state:e,dispatch:s})=>{const{replaceTerm:n,results:u,resultIndex:o}=t.storage.searchAndReplace,c=u[o];return c?(K(n,[c],{state:e,dispatch:s}),t.storage.searchAndReplace.results.splice(o,1)):(K(n,u,{state:e,dispatch:s}),t.storage.searchAndReplace.results.shift()),C(e,s),!1},replaceAll:()=>({editor:t,tr:e,state:s,dispatch:n})=>{const{replaceTerm:u,results:o}=t.storage.searchAndReplace;return ce(u,o,{tr:e,dispatch:n}),t.storage.searchAndReplace.resultIndex=0,t.storage.searchAndReplace.results=[],C(s,n),!1}}},addProseMirrorPlugins(){const t=this.editor,{searchResultClass:e,disableRegex:s}=this.options,n=c=>t.storage.searchAndReplace.lastSearchTerm=c,u=c=>t.storage.searchAndReplace.lastCaseSensitive=c,o=c=>t.storage.searchAndReplace.lastResultIndex=c;return[new F.Plugin({key:new F.PluginKey(`richtextCustomPlugin${this.name}`),state:{init:()=>b.DecorationSet.empty,apply({doc:c,docChanged:x},h){const{searchTerm:i,lastSearchTerm:g,caseSensitive:d,lastCaseSensitive:p,resultIndex:A,lastResultIndex:T}=t.storage.searchAndReplace;if(!x&&g===i&&p===d&&T===A)return h;if(n(i),u(d),o(A),!i)return t.storage.searchAndReplace.results=[],b.DecorationSet.empty;const{decorationsToReturn:N,results:I}=re(c,se(i,s,d),e,A);return t.storage.searchAndReplace.results=I,N}},props:{decorations(c){return this.getState(c)}}})]}});exports.RichTextSearchAndReplace=te;exports.SearchAndReplace=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./index-BBNITgNi.cjs"),F=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),f=require("react"),Z=require("./index-BFXkgG1P.cjs"),j=require("./button-Bxfjx9_Y.cjs"),M=require("./input-CZUkD6wF.cjs"),k=require("./label-CFaBdRGz.cjs"),$=require("./popover-BWYZO_fD.cjs"),_=require("./checkbox-Q6FcMQW5.cjs"),B=require("./useButtonProps-B0riSJs9.cjs"),ee=require("./index-FSRjMsxW.cjs"),V=require("./Icon-DHNSWrSX.cjs");function te(){const{t}=ee.useLocale(),e=B.useEditorInstance(),s=B.useButtonProps(W.name),{icon:n=void 0,tooltip:u=void 0,shortcutKeys:o=void 0,tooltipOptions:c={},action:x=void 0,isActive:h=void 0}=(s==null?void 0:s.componentProps)??{},{disabled:i}=B.useActive(h),[g,d]=f.useState(!1),[p,A]=f.useState(""),[T,N]=f.useState(""),[I,H]=f.useState(!1),[U,E]=f.useState(""),w=()=>{var r,l,R,m;E(`${((l=(r=e==null?void 0:e.storage)==null?void 0:r.searchAndReplace)==null?void 0:l.resultIndex)+1}/${(m=(R=e==null?void 0:e.storage)==null?void 0:R.searchAndReplace)==null?void 0:m.results.length}`)};f.useEffect(()=>{e&&w()},[e]);const z=()=>{i||x&&x()},y=(r=!1)=>{var l,R,m,v,S,D,q,O;e&&(r&&((R=(l=e==null?void 0:e.commands)==null?void 0:l.resetIndex)==null||R.call(l)),(v=(m=e==null?void 0:e.commands)==null?void 0:m.setSearchTerm)==null||v.call(m,p),(D=(S=e==null?void 0:e.commands)==null?void 0:S.setReplaceTerm)==null||D.call(S,T),(O=(q=e==null?void 0:e.commands)==null?void 0:q.setCaseSensitive)==null||O.call(q,I),w())},P=()=>{var v,S;if(!e)return;const{results:r,resultIndex:l}=e.storage.searchAndReplace,R=r[l];if(!R)return;(S=(v=e==null?void 0:e.commands)==null?void 0:v.setTextSelection)==null||S.call(v,R);const{node:m}=e.view.domAtPos(e.state.selection.anchor);m instanceof HTMLElement&&m.scrollIntoView({behavior:"smooth",block:"center"}),w()};f.useEffect(()=>{p.trim()||L(),p.trim()&&y(!0)},[p]),f.useEffect(()=>{T.trim()&&y()},[T]),f.useEffect(()=>{y(!0)},[I]);const G=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replace)==null||l.call(r),P()},J=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.nextSearchResult)==null||l.call(r),P()},Q=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.previousSearchResult)==null||l.call(r),P()},L=()=>{var r,l;A(""),N(""),(l=(r=e==null?void 0:e.commands)==null?void 0:r.resetIndex)==null||l.call(r),w()},X=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replaceAll)==null||l.call(r),E("0/0")};return s?a.jsxs($.Popover,{onOpenChange:d,open:g,children:[a.jsx($.PopoverTrigger,{asChild:!0,disabled:i,children:a.jsx(Z.ActionButton,{action:z,disabled:i,icon:n,shortcutKeys:o,tooltip:u,tooltipOptions:c})}),a.jsxs($.PopoverContent,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:[a.jsxs("div",{className:"richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between",children:[a.jsx(k.Label,{children:t("editor.search.dialog.text")}),a.jsx("span",{className:"richtext-font-semibold",children:U})]}),a.jsxs("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:[a.jsx(M.Input,{autoFocus:!0,className:"richtext-w-full",onChange:r=>A(r.target.value),placeholder:"Text",required:!0,type:"text",value:p}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:Q,children:a.jsx(V.IconComponent,{name:"ChevronUp"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:J,children:a.jsx(V.IconComponent,{name:"ChevronDown"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:L,children:"Clear"})]}),a.jsx(k.Label,{className:"richtext-mb-[6px]",children:t("editor.replace.dialog.text")}),a.jsx("div",{className:"richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:a.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:a.jsx(M.Input,{className:"richtext-w-80",onChange:r=>N(r.target.value),placeholder:"Text",required:!0,type:"text",value:T})})}),a.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1",children:[a.jsx(_.Checkbox,{checked:I,onCheckedChange:r=>{H(r),e.commands.setCaseSensitive(r)}}),a.jsx(k.Label,{children:t("editor.replace.caseSensitive")})]}),a.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[a.jsx(j.Button,{className:"richtext-flex-1",onClick:G,children:t("editor.replace.dialog.text")}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:X,children:t("editor.replaceAll.dialog.text")})]})]})]}):a.jsx(a.Fragment,{})}const C=(t,e)=>e(t.tr);function se(t,e,s){return RegExp(e?t.replace(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`):t,s?"gu":"gui")}function re(t,e,s,n){const u=[],o=[];let c=[],x=0;if(!e)return{decorationsToReturn:b.DecorationSet.empty,results:[]};t==null||t.descendants((h,i)=>{h.isText?c[x]?c[x]={text:c[x].text+h.text,pos:c[x].pos}:c[x]={text:`${h.text}`,pos:i}:x+=1}),c=c.filter(Boolean);for(const h of c){const{text:i,pos:g}=h,d=Array.from(i.matchAll(e)).filter(([p])=>p.trim());for(const p of d){if(p[0]==="")break;p.index!==void 0&&o.push({from:g+p.index,to:g+p.index+p[0].length})}}for(const[h,i]of o.entries()){const g=h===n?`${s} ${s}-current`:s,d=b.Decoration.inline(i.from,i.to,{class:g});u.push(d)}return{decorationsToReturn:b.DecorationSet.create(t,u),results:o}}function K(t,e,{state:s,dispatch:n}){if(!e[0])return;const{from:o,to:c}=e[0];n&&n(s.tr.insertText(t,o,c))}function ne(t,e,s,n){const u=e+1;if(!n[u])return null;const{from:o,to:c}=n[e],x=c-o-t.length+s,{from:h,to:i}=n[u];return n[u]={to:i-x,from:h-x},[x,n]}function ce(t,e,{tr:s,dispatch:n}){let u=0,o=e.slice();if(o.length!==0){for(let c=0;c<o.length;c+=1){const{from:x,to:h}=o[c];s.insertText(t,x,h);const i=ne(t,c,u,o);i&&(u=i[0],o=i[1])}n(s)}}const W=Y.Extension.create({name:"searchAndReplace",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),searchTerm:"",replaceTerm:"",results:[],searchResultClass:"search-result",searchResultCurrentClass:"search-result-current",caseSensitive:!1,disableRegex:!0,onChange:()=>{},button:({editor:e,t:s})=>({componentProps:{action:()=>{},icon:"SearchAndReplace",tooltip:s("editor.searchAndReplace.tooltip"),isActive:()=>!0,editor:e}})}},addStorage(){return{searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}},addCommands(){return{setSearchTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.searchTerm=t,C(s,n),!1),setReplaceTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.replaceTerm=t,C(s,n),!1),setCaseSensitive:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.caseSensitive=t,C(s,n),!1),resetIndex:()=>({editor:t,state:e,dispatch:s})=>(t.storage.searchAndReplace.resultIndex=0,C(e,s),!1),nextSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s+1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s-1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=e.length-1,!1},replace:()=>({editor:t,state:e,dispatch:s})=>{const{replaceTerm:n,results:u,resultIndex:o}=t.storage.searchAndReplace,c=u[o];return c?(K(n,[c],{state:e,dispatch:s}),t.storage.searchAndReplace.results.splice(o,1)):(K(n,u,{state:e,dispatch:s}),t.storage.searchAndReplace.results.shift()),C(e,s),!1},replaceAll:()=>({editor:t,tr:e,state:s,dispatch:n})=>{const{replaceTerm:u,results:o}=t.storage.searchAndReplace;return ce(u,o,{tr:e,dispatch:n}),t.storage.searchAndReplace.resultIndex=0,t.storage.searchAndReplace.results=[],C(s,n),!1}}},addProseMirrorPlugins(){const t=this.editor,{searchResultClass:e,disableRegex:s}=this.options,n=c=>t.storage.searchAndReplace.lastSearchTerm=c,u=c=>t.storage.searchAndReplace.lastCaseSensitive=c,o=c=>t.storage.searchAndReplace.lastResultIndex=c;return[new F.Plugin({key:new F.PluginKey(`richtextCustomPlugin${this.name}`),state:{init:()=>b.DecorationSet.empty,apply({doc:c,docChanged:x},h){const{searchTerm:i,lastSearchTerm:g,caseSensitive:d,lastCaseSensitive:p,resultIndex:A,lastResultIndex:T}=t.storage.searchAndReplace;if(!x&&g===i&&p===d&&T===A)return h;if(n(i),u(d),o(A),!i)return t.storage.searchAndReplace.results=[],b.DecorationSet.empty;const{decorationsToReturn:N,results:I}=re(c,se(i,s,d),e,A);return t.storage.searchAndReplace.results=I,N}},props:{decorations(c){return this.getState(c)}}})]}});exports.RichTextSearchAndReplace=te;exports.SearchAndReplace=W;
@@ -1,17 +1,17 @@
1
- import { E as Q } from "./index-BvYjBPF9.js";
1
+ import { E as Q } from "./index-CbIQPoF6.js";
2
2
  import { Plugin as X, PluginKey as Y } from "@tiptap/pm/state";
3
3
  import { DecorationSet as $, Decoration as Z } from "@tiptap/pm/view";
4
4
  import { jsx as u, Fragment as _, jsxs as T } from "react/jsx-runtime";
5
5
  import { useState as b, useEffect as k } from "react";
6
- import { A as ee } from "./index--knBGB61.js";
7
- import { I as V } from "./Icon-CysGlJkv.js";
8
- import { B as N } from "./button-C81t4pb1.js";
9
- import { I as q } from "./input-DR_5pbuA.js";
10
- import { L as B } from "./label-D-0oXKCn.js";
11
- import { P as te, a as se, b as re } from "./popover-D3spkemr.js";
12
- import { C as ne } from "./checkbox-CUE9ex4D.js";
13
- import { c as ce, u as ae, b as le } from "./useButtonProps-BIH_9bXT.js";
6
+ import { A as ee } from "./index-pgx8gyoC.js";
7
+ import { B as N } from "./button-0963_Pa8.js";
8
+ import { I as V } from "./input-cclJoUeC.js";
9
+ import { L as B } from "./label-aveW7pdK.js";
10
+ import { P as te, a as se, b as re } from "./popover-D5YZPv2r.js";
11
+ import { C as ne } from "./checkbox-D4p6-UMt.js";
12
+ import { c as ce, u as ae, b as le } from "./useButtonProps-StwAz7Ha.js";
14
13
  import { u as oe } from "./index-0OnGZkVF.js";
14
+ import { I as q } from "./Icon-prdLEHMN.js";
15
15
  function ye() {
16
16
  const { t } = oe(), e = ce(), s = ae(pe.name), {
17
17
  icon: n = void 0,
@@ -104,7 +104,7 @@ function ye() {
104
104
  ] }),
105
105
  /* @__PURE__ */ T("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
106
106
  /* @__PURE__ */ u(
107
- q,
107
+ V,
108
108
  {
109
109
  autoFocus: !0,
110
110
  className: "richtext-w-full",
@@ -120,7 +120,7 @@ function ye() {
120
120
  {
121
121
  className: "richtext-flex-1",
122
122
  onClick: G,
123
- children: /* @__PURE__ */ u(V, { name: "ChevronUp" })
123
+ children: /* @__PURE__ */ u(q, { name: "ChevronUp" })
124
124
  }
125
125
  ),
126
126
  /* @__PURE__ */ u(
@@ -128,7 +128,7 @@ function ye() {
128
128
  {
129
129
  className: "richtext-flex-1",
130
130
  onClick: z,
131
- children: /* @__PURE__ */ u(V, { name: "ChevronDown" })
131
+ children: /* @__PURE__ */ u(q, { name: "ChevronDown" })
132
132
  }
133
133
  ),
134
134
  /* @__PURE__ */ u(
@@ -142,7 +142,7 @@ function ye() {
142
142
  ] }),
143
143
  /* @__PURE__ */ u(B, { className: "richtext-mb-[6px]", children: t("editor.replace.dialog.text") }),
144
144
  /* @__PURE__ */ u("div", { className: "richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: /* @__PURE__ */ u("div", { className: "richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center", children: /* @__PURE__ */ u(
145
- q,
145
+ V,
146
146
  {
147
147
  className: "richtext-w-80",
148
148
  onChange: (r) => w(r.target.value),