reactjs-tiptap-editor 0.2.29 → 0.3.1
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.
- package/lib/ActionMenuButton-BllDdN2-.js +33 -0
- package/lib/ActionMenuButton-tLPdHfCT.cjs +1 -0
- package/lib/Attachment.cjs +19 -0
- package/lib/Attachment.d.cts +344 -0
- package/lib/Attachment.d.ts +344 -0
- package/lib/Attachment.js +259 -0
- package/lib/Blockquote.cjs +1 -0
- package/lib/Blockquote.d.cts +343 -0
- package/lib/Blockquote.d.ts +343 -0
- package/lib/Blockquote.js +65 -0
- package/lib/Bold.cjs +1 -0
- package/lib/Bold.d.cts +343 -0
- package/lib/Bold.d.ts +343 -0
- package/lib/Bold.js +90 -0
- package/lib/BulletList.cjs +1 -0
- package/lib/BulletList.d.cts +343 -0
- package/lib/BulletList.d.ts +343 -0
- package/lib/BulletList.js +72 -0
- package/lib/Clear.cjs +1 -0
- package/lib/Clear.d.cts +342 -0
- package/lib/Clear.d.ts +342 -0
- package/lib/Clear.js +23 -0
- package/lib/Code.cjs +1 -0
- package/lib/Code.d.cts +343 -0
- package/lib/Code.d.ts +343 -0
- package/lib/Code.js +70 -0
- package/lib/CodeBlock.cjs +44 -0
- package/lib/CodeBlock.d.cts +352 -0
- package/lib/CodeBlock.d.ts +352 -0
- package/lib/CodeBlock.js +4189 -0
- package/lib/Color.cjs +1 -0
- package/lib/Color.d.cts +350 -0
- package/lib/Color.d.ts +350 -0
- package/lib/Color.js +141 -0
- package/lib/Document.cjs +1 -0
- package/lib/Document.d.cts +272 -0
- package/lib/Document.d.ts +272 -0
- package/lib/Document.js +13 -0
- package/lib/Drawer-BBmEHEAp.cjs +1 -0
- package/lib/Drawer-hyBIiEP6.js +1367 -0
- package/lib/Drawer.cjs +1 -0
- package/lib/Drawer.d.cts +344 -0
- package/lib/Drawer.d.ts +344 -0
- package/lib/Drawer.js +7 -0
- package/lib/Emoji.cjs +1 -0
- package/lib/Emoji.d.cts +277 -0
- package/lib/Emoji.d.ts +277 -0
- package/lib/Emoji.js +2168 -0
- package/lib/Excalidraw-BQ2PeAoa.js +651 -0
- package/lib/Excalidraw-Cd01zFJl.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -0
- package/lib/Excalidraw.d.cts +278 -0
- package/lib/Excalidraw.d.ts +278 -0
- package/lib/Excalidraw.js +6 -0
- package/lib/ExportPdf.cjs +15 -0
- package/lib/ExportPdf.d.cts +270 -0
- package/lib/ExportPdf.d.ts +270 -0
- package/lib/ExportPdf.js +67 -0
- package/lib/ExportWord.cjs +1 -0
- package/lib/ExportWord.d.cts +341 -0
- package/lib/ExportWord.d.ts +341 -0
- package/lib/ExportWord.js +72 -0
- package/lib/FontFamily.cjs +1 -0
- package/lib/FontFamily.d.cts +354 -0
- package/lib/FontFamily.d.ts +354 -0
- package/lib/FontFamily.js +136 -0
- package/lib/FontSize.cjs +1 -0
- package/lib/FontSize.d.cts +359 -0
- package/lib/FontSize.d.ts +359 -0
- package/lib/FontSize.js +110 -0
- package/lib/FormatPainter.cjs +1 -0
- package/lib/FormatPainter.d.cts +353 -0
- package/lib/FormatPainter.d.ts +353 -0
- package/lib/FormatPainter.js +74 -0
- package/lib/Heading.cjs +1 -0
- package/lib/Heading.d.cts +343 -0
- package/lib/Heading.d.ts +343 -0
- package/lib/Heading.js +147 -0
- package/lib/Highlight.cjs +1 -0
- package/lib/Highlight.d.cts +344 -0
- package/lib/Highlight.d.ts +344 -0
- package/lib/Highlight.js +85 -0
- package/lib/History.cjs +1 -0
- package/lib/History.d.cts +343 -0
- package/lib/History.d.ts +343 -0
- package/lib/History.js +431 -0
- package/lib/HorizontalRule.cjs +1 -0
- package/lib/HorizontalRule.d.cts +343 -0
- package/lib/HorizontalRule.d.ts +343 -0
- package/lib/HorizontalRule.js +87 -0
- package/lib/Iframe.cjs +1 -0
- package/lib/Iframe.d.cts +277 -0
- package/lib/Iframe.d.ts +277 -0
- package/lib/Iframe.js +6 -0
- package/lib/Image.cjs +1 -0
- package/lib/Image.d.cts +370 -0
- package/lib/Image.d.ts +370 -0
- package/lib/Image.js +7 -0
- package/lib/ImageGif.cjs +1 -0
- package/lib/ImageGif.d.cts +292 -0
- package/lib/ImageGif.d.ts +292 -0
- package/lib/ImageGif.js +7 -0
- package/lib/ImportWord.cjs +231 -0
- package/lib/ImportWord.d.cts +353 -0
- package/lib/ImportWord.d.ts +353 -0
- package/lib/ImportWord.js +16620 -0
- package/lib/Indent.cjs +1 -0
- package/lib/Indent.d.cts +344 -0
- package/lib/Indent.d.ts +344 -0
- package/lib/Indent.js +78 -0
- package/lib/Italic.cjs +1 -0
- package/lib/Italic.d.cts +343 -0
- package/lib/Italic.d.ts +343 -0
- package/lib/Italic.js +91 -0
- package/lib/Katex.cjs +1 -0
- package/lib/Katex.d.cts +279 -0
- package/lib/Katex.d.ts +279 -0
- package/lib/Katex.js +197 -0
- package/lib/LineHeight.cjs +1 -0
- package/lib/LineHeight.d.cts +347 -0
- package/lib/LineHeight.d.ts +347 -0
- package/lib/LineHeight.js +137 -0
- package/lib/Link.cjs +5 -0
- package/lib/Link.d.cts +343 -0
- package/lib/Link.d.ts +343 -0
- package/lib/Link.js +1048 -0
- package/lib/ListItem.cjs +1 -0
- package/lib/ListItem.d.cts +269 -0
- package/lib/ListItem.d.ts +269 -0
- package/lib/ListItem.js +33 -0
- package/lib/Mention.cjs +1 -0
- package/lib/Mention.d.cts +272 -0
- package/lib/Mention.d.ts +272 -0
- package/lib/Mention.js +233 -0
- package/lib/Mermaid.cjs +2 -0
- package/lib/Mermaid.d.cts +344 -0
- package/lib/Mermaid.d.ts +344 -0
- package/lib/Mermaid.js +390 -0
- package/lib/MoreMark.cjs +1 -0
- package/lib/MoreMark.d.cts +355 -0
- package/lib/MoreMark.d.ts +355 -0
- package/lib/MoreMark.js +95 -0
- package/lib/MultiColumn.cjs +1 -0
- package/lib/MultiColumn.d.cts +277 -0
- package/lib/MultiColumn.d.ts +277 -0
- package/lib/MultiColumn.js +8 -0
- package/lib/OrderedList.cjs +1 -0
- package/lib/OrderedList.d.cts +343 -0
- package/lib/OrderedList.d.ts +343 -0
- package/lib/OrderedList.js +90 -0
- package/lib/RichTextEditor-CM-Xq9RS.cjs +137 -0
- package/lib/RichTextEditor-DvrUVNK2.js +11417 -0
- package/lib/SearchAndReplace.cjs +1 -0
- package/lib/SearchAndReplace.d.cts +358 -0
- package/lib/SearchAndReplace.d.ts +358 -0
- package/lib/SearchAndReplace.js +339 -0
- package/lib/Selection.cjs +1 -0
- package/lib/Selection.d.cts +272 -0
- package/lib/Selection.d.ts +272 -0
- package/lib/Selection.js +25 -0
- package/lib/SlashCommand.cjs +1 -0
- package/lib/SlashCommand.d.cts +299 -0
- package/lib/SlashCommand.d.ts +299 -0
- package/lib/SlashCommand.js +369 -0
- package/lib/Strike.cjs +1 -0
- package/lib/Strike.d.cts +343 -0
- package/lib/Strike.d.ts +343 -0
- package/lib/Strike.js +80 -0
- package/lib/SubAndSuperScript.cjs +1 -0
- package/lib/SubAndSuperScript.d.cts +358 -0
- package/lib/SubAndSuperScript.d.ts +358 -0
- package/lib/SubAndSuperScript.js +41 -0
- package/lib/Table.cjs +1 -0
- package/lib/Table.d.cts +366 -0
- package/lib/Table.d.ts +366 -0
- package/lib/Table.js +2165 -0
- package/lib/TableOfContent.cjs +1 -0
- package/lib/TableOfContent.d.cts +274 -0
- package/lib/TableOfContent.d.ts +274 -0
- package/lib/TableOfContent.js +184 -0
- package/lib/TaskList.cjs +1 -0
- package/lib/TaskList.d.cts +349 -0
- package/lib/TaskList.d.ts +349 -0
- package/lib/TaskList.js +175 -0
- package/lib/TextAlign.cjs +1 -0
- package/lib/TextAlign.d.cts +353 -0
- package/lib/TextAlign.d.ts +353 -0
- package/lib/TextAlign.js +165 -0
- package/lib/TextBubble.cjs +1 -0
- package/lib/TextBubble.d.cts +343 -0
- package/lib/TextBubble.d.ts +343 -0
- package/lib/TextBubble.js +131 -0
- package/lib/TextDirection.cjs +1 -0
- package/lib/TextDirection.d.cts +270 -0
- package/lib/TextDirection.d.ts +270 -0
- package/lib/TextDirection.js +142 -0
- package/lib/TextUnderline.cjs +1 -0
- package/lib/TextUnderline.d.cts +343 -0
- package/lib/TextUnderline.d.ts +343 -0
- package/lib/TextUnderline.js +61 -0
- package/lib/TrailingNode.cjs +1 -0
- package/lib/TrailingNode.d.cts +280 -0
- package/lib/TrailingNode.d.ts +280 -0
- package/lib/TrailingNode.js +41 -0
- package/lib/Twitter-BuMkJKBq.cjs +17 -0
- package/lib/Twitter-BvdxYuDK.js +1743 -0
- package/lib/Twitter.cjs +1 -0
- package/lib/Twitter.d.cts +295 -0
- package/lib/Twitter.d.ts +295 -0
- package/lib/Twitter.js +6 -0
- package/lib/Video.cjs +1 -0
- package/lib/Video.d.cts +371 -0
- package/lib/Video.d.ts +371 -0
- package/lib/Video.js +6 -0
- package/lib/bubble-extra.cjs +2 -0
- package/lib/bubble-extra.d.cts +294 -0
- package/lib/bubble-extra.d.ts +294 -0
- package/lib/bubble-extra.js +623 -0
- package/lib/dom-dataset-CAXnsjYE.cjs +33 -0
- package/lib/dom-dataset-CJ7GyQ2E.js +999 -0
- package/lib/index-COecBbaE.cjs +89 -0
- package/lib/index-ClFtfQ0J.cjs +1 -0
- package/lib/index-CvYIX2-x.js +129 -0
- package/lib/index-CySbCeQd.cjs +1 -0
- package/lib/{index-CO-iymkb.js → index-D9llIWB5.js} +442 -101
- package/lib/index-DXBa3JBo.js +46 -0
- package/lib/index-DjP7Onch.cjs +1 -0
- package/lib/index-Drmyqk9P.js +12322 -0
- package/lib/index-DuhDIOel.js +76 -0
- package/lib/index-LbrE7K9i.cjs +1 -0
- package/lib/index.cjs +2 -1
- package/lib/index.d.cts +290 -108
- package/lib/index.d.ts +290 -108
- package/lib/index.js +587 -13
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.d.cts +108 -108
- package/lib/locale-bundle.d.ts +108 -108
- package/lib/locale-bundle.js +1 -1
- package/lib/shortId-Bfj8TyNr.cjs +2 -0
- package/lib/shortId-WJVkrvml.js +30 -0
- package/lib/style.css +1 -1
- package/lib/textarea-B172kMgC.js +20 -0
- package/lib/textarea-CapyElEP.cjs +1 -0
- package/package.json +678 -15
- package/lib/RichTextEditor-Ce2IeNE6.js +0 -8265
- package/lib/RichTextEditor-hDDApaDD.cjs +0 -136
- package/lib/extension-bundle.cjs +0 -33
- package/lib/extension-bundle.d.cts +0 -951
- package/lib/extension-bundle.d.ts +0 -951
- package/lib/extension-bundle.js +0 -5982
- package/lib/index-CJ6Hb9MN.cjs +0 -1
- package/lib/tiptap-DOP8lVCQ.js +0 -5950
- package/lib/tiptap-Dq62HiQ9.cjs +0 -113
- package/lib/vendor-BbgkyoD-.js +0 -40297
- package/lib/vendor-DdwtMmSr.cjs +0 -302
package/lib/Mermaid.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { g as $, m as X } from "./index-Drmyqk9P.js";
|
|
2
|
+
import { w as Z, x as J, A as K, y as Y, z as Q, F as tt, B as et, G as rt, J as V, K as it, N as at } from "./RichTextEditor-DvrUVNK2.js";
|
|
3
|
+
import { N as st, R as nt } from "./dom-dataset-CJ7GyQ2E.js";
|
|
4
|
+
import { jsxs as C, jsx as o } from "react/jsx-runtime";
|
|
5
|
+
import { useState as g, useRef as ot, useCallback as y, useEffect as E, useMemo as D } from "react";
|
|
6
|
+
import { s as lt, i as ct } from "./shortId-WJVkrvml.js";
|
|
7
|
+
import { T as dt } from "./textarea-B172kMgC.js";
|
|
8
|
+
import { I as q, j as ht, k as W } from "./index-D9llIWB5.js";
|
|
9
|
+
const j = `graph TB
|
|
10
|
+
a-->b`, ut = ({ editor: r, upload: t }) => {
|
|
11
|
+
const [e, s] = g(j), [f, b] = g(""), [x, T] = g(!1), A = ot(null), [l, c] = g(null), N = y(
|
|
12
|
+
(n) => {
|
|
13
|
+
n && import("mermaid").then((p) => {
|
|
14
|
+
c(p.default);
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
[]
|
|
18
|
+
), _ = async (n) => {
|
|
19
|
+
try {
|
|
20
|
+
const { svg: p } = await l.render("mermaid-svg", n);
|
|
21
|
+
b(p);
|
|
22
|
+
} catch {
|
|
23
|
+
b("");
|
|
24
|
+
}
|
|
25
|
+
}, L = () => {
|
|
26
|
+
l.initialize({
|
|
27
|
+
darkMode: !1,
|
|
28
|
+
startOnLoad: !1,
|
|
29
|
+
// fontFamily:'',
|
|
30
|
+
fontSize: 12,
|
|
31
|
+
theme: "base"
|
|
32
|
+
}), _(e);
|
|
33
|
+
};
|
|
34
|
+
return E(() => {
|
|
35
|
+
l && x && L();
|
|
36
|
+
}, [l, x]), E(() => {
|
|
37
|
+
l && x && _(e);
|
|
38
|
+
}, [l && e]), /* @__PURE__ */ C(
|
|
39
|
+
Z,
|
|
40
|
+
{
|
|
41
|
+
onOpenChange: T,
|
|
42
|
+
open: x,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ o(J, { asChild: !0, children: /* @__PURE__ */ o(
|
|
45
|
+
K,
|
|
46
|
+
{
|
|
47
|
+
action: () => T(!0),
|
|
48
|
+
icon: "Mermaid",
|
|
49
|
+
tooltip: "Mermaid"
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ C(Y, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
|
|
53
|
+
/* @__PURE__ */ o(Q, { children: "Mermaid" }),
|
|
54
|
+
/* @__PURE__ */ o(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
ref: N,
|
|
58
|
+
style: { height: "100%", border: "1px solid hsl(var(--border))" },
|
|
59
|
+
children: /* @__PURE__ */ C("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
|
|
60
|
+
/* @__PURE__ */ o(
|
|
61
|
+
dt,
|
|
62
|
+
{
|
|
63
|
+
autoFocus: !0,
|
|
64
|
+
className: "richtext-flex-1",
|
|
65
|
+
defaultValue: j,
|
|
66
|
+
onChange: (n) => s(n.target.value),
|
|
67
|
+
placeholder: "Text",
|
|
68
|
+
required: !0,
|
|
69
|
+
rows: 10,
|
|
70
|
+
value: e,
|
|
71
|
+
style: {
|
|
72
|
+
color: "hsl(var(--richtext-foreground))"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ o(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: "richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",
|
|
80
|
+
dangerouslySetInnerHTML: { __html: f },
|
|
81
|
+
ref: A,
|
|
82
|
+
style: { height: "100%", borderWidth: 1, minHeight: 500, background: "#fff" }
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] })
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ o(tt, { children: /* @__PURE__ */ o(
|
|
89
|
+
et,
|
|
90
|
+
{
|
|
91
|
+
onClick: async () => {
|
|
92
|
+
if (e !== "") {
|
|
93
|
+
if (e) {
|
|
94
|
+
const n = A.current.querySelector("svg"), { width: p, height: H } = n.getBoundingClientRect(), I = `mermaid-${lt()}.svg`;
|
|
95
|
+
let w = ct(n.outerHTML);
|
|
96
|
+
if (t) {
|
|
97
|
+
console.log({
|
|
98
|
+
src: w
|
|
99
|
+
});
|
|
100
|
+
const R = rt(w, I);
|
|
101
|
+
w = await t(R);
|
|
102
|
+
}
|
|
103
|
+
r == null || r.chain().focus().setMermaid(
|
|
104
|
+
{
|
|
105
|
+
type: "mermaid",
|
|
106
|
+
src: w,
|
|
107
|
+
alt: encodeURIComponent(e),
|
|
108
|
+
width: p,
|
|
109
|
+
height: H
|
|
110
|
+
},
|
|
111
|
+
!!e
|
|
112
|
+
).run();
|
|
113
|
+
}
|
|
114
|
+
T(!1);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
type: "button",
|
|
118
|
+
children: "Save changes"
|
|
119
|
+
}
|
|
120
|
+
) })
|
|
121
|
+
] })
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}, O = {
|
|
126
|
+
TOP_LEFT: "tl",
|
|
127
|
+
TOP_RIGHT: "tr",
|
|
128
|
+
BOTTOM_LEFT: "bl",
|
|
129
|
+
BOTTOM_RIGHT: "br"
|
|
130
|
+
};
|
|
131
|
+
function mt({ editor: r, node: t, updateAttributes: e, getPos: s, selected: f }) {
|
|
132
|
+
const [b, x] = g({
|
|
133
|
+
width: q,
|
|
134
|
+
height: q
|
|
135
|
+
}), [T, A] = g({
|
|
136
|
+
width: 0,
|
|
137
|
+
height: 0
|
|
138
|
+
}), [l] = g([
|
|
139
|
+
O.TOP_LEFT,
|
|
140
|
+
O.TOP_RIGHT,
|
|
141
|
+
O.BOTTOM_LEFT,
|
|
142
|
+
O.BOTTOM_RIGHT
|
|
143
|
+
]), [c, N] = g(!1), [_, L] = g({
|
|
144
|
+
x: 0,
|
|
145
|
+
y: 0,
|
|
146
|
+
w: 0,
|
|
147
|
+
h: 0,
|
|
148
|
+
dir: ""
|
|
149
|
+
}), { align: F } = t == null ? void 0 : t.attrs, n = D(() => {
|
|
150
|
+
const { src: i, alt: h, width: u, height: M } = t == null ? void 0 : t.attrs, v = $(u) ? `${u}px` : u, a = $(M) ? `${M}px` : M;
|
|
151
|
+
return {
|
|
152
|
+
src: i || void 0,
|
|
153
|
+
alt: h || void 0,
|
|
154
|
+
style: {
|
|
155
|
+
width: v || void 0,
|
|
156
|
+
height: a || void 0
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}, [t == null ? void 0 : t.attrs]), p = D(() => {
|
|
160
|
+
const {
|
|
161
|
+
style: { width: i }
|
|
162
|
+
} = n;
|
|
163
|
+
return { width: i === "100%" ? i : void 0 };
|
|
164
|
+
}, [n]);
|
|
165
|
+
function H(i) {
|
|
166
|
+
A({
|
|
167
|
+
width: i.target.width,
|
|
168
|
+
height: i.target.height
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function I() {
|
|
172
|
+
r.commands.setNodeSelection(s());
|
|
173
|
+
}
|
|
174
|
+
const w = y(
|
|
175
|
+
V(() => {
|
|
176
|
+
const { width: i } = getComputedStyle(r.view.dom);
|
|
177
|
+
x((h) => ({
|
|
178
|
+
...h,
|
|
179
|
+
width: Number.parseInt(i, 10)
|
|
180
|
+
}));
|
|
181
|
+
}, W),
|
|
182
|
+
[r]
|
|
183
|
+
);
|
|
184
|
+
function R(i, h) {
|
|
185
|
+
i.preventDefault(), i.stopPropagation();
|
|
186
|
+
const u = T.width, M = T.height, v = u / M;
|
|
187
|
+
let a = Number(t.attrs.width), m = Number(t.attrs.height);
|
|
188
|
+
const d = b.width;
|
|
189
|
+
a && !m ? (a = a > d ? d : a, m = Math.round(a / v)) : m && !a ? (a = Math.round(m * v), a = a > d ? d : a) : !a && !m ? (a = u > d ? d : u, m = Math.round(a / v)) : a = a > d ? d : a, N(!0), L({
|
|
190
|
+
x: i.clientX,
|
|
191
|
+
y: i.clientY,
|
|
192
|
+
w: a,
|
|
193
|
+
h: m,
|
|
194
|
+
dir: h
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const S = y(
|
|
198
|
+
V((i) => {
|
|
199
|
+
if (i.preventDefault(), i.stopPropagation(), !c)
|
|
200
|
+
return;
|
|
201
|
+
const { x: h, w: u, dir: M } = _, v = (i.clientX - h) * (/l/.test(M) ? -1 : 1), { width: a, height: m } = t == null ? void 0 : t.attrs, d = a / m, P = it(u + v, ht, b.width), U = Math.round(P / d);
|
|
202
|
+
e({
|
|
203
|
+
width: P,
|
|
204
|
+
height: U
|
|
205
|
+
});
|
|
206
|
+
}, W),
|
|
207
|
+
[c, _, b, e, t == null ? void 0 : t.attrs]
|
|
208
|
+
), z = y(
|
|
209
|
+
(i) => {
|
|
210
|
+
i.preventDefault(), i.stopPropagation(), c && (L({
|
|
211
|
+
x: 0,
|
|
212
|
+
y: 0,
|
|
213
|
+
w: 0,
|
|
214
|
+
h: 0,
|
|
215
|
+
dir: ""
|
|
216
|
+
}), N(!1), I());
|
|
217
|
+
},
|
|
218
|
+
[c, I]
|
|
219
|
+
), G = y(() => {
|
|
220
|
+
document == null || document.addEventListener("mousemove", S, !0), document == null || document.addEventListener("mouseup", z, !0);
|
|
221
|
+
}, [S, z]), k = y(() => {
|
|
222
|
+
document == null || document.removeEventListener("mousemove", S, !0), document == null || document.removeEventListener("mouseup", z, !0);
|
|
223
|
+
}, [S, z]);
|
|
224
|
+
E(() => (c ? G() : k(), () => {
|
|
225
|
+
k();
|
|
226
|
+
}), [c, G, k]);
|
|
227
|
+
const B = D(() => new ResizeObserver(() => w()), [w]);
|
|
228
|
+
return E(() => (B.observe(r.view.dom), () => {
|
|
229
|
+
B.disconnect();
|
|
230
|
+
}), [r.view.dom, B]), /* @__PURE__ */ o(
|
|
231
|
+
st,
|
|
232
|
+
{
|
|
233
|
+
className: "image-view",
|
|
234
|
+
style: { ...p, width: "100%", textAlign: F },
|
|
235
|
+
children: /* @__PURE__ */ C(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
"data-drag-handle": !0,
|
|
239
|
+
draggable: "true",
|
|
240
|
+
style: { ...p, background: "#fff" },
|
|
241
|
+
className: `image-view__body ${f ? "image-view__body--focused" : ""} ${c ? "image-view__body--resizing" : ""}`,
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ o(
|
|
244
|
+
"img",
|
|
245
|
+
{
|
|
246
|
+
alt: n.alt,
|
|
247
|
+
className: "image-view__body__image block",
|
|
248
|
+
height: "auto",
|
|
249
|
+
onClick: I,
|
|
250
|
+
onLoad: H,
|
|
251
|
+
src: n.src,
|
|
252
|
+
style: n.style
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
r.view.editable && (f || c) && /* @__PURE__ */ o("div", { className: "image-resizer", children: l == null ? void 0 : l.map((i) => /* @__PURE__ */ o(
|
|
256
|
+
"span",
|
|
257
|
+
{
|
|
258
|
+
className: `image-resizer__handler image-resizer__handler--${i}`,
|
|
259
|
+
onMouseDown: (h) => R(h, i)
|
|
260
|
+
},
|
|
261
|
+
`image-dir-${i}`
|
|
262
|
+
)) })
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
const Tt = /* @__PURE__ */ at.extend({
|
|
270
|
+
name: "mermaid",
|
|
271
|
+
addOptions() {
|
|
272
|
+
var r;
|
|
273
|
+
return {
|
|
274
|
+
...(r = this.parent) == null ? void 0 : r.call(this),
|
|
275
|
+
inline: !1,
|
|
276
|
+
content: "",
|
|
277
|
+
marks: "",
|
|
278
|
+
group: "block",
|
|
279
|
+
draggable: !1,
|
|
280
|
+
selectable: !0,
|
|
281
|
+
atom: !0,
|
|
282
|
+
HTMLAttributes: {
|
|
283
|
+
class: "mermaid"
|
|
284
|
+
},
|
|
285
|
+
button: ({ editor: t, t: e, extension: s }) => {
|
|
286
|
+
var f;
|
|
287
|
+
return {
|
|
288
|
+
component: ut,
|
|
289
|
+
componentProps: {
|
|
290
|
+
action: () => !0,
|
|
291
|
+
isActive: () => !1,
|
|
292
|
+
disabled: !1,
|
|
293
|
+
editor: t,
|
|
294
|
+
icon: "Mermaid",
|
|
295
|
+
tooltip: e("editor.mermaid.tooltip"),
|
|
296
|
+
upload: (f = s == null ? void 0 : s.options) == null ? void 0 : f.upload
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
addAttributes() {
|
|
303
|
+
var r;
|
|
304
|
+
return {
|
|
305
|
+
...(r = this.parent) == null ? void 0 : r.call(this),
|
|
306
|
+
width: {
|
|
307
|
+
default: null,
|
|
308
|
+
parseHTML: (t) => {
|
|
309
|
+
const e = t.querySelector("img"), s = e == null ? void 0 : e.getAttribute("width");
|
|
310
|
+
return s ? Number.parseInt(s, 10) : 320;
|
|
311
|
+
},
|
|
312
|
+
renderHTML: (t) => ({
|
|
313
|
+
width: t.width
|
|
314
|
+
})
|
|
315
|
+
},
|
|
316
|
+
height: {
|
|
317
|
+
default: null,
|
|
318
|
+
parseHTML: (t) => {
|
|
319
|
+
const e = t.querySelector("img"), s = e == null ? void 0 : e.getAttribute("height");
|
|
320
|
+
return s ? Number.parseInt(s, 10) : 212;
|
|
321
|
+
},
|
|
322
|
+
renderHTML: (t) => ({
|
|
323
|
+
height: t.height
|
|
324
|
+
})
|
|
325
|
+
},
|
|
326
|
+
align: {
|
|
327
|
+
default: "center",
|
|
328
|
+
parseHTML: (t) => t.getAttribute("align"),
|
|
329
|
+
renderHTML: (t) => ({
|
|
330
|
+
align: t.align
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
},
|
|
335
|
+
addNodeView() {
|
|
336
|
+
return nt(mt);
|
|
337
|
+
},
|
|
338
|
+
// @ts-ignore
|
|
339
|
+
addCommands() {
|
|
340
|
+
return {
|
|
341
|
+
setMermaid: (r, t) => ({ commands: e, editor: s }) => t ? e.insertContent({
|
|
342
|
+
type: this.name,
|
|
343
|
+
attrs: r
|
|
344
|
+
}) : e.insertContentAt(s.state.selection.anchor, {
|
|
345
|
+
type: this.name,
|
|
346
|
+
attrs: r
|
|
347
|
+
}),
|
|
348
|
+
setAlignImageMermaid: (r) => ({ commands: t }) => t.updateAttributes(this.name, { align: r })
|
|
349
|
+
};
|
|
350
|
+
},
|
|
351
|
+
renderHTML({ HTMLAttributes: r }) {
|
|
352
|
+
const { align: t } = r;
|
|
353
|
+
return [
|
|
354
|
+
"div",
|
|
355
|
+
// Parent element
|
|
356
|
+
{
|
|
357
|
+
style: t ? `text-align: ${t};` : "",
|
|
358
|
+
class: "imageMermaid"
|
|
359
|
+
},
|
|
360
|
+
[
|
|
361
|
+
"img",
|
|
362
|
+
X(
|
|
363
|
+
// @ts-ignore
|
|
364
|
+
this.options.HTMLAttributes,
|
|
365
|
+
r
|
|
366
|
+
)
|
|
367
|
+
]
|
|
368
|
+
];
|
|
369
|
+
},
|
|
370
|
+
parseHTML() {
|
|
371
|
+
return [
|
|
372
|
+
{
|
|
373
|
+
tag: "div[class=imageMermaid]",
|
|
374
|
+
getAttrs: (r) => {
|
|
375
|
+
const t = r.querySelector("img"), e = t == null ? void 0 : t.getAttribute("width"), s = t == null ? void 0 : t.getAttribute("height");
|
|
376
|
+
return {
|
|
377
|
+
src: t == null ? void 0 : t.getAttribute("src"),
|
|
378
|
+
alt: t == null ? void 0 : t.getAttribute("alt"),
|
|
379
|
+
width: e ? Number.parseInt(e, 10) : null,
|
|
380
|
+
height: s ? Number.parseInt(s, 10) : null,
|
|
381
|
+
align: (t == null ? void 0 : t.getAttribute("align")) || r.style.textAlign || null
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
export {
|
|
389
|
+
Tt as Mermaid
|
|
390
|
+
};
|
package/lib/MoreMark.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-COecBbaE.cjs"),l=require("./index-ClFtfQ0J.cjs"),c=require("react/jsx-runtime"),x=require("react"),s=require("./RichTextEditor-CM-Xq9RS.cjs");function b(t){var n;const i=x.useMemo(()=>{var r;const e=(r=t==null?void 0:t.items)==null?void 0:r.find(u=>u.isActive());return e&&!e.default?{...e,icon:e!=null&&e.icon?e==null?void 0:e.icon:t==null?void 0:t.icon}:{title:t.tooltip,icon:t.icon,isActive:()=>!1}},[t]);return c.jsxs(s.DropdownMenu,{children:[c.jsx(s.DropdownMenuTrigger,{asChild:!0,disabled:t==null?void 0:t.disabled,children:c.jsx(s.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:t==null?void 0:t.disabled,icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,children:c.jsx(s.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),c.jsx(s.DropdownMenuContent,{className:"w-full",children:(n=t==null?void 0:t.items)==null?void 0:n.map((e,o)=>c.jsxs(s.DropdownMenuCheckboxItem,{checked:i.title===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[c.jsx(s.IconComponent,{name:e==null?void 0:e.icon}),c.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&c.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:s.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${o}`))})]})}const m=h.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:i,extension:n,t:e}){const o=n.options.subscript,r=n.options.superscript,u={action:()=>i.commands.toggleSubscript(),isActive:()=>i.isActive("subscript")||!1,disabled:!i.can().toggleSubscript(),icon:"Subscript",title:e("editor.subscript.tooltip"),shortcutKeys:["mod","."]},d={action:()=>i.commands.toggleSuperscript(),isActive:()=>i.isActive("superscript")||!1,disabled:!i.can().toggleSuperscript(),icon:"Superscript",title:e("editor.superscript.tooltip"),shortcutKeys:["mod",","]},a=[];return o!==!1&&a.push(u),r!==!1&&a.push(d),{component:b,componentProps:{icon:"Type",tooltip:e("editor.moremark"),disabled:!i.isEditable,items:a}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(l.Subscript.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(l.Superscript.configure(this.options.superscript)),t}});exports.MoreMark=m;
|