@remarkablejames/editor 0.0.1 → 0.0.2
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-B0EHT9CC.js → ActionMenuButton-Bmn3RME4.js} +10 -9
- package/lib/ActionMenuButton-C5P0Kzrb.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +33 -31
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +12 -13
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +10 -11
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +8 -9
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +45 -41
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +14 -13
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +5 -6
- package/lib/CodeBlock.cjs +1 -44
- package/lib/CodeBlock.js +183 -3858
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +8 -9
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +19 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +8 -9
- package/lib/{Drawer-BCWVN-4l.js → Drawer-DvGh9aXG.js} +52 -46
- package/lib/Drawer-gz9U5ArC.cjs +2 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +15 -14
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +20 -16
- package/lib/ExportPdf.cjs +3 -3
- package/lib/ExportPdf.js +13 -14
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +6 -6
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +6 -7
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +14 -15
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +26 -26
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +23 -22
- package/lib/History.cjs +1 -1
- package/lib/History.js +11 -11
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +9 -10
- package/lib/Icon-CKM0tYbW.js +15 -0
- package/lib/Icon-CQyFgXeo.cjs +1 -0
- package/lib/{Iframe-BdgiWGml.js → Iframe-CnnvV6cK.js} +21 -19
- package/lib/Iframe-Ds6gG2YO.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +5 -4
- package/lib/ImageCropper-BKhXlnXN.cjs +1 -0
- package/lib/ImageCropper-DUzu_9-6.js +896 -0
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +94 -91
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +26 -25
- package/lib/{Indent-BpMcZKok.js → Indent-Bsj8gKvT.js} +30 -31
- package/lib/Indent-D_7HOYYd.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +11 -12
- package/lib/{Katex-B8_uprkO.js → Katex-CilGTz7u.js} +22 -19
- package/lib/Katex-lL3bHXJd.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +20 -19
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-BX0fXXpF.js → LinkEditBlock-BD_WvA3r.js} +24 -19
- package/lib/LinkEditBlock-D3HSHmsU.cjs +5 -0
- package/lib/Mention.js +3 -3
- package/lib/Mermaid-BfeLPzoS.cjs +2 -0
- package/lib/{Mermaid-D8bbIgAl.js → Mermaid-BrjU75Bs.js} +48 -45
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +2 -2
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +28 -26
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -11
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +42 -37
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +5 -5
- package/lib/{SlashCommandNodeView-BcmtKbEE.js → SlashCommandNodeView-COx5qZ2y.js} +41 -39
- package/lib/SlashCommandNodeView-DD-nlhM-.cjs +1 -0
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +11 -12
- package/lib/{Table-DbxuP5xh.js → Table-BlM8yMhr.js} +46 -46
- package/lib/Table-C21AlUrh.cjs +5 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +11 -12
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +27 -26
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +19 -18
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +8 -9
- package/lib/{Twitter-9I6BLNmg.js → Twitter-BP8sYXX7.js} +22 -18
- package/lib/Twitter-D46MnvPr.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video-Bpd8W8l6.js +231 -0
- package/lib/Video-BwrHx6B1.cjs +1 -0
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -4
- package/lib/bubble.cjs +3 -3
- package/lib/bubble.js +171 -162
- package/lib/button-BmTP96NR.cjs +1 -0
- package/lib/button-CDIxPURh.js +35 -0
- package/lib/checkbox-7sfSdzy9.js +29 -0
- package/lib/checkbox-DyVlLWHv.cjs +1 -0
- package/lib/{clsx-CDyrfCnw.js → clsx-m_C5j3RU.js} +24 -24
- package/lib/dialog-B-jOQ5i3.cjs +1 -0
- package/lib/dialog-QWWUWOGP.js +95 -0
- package/lib/{dropdown-menu-Bs69ZBbO.js → dropdown-menu-C1hdPLCZ.js} +1 -1
- package/lib/{dropdown-menu-DjWlG2-J.cjs → dropdown-menu-CkHN04Mx.cjs} +1 -1
- package/lib/events.constant-Bh2uzJud.js +71 -0
- package/lib/events.constant-ELn21EzG.cjs +1 -0
- package/lib/extensions/CodeBlock/CodeBlock.d.ts +1 -1
- package/lib/file-BLas99n7.js +43 -0
- package/lib/file-i7e4nQY2.cjs +1 -0
- package/lib/{index-C-tDsIKJ.js → index-B3Ijnbxs.js} +1 -1
- package/lib/{index-C1WCZhyA.js → index-C1KQsOcg.js} +1 -1
- package/lib/{index-CsSfYR30.js → index-C8FjP66D.js} +1 -1
- package/lib/index-CAiZY1nx.js +2741 -0
- package/lib/index-DWSAk_9a.cjs +1 -0
- package/lib/{index-DjDf4BK8.js → index-s3l5RdyW.js} +1 -1
- package/lib/index.cjs +4 -4
- package/lib/index.js +392 -147
- package/lib/input-qvpuOf-3.js +21 -0
- package/lib/input-s0JD5kf2.cjs +1 -0
- package/lib/isNumber-BTYSVlKo.cjs +1 -0
- package/lib/isNumber-WaBzl_0s.js +15 -0
- package/lib/label-CFax-gzo.cjs +1 -0
- package/lib/label-DC37f2RQ.js +11 -0
- package/lib/{popover-D-hUKDYu.cjs → popover-B05Fd8lC.cjs} +1 -1
- package/lib/{popover-CPr9bHYn.js → popover-CsSXh7w6.js} +1 -1
- package/lib/{renderNodeView-BJSrgyGj.js → renderNodeView-C_hPIdEs.js} +2 -2
- package/lib/{select-C2KF4RNg.cjs → select-7ubC1NF0.cjs} +1 -1
- package/lib/{select-CuE_HaQJ.js → select-B3-5wTqn.js} +1 -1
- package/lib/{separator-CHzYNMVt.js → separator-CYCA8tSn.js} +13 -12
- package/lib/separator-ncbdw4oq.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/tabs-BeHxylKH.js +46 -0
- package/lib/tabs-DBqNpGAq.cjs +1 -0
- package/lib/{textarea-gEoNp9CA.js → textarea-1FhpmBkP.js} +1 -1
- package/lib/{textarea-DZj6EY-N.cjs → textarea-Bjhcpp76.cjs} +1 -1
- package/lib/throttle-CRNq0z-O.js +249 -0
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-DoJTBdvy.js +89 -0
- package/lib/toggle-oFwBZC4x.cjs +1 -0
- package/lib/{updatePosition-e90ZrFWW.js → updatePosition-DvfTZHcH.js} +2 -2
- package/lib/useButtonProps-BE10eHkG.js +165 -0
- package/lib/useButtonProps-CFu0GHzW.cjs +1 -0
- package/package.json +1 -1
- package/lib/ActionMenuButton-J1el_e6Z.cjs +0 -1
- package/lib/Drawer-BTouEroZ.cjs +0 -2
- package/lib/Iframe-BfBLILDA.cjs +0 -1
- package/lib/Indent-Dvqz_WEn.cjs +0 -1
- package/lib/Katex-BQyeCeQ0.cjs +0 -4
- package/lib/LinkEditBlock-CIshn_8F.cjs +0 -5
- package/lib/Mermaid-0GiGVxn0.cjs +0 -2
- package/lib/SlashCommandNodeView-rDJ7OjRd.cjs +0 -1
- package/lib/Table-BEhNBeuA.cjs +0 -5
- package/lib/Twitter-BuEBgpi9.cjs +0 -1
- package/lib/index-D9oM__YW.cjs +0 -1
- package/lib/index-lj3VWExo.js +0 -4883
- package/lib/separator-_gvUNba_.cjs +0 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { N as I } from "./clsx-m_C5j3RU.js";
|
|
2
|
+
import { u as $, V as H } from "./index-4Q5IhypJ.js";
|
|
3
|
+
import { f as S, u as R, c as z, i as B, k as N } from "./useButtonProps-BE10eHkG.js";
|
|
4
|
+
import { jsxs as d, jsx as s } from "react/jsx-runtime";
|
|
5
|
+
import { useState as y, useRef as E, useMemo as U } from "react";
|
|
6
|
+
import { A as j } from "./toggle-DoJTBdvy.js";
|
|
7
|
+
import { D as F, a as O, b as Z, c as _ } from "./dialog-QWWUWOGP.js";
|
|
8
|
+
import { T as q, a as W, b as L, c as M } from "./tabs-BeHxylKH.js";
|
|
9
|
+
import { B as T } from "./button-CDIxPURh.js";
|
|
10
|
+
import { I as G } from "./input-qvpuOf-3.js";
|
|
11
|
+
function J(e, t) {
|
|
12
|
+
let o;
|
|
13
|
+
try {
|
|
14
|
+
o = new URL(e);
|
|
15
|
+
} catch {
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
return !(t != null && t.length) || t.length === 1 && t[0] === "." ? !0 : t.some((n) => {
|
|
19
|
+
if (n.includes("*")) {
|
|
20
|
+
const a = n.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*");
|
|
21
|
+
return new RegExp(`^${a}$`).test(o.hostname);
|
|
22
|
+
}
|
|
23
|
+
return o.hostname.includes(n);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function ne() {
|
|
27
|
+
const { t: e } = $(), t = S(), o = R(k.name), { icon: n, tooltip: a } = (o == null ? void 0 : o.componentProps) ?? {}, { editorDisabled: c } = z(), [u, v] = y(""), b = E(null), [g, h] = y(""), [x, p] = y(!1), m = B(k.name), i = U(() => (m == null ? void 0 : m.options) ?? {}, [m]);
|
|
28
|
+
async function D(r) {
|
|
29
|
+
var V;
|
|
30
|
+
const l = (V = r == null ? void 0 : r.target) == null ? void 0 : V.files;
|
|
31
|
+
if (!t || t.isDestroyed || l.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
const f = l[0];
|
|
34
|
+
let w = "";
|
|
35
|
+
i.upload ? w = await i.upload(f) : w = URL.createObjectURL(f), t.chain().focus().setVideo({
|
|
36
|
+
src: w,
|
|
37
|
+
width: "100%"
|
|
38
|
+
}).run(), p(!1);
|
|
39
|
+
}
|
|
40
|
+
function A(r) {
|
|
41
|
+
r.preventDefault(), r.stopPropagation(), u && (t.chain().focus().setVideo({
|
|
42
|
+
src: u,
|
|
43
|
+
width: "100%"
|
|
44
|
+
}).run(), p(!1), v(""));
|
|
45
|
+
}
|
|
46
|
+
function C(r) {
|
|
47
|
+
var l;
|
|
48
|
+
r.preventDefault(), (l = b.current) == null || l.click();
|
|
49
|
+
}
|
|
50
|
+
return /* @__PURE__ */ d(F, { onOpenChange: p, open: x, children: [
|
|
51
|
+
/* @__PURE__ */ s(O, { asChild: !0, children: /* @__PURE__ */ s(
|
|
52
|
+
j,
|
|
53
|
+
{
|
|
54
|
+
disabled: c,
|
|
55
|
+
icon: n,
|
|
56
|
+
tooltip: a,
|
|
57
|
+
action: () => {
|
|
58
|
+
c || p(!0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
) }),
|
|
62
|
+
/* @__PURE__ */ d(Z, { children: [
|
|
63
|
+
/* @__PURE__ */ s(_, { children: e("editor.video.dialog.title") }),
|
|
64
|
+
/* @__PURE__ */ d(
|
|
65
|
+
q,
|
|
66
|
+
{
|
|
67
|
+
activationMode: "manual",
|
|
68
|
+
defaultValue: (i == null ? void 0 : i.resourceVideo) === "both" || (i == null ? void 0 : i.resourceVideo) === "upload" ? "upload" : "link",
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ d(W, { className: "richtext-grid richtext-w-full richtext-grid-cols-2", children: [
|
|
71
|
+
((i == null ? void 0 : i.resourceVideo) === "both" || (i == null ? void 0 : i.resourceVideo) === "upload") && /* @__PURE__ */ s(L, { value: "upload", children: e("editor.video.dialog.tab.upload") }),
|
|
72
|
+
((i == null ? void 0 : i.resourceVideo) === "both" || (i == null ? void 0 : i.resourceVideo) === "link") && /* @__PURE__ */ s(L, { value: "link", children: e("editor.video.dialog.link") })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ d(M, { value: "upload", children: [
|
|
75
|
+
/* @__PURE__ */ s("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: /* @__PURE__ */ s(T, { className: "richtext-mt-1 richtext-w-full", onClick: C, size: "sm", children: e("editor.video.dialog.tab.upload") }) }),
|
|
76
|
+
/* @__PURE__ */ s(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
accept: "video/*",
|
|
80
|
+
multiple: !0,
|
|
81
|
+
onChange: D,
|
|
82
|
+
ref: b,
|
|
83
|
+
type: "file",
|
|
84
|
+
style: {
|
|
85
|
+
display: "none"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ d(M, { value: "link", children: [
|
|
91
|
+
/* @__PURE__ */ s("div", { children: /* @__PURE__ */ d("div", { className: "richtext-flex richtext-items-center richtext-gap-2", children: [
|
|
92
|
+
/* @__PURE__ */ s(
|
|
93
|
+
G,
|
|
94
|
+
{
|
|
95
|
+
autoFocus: !0,
|
|
96
|
+
placeholder: e("editor.video.dialog.placeholder"),
|
|
97
|
+
required: !0,
|
|
98
|
+
type: "url",
|
|
99
|
+
value: u,
|
|
100
|
+
onBlur: (r) => {
|
|
101
|
+
const l = r.target.value, f = i.videoProviders || ["."];
|
|
102
|
+
l && !J(l, f) ? h("Invalid video URL") : h("");
|
|
103
|
+
},
|
|
104
|
+
onChange: (r) => {
|
|
105
|
+
v(r.target.value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
/* @__PURE__ */ s(T, { onClick: A, type: "button", children: e("editor.video.dialog.button.apply") })
|
|
110
|
+
] }) }),
|
|
111
|
+
g && /* @__PURE__ */ s("div", { className: "richtext-my-[5px] richtext-text-red-500", children: g })
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] })
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
function K(e) {
|
|
120
|
+
e = e.replace("https://youtu.be/", "https://www.youtube.com/watch?v=").replace("watch?v=", "embed/");
|
|
121
|
+
const t = e.match(/^https:\/\/www\.youtube\.com\/shorts\/([a-zA-Z0-9_-]+)/);
|
|
122
|
+
t && (e = `https://www.youtube.com/embed/${t[1]}`);
|
|
123
|
+
const o = e.match(/^https:\/\/vimeo\.com\/(\d+)(?:\/([a-zA-Z0-9]+))?/);
|
|
124
|
+
if (o) {
|
|
125
|
+
const a = o[1], c = o[2];
|
|
126
|
+
c ? e = `https://player.vimeo.com/video/${a}?h=${c}` : e = `https://player.vimeo.com/video/${a}`;
|
|
127
|
+
}
|
|
128
|
+
return /^https?:\/\/www.bilibili.com\/video\/.*/i.test(e) && (e = e.replace(/\?.*$/, "").replace("https://www.bilibili.com/video/", "https://player.bilibili.com/player.html?bvid=")), e.includes("drive.google.com") && (e = e.replace("/view", "/preview")), e;
|
|
129
|
+
}
|
|
130
|
+
const k = /* @__PURE__ */ I.create({
|
|
131
|
+
name: "video",
|
|
132
|
+
group: "block",
|
|
133
|
+
atom: !0,
|
|
134
|
+
draggable: !0,
|
|
135
|
+
//@ts-expect-error
|
|
136
|
+
addOptions() {
|
|
137
|
+
return {
|
|
138
|
+
divider: !1,
|
|
139
|
+
spacer: !1,
|
|
140
|
+
allowFullscreen: !0,
|
|
141
|
+
upload: void 0,
|
|
142
|
+
frameborder: !1,
|
|
143
|
+
resourceVideo: "both",
|
|
144
|
+
width: H["size-medium"],
|
|
145
|
+
HTMLAttributes: {
|
|
146
|
+
class: "iframe-wrapper"
|
|
147
|
+
// style: 'display: flex;justify-content: center;',
|
|
148
|
+
},
|
|
149
|
+
button: ({ editor: e, t }) => {
|
|
150
|
+
var o, n;
|
|
151
|
+
return {
|
|
152
|
+
componentProps: {
|
|
153
|
+
action: () => {
|
|
154
|
+
},
|
|
155
|
+
isActive: () => e.isActive("video") || !1,
|
|
156
|
+
/* If setVideo is not available(when Video Component is not imported), the button is disabled */
|
|
157
|
+
disabled: !((n = (o = e.can()).setVideo) != null && n.call(o, {})),
|
|
158
|
+
icon: "Video",
|
|
159
|
+
tooltip: t("editor.video.tooltip"),
|
|
160
|
+
videoProviders: ["."],
|
|
161
|
+
editor: e
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
addAttributes() {
|
|
168
|
+
return {
|
|
169
|
+
src: {
|
|
170
|
+
default: null,
|
|
171
|
+
renderHTML: ({ src: e }) => ({
|
|
172
|
+
src: e ? K(e) : null
|
|
173
|
+
})
|
|
174
|
+
},
|
|
175
|
+
width: {
|
|
176
|
+
default: this.options.width,
|
|
177
|
+
renderHTML: ({ width: e }) => ({
|
|
178
|
+
width: N(e)
|
|
179
|
+
})
|
|
180
|
+
},
|
|
181
|
+
frameborder: {
|
|
182
|
+
default: this.options.frameborder ? 1 : 0,
|
|
183
|
+
parseHTML: () => this.options.frameborder ? 1 : 0
|
|
184
|
+
},
|
|
185
|
+
allowfullscreen: {
|
|
186
|
+
default: this.options.allowFullscreen,
|
|
187
|
+
parseHTML: () => this.options.allowFullscreen
|
|
188
|
+
},
|
|
189
|
+
align: {
|
|
190
|
+
default: "center",
|
|
191
|
+
// Default alignment
|
|
192
|
+
renderHTML: ({ align: e }) => ({
|
|
193
|
+
align: e
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
parseHTML() {
|
|
199
|
+
return [
|
|
200
|
+
{
|
|
201
|
+
tag: "div[data-video] iframe"
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
},
|
|
205
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
206
|
+
const { width: t = "100%", align: o = "center" } = e ?? {}, n = {
|
|
207
|
+
...e,
|
|
208
|
+
width: "100%",
|
|
209
|
+
height: "100%"
|
|
210
|
+
}, a = `position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`, c = `flex: 1;padding-bottom: ${9 / 16 * 100}%;`, h = ["div", { style: `display: flex; justify-content: ${o};` }, ["div", { style: a }, ["div", { style: c }], ["iframe", n]]];
|
|
211
|
+
return ["div", {
|
|
212
|
+
...this.options.HTMLAttributes,
|
|
213
|
+
class: "iframe-wrapper",
|
|
214
|
+
"data-video": ""
|
|
215
|
+
}, h];
|
|
216
|
+
},
|
|
217
|
+
addCommands() {
|
|
218
|
+
return {
|
|
219
|
+
setVideo: (e) => ({ commands: t }) => t.insertContent({
|
|
220
|
+
type: this.name,
|
|
221
|
+
attrs: e
|
|
222
|
+
}),
|
|
223
|
+
updateVideo: (e) => ({ commands: t }) => t.updateAttributes(this.name, e)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
export {
|
|
228
|
+
ne as R,
|
|
229
|
+
k as V,
|
|
230
|
+
J as c
|
|
231
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const I=require("./clsx-CXbNJWDD.cjs"),k=require("./index-bVGIXhRg.cjs"),h=require("./useButtonProps-CFu0GHzW.cjs"),o=require("react/jsx-runtime"),u=require("react"),S=require("./toggle-oFwBZC4x.cjs"),b=require("./dialog-B-jOQ5i3.cjs"),d=require("./tabs-DBqNpGAq.cjs"),M=require("./button-BmTP96NR.cjs"),R=require("./input-s0JD5kf2.cjs");function D(e,t){let r;try{r=new URL(e)}catch{return!1}return!(t!=null&&t.length)||t.length===1&&t[0]==="."?!0:t.some(n=>{if(n.includes("*")){const l=n.replace(/\./g,String.raw`\.`).replace(/\*/g,".*");return new RegExp(`^${l}$`).test(r.hostname)}return r.hostname.includes(n)})}function $(){const{t:e}=k.useLocale(),t=h.useEditorInstance(),r=h.useButtonProps(T.name),{icon:n,tooltip:l}=(r==null?void 0:r.componentProps)??{},{editorDisabled:c}=h.useToggleActive(),[p,x]=u.useState(""),w=u.useRef(null),[y,f]=u.useState(""),[V,m]=u.useState(!1),v=h.useExtension(T.name),i=u.useMemo(()=>(v==null?void 0:v.options)??{},[v]);async function C(s){var L;const a=(L=s==null?void 0:s.target)==null?void 0:L.files;if(!t||t.isDestroyed||a.length===0)return;const g=a[0];let j="";i.upload?j=await i.upload(g):j=URL.createObjectURL(g),t.chain().focus().setVideo({src:j,width:"100%"}).run(),m(!1)}function A(s){s.preventDefault(),s.stopPropagation(),p&&(t.chain().focus().setVideo({src:p,width:"100%"}).run(),m(!1),x(""))}function q(s){var a;s.preventDefault(),(a=w.current)==null||a.click()}return o.jsxs(b.Dialog,{onOpenChange:m,open:V,children:[o.jsx(b.DialogTrigger,{asChild:!0,children:o.jsx(S.ActionButton,{disabled:c,icon:n,tooltip:l,action:()=>{c||m(!0)}})}),o.jsxs(b.DialogContent,{children:[o.jsx(b.DialogTitle,{children:e("editor.video.dialog.title")}),o.jsxs(d.Tabs,{activationMode:"manual",defaultValue:(i==null?void 0:i.resourceVideo)==="both"||(i==null?void 0:i.resourceVideo)==="upload"?"upload":"link",children:[o.jsxs(d.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[((i==null?void 0:i.resourceVideo)==="both"||(i==null?void 0:i.resourceVideo)==="upload")&&o.jsx(d.TabsTrigger,{value:"upload",children:e("editor.video.dialog.tab.upload")}),((i==null?void 0:i.resourceVideo)==="both"||(i==null?void 0:i.resourceVideo)==="link")&&o.jsx(d.TabsTrigger,{value:"link",children:e("editor.video.dialog.link")})]}),o.jsxs(d.TabsContent,{value:"upload",children:[o.jsx("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:o.jsx(M.Button,{className:"richtext-mt-1 richtext-w-full",onClick:q,size:"sm",children:e("editor.video.dialog.tab.upload")})}),o.jsx("input",{accept:"video/*",multiple:!0,onChange:C,ref:w,type:"file",style:{display:"none"}})]}),o.jsxs(d.TabsContent,{value:"link",children:[o.jsx("div",{children:o.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[o.jsx(R.Input,{autoFocus:!0,placeholder:e("editor.video.dialog.placeholder"),required:!0,type:"url",value:p,onBlur:s=>{const a=s.target.value,g=i.videoProviders||["."];a&&!D(a,g)?f("Invalid video URL"):f("")},onChange:s=>{x(s.target.value)}}),o.jsx(M.Button,{onClick:A,type:"button",children:e("editor.video.dialog.button.apply")})]})}),y&&o.jsx("div",{className:"richtext-my-[5px] richtext-text-red-500",children:y})]})]})]})]})}function H(e){e=e.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/");const t=e.match(/^https:\/\/www\.youtube\.com\/shorts\/([a-zA-Z0-9_-]+)/);t&&(e=`https://www.youtube.com/embed/${t[1]}`);const r=e.match(/^https:\/\/vimeo\.com\/(\d+)(?:\/([a-zA-Z0-9]+))?/);if(r){const l=r[1],c=r[2];c?e=`https://player.vimeo.com/video/${l}?h=${c}`:e=`https://player.vimeo.com/video/${l}`}return/^https?:\/\/www.bilibili.com\/video\/.*/i.test(e)&&(e=e.replace(/\?.*$/,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),e.includes("drive.google.com")&&(e=e.replace("/view","/preview")),e}const T=I.Node3.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,resourceVideo:"both",width:k.VIDEO_SIZE["size-medium"],HTMLAttributes:{class:"iframe-wrapper"},button:({editor:e,t})=>{var r,n;return{componentProps:{action:()=>{},isActive:()=>e.isActive("video")||!1,disabled:!((n=(r=e.can()).setVideo)!=null&&n.call(r,{})),icon:"Video",tooltip:t("editor.video.tooltip"),videoProviders:["."],editor:e}}}}},addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?H(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:h.getCssUnitWithDefault(e)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},align:{default:"center",renderHTML:({align:e})=>({align:e})}}},parseHTML(){return[{tag:"div[data-video] iframe"}]},renderHTML({HTMLAttributes:e}){const{width:t="100%",align:r="center"}=e??{},n={...e,width:"100%",height:"100%"},l=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`,c=`flex: 1;padding-bottom: ${9/16*100}%;`,f=["div",{style:`display: flex; justify-content: ${r};`},["div",{style:l},["div",{style:c}],["iframe",n]]];return["div",{...this.options.HTMLAttributes,class:"iframe-wrapper","data-video":""},f]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}}});exports.RichTextVideo=$;exports.Video=T;exports.checkIsVideoUrl=D;
|
package/lib/Video.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./index-bVGIXhRg.cjs");const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./index-bVGIXhRg.cjs");require("./useButtonProps-CFu0GHzW.cjs");const e=require("./Video-BwrHx6B1.cjs");exports.RichTextVideo=e.RichTextVideo;exports.Video=e.Video;
|
package/lib/Video.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./clsx-
|
|
1
|
+
import "./clsx-m_C5j3RU.js";
|
|
2
2
|
import "./index-4Q5IhypJ.js";
|
|
3
|
-
import
|
|
3
|
+
import "./useButtonProps-BE10eHkG.js";
|
|
4
|
+
import { R as m, V as p } from "./Video-Bpd8W8l6.js";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
m as RichTextVideo,
|
|
7
|
+
p as Video
|
|
7
8
|
};
|