@remarkablejames/editor 0.0.6 → 0.0.7

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 (187) hide show
  1. package/README.md +1 -1
  2. package/lib/ActionMenuButton-D9o3Kwmv.cjs +1 -0
  3. package/lib/{ActionMenuButton-CpmEfz31.js → ActionMenuButton-nxV91Fqo.js} +10 -9
  4. package/lib/Attachment.cjs +19 -1
  5. package/lib/Attachment.js +270 -7
  6. package/lib/Blockquote.cjs +2 -2
  7. package/lib/Blockquote.js +12 -13
  8. package/lib/Bold.cjs +1 -1
  9. package/lib/Bold.js +10 -11
  10. package/lib/BulletList.cjs +1 -1
  11. package/lib/BulletList.js +8 -9
  12. package/lib/Callout.cjs +1 -1
  13. package/lib/Callout.js +45 -40
  14. package/lib/Clear.cjs +1 -1
  15. package/lib/Clear.js +14 -13
  16. package/lib/Code.cjs +1 -1
  17. package/lib/Code.js +5 -6
  18. package/lib/CodeBlock.cjs +1 -1
  19. package/lib/CodeBlock.js +33 -31
  20. package/lib/CodeView.cjs +1 -1
  21. package/lib/CodeView.js +8 -9
  22. package/lib/Color.cjs +1 -1
  23. package/lib/Color.js +19 -18
  24. package/lib/Column.cjs +1 -1
  25. package/lib/Column.js +8 -9
  26. package/lib/Drawer-Bh-y5bs8.cjs +2 -0
  27. package/lib/{Drawer-CayP4Ww4.js → Drawer-CF6Z_IA2.js} +36 -30
  28. package/lib/Drawer.cjs +1 -1
  29. package/lib/Drawer.js +3 -3
  30. package/lib/Emoji.cjs +1 -1
  31. package/lib/Emoji.js +18 -17
  32. package/lib/Excalidraw.cjs +1 -1
  33. package/lib/Excalidraw.js +37 -32
  34. package/lib/ExportPdf.cjs +3 -3
  35. package/lib/ExportPdf.js +13 -14
  36. package/lib/ExportWord.cjs +1 -1
  37. package/lib/ExportWord.js +6 -6
  38. package/lib/FontFamily.cjs +1 -1
  39. package/lib/FontFamily.js +6 -7
  40. package/lib/FontSize.cjs +1 -1
  41. package/lib/FontSize.js +14 -15
  42. package/lib/Heading.cjs +1 -1
  43. package/lib/Heading.js +28 -28
  44. package/lib/Highlight.cjs +1 -1
  45. package/lib/Highlight.js +23 -22
  46. package/lib/History.cjs +1 -1
  47. package/lib/History.js +11 -11
  48. package/lib/HorizontalRule.cjs +1 -1
  49. package/lib/HorizontalRule.js +9 -10
  50. package/lib/Icon-BvGyfX2j.js +15 -0
  51. package/lib/Icon-wjwoRc9F.cjs +1 -0
  52. package/lib/Iframe-BbfZKbPY.cjs +1 -0
  53. package/lib/{Iframe-C6Sb97KS.js → Iframe-Dfd3LI7b.js} +14 -11
  54. package/lib/Iframe.cjs +1 -1
  55. package/lib/Iframe.js +3 -3
  56. package/lib/Image.cjs +1 -1
  57. package/lib/Image.js +5 -4
  58. package/lib/ImageCropper-CY1ETEjC.cjs +10 -0
  59. package/lib/ImageCropper-DrSdjo9x.js +979 -0
  60. package/lib/ImageGif.cjs +1 -1
  61. package/lib/ImageGif.js +83 -80
  62. package/lib/ImportWord.cjs +1 -1
  63. package/lib/ImportWord.js +37 -35
  64. package/lib/{Indent-CcFe8py3.js → Indent-CDVF9DWN.js} +30 -31
  65. package/lib/Indent-Q1VuhSM2.cjs +1 -0
  66. package/lib/Indent.cjs +1 -1
  67. package/lib/Indent.js +2 -2
  68. package/lib/Italic.cjs +1 -1
  69. package/lib/Italic.js +11 -12
  70. package/lib/{Katex-Bp6AnIUF.js → Katex-DqhWWAA-.js} +22 -18
  71. package/lib/Katex-K1QU2SB2.cjs +4 -0
  72. package/lib/Katex.cjs +1 -1
  73. package/lib/Katex.js +2 -2
  74. package/lib/LineHeight.cjs +1 -1
  75. package/lib/LineHeight.js +20 -19
  76. package/lib/Link.cjs +1 -1
  77. package/lib/Link.js +2 -2
  78. package/lib/LinkEditBlock-CBYGLs3J.cjs +5 -0
  79. package/lib/{LinkEditBlock-BiHumIJR.js → LinkEditBlock-xP0pGVhB.js} +27 -22
  80. package/lib/Mention.js +3 -3
  81. package/lib/{Mermaid-Dlx0XTJj.js → Mermaid-BJ6ryVdY.js} +59 -55
  82. package/lib/Mermaid-D3_nLeOW.cjs +2 -0
  83. package/lib/Mermaid.cjs +1 -1
  84. package/lib/Mermaid.js +2 -2
  85. package/lib/MoreMark.cjs +1 -1
  86. package/lib/MoreMark.js +28 -26
  87. package/lib/OrderedList.cjs +1 -1
  88. package/lib/OrderedList.js +10 -11
  89. package/lib/PaywallSeparator.cjs +1 -1
  90. package/lib/PaywallSeparator.js +9 -9
  91. package/lib/SearchAndReplace.cjs +1 -1
  92. package/lib/SearchAndReplace.js +39 -34
  93. package/lib/SlashCommand.cjs +1 -1
  94. package/lib/SlashCommand.js +5 -5
  95. package/lib/SlashCommandNodeView-CUJrDQS7.cjs +1 -0
  96. package/lib/{SlashCommandNodeView-DzmsYaNc.js → SlashCommandNodeView-DS9FqMiY.js} +23 -21
  97. package/lib/Strike.cjs +1 -1
  98. package/lib/Strike.js +11 -12
  99. package/lib/Table-CV6pUoVf.cjs +5 -0
  100. package/lib/{Table-IH34r4jd.js → Table-CcG-JNtV.js} +46 -46
  101. package/lib/Table.cjs +1 -1
  102. package/lib/Table.js +1 -1
  103. package/lib/TaskList.cjs +1 -1
  104. package/lib/TaskList.js +11 -12
  105. package/lib/TextAlign.cjs +1 -1
  106. package/lib/TextAlign.js +27 -26
  107. package/lib/TextDirection.cjs +1 -1
  108. package/lib/TextDirection.js +19 -18
  109. package/lib/TextUnderline.cjs +1 -1
  110. package/lib/TextUnderline.js +8 -9
  111. package/lib/{Twitter-FVQKPaq6.js → Twitter-BIL3o833.js} +19 -15
  112. package/lib/Twitter-BfSTqPDh.cjs +1 -0
  113. package/lib/Twitter.cjs +1 -1
  114. package/lib/Twitter.js +2 -2
  115. package/lib/Video-DAKr90QL.js +231 -0
  116. package/lib/Video-HAinT0w6.cjs +1 -0
  117. package/lib/Video.cjs +1 -1
  118. package/lib/Video.js +5 -4
  119. package/lib/bubble.cjs +3 -3
  120. package/lib/bubble.js +112 -101
  121. package/lib/button-090-I3tp.js +35 -0
  122. package/lib/button-B4Sz2ZhW.cjs +1 -0
  123. package/lib/checkbox-BCPsu7yR.cjs +1 -0
  124. package/lib/checkbox-DiXWHAI0.js +29 -0
  125. package/lib/{clsx-BUPZHhq3.js → clsx-m_C5j3RU.js} +24 -24
  126. package/lib/components/RichTextProvider.d.ts +1 -1
  127. package/lib/dialog-C8J59d2J.cjs +1 -0
  128. package/lib/dialog-bDkDW-C_.js +95 -0
  129. package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
  130. package/lib/dom-dataset-CIEeltF6.js +47 -0
  131. package/lib/{dropdown-menu-Ce2TorkG.js → dropdown-menu-DWt_xj4h.js} +1 -1
  132. package/lib/{dropdown-menu-DirUyRAI.cjs → dropdown-menu-tUP872Zv.cjs} +1 -1
  133. package/lib/events.constant-Bke62qxm.cjs +1 -0
  134. package/lib/events.constant-CSWD3-ho.js +72 -0
  135. package/lib/file-i7e4nQY2.cjs +1 -0
  136. package/lib/file-jDdkhyj7.js +43 -0
  137. package/lib/{index-RkKGy5oa.js → index-B3Ijnbxs.js} +1 -1
  138. package/lib/index-BXh8X1ch.cjs +1 -0
  139. package/lib/{index-Dl3OjzmR.js → index-C1KQsOcg.js} +1 -1
  140. package/lib/{index-D4M4hrH4.js → index-C8FjP66D.js} +1 -1
  141. package/lib/index-jMN4V2hr.js +2763 -0
  142. package/lib/{index-DZj2z9_1.js → index-s3l5RdyW.js} +1 -1
  143. package/lib/index.cjs +4 -4
  144. package/lib/index.js +464 -149
  145. package/lib/input-C_J-pfTx.js +21 -0
  146. package/lib/input-DwLo4r7V.cjs +1 -0
  147. package/lib/isNumber-BTYSVlKo.cjs +1 -0
  148. package/lib/isNumber-WaBzl_0s.js +15 -0
  149. package/lib/label-BgIVynq3.cjs +1 -0
  150. package/lib/label-ClsOg9Hr.js +11 -0
  151. package/lib/{popover-BzJyaFvy.js → popover-BC7FRr8B.js} +1 -1
  152. package/lib/{popover-BdLwAlrM.cjs → popover-C3A6zzNV.cjs} +1 -1
  153. package/lib/{renderNodeView-dj6AaFSX.js → renderNodeView-C_hPIdEs.js} +2 -2
  154. package/lib/select-B8HIWDXf.cjs +1 -0
  155. package/lib/select-DSKqhVGR.js +120 -0
  156. package/lib/{separator-D-fyzbfx.js → separator-BJWSNjvr.js} +23 -22
  157. package/lib/separator-D6ruF682.cjs +1 -0
  158. package/lib/style.css +1 -1
  159. package/lib/tabs-D1J1iB7B.js +46 -0
  160. package/lib/tabs-IEbMQmNX.cjs +1 -0
  161. package/lib/textarea-Ch5w3PiI.js +20 -0
  162. package/lib/textarea-CtVdqwSM.cjs +1 -0
  163. package/lib/theme.cjs +1 -1
  164. package/lib/theme.js +18 -18
  165. package/lib/throttle-CRNq0z-O.js +249 -0
  166. package/lib/throttle-gTTvqDTW.cjs +1 -0
  167. package/lib/toggle-C9tcMm1r.cjs +1 -0
  168. package/lib/toggle-CaSwYCk4.js +89 -0
  169. package/lib/{updatePosition-C294Pixi.js → updatePosition-DvfTZHcH.js} +2 -2
  170. package/lib/use-toast-C6zPo25l.cjs +1 -0
  171. package/lib/use-toast-CEOqhXfx.js +97 -0
  172. package/lib/useButtonProps-D-ruygH7.js +165 -0
  173. package/lib/useButtonProps-D9ndBdmA.cjs +1 -0
  174. package/package.json +21 -32
  175. package/lib/ActionMenuButton-NfiUDE60.cjs +0 -1
  176. package/lib/Drawer-DlgdaO_B.cjs +0 -2
  177. package/lib/Iframe-CANdxSpV.cjs +0 -1
  178. package/lib/Indent-DuB2U6Cs.cjs +0 -1
  179. package/lib/Katex-DFU1unCm.cjs +0 -4
  180. package/lib/LinkEditBlock-C2zX0WVK.cjs +0 -5
  181. package/lib/Mermaid-B8lQSOGn.cjs +0 -2
  182. package/lib/SlashCommandNodeView-BfWNWGRr.cjs +0 -1
  183. package/lib/Table-BfM6ywrZ.cjs +0 -5
  184. package/lib/Twitter-axcoCgD7.cjs +0 -1
  185. package/lib/index-BynXHtjJ.cjs +0 -28
  186. package/lib/index-CnKgiZFQ.js +0 -5576
  187. package/lib/separator-CoQaQmFK.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-BGd2HiwP.js";
3
+ import { f as S, u as R, c as z, i as B, k as N } from "./useButtonProps-D-ruygH7.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-CaSwYCk4.js";
7
+ import { D as F, a as O, b as Z, c as _ } from "./dialog-bDkDW-C_.js";
8
+ import { T as q, a as W, b as L, c as M } from "./tabs-D1J1iB7B.js";
9
+ import { B as T } from "./button-090-I3tp.js";
10
+ import { I as G } from "./input-C_J-pfTx.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-DgOXAdKt.cjs"),h=require("./useButtonProps-D9ndBdmA.cjs"),o=require("react/jsx-runtime"),u=require("react"),S=require("./toggle-C9tcMm1r.cjs"),b=require("./dialog-C8J59d2J.cjs"),d=require("./tabs-IEbMQmNX.cjs"),M=require("./button-B4Sz2ZhW.cjs"),R=require("./input-DwLo4r7V.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-DgOXAdKt.cjs");const e=require("./index-BynXHtjJ.cjs");exports.RichTextVideo=e.RichTextVideo;exports.Video=e.Video;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./index-DgOXAdKt.cjs");require("./useButtonProps-D9ndBdmA.cjs");const e=require("./Video-HAinT0w6.cjs");exports.RichTextVideo=e.RichTextVideo;exports.Video=e.Video;
package/lib/Video.js CHANGED
@@ -1,7 +1,8 @@
1
- import "./clsx-BUPZHhq3.js";
1
+ import "./clsx-m_C5j3RU.js";
2
2
  import "./index-BGd2HiwP.js";
3
- import { a5 as r, a1 as t } from "./index-CnKgiZFQ.js";
3
+ import "./useButtonProps-D-ruygH7.js";
4
+ import { R as m, V as p } from "./Video-DAKr90QL.js";
4
5
  export {
5
- r as RichTextVideo,
6
- t as Video
6
+ m as RichTextVideo,
7
+ p as Video
7
8
  };