reactjs-tiptap-editor 0.4.2 → 1.0.1
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-BKOg7hkq.js +38 -0
- package/lib/ActionMenuButton-DLQyd_gx.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.d.cts +27 -39
- package/lib/Attachment.d.ts +27 -39
- package/lib/Attachment.js +129 -99
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.d.cts +27 -39
- package/lib/Blockquote.d.ts +27 -39
- package/lib/Blockquote.js +50 -22
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +27 -39
- package/lib/Bold.d.ts +27 -39
- package/lib/Bold.js +48 -20
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +27 -39
- package/lib/BulletList.d.ts +27 -39
- package/lib/BulletList.js +38 -9
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +27 -39
- package/lib/Clear.d.ts +27 -39
- package/lib/Clear.js +32 -6
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +27 -39
- package/lib/Code.d.ts +27 -39
- package/lib/Code.js +53 -25
- package/lib/CodeBlock.cjs +35 -35
- package/lib/CodeBlock.d.cts +27 -39
- package/lib/CodeBlock.d.ts +27 -39
- package/lib/CodeBlock.js +605 -590
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +28 -40
- package/lib/CodeView.d.ts +28 -40
- package/lib/CodeView.js +49 -21
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +31 -39
- package/lib/Color.d.ts +31 -39
- package/lib/Color.js +123 -79
- package/lib/Column.cjs +1 -0
- package/lib/{Document.d.cts → Column.d.cts} +33 -42
- package/lib/{Document.d.ts → Column.d.ts} +33 -42
- package/lib/Column.js +217 -0
- package/lib/{Drawer-CaAfmqNo.js → Drawer-DZ5jvmrX.js} +404 -394
- package/lib/Drawer-SRhwOc6T.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +27 -39
- package/lib/Drawer.d.ts +27 -39
- package/lib/Drawer.js +6 -5
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +27 -44
- package/lib/Emoji.d.ts +27 -44
- package/lib/Emoji.js +377 -392
- package/lib/Excalidraw-DwBRXEtC.js +345 -0
- package/lib/Excalidraw-ZN3DQvDC.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +27 -39
- package/lib/Excalidraw.d.ts +27 -39
- package/lib/Excalidraw.js +6 -4
- package/lib/ExportPdf.cjs +5 -5
- package/lib/ExportPdf.d.cts +27 -39
- package/lib/ExportPdf.d.ts +27 -39
- package/lib/ExportPdf.js +60 -32
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +28 -40
- package/lib/ExportWord.d.ts +28 -40
- package/lib/ExportWord.js +84 -21
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +41 -42
- package/lib/FontFamily.d.ts +41 -42
- package/lib/FontFamily.js +72 -74
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +38 -42
- package/lib/FontSize.d.ts +38 -42
- package/lib/FontSize.js +72 -64
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +41 -39
- package/lib/Heading.d.ts +41 -39
- package/lib/Heading.js +91 -73
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +31 -39
- package/lib/Highlight.d.ts +31 -39
- package/lib/Highlight.js +150 -19
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +29 -39
- package/lib/History.d.ts +29 -39
- package/lib/History.js +976 -53
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +27 -39
- package/lib/HorizontalRule.d.ts +27 -39
- package/lib/HorizontalRule.js +97 -17
- package/lib/Icon-DUpv2cI6.cjs +1 -0
- package/lib/Icon-jKs8Hr6p.js +11 -0
- package/lib/Iframe-CmXkEqOd.js +431 -0
- package/lib/Iframe-Cvca2G7X.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +26 -45
- package/lib/Iframe.d.ts +26 -45
- package/lib/Iframe.js +6 -4
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +27 -40
- package/lib/Image.d.ts +27 -40
- package/lib/Image.js +848 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +28 -42
- package/lib/ImageGif.d.ts +28 -42
- package/lib/ImageGif.js +424 -5
- package/lib/ImportWord.cjs +48 -48
- package/lib/ImportWord.d.cts +28 -40
- package/lib/ImportWord.d.ts +28 -40
- package/lib/ImportWord.js +2759 -2751
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +27 -39
- package/lib/Indent.d.ts +27 -39
- package/lib/Indent.js +97 -27
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +27 -39
- package/lib/Italic.d.ts +27 -39
- package/lib/Italic.js +47 -19
- package/lib/Katex-DsYXsjSS.js +2740 -0
- package/lib/Katex-XfrNne6U.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +27 -39
- package/lib/Katex.d.ts +27 -39
- package/lib/Katex.js +5 -196
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +29 -45
- package/lib/LineHeight.d.ts +29 -45
- package/lib/LineHeight.js +71 -112
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +28 -42
- package/lib/Link.d.ts +28 -42
- package/lib/Link.js +3 -3
- package/lib/LinkEditBlock-BZenZq-Z.cjs +5 -0
- package/lib/LinkEditBlock-CB8yIffE.js +1241 -0
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +24 -39
- package/lib/Mention.d.ts +24 -39
- package/lib/Mention.js +112 -124
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +27 -39
- package/lib/Mermaid.d.ts +27 -39
- package/lib/Mermaid.js +177 -165
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +42 -41
- package/lib/MoreMark.d.ts +42 -41
- package/lib/MoreMark.js +125 -55
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +27 -39
- package/lib/OrderedList.d.ts +27 -39
- package/lib/OrderedList.js +37 -9
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +27 -42
- package/lib/SearchAndReplace.d.ts +27 -42
- package/lib/SearchAndReplace.js +221 -197
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +39 -46
- package/lib/SlashCommand.d.ts +39 -46
- package/lib/SlashCommand.js +235 -249
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +27 -39
- package/lib/Strike.d.ts +27 -39
- package/lib/Strike.js +39 -11
- package/lib/Table-B1j1Ebmh.cjs +9 -0
- package/lib/Table-Db8TcQX8.js +1984 -0
- package/lib/Table.cjs +1 -9
- package/lib/Table.d.cts +28 -42
- package/lib/Table.d.ts +28 -42
- package/lib/Table.js +3 -558
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +27 -39
- package/lib/TaskList.d.ts +27 -39
- package/lib/TaskList.js +38 -10
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +40 -39
- package/lib/TextAlign.d.ts +40 -39
- package/lib/TextAlign.js +108 -101
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +56 -39
- package/lib/TextDirection.d.ts +56 -39
- package/lib/TextDirection.js +105 -112
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +27 -39
- package/lib/TextUnderline.d.ts +27 -39
- package/lib/TextUnderline.js +46 -18
- package/lib/{Twitter-BFULyqdR.js → Twitter-CXmmjz9R.js} +536 -498
- package/lib/Twitter-CtVTIWJW.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +27 -39
- package/lib/Twitter.d.ts +27 -39
- package/lib/Twitter.js +5 -4
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +27 -39
- package/lib/Video.d.ts +27 -39
- package/lib/Video.js +261 -4
- package/lib/_commonjsHelpers-BItOPCY9.js +28 -0
- package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
- package/lib/bubble.cjs +2 -0
- package/lib/{bubble-extra.d.cts → bubble.d.cts} +53 -54
- package/lib/{bubble-extra.d.ts → bubble.d.ts} +53 -54
- package/lib/bubble.js +1925 -0
- package/lib/button-B12K7BJ4.cjs +1 -0
- package/lib/button-DXMsXUEn.js +43 -0
- package/lib/clsx-C11secjj.cjs +1 -0
- package/lib/clsx-OuTLNxxd.js +16 -0
- package/lib/delete-node-CosiBes5.cjs +1 -0
- package/lib/delete-node-IyVmiRbI.js +22 -0
- package/lib/dialog-CaCS-W5S.cjs +1 -0
- package/lib/dialog-PtQivpHS.js +100 -0
- package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
- package/lib/dom-dataset-CIEeltF6.js +47 -0
- package/lib/dropdown-menu-BPp2Z_U-.js +136 -0
- package/lib/dropdown-menu-CdSm4emp.cjs +1 -0
- package/lib/file-BLas99n7.js +43 -0
- package/lib/file-i7e4nQY2.cjs +1 -0
- package/lib/floating-ui.dom-U1vPFQ5f.js +1151 -0
- package/lib/floating-ui.dom-VCrc58uF.cjs +1 -0
- package/lib/icons-Cllpys39.js +362 -0
- package/lib/icons-CqHjeW5T.cjs +1 -0
- package/lib/index-BH4bc3jN.cjs +33 -0
- package/lib/index-BPfVXs5_.js +2380 -0
- package/lib/index-Bnmd0WvY.js +1631 -0
- package/lib/{index-Ch6dBBad.js → index-CBce_TWY.js} +40 -42
- package/lib/{index-5iBZLua9.cjs → index-D-5U8dY8.cjs} +8 -8
- package/lib/{index-ByurDDMv.js → index-D2TUfKkC.js} +2 -2
- package/lib/index-DV5kbgRU.cjs +1 -0
- package/lib/{index-LmrOdnen.js → index-DYkucCoF.js} +396 -495
- package/lib/index-Dfmm6FTT.cjs +1 -0
- package/lib/index-DnWWK9F_.js +6374 -0
- package/lib/index-DzcKxutn.js +632 -0
- package/lib/index-DzvuNTxo.cjs +4 -0
- package/lib/{index-BeCTd5v2.cjs → index-N--9MohJ.cjs} +1 -1
- package/lib/index-RfTlOzIr.cjs +22 -0
- package/lib/index.cjs +132 -1
- package/lib/index.d.cts +29 -280
- package/lib/index.d.ts +29 -280
- package/lib/index.js +243 -2
- package/lib/input-_ECRfn3Y.cjs +1 -0
- package/lib/input-wJ9PDEzZ.js +21 -0
- package/lib/isNumber-ClPupm7P.cjs +1 -0
- package/lib/isNumber-fpLGS0AZ.js +15 -0
- package/lib/label-BkgAe7IY.cjs +1 -0
- package/lib/label-CGdLYWv7.js +19 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.d.cts +5405 -57
- package/lib/locale-bundle.d.ts +5405 -57
- package/lib/locale-bundle.js +9 -7
- package/lib/popover-BgmUNMHj.cjs +1 -0
- package/lib/popover-CAuEW0Mr.js +23 -0
- package/lib/separator-CuBW_w98.js +328 -0
- package/lib/separator-DRIrVZ2N.cjs +1 -0
- package/lib/store-DX599H5W.js +10 -0
- package/lib/store-WStcMOiW.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/switch-CnLJ7Y-b.cjs +1 -0
- package/lib/switch-Coix_FA1.js +27 -0
- package/lib/tabs-B5mVSN1I.js +46 -0
- package/lib/tabs-BoLCMcCI.cjs +1 -0
- package/lib/textarea-B-6zTKQz.cjs +1 -0
- package/lib/{textarea-aPtytkDx.js → textarea-DUUM1jZd.js} +1 -1
- package/lib/theme-B7aAsK_T.js +15 -0
- package/lib/theme-D8_cxGqB.cjs +1 -0
- package/lib/throttle-CdwDrFpn.js +249 -0
- package/lib/throttle-qX7Yjtsg.cjs +1 -0
- package/lib/toggle-Cdp4IT2U.js +85 -0
- package/lib/toggle-D41PzQLJ.cjs +1 -0
- package/lib/tooltip-BuEiE96N.cjs +1 -0
- package/lib/tooltip-CopwsU8q.js +23 -0
- package/lib/updatePosition-8Sdem5jb.cjs +1 -0
- package/lib/updatePosition-BPmcE0YD.js +215 -0
- package/lib/use-toast-Bz3QCOtE.cjs +1 -0
- package/lib/use-toast-Crf7-q5H.js +98 -0
- package/lib/useButtonProps-BsEd4zYM.js +141 -0
- package/lib/useButtonProps-C6Vpn190.cjs +1 -0
- package/package.json +22 -105
- package/lib/ActionMenuButton-CYdM1xx5.cjs +0 -1
- package/lib/ActionMenuButton-DKRF6oa0.js +0 -33
- package/lib/BaseKit.cjs +0 -3
- package/lib/BaseKit.d.cts +0 -481
- package/lib/BaseKit.d.ts +0 -481
- package/lib/BaseKit.js +0 -132
- package/lib/Document.cjs +0 -1
- package/lib/Document.js +0 -9
- package/lib/Drawer-CdvCMSzN.cjs +0 -1
- package/lib/Excalidraw-BbMQhNvs.cjs +0 -1
- package/lib/Excalidraw-CVWz2Vyn.js +0 -290
- package/lib/FormatPainter.cjs +0 -1
- package/lib/FormatPainter.d.cts +0 -372
- package/lib/FormatPainter.d.ts +0 -372
- package/lib/FormatPainter.js +0 -76
- package/lib/ListItem.cjs +0 -1
- package/lib/ListItem.d.cts +0 -290
- package/lib/ListItem.d.ts +0 -290
- package/lib/ListItem.js +0 -7
- package/lib/MultiColumn.cjs +0 -1
- package/lib/MultiColumn.d.cts +0 -294
- package/lib/MultiColumn.d.ts +0 -294
- package/lib/MultiColumn.js +0 -8
- package/lib/RichTextEditor-CxvwGvQG.cjs +0 -142
- package/lib/RichTextEditor-DGcKEUGr.js +0 -22166
- package/lib/Selection.cjs +0 -1
- package/lib/Selection.d.cts +0 -289
- package/lib/Selection.d.ts +0 -289
- package/lib/Selection.js +0 -25
- package/lib/SubAndSuperScript.cjs +0 -1
- package/lib/SubAndSuperScript.d.cts +0 -377
- package/lib/SubAndSuperScript.d.ts +0 -377
- package/lib/SubAndSuperScript.js +0 -43
- package/lib/TableOfContent.cjs +0 -1
- package/lib/TableOfContent.d.cts +0 -291
- package/lib/TableOfContent.d.ts +0 -291
- package/lib/TableOfContent.js +0 -185
- package/lib/TextBubble.cjs +0 -1
- package/lib/TextBubble.d.cts +0 -362
- package/lib/TextBubble.d.ts +0 -362
- package/lib/TextBubble.js +0 -133
- package/lib/TrailingNode.cjs +0 -1
- package/lib/TrailingNode.d.cts +0 -297
- package/lib/TrailingNode.d.ts +0 -297
- package/lib/TrailingNode.js +0 -41
- package/lib/Twitter-Cutpkh3h.cjs +0 -1
- package/lib/bubble-extra.cjs +0 -2
- package/lib/bubble-extra.js +0 -631
- package/lib/dom-dataset-_6-diIRQ.cjs +0 -33
- package/lib/dom-dataset-lYeH6gfI.js +0 -2361
- package/lib/index-6D1J-A-o.cjs +0 -1
- package/lib/index-B96Cclrj.cjs +0 -3
- package/lib/index-BBz7Nmv9.js +0 -55
- package/lib/index-CUogRI7j.cjs +0 -1
- package/lib/index-DF2Lp4HZ.cjs +0 -100
- package/lib/index-D_L6n8O8.js +0 -76
- package/lib/index-Dbvi-Bvh.cjs +0 -1
- package/lib/index-DpCrt7xs.cjs +0 -1
- package/lib/index-DsAX1Vq8.cjs +0 -1
- package/lib/index-Dy4DlW9o.js +0 -12
- package/lib/index-J3jHHZ4d.js +0 -200
- package/lib/index-VvXaaKe3.js +0 -898
- package/lib/index-kbO3iWqL.js +0 -13432
- package/lib/textarea-DFo_aXnj.cjs +0 -1
package/lib/SearchAndReplace.js
CHANGED
|
@@ -1,158 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { E as Q } from "./index-DnWWK9F_.js";
|
|
2
|
+
import { Plugin as X, PluginKey as Y } from "@tiptap/pm/state";
|
|
3
|
+
import { DecorationSet as $, Decoration as Z } from "@tiptap/pm/view";
|
|
4
|
+
import { jsx as u, Fragment as _, jsxs as T } from "react/jsx-runtime";
|
|
5
|
+
import { useState as b, useEffect as k } from "react";
|
|
6
|
+
import { A as ee } from "./toggle-Cdp4IT2U.js";
|
|
7
|
+
import { a as te } from "./index-BPfVXs5_.js";
|
|
8
|
+
import { I as V } from "./Icon-jKs8Hr6p.js";
|
|
9
|
+
import { u as se, b as re } from "./useButtonProps-BsEd4zYM.js";
|
|
10
|
+
import { u as ne } from "./index-DYkucCoF.js";
|
|
11
|
+
import { P as ce, a as ae, b as le } from "./popover-CAuEW0Mr.js";
|
|
12
|
+
import { L as B } from "./label-CGdLYWv7.js";
|
|
13
|
+
import { I as q } from "./input-wJ9PDEzZ.js";
|
|
14
|
+
import { B as N } from "./button-DXMsXUEn.js";
|
|
15
|
+
import { S as oe } from "./switch-Coix_FA1.js";
|
|
16
|
+
function ye() {
|
|
17
|
+
const { t } = ne(), e = te(), s = se(pe.name), {
|
|
18
|
+
icon: n = void 0,
|
|
19
|
+
tooltip: i = void 0,
|
|
20
|
+
shortcutKeys: l = void 0,
|
|
21
|
+
tooltipOptions: c = {},
|
|
22
|
+
action: m = void 0,
|
|
23
|
+
isActive: h = void 0
|
|
24
|
+
} = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = re(h), [f, d] = b(!1), [p, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, D] = b(""), P = () => {
|
|
25
|
+
var r, a, g, x;
|
|
26
|
+
D(`${((a = (r = e == null ? void 0 : e.storage) == null ? void 0 : r.searchAndReplace) == null ? void 0 : a.resultIndex) + 1}/${(x = (g = e == null ? void 0 : e.storage) == null ? void 0 : g.searchAndReplace) == null ? void 0 : x.results.length}`);
|
|
10
27
|
};
|
|
11
|
-
|
|
12
|
-
e &&
|
|
28
|
+
k(() => {
|
|
29
|
+
e && P();
|
|
13
30
|
}, [e]);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
},
|
|
31
|
+
const H = () => {
|
|
32
|
+
o || m && m();
|
|
33
|
+
}, L = (r = !1) => {
|
|
34
|
+
var a, g, x, R, v, F, y, O;
|
|
35
|
+
e && (r && ((g = (a = e == null ? void 0 : e.commands) == null ? void 0 : a.resetIndex) == null || g.call(a)), (R = (x = e == null ? void 0 : e.commands) == null ? void 0 : x.setSearchTerm) == null || R.call(x, p), (F = (v = e == null ? void 0 : e.commands) == null ? void 0 : v.setReplaceTerm) == null || F.call(v, S), (O = (y = e == null ? void 0 : e.commands) == null ? void 0 : y.setCaseSensitive) == null || O.call(y, I), P());
|
|
36
|
+
}, E = () => {
|
|
37
|
+
var R, v;
|
|
17
38
|
if (!e) return;
|
|
18
|
-
const { results:
|
|
19
|
-
if (!
|
|
20
|
-
e.commands.setTextSelection(
|
|
21
|
-
const { node:
|
|
39
|
+
const { results: r, resultIndex: a } = e.storage.searchAndReplace, g = r[a];
|
|
40
|
+
if (!g) return;
|
|
41
|
+
(v = (R = e == null ? void 0 : e.commands) == null ? void 0 : R.setTextSelection) == null || v.call(R, g);
|
|
42
|
+
const { node: x } = e.view.domAtPos(
|
|
22
43
|
e.state.selection.anchor
|
|
23
44
|
);
|
|
24
|
-
|
|
45
|
+
x instanceof HTMLElement && x.scrollIntoView({ behavior: "smooth", block: "center" }), P();
|
|
25
46
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
e == null
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
k(() => {
|
|
48
|
+
p.trim() || j(), p.trim() && L(!0);
|
|
49
|
+
}, [p]), k(() => {
|
|
50
|
+
S.trim() && L();
|
|
51
|
+
}, [S]), k(() => {
|
|
52
|
+
L(!0);
|
|
53
|
+
}, [I]);
|
|
54
|
+
const U = () => {
|
|
55
|
+
var r, a;
|
|
56
|
+
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replace) == null || a.call(r), E();
|
|
57
|
+
}, z = () => {
|
|
58
|
+
var r, a;
|
|
59
|
+
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.nextSearchResult) == null || a.call(r), E();
|
|
60
|
+
}, G = () => {
|
|
61
|
+
var r, a;
|
|
62
|
+
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.previousSearchResult) == null || a.call(r), E();
|
|
63
|
+
}, j = () => {
|
|
64
|
+
var r, a;
|
|
65
|
+
A(""), w(""), (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.resetIndex) == null || a.call(r), P();
|
|
66
|
+
}, J = () => {
|
|
67
|
+
var r, a;
|
|
68
|
+
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), D("0/0");
|
|
43
69
|
};
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
70
|
+
return s ? /* @__PURE__ */ T(
|
|
71
|
+
ce,
|
|
46
72
|
{
|
|
47
|
-
onOpenChange:
|
|
48
|
-
open:
|
|
73
|
+
onOpenChange: d,
|
|
74
|
+
open: f,
|
|
49
75
|
children: [
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
|
|
76
|
+
/* @__PURE__ */ u(
|
|
77
|
+
ae,
|
|
52
78
|
{
|
|
53
79
|
asChild: !0,
|
|
54
|
-
disabled:
|
|
55
|
-
children: /* @__PURE__ */
|
|
56
|
-
|
|
80
|
+
disabled: o,
|
|
81
|
+
children: /* @__PURE__ */ u(
|
|
82
|
+
ee,
|
|
57
83
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
action: H,
|
|
85
|
+
disabled: o,
|
|
86
|
+
icon: n,
|
|
87
|
+
shortcutKeys: l,
|
|
88
|
+
tooltip: i,
|
|
89
|
+
tooltipOptions: c
|
|
63
90
|
}
|
|
64
91
|
)
|
|
65
92
|
}
|
|
66
93
|
),
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
|
|
94
|
+
/* @__PURE__ */ T(
|
|
95
|
+
le,
|
|
69
96
|
{
|
|
70
97
|
align: "start",
|
|
71
98
|
className: "richtext-w-full",
|
|
72
99
|
hideWhenDetached: !0,
|
|
73
100
|
side: "bottom",
|
|
74
101
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ T("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
|
|
103
|
+
/* @__PURE__ */ u(B, { children: t("editor.search.dialog.text") }),
|
|
104
|
+
/* @__PURE__ */ u("span", { className: "richtext-font-semibold", children: W })
|
|
78
105
|
] }),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
106
|
+
/* @__PURE__ */ T("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
|
|
107
|
+
/* @__PURE__ */ u(
|
|
108
|
+
q,
|
|
82
109
|
{
|
|
83
110
|
autoFocus: !0,
|
|
84
111
|
className: "richtext-w-full",
|
|
85
|
-
onChange: (
|
|
112
|
+
onChange: (r) => A(r.target.value),
|
|
86
113
|
placeholder: "Text",
|
|
87
114
|
required: !0,
|
|
88
115
|
type: "text",
|
|
89
|
-
value:
|
|
116
|
+
value: p
|
|
90
117
|
}
|
|
91
118
|
),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
119
|
+
/* @__PURE__ */ u(
|
|
120
|
+
N,
|
|
94
121
|
{
|
|
95
122
|
className: "richtext-flex-1",
|
|
96
|
-
onClick:
|
|
97
|
-
children: /* @__PURE__ */
|
|
123
|
+
onClick: G,
|
|
124
|
+
children: /* @__PURE__ */ u(V, { name: "ChevronUp" })
|
|
98
125
|
}
|
|
99
126
|
),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
127
|
+
/* @__PURE__ */ u(
|
|
128
|
+
N,
|
|
102
129
|
{
|
|
103
130
|
className: "richtext-flex-1",
|
|
104
|
-
onClick:
|
|
105
|
-
children: /* @__PURE__ */
|
|
131
|
+
onClick: z,
|
|
132
|
+
children: /* @__PURE__ */ u(V, { name: "ChevronDown" })
|
|
106
133
|
}
|
|
107
134
|
),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
|
|
135
|
+
/* @__PURE__ */ u(
|
|
136
|
+
N,
|
|
110
137
|
{
|
|
111
138
|
className: "richtext-flex-1",
|
|
112
|
-
onClick:
|
|
139
|
+
onClick: j,
|
|
113
140
|
children: "Clear"
|
|
114
141
|
}
|
|
115
142
|
)
|
|
116
143
|
] }),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
|
|
144
|
+
/* @__PURE__ */ u(B, { className: "richtext-mb-[6px]", children: t("editor.replace.dialog.text") }),
|
|
145
|
+
/* @__PURE__ */ u("div", { className: "richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: /* @__PURE__ */ u("div", { className: "richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center", children: /* @__PURE__ */ u(
|
|
146
|
+
q,
|
|
120
147
|
{
|
|
121
148
|
className: "richtext-w-80",
|
|
122
|
-
onChange: (
|
|
149
|
+
onChange: (r) => w(r.target.value),
|
|
123
150
|
placeholder: "Text",
|
|
124
151
|
required: !0,
|
|
125
152
|
type: "text",
|
|
126
|
-
value:
|
|
153
|
+
value: S
|
|
127
154
|
}
|
|
128
155
|
) }) }),
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
|
|
156
|
+
/* @__PURE__ */ T("div", { className: "richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2", children: [
|
|
157
|
+
/* @__PURE__ */ u(
|
|
158
|
+
oe,
|
|
132
159
|
{
|
|
133
|
-
checked:
|
|
134
|
-
onCheckedChange: (
|
|
135
|
-
|
|
160
|
+
checked: I,
|
|
161
|
+
onCheckedChange: (r) => {
|
|
162
|
+
M(r), e.commands.setCaseSensitive(r);
|
|
136
163
|
}
|
|
137
164
|
}
|
|
138
165
|
),
|
|
139
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ u(B, { children: t("editor.replace.caseSensitive") })
|
|
140
167
|
] }),
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
|
|
168
|
+
/* @__PURE__ */ T("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
|
|
169
|
+
/* @__PURE__ */ u(
|
|
170
|
+
N,
|
|
144
171
|
{
|
|
145
172
|
className: "richtext-flex-1",
|
|
146
|
-
onClick:
|
|
147
|
-
children:
|
|
173
|
+
onClick: U,
|
|
174
|
+
children: t("editor.replace.dialog.text")
|
|
148
175
|
}
|
|
149
176
|
),
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
|
|
177
|
+
/* @__PURE__ */ u(
|
|
178
|
+
N,
|
|
152
179
|
{
|
|
153
180
|
className: "richtext-flex-1",
|
|
154
|
-
onClick:
|
|
155
|
-
children:
|
|
181
|
+
onClick: J,
|
|
182
|
+
children: t("editor.replaceAll.dialog.text")
|
|
156
183
|
}
|
|
157
184
|
)
|
|
158
185
|
] })
|
|
@@ -161,94 +188,92 @@ function z({ editor: e, ...t }) {
|
|
|
161
188
|
)
|
|
162
189
|
]
|
|
163
190
|
}
|
|
164
|
-
);
|
|
191
|
+
) : /* @__PURE__ */ u(_, {});
|
|
165
192
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
193
|
+
const C = (t, e) => e(t.tr);
|
|
194
|
+
function ie(t, e, s) {
|
|
168
195
|
return RegExp(
|
|
169
|
-
|
|
196
|
+
e ? t.replace(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`) : t,
|
|
170
197
|
s ? "gu" : "gui"
|
|
171
198
|
);
|
|
172
199
|
}
|
|
173
|
-
function
|
|
174
|
-
const
|
|
175
|
-
let
|
|
176
|
-
if (!
|
|
200
|
+
function ue(t, e, s, n) {
|
|
201
|
+
const i = [], l = [];
|
|
202
|
+
let c = [], m = 0;
|
|
203
|
+
if (!e)
|
|
177
204
|
return {
|
|
178
|
-
decorationsToReturn:
|
|
205
|
+
decorationsToReturn: $.empty,
|
|
179
206
|
results: []
|
|
180
207
|
};
|
|
181
|
-
|
|
182
|
-
h.isText ?
|
|
183
|
-
text:
|
|
184
|
-
pos:
|
|
185
|
-
} :
|
|
208
|
+
t == null || t.descendants((h, o) => {
|
|
209
|
+
h.isText ? c[m] ? c[m] = {
|
|
210
|
+
text: c[m].text + h.text,
|
|
211
|
+
pos: c[m].pos
|
|
212
|
+
} : c[m] = {
|
|
186
213
|
text: `${h.text}`,
|
|
187
|
-
pos:
|
|
188
|
-
} :
|
|
189
|
-
}),
|
|
190
|
-
for (const h of
|
|
191
|
-
const { text:
|
|
192
|
-
([
|
|
214
|
+
pos: o
|
|
215
|
+
} : m += 1;
|
|
216
|
+
}), c = c.filter(Boolean);
|
|
217
|
+
for (const h of c) {
|
|
218
|
+
const { text: o, pos: f } = h, d = Array.from(o.matchAll(e)).filter(
|
|
219
|
+
([p]) => p.trim()
|
|
193
220
|
);
|
|
194
|
-
for (const
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
from: f +
|
|
198
|
-
to: f +
|
|
221
|
+
for (const p of d) {
|
|
222
|
+
if (p[0] === "") break;
|
|
223
|
+
p.index !== void 0 && l.push({
|
|
224
|
+
from: f + p.index,
|
|
225
|
+
to: f + p.index + p[0].length
|
|
199
226
|
});
|
|
200
227
|
}
|
|
201
228
|
}
|
|
202
|
-
for (const [h,
|
|
203
|
-
const f = h ===
|
|
229
|
+
for (const [h, o] of l.entries()) {
|
|
230
|
+
const f = h === n ? `${s} ${s}-current` : s, d = Z.inline(o.from, o.to, {
|
|
204
231
|
class: f
|
|
205
232
|
});
|
|
206
|
-
|
|
233
|
+
i.push(d);
|
|
207
234
|
}
|
|
208
235
|
return {
|
|
209
|
-
decorationsToReturn:
|
|
210
|
-
results:
|
|
236
|
+
decorationsToReturn: $.create(t, i),
|
|
237
|
+
results: l
|
|
211
238
|
};
|
|
212
239
|
}
|
|
213
|
-
function
|
|
214
|
-
if (!
|
|
215
|
-
const { from:
|
|
216
|
-
|
|
240
|
+
function K(t, e, { state: s, dispatch: n }) {
|
|
241
|
+
if (!e[0]) return;
|
|
242
|
+
const { from: l, to: c } = e[0];
|
|
243
|
+
n && n(s.tr.insertText(t, l, c));
|
|
217
244
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
if (!
|
|
221
|
-
const { from:
|
|
222
|
-
return
|
|
223
|
-
to:
|
|
224
|
-
from: h -
|
|
225
|
-
}, [
|
|
245
|
+
function me(t, e, s, n) {
|
|
246
|
+
const i = e + 1;
|
|
247
|
+
if (!n[i]) return null;
|
|
248
|
+
const { from: l, to: c } = n[e], m = c - l - t.length + s, { from: h, to: o } = n[i];
|
|
249
|
+
return n[i] = {
|
|
250
|
+
to: o - m,
|
|
251
|
+
from: h - m
|
|
252
|
+
}, [m, n];
|
|
226
253
|
}
|
|
227
|
-
function
|
|
228
|
-
let
|
|
229
|
-
if (
|
|
230
|
-
for (let
|
|
231
|
-
const { from:
|
|
232
|
-
s.insertText(
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
function he(t, e, { tr: s, dispatch: n }) {
|
|
255
|
+
let i = 0, l = e.slice();
|
|
256
|
+
if (l.length !== 0) {
|
|
257
|
+
for (let c = 0; c < l.length; c += 1) {
|
|
258
|
+
const { from: m, to: h } = l[c];
|
|
259
|
+
s.insertText(t, m, h);
|
|
260
|
+
const o = me(
|
|
261
|
+
t,
|
|
262
|
+
c,
|
|
263
|
+
i,
|
|
264
|
+
l
|
|
238
265
|
);
|
|
239
|
-
|
|
266
|
+
o && (i = o[0], l = o[1]);
|
|
240
267
|
}
|
|
241
|
-
|
|
268
|
+
n(s);
|
|
242
269
|
}
|
|
243
270
|
}
|
|
244
|
-
const
|
|
245
|
-
"searchAndReplacePlugin"
|
|
246
|
-
), ae = O.create({
|
|
271
|
+
const pe = Q.create({
|
|
247
272
|
name: "searchAndReplace",
|
|
248
273
|
addOptions() {
|
|
249
|
-
var
|
|
274
|
+
var t;
|
|
250
275
|
return {
|
|
251
|
-
...(
|
|
276
|
+
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
252
277
|
searchTerm: "",
|
|
253
278
|
replaceTerm: "",
|
|
254
279
|
results: [],
|
|
@@ -258,16 +283,15 @@ const Y = new j(
|
|
|
258
283
|
disableRegex: !0,
|
|
259
284
|
onChange: () => {
|
|
260
285
|
},
|
|
261
|
-
button: ({ editor:
|
|
262
|
-
component:
|
|
286
|
+
button: ({ editor: e, t: s }) => ({
|
|
287
|
+
// component: RichTextSearchAndReplace,
|
|
263
288
|
componentProps: {
|
|
264
289
|
action: () => {
|
|
265
290
|
},
|
|
266
291
|
icon: "SearchAndReplace",
|
|
267
292
|
tooltip: s("editor.searchAndReplace.tooltip"),
|
|
268
|
-
isActive: () => !
|
|
269
|
-
|
|
270
|
-
editor: t
|
|
293
|
+
isActive: () => !0,
|
|
294
|
+
editor: e
|
|
271
295
|
}
|
|
272
296
|
})
|
|
273
297
|
};
|
|
@@ -286,60 +310,60 @@ const Y = new j(
|
|
|
286
310
|
},
|
|
287
311
|
addCommands() {
|
|
288
312
|
return {
|
|
289
|
-
setSearchTerm: (
|
|
290
|
-
setReplaceTerm: (
|
|
291
|
-
setCaseSensitive: (
|
|
292
|
-
resetIndex: () => ({ editor:
|
|
293
|
-
nextSearchResult: () => ({ editor:
|
|
294
|
-
const { results:
|
|
295
|
-
return
|
|
313
|
+
setSearchTerm: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.searchTerm = t, C(s, n), !1),
|
|
314
|
+
setReplaceTerm: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.replaceTerm = t, C(s, n), !1),
|
|
315
|
+
setCaseSensitive: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.caseSensitive = t, C(s, n), !1),
|
|
316
|
+
resetIndex: () => ({ editor: t, state: e, dispatch: s }) => (t.storage.searchAndReplace.resultIndex = 0, C(e, s), !1),
|
|
317
|
+
nextSearchResult: () => ({ editor: t }) => {
|
|
318
|
+
const { results: e, resultIndex: s } = t.storage.searchAndReplace, n = s + 1;
|
|
319
|
+
return e[n] ? t.storage.searchAndReplace.resultIndex = n : t.storage.searchAndReplace.resultIndex = 0, !1;
|
|
296
320
|
},
|
|
297
|
-
previousSearchResult: () => ({ editor:
|
|
298
|
-
const { results:
|
|
299
|
-
return
|
|
321
|
+
previousSearchResult: () => ({ editor: t }) => {
|
|
322
|
+
const { results: e, resultIndex: s } = t.storage.searchAndReplace, n = s - 1;
|
|
323
|
+
return e[n] ? t.storage.searchAndReplace.resultIndex = n : t.storage.searchAndReplace.resultIndex = e.length - 1, !1;
|
|
300
324
|
},
|
|
301
|
-
replace: () => ({ editor:
|
|
302
|
-
const { replaceTerm:
|
|
303
|
-
return
|
|
325
|
+
replace: () => ({ editor: t, state: e, dispatch: s }) => {
|
|
326
|
+
const { replaceTerm: n, results: i, resultIndex: l } = t.storage.searchAndReplace, c = i[l];
|
|
327
|
+
return c ? (K(n, [c], { state: e, dispatch: s }), t.storage.searchAndReplace.results.splice(l, 1)) : (K(n, i, { state: e, dispatch: s }), t.storage.searchAndReplace.results.shift()), C(e, s), !1;
|
|
304
328
|
},
|
|
305
|
-
replaceAll: () => ({ editor:
|
|
306
|
-
const { replaceTerm:
|
|
307
|
-
return
|
|
329
|
+
replaceAll: () => ({ editor: t, tr: e, state: s, dispatch: n }) => {
|
|
330
|
+
const { replaceTerm: i, results: l } = t.storage.searchAndReplace;
|
|
331
|
+
return he(i, l, { tr: e, dispatch: n }), t.storage.searchAndReplace.resultIndex = 0, t.storage.searchAndReplace.results = [], C(s, n), !1;
|
|
308
332
|
}
|
|
309
333
|
};
|
|
310
334
|
},
|
|
311
335
|
addProseMirrorPlugins() {
|
|
312
|
-
const
|
|
336
|
+
const t = this.editor, { searchResultClass: e, disableRegex: s } = this.options, n = (c) => t.storage.searchAndReplace.lastSearchTerm = c, i = (c) => t.storage.searchAndReplace.lastCaseSensitive = c, l = (c) => t.storage.searchAndReplace.lastResultIndex = c;
|
|
313
337
|
return [
|
|
314
|
-
new
|
|
315
|
-
key: Y,
|
|
338
|
+
new X({
|
|
339
|
+
key: new Y(`richtextCustomPlugin${this.name}`),
|
|
316
340
|
state: {
|
|
317
|
-
init: () =>
|
|
318
|
-
apply({ doc:
|
|
341
|
+
init: () => $.empty,
|
|
342
|
+
apply({ doc: c, docChanged: m }, h) {
|
|
319
343
|
const {
|
|
320
|
-
searchTerm:
|
|
344
|
+
searchTerm: o,
|
|
321
345
|
lastSearchTerm: f,
|
|
322
|
-
caseSensitive:
|
|
323
|
-
lastCaseSensitive:
|
|
324
|
-
resultIndex:
|
|
325
|
-
lastResultIndex:
|
|
326
|
-
} =
|
|
327
|
-
if (!
|
|
346
|
+
caseSensitive: d,
|
|
347
|
+
lastCaseSensitive: p,
|
|
348
|
+
resultIndex: A,
|
|
349
|
+
lastResultIndex: S
|
|
350
|
+
} = t.storage.searchAndReplace;
|
|
351
|
+
if (!m && f === o && p === d && S === A)
|
|
328
352
|
return h;
|
|
329
|
-
if (
|
|
330
|
-
return
|
|
331
|
-
const { decorationsToReturn:
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
353
|
+
if (n(o), i(d), l(A), !o)
|
|
354
|
+
return t.storage.searchAndReplace.results = [], $.empty;
|
|
355
|
+
const { decorationsToReturn: w, results: I } = ue(
|
|
356
|
+
c,
|
|
357
|
+
ie(o, s, d),
|
|
358
|
+
e,
|
|
359
|
+
A
|
|
336
360
|
);
|
|
337
|
-
return
|
|
361
|
+
return t.storage.searchAndReplace.results = I, w;
|
|
338
362
|
}
|
|
339
363
|
},
|
|
340
364
|
props: {
|
|
341
|
-
decorations(
|
|
342
|
-
return this.getState(
|
|
365
|
+
decorations(c) {
|
|
366
|
+
return this.getState(c);
|
|
343
367
|
}
|
|
344
368
|
}
|
|
345
369
|
})
|
|
@@ -347,6 +371,6 @@ const Y = new j(
|
|
|
347
371
|
}
|
|
348
372
|
});
|
|
349
373
|
export {
|
|
350
|
-
|
|
351
|
-
|
|
374
|
+
ye as RichTextSearchAndReplace,
|
|
375
|
+
pe as SearchAndReplace
|
|
352
376
|
};
|
package/lib/SlashCommand.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index-RfTlOzIr.cjs"),H=require("@tiptap/pm/state"),$=require("./index-BH4bc3jN.cjs"),w=require("./updatePosition-8Sdem5jb.cjs"),d=require("react/jsx-runtime"),u=require("react"),j=require("./index-DV5kbgRU.cjs"),A=require("./Icon-DUpv2cI6.cjs"),g=require("./index-Dfmm6FTT.cjs"),D=require("./store-WStcMOiW.cjs"),O=g.d([]);function v(){const[t,n]=g.x(O);return[t,n]}const P={setOpen:(t,n)=>{g.dispatchEvent(g.EVENTS.UPLOAD_VIDEO(t),n)}};function y({t}){const n=[{name:"format",title:t("editor.slash.format"),commands:[]},{name:"insert",title:t("editor.slash.insert"),commands:[]}];return[1,2,3,4,5,6].forEach(e=>{n[0].commands.push({name:`heading${e}`,label:t(`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,action:({editor:i,range:l})=>{i.chain().focus().deleteRange(l).setHeading({level:e}).run()}})}),n[0].commands.push({name:"bulletList",label:t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleBulletList().run()}}),n[0].commands.push({name:"numberedList",label:t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleOrderedList().run()}}),n[0].commands.push({name:"taskList",label:t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleTaskList().run()}}),n[0].commands.push({name:"blockquote",label:t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setBlockquote().run()}}),n[0].commands.push({name:"codeBlock",label:t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setCodeBlock().run()}}),n[1].commands.push({name:"image",label:t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).run(),D.actionDialogImage.setOpen(e.id,!0)}}),n[1].commands.push({name:"video",label:t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).run(),P.setOpen(e.id,!0)}}),n[1].commands.push({name:"table",label:t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),n[1].commands.push({name:"horizontalRule",label:t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setHorizontalRule().run()}}),n[1].commands.push({name:"columns",label:t("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),n}function N(t,n){return t.map(l=>({...l,commands:l.commands.filter(s=>{const x=s.label.toLowerCase().trim(),m=n.toLowerCase().trim();if(s.aliases){const p=s.aliases.map(h=>h.toLowerCase().trim()),a=x.match(m),f=p.some(h=>h.match(m));return a||f}return x.match(m)})})).filter(l=>l.commands.length>0)}function V(t,n){const[e]=v(),[i,l]=u.useState(0),[s,x]=u.useState(0),m=u.useRef(null),{t:p}=g.useLocale(),a=N(e,t.query),f=u.useRef([]);u.useImperativeHandle(n,()=>({onKeyDown:h})),u.useEffect(()=>{if(!m.current)return;const r=s*1e3+i,o=f.current[r];o&&o.scrollIntoView({behavior:"smooth",block:"nearest"})},[i,s]);function h({event:r}){return r.key==="ArrowUp"?(R(),!0):r.key==="ArrowDown"?(L(),!0):r.key==="Enter"?(k(),!0):!1}function R(){var c;if(a.length===0)return!1;let r=i-1,o=s;r<0&&(o=s-1,r=((c=a[o])==null?void 0:c.commands.length)-1||0),o<0&&(o=a.length-1,r=a[o].commands.length-1),l(r),x(o)}function L(){if(a.length===0)return!1;const r=a[s].commands;let o=i+1,c=s;r.length-1<o&&(o=0,c=s+1),a.length-1<c&&(c=0),l(o),x(c)}function k(){if(a.length===0||s===-1||i===-1)return!1;C(s,i)}function C(r,o){const c=a[r].commands[o];t==null||t.command(c)}function I(r,o){C(r,o)}function S(r,o,c){f.current[r*1e3+o]=c}return d.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-[hsl(var(--richtext-border))] richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",ref:m,children:a!=null&&a.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:a==null?void 0:a.map((r,o)=>d.jsxs(u.Fragment,{children:[d.jsx("div",{className:"richtext-col-[1/-1] richtext-mx-2 richtext-mt-2 richtext-select-none richtext-text-[0.65rem] richtext-font-semibold richtext-uppercase richtext-tracking-wider !richtext-text-neutral-500 first:richtext-mt-0.5",children:r.title}),r.commands.map((c,b)=>d.jsxs("button",{onClick:()=>I(o,b),ref:q=>S(o,b,q),className:j.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm !richtext-text-neutral-800 dark:!richtext-text-neutral-200 richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"bg-item-active":s===o&&i===b}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(A.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${b}`))]},`slash-${r.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-gray-800 dark:richtext-text-gray-100",children:p("editor.slash.empty")})})})}const B=u.forwardRef(V);function T({commandList:t}){const[,n]=v(),{t:e}=g.useLocale();return u.useEffect(()=>{if(!(t!=null&&t.length)){const i=y({t:e});n(i);return}n(t)},[e,t]),d.jsx(d.Fragment,{})}const z=E.Extension.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[w.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new H.PluginKey(`richtextCustomPlugin${this.name}`),allow:({state:t,range:n})=>{var a,f,h;const e=t.doc.resolve(n.from),i=e.depth===1,l=e.parent.type.name==="paragraph",s=((a=e.parent.textContent)==null?void 0:a.charAt(0))==="/",x=this.editor.isActive("column"),m=(h=e.parent.textContent)==null?void 0:h.slice(Math.max(0,(f=e.parent.textContent)==null?void 0:f.indexOf("/"))),p=!(m!=null&&m.endsWith(" "));return(i&&l&&s||x&&l&&s)&&p},command:({editor:t,range:n,props:e})=>{const{view:i}=t;e.action({editor:t,range:n}),i.focus()},render:()=>{let t;return{onStart:n=>{n.clientRect&&(t=new $.ReactRenderer(B,{props:n,editor:n.editor}),t.element.style.position="absolute",document.body.appendChild(t.element),w.updatePosition(n.editor,t.element))},onUpdate(n){t.updateProps(n),n.clientRect&&w.updatePosition(n.editor,t.element)},onKeyDown(n){var e;return n.event.key==="Escape"?(t.destroy(),t.element.remove(),!0):(e=t.ref)==null?void 0:e.onKeyDown(n)},onExit(){t.destroy(),t.element.remove()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}});exports.SlashCommand=z;exports.SlashCommandList=T;exports.renderCommandListDefault=y;exports.useFilterCommandList=N;
|