reactjs-tiptap-editor 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-CKTxYtl7.js → ActionMenuButton-BKqin6Kz.js} +17 -13
- package/lib/ActionMenuButton-CPPHERbq.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +24 -21
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +7 -5
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +11 -9
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +14 -12
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +11 -9
- package/lib/CodeBlock.cjs +22 -22
- package/lib/CodeBlock.js +102 -100
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +10 -8
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +20 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -5
- package/lib/{Drawer-Cfx115up.js → Drawer-DUPsBE0H.js} +10 -9
- package/lib/Drawer-fplzqNI6.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +11 -9
- package/lib/{Excalidraw-CO93Tsmb.js → Excalidraw-BEzpvRLx.js} +20 -19
- package/lib/Excalidraw-qjnQspLq.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +7 -5
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +7 -5
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -8
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +13 -12
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +25 -24
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +9 -7
- package/lib/History.cjs +1 -1
- package/lib/History.js +18 -15
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +7 -5
- package/lib/Icon-CiR8RqdQ.cjs +1 -0
- package/lib/Icon-ONE1AwKo.js +12 -0
- package/lib/{Iframe-DwhclppJ.js → Iframe-CBTnv2mk.js} +41 -39
- package/lib/Iframe-DsUNJ2n2.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +25 -23
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +53 -51
- package/lib/ImportWord.cjs +31 -31
- package/lib/ImportWord.js +8 -6
- package/lib/{Indent-BOsymiZ7.js → Indent-B00o0P0M.js} +26 -24
- package/lib/Indent-CaGP0qTp.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 +12 -10
- package/lib/Katex-XsfpKgJU.cjs +4 -0
- package/lib/{Katex-BYK-b9X2.js → Katex-x370CSXZ.js} +12 -10
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +10 -8
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DgrLUMsJ.js → LinkEditBlock-C_ipl3EA.js} +23 -21
- package/lib/{LinkEditBlock-4-iRXH7m.cjs → LinkEditBlock-xt88G5fb.cjs} +2 -2
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +18 -17
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -22
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -8
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +43 -41
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-BT5ystah.cjs +1 -0
- package/lib/{SlashCommandNodeView-BpNNU7Sm.js → SlashCommandNodeView-DX6axvLs.js} +75 -66
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +7 -5
- package/lib/Table-DSRSwtXx.cjs +9 -0
- package/lib/{Table-CT9R9Sdq.js → Table-DidusYID.js} +10 -8
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +15 -13
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +20 -17
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +20 -17
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -5
- package/lib/Twitter-CBuVBQM1.cjs +1 -0
- package/lib/{Twitter-mowilxRd.js → Twitter-D58T0Zt3.js} +51 -49
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +13 -11
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +403 -407
- package/lib/{button-CBO-WDXK.js → button-9_8t7ca7.js} +4 -3
- package/lib/button-Cs9TroWr.cjs +1 -0
- package/lib/{checkbox-DUcLSGZD.cjs → checkbox-BQRKTXXr.cjs} +1 -1
- package/lib/{checkbox-D1h32VWM.js → checkbox-DnkkV6qo.js} +1 -1
- package/lib/{index-BBNITgNi.cjs → clsx-CXbNJWDD.cjs} +13 -13
- package/lib/{index-sVScpCFG.js → clsx-DmuN0U_8.js} +228 -228
- package/lib/{dialog-DY868Uji.cjs → dialog-BS3zm-T9.cjs} +1 -1
- package/lib/{dialog-DSvgtlDI.js → dialog-DhayAPvV.js} +1 -1
- package/lib/{dropdown-menu-BripAeGB.cjs → dropdown-menu-CxwWX0yj.cjs} +1 -1
- package/lib/{dropdown-menu-B88Qn2KR.js → dropdown-menu-DQqKeZcx.js} +1 -1
- package/lib/events.constant-Dq21NPdV.cjs +1 -0
- package/lib/events.constant-do95b767.js +21 -0
- package/lib/{index-CApXPpjF.cjs → index-BCzvbrf5.cjs} +1 -1
- package/lib/{index-0OnGZkVF.js → index-BDX1uE62.js} +78 -312
- package/lib/index-CBFmXCcU.cjs +1 -0
- package/lib/{index-DmPwbBqm.js → index-CKmT9KAQ.js} +1 -1
- package/lib/index-CVFzP1Dc.cjs +1 -0
- package/lib/index-CX4pNJlH.cjs +1 -0
- package/lib/index-CjhjjJsN.cjs +1 -0
- package/lib/index-Cs6cp0Y6.cjs +1 -0
- package/lib/{index-9A6-kVBM.js → index-D1jd7elj.js} +1 -1
- package/lib/{index-BIqaogQg.js → index-D9JOHlso.js} +449 -1216
- package/lib/{index-DRHrDScg.js → index-DdEmgiAA.js} +1 -1
- package/lib/{index-DKt5wfAc.js → index-DvvwJvau.js} +23 -23
- package/lib/index-EAK64CCA.js +425 -0
- package/lib/{index--nUS7Y66.cjs → index-neeeY2o7.cjs} +3 -3
- package/lib/index.cjs +9 -2
- package/lib/index.js +142 -26
- package/lib/{input-BeD5GdMv.cjs → input-BJ7ihMq-.cjs} +1 -1
- package/lib/{input-Bx4uo4gO.js → input-YoheBL2D.js} +1 -1
- package/lib/{isNumber-Bv1Qhmw8.cjs → isNumber-BTYSVlKo.cjs} +1 -1
- package/lib/{isNumber-DF0fU3ob.js → isNumber-DmQXlKp3.js} +1 -1
- package/lib/label-C8PLcjFI.js +19 -0
- package/lib/label-Y7_hvqf2.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +6 -7
- package/lib/locales/index.d.ts +3 -4316
- package/lib/{popover-Csk538NC.cjs → popover-BiSrlM4j.cjs} +1 -1
- package/lib/{popover-BVX8otO9.js → popover-CWmTzHSy.js} +1 -1
- package/lib/react-BEoMZB61.cjs +1 -0
- package/lib/react-c9FSfB30.js +27 -0
- package/lib/separator-C-DKMYmg.js +329 -0
- package/lib/separator-CJ_adziN.cjs +1 -0
- package/lib/store/EditorEditableReactive.d.ts +1 -0
- package/lib/store/ThemeColorReactive.d.ts +1 -0
- package/lib/store/commandList.d.ts +1 -1
- package/lib/store/store.d.ts +6 -7
- package/lib/store-BKMaw1AW.cjs +1 -0
- package/lib/store-DG7cMfET.js +10 -0
- package/lib/style.css +1 -1
- package/lib/{tabs-DOasUMDU.cjs → tabs-DpHSMyF_.cjs} +1 -1
- package/lib/{tabs-BKpr0QQB.js → tabs-DxlKKM-N.js} +1 -1
- package/lib/{textarea-Ba9OOzba.js → textarea-D7m-apUh.js} +1 -1
- package/lib/{textarea-D9egO4qC.cjs → textarea-DU9RMi6u.cjs} +1 -1
- package/lib/theme/theme.d.ts +5 -0
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +37 -8
- package/lib/{throttle-DsowOft0.js → throttle-BRtichEP.js} +1 -1
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-BYvLnjCL.cjs +1 -0
- package/lib/toggle-Bxwwb_Kp.js +99 -0
- package/lib/tooltip-BTy5CRrN.js +24 -0
- package/lib/tooltip-COvf4_R-.cjs +1 -0
- package/lib/{updatePosition-Bbd8ETMv.js → updatePosition-CUukgu-Q.js} +2 -2
- package/lib/updatePosition-Cjuj2E26.cjs +1 -0
- package/lib/{useButtonProps-C_bqxmHi.js → useButtonProps-CfYtuEnd.js} +48 -36
- package/lib/useButtonProps-CydzndG1.cjs +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +0 -5
- package/package.json +3 -3
- package/lib/ActionMenuButton-BPdRqzDX.cjs +0 -1
- package/lib/Drawer-hHj4Opkg.cjs +0 -1
- package/lib/Excalidraw-8pWJ17Ye.cjs +0 -1
- package/lib/Icon-D7GJZzoa.js +0 -10
- package/lib/Icon-gtc3g-VK.cjs +0 -1
- package/lib/Iframe-BmXO2c65.cjs +0 -1
- package/lib/Indent-DPkMWfcv.cjs +0 -1
- package/lib/Katex-B1XbT8-X.cjs +0 -4
- package/lib/SlashCommandNodeView-CQvMTXys.cjs +0 -1
- package/lib/Table-LnWGm2m8.cjs +0 -9
- package/lib/Twitter-Bo4JkBTL.cjs +0 -1
- package/lib/button-wt49IYwP.cjs +0 -1
- package/lib/events.constant-DQYeJpu5.cjs +0 -1
- package/lib/events.constant-wrlJ_7JZ.js +0 -26
- package/lib/index-BZ6DfR2r.cjs +0 -1
- package/lib/index-BvIJKpX1.cjs +0 -8
- package/lib/index-Cv9Z6dyV.cjs +0 -1
- package/lib/index-FSRjMsxW.cjs +0 -1
- package/lib/label--161UPH6.cjs +0 -1
- package/lib/label-uKG7RzFU.js +0 -18
- package/lib/separator-DLRVddHS.cjs +0 -1
- package/lib/separator-DtrEdjAF.js +0 -241
- package/lib/store/ProviderUniqueId.d.ts +0 -6
- package/lib/store-B8IkVz1J.cjs +0 -1
- package/lib/store-CsIFDUKR.js +0 -10
- package/lib/throttle-BM3Bmbf_.cjs +0 -1
- package/lib/updatePosition-M2IyqkI1.cjs +0 -1
- package/lib/useButtonProps-DEtmDVPr.cjs +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as N from "react";
|
|
3
|
+
import R from "react";
|
|
4
|
+
import { Slot as y } from "@radix-ui/react-slot";
|
|
5
|
+
import { c as x } from "./index-D9JOHlso.js";
|
|
6
|
+
import "./theme.js";
|
|
7
|
+
import * as d from "@radix-ui/react-toggle";
|
|
8
|
+
import { i as w, c as z } from "./index-EAK64CCA.js";
|
|
9
|
+
import { T as j, a as k, b as A } from "./tooltip-BTy5CRrN.js";
|
|
10
|
+
import { g as S } from "./useButtonProps-CfYtuEnd.js";
|
|
11
|
+
const K = R.forwardRef(
|
|
12
|
+
(o, c) => {
|
|
13
|
+
const {
|
|
14
|
+
icon: a = void 0,
|
|
15
|
+
// title = undefined,
|
|
16
|
+
tooltip: e = void 0,
|
|
17
|
+
disabled: i = !1,
|
|
18
|
+
customClass: m = "",
|
|
19
|
+
// color = undefined,
|
|
20
|
+
loading: V = void 0,
|
|
21
|
+
shortcutKeys: r = void 0,
|
|
22
|
+
tooltipOptions: p = {},
|
|
23
|
+
action: s = void 0,
|
|
24
|
+
isActive: _ = void 0,
|
|
25
|
+
children: u,
|
|
26
|
+
asChild: g = !1,
|
|
27
|
+
upload: B = !1,
|
|
28
|
+
initialDisplayedColor: H = void 0,
|
|
29
|
+
dataState: v = !1,
|
|
30
|
+
...b
|
|
31
|
+
} = o, l = w[a], C = g ? y : f, T = (h) => {
|
|
32
|
+
if (i) {
|
|
33
|
+
h.preventDefault();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
s == null || s(h);
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ n(j, { children: [
|
|
39
|
+
/* @__PURE__ */ t(k, { asChild: !0, children: /* @__PURE__ */ n(
|
|
40
|
+
C,
|
|
41
|
+
{
|
|
42
|
+
className: x("richtext-w-[32px] richtext-h-[32px]", m),
|
|
43
|
+
"data-state": v ? "on" : "off",
|
|
44
|
+
disabled: i,
|
|
45
|
+
onClick: T,
|
|
46
|
+
ref: c,
|
|
47
|
+
size: "sm",
|
|
48
|
+
...b,
|
|
49
|
+
children: [
|
|
50
|
+
l && /* @__PURE__ */ t(l, { className: "richtext-size-4" }),
|
|
51
|
+
u
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
) }),
|
|
55
|
+
e && /* @__PURE__ */ t(
|
|
56
|
+
A,
|
|
57
|
+
{
|
|
58
|
+
...p,
|
|
59
|
+
className: "richtext-tooltip",
|
|
60
|
+
children: /* @__PURE__ */ n("div", { className: "richtext-flex richtext-max-w-24 richtext-flex-col richtext-items-center richtext-text-center", children: [
|
|
61
|
+
/* @__PURE__ */ t("div", { children: e }),
|
|
62
|
+
!!(r != null && r.length) && /* @__PURE__ */ t("span", { children: S(r) })
|
|
63
|
+
] })
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
), D = z(
|
|
69
|
+
"richtext-inline-flex richtext-items-center richtext-justify-center richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-muted hover:richtext-text-muted-foreground 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 data-[state=on]:richtext-bg-accent data-[state=on]:richtext-text-accent-foreground",
|
|
70
|
+
{
|
|
71
|
+
variants: {
|
|
72
|
+
variant: {
|
|
73
|
+
default: "richtext-bg-transparent",
|
|
74
|
+
outline: "richtext-border richtext-border-input richtext-bg-transparent hover:richtext-bg-accent hover:richtext-text-accent-foreground"
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
default: "richtext-h-10 richtext-px-3",
|
|
78
|
+
sm: "richtext-h-9 richtext-px-2",
|
|
79
|
+
lg: "richtext-h-11 richtext-px-5"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
variant: "default",
|
|
84
|
+
size: "default"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
), f = N.forwardRef(({ className: o, variant: c, size: a, ...e }, i) => /* @__PURE__ */ t(
|
|
88
|
+
d.Root,
|
|
89
|
+
{
|
|
90
|
+
ref: i,
|
|
91
|
+
className: x(D({ variant: c, size: a, className: o })),
|
|
92
|
+
...e
|
|
93
|
+
}
|
|
94
|
+
));
|
|
95
|
+
f.displayName = d.Root.displayName;
|
|
96
|
+
export {
|
|
97
|
+
K as A,
|
|
98
|
+
f as T
|
|
99
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import * as t from "@radix-ui/react-tooltip";
|
|
4
|
+
import { c } from "./index-D9JOHlso.js";
|
|
5
|
+
const x = t.Provider, h = t.Root, p = t.Trigger, s = d.forwardRef(({ className: i, sideOffset: r = 4, ...e }, o) => /* @__PURE__ */ a(
|
|
6
|
+
t.Content,
|
|
7
|
+
{
|
|
8
|
+
"data-richtext-portal": !0,
|
|
9
|
+
ref: o,
|
|
10
|
+
sideOffset: r,
|
|
11
|
+
className: c(
|
|
12
|
+
"richtext-z-50 richtext-overflow-hidden richtext-rounded-md richtext-bg-primary richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-text-primary-foreground richtext-shadow-md richtext-animate-in richtext-fade-in-0 richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2 !richtext-border-none",
|
|
13
|
+
i
|
|
14
|
+
),
|
|
15
|
+
...e
|
|
16
|
+
}
|
|
17
|
+
));
|
|
18
|
+
s.displayName = t.Content.displayName;
|
|
19
|
+
export {
|
|
20
|
+
h as T,
|
|
21
|
+
p as a,
|
|
22
|
+
s as b,
|
|
23
|
+
x as c
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const a=require("react/jsx-runtime"),d=require("react"),s=require("@radix-ui/react-tooltip"),l=require("./index-CX4pNJlH.cjs");function n(t){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return i.default=t,Object.freeze(i)}const p=n(d),r=n(s),m=r.Provider,x=r.Root,h=r.Trigger,c=p.forwardRef(({className:t,sideOffset:i=4,...e},o)=>a.jsx(r.Content,{"data-richtext-portal":!0,ref:o,sideOffset:i,className:l.cn("richtext-z-50 richtext-overflow-hidden richtext-rounded-md richtext-bg-primary richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-text-primary-foreground richtext-shadow-md richtext-animate-in richtext-fade-in-0 richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2 !richtext-border-none",t),...e}));c.displayName=r.Content.displayName;exports.Tooltip=x;exports.TooltipContent=c;exports.TooltipProvider=m;exports.TooltipTrigger=h;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as a, s as n, f as l } from "./index-
|
|
2
|
-
import { d as p } from "./
|
|
1
|
+
import { c as a, s as n, f as l } from "./index-D1jd7elj.js";
|
|
2
|
+
import { d as p } from "./clsx-DmuN0U_8.js";
|
|
3
3
|
function m(o, t) {
|
|
4
4
|
a({
|
|
5
5
|
getBoundingClientRect: () => p(o.view, o.state.selection.from, o.state.selection.to)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("./index-Cs6cp0Y6.cjs"),a=require("./clsx-CXbNJWDD.cjs");function l(o,t){const e={getBoundingClientRect:()=>a.posToDOMRect(o.view,o.state.selection.from,o.state.selection.to)};s.computePosition(e,t,{placement:"bottom-start",strategy:"absolute",middleware:[s.shift(),s.flip()]}).then(({x:i,y:n,strategy:c})=>{t.style.width="max-content",t.style.position=c,t.style.left=`${i}px`,t.style.top=`${n}px`})}exports.updatePosition=l;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { u as
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as E from "react";
|
|
2
|
+
import { useState as m, useEffect as b, useMemo as a } from "react";
|
|
3
|
+
import { a as S } from "./index-D9JOHlso.js";
|
|
4
|
+
import { O as h, P as C } from "./clsx-DmuN0U_8.js";
|
|
5
|
+
import { u as M } from "./index-BDX1uE62.js";
|
|
6
|
+
let l;
|
|
7
|
+
function p() {
|
|
8
|
+
return l === void 0 && (l = navigator.platform.includes("Mac")), l;
|
|
9
|
+
}
|
|
10
|
+
function x(t) {
|
|
11
|
+
return `${t}`.toLowerCase() === "mod" ? p() ? "⌘" : "Ctrl" : `${t}`.toLowerCase() === "alt" ? p() ? "⌥" : "Alt" : `${t}`.toLowerCase() === "shift" ? p() ? "⇧" : "Shift" : t;
|
|
12
|
+
}
|
|
13
|
+
function F(t) {
|
|
14
|
+
return t.map(x).join(" ");
|
|
15
|
+
}
|
|
16
|
+
function D(t) {
|
|
17
|
+
const { editor: n } = h(), r = E.useMemo(
|
|
8
18
|
() => n,
|
|
9
19
|
[t, n]
|
|
10
20
|
);
|
|
11
|
-
return
|
|
21
|
+
return C({
|
|
12
22
|
editor: r,
|
|
13
23
|
selector(e) {
|
|
14
24
|
return e.editor ? {
|
|
@@ -24,15 +34,15 @@ function y(t) {
|
|
|
24
34
|
}) || { editor: null };
|
|
25
35
|
}
|
|
26
36
|
function f() {
|
|
27
|
-
return
|
|
37
|
+
return D().editor;
|
|
28
38
|
}
|
|
29
|
-
const
|
|
30
|
-
function
|
|
31
|
-
const n =
|
|
39
|
+
const g = () => !1;
|
|
40
|
+
function K(t = g) {
|
|
41
|
+
const n = S(), [r, o] = m(() => {
|
|
32
42
|
const s = t();
|
|
33
43
|
return typeof s == "boolean" ? !s : s;
|
|
34
44
|
}), e = f();
|
|
35
|
-
|
|
45
|
+
b(() => {
|
|
36
46
|
if (!e || !t) return;
|
|
37
47
|
const s = () => {
|
|
38
48
|
const c = t();
|
|
@@ -51,9 +61,9 @@ function T(t = b) {
|
|
|
51
61
|
editorDisabled: i
|
|
52
62
|
};
|
|
53
63
|
}
|
|
54
|
-
function
|
|
55
|
-
const n =
|
|
56
|
-
|
|
64
|
+
function O(t = g) {
|
|
65
|
+
const n = S(), [r, o] = m({}), [e, u] = m(t()), i = f();
|
|
66
|
+
b(() => {
|
|
57
67
|
if (!i || !t) return;
|
|
58
68
|
const d = () => {
|
|
59
69
|
u(t());
|
|
@@ -73,38 +83,38 @@ function V(t = b) {
|
|
|
73
83
|
// force update
|
|
74
84
|
};
|
|
75
85
|
}
|
|
76
|
-
function
|
|
86
|
+
function U(t) {
|
|
77
87
|
const n = f();
|
|
78
88
|
return a(() => n ? n.extensionManager.extensions.find((o) => o.name === t) : null, [n, t]);
|
|
79
89
|
}
|
|
80
|
-
function
|
|
90
|
+
function R(t, n, r) {
|
|
81
91
|
return t < n ? n : t > r ? r : t;
|
|
82
92
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
93
|
+
const y = (t) => typeof t == "number", N = (t) => typeof t == "string", L = (t) => typeof t == "function";
|
|
94
|
+
function T(t, n = "px") {
|
|
85
95
|
if (!t)
|
|
86
96
|
return t;
|
|
87
|
-
const r =
|
|
97
|
+
const r = y(t) ? String(t) : t, o = Number.parseFloat(r), e = r.match(/[%a-z]+$/i), u = e ? e[0] : n;
|
|
88
98
|
return Number.isNaN(o) ? t : o + u;
|
|
89
99
|
}
|
|
90
|
-
function
|
|
100
|
+
function V(t, n) {
|
|
91
101
|
if (!t)
|
|
92
102
|
return !1;
|
|
93
103
|
const { extensions: r = [] } = (t == null ? void 0 : t.extensionManager) ?? {};
|
|
94
104
|
return !!r.find((e) => e.name === n);
|
|
95
105
|
}
|
|
96
|
-
function
|
|
97
|
-
return t.map((n) =>
|
|
106
|
+
function z(t) {
|
|
107
|
+
return t.map((n) => N(n) ? { value: n, name: n } : n);
|
|
98
108
|
}
|
|
99
|
-
function
|
|
100
|
-
const n = f(), r =
|
|
109
|
+
function B(t) {
|
|
110
|
+
const n = f(), r = U(t), { t: o } = M();
|
|
101
111
|
return a(() => {
|
|
102
|
-
if (!n || !r)
|
|
112
|
+
if (!n || !r || !o)
|
|
103
113
|
return null;
|
|
104
114
|
const {
|
|
105
115
|
button: e
|
|
106
116
|
} = r.options;
|
|
107
|
-
return !e || !
|
|
117
|
+
return !e || !L(e) ? null : e({
|
|
108
118
|
editor: n,
|
|
109
119
|
extension: r,
|
|
110
120
|
t: o
|
|
@@ -112,13 +122,15 @@ function H(t) {
|
|
|
112
122
|
}, [n, r, o]);
|
|
113
123
|
}
|
|
114
124
|
export {
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
O as a,
|
|
126
|
+
K as b,
|
|
117
127
|
f as c,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
U as d,
|
|
129
|
+
z as e,
|
|
130
|
+
T as f,
|
|
131
|
+
F as g,
|
|
132
|
+
x as h,
|
|
133
|
+
R as i,
|
|
134
|
+
V as j,
|
|
135
|
+
B as u
|
|
124
136
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react"),b=require("./index-CX4pNJlH.cjs"),m=require("./clsx-CXbNJWDD.cjs"),M=require("./index-CVFzP1Dc.cjs");function h(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const x=h(s);let l;function p(){return l===void 0&&(l=navigator.platform.includes("Mac")),l}function g(t){return`${t}`.toLowerCase()==="mod"?p()?"⌘":"Ctrl":`${t}`.toLowerCase()==="alt"?p()?"⌥":"Alt":`${t}`.toLowerCase()==="shift"?p()?"⇧":"Shift":t}function y(t){return t.map(g).join(" ")}function C(t){const{editor:e}=m.useCurrentEditor(),n=x.useMemo(()=>e,[t,e]);return m.useEditorState({editor:n,selector(r){return r.editor?{editor:r.editor,editorState:r.editor.state,canCommand:r.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})||{editor:null}}function f(){return C().editor}const S=()=>!1;function D(t=S){const e=b.useEditableEditor(),[n,o]=s.useState(()=>{const u=t();return typeof u=="boolean"?!u:u}),r=f();s.useEffect(()=>{if(!r||!t)return;const u=()=>{const c=t();o(typeof c=="boolean"?!c:c)};return u(),r.on("selectionUpdate",u),r.on("transaction",u),()=>{r.off("selectionUpdate",u),r.off("transaction",u)}},[r,t]);const a=s.useMemo(()=>!e||!r?!0:typeof n=="boolean"?n:!1,[e,r,n]),i=s.useMemo(()=>!e||!r,[e,r]);return{disabled:a,dataState:n,editorDisabled:i}}function N(t=S){const e=b.useEditableEditor(),[n,o]=s.useState({}),[r,a]=s.useState(t()),i=f();s.useEffect(()=>{if(!i||!t)return;const d=()=>{a(t())};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[n,i,t]);const u=s.useMemo(()=>!e||!i,[e,i]),c=s.useMemo(()=>!e||!i,[e,i]);return{disabled:u,dataState:r,editorDisabled:c,update:()=>o({})}}function E(t){const e=f();return s.useMemo(()=>e?e.extensionManager.extensions.find(o=>o.name===t):null,[e,t])}function O(t,e,n){return t<e?e:t>n?n:t}const U=t=>typeof t=="number",P=t=>typeof t=="string",j=t=>typeof t=="function";function $(t,e="px"){if(!t)return t;const n=U(t)?String(t):t,o=Number.parseFloat(n),r=n.match(/[%a-z]+$/i),a=r?r[0]:e;return Number.isNaN(o)?t:o+a}function q(t,e){if(!t)return!1;const{extensions:n=[]}=(t==null?void 0:t.extensionManager)??{};return!!n.find(r=>r.name===e)}function w(t){return t.map(e=>P(e)?{value:e,name:e}:e)}function K(t){const e=f(),n=E(t),{t:o}=M.useLocale();return s.useMemo(()=>{if(!e||!n||!o)return null;const{button:r}=n.options;return!r||!j(r)?null:r({editor:e,extension:n,t:o})},[e,n,o])}exports.clamp=O;exports.ensureNameValueOptions=w;exports.getCssUnitWithDefault=$;exports.getShortcutKey=g;exports.getShortcutKeys=y;exports.hasExtension=q;exports.useActive=D;exports.useButtonProps=K;exports.useEditorInstance=f;exports.useExtension=E;exports.useToggleActive=N;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export declare const EVENTS: {
|
|
2
2
|
readonly UPLOAD_IMAGE: (id: any) => string;
|
|
3
3
|
readonly UPLOAD_VIDEO: (id: string) => string;
|
|
4
|
-
readonly CHANGE_THEME: "CHANGE_THEME";
|
|
5
|
-
readonly CHANGE_COLOR: "CHANGE_COLOR";
|
|
6
|
-
readonly CHANGE_BORDER_RADIUS: "CHANGE_BORDER_RADIUS";
|
|
7
|
-
readonly MODIFY_LANGUAGE: "MODIFY_LANGUAGE";
|
|
8
|
-
readonly CHANGE_LANGUAGE: "CHANGE_LANGUAGE";
|
|
9
4
|
};
|
|
10
5
|
export type EventValues = any;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactjs-tiptap-editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"packageManager": "pnpm@8.15.9",
|
|
6
6
|
"description": "A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React",
|
|
7
7
|
"license": "MIT",
|
|
@@ -779,11 +779,11 @@
|
|
|
779
779
|
"react-colorful": "^5.6.1",
|
|
780
780
|
"react-image-crop": "^11.0.10",
|
|
781
781
|
"react-tweet": "^3.3.0",
|
|
782
|
-
"reactjs-signal": "^2.0.1",
|
|
783
782
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
784
783
|
"svg64": "^2.0.0",
|
|
785
784
|
"y-protocols": "^1.0.7",
|
|
786
|
-
"yjs": "^13.6.28"
|
|
785
|
+
"yjs": "^13.6.28",
|
|
786
|
+
"zustand": "^5.0.9"
|
|
787
787
|
},
|
|
788
788
|
"devDependencies": {
|
|
789
789
|
"@hunghg255/eslint-config": "^1.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),a=require("react"),d=require("@radix-ui/react-slot"),i=require("./index-BvIJKpX1.cjs"),s=require("./button-wt49IYwP.cjs"),u=a.forwardRef(({asChild:h=!1,tooltip:c,...t},l)=>{var x;const n=i.icons[t.icon],r=h?d.Slot:s.Button;return e.jsxs(i.Tooltip,{children:[e.jsx(i.TooltipTrigger,{asChild:!0,children:e.jsx(r,{className:"richtext-h-[32px] richtext-min-w-24 richtext-overflow-hidden richtext-px-[5px] richtext-py-0","data-state":t!=null&&t.dataState?"on":"off",disabled:t==null?void 0:t.disabled,ref:l,variant:"ghost",...t,children:e.jsxs("div",{className:"richtext-flex richtext-h-full richtext-items-center richtext-font-normal",children:[(t==null?void 0:t.title)&&e.jsx("div",{className:"richtext-grow richtext-truncate richtext-text-left richtext-text-sm",children:t==null?void 0:t.title}),n&&e.jsx(n,{className:"richtext-ml-1 richtext-size-3 richtext-shrink-0 richtext-text-zinc-500"})]})})}),c&&e.jsx(i.TooltipContent,{children:e.jsxs("div",{className:"richtext-flex richtext-max-w-24 richtext-flex-col richtext-items-center richtext-text-center",children:[c&&e.jsx("div",{children:c}),e.jsx("div",{className:"richtext-flex",children:!!((x=t==null?void 0:t.shortcutKeys)!=null&&x.length)&&e.jsx("span",{children:i.getShortcutKeys(t==null?void 0:t.shortcutKeys)})})]})})]})});exports.ActionMenuButton=u;
|
package/lib/Drawer-hHj4Opkg.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const I=require("./index-BBNITgNi.cjs"),G=require("./throttle-BM3Bmbf_.cjs"),e=require("react/jsx-runtime"),m=require("react"),B=require("./index-FSRjMsxW.cjs"),F=require("./useButtonProps-DEtmDVPr.cjs"),d=require("easydrawer"),Z=require("./shortId-Bfj8TyNr.cjs"),g=require("./index-BvIJKpX1.cjs"),J=require("./button-wt49IYwP.cjs"),P=require("./dialog-DY868Uji.cjs"),ee=require("./file-i7e4nQY2.cjs"),W={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({editor:t,node:o,updateAttributes:r,getPos:s,selected:f}){const[M,H]=m.useState({width:B.IMAGE_MAX_SIZE,height:B.IMAGE_MAX_SIZE}),[w,h]=m.useState({width:0,height:0}),[L]=m.useState([W.TOP_LEFT,W.TOP_RIGHT,W.BOTTOM_LEFT,W.BOTTOM_RIGHT]),[j,_]=m.useState(!1),[a,c]=m.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=o==null?void 0:o.attrs,C=m.useMemo(()=>{const{src:u,alt:y,width:S,height:N}=o==null?void 0:o.attrs,z=I.isNumber(S)?`${S}px`:S,v=I.isNumber(N)?`${N}px`:N;return{src:u||void 0,alt:y||void 0,style:{width:z||void 0,height:v||void 0}}},[o==null?void 0:o.attrs]),n=m.useMemo(()=>{const{style:{width:u}}=C;return{width:u==="100%"?u:void 0}},[C]);function O(u){h({width:u.target.width,height:u.target.height})}function A(){t.commands.setNodeSelection(s())}const D=m.useCallback(G.throttle(()=>{const{width:u}=getComputedStyle(t.view.dom);H(y=>({...y,width:Number.parseInt(u,10)}))},B.IMAGE_THROTTLE_WAIT_TIME),[t]);function V(u,y){u.preventDefault(),u.stopPropagation();const S=w.width,N=w.height,z=S/N;let v=Number(o.attrs.width),E=Number(o.attrs.height);const b=M.width;v&&!E?(v=v>b?b:v,E=Math.round(v/z)):E&&!v?(v=Math.round(E*z),v=v>b?b:v):!v&&!E?(v=S>b?b:S,E=Math.round(v/z)):v=v>b?b:v,_(!0),c({x:u.clientX,y:u.clientY,w:v,h:E,dir:y})}const x=m.useCallback(G.throttle(u=>{if(u.preventDefault(),u.stopPropagation(),!j)return;const{x:y,w:S,dir:N}=a,z=(u.clientX-y)*(/l/.test(N)?-1:1),{width:v,height:E}=o==null?void 0:o.attrs,b=v/E,U=F.clamp(S+z,B.IMAGE_MIN_SIZE,M.width),Y=Math.round(U/b);r({width:U,height:Y})},B.IMAGE_THROTTLE_WAIT_TIME),[j,a,M,r,o==null?void 0:o.attrs]),i=m.useCallback(u=>{u.preventDefault(),u.stopPropagation(),j&&(c({x:0,y:0,w:0,h:0,dir:""}),_(!1),A())},[j,A]),p=m.useCallback(()=>{document==null||document.addEventListener("mousemove",x,!0),document==null||document.addEventListener("mouseup",i,!0)},[x,i]),k=m.useCallback(()=>{document==null||document.removeEventListener("mousemove",x,!0),document==null||document.removeEventListener("mouseup",i,!0)},[x,i]);m.useEffect(()=>(j?p():k(),()=>{k()}),[j,p,k]);const q=m.useMemo(()=>new ResizeObserver(()=>D()),[D]);return m.useEffect(()=>(q.observe(t.view.dom),()=>{q.disconnect()}),[t.view.dom,q]),e.jsx(I.NodeViewWrapper,{className:"image-view",style:{...n,width:"100%",textAlign:T},children:e.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...n,background:"#fff"},className:`image-view__body ${f?"image-view__body--focused":""} ${j?"image-view__body--resizing":""}`,children:[e.jsx("img",{alt:C.alt,className:"image-view__body__image block",height:"auto",onClick:A,onLoad:O,src:C.src,style:C.style}),t.view.editable&&(f||j)&&e.jsx("div",{className:"image-resizer",children:L==null?void 0:L.map(u=>e.jsx("span",{className:`image-resizer__handler image-resizer__handler--${u}`,onMouseDown:y=>V(y,u)},`image-dir-${u}`))})]})})}const oe="_wrapper_rraz2_1",re="_tool_rraz2_17",le="_active_rraz2_37",ne="_pen_rraz2_41",se="_line_rraz2_48",ie="_options_rraz2_56",ae="_colorWrap_rraz2_66",ce="_color_rraz2_66",he="_colorActive_rraz2_83",l={wrapper:oe,tool:re,active:le,pen:ne,line:se,options:ie,colorWrap:ae,color:ce,colorActive:he};function ue(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function de(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function ge(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function me(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function xe(t){return e.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),e.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function pe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function we(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function ve(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function Ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function fe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function Te(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsxs("g",{fill:"none",fillRule:"evenodd",children:[e.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),e.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function je(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function be(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function Me(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function ye(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Se(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function Ee(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function He(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function Le(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function ke(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const Ne=[d.Color4.blackHighlight,d.Color4.ofRGBA(166/255,81/255,167/255,.3),d.Color4.ofRGBA(247/255,78/255,158/255,.3),d.Color4.ofRGBA(166/255,83/255,88/255,.3),d.Color4.ofRGBA(246/255,130/255,28/255,.3),d.Color4.ofRGBA(166/255,198/255,0,.3),d.Color4.ofRGBA(98/255,186/255,70/255,.3)],X=[d.Color4.black,d.Color4.fromHex("#007AFF"),d.Color4.fromHex("#A651A7"),d.Color4.fromHex("#F74E9E"),d.Color4.fromHex("#FF5358"),d.Color4.fromHex("#F6821C"),d.Color4.fromHex("#FFC600"),d.Color4.fromHex("#62BA46"),d.Color4.fromHex("#E6BFE8"),d.Color4.fromHex("#FEA3D2"),d.Color4.fromHex("#FFA0A3"),d.Color4.fromHex("#FBC276"),d.Color4.fromHex("#FFFB85"),d.Color4.fromHex("#AADC99")];function ze({onChange:t}){const[o,r]=m.useState(d.Color4.blackHighlight);return e.jsx("div",{className:l.colorWrap,children:Ne.map((s,f)=>e.jsx("button",{style:{backgroundColor:s.toHexString()},className:g.cn(l.color,{[l.colorActive]:o.toHexString()===s.toHexString()}),onClick:()=>{r(s),t(s)}},f))})}function $({onChange:t}){const[o,r]=m.useState(d.Color4.black);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l.colorWrap,children:X.slice(0,7).map((s,f)=>e.jsx("button",{style:{backgroundColor:s.toHexString()},className:g.cn(l.color,{[l.colorActive]:o.toHexString()===s.toHexString()}),onClick:()=>{r(s),t(s)}},f))}),e.jsx("div",{className:l.colorWrap,children:X.slice(7).map((s,f)=>e.jsx("button",{style:{backgroundColor:s.toHexString()},className:g.cn(l.color,{[l.colorActive]:o.toHexString()===s.toHexString()}),onClick:()=>{r(s),t(s)}},f))})]})}function _e({setColorPen:t,setThicknessPen:o}){const[r,s]=m.useState(2);return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx($,{onChange:f=>t(f)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{max:10,min:1,step:.1,type:"range",value:r,onChange:f=>{o(Number.parseFloat(f.target.value)),s(Number.parseFloat(f.target.value))}})})]})}function Ae({setColorHighlight:t}){return e.jsx("div",{className:l.options,children:e.jsx(ze,{onChange:o=>t(o)})})}function qe({changeColorShape:t,changeBorderColorShape:o,onThicknessChange:r}){return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx($,{onChange:s=>t(s)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx($,{onChange:s=>o(s)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:s=>{r(Number.parseFloat(s.target.value))}})})]})}function K(t){const{setColorPen:o,refEditor:r,setThicknessPen:s,setColorHighlight:f,changeBorderColorShape:M,onUndo:H,changeColorShape:w,changeShape:h,onThicknessChange:L,onRedo:j,onClear:_}=t,[a,c]=m.useState(null),[T,C]=m.useState(0);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:l.wrapper,children:[e.jsxs("div",{className:l.pen,children:[e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="select"}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();if(a==="select"){c(null),n[0].setEnabled(!1);return}c("select"),n[0].setEnabled(!0)},children:e.jsx(ue,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="text"}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();if(r.current.toolController.setToolEnabled(n[1]),a==="text"){n[1].setEnabled(!1),c(null);return}c("text"),n[1].setEnabled(!0)},children:e.jsx(de,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="pencil"}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();if(a==="pencil"){c(null),n[2].setEnabled(!1);return}c("pencil"),n[2].setEnabled(!0)},children:e.jsx(ge,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="highlighter"}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();if(a==="highlighter"){c(null),n[3].setEnabled(!1);return}c("highlighter"),n[3].setEnabled(!0)},children:e.jsx(me,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="eraser"}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();if(a==="eraser"){c(null),n[4].setEnabled(!1);return}c("eraser"),n[4].setEnabled(!0)},children:e.jsx(xe,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===0}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(0),C(0)},children:e.jsx(pe,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===1}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(1),C(1)},children:e.jsx(we,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===2}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(2),C(2)},children:e.jsx(ve,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===3}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(3),C(3)},children:e.jsx(Ce,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===4}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(4),C(4)},children:e.jsx(fe,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===5}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(5),C(5)},children:e.jsx(Te,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===6}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(6),C(6)},children:e.jsx(je,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===7}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(7),C(7)},children:e.jsx(Se,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===8}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(8),C(8)},children:e.jsx(Ee,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===9}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(9),C(9)},children:e.jsx(He,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===10}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(10),C(10)},children:e.jsx(Le,{})}),e.jsx("button",{className:g.cn(l.tool,{[l.active]:a==="shapes"&&T===11}),onClick:()=>{const n=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(n[5]),c("shapes"),n[5].setEnabled(!0),h(11),C(11)},children:e.jsx(ke,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:g.cn(l.tool),onClick:H,children:e.jsx(be,{})}),e.jsx("button",{className:g.cn(l.tool),onClick:j,children:e.jsx(Me,{})}),e.jsx("button",{className:g.cn(l.tool),onClick:_,children:e.jsx(ye,{})})]}),e.jsxs("div",{className:l.optionsWrap,children:[a==="pencil"&&e.jsx(_e,{setColorPen:o,setThicknessPen:s}),a==="highlighter"&&e.jsx(Ae,{setColorHighlight:f}),a==="shapes"&&e.jsx(qe,{changeBorderColorShape:M,changeColorShape:w,changeShape:h,onThicknessChange:L})]})]})})}let R=!1;function Be(){const t=F.useEditorInstance(),o=F.useButtonProps(Q.name),{isActive:r=void 0,upload:s}=(o==null?void 0:o.componentProps)??{},{editorDisabled:f}=F.useToggleActive(r),[M,H]=m.useState(!1),w=m.useRef(null),h=m.useRef(null),L=()=>{(async()=>{const i=document.querySelector("#easydrawer");i&&(w.current=new d.Editor(i,{wheelEventsEnabled:!1,disableZoom:!0}),h.current=d.makeDropdownToolbar(w.current),h.current.addDefaultToolWidgets())})()};m.useEffect(()=>{M&&setTimeout(()=>{L()},200)},[M]);const j=async()=>{if(w.current){const x=w.current.toSVG(),i=x.outerHTML,p=`drawer-${Z.shortId()}.svg`;let k=Z.i(x.outerHTML);if(s){const q=ee.dataURLtoFile(k,p);k=await s(q)}t==null||t.chain().focus().setDrawer({type:"drawer",src:k,alt:encodeURIComponent(i),width:426,height:212},!!i).run()}H(!1)},_=x=>{const i=w.current.toolController.getPrimaryTools()[2],p=h.current.getWidgetById("pen-1");i&&p&&(i.setColor(x),p.serializeState())},a=x=>{const i=w.current.toolController.getPrimaryTools()[2],p=h.current.getWidgetById("pen-1");i&&p&&(i.setThickness(x),p.serializeState())},c=x=>{const i=w.current.toolController.getPrimaryTools()[3],p=h.current.getWidgetById("pen-2");i&&p&&(i.setColor(x),p.serializeState())},T=x=>{const i=h.current.getWidgetById("shape");i&&i.setShapeType(x)},C=x=>{const i=w.current.toolController.getPrimaryTools()[5],p=h.current.getWidgetById("shape");i&&p&&(i.setColor(x),p.serializeState())},n=x=>{const i=w.current.toolController.getPrimaryTools()[5],p=h.current.getWidgetById("shape");i&&p&&(i.setThickness(x),p.serializeState())},O=x=>{const i=w.current.toolController.getPrimaryTools()[5],p=h.current.getWidgetById("shape");i&&p&&(i.setBorderColor(x),p.serializeState())},A=()=>{if(R){for(;w.current.history.redoStackSize>0;)w.current.history.redo();R=!1;return}w.current.history.undo()},D=()=>{R||w.current.history.redo()},V=()=>{if(!R){for(;w.current.history.undoStackSize>0;)A();R=!0}};return o?e.jsxs(P.Dialog,{onOpenChange:H,open:M,children:[e.jsx(P.DialogTrigger,{asChild:!0,children:e.jsx(g.ActionButton,{disabled:f,action:()=>{f||H(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),e.jsxs(P.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[e.jsx(P.DialogTitle,{children:"Drawer"}),e.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[e.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),e.jsx(K,{changeBorderColorShape:O,changeColorShape:C,changeShape:T,onClear:V,onRedo:D,onThicknessChange:n,onUndo:A,refEditor:w,setColorHighlight:c,setColorPen:_,setThicknessPen:a})]}),e.jsx(P.DialogFooter,{children:e.jsx(J.Button,{onClick:j,type:"button",children:"Save changes"})})]})]}):e.jsx(e.Fragment,{})}const Q=G.index_default.extend({name:"richTextDrawer",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:o,extension:r})=>{var s;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:o("editor.drawer.tooltip"),upload:(s=r==null?void 0:r.options)==null?void 0:s.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:o=>{const r=o.querySelector("img"),s=r==null?void 0:r.getAttribute("width");return s?Number.parseInt(s,10):320},renderHTML:o=>({width:o.width})},height:{default:null,parseHTML:o=>{const r=o.querySelector("img"),s=r==null?void 0:r.getAttribute("height");return s?Number.parseInt(s,10):212},renderHTML:o=>({height:o.height})},align:{default:"center",parseHTML:o=>o.getAttribute("align"),renderHTML:o=>({align:o.align})}}},addNodeView(){return I.ReactNodeViewRenderer(te)},addCommands(){return{setDrawer:(t,o)=>({commands:r,editor:s})=>o?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(s.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageDrawer:t=>({commands:o})=>o.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:o}=t;return["div",{style:o?`text-align: ${o};`:"",class:"imageDrawer"},["img",I.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:t=>{const o=t.querySelector("img"),r=o==null?void 0:o.getAttribute("width"),s=o==null?void 0:o.getAttribute("height");return{src:o==null?void 0:o.getAttribute("src"),alt:o==null?void 0:o.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:s?Number.parseInt(s,10):null,align:(o==null?void 0:o.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.ControlDrawer=K;exports.Drawer=Q;exports.RichTextDrawer=Be;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var B=Object.create;var H=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var F=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of V(t))!X.call(e,a)&&a!==r&&H(e,a,{get:()=>t[a],enumerable:!(n=$(t,a))||n.enumerable});return e};var k=(e,t,r)=>(r=e!=null?B(U(e)):{},F(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e));const E=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),i=require("react"),L=require("./index-BvIJKpX1.cjs"),G=require("./button-wt49IYwP.cjs"),A=require("./dialog-DY868Uji.cjs"),T=require("./useButtonProps-DEtmDVPr.cjs"),Y=require("re-resizable"),I=require("./dom-dataset-BqoJhJXt.cjs");function J(e){return e=e||new Map,{all:e,on(t,r){const n=e.get(t);n?n.push(r):e.set(t,[r])},off(t,r){const n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit(t,r){let n=e.get(t);n&&[...n].map(a=>{a(r)}),n=e.get("*"),n&&[...n].map(a=>{a(t,r)})}}}let C;function W(){try{return C||(C=J()),C}catch{throw new Error("Error EventEmitter")}}const R="OPEN_EXCALIDRAW_SETTING_MODAL";function K(e,t){W().on(e,t)}function Q(e,t){W().off(e,t)}function ee(e){W().emit(R,e)}function te(){const e=T.useEditorInstance(),t=T.useButtonProps(M.name),r=T.useExtension(M.name),{tooltipOptions:n={},isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{editorDisabled:f}=T.useToggleActive(a),u=i.useMemo(()=>(r==null?void 0:r.options)||{},[r]),[c,_]=i.useState(null),[x,y]=i.useState({}),[b,N]=i.useState({elements:[],appState:{isLoading:!1},files:null}),[d,h]=i.useState(!1),[v,j]=i.useState(!0),[m,O]=i.useState(null),o=i.useCallback(p=>{p&&import("@excalidraw/excalidraw").then(g=>{_(g.Excalidraw)}).catch(O).finally(()=>j(!1))},[j]),l=i.useCallback(p=>{setTimeout(()=>{p.refresh()})},[]),w=i.useCallback((p,g,z)=>{y({elements:p,appState:{isLoading:!1},files:z})},[]),D=i.useCallback(()=>{if(!c){h(!1);return}e.chain().focus().setExcalidraw({data:x}).run(),h(!1)},[c,e,x,h]);return i.useEffect(()=>{const p=g=>{(g==null?void 0:g.editor)===e&&(h(!0),g&&N(g.data))};return K(R,p),()=>{Q(R,p)}},[e,h]),i.useEffect(()=>{!v&&c&&d&&setTimeout(()=>{window.dispatchEvent(new Event("resize"))},400)},[v,c,d]),s.jsxs(A.Dialog,{onOpenChange:h,open:d,children:[s.jsx(A.DialogTrigger,{asChild:!0,children:s.jsx(L.ActionButton,{disabled:f,icon:"Excalidraw",tooltip:"Excalidraw",tooltipOptions:n,action:()=>{f||h(!0)}})}),s.jsxs(A.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[s.jsx(A.DialogTitle,{children:"Excalidraw"}),s.jsxs("div",{style:{height:"100%",borderWidth:1},children:[v&&s.jsx("p",{children:"Loading..."}),m&&s.jsx("p",{children:m&&m.message||"Error"}),s.jsx("div",{ref:o,style:{width:"100%",height:600},children:!v&&!m&&c?s.jsx(c,{initialData:b,langCode:"en",onChange:w,ref:l,...u.excalidrawProps}):null})]}),s.jsx(A.DialogFooter,{children:s.jsx(G.Button,{disabled:!c,onClick:D,type:"button",children:"Save changes"})})]})]})}const re="_wrap_dra8y_1",ne="_renderWrap_dra8y_7",se="_handlerWrap_dra8y_30",ie="_disabled_dra8y_40",S={wrap:re,renderWrap:ne,handlerWrap:se,disabled:ie},ae=10,oe=200,q=15,P={width:"100%",height:"100%",maxWidth:"100%"};function ce({editor:e,node:t,updateAttributes:r}){const n=i.useRef(null),a=L.useEditableEditor(),f=e.isActive(M.name),{data:u,width:c,height:_}=t.attrs,[x,y]=i.useState(null),[b,N]=i.useState(!0),[d,h]=i.useState(null),[v,j]=i.useState(100),m=i.useCallback(o=>()=>{j(l=>T.clamp(o==="minus"?l-q:l+q,ae,oe))},[]);i.useEffect(()=>{let o=!1;return import("@excalidraw/excalidraw").then(l=>{o||(n.current=l.exportToSvg)}).catch(l=>!o&&h(l)).finally(()=>!o&&N(!1)),()=>{o=!0}},[u]),i.useEffect(()=>{let o=!1;return(async()=>{if(!n.current||o||b||d||!u)return;const w=await n.current(u);o||(w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.setAttribute("display","block"),y(w))})(),()=>{o=!0}},[u,b,d]);const O=o=>{r({width:o.width,height:o.height})};return s.jsx(E.NodeViewWrapper,{className:E.clsx(S.wrap,{[S.active]:f,[S.disabled]:!a}),children:s.jsx(Y.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(_)},onResizeStop:(o,l,w,D)=>{O({width:Number.parseInt(c)+D.width,height:Number.parseInt(_)+D.height})},children:s.jsxs("div",{className:E.clsx(S.renderWrap,"render-wrapper"),style:{...P,overflow:"hidden"},children:[d&&s.jsx("div",{style:P,children:s.jsx("p",{children:d.message||d})}),b&&s.jsx("p",{children:"Loading..."}),!b&&!d&&x&&s.jsx("div",{dangerouslySetInnerHTML:{__html:(x==null?void 0:x.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${v/100})`,transition:"all ease-in-out .3s"}}),s.jsxs("div",{className:S.handlerWrap,children:[s.jsx(L.ActionButton,{action:m("minus"),disabled:!a,icon:"ZoomOut",tooltip:"Zoom Out"}),s.jsx(L.ActionButton,{action:m("plus"),disabled:!a,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}const Z={elements:[]},M=E.Node3.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:I.getDatasetAttribute("width")},height:{default:240,parseHTML:I.getDatasetAttribute("height")},data:{default:Z,parseHTML:I.getDatasetAttribute("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},excalidrawProps:{},button:()=>({componentProps:{}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:t}){return["div",E.mergeAttributes(this.options.HTMLAttributes,e,I.nodeAttrsToDataset(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:r,chain:n})=>{var a,f,u;return e=e||{},e.data=e.data||Z,((u=(f=(a=t.selection)==null?void 0:a.node)==null?void 0:f.type)==null?void 0:u.name)==this.name?r.updateAttributes(this.name,e):n().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return E.ReactNodeViewRenderer(ce)},addInputRules(){return[E.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});exports.Excalidraw=M;exports.RichTextExcalidraw=te;exports.triggerOpenExcalidrawSettingModal=ee;
|
package/lib/Icon-D7GJZzoa.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { i } from "./index-BIqaogQg.js";
|
|
3
|
-
import "react";
|
|
4
|
-
function l(n) {
|
|
5
|
-
const t = i[n.name];
|
|
6
|
-
return t ? /* @__PURE__ */ c(t, { onClick: n == null ? void 0 : n.onClick, className: `richtext-w-4 richtext-h-4 ${(n == null ? void 0 : n.className) || ""}` }) : null;
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
l as I
|
|
10
|
-
};
|
package/lib/Icon-gtc3g-VK.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const c=require("react/jsx-runtime"),t=require("./index-BvIJKpX1.cjs");require("react");function i(n){const e=t.icons[n.name];return e?c.jsx(e,{onClick:n==null?void 0:n.onClick,className:`richtext-w-4 richtext-h-4 ${(n==null?void 0:n.className)||""}`}):null}exports.IconComponent=i;
|
package/lib/Iframe-BmXO2c65.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),b=require("react"),S=require("re-resizable"),I=require("./button-wt49IYwP.cjs"),P=require("./input-BeD5GdMv.cjs"),x=require("./index-BvIJKpX1.cjs"),h=require("./dom-dataset-BqoJhJXt.cjs"),g=require("./useButtonProps-DEtmDVPr.cjs"),m={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:[String.raw`v.youku.com\/v_show\/id_\w+\=*`],idRule:String.raw`id_\w+\=*`},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:[String.raw`www.bilibili.com\/video\/\w+`]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:[String.raw`v.qq.com\/x\/cover\/\w+\/\w+`]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:[String.raw`\.amap\.com`]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:[String.raw`map\.baidu\.com`]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:[String.raw`https:\/\/\w+.modao.cc\/app\/\w+\/embed\/v2`],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:[String.raw`https:\/\/lanhuapp.com\/url\/\w+`],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:[String.raw`https:\/\/www.figma.com\/file\/\w+`]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:[String.raw`https:\/\/www.canva.cn\/design\/.+\/view`]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:[String.raw`https:\/\/www.processon.com\/embed\/\w+`]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:[String.raw`https:\/\/codepen.io\/.+\/embed\/\w+`]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:[String.raw`https:\/\/jinshuju.net\/f\/\w+`]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:[String.raw`https:\/\/goo.gl\/maps\/\w+`]}};function R(e){const t=m.youtube,i=e.matchedUrl;e.validLink=!0;const r=i.split("="),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}/${c}`,e.validId=!0}return e}function j(e){const t=m.youku,i=e.matchedUrl,r=t.idRule,n=new RegExp(r),c=i.match(n);if(c&&c.length>0){const o=c[0].slice(3);e.validId=!0,e.src=`${t.srcPrefix}/${o}`}else e.validId=!1;return e}function M(e){const t=m.bilibili,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function q(e){const t=m.qqvideo,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function N(e,t){return t.src=e,t.validId=!0,t}function U(e,t){return t.src=e,t.validId=!0,t}function A(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function D(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function L(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function $(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function _(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function T(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function z(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function Y(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function C(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function E(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=m[e].linkRule;for(const c of n){const o=new RegExp(c),a=t.match(o);if(a&&a.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?a[1]:a[0],i}return i}function H(e){var i,r;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(r=e.includes)!=null&&r.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t}function k(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=H(e);if(t=E(i,e,t),!t.validLink)return t;switch(i){case"youtube":return R(t);case"youku":return j(t);case"bilibili":return M(t);case"qqvideo":return q(t);case"amap":return N(e,t);case"baidu_map":return U(e,t);case"googlemaps":return A(e,t);case"modao":return D(t);case"lanhu":return L(t);case"figma":return $(t);case"canva":return _(e,t);case"processon":return T(e,t);case"codepen":return z(t);case"jinshuju":return Y(e,t);case"iframe":return C(e,t);default:return e}}const B="_wrap_5y04w_1",V="_innerWrap_5y04w_15",v={wrap:B,innerWrap:V};function K({editor:e,node:t,updateAttributes:i}){const r=x.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=b.useState("");function l(){if(!a)return;const d=k(a);e.chain().updateAttributes(f.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const y=b.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(u.NodeViewWrapper,{children:[!n&&s.jsxs("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:[s.jsx(P.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(I.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(S.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,X,J,w)=>{y({width:Number.parseInt(c)+w.width,height:Number.parseInt(o)+w.height})},children:s.jsx("div",{className:u.clsx(v.wrap,"render-wrapper"),children:s.jsx("div",{className:v.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px] ",src:n})})})})]})}function O(){const e=g.useButtonProps(f.name),{icon:t=void 0,tooltip:i=void 0,shortcutKeys:r=void 0,tooltipOptions:n={},action:c=void 0,isActive:o=void 0}=(e==null?void 0:e.componentProps)??{},{editorDisabled:a,update:p}=g.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(x.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const f=u.Node3.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:i,t:r})=>({componentProps:{action:n=>t.commands.setIframe(n),upload:i.options.upload,icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:h.getDatasetAttribute("width")},height:{default:300,parseHTML:h.getDatasetAttribute("height")},src:{default:null,parseHTML:h.getDatasetAttribute("src")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",u.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var c,o,a;if(((a=(o=(c=t.selection)==null?void 0:c.node)==null?void 0:o.type)==null?void 0:a.name)==this.name)return i.updateAttributes(this.name,e);const n=e||{url:""};return r().insertContent({type:this.name,attrs:n}).run()}}},addInputRules(){return[u.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return u.ReactNodeViewRenderer(K)}});exports.Iframe=f;exports.RichTextIframe=O;exports.getServiceSrc=k;
|
package/lib/Indent-DPkMWfcv.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("./index-BBNITgNi.cjs"),m=require("@tiptap/pm/state"),c=require("react/jsx-runtime"),l=require("./index-BvIJKpX1.cjs");require("react");const p=require("./useButtonProps-DEtmDVPr.cjs");var a=(t=>(t[t.max=7]="max",t[t.min=0]="min",t[t.more=1]="more",t[t.less=-1]="less",t))(a||{});function T(t,e,n){return t<e?e:t>n?n:t}function A(t,e,n,o){const{doc:s,selection:i}=t;if(!s||!i||!(i instanceof m.TextSelection||i instanceof m.AllSelection))return t;const{from:r,to:u}=i;return s.nodesBetween(r,u,(d,I)=>{const b=d.type;return n.includes(b.name)?(t=y(t,I,e),!1):!h.isList(d.type.name,o.extensionManager.extensions)}),t}function y(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o)return t;const r=T((o.attrs.indent||0)+n,0,7);if(r===o.attrs.indent)return t;const u={...o.attrs,indent:r};return t.setNodeMarkup(e,o.type,u,o.marks)}function f({delta:t,types:e}){return({state:n,dispatch:o,editor:s})=>{const{selection:i}=n;let{tr:r}=n;return r=r.setSelection(i),r=A(r,t,e,s),r.docChanged?(o&&o(r),!0):!1}}function K(){const t=p.useButtonProps(x.name),{indent:e,outdent:n}=(t==null?void 0:t.componentProps)??{},{editorDisabled:o}=p.useToggleActive(),s=()=>{o||e!=null&&e.action&&(e==null||e.action())},i=()=>{o||n!=null&&n.action&&(n==null||n.action())};return t?c.jsxs(c.Fragment,{children:[c.jsx(l.ActionButton,{action:s,disabled:o,icon:e==null?void 0:e.icon,shortcutKeys:e==null?void 0:e.shortcutKeys,tooltip:e==null?void 0:e.tooltip}),c.jsx(l.ActionButton,{action:i,disabled:o,icon:n==null?void 0:n.icon,shortcutKeys:n==null?void 0:n.shortcutKeys,tooltip:n==null?void 0:n.tooltip})]}):c.jsx(c.Fragment,{})}const x=h.Extension.create({name:"richtextIndentOutdent",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["paragraph","heading","blockquote"],minIndent:a.min,maxIndent:a.max,button({editor:e,t:n,extension:o}){var s,i;return{componentProps:{indent:{action:()=>{e.commands.indent()},shortcutKeys:((s=o.options.shortcutKeys)==null?void 0:s[0])??["Tab"],icon:"IndentIncrease",tooltip:n("editor.indent.tooltip")},outdent:{action:()=>{e.commands.outdent()},shortcutKeys:((i=o.options.shortcutKeys)==null?void 0:i[1])??["Shift","Tab"],icon:"IndentDecrease",tooltip:n("editor.outdent.tooltip")}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.dataset.indent;return(e?Number.parseInt(e,10):0)||0},renderHTML:t=>t.indent?{"data-indent":t.indent}:{}}}}]},addCommands(){return{indent:()=>f({delta:a.more,types:this.options.types}),outdent:()=>f({delta:a.less,types:this.options.types})}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}});exports.Indent=x;exports.IndentProps=a;exports.RichTextIndent=K;exports.setNodeIndentMarkup=y;
|