@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.
Files changed (194) hide show
  1. package/README.md +1 -1
  2. package/lib/ActionMenuButton-D9o3Kwmv.cjs +1 -0
  3. package/lib/{ActionMenuButton-DBZjUu-F.js → ActionMenuButton-nxV91Fqo.js} +10 -9
  4. package/lib/Attachment.cjs +19 -1
  5. package/lib/Attachment.js +270 -7
  6. package/lib/Blockquote.cjs +2 -2
  7. package/lib/Blockquote.js +12 -13
  8. package/lib/Bold.cjs +1 -1
  9. package/lib/Bold.js +10 -11
  10. package/lib/BulletList.cjs +1 -1
  11. package/lib/BulletList.js +8 -9
  12. package/lib/Callout.cjs +1 -1
  13. package/lib/Callout.js +45 -41
  14. package/lib/Clear.cjs +1 -1
  15. package/lib/Clear.js +14 -13
  16. package/lib/Code.cjs +1 -1
  17. package/lib/Code.js +5 -6
  18. package/lib/CodeBlock.cjs +1 -1
  19. package/lib/CodeBlock.js +31 -30
  20. package/lib/CodeView.cjs +1 -1
  21. package/lib/CodeView.js +8 -9
  22. package/lib/Color.cjs +1 -1
  23. package/lib/Color.js +19 -18
  24. package/lib/Column.cjs +1 -1
  25. package/lib/Column.js +8 -9
  26. package/lib/Drawer-Bh-y5bs8.cjs +2 -0
  27. package/lib/{Drawer-DTCwtJEs.js → Drawer-CF6Z_IA2.js} +24 -18
  28. package/lib/Drawer.cjs +1 -1
  29. package/lib/Drawer.js +3 -3
  30. package/lib/Emoji.cjs +1 -1
  31. package/lib/Emoji.js +15 -14
  32. package/lib/Excalidraw.cjs +1 -1
  33. package/lib/Excalidraw.js +33 -28
  34. package/lib/ExportPdf.cjs +3 -3
  35. package/lib/ExportPdf.js +13 -14
  36. package/lib/ExportWord.cjs +1 -1
  37. package/lib/ExportWord.js +6 -6
  38. package/lib/FontFamily.cjs +1 -1
  39. package/lib/FontFamily.js +6 -7
  40. package/lib/FontSize.cjs +1 -1
  41. package/lib/FontSize.js +14 -15
  42. package/lib/Heading.cjs +1 -1
  43. package/lib/Heading.js +26 -26
  44. package/lib/Highlight.cjs +1 -1
  45. package/lib/Highlight.js +23 -22
  46. package/lib/History.cjs +1 -1
  47. package/lib/History.js +11 -11
  48. package/lib/HorizontalRule.cjs +1 -1
  49. package/lib/HorizontalRule.js +9 -10
  50. package/lib/Icon-BvGyfX2j.js +15 -0
  51. package/lib/Icon-wjwoRc9F.cjs +1 -0
  52. package/lib/Iframe-BbfZKbPY.cjs +1 -0
  53. package/lib/{Iframe-D-UYBxiv.js → Iframe-Dfd3LI7b.js} +18 -15
  54. package/lib/Iframe.cjs +1 -1
  55. package/lib/Iframe.js +3 -3
  56. package/lib/Image.cjs +1 -1
  57. package/lib/Image.js +5 -4
  58. package/lib/ImageCropper-CY1ETEjC.cjs +10 -0
  59. package/lib/ImageCropper-DrSdjo9x.js +979 -0
  60. package/lib/ImageGif.cjs +1 -1
  61. package/lib/ImageGif.js +80 -77
  62. package/lib/ImportWord.cjs +1 -1
  63. package/lib/ImportWord.js +28 -26
  64. package/lib/{Indent-Bvt-Qwar.js → Indent-CDVF9DWN.js} +30 -31
  65. package/lib/Indent-Q1VuhSM2.cjs +1 -0
  66. package/lib/Indent.cjs +1 -1
  67. package/lib/Indent.js +2 -2
  68. package/lib/Italic.cjs +1 -1
  69. package/lib/Italic.js +11 -12
  70. package/lib/{Katex-CJDtvu-v.js → Katex-DqhWWAA-.js} +22 -19
  71. package/lib/Katex-K1QU2SB2.cjs +4 -0
  72. package/lib/Katex.cjs +1 -1
  73. package/lib/Katex.js +2 -2
  74. package/lib/LineHeight.cjs +1 -1
  75. package/lib/LineHeight.js +20 -19
  76. package/lib/Link.cjs +1 -1
  77. package/lib/Link.js +2 -2
  78. package/lib/LinkEditBlock-CBYGLs3J.cjs +5 -0
  79. package/lib/{LinkEditBlock-Cdqwj_NU.js → LinkEditBlock-xP0pGVhB.js} +24 -19
  80. package/lib/Mention.js +3 -3
  81. package/lib/{Mermaid-CnMYVX1P.js → Mermaid-BJ6ryVdY.js} +48 -45
  82. package/lib/Mermaid-D3_nLeOW.cjs +2 -0
  83. package/lib/Mermaid.cjs +1 -1
  84. package/lib/Mermaid.js +2 -2
  85. package/lib/MoreMark.cjs +1 -1
  86. package/lib/MoreMark.js +28 -26
  87. package/lib/OrderedList.cjs +1 -1
  88. package/lib/OrderedList.js +10 -11
  89. package/lib/PaywallSeparator.cjs +1 -0
  90. package/lib/PaywallSeparator.js +140 -0
  91. package/lib/SearchAndReplace.cjs +1 -1
  92. package/lib/SearchAndReplace.js +42 -37
  93. package/lib/SlashCommand.cjs +1 -1
  94. package/lib/SlashCommand.js +5 -5
  95. package/lib/SlashCommandNodeView-CUJrDQS7.cjs +1 -0
  96. package/lib/{SlashCommandNodeView-DcoLvt_6.js → SlashCommandNodeView-DS9FqMiY.js} +80 -62
  97. package/lib/Strike.cjs +1 -1
  98. package/lib/Strike.js +11 -12
  99. package/lib/Table-CV6pUoVf.cjs +5 -0
  100. package/lib/{Table-Cu12PvQ_.js → Table-CcG-JNtV.js} +46 -46
  101. package/lib/Table.cjs +1 -1
  102. package/lib/Table.js +1 -1
  103. package/lib/TaskList.cjs +1 -1
  104. package/lib/TaskList.js +11 -12
  105. package/lib/TextAlign.cjs +1 -1
  106. package/lib/TextAlign.js +27 -26
  107. package/lib/TextDirection.cjs +1 -1
  108. package/lib/TextDirection.js +19 -18
  109. package/lib/TextUnderline.cjs +1 -1
  110. package/lib/TextUnderline.js +8 -9
  111. package/lib/{Twitter-CrX4XY1j.js → Twitter-BIL3o833.js} +22 -18
  112. package/lib/Twitter-BfSTqPDh.cjs +1 -0
  113. package/lib/Twitter.cjs +1 -1
  114. package/lib/Twitter.js +2 -2
  115. package/lib/Video-DAKr90QL.js +231 -0
  116. package/lib/Video-HAinT0w6.cjs +1 -0
  117. package/lib/Video.cjs +1 -1
  118. package/lib/Video.js +5 -4
  119. package/lib/bubble.cjs +3 -3
  120. package/lib/bubble.js +86 -77
  121. package/lib/button-090-I3tp.js +35 -0
  122. package/lib/button-B4Sz2ZhW.cjs +1 -0
  123. package/lib/checkbox-BCPsu7yR.cjs +1 -0
  124. package/lib/checkbox-DiXWHAI0.js +29 -0
  125. package/lib/{clsx-BUPZHhq3.js → clsx-m_C5j3RU.js} +24 -24
  126. package/lib/components/RichTextProvider.d.ts +1 -1
  127. package/lib/dialog-C8J59d2J.cjs +1 -0
  128. package/lib/dialog-bDkDW-C_.js +95 -0
  129. package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
  130. package/lib/dom-dataset-CIEeltF6.js +47 -0
  131. package/lib/{dropdown-menu-CVwXaR3Z.js → dropdown-menu-DWt_xj4h.js} +1 -1
  132. package/lib/{dropdown-menu-XIrQk3jr.cjs → dropdown-menu-tUP872Zv.cjs} +1 -1
  133. package/lib/events.constant-Bke62qxm.cjs +1 -0
  134. package/lib/events.constant-CSWD3-ho.js +72 -0
  135. package/lib/extensions/PaywallSeparator/PaywallSeparator.d.ts +35 -0
  136. package/lib/extensions/PaywallSeparator/components/PaywallIcon.d.ts +2 -0
  137. package/lib/extensions/PaywallSeparator/components/PaywallSeparatorView.d.ts +17 -0
  138. package/lib/extensions/PaywallSeparator/components/RichTextPaywallSeparator.d.ts +1 -0
  139. package/lib/extensions/PaywallSeparator/components/index.d.ts +2 -0
  140. package/lib/extensions/PaywallSeparator/index.d.ts +1 -0
  141. package/lib/file-i7e4nQY2.cjs +1 -0
  142. package/lib/file-jDdkhyj7.js +43 -0
  143. package/lib/{index-RkKGy5oa.js → index-B3Ijnbxs.js} +1 -1
  144. package/lib/index-BXh8X1ch.cjs +1 -0
  145. package/lib/{index-Dl3OjzmR.js → index-C1KQsOcg.js} +1 -1
  146. package/lib/{index-D4M4hrH4.js → index-C8FjP66D.js} +1 -1
  147. package/lib/index-jMN4V2hr.js +2763 -0
  148. package/lib/{index-DZj2z9_1.js → index-s3l5RdyW.js} +1 -1
  149. package/lib/index.cjs +4 -4
  150. package/lib/index.js +464 -149
  151. package/lib/input-C_J-pfTx.js +21 -0
  152. package/lib/input-DwLo4r7V.cjs +1 -0
  153. package/lib/isNumber-BTYSVlKo.cjs +1 -0
  154. package/lib/isNumber-WaBzl_0s.js +15 -0
  155. package/lib/label-BgIVynq3.cjs +1 -0
  156. package/lib/label-ClsOg9Hr.js +11 -0
  157. package/lib/{popover-DDT8YRht.js → popover-BC7FRr8B.js} +1 -1
  158. package/lib/{popover-0syCfWYi.cjs → popover-C3A6zzNV.cjs} +1 -1
  159. package/lib/{renderNodeView-dj6AaFSX.js → renderNodeView-C_hPIdEs.js} +2 -2
  160. package/lib/{select-DTNz0ZeE.cjs → select-B8HIWDXf.cjs} +1 -1
  161. package/lib/{select-D9wQw2qB.js → select-DSKqhVGR.js} +1 -1
  162. package/lib/{separator-DRGTEiX4.js → separator-BJWSNjvr.js} +13 -12
  163. package/lib/separator-D6ruF682.cjs +1 -0
  164. package/lib/style.css +1 -1
  165. package/lib/tabs-D1J1iB7B.js +46 -0
  166. package/lib/tabs-IEbMQmNX.cjs +1 -0
  167. package/lib/{textarea-DfVzbMr5.js → textarea-Ch5w3PiI.js} +1 -1
  168. package/lib/{textarea-DpkwluT0.cjs → textarea-CtVdqwSM.cjs} +1 -1
  169. package/lib/theme.cjs +1 -1
  170. package/lib/theme.js +18 -18
  171. package/lib/throttle-CRNq0z-O.js +249 -0
  172. package/lib/throttle-gTTvqDTW.cjs +1 -0
  173. package/lib/toggle-C9tcMm1r.cjs +1 -0
  174. package/lib/toggle-CaSwYCk4.js +89 -0
  175. package/lib/types.d.ts +5 -5
  176. package/lib/{updatePosition-C294Pixi.js → updatePosition-DvfTZHcH.js} +2 -2
  177. package/lib/use-toast-C6zPo25l.cjs +1 -0
  178. package/lib/use-toast-CEOqhXfx.js +97 -0
  179. package/lib/useButtonProps-D-ruygH7.js +165 -0
  180. package/lib/useButtonProps-D9ndBdmA.cjs +1 -0
  181. package/package.json +34 -32
  182. package/lib/ActionMenuButton-C6jGtl3k.cjs +0 -1
  183. package/lib/Drawer-B031ezmA.cjs +0 -2
  184. package/lib/Iframe-BUK2pkOL.cjs +0 -1
  185. package/lib/Indent-_y6N8MIQ.cjs +0 -1
  186. package/lib/Katex-bJXkt-VP.cjs +0 -4
  187. package/lib/LinkEditBlock-ewTApx0K.cjs +0 -5
  188. package/lib/Mermaid-Dwz9o-yM.cjs +0 -2
  189. package/lib/SlashCommandNodeView-BMgQJ4xT.cjs +0 -1
  190. package/lib/Table-B8CHl8jK.cjs +0 -5
  191. package/lib/Twitter-6HYP_upt.cjs +0 -1
  192. package/lib/index-B0d-u29p.js +0 -5425
  193. package/lib/index-De9MZVWQ.cjs +0 -28
  194. package/lib/separator-D8lOAf8f.cjs +0 -1
@@ -0,0 +1,97 @@
1
+ import * as c from "react";
2
+ const d = 1, f = 1e6;
3
+ let T = 0;
4
+ function p() {
5
+ return T = (T + 1) % Number.MAX_SAFE_INTEGER, T.toString();
6
+ }
7
+ const a = /* @__PURE__ */ new Map();
8
+ function S(t) {
9
+ if (a.has(t))
10
+ return;
11
+ const s = setTimeout(() => {
12
+ a.delete(t), n({
13
+ type: "REMOVE_TOAST",
14
+ toastId: t
15
+ });
16
+ }, f);
17
+ a.set(t, s);
18
+ }
19
+ function A(t, s) {
20
+ switch (s.type) {
21
+ case "ADD_TOAST":
22
+ return {
23
+ ...t,
24
+ toasts: [s.toast, ...t.toasts].slice(0, d)
25
+ };
26
+ case "UPDATE_TOAST":
27
+ return {
28
+ ...t,
29
+ toasts: t.toasts.map((e) => e.id === s.toast.id ? { ...e, ...s.toast } : e)
30
+ };
31
+ case "DISMISS_TOAST": {
32
+ const { toastId: e } = s;
33
+ return e ? S(e) : t.toasts.forEach((o) => {
34
+ S(o.id);
35
+ }), {
36
+ ...t,
37
+ toasts: t.toasts.map(
38
+ (o) => o.id === e || e === void 0 ? {
39
+ ...o,
40
+ open: !1
41
+ } : o
42
+ )
43
+ };
44
+ }
45
+ case "REMOVE_TOAST":
46
+ return s.toastId === void 0 ? {
47
+ ...t,
48
+ toasts: []
49
+ } : {
50
+ ...t,
51
+ toasts: t.toasts.filter((e) => e.id !== s.toastId)
52
+ };
53
+ }
54
+ }
55
+ const r = [];
56
+ let u = { toasts: [] };
57
+ function n(t) {
58
+ u = A(u, t), r.forEach((s) => {
59
+ s(u);
60
+ });
61
+ }
62
+ function O({ ...t }) {
63
+ const s = p(), e = (i) => n({
64
+ type: "UPDATE_TOAST",
65
+ toast: { ...i, id: s }
66
+ }), o = () => n({ type: "DISMISS_TOAST", toastId: s });
67
+ return n({
68
+ type: "ADD_TOAST",
69
+ toast: {
70
+ ...t,
71
+ id: s,
72
+ open: !0,
73
+ onOpenChange: (i) => {
74
+ i || o();
75
+ }
76
+ }
77
+ }), {
78
+ id: s,
79
+ dismiss: o,
80
+ update: e
81
+ };
82
+ }
83
+ function E() {
84
+ const [t, s] = c.useState(u);
85
+ return c.useEffect(() => (r.push(s), () => {
86
+ const e = r.indexOf(s);
87
+ e > -1 && r.splice(e, 1);
88
+ }), [t]), {
89
+ ...t,
90
+ toast: O,
91
+ dismiss: (e) => n({ type: "DISMISS_TOAST", toastId: e })
92
+ };
93
+ }
94
+ export {
95
+ O as t,
96
+ E as u
97
+ };
@@ -0,0 +1,165 @@
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import * as d from "@radix-ui/react-tooltip";
3
+ import * as x from "react";
4
+ import { useState as h, useEffect as b, useMemo as u } from "react";
5
+ import { c as C } from "./index-jMN4V2hr.js";
6
+ import { y as T, b as M, S as N } from "./index-BG0kQamI.js";
7
+ import { $ as w, a0 as D } from "./clsx-m_C5j3RU.js";
8
+ import { u as P } from "./index-BGd2HiwP.js";
9
+ let m;
10
+ function p() {
11
+ return m === void 0 && (m = navigator.platform.includes("Mac")), m;
12
+ }
13
+ function U(t) {
14
+ return `${t}`.toLowerCase() === "mod" ? p() ? "⌘" : "Ctrl" : `${t}`.toLowerCase() === "alt" ? p() ? "⌥" : "Alt" : `${t}`.toLowerCase() === "shift" ? p() ? "⇧" : "Shift" : t;
15
+ }
16
+ function q(t) {
17
+ return t.map(U).join(" ");
18
+ }
19
+ const v = d.Provider, G = d.Root, H = d.Trigger, $ = x.forwardRef(({ className: t, sideOffset: e = 4, ...n }, o) => /* @__PURE__ */ y(
20
+ d.Content,
21
+ {
22
+ "data-richtext-portal": !0,
23
+ ref: o,
24
+ sideOffset: e,
25
+ className: C(
26
+ "richtext-z-50 richtext-overflow-hidden richtext-rounded-md !richtext-border-none 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",
27
+ t
28
+ ),
29
+ ...n
30
+ }
31
+ ));
32
+ $.displayName = d.Content.displayName;
33
+ function L(t) {
34
+ const { editor: e } = w(), n = x.useMemo(
35
+ () => e,
36
+ [t, e]
37
+ );
38
+ return D({
39
+ editor: n,
40
+ selector(r) {
41
+ return r.editor ? {
42
+ editor: r.editor,
43
+ editorState: r.editor.state,
44
+ canCommand: r.editor.can
45
+ } : {
46
+ editor: null,
47
+ editorState: void 0,
48
+ canCommand: void 0
49
+ };
50
+ }
51
+ }) || { editor: null };
52
+ }
53
+ function f() {
54
+ return L().editor;
55
+ }
56
+ const g = T(!1);
57
+ function S() {
58
+ return M(g);
59
+ }
60
+ function J() {
61
+ return N(g);
62
+ }
63
+ const E = () => !1;
64
+ function Q(t = E) {
65
+ const e = S(), [n, o] = h(() => {
66
+ const i = t();
67
+ return typeof i == "boolean" ? !i : i;
68
+ }), r = f();
69
+ b(() => {
70
+ if (!r || !t) return;
71
+ const i = () => {
72
+ const c = t();
73
+ o(typeof c == "boolean" ? !c : c);
74
+ };
75
+ return i(), r.on("selectionUpdate", i), r.on("transaction", i), () => {
76
+ r.off("selectionUpdate", i), r.off("transaction", i);
77
+ };
78
+ }, [r, t]);
79
+ const a = u(() => !e || !r ? !0 : typeof n == "boolean" ? n : !1, [e, r, n]), s = u(() => !e || !r, [e, r]);
80
+ return {
81
+ disabled: a,
82
+ // can not action, opacity < 1
83
+ dataState: n,
84
+ // true => show background, false => no background
85
+ editorDisabled: s
86
+ };
87
+ }
88
+ function X(t = E) {
89
+ const e = S(), [n, o] = h({}), [r, a] = h(t()), s = f();
90
+ b(() => {
91
+ if (!s || !t) return;
92
+ const l = () => {
93
+ a(t());
94
+ };
95
+ return l(), s.on("selectionUpdate", l), () => {
96
+ s.off("selectionUpdate", l);
97
+ };
98
+ }, [n, s, t]);
99
+ const i = u(() => !e || !s, [e, s]), c = u(() => !e || !s, [e, s]);
100
+ return {
101
+ disabled: i,
102
+ // can not action, opacity < 1
103
+ dataState: r,
104
+ // true => show background, false => no background
105
+ editorDisabled: c,
106
+ update: () => o({})
107
+ // force update
108
+ };
109
+ }
110
+ function R(t) {
111
+ const e = f();
112
+ return u(() => e ? e.extensionManager.extensions.find(
113
+ (o) => o.name === t
114
+ ) : null, [e, t]);
115
+ }
116
+ function Y(t, e, n) {
117
+ return t < e ? e : t > n ? n : t;
118
+ }
119
+ const j = (t) => typeof t == "number", z = (t) => typeof t == "string", F = (t) => typeof t == "function";
120
+ function Z(t, e = "px") {
121
+ if (!t) return t;
122
+ const n = j(t) ? String(t) : t, o = Number.parseFloat(n), r = n.match(/[%a-z]+$/i), a = r ? r[0] : e;
123
+ return Number.isNaN(o) ? t : o + a;
124
+ }
125
+ function _(t, e) {
126
+ if (!t)
127
+ return !1;
128
+ const { extensions: n = [] } = (t == null ? void 0 : t.extensionManager) ?? {};
129
+ return !!n.find((r) => r.name === e);
130
+ }
131
+ function k(t) {
132
+ return t.map((e) => z(e) ? { value: e, name: e } : e);
133
+ }
134
+ function A(t) {
135
+ const e = f(), n = R(t), { t: o } = P();
136
+ return u(() => {
137
+ if (!e || !n || !o)
138
+ return null;
139
+ const { button: r } = n.options;
140
+ return !r || !F(r) ? null : r({
141
+ editor: e,
142
+ extension: n,
143
+ t: o
144
+ });
145
+ }, [e, n, o]);
146
+ }
147
+ export {
148
+ G as T,
149
+ H as a,
150
+ $ as b,
151
+ X as c,
152
+ Q as d,
153
+ k as e,
154
+ f,
155
+ q as g,
156
+ U as h,
157
+ R as i,
158
+ _ as j,
159
+ Z as k,
160
+ S as l,
161
+ Y as m,
162
+ J as n,
163
+ v as o,
164
+ A as u
165
+ };
@@ -0,0 +1 @@
1
+ "use strict";const P=require("react/jsx-runtime"),N=require("@radix-ui/react-tooltip"),i=require("react"),D=require("./index-BXh8X1ch.cjs"),h=require("./index-NsYff_Ni.cjs"),g=require("./clsx-CXbNJWDD.cjs"),j=require("./index-DgOXAdKt.cjs");function b(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 d=b(N),S=b(i);let p;function m(){return p===void 0&&(p=navigator.platform.includes("Mac")),p}function E(t){return`${t}`.toLowerCase()==="mod"?m()?"⌘":"Ctrl":`${t}`.toLowerCase()==="alt"?m()?"⌥":"Alt":`${t}`.toLowerCase()==="shift"?m()?"⇧":"Shift":t}function q(t){return t.map(E).join(" ")}const w=d.Provider,O=d.Root,U=d.Trigger,T=S.forwardRef(({className:t,sideOffset:e=4,...n},o)=>P.jsx(d.Content,{"data-richtext-portal":!0,ref:o,sideOffset:e,className:D.cn("richtext-z-50 richtext-overflow-hidden richtext-rounded-md !richtext-border-none 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",t),...n}));T.displayName=d.Content.displayName;function R(t){const{editor:e}=g.useCurrentEditor(),n=S.useMemo(()=>e,[t,e]);return g.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 R().editor}const y=h.y(!1);function x(){return h.b(y)}function $(){return h.S(y)}const M=()=>!1;function v(t=M){const e=x(),[n,o]=i.useState(()=>{const s=t();return typeof s=="boolean"?!s:s}),r=f();i.useEffect(()=>{if(!r||!t)return;const s=()=>{const c=t();o(typeof c=="boolean"?!c:c)};return s(),r.on("selectionUpdate",s),r.on("transaction",s),()=>{r.off("selectionUpdate",s),r.off("transaction",s)}},[r,t]);const a=i.useMemo(()=>!e||!r?!0:typeof n=="boolean"?n:!1,[e,r,n]),u=i.useMemo(()=>!e||!r,[e,r]);return{disabled:a,dataState:n,editorDisabled:u}}function _(t=M){const e=x(),[n,o]=i.useState({}),[r,a]=i.useState(t()),u=f();i.useEffect(()=>{if(!u||!t)return;const l=()=>{a(t())};return l(),u.on("selectionUpdate",l),()=>{u.off("selectionUpdate",l)}},[n,u,t]);const s=i.useMemo(()=>!e||!u,[e,u]),c=i.useMemo(()=>!e||!u,[e,u]);return{disabled:s,dataState:r,editorDisabled:c,update:()=>o({})}}function C(t){const e=f();return i.useMemo(()=>e?e.extensionManager.extensions.find(o=>o.name===t):null,[e,t])}function z(t,e,n){return t<e?e:t>n?n:t}const K=t=>typeof t=="number",L=t=>typeof t=="string",V=t=>typeof t=="function";function B(t,e="px"){if(!t)return t;const n=K(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 F(t,e){if(!t)return!1;const{extensions:n=[]}=(t==null?void 0:t.extensionManager)??{};return!!n.find(r=>r.name===e)}function I(t){return t.map(e=>L(e)?{value:e,name:e}:e)}function W(t){const e=f(),n=C(t),{t:o}=j.useLocale();return i.useMemo(()=>{if(!e||!n||!o)return null;const{button:r}=n.options;return!r||!V(r)?null:r({editor:e,extension:n,t:o})},[e,n,o])}exports.Tooltip=O;exports.TooltipContent=T;exports.TooltipProvider=w;exports.TooltipTrigger=U;exports.clamp=z;exports.ensureNameValueOptions=I;exports.getCssUnitWithDefault=B;exports.getShortcutKey=E;exports.getShortcutKeys=q;exports.hasExtension=F;exports.useActive=v;exports.useButtonProps=W;exports.useEditableEditor=x;exports.useEditorInstance=f;exports.useExtension=C;exports.useStoreEditableEditor=$;exports.useToggleActive=_;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remarkablejames/editor",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React",
5
5
  "keywords": [
6
6
  "editor",
@@ -185,6 +185,9 @@
185
185
  ],
186
186
  "./callout": [
187
187
  "./lib/extensions/Callout/index.d.ts"
188
+ ],
189
+ "./paywallseparator": [
190
+ "./lib/extensions/PaywallSeparator/index.d.ts"
188
191
  ]
189
192
  }
190
193
  },
@@ -685,29 +688,18 @@
685
688
  "types": "./lib/extensions/Callout/index.d.ts",
686
689
  "default": "./lib/Callout.js"
687
690
  }
691
+ },
692
+ "./paywallseparator": {
693
+ "require": {
694
+ "types": "./lib/extensions/PaywallSeparator/index.d.ts",
695
+ "default": "./lib/PaywallSeparator.cjs"
696
+ },
697
+ "import": {
698
+ "types": "./lib/extensions/PaywallSeparator/index.d.ts",
699
+ "default": "./lib/PaywallSeparator.js"
700
+ }
688
701
  }
689
702
  },
690
- "scripts": {
691
- "build:lib": "vite build",
692
- "build:lib:dev": "vite build --mode development --watch",
693
- "build:playground": "pnpm build:lib && pnpm --dir ./playground run build",
694
- "docs:dev": "pnpm --parallel --filter docs... dev",
695
- "docs:build": "pnpm --filter docs... build",
696
- "docs:preview": "pnpm -C docs preview",
697
- "prepublishOnly": "pnpm build:lib",
698
- "playground": "pnpm --dir ./playground run dev",
699
- "preview": "pnpm --dir ./playground run preview",
700
- "lint": "oxlint",
701
- "lint:fix": "oxlint --fix",
702
- "fmt": "oxfmt",
703
- "fmt:check": "oxfmt --check",
704
- "type-check": "tsc",
705
- "verify-commit": "verify-commit-msg",
706
- "prepare": "git-scm-hooks",
707
- "release": "bumpp -r",
708
- "gen-changelog": "esno ./scripts/genExtensions.ts && esno ./scripts/changelog.ts",
709
- "gen-contributors": "contributorkit"
710
- },
711
703
  "dependencies": {
712
704
  "@excalidraw/excalidraw": "^0.18.0",
713
705
  "@floating-ui/dom": "^1.7.4",
@@ -829,17 +821,27 @@
829
821
  "node": ">=18.0.0"
830
822
  },
831
823
  "packageManager": "pnpm@8.15.9",
832
- "pnpm": {
833
- "overrides": {
834
- "@excalidraw/excalidraw>nanoid": "3.3.11",
835
- "@excalidraw/mermaid-to-excalidraw": "2.0.0",
836
- "@excalidraw/mermaid-to-excalidraw>nanoid": "5.1.6",
837
- "esbuild": "0.25.12",
838
- "prosemirror-view": "1.41.1"
839
- }
840
- },
841
824
  "git-hooks": {
842
825
  "pre-commit": "npm run lint:fix",
843
826
  "commit-msg": "npm run verify-commit"
827
+ },
828
+ "scripts": {
829
+ "build:lib": "vite build",
830
+ "build:lib:dev": "vite build --mode development --watch",
831
+ "build:playground": "pnpm build:lib && pnpm --dir ./playground run build",
832
+ "docs:dev": "pnpm --parallel --filter docs... dev",
833
+ "docs:build": "pnpm --filter docs... build",
834
+ "docs:preview": "pnpm -C docs preview",
835
+ "playground": "pnpm --dir ./playground run dev",
836
+ "preview": "pnpm --dir ./playground run preview",
837
+ "lint": "oxlint",
838
+ "lint:fix": "oxlint --fix",
839
+ "fmt": "oxfmt",
840
+ "fmt:check": "oxfmt --check",
841
+ "type-check": "tsc",
842
+ "verify-commit": "verify-commit-msg",
843
+ "release": "bumpp -r",
844
+ "gen-changelog": "esno ./scripts/genExtensions.ts && esno ./scripts/changelog.ts",
845
+ "gen-contributors": "contributorkit"
844
846
  }
845
- }
847
+ }
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),a=require("@radix-ui/react-slot"),d=require("react"),c=require("./index-De9MZVWQ.cjs");require("./theme.cjs");const s=d.forwardRef(({asChild:h=!1,tooltip:i,...t},l)=>{var n;const x=c.icons[t.icon],r=h?a.Slot:c.Button;return e.jsxs(c.Tooltip,{children:[e.jsx(c.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}),x&&e.jsx(x,{className:"richtext-ml-1 richtext-size-3 richtext-shrink-0 richtext-text-zinc-500"})]})})}),i&&e.jsx(c.TooltipContent,{children:e.jsxs("div",{className:"richtext-flex richtext-max-w-24 richtext-flex-col richtext-items-center richtext-text-center",children:[i&&e.jsx("div",{children:i}),e.jsx("div",{className:"richtext-flex",children:!!((n=t==null?void 0:t.shortcutKeys)!=null&&n.length)&&e.jsx("span",{children:c.getShortcutKeys(t==null?void 0:t.shortcutKeys)})})]})})]})});exports.ActionMenuButton=s;
@@ -1,2 +0,0 @@
1
- "use strict";const R=require("./clsx-CXbNJWDD.cjs"),i=require("./index-De9MZVWQ.cjs"),e=require("react/jsx-runtime"),m=require("react"),q=require("./index-DgOXAdKt.cjs"),p=require("easydrawer"),D={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function J({editor:t,node:r,updateAttributes:o,getPos:n,selected:v}){const[j,S]=m.useState({width:q.IMAGE_MAX_SIZE,height:q.IMAGE_MAX_SIZE}),[d,c]=m.useState({width:0,height:0}),[M]=m.useState([D.TOP_LEFT,D.TOP_RIGHT,D.BOTTOM_LEFT,D.BOTTOM_RIGHT]),[b,_]=m.useState(!1),[h,u]=m.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=r==null?void 0:r.attrs,f=m.useMemo(()=>{const{src:g,alt:E,width:H,height:L}=r==null?void 0:r.attrs,k=R.isNumber(H)?`${H}px`:H,C=R.isNumber(L)?`${L}px`:L;return{src:g||void 0,alt:E||void 0,style:{width:k||void 0,height:C||void 0}}},[r==null?void 0:r.attrs]),s=m.useMemo(()=>{const{style:{width:g}}=f;return{width:g==="100%"?g:void 0}},[f]);function F(g){c({width:g.target.width,height:g.target.height})}const z=m.useCallback(()=>{t.commands.setNodeSelection(n())},[]),I=m.useCallback(i.throttle(()=>{const{width:g}=getComputedStyle(t.view.dom);S(E=>({...E,width:Number.parseInt(g,10)}))},q.IMAGE_THROTTLE_WAIT_TIME),[t]);function O(g,E){g.preventDefault(),g.stopPropagation();const H=d.width,L=d.height,k=H/L;let C=Number(r.attrs.width),N=Number(r.attrs.height);const y=j.width;C&&!N?(C=C>y?y:C,N=Math.round(C/k)):N&&!C?(C=Math.round(N*k),C=C>y?y:C):!C&&!N?(C=H>y?y:H,N=Math.round(C/k)):C=C>y?y:C,_(!0),u({x:g.clientX,y:g.clientY,w:C,h:N,dir:E})}const x=m.useCallback(i.throttle(g=>{if(g.preventDefault(),g.stopPropagation(),!b)return;const{x:E,w:H,dir:L}=h,k=(g.clientX-E)*(/l/.test(L)?-1:1),{width:C,height:N}=r==null?void 0:r.attrs,y=C/N,G=i.clamp(H+k,q.IMAGE_MIN_SIZE,j.width),Y=Math.round(G/y);o({width:G,height:Y})},q.IMAGE_THROTTLE_WAIT_TIME),[b,h,j,o,r==null?void 0:r.attrs]),a=m.useCallback(g=>{g.preventDefault(),g.stopPropagation(),b&&(u({x:0,y:0,w:0,h:0,dir:""}),_(!1),z())},[b,z]),w=m.useCallback(()=>{document==null||document.addEventListener("mousemove",x,!0),document==null||document.addEventListener("mouseup",a,!0)},[x,a]),A=m.useCallback(()=>{document==null||document.removeEventListener("mousemove",x,!0),document==null||document.removeEventListener("mouseup",a,!0)},[x,a]);m.useEffect(()=>(b?w():A(),()=>{A()}),[b,w,A]);const B=m.useMemo(()=>new ResizeObserver(()=>I()),[I]);return m.useEffect(()=>(B.observe(t.view.dom),()=>{B.disconnect()}),[t.view.dom,B]),e.jsx(R.NodeViewWrapper,{className:"image-view",style:{...s,width:"100%",textAlign:T},children:e.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...s,background:"#fff"},className:`image-view__body ${v?"image-view__body--focused":""} ${b?"image-view__body--resizing":""}`,children:[e.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:z,onLoad:F,src:f.src,style:f.style}),t.view.editable&&(v||b)&&e.jsx("div",{className:"image-resizer",children:M==null?void 0:M.map(g=>e.jsx("span",{className:`image-resizer__handler image-resizer__handler--${g}`,onMouseDown:E=>O(E,g)},`image-dir-${g}`))})]})})}const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ee=t=>{t=t.replace(/\r\n/g,`
2
- `);let r=0,o="";for(;r<t.length;r++){const n=t.charCodeAt(r);n<128?o+=String.fromCharCode(n):n>127&&n<2048?(o+=String.fromCharCode(n>>6|192),o+=String.fromCharCode(63&n|128)):(o+=String.fromCharCode(n>>12|224),o+=String.fromCharCode(n>>6&63|128),o+=String.fromCharCode(63&n|128))}return o},te=t=>{let r,o,n,v,j,S,d,c=0,M="";for(t=ee(t);c<t.length;)r=t.charCodeAt(c++),o=t.charCodeAt(c++),n=t.charCodeAt(c++),v=r>>2,j=(3&r)<<4|o>>4,S=(15&o)<<2|n>>6,d=63&n,isNaN(o)?S=d=64:isNaN(n)&&(d=64),M=M+W.charAt(v)+W.charAt(j)+W.charAt(S)+W.charAt(d);return M},re=t=>typeof t=="string"?"string":typeof SVGElement<"u"&&t instanceof SVGElement?"element":void 0,$=t=>"data:image/svg+xml;base64,"+te(t),oe=t=>$(new XMLSerializer().serializeToString(t)),Z=t=>{switch(re(t)){case"string":return $(t);case"element":return oe(t);default:return t}};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",{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 ne(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 se(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 ie(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 ae(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 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:"M3 3h18v18H3zm2 2v14h14V5z",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:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}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",{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 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:"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 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:"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 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.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 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:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function xe(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 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",{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 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:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Ce(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 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:"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 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.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 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:"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 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",{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 Se="_wrapper_pva9d_1",Me="_tool_pva9d_17",ye="_active_pva9d_37",Ee="_pen_pva9d_41",He="_line_pva9d_48",Ne="_options_pva9d_56",Ae="_colorWrap_pva9d_66",Le="_color_pva9d_66",ke="_colorActive_pva9d_83",l={wrapper:Se,tool:Me,active:ye,pen:Ee,line:He,options:Ne,colorWrap:Ae,color:Le,colorActive:ke},_e=[p.Color4.blackHighlight,p.Color4.ofRGBA(166/255,81/255,167/255,.3),p.Color4.ofRGBA(247/255,78/255,158/255,.3),p.Color4.ofRGBA(166/255,83/255,88/255,.3),p.Color4.ofRGBA(246/255,130/255,28/255,.3),p.Color4.ofRGBA(166/255,198/255,0,.3),p.Color4.ofRGBA(98/255,186/255,70/255,.3)],U=[p.Color4.black,p.Color4.fromHex("#007AFF"),p.Color4.fromHex("#A651A7"),p.Color4.fromHex("#F74E9E"),p.Color4.fromHex("#FF5358"),p.Color4.fromHex("#F6821C"),p.Color4.fromHex("#FFC600"),p.Color4.fromHex("#62BA46"),p.Color4.fromHex("#E6BFE8"),p.Color4.fromHex("#FEA3D2"),p.Color4.fromHex("#FFA0A3"),p.Color4.fromHex("#FBC276"),p.Color4.fromHex("#FFFB85"),p.Color4.fromHex("#AADC99")];function ze({onChange:t}){const[r,o]=m.useState(p.Color4.blackHighlight);return e.jsx("div",{className:l.colorWrap,children:_e.map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})}function V({onChange:t}){const[r,o]=m.useState(p.Color4.black);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l.colorWrap,children:U.slice(0,7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))}),e.jsx("div",{className:l.colorWrap,children:U.slice(7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})]})}function Be({setColorPen:t,setThicknessPen:r}){const[o,n]=m.useState(2);return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:v=>t(v)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{max:10,min:1,step:.1,type:"range",value:o,onChange:v=>{r(Number.parseFloat(v.target.value)),n(Number.parseFloat(v.target.value))}})})]})}function qe({setColorHighlight:t}){return e.jsx("div",{className:l.options,children:e.jsx(ze,{onChange:r=>t(r)})})}function Pe({changeColorShape:t,changeBorderColorShape:r,onThicknessChange:o}){return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:n=>t(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx(V,{onChange:n=>r(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:n=>{o(Number.parseFloat(n.target.value))}})})]})}function X(t){const{setColorPen:r,refEditor:o,setThicknessPen:n,setColorHighlight:v,changeBorderColorShape:j,onUndo:S,changeColorShape:d,changeShape:c,onThicknessChange:M,onRedo:b,onClear:_}=t,[h,u]=m.useState(null),[T,f]=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:i.cn(l.tool,{[l.active]:h==="select"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="select"){u(null),s[0].setEnabled(!1);return}u("select"),s[0].setEnabled(!0)},children:e.jsx(le,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="text"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(s[1]),h==="text"){s[1].setEnabled(!1),u(null);return}u("text"),s[1].setEnabled(!0)},children:e.jsx(ne,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="pencil"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="pencil"){u(null),s[2].setEnabled(!1);return}u("pencil"),s[2].setEnabled(!0)},children:e.jsx(se,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="highlighter"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="highlighter"){u(null),s[3].setEnabled(!1);return}u("highlighter"),s[3].setEnabled(!0)},children:e.jsx(ie,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="eraser"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="eraser"){u(null),s[4].setEnabled(!1);return}u("eraser"),s[4].setEnabled(!0)},children:e.jsx(ae,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===0}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(0),f(0)},children:e.jsx(ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===1}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(1),f(1)},children:e.jsx(he,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===2}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(2),f(2)},children:e.jsx(ue,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===3}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(3),f(3)},children:e.jsx(de,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===4}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(4),f(4)},children:e.jsx(ge,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===5}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(5),f(5)},children:e.jsx(me,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===6}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(6),f(6)},children:e.jsx(pe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===7}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(7),f(7)},children:e.jsx(Ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===8}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(8),f(8)},children:e.jsx(fe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===9}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(9),f(9)},children:e.jsx(Te,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===10}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(10),f(10)},children:e.jsx(je,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===11}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(11),f(11)},children:e.jsx(be,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool),onClick:S,children:e.jsx(xe,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:b,children:e.jsx(we,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:_,children:e.jsx(ve,{})})]}),e.jsxs("div",{className:l.optionsWrap,children:[h==="pencil"&&e.jsx(Be,{setColorPen:r,setThicknessPen:n}),h==="highlighter"&&e.jsx(qe,{setColorHighlight:v}),h==="shapes"&&e.jsx(Pe,{changeBorderColorShape:j,changeColorShape:d,changeShape:c,onThicknessChange:M})]})]})})}function K(t=8){return Math.random().toString(36).substring(2,t+2)}let P=!1;function Re(){const t=i.useEditorInstance(),r=i.useButtonProps(Q.name),{isActive:o=void 0,upload:n}=(r==null?void 0:r.componentProps)??{},{editorDisabled:v}=i.useToggleActive(o),[j,S]=m.useState(!1),d=m.useRef(null),c=m.useRef(null),M=()=>{(async()=>{const a=document.querySelector("#easydrawer");a&&(d.current=new p.Editor(a,{wheelEventsEnabled:!1,disableZoom:!0}),c.current=p.makeDropdownToolbar(d.current),c.current.addDefaultToolWidgets())})()};m.useEffect(()=>{j&&setTimeout(()=>{M()},200)},[j]);const b=async()=>{if(d.current){const x=d.current.toSVG(),a=x.outerHTML,w=`drawer-${K()}.svg`;let A=Z(x.outerHTML);if(n){const B=i.dataURLtoFile(A,w);A=await n(B)}t==null||t.chain().focus().setDrawer({type:"drawer",src:A,alt:encodeURIComponent(a),width:426,height:212},!!a).run()}S(!1)},_=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setColor(x),w.serializeState())},h=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setThickness(x),w.serializeState())},u=x=>{const a=d.current.toolController.getPrimaryTools()[3],w=c.current.getWidgetById("pen-2");a&&w&&(a.setColor(x),w.serializeState())},T=x=>{const a=c.current.getWidgetById("shape");a&&a.setShapeType(x)},f=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setColor(x),w.serializeState())},s=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setThickness(x),w.serializeState())},F=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setBorderColor(x),w.serializeState())},z=()=>{if(P){for(;d.current.history.redoStackSize>0;)d.current.history.redo();P=!1;return}d.current.history.undo()},I=()=>{P||d.current.history.redo()},O=()=>{if(!P){for(;d.current.history.undoStackSize>0;)z();P=!0}};return r?e.jsxs(i.Dialog,{onOpenChange:S,open:j,children:[e.jsx(i.DialogTrigger,{asChild:!0,children:e.jsx(i.ActionButton,{disabled:v,action:()=>{v||S(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),e.jsxs(i.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[e.jsx(i.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(X,{changeBorderColorShape:F,changeColorShape:f,changeShape:T,onClear:O,onRedo:I,onThicknessChange:s,onUndo:z,refEditor:d,setColorHighlight:u,setColorPen:_,setThicknessPen:h})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{onClick:b,type:"button",children:"Save changes"})})]})]}):e.jsx(e.Fragment,{})}const Q=i.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:r,extension:o})=>{var n;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:r("editor.drawer.tooltip"),upload:(n=o==null?void 0:o.options)==null?void 0:n.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("width");return n?Number.parseInt(n,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("height");return n?Number.parseInt(n,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return R.ReactNodeViewRenderer(J)},addCommands(){return{setDrawer:(t,r)=>({commands:o,editor:n})=>r?o.insertContent({type:this.name,attrs:t}):o.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageDrawer:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:r}=t;return["div",{style:r?`text-align: ${r};`:"",class:"imageDrawer"},["img",R.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:t=>{const r=t.querySelector("img"),o=r==null?void 0:r.getAttribute("width"),n=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.ControlDrawer=X;exports.Drawer=Q;exports.RichTextDrawer=Re;exports.i=Z;exports.shortId=K;
@@ -1 +0,0 @@
1
- "use strict";const m=require("./clsx-CXbNJWDD.cjs"),s=require("react/jsx-runtime"),k=require("re-resizable"),b=require("react"),u=require("./index-De9MZVWQ.cjs");require("./theme.cjs");const p={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 y(e){const t=p.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 S(e){const t=p.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 I(e){const t=p.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 R(e){const t=p.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 P(e,t){return t.src=e,t.validId=!0,t}function j(e,t){return t.src=e,t.validId=!0,t}function M(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function N(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function q(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function U(e){const t=p.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function A(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function D(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function L(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function _(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function $(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function T(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=p[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 z(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 v(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=z(e);if(t=T(i,e,t),!t.validLink)return t;switch(i){case"youtube":return y(t);case"youku":return S(t);case"bilibili":return I(t);case"qqvideo":return R(t);case"amap":return P(e,t);case"baidu_map":return j(e,t);case"googlemaps":return M(e,t);case"modao":return N(t);case"lanhu":return q(t);case"figma":return U(t);case"canva":return A(e,t);case"processon":return D(e,t);case"codepen":return L(t);case"jinshuju":return _(e,t);case"iframe":return $(e,t);default:return e}}const Y="_wrap_5y04w_1",C="_innerWrap_5y04w_15",g={wrap:Y,innerWrap:C};function E({editor:e,node:t,updateAttributes:i}){const r=u.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,l]=b.useState("");function h(){if(!a)return;const d=v(a);e.chain().updateAttributes(f.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const x=b.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(m.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(u.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>l(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(u.Button,{className:"richtext-w-[60px]",onClick:h,children:"OK"})]}),n&&s.jsx(k.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,B,V,w)=>{x({width:Number.parseInt(c)+w.width,height:Number.parseInt(o)+w.height})},children:s.jsx("div",{className:m.clsx(g.wrap,"render-wrapper"),children:s.jsx("div",{className:g.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px]",src:n})})})})]})}function H(){const e=u.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:l}=u.useToggleActive(o),h=()=>{a||c&&(c(),l())};return e?s.jsx(u.ActionButton,{action:h,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const f=m.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:u.getDatasetAttribute("width")},height:{default:300,parseHTML:u.getDatasetAttribute("height")},src:{default:null,parseHTML:u.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",m.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[m.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return m.ReactNodeViewRenderer(E)}});exports.Iframe=f;exports.RichTextIframe=H;exports.getServiceSrc=v;
@@ -1 +0,0 @@
1
- "use strict";const p=require("./clsx-CXbNJWDD.cjs"),l=require("@tiptap/pm/state"),c=require("react/jsx-runtime"),u=require("./index-De9MZVWQ.cjs");require("react");require("./theme.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 b(t,e,n){return t<e?e:t>n?n:t}function A(t,e,n,o){const{doc:s,selection:r}=t;if(!s||!r||!(r instanceof l.TextSelection||r instanceof l.AllSelection))return t;const{from:i,to:d}=r;return s.nodesBetween(i,d,(m,x)=>{const I=m.type;return n.includes(I.name)?(t=h(t,x,e),!1):!p.isList(m.type.name,o.extensionManager.extensions)}),t}function h(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o)return t;const i=b((o.attrs.indent||0)+n,0,7);if(i===o.attrs.indent)return t;const d={...o.attrs,indent:i};return t.setNodeMarkup(e,o.type,d,o.marks)}function f({delta:t,types:e}){return({state:n,dispatch:o,editor:s})=>{const{selection:r}=n;let{tr:i}=n;return i=i.setSelection(r),i=A(i,t,e,s),i.docChanged?(o&&o(i),!0):!1}}function T(){const t=u.useButtonProps(y.name),{indent:e,outdent:n}=(t==null?void 0:t.componentProps)??{},{editorDisabled:o}=u.useToggleActive(),s=()=>{o||e!=null&&e.action&&(e==null||e.action())},r=()=>{o||n!=null&&n.action&&(n==null||n.action())};return t?c.jsxs(c.Fragment,{children:[c.jsx(u.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(u.ActionButton,{action:r,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 y=p.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,r;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:((r=o.options.shortcutKeys)==null?void 0:r[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=y;exports.IndentProps=a;exports.RichTextIndent=T;exports.setNodeIndentMarkup=h;