reactjs-tiptap-editor 0.3.29 → 0.3.31

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 (225) hide show
  1. package/lib/{ActionMenuButton-5Y8QcYxD.cjs → ActionMenuButton-BCgqJsST.cjs} +1 -1
  2. package/lib/{ActionMenuButton-Cs9DM_16.js → ActionMenuButton-D97K0UWT.js} +5 -5
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.d.cts +4 -4
  5. package/lib/Attachment.d.ts +4 -4
  6. package/lib/Attachment.js +1 -1
  7. package/lib/Blockquote.cjs +1 -1
  8. package/lib/Blockquote.d.cts +4 -4
  9. package/lib/Blockquote.d.ts +4 -4
  10. package/lib/Blockquote.js +1 -1
  11. package/lib/Bold.cjs +1 -1
  12. package/lib/Bold.d.cts +4 -4
  13. package/lib/Bold.d.ts +4 -4
  14. package/lib/Bold.js +1 -1
  15. package/lib/BulletList.cjs +1 -1
  16. package/lib/BulletList.d.cts +4 -4
  17. package/lib/BulletList.d.ts +4 -4
  18. package/lib/BulletList.js +1 -1
  19. package/lib/Clear.cjs +1 -1
  20. package/lib/Clear.d.cts +4 -4
  21. package/lib/Clear.d.ts +4 -4
  22. package/lib/Clear.js +1 -1
  23. package/lib/Code.cjs +1 -1
  24. package/lib/Code.d.cts +4 -4
  25. package/lib/Code.d.ts +4 -4
  26. package/lib/Code.js +1 -1
  27. package/lib/CodeBlock.cjs +1 -1
  28. package/lib/CodeBlock.d.cts +4 -4
  29. package/lib/CodeBlock.d.ts +4 -4
  30. package/lib/CodeBlock.js +3 -2
  31. package/lib/CodeView.cjs +1 -1
  32. package/lib/CodeView.d.cts +4 -4
  33. package/lib/CodeView.d.ts +4 -4
  34. package/lib/CodeView.js +1 -1
  35. package/lib/Color.cjs +1 -1
  36. package/lib/Color.d.cts +4 -4
  37. package/lib/Color.d.ts +4 -4
  38. package/lib/Color.js +2 -2
  39. package/lib/Document.d.cts +4 -4
  40. package/lib/Document.d.ts +4 -4
  41. package/lib/Drawer-5Q_-WRhc.cjs +1 -0
  42. package/lib/{Drawer-BCmNLh31.js → Drawer-BHkje8ys.js} +250 -249
  43. package/lib/Drawer.cjs +1 -1
  44. package/lib/Drawer.d.cts +4 -4
  45. package/lib/Drawer.d.ts +4 -4
  46. package/lib/Drawer.js +2 -2
  47. package/lib/Emoji.cjs +1 -1
  48. package/lib/Emoji.d.cts +4 -4
  49. package/lib/Emoji.d.ts +4 -4
  50. package/lib/Emoji.js +22 -21
  51. package/lib/Excalidraw-CG498239.js +290 -0
  52. package/lib/Excalidraw-GUVW-IqC.cjs +1 -0
  53. package/lib/Excalidraw.cjs +1 -1
  54. package/lib/Excalidraw.d.cts +4 -4
  55. package/lib/Excalidraw.d.ts +4 -4
  56. package/lib/Excalidraw.js +1 -1
  57. package/lib/ExportPdf.cjs +1 -1
  58. package/lib/ExportPdf.d.cts +4 -4
  59. package/lib/ExportPdf.d.ts +4 -4
  60. package/lib/ExportPdf.js +1 -1
  61. package/lib/ExportWord.cjs +1 -1
  62. package/lib/ExportWord.d.cts +4 -4
  63. package/lib/ExportWord.d.ts +4 -4
  64. package/lib/ExportWord.js +1 -1
  65. package/lib/FontFamily.cjs +1 -1
  66. package/lib/FontFamily.d.cts +4 -4
  67. package/lib/FontFamily.d.ts +4 -4
  68. package/lib/FontFamily.js +11 -10
  69. package/lib/FontSize.cjs +1 -1
  70. package/lib/FontSize.d.cts +4 -4
  71. package/lib/FontSize.d.ts +4 -4
  72. package/lib/FontSize.js +6 -5
  73. package/lib/FormatPainter.cjs +1 -1
  74. package/lib/FormatPainter.d.cts +4 -4
  75. package/lib/FormatPainter.d.ts +4 -4
  76. package/lib/FormatPainter.js +1 -1
  77. package/lib/Heading.cjs +1 -1
  78. package/lib/Heading.d.cts +4 -4
  79. package/lib/Heading.d.ts +4 -4
  80. package/lib/Heading.js +32 -31
  81. package/lib/Highlight.cjs +1 -1
  82. package/lib/Highlight.d.cts +4 -4
  83. package/lib/Highlight.d.ts +4 -4
  84. package/lib/Highlight.js +1 -1
  85. package/lib/History.cjs +1 -1
  86. package/lib/History.d.cts +4 -4
  87. package/lib/History.d.ts +4 -4
  88. package/lib/History.js +1 -1
  89. package/lib/HorizontalRule.cjs +1 -1
  90. package/lib/HorizontalRule.d.cts +4 -4
  91. package/lib/HorizontalRule.d.ts +4 -4
  92. package/lib/HorizontalRule.js +1 -1
  93. package/lib/Iframe.cjs +1 -1
  94. package/lib/Iframe.d.cts +4 -4
  95. package/lib/Iframe.d.ts +4 -4
  96. package/lib/Iframe.js +1 -1
  97. package/lib/Image.cjs +1 -1
  98. package/lib/Image.d.cts +4 -4
  99. package/lib/Image.d.ts +4 -4
  100. package/lib/Image.js +1 -1
  101. package/lib/ImageGif.cjs +1 -1
  102. package/lib/ImageGif.d.cts +4 -4
  103. package/lib/ImageGif.d.ts +4 -4
  104. package/lib/ImageGif.js +1 -1
  105. package/lib/ImportWord.cjs +2 -2
  106. package/lib/ImportWord.d.cts +4 -4
  107. package/lib/ImportWord.d.ts +4 -4
  108. package/lib/ImportWord.js +3 -2
  109. package/lib/Indent.cjs +1 -1
  110. package/lib/Indent.d.cts +4 -4
  111. package/lib/Indent.d.ts +4 -4
  112. package/lib/Indent.js +1 -1
  113. package/lib/Italic.cjs +1 -1
  114. package/lib/Italic.d.cts +4 -4
  115. package/lib/Italic.d.ts +4 -4
  116. package/lib/Italic.js +1 -1
  117. package/lib/Katex.cjs +1 -1
  118. package/lib/Katex.d.cts +4 -4
  119. package/lib/Katex.d.ts +4 -4
  120. package/lib/Katex.js +41 -40
  121. package/lib/LineHeight.cjs +1 -1
  122. package/lib/LineHeight.d.cts +4 -4
  123. package/lib/LineHeight.d.ts +4 -4
  124. package/lib/LineHeight.js +17 -16
  125. package/lib/Link.cjs +1 -1
  126. package/lib/Link.d.cts +4 -4
  127. package/lib/Link.d.ts +4 -4
  128. package/lib/Link.js +1 -1
  129. package/lib/ListItem.d.cts +4 -4
  130. package/lib/ListItem.d.ts +4 -4
  131. package/lib/Mention.d.cts +4 -4
  132. package/lib/Mention.d.ts +4 -4
  133. package/lib/Mermaid.cjs +2 -2
  134. package/lib/Mermaid.d.cts +4 -4
  135. package/lib/Mermaid.d.ts +4 -4
  136. package/lib/Mermaid.js +138 -137
  137. package/lib/MoreMark.cjs +1 -1
  138. package/lib/MoreMark.d.cts +4 -4
  139. package/lib/MoreMark.d.ts +4 -4
  140. package/lib/MoreMark.js +1 -1
  141. package/lib/MultiColumn.cjs +1 -1
  142. package/lib/MultiColumn.d.cts +4 -4
  143. package/lib/MultiColumn.d.ts +4 -4
  144. package/lib/MultiColumn.js +1 -1
  145. package/lib/OrderedList.cjs +1 -1
  146. package/lib/OrderedList.d.cts +4 -4
  147. package/lib/OrderedList.d.ts +4 -4
  148. package/lib/OrderedList.js +1 -1
  149. package/lib/{RichTextEditor-DsUcQSbm.cjs → RichTextEditor-DWlLqTl9.cjs} +4 -4
  150. package/lib/{RichTextEditor-e6q30rbV.js → RichTextEditor-KP2Rgcqe.js} +18 -44
  151. package/lib/SearchAndReplace.cjs +1 -1
  152. package/lib/SearchAndReplace.d.cts +4 -4
  153. package/lib/SearchAndReplace.d.ts +4 -4
  154. package/lib/SearchAndReplace.js +68 -67
  155. package/lib/Selection.d.cts +4 -4
  156. package/lib/Selection.d.ts +4 -4
  157. package/lib/SlashCommand.cjs +1 -1
  158. package/lib/SlashCommand.d.cts +4 -4
  159. package/lib/SlashCommand.d.ts +4 -4
  160. package/lib/SlashCommand.js +1 -1
  161. package/lib/Strike.cjs +1 -1
  162. package/lib/Strike.d.cts +4 -4
  163. package/lib/Strike.d.ts +4 -4
  164. package/lib/Strike.js +1 -1
  165. package/lib/SubAndSuperScript.cjs +1 -1
  166. package/lib/SubAndSuperScript.d.cts +4 -4
  167. package/lib/SubAndSuperScript.d.ts +4 -4
  168. package/lib/SubAndSuperScript.js +1 -1
  169. package/lib/Table.cjs +1 -1
  170. package/lib/Table.d.cts +4 -4
  171. package/lib/Table.d.ts +4 -4
  172. package/lib/Table.js +2 -1
  173. package/lib/TableOfContent.cjs +1 -1
  174. package/lib/TableOfContent.d.cts +4 -4
  175. package/lib/TableOfContent.d.ts +4 -4
  176. package/lib/TableOfContent.js +50 -49
  177. package/lib/TaskList.cjs +1 -1
  178. package/lib/TaskList.d.cts +4 -4
  179. package/lib/TaskList.d.ts +4 -4
  180. package/lib/TaskList.js +1 -1
  181. package/lib/TextAlign.cjs +1 -1
  182. package/lib/TextAlign.d.cts +4 -4
  183. package/lib/TextAlign.d.ts +4 -4
  184. package/lib/TextAlign.js +8 -7
  185. package/lib/TextBubble.cjs +1 -1
  186. package/lib/TextBubble.d.cts +4 -4
  187. package/lib/TextBubble.d.ts +4 -4
  188. package/lib/TextBubble.js +1 -1
  189. package/lib/TextDirection.cjs +1 -1
  190. package/lib/TextDirection.d.cts +4 -4
  191. package/lib/TextDirection.d.ts +4 -4
  192. package/lib/TextDirection.js +14 -13
  193. package/lib/TextUnderline.cjs +1 -1
  194. package/lib/TextUnderline.d.cts +4 -4
  195. package/lib/TextUnderline.d.ts +4 -4
  196. package/lib/TextUnderline.js +1 -1
  197. package/lib/TrailingNode.d.cts +4 -4
  198. package/lib/TrailingNode.d.ts +4 -4
  199. package/lib/{Twitter-Wb7cD3M-.js → Twitter-99ivY5qv.js} +62 -61
  200. package/lib/{Twitter-D2Osj8qP.cjs → Twitter-BvfvUtNT.cjs} +2 -2
  201. package/lib/Twitter.cjs +1 -1
  202. package/lib/Twitter.d.cts +4 -4
  203. package/lib/Twitter.d.ts +4 -4
  204. package/lib/Twitter.js +1 -1
  205. package/lib/Video.cjs +1 -1
  206. package/lib/Video.d.cts +4 -4
  207. package/lib/Video.d.ts +4 -4
  208. package/lib/Video.js +1 -1
  209. package/lib/bubble-extra.cjs +1 -1
  210. package/lib/bubble-extra.d.cts +4 -4
  211. package/lib/bubble-extra.d.ts +4 -4
  212. package/lib/bubble-extra.js +5 -5
  213. package/lib/index.cjs +1 -1
  214. package/lib/index.d.cts +5 -4
  215. package/lib/index.d.ts +5 -4
  216. package/lib/index.js +2 -2
  217. package/lib/locale-bundle.d.cts +4 -4
  218. package/lib/locale-bundle.d.ts +4 -4
  219. package/lib/style.css +1 -1
  220. package/lib/{textarea-Csmx5x-_.js → textarea-CktfkXNe.js} +1 -1
  221. package/lib/{textarea-BVbzd9-k.cjs → textarea-DdH64g04.cjs} +1 -1
  222. package/package.json +1 -1
  223. package/lib/Drawer-DCAp7eZF.cjs +0 -1
  224. package/lib/Excalidraw-BI50RQL-.cjs +0 -1
  225. package/lib/Excalidraw-CYPcjYZB.js +0 -289
package/lib/Katex.js CHANGED
@@ -1,29 +1,29 @@
1
1
  import { N as b, n as g, m as w } from "./index-DI9T3iLd.js";
2
2
  import { N as k, R as N } from "./dom-dataset-Di3tIRrR.js";
3
- import { jsx as n, jsxs as u } from "react/jsx-runtime";
4
- import { useState as T, useCallback as $, useEffect as v, useMemo as c } from "react";
3
+ import { jsx as n, jsxs as c } from "react/jsx-runtime";
4
+ import { useState as T, useCallback as $, useEffect as v, useMemo as l } from "react";
5
5
  import x from "katex";
6
6
  import { HelpCircle as A } from "lucide-react";
7
- import { O as S, P as L, m as P, A as C, n as H, L as I, B as M, Q as y } from "./RichTextEditor-e6q30rbV.js";
8
- import { T as K } from "./textarea-Csmx5x-_.js";
7
+ import { O as S, P as L, m as P, A as C, n as H, L as I, B as M, Q as y } from "./RichTextEditor-KP2Rgcqe.js";
8
+ import { T as K } from "./textarea-CktfkXNe.js";
9
9
  import { u as R } from "./index-CsK90iVd.js";
10
- function V({ editor: t, ...e }) {
11
- const { t: a } = R(), o = S(t, h.name, {
10
+ function V({ editor: e, ...t }) {
11
+ const { t: a } = R(), o = S(e, h.name, {
12
12
  text: "",
13
13
  defaultShowPicker: !1
14
- }), { text: s, defaultShowPicker: r } = o, [i, l] = T(""), f = $(() => {
15
- t.chain().focus().setKatex({ text: i }).run(), l("");
16
- }, [t, i]);
14
+ }), { text: s, defaultShowPicker: r } = o, [i, u] = T(""), f = $(() => {
15
+ e.chain().focus().setKatex({ text: i }).run(), u("");
16
+ }, [e, i]);
17
17
  v(() => {
18
- r && t.chain().updateAttributes(h.name, { defaultShowPicker: !1 }).focus().run();
19
- }, [t, r]);
20
- const m = c(() => {
18
+ r && e.chain().updateAttributes(h.name, { defaultShowPicker: !1 }).focus().run();
19
+ }, [e, r]);
20
+ const m = l(() => {
21
21
  try {
22
22
  return x.renderToString(`${i}`);
23
23
  } catch {
24
24
  return i;
25
25
  }
26
- }, [i]), d = c(
26
+ }, [i]), d = l(
27
27
  () => `${i}`.trim() ? /* @__PURE__ */ n(
28
28
  "span",
29
29
  {
@@ -33,15 +33,16 @@ function V({ editor: t, ...e }) {
33
33
  ) : null,
34
34
  [i, m]
35
35
  );
36
- return /* @__PURE__ */ u(L, { modal: !0, children: [
36
+ return /* @__PURE__ */ c(L, { modal: !0, children: [
37
37
  /* @__PURE__ */ n(P, { asChild: !0, children: /* @__PURE__ */ n(
38
38
  C,
39
39
  {
40
- icon: e == null ? void 0 : e.icon,
41
- tooltip: e == null ? void 0 : e.tooltip
40
+ icon: t == null ? void 0 : t.icon,
41
+ tooltip: t == null ? void 0 : t.tooltip,
42
+ tooltipOptions: t == null ? void 0 : t.tooltipOptions
42
43
  }
43
44
  ) }),
44
- /* @__PURE__ */ u(
45
+ /* @__PURE__ */ c(
45
46
  H,
46
47
  {
47
48
  align: "start",
@@ -56,7 +57,7 @@ function V({ editor: t, ...e }) {
56
57
  autoFocus: !0,
57
58
  className: "richtext-w-full",
58
59
  defaultValue: s,
59
- onChange: (p) => l(p.target.value),
60
+ onChange: (p) => u(p.target.value),
60
61
  placeholder: "Text",
61
62
  required: !0,
62
63
  rows: 3,
@@ -64,7 +65,7 @@ function V({ editor: t, ...e }) {
64
65
  }
65
66
  ) }) }),
66
67
  d && /* @__PURE__ */ n("div", { className: "richtext-my-[10px] richtext-max-w-[286px] richtext-overflow-auto richtext-whitespace-nowrap richtext-rounded-[6px] !richtext-border richtext-p-[10px]", children: d }),
67
- /* @__PURE__ */ u("div", { className: "richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]", children: [
68
+ /* @__PURE__ */ c("div", { className: "richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]", children: [
68
69
  /* @__PURE__ */ n(
69
70
  M,
70
71
  {
@@ -88,29 +89,29 @@ function V({ editor: t, ...e }) {
88
89
  )
89
90
  ] });
90
91
  }
91
- function B(t, e = 1) {
92
+ function B(e, t = 1) {
92
93
  let a = 0, o = 0, s = 0;
93
- if (t.startsWith("rgb")) {
94
- const r = t.replace(/\s/g, "").match(/rgb\((.*)\)$/)[1].split(",");
94
+ if (e.startsWith("rgb")) {
95
+ const r = e.replace(/\s/g, "").match(/rgb\((.*)\)$/)[1].split(",");
95
96
  a = +r[0], o = +r[1], s = +r[2];
96
- } else if (t.startsWith("#")) {
97
- let r = t.replace("#", "");
97
+ } else if (e.startsWith("#")) {
98
+ let r = e.replace("#", "");
98
99
  r.length === 3 && (r = `${r[0]}${r[0]}${r[1]}${r[1]}${r[2]}${r[2]}`), a = Number.parseInt(r.substring(0, 2), 16), o = Number.parseInt(r.substring(2, 4), 16), s = Number.parseInt(r.substring(4, 6), 16);
99
100
  } else
100
- return t;
101
- return e > 1 && e <= 100 && (e = e / 100), `rgba(${a},${o},${s},${e})`;
101
+ return e;
102
+ return t > 1 && t <= 100 && (t = t / 100), `rgba(${a},${o},${s},${t})`;
102
103
  }
103
- function W({ node: t }) {
104
- const e = y(), { text: a } = t.attrs, o = c(() => {
104
+ function W({ node: e }) {
105
+ const t = y(), { text: a } = e.attrs, o = l(() => {
105
106
  const i = "rgb(254, 242, 237)";
106
- return e === "dark" ? B(i, 0.75) : i;
107
- }, [e]), s = c(() => {
107
+ return t === "dark" ? B(i, 0.75) : i;
108
+ }, [t]), s = l(() => {
108
109
  try {
109
110
  return x.renderToString(`${a}`);
110
111
  } catch {
111
112
  return a;
112
113
  }
113
- }, [a]), r = c(
114
+ }, [a]), r = l(
114
115
  () => a.trim() ? /* @__PURE__ */ n("span", { contentEditable: !1, dangerouslySetInnerHTML: { __html: s } }) : /* @__PURE__ */ n("span", { contentEditable: !1, children: "Not enter a formula" }),
115
116
  [a, s]
116
117
  );
@@ -126,8 +127,8 @@ function W({ node: t }) {
126
127
  }
127
128
  );
128
129
  }
129
- function _(t) {
130
- return (e) => e.getAttribute(t);
130
+ function _(e) {
131
+ return (t) => t.getAttribute(e);
131
132
  }
132
133
  const h = /* @__PURE__ */ b.create({
133
134
  name: "katex",
@@ -141,15 +142,15 @@ const h = /* @__PURE__ */ b.create({
141
142
  HTMLAttributes: {
142
143
  class: "katex"
143
144
  },
144
- button: ({ editor: t, t: e }) => ({
145
+ button: ({ editor: e, t }) => ({
145
146
  component: V,
146
147
  componentProps: {
147
- editor: t,
148
+ editor: e,
148
149
  action: () => !0,
149
150
  isActive: () => !1,
150
151
  disabled: !1,
151
152
  icon: "KatexIcon",
152
- tooltip: e("editor.katex.tooltip")
153
+ tooltip: t("editor.katex.tooltip")
153
154
  }
154
155
  })
155
156
  };
@@ -168,14 +169,14 @@ const h = /* @__PURE__ */ b.create({
168
169
  parseHTML() {
169
170
  return [{ tag: "span.katex" }];
170
171
  },
171
- renderHTML({ HTMLAttributes: t }) {
172
- return ["span", w(this.options && this.options.HTMLAttributes || {}, t)];
172
+ renderHTML({ HTMLAttributes: e }) {
173
+ return ["span", w(this.options && this.options.HTMLAttributes || {}, e)];
173
174
  },
174
175
  addCommands() {
175
176
  return {
176
- setKatex: (t) => ({ commands: e }) => e.insertContent({
177
+ setKatex: (e) => ({ commands: t }) => t.insertContent({
177
178
  type: this.name,
178
- attrs: t
179
+ attrs: e
179
180
  })
180
181
  };
181
182
  },
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-ByRfqzMr.cjs"),g=require("./index-D_A0TBRA.cjs"),c=require("react/jsx-runtime"),L=require("react"),u=require("./RichTextEditor-DsUcQSbm.cjs");function T(e){return Number.parseFloat(e.replace("%",""))/100}function x(e){const{t}=g.useLocale(),[n,r]=L.useState("default");function o(i){i==="default"?e.editor.commands.unsetLineHeight():e.editor.commands.setLineHeight(i),r(i)}const d=L.useMemo(()=>{const s=e.editor.extensionManager.extensions.find(l=>l.name==="lineHeight").options.lineHeights.map(l=>({label:T(l),value:l}));return s.unshift({label:t("editor.default"),value:"default"}),s},[e]);return c.jsxs(u.DropdownMenu,{children:[c.jsx(u.DropdownMenuTrigger,{asChild:!0,disabled:e==null?void 0:e.disabled,children:c.jsx(u.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:e==null?void 0:e.disabled,icon:"LineHeight",tooltip:e==null?void 0:e.tooltip,children:c.jsx(u.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),c.jsx(u.DropdownMenuContent,{className:"richtext-min-w-24",children:d==null?void 0:d.map((i,h)=>c.jsx(u.DropdownMenuCheckboxItem,{checked:i.value===n,onClick:()=>o(i.value),children:i.label},`lineHeight-${h}`))})]})}const _=["paragraph","heading","list_item","todo_item"];function E(e,t){const{selection:n,doc:r}=e;if(!n||!r||!(n instanceof m.TextSelection||n instanceof m.AllSelection))return e;const{from:o,to:d}=n,i=[],h=t&&t!==g.DEFAULT_LINE_HEIGHT?t:null;if(r.nodesBetween(o,d,(s,l)=>{const a=s.type;return _.includes(a.name)?((s.attrs.lineHeight||null)!==h&&i.push({node:s,pos:l,nodeType:a}),a.name!=="list_item"&&a.name!=="todo_item"):!0}),i.length===0)return e;for(const s of i){const{node:l,pos:a,nodeType:f}=s;let{attrs:H}=l;H={...H,lineHeight:h},e=e.setNodeMarkup(a,f,H,l.marks)}return e}function b(e){return({state:t,dispatch:n})=>{const{selection:r}=t;let{tr:o}=t;return o=o.setSelection(r),o=E(o,e),o.docChanged?(n&&n(o),!0):!1}}const I=m.Extension.create({name:"lineHeight",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","list_item","todo_item"],lineHeights:g.DEFAULT_LINE_HEIGHT_LIST,defaultHeight:g.DEFAULT_LINE_HEIGHT,button({editor:t,t:n}){return{component:x,componentProps:{editor:t,tooltip:n("editor.lineheight.tooltip")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||this.options.defaultHeight,renderHTML:e=>e.lineHeight===this.options.defaultHeight||!e.lineHeight?{}:{style:`line-height: ${e.lineHeight}`}}}}]},addCommands(){return{setLineHeight:e=>b(e),unsetLineHeight:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"lineHeight"))}}});exports.DEFAULT_LINE_HEIGHT_LIST=g.DEFAULT_LINE_HEIGHT_LIST;exports.LineHeight=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-ByRfqzMr.cjs"),g=require("./index-D_A0TBRA.cjs"),c=require("react/jsx-runtime"),L=require("react"),u=require("./RichTextEditor-DWlLqTl9.cjs");function T(e){return Number.parseFloat(e.replace("%",""))/100}function x(e){const{t}=g.useLocale(),[n,a]=L.useState("default");function o(i){i==="default"?e.editor.commands.unsetLineHeight():e.editor.commands.setLineHeight(i),a(i)}const d=L.useMemo(()=>{const s=e.editor.extensionManager.extensions.find(l=>l.name==="lineHeight").options.lineHeights.map(l=>({label:T(l),value:l}));return s.unshift({label:t("editor.default"),value:"default"}),s},[e]);return c.jsxs(u.DropdownMenu,{children:[c.jsx(u.DropdownMenuTrigger,{asChild:!0,disabled:e==null?void 0:e.disabled,children:c.jsx(u.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:e==null?void 0:e.disabled,icon:"LineHeight",tooltip:e==null?void 0:e.tooltip,tooltipOptions:e==null?void 0:e.tooltipOptions,children:c.jsx(u.IconComponent,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),c.jsx(u.DropdownMenuContent,{className:"richtext-min-w-24",children:d==null?void 0:d.map((i,h)=>c.jsx(u.DropdownMenuCheckboxItem,{checked:i.value===n,onClick:()=>o(i.value),children:i.label},`lineHeight-${h}`))})]})}const _=["paragraph","heading","list_item","todo_item"];function E(e,t){const{selection:n,doc:a}=e;if(!n||!a||!(n instanceof m.TextSelection||n instanceof m.AllSelection))return e;const{from:o,to:d}=n,i=[],h=t&&t!==g.DEFAULT_LINE_HEIGHT?t:null;if(a.nodesBetween(o,d,(s,l)=>{const r=s.type;return _.includes(r.name)?((s.attrs.lineHeight||null)!==h&&i.push({node:s,pos:l,nodeType:r}),r.name!=="list_item"&&r.name!=="todo_item"):!0}),i.length===0)return e;for(const s of i){const{node:l,pos:r,nodeType:f}=s;let{attrs:H}=l;H={...H,lineHeight:h},e=e.setNodeMarkup(r,f,H,l.marks)}return e}function b(e){return({state:t,dispatch:n})=>{const{selection:a}=t;let{tr:o}=t;return o=o.setSelection(a),o=E(o,e),o.docChanged?(n&&n(o),!0):!1}}const I=m.Extension.create({name:"lineHeight",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),types:["paragraph","heading","list_item","todo_item"],lineHeights:g.DEFAULT_LINE_HEIGHT_LIST,defaultHeight:g.DEFAULT_LINE_HEIGHT,button({editor:t,t:n}){return{component:x,componentProps:{editor:t,tooltip:n("editor.lineheight.tooltip")}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight||this.options.defaultHeight,renderHTML:e=>e.lineHeight===this.options.defaultHeight||!e.lineHeight?{}:{style:`line-height: ${e.lineHeight}`}}}}]},addCommands(){return{setLineHeight:e=>b(e),unsetLineHeight:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"lineHeight"))}}});exports.DEFAULT_LINE_HEIGHT_LIST=g.DEFAULT_LINE_HEIGHT_LIST;exports.LineHeight=I;
@@ -138,8 +138,8 @@ declare module '@tiptap/core' {
138
138
 
139
139
  declare module '@tiptap/core' {
140
140
  interface Commands<ReturnType> {
141
- exportPdf: {
142
- exportToPdf: () => ReturnType;
141
+ excalidraw: {
142
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
143
143
  };
144
144
  }
145
145
  }
@@ -147,8 +147,8 @@ declare module '@tiptap/core' {
147
147
 
148
148
  declare module '@tiptap/core' {
149
149
  interface Commands<ReturnType> {
150
- excalidraw: {
151
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
150
+ exportPdf: {
151
+ exportToPdf: () => ReturnType;
152
152
  };
153
153
  }
154
154
  }
@@ -138,8 +138,8 @@ declare module '@tiptap/core' {
138
138
 
139
139
  declare module '@tiptap/core' {
140
140
  interface Commands<ReturnType> {
141
- exportPdf: {
142
- exportToPdf: () => ReturnType;
141
+ excalidraw: {
142
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
143
143
  };
144
144
  }
145
145
  }
@@ -147,8 +147,8 @@ declare module '@tiptap/core' {
147
147
 
148
148
  declare module '@tiptap/core' {
149
149
  interface Commands<ReturnType> {
150
- excalidraw: {
151
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
150
+ exportPdf: {
151
+ exportToPdf: () => ReturnType;
152
152
  };
153
153
  }
154
154
  }
package/lib/LineHeight.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { T as f, A as H, E as L } from "./index-DI9T3iLd.js";
2
2
  import { u as x, k as g, m as T } from "./index-CsK90iVd.js";
3
3
  import { jsxs as b, jsx as h } from "react/jsx-runtime";
4
- import { useState as p, useMemo as _ } from "react";
5
- import { D, e as E, A as M, k as w, f as A, h as C } from "./RichTextEditor-e6q30rbV.js";
6
- function y(e) {
4
+ import { useState as _, useMemo as D } from "react";
5
+ import { D as E, e as M, A as w, k as A, f as C, h as y } from "./RichTextEditor-KP2Rgcqe.js";
6
+ function k(e) {
7
7
  return Number.parseFloat(e.replace("%", "")) / 100;
8
8
  }
9
- function k(e) {
10
- const { t } = x(), [n, s] = p("default");
9
+ function p(e) {
10
+ const { t } = x(), [n, s] = _("default");
11
11
  function o(i) {
12
12
  i === "default" ? e.editor.commands.unsetLineHeight() : e.editor.commands.setLineHeight(i), s(i);
13
13
  }
14
- const c = _(() => {
14
+ const c = D(() => {
15
15
  const a = e.editor.extensionManager.extensions.find(
16
16
  (l) => l.name === "lineHeight"
17
17
  ).options.lineHeights.map((l) => ({
18
- label: y(l),
18
+ label: k(l),
19
19
  value: l
20
20
  }));
21
21
  return a.unshift({
@@ -23,21 +23,22 @@ function k(e) {
23
23
  value: "default"
24
24
  }), a;
25
25
  }, [e]);
26
- return /* @__PURE__ */ b(D, { children: [
26
+ return /* @__PURE__ */ b(E, { children: [
27
27
  /* @__PURE__ */ h(
28
- E,
28
+ M,
29
29
  {
30
30
  asChild: !0,
31
31
  disabled: e == null ? void 0 : e.disabled,
32
32
  children: /* @__PURE__ */ h(
33
- M,
33
+ w,
34
34
  {
35
35
  customClass: "!richtext-w-12 richtext-h-12",
36
36
  disabled: e == null ? void 0 : e.disabled,
37
37
  icon: "LineHeight",
38
38
  tooltip: e == null ? void 0 : e.tooltip,
39
+ tooltipOptions: e == null ? void 0 : e.tooltipOptions,
39
40
  children: /* @__PURE__ */ h(
40
- w,
41
+ A,
41
42
  {
42
43
  className: "richtext-ml-1 richtext-size-3 richtext-text-zinc-500",
43
44
  name: "MenuDown"
@@ -47,8 +48,8 @@ function k(e) {
47
48
  )
48
49
  }
49
50
  ),
50
- /* @__PURE__ */ h(A, { className: "richtext-min-w-24", children: c == null ? void 0 : c.map((i, u) => /* @__PURE__ */ h(
51
- C,
51
+ /* @__PURE__ */ h(C, { className: "richtext-min-w-24", children: c == null ? void 0 : c.map((i, u) => /* @__PURE__ */ h(
52
+ y,
52
53
  {
53
54
  checked: i.value === n,
54
55
  onClick: () => o(i.value),
@@ -83,7 +84,7 @@ function N(e, t) {
83
84
  }
84
85
  return e;
85
86
  }
86
- function v(e) {
87
+ function O(e) {
87
88
  return ({ state: t, dispatch: n }) => {
88
89
  const { selection: s } = t;
89
90
  let { tr: o } = t;
@@ -101,7 +102,7 @@ const z = /* @__PURE__ */ L.create({
101
102
  defaultHeight: g,
102
103
  button({ editor: t, t: n }) {
103
104
  return {
104
- component: k,
105
+ component: p,
105
106
  componentProps: {
106
107
  editor: t,
107
108
  tooltip: n("editor.lineheight.tooltip")
@@ -126,7 +127,7 @@ const z = /* @__PURE__ */ L.create({
126
127
  },
127
128
  addCommands() {
128
129
  return {
129
- setLineHeight: (e) => v(e),
130
+ setLineHeight: (e) => O(e),
130
131
  unsetLineHeight: () => ({ commands: e }) => this.options.types.every((t) => e.resetAttributes(t, "lineHeight"))
131
132
  };
132
133
  }
package/lib/Link.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./index-ByRfqzMr.cjs");const e=require("./RichTextEditor-DsUcQSbm.cjs");exports.Link=e.Link;exports.default=e.Link;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./index-ByRfqzMr.cjs");const e=require("./RichTextEditor-DWlLqTl9.cjs");exports.Link=e.Link;exports.default=e.Link;
package/lib/Link.d.cts CHANGED
@@ -136,8 +136,8 @@ declare module '@tiptap/core' {
136
136
 
137
137
  declare module '@tiptap/core' {
138
138
  interface Commands<ReturnType> {
139
- exportPdf: {
140
- exportToPdf: () => ReturnType;
139
+ excalidraw: {
140
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
141
141
  };
142
142
  }
143
143
  }
@@ -145,8 +145,8 @@ declare module '@tiptap/core' {
145
145
 
146
146
  declare module '@tiptap/core' {
147
147
  interface Commands<ReturnType> {
148
- excalidraw: {
149
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
148
+ exportPdf: {
149
+ exportToPdf: () => ReturnType;
150
150
  };
151
151
  }
152
152
  }
package/lib/Link.d.ts CHANGED
@@ -136,8 +136,8 @@ declare module '@tiptap/core' {
136
136
 
137
137
  declare module '@tiptap/core' {
138
138
  interface Commands<ReturnType> {
139
- exportPdf: {
140
- exportToPdf: () => ReturnType;
139
+ excalidraw: {
140
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
141
141
  };
142
142
  }
143
143
  }
@@ -145,8 +145,8 @@ declare module '@tiptap/core' {
145
145
 
146
146
  declare module '@tiptap/core' {
147
147
  interface Commands<ReturnType> {
148
- excalidraw: {
149
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
148
+ exportPdf: {
149
+ exportToPdf: () => ReturnType;
150
150
  };
151
151
  }
152
152
  }
package/lib/Link.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./index-DI9T3iLd.js";
2
- import { ae as r, ae as t } from "./RichTextEditor-e6q30rbV.js";
2
+ import { ae as r, ae as t } from "./RichTextEditor-KP2Rgcqe.js";
3
3
  export {
4
4
  r as Link,
5
5
  t as default
@@ -58,8 +58,8 @@ declare module '@tiptap/core' {
58
58
 
59
59
  declare module '@tiptap/core' {
60
60
  interface Commands<ReturnType> {
61
- exportPdf: {
62
- exportToPdf: () => ReturnType;
61
+ excalidraw: {
62
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
63
63
  };
64
64
  }
65
65
  }
@@ -67,8 +67,8 @@ declare module '@tiptap/core' {
67
67
 
68
68
  declare module '@tiptap/core' {
69
69
  interface Commands<ReturnType> {
70
- excalidraw: {
71
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
70
+ exportPdf: {
71
+ exportToPdf: () => ReturnType;
72
72
  };
73
73
  }
74
74
  }
package/lib/ListItem.d.ts CHANGED
@@ -58,8 +58,8 @@ declare module '@tiptap/core' {
58
58
 
59
59
  declare module '@tiptap/core' {
60
60
  interface Commands<ReturnType> {
61
- exportPdf: {
62
- exportToPdf: () => ReturnType;
61
+ excalidraw: {
62
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
63
63
  };
64
64
  }
65
65
  }
@@ -67,8 +67,8 @@ declare module '@tiptap/core' {
67
67
 
68
68
  declare module '@tiptap/core' {
69
69
  interface Commands<ReturnType> {
70
- excalidraw: {
71
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
70
+ exportPdf: {
71
+ exportToPdf: () => ReturnType;
72
72
  };
73
73
  }
74
74
  }
package/lib/Mention.d.cts CHANGED
@@ -61,8 +61,8 @@ declare module '@tiptap/core' {
61
61
 
62
62
  declare module '@tiptap/core' {
63
63
  interface Commands<ReturnType> {
64
- exportPdf: {
65
- exportToPdf: () => ReturnType;
64
+ excalidraw: {
65
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
66
66
  };
67
67
  }
68
68
  }
@@ -70,8 +70,8 @@ declare module '@tiptap/core' {
70
70
 
71
71
  declare module '@tiptap/core' {
72
72
  interface Commands<ReturnType> {
73
- excalidraw: {
74
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
73
+ exportPdf: {
74
+ exportToPdf: () => ReturnType;
75
75
  };
76
76
  }
77
77
  }
package/lib/Mention.d.ts CHANGED
@@ -61,8 +61,8 @@ declare module '@tiptap/core' {
61
61
 
62
62
  declare module '@tiptap/core' {
63
63
  interface Commands<ReturnType> {
64
- exportPdf: {
65
- exportToPdf: () => ReturnType;
64
+ excalidraw: {
65
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
66
66
  };
67
67
  }
68
68
  }
@@ -70,8 +70,8 @@ declare module '@tiptap/core' {
70
70
 
71
71
  declare module '@tiptap/core' {
72
72
  interface Commands<ReturnType> {
73
- excalidraw: {
74
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
73
+ exportPdf: {
74
+ exportToPdf: () => ReturnType;
75
75
  };
76
76
  }
77
77
  }
package/lib/Mermaid.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var W=Object.create;var G=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var J=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of U(e))!Y.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=X(e,l))||a.enumerable});return t};var K=(t,e,r)=>(r=t!=null?W(Z(t)):{},J(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./index-ByRfqzMr.cjs"),u=require("./RichTextEditor-DsUcQSbm.cjs"),F=require("./dom-dataset-Byuf1YmW.cjs"),o=require("react/jsx-runtime"),s=require("react"),P=require("./shortId-Bfj8TyNr.cjs"),Q=require("./textarea-BVbzd9-k.cjs"),S=require("./index-D_A0TBRA.cjs"),$=`graph TB
2
- a-->b`,ee=({editor:t,upload:e})=>{const[r,a]=s.useState($),[l,v]=s.useState(""),[T,y]=s.useState(!1),A=s.useRef(null),[d,h]=s.useState(null),E=s.useCallback(c=>{c&&import("mermaid").then(x=>{h(x.default)})},[]),_=async c=>{try{const{svg:x}=await d.render("mermaid-svg",c);v(x)}catch{v("")}},L=()=>{d.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),_(r)};s.useEffect(()=>{d&&T&&L()},[d,T]),s.useEffect(()=>{d&&T&&_(r)},[d&&r]);const R=async()=>{if(r!==""){if(r){const c=A.current.querySelector("svg"),{width:x,height:j}=c.getBoundingClientRect(),I=`mermaid-${P.shortId()}.svg`;let M=P.i(c.outerHTML);if(e){console.log({src:M});const H=u.dataURLtoFile(M,I);M=await e(H)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:M,alt:encodeURIComponent(r),width:x,height:j},!!r).run()}y(!1)}};return o.jsxs(u.Dialog,{onOpenChange:y,open:T,children:[o.jsx(u.DialogTrigger,{asChild:!0,children:o.jsx(u.ActionButton,{action:()=>y(!0),icon:"Mermaid",tooltip:"Mermaid"})}),o.jsxs(u.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(u.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:E,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(Q.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:$,onChange:c=>a(c.target.value),placeholder:"Text",required:!0,rows:10,value:r,style:{color:"hsl(var(--richtext-foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:l},ref:A,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),o.jsx(u.DialogFooter,{children:o.jsx(u.Button,{onClick:R,type:"button",children:"Save changes"})})]})]})},O={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[v,T]=s.useState({width:S.IMAGE_MAX_SIZE,height:S.IMAGE_MAX_SIZE}),[y,A]=s.useState({width:0,height:0}),[d]=s.useState([O.TOP_LEFT,O.TOP_RIGHT,O.BOTTOM_LEFT,O.BOTTOM_RIGHT]),[h,E]=s.useState(!1),[_,L]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:R}=e==null?void 0:e.attrs,c=s.useMemo(()=>{const{src:i,alt:m,width:f,height:b}=e==null?void 0:e.attrs,w=q.isNumber(f)?`${f}px`:f,n=q.isNumber(b)?`${b}px`:b;return{src:i||void 0,alt:m||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),x=s.useMemo(()=>{const{style:{width:i}}=c;return{width:i==="100%"?i:void 0}},[c]);function j(i){A({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const M=s.useCallback(u.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);T(m=>({...m,width:Number.parseInt(i,10)}))},S.IMAGE_THROTTLE_WAIT_TIME),[t]);function H(i,m){i.preventDefault(),i.stopPropagation();const f=y.width,b=y.height,w=f/b;let n=Number(e.attrs.width),p=Number(e.attrs.height);const g=v.width;n&&!p?(n=n>g?g:n,p=Math.round(n/w)):p&&!n?(n=Math.round(p*w),n=n>g?g:n):!n&&!p?(n=f>g?g:f,p=Math.round(n/w)):n=n>g?g:n,E(!0),L({x:i.clientX,y:i.clientY,w:n,h:p,dir:m})}const N=s.useCallback(u.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!h)return;const{x:m,w:f,dir:b}=_,w=(i.clientX-m)*(/l/.test(b)?-1:1),{width:n,height:p}=e==null?void 0:e.attrs,g=n/p,B=u.clamp(f+w,S.IMAGE_MIN_SIZE,v.width),V=Math.round(B/g);r({width:B,height:V})},S.IMAGE_THROTTLE_WAIT_TIME),[h,_,v,r,e==null?void 0:e.attrs]),C=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),h&&(L({x:0,y:0,w:0,h:0,dir:""}),E(!1),I())},[h,I]),D=s.useCallback(()=>{document==null||document.addEventListener("mousemove",N,!0),document==null||document.addEventListener("mouseup",C,!0)},[N,C]),z=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",N,!0),document==null||document.removeEventListener("mouseup",C,!0)},[N,C]);s.useEffect(()=>(h?D():z(),()=>{z()}),[h,D,z]);const k=s.useMemo(()=>new ResizeObserver(()=>M()),[M]);return s.useEffect(()=>(k.observe(t.view.dom),()=>{k.disconnect()}),[t.view.dom,k]),o.jsx(F.NodeViewWrapper,{className:"image-view",style:{...x,width:"100%",textAlign:R},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...x,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:c.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:j,src:c.src,style:c.style}),t.view.editable&&(l||h)&&o.jsx("div",{className:"image-resizer",children:d==null?void 0:d.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:m=>H(m,i)},`image-dir-${i}`))})]})})}const re=u.Image.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{component:ee,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 F.ReactNodeViewRenderer(te)},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",q.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=re;
1
+ "use strict";var W=Object.create;var G=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var J=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of U(e))!Y.call(t,l)&&l!==i&&G(t,l,{get:()=>e[l],enumerable:!(r=X(e,l))||r.enumerable});return t};var K=(t,e,i)=>(i=t!=null?W(Z(t)):{},J(e||!t||!t.__esModule?G(i,"default",{value:t,enumerable:!0}):i,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./index-ByRfqzMr.cjs"),u=require("./RichTextEditor-DWlLqTl9.cjs"),F=require("./dom-dataset-Byuf1YmW.cjs"),o=require("react/jsx-runtime"),a=require("react"),P=require("./shortId-Bfj8TyNr.cjs"),Q=require("./textarea-DdH64g04.cjs"),E=require("./index-D_A0TBRA.cjs"),$=`graph TB
2
+ a-->b`,ee=({editor:t,upload:e,tooltipOptions:i})=>{const[r,l]=a.useState($),[_,L]=a.useState(""),[p,I]=a.useState(!1),v=a.useRef(null),[c,N]=a.useState(null),C=a.useCallback(d=>{d&&import("mermaid").then(M=>{N(M.default)})},[]),S=async d=>{try{const{svg:M}=await c.render("mermaid-svg",d);L(M)}catch{L("")}},H=()=>{c.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),S(r)};a.useEffect(()=>{c&&p&&H()},[c,p]),a.useEffect(()=>{c&&p&&S(r)},[c&&r]);const x=async()=>{if(r!==""){if(r){const d=v.current.querySelector("svg"),{width:M,height:A}=d.getBoundingClientRect(),O=`mermaid-${P.shortId()}.svg`;let T=P.i(d.outerHTML);if(e){console.log({src:T});const y=u.dataURLtoFile(T,O);T=await e(y)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:T,alt:encodeURIComponent(r),width:M,height:A},!!r).run()}I(!1)}};return o.jsxs(u.Dialog,{onOpenChange:I,open:p,children:[o.jsx(u.DialogTrigger,{asChild:!0,children:o.jsx(u.ActionButton,{action:()=>I(!0),icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:i})}),o.jsxs(u.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(u.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:C,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(Q.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:$,onChange:d=>l(d.target.value),placeholder:"Text",required:!0,rows:10,value:r,style:{color:"hsl(var(--richtext-foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:_},ref:v,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),o.jsx(u.DialogFooter,{children:o.jsx(u.Button,{onClick:x,type:"button",children:"Save changes"})})]})]})},j={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({editor:t,node:e,updateAttributes:i,getPos:r,selected:l}){const[_,L]=a.useState({width:E.IMAGE_MAX_SIZE,height:E.IMAGE_MAX_SIZE}),[p,I]=a.useState({width:0,height:0}),[v]=a.useState([j.TOP_LEFT,j.TOP_RIGHT,j.BOTTOM_LEFT,j.BOTTOM_RIGHT]),[c,N]=a.useState(!1),[C,S]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:H}=e==null?void 0:e.attrs,x=a.useMemo(()=>{const{src:s,alt:g,width:m,height:b}=e==null?void 0:e.attrs,w=q.isNumber(m)?`${m}px`:m,n=q.isNumber(b)?`${b}px`:b;return{src:s||void 0,alt:g||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),d=a.useMemo(()=>{const{style:{width:s}}=x;return{width:s==="100%"?s:void 0}},[x]);function M(s){I({width:s.target.width,height:s.target.height})}function A(){t.commands.setNodeSelection(r())}const O=a.useCallback(u.throttle(()=>{const{width:s}=getComputedStyle(t.view.dom);L(g=>({...g,width:Number.parseInt(s,10)}))},E.IMAGE_THROTTLE_WAIT_TIME),[t]);function T(s,g){s.preventDefault(),s.stopPropagation();const m=p.width,b=p.height,w=m/b;let n=Number(e.attrs.width),f=Number(e.attrs.height);const h=_.width;n&&!f?(n=n>h?h:n,f=Math.round(n/w)):f&&!n?(n=Math.round(f*w),n=n>h?h:n):!n&&!f?(n=m>h?h:m,f=Math.round(n/w)):n=n>h?h:n,N(!0),S({x:s.clientX,y:s.clientY,w:n,h:f,dir:g})}const y=a.useCallback(u.throttle(s=>{if(s.preventDefault(),s.stopPropagation(),!c)return;const{x:g,w:m,dir:b}=C,w=(s.clientX-g)*(/l/.test(b)?-1:1),{width:n,height:f}=e==null?void 0:e.attrs,h=n/f,B=u.clamp(m+w,E.IMAGE_MIN_SIZE,_.width),V=Math.round(B/h);i({width:B,height:V})},E.IMAGE_THROTTLE_WAIT_TIME),[c,C,_,i,e==null?void 0:e.attrs]),R=a.useCallback(s=>{s.preventDefault(),s.stopPropagation(),c&&(S({x:0,y:0,w:0,h:0,dir:""}),N(!1),A())},[c,A]),D=a.useCallback(()=>{document==null||document.addEventListener("mousemove",y,!0),document==null||document.addEventListener("mouseup",R,!0)},[y,R]),z=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",y,!0),document==null||document.removeEventListener("mouseup",R,!0)},[y,R]);a.useEffect(()=>(c?D():z(),()=>{z()}),[c,D,z]);const k=a.useMemo(()=>new ResizeObserver(()=>O()),[O]);return a.useEffect(()=>(k.observe(t.view.dom),()=>{k.disconnect()}),[t.view.dom,k]),o.jsx(F.NodeViewWrapper,{className:"image-view",style:{...d,width:"100%",textAlign:H},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...d,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:x.alt,className:"image-view__body__image block",height:"auto",onClick:A,onLoad:M,src:x.src,style:x.style}),t.view.editable&&(l||c)&&o.jsx("div",{className:"image-resizer",children:v==null?void 0:v.map(s=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${s}`,onMouseDown:g=>T(g,s)},`image-dir-${s}`))})]})})}const re=u.Image.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:i,extension:r})=>{var l;return{component:ee,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:i("editor.mermaid.tooltip"),upload:(l=r==null?void 0:r.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 i=e.querySelector("img"),r=i==null?void 0:i.getAttribute("width");return r?Number.parseInt(r,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const i=e.querySelector("img"),r=i==null?void 0:i.getAttribute("height");return r?Number.parseInt(r,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return F.ReactNodeViewRenderer(te)},addCommands(){return{setMermaid:(t,e)=>({commands:i,editor:r})=>e?i.insertContent({type:this.name,attrs:t}):i.insertContentAt(r.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",q.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),i=e==null?void 0:e.getAttribute("width"),r=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:i?Number.parseInt(i,10):null,height:r?Number.parseInt(r,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=re;
package/lib/Mermaid.d.cts CHANGED
@@ -135,8 +135,8 @@ declare module '@tiptap/core' {
135
135
 
136
136
  declare module '@tiptap/core' {
137
137
  interface Commands<ReturnType> {
138
- exportPdf: {
139
- exportToPdf: () => ReturnType;
138
+ excalidraw: {
139
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
140
140
  };
141
141
  }
142
142
  }
@@ -144,8 +144,8 @@ declare module '@tiptap/core' {
144
144
 
145
145
  declare module '@tiptap/core' {
146
146
  interface Commands<ReturnType> {
147
- excalidraw: {
148
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
147
+ exportPdf: {
148
+ exportToPdf: () => ReturnType;
149
149
  };
150
150
  }
151
151
  }
package/lib/Mermaid.d.ts CHANGED
@@ -135,8 +135,8 @@ declare module '@tiptap/core' {
135
135
 
136
136
  declare module '@tiptap/core' {
137
137
  interface Commands<ReturnType> {
138
- exportPdf: {
139
- exportToPdf: () => ReturnType;
138
+ excalidraw: {
139
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
140
140
  };
141
141
  }
142
142
  }
@@ -144,8 +144,8 @@ declare module '@tiptap/core' {
144
144
 
145
145
  declare module '@tiptap/core' {
146
146
  interface Commands<ReturnType> {
147
- excalidraw: {
148
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
147
+ exportPdf: {
148
+ exportToPdf: () => ReturnType;
149
149
  };
150
150
  }
151
151
  }