reactjs-tiptap-editor 1.0.16 → 1.0.17
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-B_E2mbAW.cjs +1 -0
- package/lib/{ActionMenuButton-a8LhmHXe.js → ActionMenuButton-lsIBc9sU.js} +12 -16
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +28 -32
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +11 -13
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +13 -15
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +15 -17
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +56 -62
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +12 -13
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +8 -10
- package/lib/CodeBlock.cjs +29 -29
- package/lib/CodeBlock.js +11 -14
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +9 -11
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +26 -29
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -9
- package/lib/{Drawer-CbOJ1Igo.js → Drawer-DQ4CxBwG.js} +23 -29
- package/lib/Drawer-FUeUKshi.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 +13 -15
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +276 -5
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +19 -21
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +8 -10
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -10
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +19 -20
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +27 -28
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +24 -27
- package/lib/History.cjs +1 -1
- package/lib/History.js +25 -28
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +8 -10
- package/lib/{Iframe-CmjbQQcz.js → Iframe-CTajPyzs.js} +34 -38
- package/lib/Iframe-EVWXCqe4.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 +4 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +109 -114
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +15 -18
- package/lib/{Indent-BoG-vpIE.js → Indent-BGEHlRx_.js} +24 -26
- package/lib/Indent-q9cEWAa_.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +11 -13
- package/lib/Katex-ClqcEnN_.cjs +4 -0
- package/lib/{Katex-ByL9snce.js → Katex-tMh4bfBb.js} +19 -24
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +17 -20
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-Ckih17pU.js → LinkEditBlock-CA5NhP-m.js} +19 -26
- package/lib/LinkEditBlock-DZXk4ln_.cjs +5 -0
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +31 -36
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -29
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +13 -15
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +62 -69
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +5 -5
- package/lib/SlashCommandNodeView-CZoM3ZlS.cjs +1 -0
- package/lib/{SlashCommandNodeView-B2g1MbgN.js → SlashCommandNodeView-DLuqbX2o.js} +64 -69
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +12 -14
- package/lib/{Table-BEwrZVup.js → Table-BC4Lbqzn.js} +27 -29
- package/lib/Table-BmDopO43.cjs +9 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +18 -20
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +29 -33
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +16 -20
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -9
- package/lib/Twitter-BbMD3Ybp.cjs +1 -0
- package/lib/{Twitter-4U_ZBhpv.js → Twitter-D8Cbgl7g.js} +17 -23
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -270
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +543 -552
- package/lib/{clsx-DSzxBzvL.js → clsx-DaPvp9ji.js} +23 -23
- package/lib/components/ReactBus.d.ts +11 -0
- package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -0
- package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -0
- package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +5 -0
- package/lib/{dropdown-menu-eUeBXQeA.cjs → dropdown-menu-C_F7LEy5.cjs} +1 -1
- package/lib/{dropdown-menu-CW3Kthwy.js → dropdown-menu-q6RL_fkA.js} +1 -1
- package/lib/{index-4bHF5ovf.js → index-BDYJ8Ph2.js} +1 -1
- package/lib/index-BnVcq33n.cjs +1 -0
- package/lib/{index-DR5tIdL7.js → index-Do_dsOGB.js} +1 -1
- package/lib/{index-CpTykZBR.js → index-DqruLhsu.js} +1 -1
- package/lib/{index-D8li6EQ4.js → index-Qcl3BG94.js} +1 -1
- package/lib/index-RcSPeQHn.js +4941 -0
- package/lib/index.cjs +3 -3
- package/lib/index.js +45 -49
- package/lib/{popover-CeY3RbI5.js → popover-CtinPbiy.js} +1 -1
- package/lib/{popover-C6Cya3Cz.cjs → popover-DIMT3pae.cjs} +1 -1
- package/lib/{renderNodeView-CSazLrKF.js → renderNodeView-BEkECnnY.js} +2 -2
- package/lib/{select-Doa_-jkZ.cjs → select-CYyIeImH.cjs} +1 -1
- package/lib/{select-F0ZZ3VZB.js → select-CmV5uTXr.js} +1 -1
- package/lib/separator-BLp6xpSY.cjs +1 -0
- package/lib/{separator-Cjn4YH8a.js → separator-C7luvaG8.js} +13 -15
- package/lib/store/store.d.ts +2 -22
- package/lib/style.css +1 -1
- package/lib/{textarea-tOsPnxHf.js → textarea-CkVKMPqK.js} +1 -1
- package/lib/{textarea-BAolHF_W.cjs → textarea-Cn75Cm2n.cjs} +1 -1
- package/lib/{updatePosition-CDK7OR0i.js → updatePosition-DRmKQBGm.js} +2 -2
- package/lib/utils/checkIsVideoUrl.d.ts +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +1 -0
- package/lib/utils/mitt.d.ts +6 -3
- package/package.json +1 -1
- package/lib/ActionMenuButton-BYu0NyVo.cjs +0 -1
- package/lib/Drawer-DNaDMoAk.cjs +0 -1
- package/lib/Excalidraw-DnHTVOj8.js +0 -355
- package/lib/Excalidraw-DxfO1lQ_.cjs +0 -1
- package/lib/Icon-C0TJMAOm.js +0 -12
- package/lib/Icon-DzK0_ztP.cjs +0 -1
- package/lib/Iframe-BSNCsofW.cjs +0 -1
- package/lib/Image-BZEFuS0P.js +0 -925
- package/lib/Image-iKsGKjvg.cjs +0 -1
- package/lib/Indent-Bou16OcB.cjs +0 -1
- package/lib/Katex-BqDocr3a.cjs +0 -4
- package/lib/LinkEditBlock-B0I0EUrt.cjs +0 -5
- package/lib/SlashCommandNodeView-BEJhEzba.cjs +0 -1
- package/lib/Table-BclWwp6P.cjs +0 -9
- package/lib/Twitter-Dtq6PEMC.cjs +0 -1
- package/lib/button-Bwn6gUuS.js +0 -43
- package/lib/button-CqJztfH2.cjs +0 -1
- package/lib/checkbox-BAzbZY2Y.cjs +0 -1
- package/lib/checkbox-B_rpz5Xq.js +0 -27
- package/lib/dialog-CJvpoeMm.js +0 -101
- package/lib/dialog-CWYTvz5J.cjs +0 -1
- package/lib/events.constant-Dq21NPdV.cjs +0 -1
- package/lib/events.constant-do95b767.js +0 -21
- package/lib/extensions/Image/store.d.ts +0 -4
- package/lib/extensions/Video/store.d.ts +0 -4
- package/lib/file-BLas99n7.js +0 -43
- package/lib/file-i7e4nQY2.cjs +0 -1
- package/lib/index-CL7JP-Xz.js +0 -426
- package/lib/index-Cn-t3Zxw.cjs +0 -1
- package/lib/index-DoiuU6VA.js +0 -2315
- package/lib/index-VhKd73hZ.cjs +0 -1
- package/lib/input-B1egKb-t.js +0 -21
- package/lib/input-ZGRt7lWR.cjs +0 -1
- package/lib/isNumber-BTYSVlKo.cjs +0 -1
- package/lib/isNumber-ClwLypY2.js +0 -15
- package/lib/label-Cjrzc5H2.js +0 -19
- package/lib/label-tzSPdqui.cjs +0 -1
- package/lib/separator-CUh5Y7Rh.cjs +0 -1
- package/lib/store/fast-context.d.ts +0 -7
- package/lib/store-BsJz5QRC.js +0 -10
- package/lib/store-DjkMIIEN.cjs +0 -1
- package/lib/tabs-BP8ypR_m.cjs +0 -1
- package/lib/tabs-CBDjOLl_.js +0 -46
- package/lib/throttle-D040PfWL.js +0 -249
- package/lib/throttle-gTTvqDTW.cjs +0 -1
- package/lib/toggle-C_SSvDRy.cjs +0 -1
- package/lib/toggle-DEerYRil.js +0 -99
- package/lib/tooltip-BJIvosho.js +0 -24
- package/lib/tooltip-FS1rsvd3.cjs +0 -1
- package/lib/useButtonProps-CtZCbMQu.js +0 -136
- package/lib/useButtonProps-Cz4W5dC8.cjs +0 -1
- package/lib/utils/_event.d.ts +0 -13
- package/lib/utils/customEvents/customEvents.d.ts +0 -3
package/lib/History.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as N, y as te, F as V, x as G, T as H, v as _, S as A, U as W, V as ne, E as C, W as re, X as ie, Y as oe, q as se } from "./clsx-DaPvp9ji.js";
|
|
2
2
|
import { Plugin as I, PluginKey as b } from "@tiptap/pm/state";
|
|
3
3
|
import { DecorationSet as O, Decoration as R } from "@tiptap/pm/view";
|
|
4
|
-
import { k as le, D as ae, a as de } from "./index-
|
|
4
|
+
import { k as le, D as ae, a as de } from "./index-DqruLhsu.js";
|
|
5
5
|
import { jsx as T, Fragment as j } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
6
|
+
import { u as U, e as X, A as Y, i as ce } from "./index-RcSPeQHn.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import "./index-DoiuU6VA.js";
|
|
9
8
|
import "./theme.js";
|
|
10
|
-
import { u as X, b as Y } from "./useButtonProps-CtZCbMQu.js";
|
|
11
|
-
import { i as ce } from "./index-CL7JP-Xz.js";
|
|
12
9
|
function ue(i = {}) {
|
|
13
10
|
return new N({
|
|
14
11
|
view(e) {
|
|
@@ -102,7 +99,7 @@ class f extends A {
|
|
|
102
99
|
return f.valid(n) ? new f(n) : A.near(n);
|
|
103
100
|
}
|
|
104
101
|
content() {
|
|
105
|
-
return
|
|
102
|
+
return G.empty;
|
|
106
103
|
}
|
|
107
104
|
eq(e) {
|
|
108
105
|
return e instanceof f && e.head == this.head;
|
|
@@ -160,7 +157,7 @@ class f extends A {
|
|
|
160
157
|
for (; ; ) {
|
|
161
158
|
let s = t > 0 ? o.firstChild : o.lastChild;
|
|
162
159
|
if (!s) {
|
|
163
|
-
if (o.isAtom && !o.isText && !
|
|
160
|
+
if (o.isAtom && !o.isText && !_.isSelectable(o)) {
|
|
164
161
|
e = e.doc.resolve(r + o.nodeSize * t), n = !1;
|
|
165
162
|
continue e;
|
|
166
163
|
}
|
|
@@ -190,7 +187,7 @@ class F {
|
|
|
190
187
|
return f.valid(t) ? new f(t) : A.near(t);
|
|
191
188
|
}
|
|
192
189
|
}
|
|
193
|
-
function
|
|
190
|
+
function J(i) {
|
|
194
191
|
return i.isAtom || i.spec.isolating || i.spec.createGapCursor;
|
|
195
192
|
}
|
|
196
193
|
function fe(i) {
|
|
@@ -202,7 +199,7 @@ function fe(i) {
|
|
|
202
199
|
continue;
|
|
203
200
|
}
|
|
204
201
|
for (let r = n.child(t - 1); ; r = r.lastChild) {
|
|
205
|
-
if (r.childCount == 0 && !r.inlineContent ||
|
|
202
|
+
if (r.childCount == 0 && !r.inlineContent || J(r.type))
|
|
206
203
|
return !0;
|
|
207
204
|
if (r.inlineContent)
|
|
208
205
|
return !1;
|
|
@@ -219,7 +216,7 @@ function he(i) {
|
|
|
219
216
|
continue;
|
|
220
217
|
}
|
|
221
218
|
for (let r = n.child(t); ; r = r.firstChild) {
|
|
222
|
-
if (r.childCount == 0 && !r.inlineContent ||
|
|
219
|
+
if (r.childCount == 0 && !r.inlineContent || J(r.type))
|
|
223
220
|
return !0;
|
|
224
221
|
if (r.inlineContent)
|
|
225
222
|
return !1;
|
|
@@ -250,7 +247,7 @@ function x(i, e) {
|
|
|
250
247
|
const t = i == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
251
248
|
return function(n, r, o) {
|
|
252
249
|
let s = n.selection, l = e > 0 ? s.$to : s.$from, a = s.empty;
|
|
253
|
-
if (s instanceof
|
|
250
|
+
if (s instanceof H) {
|
|
254
251
|
if (!o.endOfTextblock(t) || l.depth == 0)
|
|
255
252
|
return !1;
|
|
256
253
|
a = !1, l = n.doc.resolve(e > 0 ? l.after() : l.before());
|
|
@@ -266,7 +263,7 @@ function ve(i, e, t) {
|
|
|
266
263
|
if (!f.valid(n))
|
|
267
264
|
return !1;
|
|
268
265
|
let r = i.posAtCoords({ left: t.clientX, top: t.clientY });
|
|
269
|
-
return r && r.inside > -1 &&
|
|
266
|
+
return r && r.inside > -1 && _.isSelectable(i.state.doc.nodeAt(r.inside)) ? !1 : (i.dispatch(i.state.tr.setSelection(new f(n))), !0);
|
|
270
267
|
}
|
|
271
268
|
function we(i, e) {
|
|
272
269
|
if (e.inputType != "insertCompositionText" || !(i.state.selection instanceof f))
|
|
@@ -277,8 +274,8 @@ function we(i, e) {
|
|
|
277
274
|
let r = V.empty;
|
|
278
275
|
for (let s = n.length - 1; s >= 0; s--)
|
|
279
276
|
r = V.from(n[s].createAndFill(null, r));
|
|
280
|
-
let o = i.state.tr.replace(t.pos, t.pos, new
|
|
281
|
-
return o.setSelection(
|
|
277
|
+
let o = i.state.tr.replace(t.pos, t.pos, new G(r, 0, 0));
|
|
278
|
+
return o.setSelection(H.near(o.doc.resolve(t.pos + 1))), i.dispatch(o), !1;
|
|
282
279
|
}
|
|
283
280
|
function ye(i) {
|
|
284
281
|
if (!(i.selection instanceof f))
|
|
@@ -315,9 +312,9 @@ m.prototype.map = function(e, t, n) {
|
|
|
315
312
|
}, t, n), r;
|
|
316
313
|
};
|
|
317
314
|
m.from = function(e) {
|
|
318
|
-
return e instanceof m ? e : e && e.length ? new
|
|
315
|
+
return e instanceof m ? e : e && e.length ? new Z(e) : m.empty;
|
|
319
316
|
};
|
|
320
|
-
var
|
|
317
|
+
var Z = /* @__PURE__ */ (function(i) {
|
|
321
318
|
function e(n) {
|
|
322
319
|
i.call(this), this.values = n;
|
|
323
320
|
}
|
|
@@ -349,7 +346,7 @@ var J = /* @__PURE__ */ (function(i) {
|
|
|
349
346
|
return 0;
|
|
350
347
|
}, Object.defineProperties(e.prototype, t), e;
|
|
351
348
|
})(m);
|
|
352
|
-
m.empty = new
|
|
349
|
+
m.empty = new Z([]);
|
|
353
350
|
var Ce = /* @__PURE__ */ (function(i) {
|
|
354
351
|
function e(t, n) {
|
|
355
352
|
i.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
|
|
@@ -902,20 +899,20 @@ var Oe = C.create({
|
|
|
902
899
|
};
|
|
903
900
|
}
|
|
904
901
|
});
|
|
905
|
-
function
|
|
902
|
+
function Le() {
|
|
906
903
|
var u;
|
|
907
|
-
const i =
|
|
904
|
+
const i = U(ee.name), {
|
|
908
905
|
icon: e = void 0,
|
|
909
906
|
tooltip: t = void 0,
|
|
910
907
|
shortcutKeys: n = void 0,
|
|
911
908
|
tooltipOptions: r = {},
|
|
912
909
|
action: o = void 0,
|
|
913
910
|
isActive: s = void 0
|
|
914
|
-
} = ((u = i == null ? void 0 : i.componentProps) == null ? void 0 : u.undo) ?? {}, { disabled: l } =
|
|
911
|
+
} = ((u = i == null ? void 0 : i.componentProps) == null ? void 0 : u.undo) ?? {}, { disabled: l } = X(s), a = ce[e], d = () => {
|
|
915
912
|
l || o && o();
|
|
916
913
|
};
|
|
917
914
|
return !i || !a ? /* @__PURE__ */ T(j, {}) : /* @__PURE__ */ T(
|
|
918
|
-
|
|
915
|
+
Y,
|
|
919
916
|
{
|
|
920
917
|
action: d,
|
|
921
918
|
disabled: l,
|
|
@@ -926,20 +923,20 @@ function _e() {
|
|
|
926
923
|
}
|
|
927
924
|
);
|
|
928
925
|
}
|
|
929
|
-
function
|
|
926
|
+
function Be() {
|
|
930
927
|
var d;
|
|
931
|
-
const i =
|
|
928
|
+
const i = U(ee.name), {
|
|
932
929
|
icon: e = void 0,
|
|
933
930
|
tooltip: t = void 0,
|
|
934
931
|
shortcutKeys: n = void 0,
|
|
935
932
|
tooltipOptions: r = {},
|
|
936
933
|
action: o = void 0,
|
|
937
934
|
isActive: s = void 0
|
|
938
|
-
} = ((d = i == null ? void 0 : i.componentProps) == null ? void 0 : d.redo) ?? {}, { disabled: l } =
|
|
935
|
+
} = ((d = i == null ? void 0 : i.componentProps) == null ? void 0 : d.redo) ?? {}, { disabled: l } = X(s), a = () => {
|
|
939
936
|
l || o && o();
|
|
940
937
|
};
|
|
941
938
|
return i ? /* @__PURE__ */ T(
|
|
942
|
-
|
|
939
|
+
Y,
|
|
943
940
|
{
|
|
944
941
|
action: a,
|
|
945
942
|
disabled: l,
|
|
@@ -989,6 +986,6 @@ const ee = /* @__PURE__ */ Oe.extend({
|
|
|
989
986
|
});
|
|
990
987
|
export {
|
|
991
988
|
ee as History,
|
|
992
|
-
|
|
993
|
-
|
|
989
|
+
Be as RichTextRedo,
|
|
990
|
+
Le as RichTextUndo
|
|
994
991
|
};
|
package/lib/HorizontalRule.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./clsx-CXbNJWDD.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./clsx-CXbNJWDD.cjs"),l=require("@tiptap/pm/state"),p=require("./index-BnVcq33n.cjs"),m=require("react/jsx-runtime");require("react");require("./theme.cjs");var y=i.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",i.mergeAttributes(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,n)=>n.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:n})=>{if(!i.canInsertNode(n,n.schema.nodes[this.name]))return!1;const{selection:r}=n,{$to:s}=r,c=t();return i.isNodeSelection(r)?c.insertContentAt(s.pos,{type:this.name}):c.insertContent({type:this.name}),c.command(({state:a,tr:e,dispatch:h})=>{if(h){const{$to:o}=e.selection,u=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(l.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(l.NodeSelection.create(e.doc,o.pos)):e.setSelection(l.TextSelection.create(e.doc,o.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,T=d==null?void 0:d.create();T&&(e.insert(u,T),e.setSelection(l.TextSelection.create(e.doc,u+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[i.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});function A(){const t=p.useButtonProps(f.name),{icon:n=void 0,tooltip:r=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:a=void 0,isActive:e=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:h,disabled:o,update:u}=p.useToggleActive(e),d=()=>{o||a&&(a(),u())};return t?m.jsx(p.ActionButton,{action:d,dataState:h,disabled:o,icon:n,shortcutKeys:s,tooltip:r,tooltipOptions:c}):m.jsx(m.Fragment,{})}const f=y.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:n,t:r,extension:s})=>({component:p.ActionButton,componentProps:{action:()=>n.commands.setHorizontalRule(),disabled:!n.can().setHorizontalRule(),icon:"Minus",shortcutKeys:s.options.shortcutKeys??["mod","alt","S"],tooltip:r("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}},renderHTML(){return["div",i.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});exports.HorizontalRule=f;exports.RichTextHorizontalRule=A;
|
package/lib/HorizontalRule.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { N as T, n as A, o as y, q as H, m as h } from "./clsx-
|
|
1
|
+
import { N as T, n as A, o as y, q as H, m as h } from "./clsx-DaPvp9ji.js";
|
|
2
2
|
import { TextSelection as u, NodeSelection as R } from "@tiptap/pm/state";
|
|
3
|
-
import { A as f } from "./
|
|
4
|
-
import { jsx as m, Fragment as
|
|
3
|
+
import { u as M, d as v, A as f } from "./index-RcSPeQHn.js";
|
|
4
|
+
import { jsx as m, Fragment as z } from "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
|
-
import "./index-DoiuU6VA.js";
|
|
7
6
|
import "./theme.js";
|
|
8
|
-
import { u as v, a as z } from "./useButtonProps-CtZCbMQu.js";
|
|
9
7
|
var S = T.create({
|
|
10
8
|
name: "horizontalRule",
|
|
11
9
|
addOptions() {
|
|
@@ -57,15 +55,15 @@ var S = T.create({
|
|
|
57
55
|
];
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
58
|
+
function w() {
|
|
59
|
+
const t = M(b.name), {
|
|
62
60
|
icon: n = void 0,
|
|
63
61
|
tooltip: r = void 0,
|
|
64
62
|
shortcutKeys: s = void 0,
|
|
65
63
|
tooltipOptions: i = {},
|
|
66
64
|
action: a = void 0,
|
|
67
65
|
isActive: e = void 0
|
|
68
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: l, disabled: o, update: c } =
|
|
66
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: l, disabled: o, update: c } = v(e), d = () => {
|
|
69
67
|
o || a && (a(), c());
|
|
70
68
|
};
|
|
71
69
|
return t ? /* @__PURE__ */ m(
|
|
@@ -79,7 +77,7 @@ function I() {
|
|
|
79
77
|
tooltip: r,
|
|
80
78
|
tooltipOptions: i
|
|
81
79
|
}
|
|
82
|
-
) : /* @__PURE__ */ m(
|
|
80
|
+
) : /* @__PURE__ */ m(z, {});
|
|
83
81
|
}
|
|
84
82
|
const b = /* @__PURE__ */ S.extend({
|
|
85
83
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -117,5 +115,5 @@ const b = /* @__PURE__ */ S.extend({
|
|
|
117
115
|
});
|
|
118
116
|
export {
|
|
119
117
|
b as HorizontalRule,
|
|
120
|
-
|
|
118
|
+
w as RichTextHorizontalRule
|
|
121
119
|
};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { h as v, j as x, N as k, k as y, n as S, m as I } from "./clsx-
|
|
1
|
+
import { h as v, j as x, N as k, k as y, n as S, m as I } from "./clsx-DaPvp9ji.js";
|
|
2
2
|
import { jsxs as f, jsx as d, Fragment as P } from "react/jsx-runtime";
|
|
3
3
|
import { useState as M, useCallback as R } from "react";
|
|
4
4
|
import { Resizable as N } from "re-resizable";
|
|
5
5
|
import { g as l } from "./dom-dataset-CIEeltF6.js";
|
|
6
|
-
import {
|
|
7
|
-
import { a as U } from "./index-DoiuU6VA.js";
|
|
6
|
+
import { G as j, j as U, B as q, u as A, d as L, A as D } from "./index-RcSPeQHn.js";
|
|
8
7
|
import "./theme.js";
|
|
9
|
-
import { u as q, a as A } from "./useButtonProps-CtZCbMQu.js";
|
|
10
|
-
import { I as L } from "./input-B1egKb-t.js";
|
|
11
|
-
import { B as D } from "./button-Bwn6gUuS.js";
|
|
12
8
|
const m = {
|
|
13
9
|
youtube: {
|
|
14
10
|
example: "https://www.youtube.com/watch?v=I4sMhHbHYXM",
|
|
@@ -111,15 +107,15 @@ function _(e) {
|
|
|
111
107
|
e.validLink = !0;
|
|
112
108
|
const r = i.split("="), n = r.length;
|
|
113
109
|
if (n > 0) {
|
|
114
|
-
const
|
|
115
|
-
e.src = `${t.srcPrefix}/${
|
|
110
|
+
const c = r[n - 1];
|
|
111
|
+
e.src = `${t.srcPrefix}/${c}`, e.validId = !0;
|
|
116
112
|
}
|
|
117
113
|
return e;
|
|
118
114
|
}
|
|
119
115
|
function $(e) {
|
|
120
|
-
const t = m.youku, i = e.matchedUrl, r = t.idRule, n = new RegExp(r),
|
|
121
|
-
if (
|
|
122
|
-
const o =
|
|
116
|
+
const t = m.youku, i = e.matchedUrl, r = t.idRule, n = new RegExp(r), c = i.match(n);
|
|
117
|
+
if (c && c.length > 0) {
|
|
118
|
+
const o = c[0].slice(3);
|
|
123
119
|
e.validId = !0, e.src = `${t.srcPrefix}/${o}`;
|
|
124
120
|
} else
|
|
125
121
|
e.validId = !1;
|
|
@@ -128,16 +124,16 @@ function $(e) {
|
|
|
128
124
|
function T(e) {
|
|
129
125
|
const t = m.bilibili, r = e.matchedUrl.split("/"), n = r.length;
|
|
130
126
|
if (n > 0) {
|
|
131
|
-
const
|
|
132
|
-
e.src = `${t.srcPrefix}=${
|
|
127
|
+
const c = r[n - 1];
|
|
128
|
+
e.src = `${t.srcPrefix}=${c}`, e.validId = !0;
|
|
133
129
|
}
|
|
134
130
|
return e;
|
|
135
131
|
}
|
|
136
132
|
function Y(e) {
|
|
137
133
|
const t = m.qqvideo, r = e.matchedUrl.split("/"), n = r.length;
|
|
138
134
|
if (n > 0) {
|
|
139
|
-
const
|
|
140
|
-
e.src = `${t.srcPrefix}=${
|
|
135
|
+
const c = r[n - 1];
|
|
136
|
+
e.src = `${t.srcPrefix}=${c}`, e.validId = !0;
|
|
141
137
|
}
|
|
142
138
|
return e;
|
|
143
139
|
}
|
|
@@ -179,10 +175,10 @@ function F(e, t, i) {
|
|
|
179
175
|
if (e === "googlemaps")
|
|
180
176
|
return i.validLink = !0, i.matchedUrl = t, i;
|
|
181
177
|
const n = m[e].linkRule;
|
|
182
|
-
for (const
|
|
183
|
-
const o = new RegExp(
|
|
184
|
-
if (
|
|
185
|
-
return i.validLink = !0, i.matchedUrl = e === "youtube" ?
|
|
178
|
+
for (const c of n) {
|
|
179
|
+
const o = new RegExp(c), a = t.match(o);
|
|
180
|
+
if (a && a.length > 0)
|
|
181
|
+
return i.validLink = !0, i.matchedUrl = e === "youtube" ? a[1] : a[0], i;
|
|
186
182
|
}
|
|
187
183
|
return i;
|
|
188
184
|
}
|
|
@@ -242,13 +238,13 @@ const Q = "_wrap_5y04w_1", ee = "_innerWrap_5y04w_15", w = {
|
|
|
242
238
|
innerWrap: ee
|
|
243
239
|
};
|
|
244
240
|
function te({ editor: e, node: t, updateAttributes: i }) {
|
|
245
|
-
const r =
|
|
241
|
+
const r = j(), { src: n, width: c, height: o } = t.attrs, [a, p] = M("");
|
|
246
242
|
function u() {
|
|
247
|
-
if (!
|
|
243
|
+
if (!a)
|
|
248
244
|
return;
|
|
249
|
-
const s = Z(
|
|
245
|
+
const s = Z(a);
|
|
250
246
|
e.chain().updateAttributes(b.name, {
|
|
251
|
-
src: (s == null ? void 0 : s.src) ||
|
|
247
|
+
src: (s == null ? void 0 : s.src) || a
|
|
252
248
|
}).setNodeSelection(e.state.selection.from).focus().run();
|
|
253
249
|
}
|
|
254
250
|
const g = R(
|
|
@@ -260,18 +256,18 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
260
256
|
return /* @__PURE__ */ f(v, { children: [
|
|
261
257
|
!n && /* @__PURE__ */ f("div", { className: "richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]", children: [
|
|
262
258
|
/* @__PURE__ */ d(
|
|
263
|
-
|
|
259
|
+
U,
|
|
264
260
|
{
|
|
265
261
|
autoFocus: !0,
|
|
266
262
|
className: "richtext-flex-1",
|
|
267
263
|
onInput: (s) => p(s.target.value),
|
|
268
264
|
placeholder: "Enter link",
|
|
269
265
|
type: "url",
|
|
270
|
-
value:
|
|
266
|
+
value: a
|
|
271
267
|
}
|
|
272
268
|
),
|
|
273
269
|
/* @__PURE__ */ d(
|
|
274
|
-
|
|
270
|
+
q,
|
|
275
271
|
{
|
|
276
272
|
className: "richtext-w-[60px]",
|
|
277
273
|
onClick: u,
|
|
@@ -282,10 +278,10 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
282
278
|
n && /* @__PURE__ */ d(
|
|
283
279
|
N,
|
|
284
280
|
{
|
|
285
|
-
size: { width: Number.parseInt(
|
|
281
|
+
size: { width: Number.parseInt(c), height: Number.parseInt(o) },
|
|
286
282
|
onResizeStop: (s, ie, re, h) => {
|
|
287
283
|
g({
|
|
288
|
-
width: Number.parseInt(
|
|
284
|
+
width: Number.parseInt(c) + h.width,
|
|
289
285
|
height: Number.parseInt(o) + h.height
|
|
290
286
|
});
|
|
291
287
|
},
|
|
@@ -307,22 +303,22 @@ function te({ editor: e, node: t, updateAttributes: i }) {
|
|
|
307
303
|
)
|
|
308
304
|
] });
|
|
309
305
|
}
|
|
310
|
-
function
|
|
311
|
-
const e =
|
|
306
|
+
function pe() {
|
|
307
|
+
const e = A(b.name), {
|
|
312
308
|
icon: t = void 0,
|
|
313
309
|
tooltip: i = void 0,
|
|
314
310
|
shortcutKeys: r = void 0,
|
|
315
311
|
tooltipOptions: n = {},
|
|
316
|
-
action:
|
|
312
|
+
action: c = void 0,
|
|
317
313
|
isActive: o = void 0
|
|
318
|
-
} = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled:
|
|
319
|
-
|
|
314
|
+
} = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a, update: p } = L(o), u = () => {
|
|
315
|
+
a || c && (c(), p());
|
|
320
316
|
};
|
|
321
317
|
return e ? /* @__PURE__ */ d(
|
|
322
|
-
|
|
318
|
+
D,
|
|
323
319
|
{
|
|
324
320
|
action: u,
|
|
325
|
-
disabled:
|
|
321
|
+
disabled: a,
|
|
326
322
|
icon: t,
|
|
327
323
|
shortcutKeys: r,
|
|
328
324
|
tooltip: i,
|
|
@@ -399,8 +395,8 @@ const b = /* @__PURE__ */ k.create({
|
|
|
399
395
|
addCommands() {
|
|
400
396
|
return {
|
|
401
397
|
setIframe: (e) => ({ tr: t, commands: i, chain: r }) => {
|
|
402
|
-
var
|
|
403
|
-
if (((
|
|
398
|
+
var c, o, a;
|
|
399
|
+
if (((a = (o = (c = t.selection) == null ? void 0 : c.node) == null ? void 0 : o.type) == null ? void 0 : a.name) == this.name)
|
|
404
400
|
return i.updateAttributes(this.name, e);
|
|
405
401
|
const n = e || { url: "" };
|
|
406
402
|
return r().insertContent({
|
|
@@ -425,6 +421,6 @@ const b = /* @__PURE__ */ k.create({
|
|
|
425
421
|
});
|
|
426
422
|
export {
|
|
427
423
|
b as I,
|
|
428
|
-
|
|
424
|
+
pe as R,
|
|
429
425
|
Z as g
|
|
430
426
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./clsx-CXbNJWDD.cjs"),s=require("react/jsx-runtime"),g=require("react"),y=require("re-resizable"),f=require("./dom-dataset-BqoJhJXt.cjs"),m=require("./index-BnVcq33n.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 S(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 I(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 R(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 P(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 j(e,t){return t.src=e,t.validId=!0,t}function M(e,t){return t.src=e,t.validId=!0,t}function N(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function q(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function U(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function A(e){const t=p.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function D(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function L(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function _(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 T(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function z(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 Y(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 x(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=Y(e);if(t=z(i,e,t),!t.validLink)return t;switch(i){case"youtube":return S(t);case"youku":return I(t);case"bilibili":return R(t);case"qqvideo":return P(t);case"amap":return j(e,t);case"baidu_map":return M(e,t);case"googlemaps":return N(e,t);case"modao":return q(t);case"lanhu":return U(t);case"figma":return A(t);case"canva":return D(e,t);case"processon":return L(e,t);case"codepen":return _(t);case"jinshuju":return $(e,t);case"iframe":return T(e,t);default:return e}}const C="_wrap_5y04w_1",E="_innerWrap_5y04w_15",v={wrap:C,innerWrap:E};function H({editor:e,node:t,updateAttributes:i}){const r=m.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,l]=g.useState("");function h(){if(!a)return;const d=x(a);e.chain().updateAttributes(w.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const k=g.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(m.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>l(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(m.Button,{className:"richtext-w-[60px]",onClick:h,children:"OK"})]}),n&&s.jsx(y.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,V,K,b)=>{k({width:Number.parseInt(c)+b.width,height:Number.parseInt(o)+b.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 B(){const e=m.useButtonProps(w.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}=m.useToggleActive(o),h=()=>{a||c&&(c(),l())};return e?s.jsx(m.ActionButton,{action:h,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const w=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:f.getDatasetAttribute("width")},height:{default:300,parseHTML:f.getDatasetAttribute("height")},src:{default:null,parseHTML:f.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(H)}});exports.Iframe=w;exports.RichTextIframe=B;exports.getServiceSrc=x;
|
package/lib/Iframe.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./Iframe-EVWXCqe4.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
|
package/lib/Iframe.js
CHANGED
package/lib/Image.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");const e=require("./index-BnVcq33n.cjs");exports.Image=e.Image;exports.RichTextImage=e.RichTextImage;
|
package/lib/Image.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "./clsx-
|
|
2
|
-
import "./
|
|
3
|
-
import { I as r, R as t } from "./Image-BZEFuS0P.js";
|
|
1
|
+
import "./clsx-DaPvp9ji.js";
|
|
2
|
+
import { t, _ as o } from "./index-RcSPeQHn.js";
|
|
4
3
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
t as Image,
|
|
5
|
+
o as RichTextImage
|
|
7
6
|
};
|
package/lib/ImageGif.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./clsx-CXbNJWDD.cjs"),f=require("./index-BnVcq33n.cjs"),l=require("react/jsx-runtime"),u=require("react"),j=require("./index-BsFvo9PG.cjs");require("./theme.cjs");const L=require("./popover-DIMT3pae.cjs"),N={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function q(e){var k,z;const[t,r]=u.useState({width:j.IMAGE_MAX_SIZE,height:j.IMAGE_MAX_SIZE}),[o,i]=u.useState({width:0,height:0}),[n]=u.useState([N.TOP_LEFT,N.TOP_RIGHT,N.BOTTOM_LEFT,N.BOTTOM_RIGHT]),[s,a]=u.useState(!1),[h,x]=u.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=(k=e==null?void 0:e.node)==null?void 0:k.attrs,m=u.useMemo(()=>{var b;const{src:c,alt:w,width:v,height:A}=(b=e==null?void 0:e.node)==null?void 0:b.attrs,G=f.isNumber(v)?`${v}px`:v,d=f.isNumber(A)?`${A}px`:A;return{src:c||void 0,alt:w||void 0,style:{width:G||void 0,height:d||void 0}}},[(z=e==null?void 0:e.node)==null?void 0:z.attrs]),_=u.useMemo(()=>{const{style:{width:c}}=m;return{width:c==="100%"?c:void 0}},[m]);function g(c){i({width:c.target.width,height:c.target.height})}function I(){const{editor:c,getPos:w}=e;c.commands.setNodeSelection(w())}const M=u.useCallback(f.throttle(()=>{const{editor:c}=e,{width:w}=getComputedStyle(c.view.dom);r(v=>({...v,width:Number.parseInt(w,10)}))},j.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function H(c,w){c.preventDefault(),c.stopPropagation();const v=o.width,A=o.height,G=v/A;let d=Number(e.node.attrs.width),b=Number(e.node.attrs.height);const y=t.width;d&&!b?(d=d>y?y:d,b=Math.round(d/G)):b&&!d?(d=Math.round(b*G),d=d>y?y:d):!d&&!b?(d=v>y?y:v,b=Math.round(d/G)):d=d>y?y:d,a(!0),x({x:c.clientX,y:c.clientY,w:d,h:b,dir:w})}const E=u.useCallback(f.throttle(c=>{if(c.preventDefault(),c.stopPropagation(),!s)return;const{x:w,w:v,dir:A}=h,G=(c.clientX-w)*(/l/.test(A)?-1:1),d=f.clamp$1(v+G,j.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:d,height:null})},j.IMAGE_THROTTLE_WAIT_TIME),[s,h,t,e.updateAttributes]),S=u.useCallback(c=>{c.preventDefault(),c.stopPropagation(),s&&(x({x:0,y:0,w:0,h:0,dir:""}),a(!1),I())},[s,I]),$=u.useCallback(()=>{document==null||document.addEventListener("mousemove",E,!0),document==null||document.addEventListener("mouseup",S,!0)},[E,S]),O=u.useCallback(()=>{document==null||document.removeEventListener("mousemove",E,!0),document==null||document.removeEventListener("mouseup",S,!0)},[E,S]);u.useEffect(()=>(s?$():O(),()=>{O()}),[s,$,O]);const R=u.useMemo(()=>new ResizeObserver(()=>M()),[M]);return u.useEffect(()=>(R.observe(e.editor.view.dom),()=>{R.disconnect()}),[e.editor.view.dom,R]),l.jsx(P.NodeViewWrapper,{className:"image-view",style:{..._,width:"100%",textAlign:T},children:l.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:_,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${s?"image-view__body--resizing":""}`,children:[l.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:g,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||s)&&l.jsx("div",{className:"image-resizer",children:n==null?void 0:n.map(c=>l.jsx("span",{className:`image-resizer__handler image-resizer__handler--${c}`,onMouseDown:w=>H(w,c)},`image-dir-${c}`))})]})})}async function W(e){var o;const r=await(await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();return(o=r==null?void 0:r.data)==null?void 0:o.map(i=>{var n,s,a;return{id:i==null?void 0:i.id,src:(n=i==null?void 0:i.images.original)==null?void 0:n.url,width:+((s=i==null?void 0:i.images.original)==null?void 0:s.width),height:+((a=i==null?void 0:i.images.original)==null?void 0:a.width)}})}async function p(e,t){var i;const o=await(await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();return(i=o==null?void 0:o.data)==null?void 0:i.map(n=>{var s,a,h;return{id:n==null?void 0:n.id,src:(s=n==null?void 0:n.images.original)==null?void 0:s.url,width:+((a=n==null?void 0:n.images.original)==null?void 0:a.width),height:+((h=n==null?void 0:n.images.original)==null?void 0:h.width)}})}async function D(e){var n,s;const t=await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),r=await(t==null?void 0:t.json()),i=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n=r==null?void 0:r.results)==null?void 0:n[0]}&limit=15`)).json();return(s=i==null?void 0:i.results)==null?void 0:s.map(a=>{var h,x,T,m,_,g,I,M;return{id:a==null?void 0:a.id,src:(x=(h=a==null?void 0:a.media_formats)==null?void 0:h.gif)==null?void 0:x.url,width:(_=(m=(T=a==null?void 0:a.media_formats)==null?void 0:T.gif)==null?void 0:m.dims)==null?void 0:_[0],height:(M=(I=(g=a==null?void 0:a.media_formats)==null?void 0:g.gif)==null?void 0:I.dims)==null?void 0:M[1]}})}async function F(e,t){var i;const o=await(await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();return(i=o==null?void 0:o.results)==null?void 0:i.map(n=>{var s,a,h,x,T,m,_,g;return{id:n==null?void 0:n.id,src:(a=(s=n==null?void 0:n.media_formats)==null?void 0:s.gif)==null?void 0:a.url,width:(T=(x=(h=n==null?void 0:n.media_formats)==null?void 0:h.gif)==null?void 0:x.dims)==null?void 0:T[0],height:(g=(_=(m=n==null?void 0:n.media_formats)==null?void 0:m.gif)==null?void 0:_.dims)==null?void 0:g[1]}})}function B(e,t){return{searchTrending:async()=>t?e==="giphy"?W(t):e==="tenor"?D(t):[]:[],searchWord:async i=>t?e==="giphy"?p(i,t):e==="tenor"?F(i,t):[]:[]}}function V({selectImage:e,apiKey:t,provider:r,children:o}){const[i,n]=u.useState(!1),[s,a]=u.useState([]),{editorDisabled:h}=f.useToggleActive(),x=u.useRef(null),{searchTrending:T,searchWord:m}=B(r,t);u.useEffect(()=>{(async()=>{const g=await T();a(g)})()},[]);const _=u.useCallback(f.debounce(async g=>{if(!g.target.value){const M=await T();a(M);return}const I=await m(g.target.value);a(I)},350),[]);return l.jsxs(L.Popover,{modal:!0,onOpenChange:n,open:i,children:[l.jsx(L.PopoverTrigger,{asChild:!0,disabled:h,children:o}),l.jsx(L.PopoverContent,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:l.jsx(f.Input,{onChange:_,placeholder:"Search GIF",ref:x,type:"text"})}),l.jsx("div",{className:"richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto",children:l.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1 ",children:s!=null&&s.length?s==null?void 0:s.map(g=>l.jsx("img",{alt:"",className:"richtext-cursor-pointer richtext-object-contain richtext-text-center",src:g.src,onClick:()=>{e(g.src),n(!1)}},g.id)):l.jsx("p",{children:"No GIFs found"})})})]}):l.jsx("div",{children:l.jsx("p",{children:"Missing Giphy API Key"})})})]})}function X(){const e=f.useButtonProps(C.name),{action:t,icon:r,tooltip:o,apiKey:i,provider:n}=(e==null?void 0:e.componentProps)??{},{editorDisabled:s}=f.useToggleActive(),a=h=>{s||t&&t(h)};return l.jsx(V,{apiKey:i,provider:n,selectImage:a,children:l.jsx(f.ActionButton,{disabled:s,icon:r,tooltip:o})})}const C=f.index_default.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",API_KEY:"",provider:"giphy",draggable:!1,selectable:!0,atom:!0,button:({editor:t,extension:r,t:o})=>{var s,a;const i=((s=r==null?void 0:r.options)==null?void 0:s.provider)||"",n=((a=r==null?void 0:r.options)==null?void 0:a.API_KEY)||"";return{componentProps:{action:h=>{t.chain().focus().setImageGif({src:h}).run()},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:o("editor.imageGif.tooltip"),apiKey:n,provider:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const r=t.style.width||t.getAttribute("width")||"10";return r===void 0?null:Number.parseInt(`${r}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return P.ReactNodeViewRenderer(q)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:r})=>r.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:r})=>r.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",P.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),r=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:r?Number.parseInt(r,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});exports.ImageGif=C;exports.RichTextImageGif=X;
|