@remarkablejames/editor 0.0.5 → 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.
- package/README.md +1 -1
- package/lib/ActionMenuButton-D9o3Kwmv.cjs +1 -0
- package/lib/{ActionMenuButton-DBZjUu-F.js → ActionMenuButton-nxV91Fqo.js} +10 -9
- package/lib/Attachment.cjs +19 -1
- package/lib/Attachment.js +270 -7
- 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 -1
- package/lib/CodeBlock.js +31 -30
- 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-Bh-y5bs8.cjs +2 -0
- package/lib/{Drawer-DTCwtJEs.js → Drawer-CF6Z_IA2.js} +24 -18
- 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 +33 -28
- 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-BvGyfX2j.js +15 -0
- package/lib/Icon-wjwoRc9F.cjs +1 -0
- package/lib/Iframe-BbfZKbPY.cjs +1 -0
- package/lib/{Iframe-D-UYBxiv.js → Iframe-Dfd3LI7b.js} +18 -15
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +5 -4
- package/lib/ImageCropper-CY1ETEjC.cjs +10 -0
- package/lib/ImageCropper-DrSdjo9x.js +979 -0
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +80 -77
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +28 -26
- package/lib/{Indent-Bvt-Qwar.js → Indent-CDVF9DWN.js} +30 -31
- package/lib/Indent-Q1VuhSM2.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-CJDtvu-v.js → Katex-DqhWWAA-.js} +22 -19
- package/lib/Katex-K1QU2SB2.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-CBYGLs3J.cjs +5 -0
- package/lib/{LinkEditBlock-Cdqwj_NU.js → LinkEditBlock-xP0pGVhB.js} +24 -19
- package/lib/Mention.js +3 -3
- package/lib/{Mermaid-CnMYVX1P.js → Mermaid-BJ6ryVdY.js} +48 -45
- package/lib/Mermaid-D3_nLeOW.cjs +2 -0
- 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/PaywallSeparator.cjs +1 -0
- package/lib/PaywallSeparator.js +140 -0
- 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-CUJrDQS7.cjs +1 -0
- package/lib/{SlashCommandNodeView-DcoLvt_6.js → SlashCommandNodeView-DS9FqMiY.js} +80 -62
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +11 -12
- package/lib/Table-CV6pUoVf.cjs +5 -0
- package/lib/{Table-Cu12PvQ_.js → Table-CcG-JNtV.js} +46 -46
- 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-CrX4XY1j.js → Twitter-BIL3o833.js} +22 -18
- package/lib/Twitter-BfSTqPDh.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video-DAKr90QL.js +231 -0
- package/lib/Video-HAinT0w6.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 +86 -77
- package/lib/button-090-I3tp.js +35 -0
- package/lib/button-B4Sz2ZhW.cjs +1 -0
- package/lib/checkbox-BCPsu7yR.cjs +1 -0
- package/lib/checkbox-DiXWHAI0.js +29 -0
- package/lib/{clsx-BUPZHhq3.js → clsx-m_C5j3RU.js} +24 -24
- package/lib/components/RichTextProvider.d.ts +1 -1
- package/lib/dialog-C8J59d2J.cjs +1 -0
- package/lib/dialog-bDkDW-C_.js +95 -0
- package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
- package/lib/dom-dataset-CIEeltF6.js +47 -0
- package/lib/{dropdown-menu-CVwXaR3Z.js → dropdown-menu-DWt_xj4h.js} +1 -1
- package/lib/{dropdown-menu-XIrQk3jr.cjs → dropdown-menu-tUP872Zv.cjs} +1 -1
- package/lib/events.constant-Bke62qxm.cjs +1 -0
- package/lib/events.constant-CSWD3-ho.js +72 -0
- package/lib/extensions/PaywallSeparator/PaywallSeparator.d.ts +35 -0
- package/lib/extensions/PaywallSeparator/components/PaywallIcon.d.ts +2 -0
- package/lib/extensions/PaywallSeparator/components/PaywallSeparatorView.d.ts +17 -0
- package/lib/extensions/PaywallSeparator/components/RichTextPaywallSeparator.d.ts +1 -0
- package/lib/extensions/PaywallSeparator/components/index.d.ts +2 -0
- package/lib/extensions/PaywallSeparator/index.d.ts +1 -0
- package/lib/file-i7e4nQY2.cjs +1 -0
- package/lib/file-jDdkhyj7.js +43 -0
- package/lib/{index-RkKGy5oa.js → index-B3Ijnbxs.js} +1 -1
- package/lib/index-BXh8X1ch.cjs +1 -0
- package/lib/{index-Dl3OjzmR.js → index-C1KQsOcg.js} +1 -1
- package/lib/{index-D4M4hrH4.js → index-C8FjP66D.js} +1 -1
- package/lib/index-jMN4V2hr.js +2763 -0
- package/lib/{index-DZj2z9_1.js → index-s3l5RdyW.js} +1 -1
- package/lib/index.cjs +4 -4
- package/lib/index.js +464 -149
- package/lib/input-C_J-pfTx.js +21 -0
- package/lib/input-DwLo4r7V.cjs +1 -0
- package/lib/isNumber-BTYSVlKo.cjs +1 -0
- package/lib/isNumber-WaBzl_0s.js +15 -0
- package/lib/label-BgIVynq3.cjs +1 -0
- package/lib/label-ClsOg9Hr.js +11 -0
- package/lib/{popover-DDT8YRht.js → popover-BC7FRr8B.js} +1 -1
- package/lib/{popover-0syCfWYi.cjs → popover-C3A6zzNV.cjs} +1 -1
- package/lib/{renderNodeView-dj6AaFSX.js → renderNodeView-C_hPIdEs.js} +2 -2
- package/lib/{select-DTNz0ZeE.cjs → select-B8HIWDXf.cjs} +1 -1
- package/lib/{select-D9wQw2qB.js → select-DSKqhVGR.js} +1 -1
- package/lib/{separator-DRGTEiX4.js → separator-BJWSNjvr.js} +13 -12
- package/lib/separator-D6ruF682.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/tabs-D1J1iB7B.js +46 -0
- package/lib/tabs-IEbMQmNX.cjs +1 -0
- package/lib/{textarea-DfVzbMr5.js → textarea-Ch5w3PiI.js} +1 -1
- package/lib/{textarea-DpkwluT0.cjs → textarea-CtVdqwSM.cjs} +1 -1
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +18 -18
- package/lib/throttle-CRNq0z-O.js +249 -0
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-C9tcMm1r.cjs +1 -0
- package/lib/toggle-CaSwYCk4.js +89 -0
- package/lib/types.d.ts +5 -5
- package/lib/{updatePosition-C294Pixi.js → updatePosition-DvfTZHcH.js} +2 -2
- package/lib/use-toast-C6zPo25l.cjs +1 -0
- package/lib/use-toast-CEOqhXfx.js +97 -0
- package/lib/useButtonProps-D-ruygH7.js +165 -0
- package/lib/useButtonProps-D9ndBdmA.cjs +1 -0
- package/package.json +34 -32
- package/lib/ActionMenuButton-C6jGtl3k.cjs +0 -1
- package/lib/Drawer-B031ezmA.cjs +0 -2
- package/lib/Iframe-BUK2pkOL.cjs +0 -1
- package/lib/Indent-_y6N8MIQ.cjs +0 -1
- package/lib/Katex-bJXkt-VP.cjs +0 -4
- package/lib/LinkEditBlock-ewTApx0K.cjs +0 -5
- package/lib/Mermaid-Dwz9o-yM.cjs +0 -2
- package/lib/SlashCommandNodeView-BMgQJ4xT.cjs +0 -1
- package/lib/Table-B8CHl8jK.cjs +0 -5
- package/lib/Twitter-6HYP_upt.cjs +0 -1
- package/lib/index-B0d-u29p.js +0 -5425
- package/lib/index-De9MZVWQ.cjs +0 -28
- package/lib/separator-D8lOAf8f.cjs +0 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { h as v, j as x, N as k, k as y, n as S, m as I } from "./clsx-
|
|
1
|
+
import { h as v, j as x, N as k, k as y, n as S, m as I } from "./clsx-m_C5j3RU.js";
|
|
2
2
|
import { jsxs as f, jsx as d, Fragment as P } from "react/jsx-runtime";
|
|
3
3
|
import { Resizable as M } from "re-resizable";
|
|
4
4
|
import { useState as R, useCallback as N } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import "./
|
|
5
|
+
import { g as l } from "./dom-dataset-CIEeltF6.js";
|
|
6
|
+
import { A as j } from "./toggle-CaSwYCk4.js";
|
|
7
|
+
import { l as U, u as q, c as A } from "./useButtonProps-D-ruygH7.js";
|
|
8
|
+
import { I as L } from "./input-C_J-pfTx.js";
|
|
9
|
+
import { B as D } from "./button-090-I3tp.js";
|
|
7
10
|
const m = {
|
|
8
11
|
youtube: {
|
|
9
12
|
example: "https://www.youtube.com/watch?v=I4sMhHbHYXM",
|
|
@@ -167,10 +170,10 @@ function X(e) {
|
|
|
167
170
|
function J(e, t) {
|
|
168
171
|
return t.src = `${t.matchedUrl}?background=white&banner=show&embedded=true`, t.validId = !0, t.originalLink = e, t;
|
|
169
172
|
}
|
|
170
|
-
function
|
|
173
|
+
function W(e, t) {
|
|
171
174
|
return t.src = `${t.matchedUrl}`, t.validId = !0, t.originalLink = e, t;
|
|
172
175
|
}
|
|
173
|
-
function
|
|
176
|
+
function F(e, t, i) {
|
|
174
177
|
if (e === "googlemaps")
|
|
175
178
|
return i.validLink = !0, i.matchedUrl = t, i;
|
|
176
179
|
const n = m[e].linkRule;
|
|
@@ -195,7 +198,7 @@ function Z(e) {
|
|
|
195
198
|
src: ""
|
|
196
199
|
};
|
|
197
200
|
const i = G(e);
|
|
198
|
-
if (t =
|
|
201
|
+
if (t = F(i, e, t), !t.validLink)
|
|
199
202
|
return t;
|
|
200
203
|
switch (i) {
|
|
201
204
|
case "youtube":
|
|
@@ -227,7 +230,7 @@ function Z(e) {
|
|
|
227
230
|
case "jinshuju":
|
|
228
231
|
return J(e, t);
|
|
229
232
|
case "iframe":
|
|
230
|
-
return
|
|
233
|
+
return W(e, t);
|
|
231
234
|
default:
|
|
232
235
|
return e;
|
|
233
236
|
}
|
|
@@ -237,7 +240,7 @@ const Q = "_wrap_5y04w_1", ee = "_innerWrap_5y04w_15", w = {
|
|
|
237
240
|
innerWrap: ee
|
|
238
241
|
};
|
|
239
242
|
function te({ editor: e, node: t, updateAttributes: i }) {
|
|
240
|
-
const r =
|
|
243
|
+
const r = U(), { src: n, width: c, height: o } = t.attrs, [a, p] = R("");
|
|
241
244
|
function u() {
|
|
242
245
|
if (!a)
|
|
243
246
|
return;
|
|
@@ -255,7 +258,7 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
255
258
|
return /* @__PURE__ */ f(v, { children: [
|
|
256
259
|
!n && /* @__PURE__ */ f("div", { className: "richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]", children: [
|
|
257
260
|
/* @__PURE__ */ d(
|
|
258
|
-
|
|
261
|
+
L,
|
|
259
262
|
{
|
|
260
263
|
autoFocus: !0,
|
|
261
264
|
className: "richtext-flex-1",
|
|
@@ -265,7 +268,7 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
265
268
|
value: a
|
|
266
269
|
}
|
|
267
270
|
),
|
|
268
|
-
/* @__PURE__ */ d(
|
|
271
|
+
/* @__PURE__ */ d(D, { className: "richtext-w-[60px]", onClick: u, children: "OK" })
|
|
269
272
|
] }),
|
|
270
273
|
n && /* @__PURE__ */ d(
|
|
271
274
|
M,
|
|
@@ -292,19 +295,19 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
292
295
|
)
|
|
293
296
|
] });
|
|
294
297
|
}
|
|
295
|
-
function
|
|
296
|
-
const e =
|
|
298
|
+
function le() {
|
|
299
|
+
const e = q(b.name), {
|
|
297
300
|
icon: t = void 0,
|
|
298
301
|
tooltip: i = void 0,
|
|
299
302
|
shortcutKeys: r = void 0,
|
|
300
303
|
tooltipOptions: n = {},
|
|
301
304
|
action: c = void 0,
|
|
302
305
|
isActive: o = void 0
|
|
303
|
-
} = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a, update: p } =
|
|
306
|
+
} = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a, update: p } = A(o), u = () => {
|
|
304
307
|
a || c && (c(), p());
|
|
305
308
|
};
|
|
306
309
|
return e ? /* @__PURE__ */ d(
|
|
307
|
-
|
|
310
|
+
j,
|
|
308
311
|
{
|
|
309
312
|
action: u,
|
|
310
313
|
disabled: a,
|
|
@@ -410,6 +413,6 @@ const b = /* @__PURE__ */ k.create({
|
|
|
410
413
|
});
|
|
411
414
|
export {
|
|
412
415
|
b as I,
|
|
413
|
-
|
|
416
|
+
le as R,
|
|
414
417
|
Z as g
|
|
415
418
|
};
|
package/lib/Iframe.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-BbfZKbPY.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
|
package/lib/Iframe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./clsx-
|
|
2
|
-
import { I as o, R as t } from "./Iframe-
|
|
3
|
-
import "./
|
|
1
|
+
import "./clsx-m_C5j3RU.js";
|
|
2
|
+
import { I as o, R as t } from "./Iframe-Dfd3LI7b.js";
|
|
3
|
+
import "./dom-dataset-CIEeltF6.js";
|
|
4
4
|
export {
|
|
5
5
|
o as Iframe,
|
|
6
6
|
t as RichTextIframe
|
package/lib/Image.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./throttle-gTTvqDTW.cjs");const e=require("./ImageCropper-CY1ETEjC.cjs");exports.Image=e.Image;exports.RichTextImage=e.RichTextImage;
|
package/lib/Image.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "./clsx-
|
|
2
|
-
import
|
|
1
|
+
import "./clsx-m_C5j3RU.js";
|
|
2
|
+
import "./throttle-CRNq0z-O.js";
|
|
3
|
+
import { I as r, R as t } from "./ImageCropper-DrSdjo9x.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
r as Image,
|
|
6
|
+
t as RichTextImage
|
|
6
7
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),u=require("react"),re=require("react-image-crop"),P=require("./button-B4Sz2ZhW.cjs"),z=require("./dialog-C8J59d2J.cjs"),W=require("./clsx-CXbNJWDD.cjs"),Z=require("./throttle-gTTvqDTW.cjs"),O=require("./index-DgOXAdKt.cjs"),G=require("./isNumber-BTYSVlKo.cjs"),se=require("./toggle-C9tcMm1r.cjs"),B=require("./useButtonProps-D9ndBdmA.cjs"),Q=require("./file-i7e4nQY2.cjs"),V=require("./Icon-wjwoRc9F.cjs"),ne=require("./use-toast-C6zPo25l.cjs"),q=require("./tabs-IEbMQmNX.cjs"),le=require("./checkbox-BCPsu7yR.cjs"),ee=require("./label-BgIVynq3.cjs"),te=require("./input-DwLo4r7V.cjs"),X={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function oe({src:e,style:t}){return n.jsxs("div",{style:{position:"relative",display:"inline-block",overflow:"hidden",borderRadius:8,background:"hsl(var(--muted, 220 14% 96%))",minHeight:120,minWidth:180,...t},children:[e&&n.jsx("img",{src:e,alt:"","aria-hidden":!0,style:{display:"block",width:"100%",height:"100%",objectFit:"cover",filter:"blur(20px) saturate(0.5)",transform:"scale(1.1)",opacity:.5}}),n.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(110deg, transparent 30%, hsl(var(--muted-foreground, 220 9% 46%) / 0.08) 50%, transparent 70%)",animation:"richtext-skeleton-shimmer 1.8s ease-in-out infinite"}}),n.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,pointerEvents:"none"},children:[n.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"hsl(var(--muted-foreground, 220 9% 46%))",animation:"richtext-skeleton-spin 1s linear infinite"},children:n.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),n.jsx("span",{style:{fontSize:12,fontWeight:500,color:"hsl(var(--muted-foreground, 220 9% 46%))",userSelect:"none"},children:"Uploading…"})]}),n.jsx("style",{children:`
|
|
2
|
+
@keyframes richtext-skeleton-shimmer {
|
|
3
|
+
0% { transform: translateX(-100%); }
|
|
4
|
+
100% { transform: translateX(100%); }
|
|
5
|
+
}
|
|
6
|
+
@keyframes richtext-skeleton-spin {
|
|
7
|
+
from { transform: rotate(0deg); }
|
|
8
|
+
to { transform: rotate(360deg); }
|
|
9
|
+
}
|
|
10
|
+
`})]})}function ce(e){var H,_,D,R;const[t,l]=u.useState({width:O.IMAGE_MAX_SIZE,height:O.IMAGE_MAX_SIZE}),[a,r]=u.useState({width:0,height:0}),[d]=u.useState([X.TOP_LEFT,X.TOP_RIGHT,X.BOTTOM_LEFT,X.BOTTOM_RIGHT]),[o,v]=u.useState(!1),[c,p]=u.useState({x:0,y:0,w:0,h:0,dir:""}),{align:I,inline:w,uploading:M}=(H=e==null?void 0:e.node)==null?void 0:H.attrs,m=w&&(I==="left"||I==="right"),f=u.useMemo(()=>{var K;const{src:i,alt:s,width:b,height:T,flipX:C,flipY:g}=(K=e==null?void 0:e.node)==null?void 0:K.attrs,N=G.isNumber(b)?`${b}px`:b,E=G.isNumber(T)?`${T}px`:T,Y=[];C&&Y.push("rotateX(180deg)"),g&&Y.push("rotateY(180deg)");const ae=Y.join(" ");return{src:i||void 0,alt:s||void 0,style:{width:N||void 0,height:E||void 0,transform:ae||"none",...m?{float:I}:{}}}},[(_=e==null?void 0:e.node)==null?void 0:_.attrs]),A=u.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function S(i){r({width:i.target.width,height:i.target.height})}function j(){const{editor:i,getPos:s}=e;i.commands.setNodeSelection(s())}const h=u.useCallback(Z.throttle(()=>{const{editor:i}=e,{width:s}=getComputedStyle(i.view.dom);l(b=>({...b,width:Number.parseInt(s,10)}))},O.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function F(i,s){i.preventDefault(),i.stopPropagation();const b=a.width,T=a.height,C=b/T;let g=Number(e.node.attrs.width),N=Number(e.node.attrs.height);const E=t.width;g&&!N?(g=g>E?E:g,N=Math.round(g/C)):N&&!g?(g=Math.round(N*C),g=g>E?E:g):!g&&!N?(g=b>E?E:b,N=Math.round(g/C)):g=g>E?E:g,v(!0),p({x:i.clientX,y:i.clientY,w:g,h:N,dir:s})}const y=u.useCallback(Z.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!o)return;const{x:s,w:b,dir:T}=c,C=(i.clientX-s)*(/l/.test(T)?-1:1),g=G.clamp(b+C,O.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:g,height:null})},O.IMAGE_THROTTLE_WAIT_TIME),[o,c,t,e.updateAttributes]),U=u.useCallback(i=>{i.preventDefault(),i.stopPropagation(),o&&(p({x:0,y:0,w:0,h:0,dir:""}),v(!1),j())},[o,j]),x=u.useCallback(()=>{document==null||document.addEventListener("mousemove",y,!0),document==null||document.addEventListener("mouseup",U,!0)},[y,U]),L=u.useCallback(()=>{document==null||document.removeEventListener("mousemove",y,!0),document==null||document.removeEventListener("mouseup",U,!0)},[y,U]);u.useEffect(()=>(o?x():L(),()=>{L()}),[o,x,L]);const k=u.useMemo(()=>new ResizeObserver(()=>h()),[h]);return u.useEffect(()=>(k.observe(e.editor.view.dom),()=>{k.disconnect()}),[e.editor.view.dom,k]),M?n.jsx(W.NodeViewWrapper,{as:w?"span":"div",className:"image-view",style:{float:m?I:void 0,margin:m?I==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:w?"inline":"block",textAlign:m?void 0:I,width:((D=f.style)==null?void 0:D.width)??"auto",...m?{}:A},children:n.jsx("div",{style:A,className:"image-view__body",children:n.jsx(oe,{src:f.src,style:f.style})})}):n.jsx(W.NodeViewWrapper,{as:w?"span":"div",className:"image-view",style:{float:m?I:void 0,margin:m?I==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:w?"inline":"block",textAlign:m?void 0:I,width:((R=f.style)==null?void 0:R.width)??"auto",...m?{}:A},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:A,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${o?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:j,onLoad:S,src:f.src,style:f.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||o)&&n.jsx("div",{className:"image-resizer",children:d==null?void 0:d.map(i=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:s=>F(s,i)},`image-dir-${i}`))})]})})}function ue(e,t){const l=e.type,a=e.name.toLowerCase(),r=a.split(".").pop();if(!r)return!1;const o=l||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[r];return t.some(v=>{if(v.startsWith("."))return a.endsWith(v);if(v.endsWith("/*")){const c=v.split("/")[0];return o==null?void 0:o.startsWith(c+"/")}return o===v})}function J(e,t){const{acceptMimes:l,maxSize:a,t:r,toast:d}=t,o=[];return(Array.isArray(e)?e:Object.values(e)).forEach(c=>{if(!ue(c,l)){t.onError?t.onError({type:"type",message:r("editor.upload.fileTypeNotSupported",{fileName:c.name}),file:c}):d({variant:"destructive",title:r("editor.upload.fileTypeNotSupported",{fileName:c.name})});return}if(c.size>a){const p=(a/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:r("editor.upload.fileSizeTooBig",{fileName:c.name,size:p}),file:c}):d({variant:"destructive",title:r("editor.upload.fileSizeTooBig",{fileName:c.name,size:p})});return}o.push(c)}),o}function de(){const{t:e}=O.useLocale(),{toast:t}=ne.useToast(),l=B.useEditorInstance(),a=B.useButtonProps($.name),{icon:r,tooltip:d}=(a==null?void 0:a.componentProps)??{},{editorDisabled:o}=B.useToggleActive(),[v,c]=u.useState(!1),p=B.useExtension($.name),[I,w]=u.useState(""),[M,m]=u.useState(""),f=u.useRef(null),A=(p==null?void 0:p.options.defaultInline)||!1,[S,j]=u.useState(A),h=u.useMemo(()=>p==null?void 0:p.options,[p]);function F(x){var D;const L=(D=x==null?void 0:x.target)==null?void 0:D.files;if(!l||l.isDestroyed||L.length===0){x.target.value="";return}const k=J(L,{acceptMimes:h==null?void 0:h.acceptMimes,maxSize:h==null?void 0:h.maxSize,t:e,toast:t,onError:h.onError});if(k.length<=0){x.target.value="";return}c(!1);const H=M,_=S;if(m(""),j(A),h.upload){const R=h!=null&&h.multiple?k:[k[0]];for(const i of R)l.chain().focus().insertImagePlaceholder({file:i,inline:_,alt:H}).run()}else{const R=h!=null&&h.multiple?k:[k[0]];for(const i of R){const s=URL.createObjectURL(i);l.chain().focus().setImageInline({src:s,inline:_,alt:H}).run()}}x.target.value=""}function y(x){x.preventDefault(),x.stopPropagation(),l.chain().focus().setImageInline({src:I,inline:S,alt:M}).run(),c(!1),j(A),w(""),m("")}function U(x){var L;x.preventDefault(),(L=f.current)==null||L.click()}return a?n.jsxs(z.Dialog,{onOpenChange:c,open:v,children:[n.jsx(z.DialogTrigger,{asChild:!0,children:n.jsx(se.ActionButton,{disabled:o,icon:r,tooltip:d,action:()=>{o||c(!0)}})}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:e("editor.image.dialog.title")}),n.jsxs(q.Tabs,{activationMode:"manual",defaultValue:h.resourceImage==="both"||h.resourceImage==="upload"?"upload":"link",children:[h.resourceImage==="both"&&n.jsxs(q.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[n.jsx(q.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),n.jsx(q.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),n.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[n.jsx(le.Checkbox,{checked:S,onCheckedChange:x=>{j(x)}}),n.jsx(ee.Label,{children:e("editor.link.dialog.inline")})]}),h.enableAlt&&n.jsxs("div",{className:"richtext-my-[10px]",children:[n.jsx(ee.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),n.jsx(te.Input,{onChange:x=>m(x.target.value),required:!0,type:"text",value:M})]}),n.jsxs(q.TabsContent,{value:"upload",children:[n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[n.jsx(P.Button,{className:"richtext-mt-1 richtext-w-full",onClick:U,size:"sm",children:e("editor.image.dialog.tab.upload")}),n.jsx(ie,{alt:M,disabled:!1,editor:l,imageInline:S,onClose:()=>{m("")}})]}),n.jsx("input",{accept:h.acceptMimes.join(",")||"image/*",multiple:h.multiple,onChange:F,ref:f,style:{display:"none"},type:"file"})]}),n.jsx(q.TabsContent,{value:"link",children:n.jsx("form",{onSubmit:y,children:n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[n.jsx(te.Input,{autoFocus:!0,onChange:x=>w(x.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:I}),n.jsx(P.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):n.jsx(n.Fragment,{})}const he={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},$=Z.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...he,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:l,t:a})=>{var r,d;return{componentProps:{action:()=>!0,upload:l.options.upload,disabled:!((d=(r=t.can()).setImage)!=null&&d.call(r,{})),icon:"ImageUp",tooltip:a("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),uploading:{default:!1,parseHTML:()=>!1,renderHTML:()=>({})},imageId:{default:null,parseHTML:t=>t.getAttribute("data-image-id"),renderHTML:t=>t.imageId?{"data-image-id":t.imageId}:{}},flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const l=t.style.width||t.getAttribute("width")||null;return l?Number.parseInt(l,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return W.ReactNodeViewRenderer(ce)},addCommands(){var l;const e=this.name,t=this.options;return{...(l=this.parent)==null?void 0:l.call(this),setImageInline:a=>({commands:r})=>r.insertContent({type:e,attrs:{...a,imageId:a.imageId??null,inline:a.inline??t.defaultInline}}),insertImagePlaceholder:({file:a,inline:r,alt:d})=>({editor:o,commands:v})=>{const c=URL.createObjectURL(a);if(!v.insertContent({type:e,attrs:{src:c,alt:d??"",inline:r??t.defaultInline,uploading:!0,imageId:null}}))return!1;const I=t.upload;return I&&I(a).then(w=>{const{doc:M}=o.state;let m=null;M.descendants((f,A)=>{if(f.type.name===e&&f.attrs.uploading===!0&&f.attrs.src===c)return m=A,!1}),m!==null&&o.view.dispatch(o.state.tr.setNodeMarkup(m,void 0,{...o.state.doc.nodeAt(m).attrs,src:w.cdnUrl,imageId:w.imageId,uploading:!1})),URL.revokeObjectURL(c)}).catch(w=>{console.error("Image upload failed",w);const{doc:M}=o.state;let m=null;if(M.descendants((f,A)=>{if(f.type.name===e&&f.attrs.uploading===!0&&f.attrs.src===c)return m=A,!1}),m!==null){const f=o.state.doc.nodeAt(m);f&&o.view.dispatch(o.state.tr.delete(m,m+f.nodeSize))}URL.revokeObjectURL(c)}),!0},updateImage:a=>({commands:r})=>r.updateAttributes(this.name,a),setAlignImage:a=>({commands:r})=>r.updateAttributes(this.name,{align:a})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:l,align:a,inline:r}=e,d=r&&(a==="left"||a==="right"),o=t||l?`transform: rotateX(${t?"180":"0"}deg) rotateY(${l?"180":"0"}deg);`:"",v=d?"":`text-align: ${a};`,I=`${d?`float: ${a};`:""}${d?a==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${o}`;return[r?"span":"div",{style:v,class:"image"},["img",W.mergeAttributes({height:"auto",style:I},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var d;const t=e==null?void 0:e.parentElement,l=e==null?void 0:e.getAttribute("width"),a=(e==null?void 0:e.getAttribute("flipx"))||!1,r=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:l?Number.parseInt(l,10):null,align:(e==null?void 0:e.getAttribute("align"))||((d=t==null?void 0:t.style)==null?void 0:d.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:a==="true",flipY:r==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),l=t==null?void 0:t.getAttribute("width"),a=(t==null?void 0:t.getAttribute("flipx"))||!1,r=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:l?Number.parseInt(l,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:a==="true",flipY:r==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});function ie({editor:e,imageInline:t,onClose:l,disabled:a,alt:r}){var D,R;const{t:d}=O.useLocale(),{toast:o}=ne.useToast(),[v,c]=u.useState(!1),[p,I]=u.useState(!1),w=u.useRef(null),[M,m]=u.useState(),[f,A]=u.useState(""),S=u.useRef(null),[j,h]=u.useState({src:"",file:null}),F=B.useExtension($.name),y=u.useMemo(()=>(F==null?void 0:F.options)??{},[F]);function U(i){if(w.current&&i.width&&i.height){const s=x(w.current,i);A(s)}}function x(i,s){const b=document.createElement("canvas"),T=i.naturalWidth/i.width,C=i.naturalHeight/i.height;b.width=s.width*T,b.height=s.height*C;const g=b.getContext("2d");return g&&(g.imageSmoothingEnabled=!1,g.drawImage(i,s.x*T,s.y*C,s.width*T,s.height*C,0,0,s.width*T,s.height*C)),b.toDataURL("image/png",1)}const L=u.useCallback(()=>{var s;if(p)return;const i=Q.dataURLtoFile(f,((s=j==null?void 0:j.file)==null?void 0:s.name)||"image.png");if(c(!1),h({src:"",file:null}),_(),l(),y.upload)e.chain().focus().insertImagePlaceholder({file:i,inline:t,alt:r}).run();else{const b=URL.createObjectURL(i);e.chain().focus().setImageInline({src:b,inline:t,alt:r}).run()}},[f,e,t,p,l,(D=j==null?void 0:j.file)==null?void 0:D.name,y,r]);function k(i){var s;i.preventDefault(),(s=S.current)==null||s.click()}const H=async i=>{var g;const s=(g=i==null?void 0:i.target)==null?void 0:g.files;if(!e||e.isDestroyed||s.length===0){i.target.value="";return}const b=J(s,{acceptMimes:y==null?void 0:y.acceptMimes,maxSize:y==null?void 0:y.maxSize,t:d,toast:o,onError:y.onError});if(b.length<=0){i.target.value="";return}const T=b[0],C=await Q.readImageAsBase64(T);c(!0),h({src:C.src,file:T})},_=()=>{S.current&&(S.current.value="")};return n.jsxs(n.Fragment,{children:[n.jsx(P.Button,{className:"richtext-mt-1 richtext-w-full",disabled:a,onClick:k,size:"sm",children:d("editor.image.dialog.tab.uploadCrop")}),n.jsxs(z.Dialog,{open:v,onOpenChange:i=>{c(i),i||(h({src:"",file:null}),_())},children:[n.jsx(z.DialogTrigger,{}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:d("editor.image.dialog.tab.uploadCrop")}),n.jsx("div",{children:j.src&&n.jsx(re,{className:"richtext-w-full",crop:M,onChange:i=>m(i),onComplete:i=>U(i),children:n.jsx("img",{alt:"Crop me",ref:w,src:j.src})})}),n.jsxs(z.DialogFooter,{children:[n.jsxs(P.Button,{disabled:p,onClick:()=>{c(!1),h({src:"",file:null}),_()},children:[d("editor.imageUpload.cancel"),n.jsx(V.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),n.jsx(P.Button,{className:"richtext-w-fit",disabled:p||!M,onClick:L,children:p?n.jsxs(n.Fragment,{children:[d("editor.imageUpload.uploading"),n.jsx(V.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):n.jsxs(n.Fragment,{children:[d("editor.imageUpload.crop"),n.jsx(V.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),n.jsx("input",{accept:((R=y==null?void 0:y.acceptMimes)==null?void 0:R.join(","))||"image/*",multiple:!1,onChange:H,ref:S,style:{display:"none"},type:"file"})]})}exports.Image=$;exports.ImageCropper=ie;exports.RichTextImage=de;exports.validateFiles=J;
|