@remarkablejames/editor 0.0.2 → 0.0.4

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 (193) hide show
  1. package/lib/{ActionMenuButton-Bmn3RME4.js → ActionMenuButton-BUtJUsfO.js} +9 -10
  2. package/lib/ActionMenuButton-M55VtCZ5.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +166 -133
  5. package/lib/Blockquote.cjs +2 -2
  6. package/lib/Blockquote.js +13 -12
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +11 -10
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +9 -8
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +42 -46
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +13 -14
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +6 -5
  17. package/lib/CodeBlock.cjs +1 -1
  18. package/lib/CodeBlock.js +30 -31
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +9 -8
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +18 -19
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +9 -8
  25. package/lib/Drawer-CdQBnwUs.cjs +2 -0
  26. package/lib/{Drawer-DvGh9aXG.js → Drawer-mlmJ2nCT.js} +41 -47
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +3 -3
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +15 -16
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +24 -28
  33. package/lib/ExportPdf.cjs +3 -3
  34. package/lib/ExportPdf.js +14 -13
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +6 -6
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +8 -7
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +16 -15
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +27 -27
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +22 -23
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +11 -11
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +10 -9
  49. package/lib/Iframe-B_a_AoZc.cjs +1 -0
  50. package/lib/{Iframe-CnnvV6cK.js → Iframe-CYgR99Ny.js} +11 -13
  51. package/lib/Iframe.cjs +1 -1
  52. package/lib/Iframe.js +2 -2
  53. package/lib/Image.cjs +1 -1
  54. package/lib/Image.js +4 -5
  55. package/lib/ImageGif.cjs +1 -1
  56. package/lib/ImageGif.js +79 -82
  57. package/lib/ImportWord.cjs +1 -1
  58. package/lib/ImportWord.js +26 -27
  59. package/lib/Indent-BAcoFdaq.cjs +1 -0
  60. package/lib/{Indent-Bsj8gKvT.js → Indent-BMz2ILRl.js} +31 -30
  61. package/lib/Indent.cjs +1 -1
  62. package/lib/Indent.js +2 -2
  63. package/lib/Italic.cjs +1 -1
  64. package/lib/Italic.js +12 -11
  65. package/lib/{Katex-CilGTz7u.js → Katex-DOlb4iTP.js} +19 -22
  66. package/lib/Katex-bIhj82VV.cjs +4 -0
  67. package/lib/Katex.cjs +1 -1
  68. package/lib/Katex.js +2 -2
  69. package/lib/LineHeight.cjs +1 -1
  70. package/lib/LineHeight.js +19 -20
  71. package/lib/Link.cjs +1 -1
  72. package/lib/Link.js +2 -2
  73. package/lib/LinkEditBlock-Cqs5RxjV.cjs +5 -0
  74. package/lib/{LinkEditBlock-BD_WvA3r.js → LinkEditBlock-xnokk4G7.js} +19 -24
  75. package/lib/Mention.js +3 -3
  76. package/lib/{Mermaid-BrjU75Bs.js → Mermaid-Bs3pIGc6.js} +45 -48
  77. package/lib/Mermaid-DiOdgQv1.cjs +2 -0
  78. package/lib/Mermaid.cjs +1 -1
  79. package/lib/Mermaid.js +2 -2
  80. package/lib/MoreMark.cjs +1 -1
  81. package/lib/MoreMark.js +26 -28
  82. package/lib/OrderedList.cjs +1 -1
  83. package/lib/OrderedList.js +11 -10
  84. package/lib/SearchAndReplace.cjs +1 -1
  85. package/lib/SearchAndReplace.js +37 -42
  86. package/lib/SlashCommand.cjs +1 -1
  87. package/lib/SlashCommand.js +6 -6
  88. package/lib/SlashCommandNodeView-CLimjqhb.cjs +1 -0
  89. package/lib/{SlashCommandNodeView-COx5qZ2y.js → SlashCommandNodeView-CYcf7mVz.js} +67 -79
  90. package/lib/Strike.cjs +1 -1
  91. package/lib/Strike.js +12 -11
  92. package/lib/{Table-BlM8yMhr.js → Table-bz1Wcojf.js} +47 -47
  93. package/lib/Table-dlXTKKwJ.cjs +5 -0
  94. package/lib/Table.cjs +1 -1
  95. package/lib/Table.js +1 -1
  96. package/lib/TaskList.cjs +1 -1
  97. package/lib/TaskList.js +12 -11
  98. package/lib/TextAlign.cjs +1 -1
  99. package/lib/TextAlign.js +26 -27
  100. package/lib/TextDirection.cjs +1 -1
  101. package/lib/TextDirection.js +18 -19
  102. package/lib/TextUnderline.cjs +1 -1
  103. package/lib/TextUnderline.js +9 -8
  104. package/lib/{Twitter-BP8sYXX7.js → Twitter-CNTXzgt0.js} +18 -22
  105. package/lib/Twitter-DhEnGg6P.cjs +1 -0
  106. package/lib/Twitter.cjs +1 -1
  107. package/lib/Twitter.js +2 -2
  108. package/lib/Video.cjs +1 -1
  109. package/lib/Video.js +5 -6
  110. package/lib/bubble.cjs +3 -3
  111. package/lib/bubble.js +78 -87
  112. package/lib/{clsx-m_C5j3RU.js → clsx-CDyrfCnw.js} +24 -24
  113. package/lib/{dropdown-menu-C1hdPLCZ.js → dropdown-menu-BuSlU2uN.js} +1 -1
  114. package/lib/{dropdown-menu-CkHN04Mx.cjs → dropdown-menu-CfWNst4v.cjs} +1 -1
  115. package/lib/extensions/Attachment/Attachment.d.ts +22 -2
  116. package/lib/extensions/Image/Image.d.ts +11 -0
  117. package/lib/extensions/Image/components/ImageCropper.d.ts +1 -1
  118. package/lib/index-8B00E8e4.js +5055 -0
  119. package/lib/index-BrxL7y9p.cjs +1 -0
  120. package/lib/index-Bt9LiArC.cjs +10 -0
  121. package/lib/{index-B3Ijnbxs.js → index-C-tDsIKJ.js} +1 -1
  122. package/lib/{index-C1KQsOcg.js → index-C1WCZhyA.js} +1 -1
  123. package/lib/{index-C8FjP66D.js → index-CsSfYR30.js} +1 -1
  124. package/lib/{index-4Q5IhypJ.js → index-DZfkCNKr.js} +15 -9
  125. package/lib/{index-s3l5RdyW.js → index-DjDf4BK8.js} +1 -1
  126. package/lib/index.cjs +4 -4
  127. package/lib/index.js +147 -392
  128. package/lib/locale-bundle.cjs +1 -1
  129. package/lib/locale-bundle.js +1 -1
  130. package/lib/locales/en.d.ts +189 -188
  131. package/lib/locales/fi.d.ts +189 -188
  132. package/lib/locales/hu.d.ts +189 -188
  133. package/lib/locales/index.d.ts +1134 -1128
  134. package/lib/locales/pt-br.d.ts +189 -188
  135. package/lib/locales/vi.d.ts +189 -188
  136. package/lib/locales/zh-cn.d.ts +189 -188
  137. package/lib/{popover-B05Fd8lC.cjs → popover-51mwx3UY.cjs} +1 -1
  138. package/lib/{popover-CsSXh7w6.js → popover-DMPRgXD3.js} +1 -1
  139. package/lib/{renderNodeView-C_hPIdEs.js → renderNodeView-BJSrgyGj.js} +2 -2
  140. package/lib/{select-7ubC1NF0.cjs → select-B7v1Scb-.cjs} +1 -1
  141. package/lib/{select-B3-5wTqn.js → select-BxFDMaZi.js} +1 -1
  142. package/lib/{separator-CYCA8tSn.js → separator-CpqX9KQC.js} +12 -13
  143. package/lib/separator-kB9YUfeO.cjs +1 -0
  144. package/lib/style.css +1 -1
  145. package/lib/{textarea-1FhpmBkP.js → textarea-C5DsgzSy.js} +1 -1
  146. package/lib/{textarea-Bjhcpp76.cjs → textarea-bQSzjqg3.cjs} +1 -1
  147. package/lib/theme/theme.d.ts +1 -1
  148. package/lib/{updatePosition-DvfTZHcH.js → updatePosition-e90ZrFWW.js} +2 -2
  149. package/package.json +1 -1
  150. package/lib/ActionMenuButton-C5P0Kzrb.cjs +0 -1
  151. package/lib/Drawer-gz9U5ArC.cjs +0 -2
  152. package/lib/Icon-CKM0tYbW.js +0 -15
  153. package/lib/Icon-CQyFgXeo.cjs +0 -1
  154. package/lib/Iframe-Ds6gG2YO.cjs +0 -1
  155. package/lib/ImageCropper-BKhXlnXN.cjs +0 -1
  156. package/lib/ImageCropper-DUzu_9-6.js +0 -896
  157. package/lib/Indent-D_7HOYYd.cjs +0 -1
  158. package/lib/Katex-lL3bHXJd.cjs +0 -4
  159. package/lib/LinkEditBlock-D3HSHmsU.cjs +0 -5
  160. package/lib/Mermaid-BfeLPzoS.cjs +0 -2
  161. package/lib/SlashCommandNodeView-DD-nlhM-.cjs +0 -1
  162. package/lib/Table-C21AlUrh.cjs +0 -5
  163. package/lib/Twitter-D46MnvPr.cjs +0 -1
  164. package/lib/Video-Bpd8W8l6.js +0 -231
  165. package/lib/Video-BwrHx6B1.cjs +0 -1
  166. package/lib/button-BmTP96NR.cjs +0 -1
  167. package/lib/button-CDIxPURh.js +0 -35
  168. package/lib/checkbox-7sfSdzy9.js +0 -29
  169. package/lib/checkbox-DyVlLWHv.cjs +0 -1
  170. package/lib/dialog-B-jOQ5i3.cjs +0 -1
  171. package/lib/dialog-QWWUWOGP.js +0 -95
  172. package/lib/events.constant-Bh2uzJud.js +0 -71
  173. package/lib/events.constant-ELn21EzG.cjs +0 -1
  174. package/lib/file-BLas99n7.js +0 -43
  175. package/lib/file-i7e4nQY2.cjs +0 -1
  176. package/lib/index-CAiZY1nx.js +0 -2741
  177. package/lib/index-DWSAk_9a.cjs +0 -1
  178. package/lib/index-bVGIXhRg.cjs +0 -1
  179. package/lib/input-qvpuOf-3.js +0 -21
  180. package/lib/input-s0JD5kf2.cjs +0 -1
  181. package/lib/isNumber-BTYSVlKo.cjs +0 -1
  182. package/lib/isNumber-WaBzl_0s.js +0 -15
  183. package/lib/label-CFax-gzo.cjs +0 -1
  184. package/lib/label-DC37f2RQ.js +0 -11
  185. package/lib/separator-ncbdw4oq.cjs +0 -1
  186. package/lib/tabs-BeHxylKH.js +0 -46
  187. package/lib/tabs-DBqNpGAq.cjs +0 -1
  188. package/lib/throttle-CRNq0z-O.js +0 -249
  189. package/lib/throttle-gTTvqDTW.cjs +0 -1
  190. package/lib/toggle-DoJTBdvy.js +0 -89
  191. package/lib/toggle-oFwBZC4x.cjs +0 -1
  192. package/lib/useButtonProps-BE10eHkG.js +0 -165
  193. package/lib/useButtonProps-CFu0GHzW.cjs +0 -1
@@ -1,231 +0,0 @@
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
- };
@@ -1 +0,0 @@
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;
@@ -1 +0,0 @@
1
- "use strict";const s=require("react/jsx-runtime"),a=require("@radix-ui/react-slot"),c=require("./index-DWSAk_9a.cjs"),u=require("react");function d(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const f=d(u),l=c.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-1 disabled:richtext-pointer-events-none disabled:richtext-opacity-50",{variants:{variant:{default:"!richtext-bg-primary !richtext-text-primary-foreground hover:!richtext-bg-primary/90",destructive:"richtext-bg-destructive richtext-text-destructive-foreground hover:richtext-bg-destructive/90",outline:"richtext-border richtext-border-input richtext-bg-background richtext-text-foreground hover:richtext-bg-accent hover:richtext-text-accent-foreground",secondary:"richtext-bg-secondary richtext-text-secondary-foreground hover:richtext-bg-secondary/80",ghost:"hover:richtext-bg-accent hover:richtext-text-accent-foreground",link:"richtext-text-primary richtext-underline-offset-4 hover:richtext-underline"},size:{default:"richtext-h-10 richtext-px-4 richtext-py-2",sm:"richtext-h-9 richtext-rounded-md richtext-px-3",lg:"richtext-h-11 richtext-rounded-md richtext-px-8",icon:"richtext-size-10"}},defaultVariants:{variant:"default",size:"default"}}),n=f.forwardRef(({className:t,variant:r,size:e,asChild:i=!1,...o},x)=>{const h=i?a.Slot:"button";return s.jsx(h,{className:c.cn(l({variant:r,size:e,className:t})),ref:x,...o})});n.displayName="Button";exports.Button=n;
@@ -1,35 +0,0 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { Slot as x } from "@radix-ui/react-slot";
3
- import { c as h, a } from "./index-CAiZY1nx.js";
4
- import * as s from "react";
5
- const d = a(
6
- "richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-1 disabled:richtext-pointer-events-none disabled:richtext-opacity-50",
7
- {
8
- variants: {
9
- variant: {
10
- default: "!richtext-bg-primary !richtext-text-primary-foreground hover:!richtext-bg-primary/90",
11
- destructive: "richtext-bg-destructive richtext-text-destructive-foreground hover:richtext-bg-destructive/90",
12
- outline: "richtext-border richtext-border-input richtext-bg-background richtext-text-foreground hover:richtext-bg-accent hover:richtext-text-accent-foreground",
13
- secondary: "richtext-bg-secondary richtext-text-secondary-foreground hover:richtext-bg-secondary/80",
14
- ghost: "hover:richtext-bg-accent hover:richtext-text-accent-foreground",
15
- link: "richtext-text-primary richtext-underline-offset-4 hover:richtext-underline"
16
- },
17
- size: {
18
- default: "richtext-h-10 richtext-px-4 richtext-py-2",
19
- sm: "richtext-h-9 richtext-rounded-md richtext-px-3",
20
- lg: "richtext-h-11 richtext-rounded-md richtext-px-8",
21
- icon: "richtext-size-10"
22
- }
23
- },
24
- defaultVariants: {
25
- variant: "default",
26
- size: "default"
27
- }
28
- }
29
- ), u = s.forwardRef(
30
- ({ className: t, variant: e, size: r, asChild: i = !1, ...c }, o) => /* @__PURE__ */ n(i ? x : "button", { className: h(d({ variant: e, size: r, className: t })), ref: o, ...c })
31
- );
32
- u.displayName = "Button";
33
- export {
34
- u as B
35
- };
@@ -1,29 +0,0 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import * as e from "@radix-ui/react-checkbox";
3
- import { Check as h } from "lucide-react";
4
- import * as s from "react";
5
- import { c as r } from "./index-CAiZY1nx.js";
6
- const a = s.forwardRef(({ className: i, ...c }, o) => /* @__PURE__ */ t(
7
- e.Root,
8
- {
9
- ref: o,
10
- className: r(
11
- "!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-p-0 !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-1 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",
12
- i
13
- ),
14
- ...c,
15
- children: /* @__PURE__ */ t(
16
- e.Indicator,
17
- {
18
- className: r(
19
- "!richtext-flex !richtext-items-center !richtext-justify-center !richtext-p-0 !richtext-text-current"
20
- ),
21
- children: /* @__PURE__ */ t(h, { className: "!richtext-h-4 !richtext-w-4" })
22
- }
23
- )
24
- }
25
- ));
26
- a.displayName = e.Root.displayName;
27
- export {
28
- a as C
29
- };
@@ -1 +0,0 @@
1
- "use strict";const c=require("react/jsx-runtime"),h=require("@radix-ui/react-checkbox"),x=require("lucide-react"),u=require("react"),s=require("./index-DWSAk_9a.cjs");function n(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const i=n(h),d=n(u),a=d.forwardRef(({className:e,...r},t)=>c.jsx(i.Root,{ref:t,className:s.cn("!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-p-0 !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-1 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",e),...r,children:c.jsx(i.Indicator,{className:s.cn("!richtext-flex !richtext-items-center !richtext-justify-center !richtext-p-0 !richtext-text-current"),children:c.jsx(x.Check,{className:"!richtext-h-4 !richtext-w-4"})})}));a.displayName=i.Root.displayName;exports.Checkbox=a;
@@ -1 +0,0 @@
1
- "use strict";const a=require("react/jsx-runtime"),f=require("@radix-ui/react-dialog"),u=require("lucide-react"),m=require("react"),c=require("./index-DWSAk_9a.cjs");function n(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const r=n(f),s=n(m),p=r.Root,D=r.Trigger,y=r.Portal,x=s.forwardRef(({className:t,...e},i)=>a.jsx(r.Overlay,{ref:i,className:c.cn("richtext-fixed richtext-inset-0 richtext-z-50 richtext-bg-black/80 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0",t),...e}));x.displayName=r.Overlay.displayName;const l=s.forwardRef(({className:t,children:e,...i},o)=>a.jsxs(y,{"data-richtext-portal":!0,children:[a.jsx(x,{}),a.jsxs(r.Content,{"data-richtext-portal":!0,ref:o,className:c.cn("richtext-fixed richtext-left-[50%] richtext-top-[50%] richtext-z-50 richtext-grid richtext-w-full richtext-max-w-lg richtext-translate-x-[-50%] richtext-translate-y-[-50%] richtext-gap-4 richtext-border !richtext-border-border richtext-bg-background richtext-p-6 richtext-shadow-lg richtext-duration-200 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[state=closed]:richtext-slide-out-to-left-1/2 data-[state=closed]:richtext-slide-out-to-top-[48%] data-[state=open]:richtext-slide-in-from-left-1/2 data-[state=open]:richtext-slide-in-from-top-[48%] sm:richtext-rounded-lg",t),...i,children:[e,a.jsxs(r.Close,{className:"richtext-absolute richtext-right-4 richtext-top-4 richtext-rounded-sm richtext-opacity-70 richtext-ring-offset-background richtext-transition-opacity hover:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-1 disabled:richtext-pointer-events-none data-[state=open]:richtext-bg-accent data-[state=open]:richtext-text-muted-foreground",children:[a.jsx(u.X,{className:"richtext-size-4 richtext-text-accent-foreground"}),a.jsx("span",{className:"richtext-sr-only richtext-text-accent-foreground",children:"Close"})]})]})]}));l.displayName=r.Content.displayName;function d({className:t,...e}){return a.jsx("div",{className:c.cn("richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",t),...e})}d.displayName="DialogHeader";function h({className:t,...e}){return a.jsx("div",{className:c.cn("richtext-flex richtext-flex-col-reverse sm:richtext-flex-row sm:richtext-justify-end sm:richtext-space-x-2",t),...e})}h.displayName="DialogFooter";const g=s.forwardRef(({className:t,...e},i)=>a.jsx(r.Title,{ref:i,className:c.cn("richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight richtext-text-foreground",t),...e}));g.displayName=r.Title.displayName;const N=s.forwardRef(({className:t,...e},i)=>a.jsx(r.Description,{className:c.cn("richtext-text-sm richtext-text-muted-foreground",t),ref:i,...e}));N.displayName=r.Description.displayName;exports.Dialog=p;exports.DialogContent=l;exports.DialogFooter=h;exports.DialogHeader=d;exports.DialogTitle=g;exports.DialogTrigger=D;
@@ -1,95 +0,0 @@
1
- import { jsx as i, jsxs as s } from "react/jsx-runtime";
2
- import * as t from "@radix-ui/react-dialog";
3
- import { X as l } from "lucide-react";
4
- import * as o from "react";
5
- import { c } from "./index-CAiZY1nx.js";
6
- const D = t.Root, b = t.Trigger, d = t.Portal, x = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ i(
7
- t.Overlay,
8
- {
9
- ref: r,
10
- className: c(
11
- "richtext-fixed richtext-inset-0 richtext-z-50 richtext-bg-black/80 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0",
12
- e
13
- ),
14
- ...a
15
- }
16
- ));
17
- x.displayName = t.Overlay.displayName;
18
- const h = o.forwardRef(({ className: e, children: a, ...r }, n) => /* @__PURE__ */ s(d, { "data-richtext-portal": !0, children: [
19
- /* @__PURE__ */ i(x, {}),
20
- /* @__PURE__ */ s(
21
- t.Content,
22
- {
23
- "data-richtext-portal": !0,
24
- ref: n,
25
- className: c(
26
- "richtext-fixed richtext-left-[50%] richtext-top-[50%] richtext-z-50 richtext-grid richtext-w-full richtext-max-w-lg richtext-translate-x-[-50%] richtext-translate-y-[-50%] richtext-gap-4 richtext-border !richtext-border-border richtext-bg-background richtext-p-6 richtext-shadow-lg richtext-duration-200 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[state=closed]:richtext-slide-out-to-left-1/2 data-[state=closed]:richtext-slide-out-to-top-[48%] data-[state=open]:richtext-slide-in-from-left-1/2 data-[state=open]:richtext-slide-in-from-top-[48%] sm:richtext-rounded-lg",
27
- e
28
- ),
29
- ...r,
30
- children: [
31
- a,
32
- /* @__PURE__ */ s(t.Close, { className: "richtext-absolute richtext-right-4 richtext-top-4 richtext-rounded-sm richtext-opacity-70 richtext-ring-offset-background richtext-transition-opacity hover:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-1 disabled:richtext-pointer-events-none data-[state=open]:richtext-bg-accent data-[state=open]:richtext-text-muted-foreground", children: [
33
- /* @__PURE__ */ i(l, { className: "richtext-size-4 richtext-text-accent-foreground" }),
34
- /* @__PURE__ */ i("span", { className: "richtext-sr-only richtext-text-accent-foreground", children: "Close" })
35
- ] })
36
- ]
37
- }
38
- )
39
- ] }));
40
- h.displayName = t.Content.displayName;
41
- function m({ className: e, ...a }) {
42
- return /* @__PURE__ */ i(
43
- "div",
44
- {
45
- className: c(
46
- "richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",
47
- e
48
- ),
49
- ...a
50
- }
51
- );
52
- }
53
- m.displayName = "DialogHeader";
54
- function f({ className: e, ...a }) {
55
- return /* @__PURE__ */ i(
56
- "div",
57
- {
58
- className: c(
59
- "richtext-flex richtext-flex-col-reverse sm:richtext-flex-row sm:richtext-justify-end sm:richtext-space-x-2",
60
- e
61
- ),
62
- ...a
63
- }
64
- );
65
- }
66
- f.displayName = "DialogFooter";
67
- const p = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ i(
68
- t.Title,
69
- {
70
- ref: r,
71
- className: c(
72
- "richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight richtext-text-foreground",
73
- e
74
- ),
75
- ...a
76
- }
77
- ));
78
- p.displayName = t.Title.displayName;
79
- const g = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ i(
80
- t.Description,
81
- {
82
- className: c("richtext-text-sm richtext-text-muted-foreground", e),
83
- ref: r,
84
- ...a
85
- }
86
- ));
87
- g.displayName = t.Description.displayName;
88
- export {
89
- D,
90
- b as a,
91
- h as b,
92
- p as c,
93
- f as d,
94
- m as e
95
- };
@@ -1,71 +0,0 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import n from "react";
3
- function f(t) {
4
- return t = t || /* @__PURE__ */ new Map(), {
5
- /**
6
- * A Map of event names to registered handler functions.
7
- */
8
- all: t,
9
- /**
10
- * Register an event handler for the given type.
11
- * @param {string|symbol} type Type of event to listen for, or `'*'` for all events
12
- * @param {Function} handler Function to call in response to given event
13
- * @memberOf mitt
14
- */
15
- on(s, o) {
16
- const e = t.get(s);
17
- e ? e.push(o) : t.set(s, [o]);
18
- },
19
- /**
20
- * Remove an event handler for the given type.
21
- * If `handler` is omitted, all handlers of the given type are removed.
22
- * @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
23
- * @param {Function} [handler] Handler function to remove
24
- * @memberOf mitt
25
- */
26
- off(s, o) {
27
- const e = t.get(s);
28
- e && (o ? e.splice(e.indexOf(o) >>> 0, 1) : t.set(s, []));
29
- },
30
- /**
31
- * Invoke all handlers for the given type.
32
- * If present, `'*'` handlers are invoked after type-matched handlers.
33
- *
34
- * Note: Manually firing '*' handlers is not supported.
35
- *
36
- * @param {string|symbol} type The event type to invoke
37
- * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
38
- * @memberOf mitt
39
- */
40
- emit(s, o) {
41
- let e = t.get(s);
42
- e && e.slice().map((i) => {
43
- i(o);
44
- }), e = t.get("*"), e && e.slice().map((i) => {
45
- i(s, o);
46
- });
47
- }
48
- };
49
- }
50
- const c = f(), r = n.createContext(c), m = () => n.useContext(r);
51
- function D(t, s) {
52
- const o = m();
53
- n.useEffect(() => (s.map((e) => o.on(e, t)), () => {
54
- s.map((e) => o.off(e, t));
55
- }), [o, s, t]);
56
- }
57
- const a = c.emit;
58
- function p({ children: t }) {
59
- return /* @__PURE__ */ u(r.Provider, { value: c, children: t });
60
- }
61
- const L = {
62
- UPLOAD_IMAGE: (t) => `UPLOAD_IMAGE-${t}`,
63
- UPLOAD_VIDEO: (t) => `UPLOAD_VIDEO-${t}`,
64
- EXCALIDRAW: (t) => `EXCALIDRAW-${t}`
65
- };
66
- export {
67
- L as E,
68
- p as R,
69
- a as e,
70
- D as u
71
- };
@@ -1 +0,0 @@
1
- "use strict";const r=require("react/jsx-runtime"),o=require("react");function f(e){return e=e||new Map,{all:e,on(s,i){const t=e.get(s);t?t.push(i):e.set(s,[i])},off(s,i){const t=e.get(s);t&&(i?t.splice(t.indexOf(i)>>>0,1):e.set(s,[]))},emit(s,i){let t=e.get(s);t&&t.slice().map(n=>{n(i)}),t=e.get("*"),t&&t.slice().map(n=>{n(s,i)})}}}const c=f(),u=o.createContext(c),E=()=>o.useContext(u);function m(e,s){const i=E();o.useEffect(()=>(s.map(t=>i.on(t,e)),()=>{s.map(t=>i.off(t,e))}),[i,s,e])}const A=c.emit;function D({children:e}){return r.jsx(u.Provider,{value:c,children:e})}const L={UPLOAD_IMAGE:e=>`UPLOAD_IMAGE-${e}`,UPLOAD_VIDEO:e=>`UPLOAD_VIDEO-${e}`,EXCALIDRAW:e=>`EXCALIDRAW-${e}`};exports.EVENTS=L;exports.ReactBusProvider=D;exports.emit=A;exports.useListener=m;
@@ -1,43 +0,0 @@
1
- function o(t) {
2
- return t.replace(/^.*\/|\..+$/g, "");
3
- }
4
- function u(t) {
5
- return t.split(".").pop();
6
- }
7
- function c(t) {
8
- return t < 1024 ? `${t} Byte` : t < 1024 * 1024 ? `${(t / 1024).toFixed(2)} KB` : `${(t / 1024 / 1024).toFixed(2)} MB`;
9
- }
10
- function d(t) {
11
- return t ? t === "application/pdf" ? "pdf" : t.startsWith("application/") && [".document", "word"].some((r) => t.includes(r)) ? "word" : t.startsWith("application/") && ["presentation"].some((r) => t.includes(r)) ? "excel" : t.startsWith("application/") && ["sheet"].some((r) => t.includes(r)) ? "ppt" : t.startsWith("image") ? "image" : t.startsWith("audio") ? "audio" : t.startsWith("video") ? "video" : "file" : "file";
12
- }
13
- function l(t) {
14
- return new Promise((r) => {
15
- const n = new FileReader();
16
- n.addEventListener(
17
- "load",
18
- () => {
19
- r({
20
- alt: t.name,
21
- src: n.result
22
- });
23
- },
24
- !1
25
- ), n.readAsDataURL(t);
26
- });
27
- }
28
- function m(t, r) {
29
- const n = t.split(","), s = n[0].match(/:(.*?);/)[1], a = atob(n[n.length - 1]);
30
- let e = a.length;
31
- const i = new Uint8Array(e);
32
- for (; e--; )
33
- i[e] = a.charCodeAt(e);
34
- return new File([i], r, { type: s });
35
- }
36
- export {
37
- o as a,
38
- c as b,
39
- m as d,
40
- u as e,
41
- d as n,
42
- l as r
43
- };
@@ -1 +0,0 @@
1
- "use strict";function s(t){return t.replace(/^.*\/|\..+$/g,"")}function u(t){return t.split(".").pop()}function c(t){return t<1024?`${t} Byte`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/1024/1024).toFixed(2)} MB`}function l(t){return t?t==="application/pdf"?"pdf":t.startsWith("application/")&&[".document","word"].some(e=>t.includes(e))?"word":t.startsWith("application/")&&["presentation"].some(e=>t.includes(e))?"excel":t.startsWith("application/")&&["sheet"].some(e=>t.includes(e))?"ppt":t.startsWith("image")?"image":t.startsWith("audio")?"audio":t.startsWith("video")?"video":"file":"file"}function d(t){return new Promise(e=>{const r=new FileReader;r.addEventListener("load",()=>{e({alt:t.name,src:r.result})},!1),r.readAsDataURL(t)})}function m(t,e){const r=t.split(","),o=r[0].match(/:(.*?);/)[1],i=atob(r[r.length-1]);let n=i.length;const a=new Uint8Array(n);for(;n--;)a[n]=i.charCodeAt(n);return new File([a],e,{type:o})}exports.dataURLtoFile=m;exports.extractFileExtension=u;exports.extractFilename=s;exports.normalizeFileSize=c;exports.normalizeFileType=l;exports.readImageAsBase64=d;