@remarkablejames/editor 0.0.2 → 0.0.4
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-Bmn3RME4.js → ActionMenuButton-BUtJUsfO.js} +9 -10
- package/lib/ActionMenuButton-M55VtCZ5.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +166 -133
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +13 -12
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +11 -10
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +9 -8
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +42 -46
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +13 -14
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -5
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +30 -31
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +9 -8
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +18 -19
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +9 -8
- package/lib/Drawer-CdQBnwUs.cjs +2 -0
- package/lib/{Drawer-DvGh9aXG.js → Drawer-mlmJ2nCT.js} +41 -47
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +15 -16
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +24 -28
- package/lib/ExportPdf.cjs +3 -3
- package/lib/ExportPdf.js +14 -13
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +6 -6
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +8 -7
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +16 -15
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +27 -27
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +22 -23
- package/lib/History.cjs +1 -1
- package/lib/History.js +11 -11
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +10 -9
- package/lib/Iframe-B_a_AoZc.cjs +1 -0
- package/lib/{Iframe-CnnvV6cK.js → Iframe-CYgR99Ny.js} +11 -13
- 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 +79 -82
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +26 -27
- package/lib/Indent-BAcoFdaq.cjs +1 -0
- package/lib/{Indent-Bsj8gKvT.js → Indent-BMz2ILRl.js} +31 -30
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +12 -11
- package/lib/{Katex-CilGTz7u.js → Katex-DOlb4iTP.js} +19 -22
- package/lib/Katex-bIhj82VV.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +19 -20
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/LinkEditBlock-Cqs5RxjV.cjs +5 -0
- package/lib/{LinkEditBlock-BD_WvA3r.js → LinkEditBlock-xnokk4G7.js} +19 -24
- package/lib/Mention.js +3 -3
- package/lib/{Mermaid-BrjU75Bs.js → Mermaid-Bs3pIGc6.js} +45 -48
- package/lib/Mermaid-DiOdgQv1.cjs +2 -0
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +2 -2
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +26 -28
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +11 -10
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +37 -42
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-CLimjqhb.cjs +1 -0
- package/lib/{SlashCommandNodeView-COx5qZ2y.js → SlashCommandNodeView-CYcf7mVz.js} +67 -79
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +12 -11
- package/lib/{Table-BlM8yMhr.js → Table-bz1Wcojf.js} +47 -47
- package/lib/Table-dlXTKKwJ.cjs +5 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +12 -11
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +26 -27
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +18 -19
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +9 -8
- package/lib/{Twitter-BP8sYXX7.js → Twitter-CNTXzgt0.js} +18 -22
- package/lib/Twitter-DhEnGg6P.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -6
- package/lib/bubble.cjs +3 -3
- package/lib/bubble.js +78 -87
- package/lib/{clsx-m_C5j3RU.js → clsx-CDyrfCnw.js} +24 -24
- package/lib/{dropdown-menu-C1hdPLCZ.js → dropdown-menu-BuSlU2uN.js} +1 -1
- package/lib/{dropdown-menu-CkHN04Mx.cjs → dropdown-menu-CfWNst4v.cjs} +1 -1
- package/lib/extensions/Attachment/Attachment.d.ts +22 -2
- package/lib/extensions/Image/Image.d.ts +11 -0
- package/lib/extensions/Image/components/ImageCropper.d.ts +1 -1
- package/lib/index-8B00E8e4.js +5055 -0
- package/lib/index-BrxL7y9p.cjs +1 -0
- package/lib/index-Bt9LiArC.cjs +10 -0
- package/lib/{index-B3Ijnbxs.js → index-C-tDsIKJ.js} +1 -1
- package/lib/{index-C1KQsOcg.js → index-C1WCZhyA.js} +1 -1
- package/lib/{index-C8FjP66D.js → index-CsSfYR30.js} +1 -1
- package/lib/{index-4Q5IhypJ.js → index-DZfkCNKr.js} +15 -9
- package/lib/{index-s3l5RdyW.js → index-DjDf4BK8.js} +1 -1
- package/lib/index.cjs +4 -4
- package/lib/index.js +147 -392
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +1 -1
- package/lib/locales/en.d.ts +189 -188
- package/lib/locales/fi.d.ts +189 -188
- package/lib/locales/hu.d.ts +189 -188
- package/lib/locales/index.d.ts +1134 -1128
- package/lib/locales/pt-br.d.ts +189 -188
- package/lib/locales/vi.d.ts +189 -188
- package/lib/locales/zh-cn.d.ts +189 -188
- package/lib/{popover-B05Fd8lC.cjs → popover-51mwx3UY.cjs} +1 -1
- package/lib/{popover-CsSXh7w6.js → popover-DMPRgXD3.js} +1 -1
- package/lib/{renderNodeView-C_hPIdEs.js → renderNodeView-BJSrgyGj.js} +2 -2
- package/lib/{select-7ubC1NF0.cjs → select-B7v1Scb-.cjs} +1 -1
- package/lib/{select-B3-5wTqn.js → select-BxFDMaZi.js} +1 -1
- package/lib/{separator-CYCA8tSn.js → separator-CpqX9KQC.js} +12 -13
- package/lib/separator-kB9YUfeO.cjs +1 -0
- package/lib/style.css +1 -1
- package/lib/{textarea-1FhpmBkP.js → textarea-C5DsgzSy.js} +1 -1
- package/lib/{textarea-Bjhcpp76.cjs → textarea-bQSzjqg3.cjs} +1 -1
- package/lib/theme/theme.d.ts +1 -1
- package/lib/{updatePosition-DvfTZHcH.js → updatePosition-e90ZrFWW.js} +2 -2
- package/package.json +1 -1
- package/lib/ActionMenuButton-C5P0Kzrb.cjs +0 -1
- package/lib/Drawer-gz9U5ArC.cjs +0 -2
- package/lib/Icon-CKM0tYbW.js +0 -15
- package/lib/Icon-CQyFgXeo.cjs +0 -1
- package/lib/Iframe-Ds6gG2YO.cjs +0 -1
- package/lib/ImageCropper-BKhXlnXN.cjs +0 -1
- package/lib/ImageCropper-DUzu_9-6.js +0 -896
- package/lib/Indent-D_7HOYYd.cjs +0 -1
- package/lib/Katex-lL3bHXJd.cjs +0 -4
- package/lib/LinkEditBlock-D3HSHmsU.cjs +0 -5
- package/lib/Mermaid-BfeLPzoS.cjs +0 -2
- package/lib/SlashCommandNodeView-DD-nlhM-.cjs +0 -1
- package/lib/Table-C21AlUrh.cjs +0 -5
- package/lib/Twitter-D46MnvPr.cjs +0 -1
- package/lib/Video-Bpd8W8l6.js +0 -231
- package/lib/Video-BwrHx6B1.cjs +0 -1
- package/lib/button-BmTP96NR.cjs +0 -1
- package/lib/button-CDIxPURh.js +0 -35
- package/lib/checkbox-7sfSdzy9.js +0 -29
- package/lib/checkbox-DyVlLWHv.cjs +0 -1
- package/lib/dialog-B-jOQ5i3.cjs +0 -1
- package/lib/dialog-QWWUWOGP.js +0 -95
- package/lib/events.constant-Bh2uzJud.js +0 -71
- package/lib/events.constant-ELn21EzG.cjs +0 -1
- package/lib/file-BLas99n7.js +0 -43
- package/lib/file-i7e4nQY2.cjs +0 -1
- package/lib/index-CAiZY1nx.js +0 -2741
- package/lib/index-DWSAk_9a.cjs +0 -1
- package/lib/index-bVGIXhRg.cjs +0 -1
- package/lib/input-qvpuOf-3.js +0 -21
- package/lib/input-s0JD5kf2.cjs +0 -1
- package/lib/isNumber-BTYSVlKo.cjs +0 -1
- package/lib/isNumber-WaBzl_0s.js +0 -15
- package/lib/label-CFax-gzo.cjs +0 -1
- package/lib/label-DC37f2RQ.js +0 -11
- package/lib/separator-ncbdw4oq.cjs +0 -1
- package/lib/tabs-BeHxylKH.js +0 -46
- package/lib/tabs-DBqNpGAq.cjs +0 -1
- package/lib/throttle-CRNq0z-O.js +0 -249
- package/lib/throttle-gTTvqDTW.cjs +0 -1
- package/lib/toggle-DoJTBdvy.js +0 -89
- package/lib/toggle-oFwBZC4x.cjs +0 -1
- package/lib/useButtonProps-BE10eHkG.js +0 -165
- package/lib/useButtonProps-CFu0GHzW.cjs +0 -1
package/lib/MoreMark.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { M as h, m, E as b } from "./clsx-
|
|
2
|
-
import { jsx as e, Fragment as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { D as
|
|
7
|
-
import { M as w } from "./index-CAiZY1nx.js";
|
|
8
|
-
import { I as C } from "./Icon-CKM0tYbW.js";
|
|
1
|
+
import { M as h, m, E as b } from "./clsx-CDyrfCnw.js";
|
|
2
|
+
import { jsx as e, Fragment as M, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as f } from "react";
|
|
4
|
+
import { u as x, e as A, A as S, M as k, I as v, g as y } from "./index-8B00E8e4.js";
|
|
5
|
+
import "./theme.js";
|
|
6
|
+
import { D as T, a as K, b as w, c as C } from "./dropdown-menu-BuSlU2uN.js";
|
|
9
7
|
var H = h.create({
|
|
10
8
|
name: "subscript",
|
|
11
9
|
addOptions() {
|
|
@@ -77,39 +75,39 @@ var H = h.create({
|
|
|
77
75
|
};
|
|
78
76
|
}
|
|
79
77
|
});
|
|
80
|
-
function
|
|
81
|
-
const t =
|
|
78
|
+
function z() {
|
|
79
|
+
const t = x(D.name), {
|
|
82
80
|
icon: s = void 0,
|
|
83
|
-
tooltip:
|
|
81
|
+
tooltip: n = void 0,
|
|
84
82
|
items: i = [],
|
|
85
83
|
isActive: a = void 0
|
|
86
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState:
|
|
87
|
-
return t ? /* @__PURE__ */ d(
|
|
88
|
-
/* @__PURE__ */ e(
|
|
89
|
-
|
|
84
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } = A(a), p = f(() => (o == null ? void 0 : o.title) || "", [o]);
|
|
85
|
+
return t ? /* @__PURE__ */ d(T, { children: [
|
|
86
|
+
/* @__PURE__ */ e(K, { asChild: !0, disabled: c, children: /* @__PURE__ */ e(
|
|
87
|
+
S,
|
|
90
88
|
{
|
|
91
89
|
customClass: "!richtext-w-12 richtext-h-12",
|
|
92
90
|
disabled: c,
|
|
93
91
|
icon: s,
|
|
94
|
-
tooltip:
|
|
95
|
-
children: /* @__PURE__ */ e(
|
|
92
|
+
tooltip: n,
|
|
93
|
+
children: /* @__PURE__ */ e(k, { className: "richtext-size-3 richtext-text-gray-500" })
|
|
96
94
|
}
|
|
97
95
|
) }),
|
|
98
|
-
/* @__PURE__ */ e(
|
|
99
|
-
|
|
96
|
+
/* @__PURE__ */ e(w, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
|
|
97
|
+
C,
|
|
100
98
|
{
|
|
101
99
|
checked: p === r.title,
|
|
102
100
|
className: "richtext-flex richtext-items-center richtext-gap-3",
|
|
103
101
|
onClick: r.action,
|
|
104
102
|
children: [
|
|
105
|
-
/* @__PURE__ */ e(
|
|
103
|
+
/* @__PURE__ */ e(v, { name: r == null ? void 0 : r.icon }),
|
|
106
104
|
/* @__PURE__ */ e("span", { className: "richtext-ml-1", children: r.title }),
|
|
107
|
-
!!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children:
|
|
105
|
+
!!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children: y(r.shortcutKeys) })
|
|
108
106
|
]
|
|
109
107
|
},
|
|
110
108
|
`more-mark-${u}`
|
|
111
109
|
)) })
|
|
112
|
-
] }) : /* @__PURE__ */ e(
|
|
110
|
+
] }) : /* @__PURE__ */ e(M, {});
|
|
113
111
|
}
|
|
114
112
|
const D = /* @__PURE__ */ b.create({
|
|
115
113
|
name: "moreMark",
|
|
@@ -118,24 +116,24 @@ const D = /* @__PURE__ */ b.create({
|
|
|
118
116
|
var t;
|
|
119
117
|
return {
|
|
120
118
|
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
121
|
-
button({ editor: s, extension:
|
|
119
|
+
button({ editor: s, extension: n, t: i }) {
|
|
122
120
|
var u, l;
|
|
123
|
-
const a =
|
|
121
|
+
const a = n.options.subscript, c = n.options.superscript, o = {
|
|
124
122
|
action: () => s.commands.toggleSubscript(),
|
|
125
123
|
isActive: () => s.isActive("subscript") || !1,
|
|
126
124
|
disabled: !s.can().toggleSubscript(),
|
|
127
125
|
icon: "Subscript",
|
|
128
126
|
title: i("editor.subscript.tooltip"),
|
|
129
|
-
shortcutKeys: ((u =
|
|
127
|
+
shortcutKeys: ((u = n.options.shortcutKeys) == null ? void 0 : u[0]) ?? ["mod", "."]
|
|
130
128
|
}, p = {
|
|
131
129
|
action: () => s.commands.toggleSuperscript(),
|
|
132
130
|
isActive: () => s.isActive("superscript") || !1,
|
|
133
131
|
disabled: !s.can().toggleSuperscript(),
|
|
134
132
|
icon: "Superscript",
|
|
135
133
|
title: i("editor.superscript.tooltip"),
|
|
136
|
-
shortcutKeys: ((l =
|
|
134
|
+
shortcutKeys: ((l = n.options.shortcutKeys) == null ? void 0 : l[1]) ?? ["mod", ","]
|
|
137
135
|
}, r = [];
|
|
138
|
-
return a !== !1 && r.push(
|
|
136
|
+
return a !== !1 && r.push(o), c !== !1 && r.push(p), {
|
|
139
137
|
// component: ActionMoreButton,
|
|
140
138
|
componentProps: {
|
|
141
139
|
icon: "Type",
|
|
@@ -155,5 +153,5 @@ const D = /* @__PURE__ */ b.create({
|
|
|
155
153
|
});
|
|
156
154
|
export {
|
|
157
155
|
D as MoreMark,
|
|
158
|
-
|
|
156
|
+
z as RichTextMoreMark
|
|
159
157
|
};
|
package/lib/OrderedList.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 v=require("./index-BCzvbrf5.cjs"),r=require("react/jsx-runtime"),s=require("./index-Bt9LiArC.cjs");require("react");require("./theme.cjs");function O(){const t=s.useButtonProps(c.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:o=void 0,tooltipOptions:u={},action:n=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:d,update:l}=s.useToggleActive(a),m=()=>{d||n&&(n(),l())};return t?r.jsx(s.ActionButton,{action:m,dataState:p,disabled:d,icon:e,shortcutKeys:o,tooltip:i,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=v.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:o})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:o.options.shortcutKeys??["mod","shift","7"],tooltip:i("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=O;
|
package/lib/OrderedList.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { O as u } from "./index-
|
|
2
|
-
import { jsx as n, Fragment as
|
|
3
|
-
import { A as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { O as u } from "./index-DjDf4BK8.js";
|
|
2
|
+
import { jsx as n, Fragment as l } from "react/jsx-runtime";
|
|
3
|
+
import { u as f, d as v, A as O } from "./index-8B00E8e4.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "./theme.js";
|
|
6
|
+
function K() {
|
|
7
|
+
const t = f(A.name), {
|
|
7
8
|
icon: o = void 0,
|
|
8
9
|
tooltip: i = void 0,
|
|
9
10
|
shortcutKeys: e = void 0,
|
|
10
11
|
tooltipOptions: d = {},
|
|
11
12
|
action: s = void 0,
|
|
12
13
|
isActive: c = void 0
|
|
13
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: a, disabled: r, update: p } =
|
|
14
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: a, disabled: r, update: p } = v(c), m = () => {
|
|
14
15
|
r || s && (s(), p());
|
|
15
16
|
};
|
|
16
17
|
return t ? /* @__PURE__ */ n(
|
|
17
|
-
|
|
18
|
+
O,
|
|
18
19
|
{
|
|
19
20
|
action: m,
|
|
20
21
|
dataState: a,
|
|
@@ -24,7 +25,7 @@ function y() {
|
|
|
24
25
|
tooltip: i,
|
|
25
26
|
tooltipOptions: d
|
|
26
27
|
}
|
|
27
|
-
) : /* @__PURE__ */ n(
|
|
28
|
+
) : /* @__PURE__ */ n(l, {});
|
|
28
29
|
}
|
|
29
30
|
const A = /* @__PURE__ */ u.extend({
|
|
30
31
|
//@ts-expect-error
|
|
@@ -47,5 +48,5 @@ const A = /* @__PURE__ */ u.extend({
|
|
|
47
48
|
});
|
|
48
49
|
export {
|
|
49
50
|
A as OrderedList,
|
|
50
|
-
|
|
51
|
+
K as RichTextOrderedList
|
|
51
52
|
};
|
package/lib/SearchAndReplace.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 G=require("./clsx-CXbNJWDD.cjs"),D=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),g=require("react"),h=require("./index-Bt9LiArC.cjs");require("./theme.cjs");const J=require("./index-BrxL7y9p.cjs"),q=require("./popover-51mwx3UY.cjs");function Q(){const{t}=J.useLocale(),e=h.useEditorInstance(),s=h.useButtonProps(F.name),{icon:n=void 0,tooltip:u=void 0,shortcutKeys:o=void 0,tooltipOptions:c={},action:x=void 0,isActive:m=void 0}=(s==null?void 0:s.componentProps)??{},{disabled:i}=h.useActive(m),[R,f]=g.useState(!1),[p,T]=g.useState(""),[C,N]=g.useState(""),[j,M]=g.useState(!1),[V,B]=g.useState(""),w=()=>{var r,l,v,d;B(`${((l=(r=e==null?void 0:e.storage)==null?void 0:r.searchAndReplace)==null?void 0:l.resultIndex)+1}/${(d=(v=e==null?void 0:e.storage)==null?void 0:v.searchAndReplace)==null?void 0:d.results.length}`)};g.useEffect(()=>{e&&w()},[e]);const K=()=>{i||x&&x()},P=(r=!1)=>{var l,v,d,S,A,L,y,$;e&&(r&&((v=(l=e==null?void 0:e.commands)==null?void 0:l.resetIndex)==null||v.call(l)),(S=(d=e==null?void 0:e.commands)==null?void 0:d.setSearchTerm)==null||S.call(d,p),(L=(A=e==null?void 0:e.commands)==null?void 0:A.setReplaceTerm)==null||L.call(A,C),($=(y=e==null?void 0:e.commands)==null?void 0:y.setCaseSensitive)==null||$.call(y,j),w())},k=()=>{var S,A;if(!e)return;const{results:r,resultIndex:l}=e.storage.searchAndReplace,v=r[l];if(!v)return;(A=(S=e==null?void 0:e.commands)==null?void 0:S.setTextSelection)==null||A.call(S,v);const{node:d}=e.view.domAtPos(e.state.selection.anchor);d instanceof HTMLElement&&d.scrollIntoView({behavior:"smooth",block:"center"}),w()};g.useEffect(()=>{p.trim()||E(),p.trim()&&P(!0)},[p]),g.useEffect(()=>{C.trim()&&P()},[C]),g.useEffect(()=>{P(!0)},[j]);const W=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replace)==null||l.call(r),k()},H=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.nextSearchResult)==null||l.call(r),k()},U=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.previousSearchResult)==null||l.call(r),k()},E=()=>{var r,l;T(""),N(""),(l=(r=e==null?void 0:e.commands)==null?void 0:r.resetIndex)==null||l.call(r),w()},z=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replaceAll)==null||l.call(r),B("0/0")};return s?a.jsxs(q.Popover,{onOpenChange:f,open:R,children:[a.jsx(q.PopoverTrigger,{asChild:!0,disabled:i,children:a.jsx(h.ActionButton,{action:K,disabled:i,icon:n,shortcutKeys:o,tooltip:u,tooltipOptions:c})}),a.jsxs(q.PopoverContent,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:[a.jsxs("div",{className:"richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between",children:[a.jsx(h.Label,{children:t("editor.search.dialog.text")}),a.jsx("span",{className:"richtext-font-semibold",children:V})]}),a.jsxs("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:[a.jsx(h.Input,{autoFocus:!0,className:"richtext-w-full",onChange:r=>T(r.target.value),placeholder:"Text",required:!0,type:"text",value:p}),a.jsx(h.Button,{className:"richtext-flex-1",onClick:U,children:a.jsx(h.IconComponent,{name:"ChevronUp"})}),a.jsx(h.Button,{className:"richtext-flex-1",onClick:H,children:a.jsx(h.IconComponent,{name:"ChevronDown"})}),a.jsx(h.Button,{className:"richtext-flex-1",onClick:E,children:"Clear"})]}),a.jsx(h.Label,{className:"richtext-mb-[6px]",children:t("editor.replace.dialog.text")}),a.jsx("div",{className:"richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:a.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:a.jsx(h.Input,{className:"richtext-w-80",onChange:r=>N(r.target.value),placeholder:"Text",required:!0,type:"text",value:C})})}),a.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1",children:[a.jsx(h.Checkbox,{checked:j,onCheckedChange:r=>{M(r),e.commands.setCaseSensitive(r)}}),a.jsx(h.Label,{children:t("editor.replace.caseSensitive")})]}),a.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[a.jsx(h.Button,{className:"richtext-flex-1",onClick:W,children:t("editor.replace.dialog.text")}),a.jsx(h.Button,{className:"richtext-flex-1",onClick:z,children:t("editor.replaceAll.dialog.text")})]})]})]}):a.jsx(a.Fragment,{})}const I=(t,e)=>e(t.tr);function X(t,e,s){return RegExp(e?t.replace(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`):t,s?"gu":"gui")}function Y(t,e,s,n){const u=[],o=[];let c=[],x=0;if(!e)return{decorationsToReturn:b.DecorationSet.empty,results:[]};t==null||t.descendants((m,i)=>{m.isText?c[x]?c[x]={text:c[x].text+m.text,pos:c[x].pos}:c[x]={text:`${m.text}`,pos:i}:x+=1}),c=c.filter(Boolean);for(const m of c){const{text:i,pos:R}=m,f=Array.from(i.matchAll(e)).filter(([p])=>p.trim());for(const p of f){if(p[0]==="")break;p.index!==void 0&&o.push({from:R+p.index,to:R+p.index+p[0].length})}}for(const[m,i]of o.entries()){const R=m===n?`${s} ${s}-current`:s,f=b.Decoration.inline(i.from,i.to,{class:R});u.push(f)}return{decorationsToReturn:b.DecorationSet.create(t,u),results:o}}function O(t,e,{state:s,dispatch:n}){if(!e[0])return;const{from:o,to:c}=e[0];n&&n(s.tr.insertText(t,o,c))}function Z(t,e,s,n){const u=e+1;if(!n[u])return null;const{from:o,to:c}=n[e],x=c-o-t.length+s,{from:m,to:i}=n[u];return n[u]={to:i-x,from:m-x},[x,n]}function _(t,e,{tr:s,dispatch:n}){let u=0,o=e.slice();if(o.length!==0){for(let c=0;c<o.length;c+=1){const{from:x,to:m}=o[c];s.insertText(t,x,m);const i=Z(t,c,u,o);i&&(u=i[0],o=i[1])}n(s)}}const F=G.Extension.create({name:"searchAndReplace",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),searchTerm:"",replaceTerm:"",results:[],searchResultClass:"search-result",searchResultCurrentClass:"search-result-current",caseSensitive:!1,disableRegex:!0,onChange:()=>{},button:({editor:e,t:s})=>({componentProps:{action:()=>{},icon:"SearchAndReplace",tooltip:s("editor.searchAndReplace.tooltip"),isActive:()=>!0,editor:e}})}},addStorage(){return{searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}},addCommands(){return{setSearchTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.searchTerm=t,I(s,n),!1),setReplaceTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.replaceTerm=t,I(s,n),!1),setCaseSensitive:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.caseSensitive=t,I(s,n),!1),resetIndex:()=>({editor:t,state:e,dispatch:s})=>(t.storage.searchAndReplace.resultIndex=0,I(e,s),!1),nextSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s+1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:t})=>{const{results:e,resultIndex:s}=t.storage.searchAndReplace,n=s-1;return e[n]?t.storage.searchAndReplace.resultIndex=n:t.storage.searchAndReplace.resultIndex=e.length-1,!1},replace:()=>({editor:t,state:e,dispatch:s})=>{const{replaceTerm:n,results:u,resultIndex:o}=t.storage.searchAndReplace,c=u[o];return c?(O(n,[c],{state:e,dispatch:s}),t.storage.searchAndReplace.results.splice(o,1)):(O(n,u,{state:e,dispatch:s}),t.storage.searchAndReplace.results.shift()),I(e,s),!1},replaceAll:()=>({editor:t,tr:e,state:s,dispatch:n})=>{const{replaceTerm:u,results:o}=t.storage.searchAndReplace;return _(u,o,{tr:e,dispatch:n}),t.storage.searchAndReplace.resultIndex=0,t.storage.searchAndReplace.results=[],I(s,n),!1}}},addProseMirrorPlugins(){const t=this.editor,{searchResultClass:e,disableRegex:s}=this.options,n=c=>t.storage.searchAndReplace.lastSearchTerm=c,u=c=>t.storage.searchAndReplace.lastCaseSensitive=c,o=c=>t.storage.searchAndReplace.lastResultIndex=c;return[new D.Plugin({key:new D.PluginKey(`richtextCustomPlugin${this.name}`),state:{init:()=>b.DecorationSet.empty,apply({doc:c,docChanged:x},m){const{searchTerm:i,lastSearchTerm:R,caseSensitive:f,lastCaseSensitive:p,resultIndex:T,lastResultIndex:C}=t.storage.searchAndReplace;if(!x&&R===i&&p===f&&C===T)return m;if(n(i),u(f),o(T),!i)return t.storage.searchAndReplace.results=[],b.DecorationSet.empty;const{decorationsToReturn:N,results:j}=Y(c,X(i,s,f),e,T);return t.storage.searchAndReplace.results=j,N}},props:{decorations(c){return this.getState(c)}}})]}});exports.RichTextSearchAndReplace=Q;exports.SearchAndReplace=F;
|
package/lib/SearchAndReplace.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import { E as Q } from "./clsx-
|
|
1
|
+
import { E as Q } from "./clsx-CDyrfCnw.js";
|
|
2
2
|
import { Plugin as X, PluginKey as Y } from "@tiptap/pm/state";
|
|
3
3
|
import { DecorationSet as $, Decoration as Z } from "@tiptap/pm/view";
|
|
4
4
|
import { jsx as u, Fragment as _, jsxs as T } from "react/jsx-runtime";
|
|
5
5
|
import { useState as b, useEffect as k } from "react";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { u as
|
|
9
|
-
import { P as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { B as N } from "./button-CDIxPURh.js";
|
|
13
|
-
import { I as q } from "./Icon-CKM0tYbW.js";
|
|
14
|
-
import { C as oe } from "./checkbox-7sfSdzy9.js";
|
|
15
|
-
function ye() {
|
|
16
|
-
const { t } = ne(), e = te(), s = se(pe.name), {
|
|
6
|
+
import { h as ee, u as te, e as se, A as re, L as B, j as V, B as N, I as q, C as ne } from "./index-8B00E8e4.js";
|
|
7
|
+
import "./theme.js";
|
|
8
|
+
import { u as ce } from "./index-DZfkCNKr.js";
|
|
9
|
+
import { P as ae, a as le, b as oe } from "./popover-DMPRgXD3.js";
|
|
10
|
+
function Ce() {
|
|
11
|
+
const { t } = ce(), e = ee(), s = te(xe.name), {
|
|
17
12
|
icon: n = void 0,
|
|
18
13
|
tooltip: i = void 0,
|
|
19
14
|
shortcutKeys: l = void 0,
|
|
20
15
|
tooltipOptions: c = {},
|
|
21
16
|
action: h = void 0,
|
|
22
17
|
isActive: m = void 0
|
|
23
|
-
} = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } =
|
|
24
|
-
var r, a, g,
|
|
25
|
-
|
|
26
|
-
`${((a = (r = e == null ? void 0 : e.storage) == null ? void 0 : r.searchAndReplace) == null ? void 0 : a.resultIndex) + 1}/${(
|
|
18
|
+
} = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = se(m), [f, d] = b(!1), [x, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, j] = b(""), y = () => {
|
|
19
|
+
var r, a, g, p;
|
|
20
|
+
j(
|
|
21
|
+
`${((a = (r = e == null ? void 0 : e.storage) == null ? void 0 : r.searchAndReplace) == null ? void 0 : a.resultIndex) + 1}/${(p = (g = e == null ? void 0 : e.storage) == null ? void 0 : g.searchAndReplace) == null ? void 0 : p.results.length}`
|
|
27
22
|
);
|
|
28
23
|
};
|
|
29
24
|
k(() => {
|
|
@@ -32,20 +27,20 @@ function ye() {
|
|
|
32
27
|
const H = () => {
|
|
33
28
|
o || h && h();
|
|
34
29
|
}, L = (r = !1) => {
|
|
35
|
-
var a, g,
|
|
36
|
-
e && (r && ((g = (a = e == null ? void 0 : e.commands) == null ? void 0 : a.resetIndex) == null || g.call(a)), (R = (
|
|
30
|
+
var a, g, p, R, v, F, P, O;
|
|
31
|
+
e && (r && ((g = (a = e == null ? void 0 : e.commands) == null ? void 0 : a.resetIndex) == null || g.call(a)), (R = (p = e == null ? void 0 : e.commands) == null ? void 0 : p.setSearchTerm) == null || R.call(p, x), (F = (v = e == null ? void 0 : e.commands) == null ? void 0 : v.setReplaceTerm) == null || F.call(v, S), (O = (P = e == null ? void 0 : e.commands) == null ? void 0 : P.setCaseSensitive) == null || O.call(P, I), y());
|
|
37
32
|
}, E = () => {
|
|
38
33
|
var R, v;
|
|
39
34
|
if (!e) return;
|
|
40
35
|
const { results: r, resultIndex: a } = e.storage.searchAndReplace, g = r[a];
|
|
41
36
|
if (!g) return;
|
|
42
37
|
(v = (R = e == null ? void 0 : e.commands) == null ? void 0 : R.setTextSelection) == null || v.call(R, g);
|
|
43
|
-
const { node:
|
|
44
|
-
|
|
38
|
+
const { node: p } = e.view.domAtPos(e.state.selection.anchor);
|
|
39
|
+
p instanceof HTMLElement && p.scrollIntoView({ behavior: "smooth", block: "center" }), y();
|
|
45
40
|
};
|
|
46
41
|
k(() => {
|
|
47
|
-
|
|
48
|
-
}, [
|
|
42
|
+
x.trim() || D(), x.trim() && L(!0);
|
|
43
|
+
}, [x]), k(() => {
|
|
49
44
|
S.trim() && L();
|
|
50
45
|
}, [S]), k(() => {
|
|
51
46
|
L(!0);
|
|
@@ -59,16 +54,16 @@ function ye() {
|
|
|
59
54
|
}, G = () => {
|
|
60
55
|
var r, a;
|
|
61
56
|
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.previousSearchResult) == null || a.call(r), E();
|
|
62
|
-
},
|
|
57
|
+
}, D = () => {
|
|
63
58
|
var r, a;
|
|
64
59
|
A(""), w(""), (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.resetIndex) == null || a.call(r), y();
|
|
65
60
|
}, J = () => {
|
|
66
61
|
var r, a;
|
|
67
|
-
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r),
|
|
62
|
+
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), j("0/0");
|
|
68
63
|
};
|
|
69
|
-
return s ? /* @__PURE__ */ T(
|
|
70
|
-
/* @__PURE__ */ u(
|
|
71
|
-
|
|
64
|
+
return s ? /* @__PURE__ */ T(ae, { onOpenChange: d, open: f, children: [
|
|
65
|
+
/* @__PURE__ */ u(le, { asChild: !0, disabled: o, children: /* @__PURE__ */ u(
|
|
66
|
+
re,
|
|
72
67
|
{
|
|
73
68
|
action: H,
|
|
74
69
|
disabled: o,
|
|
@@ -78,7 +73,7 @@ function ye() {
|
|
|
78
73
|
tooltipOptions: c
|
|
79
74
|
}
|
|
80
75
|
) }),
|
|
81
|
-
/* @__PURE__ */ T(
|
|
76
|
+
/* @__PURE__ */ T(oe, { align: "start", className: "richtext-w-full", hideWhenDetached: !0, side: "bottom", children: [
|
|
82
77
|
/* @__PURE__ */ T("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
|
|
83
78
|
/* @__PURE__ */ u(B, { children: t("editor.search.dialog.text") }),
|
|
84
79
|
/* @__PURE__ */ u("span", { className: "richtext-font-semibold", children: W })
|
|
@@ -93,12 +88,12 @@ function ye() {
|
|
|
93
88
|
placeholder: "Text",
|
|
94
89
|
required: !0,
|
|
95
90
|
type: "text",
|
|
96
|
-
value:
|
|
91
|
+
value: x
|
|
97
92
|
}
|
|
98
93
|
),
|
|
99
94
|
/* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: G, children: /* @__PURE__ */ u(q, { name: "ChevronUp" }) }),
|
|
100
95
|
/* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: z, children: /* @__PURE__ */ u(q, { name: "ChevronDown" }) }),
|
|
101
|
-
/* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick:
|
|
96
|
+
/* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: D, children: "Clear" })
|
|
102
97
|
] }),
|
|
103
98
|
/* @__PURE__ */ u(B, { className: "richtext-mb-[6px]", children: t("editor.replace.dialog.text") }),
|
|
104
99
|
/* @__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(
|
|
@@ -114,7 +109,7 @@ function ye() {
|
|
|
114
109
|
) }) }),
|
|
115
110
|
/* @__PURE__ */ T("div", { className: "richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1", children: [
|
|
116
111
|
/* @__PURE__ */ u(
|
|
117
|
-
|
|
112
|
+
ne,
|
|
118
113
|
{
|
|
119
114
|
checked: I,
|
|
120
115
|
onCheckedChange: (r) => {
|
|
@@ -156,12 +151,12 @@ function ue(t, e, s, n) {
|
|
|
156
151
|
} : h += 1;
|
|
157
152
|
}), c = c.filter(Boolean);
|
|
158
153
|
for (const m of c) {
|
|
159
|
-
const { text: o, pos: f } = m, d = Array.from(o.matchAll(e)).filter(([
|
|
160
|
-
for (const
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
from: f +
|
|
164
|
-
to: f +
|
|
154
|
+
const { text: o, pos: f } = m, d = Array.from(o.matchAll(e)).filter(([x]) => x.trim());
|
|
155
|
+
for (const x of d) {
|
|
156
|
+
if (x[0] === "") break;
|
|
157
|
+
x.index !== void 0 && l.push({
|
|
158
|
+
from: f + x.index,
|
|
159
|
+
to: f + x.index + x[0].length
|
|
165
160
|
});
|
|
166
161
|
}
|
|
167
162
|
}
|
|
@@ -202,7 +197,7 @@ function me(t, e, { tr: s, dispatch: n }) {
|
|
|
202
197
|
n(s);
|
|
203
198
|
}
|
|
204
199
|
}
|
|
205
|
-
const
|
|
200
|
+
const xe = Q.create({
|
|
206
201
|
name: "searchAndReplace",
|
|
207
202
|
addOptions() {
|
|
208
203
|
var t;
|
|
@@ -278,11 +273,11 @@ const pe = Q.create({
|
|
|
278
273
|
searchTerm: o,
|
|
279
274
|
lastSearchTerm: f,
|
|
280
275
|
caseSensitive: d,
|
|
281
|
-
lastCaseSensitive:
|
|
276
|
+
lastCaseSensitive: x,
|
|
282
277
|
resultIndex: A,
|
|
283
278
|
lastResultIndex: S
|
|
284
279
|
} = t.storage.searchAndReplace;
|
|
285
|
-
if (!h && f === o &&
|
|
280
|
+
if (!h && f === o && x === d && S === A)
|
|
286
281
|
return m;
|
|
287
282
|
if (n(o), i(d), l(A), !o)
|
|
288
283
|
return t.storage.searchAndReplace.results = [], $.empty;
|
|
@@ -305,6 +300,6 @@ const pe = Q.create({
|
|
|
305
300
|
}
|
|
306
301
|
});
|
|
307
302
|
export {
|
|
308
|
-
|
|
309
|
-
|
|
303
|
+
Ce as RichTextSearchAndReplace,
|
|
304
|
+
xe as SearchAndReplace
|
|
310
305
|
};
|
package/lib/SlashCommand.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./clsx-CXbNJWDD.cjs"),u=require("@tiptap/pm/state"),d=require("./index-Cs6cp0Y6.cjs"),r=require("./SlashCommandNodeView-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./clsx-CXbNJWDD.cjs"),u=require("@tiptap/pm/state"),d=require("./index-Cs6cp0Y6.cjs"),r=require("./SlashCommandNodeView-CLimjqhb.cjs"),a=require("./updatePosition-Cjuj2E26.cjs"),s=require("react/jsx-runtime"),l=require("react"),m=require("./index-BrxL7y9p.cjs");function c({commandList:e}){const[,t]=r.useSignalCommandList(),{t:n}=m.useLocale();return l.useEffect(()=>{if(!(e!=null&&e.length)){const o=r.renderCommandListDefault({t:n});t(o);return}t(e)},[n,e]),s.jsx(s.Fragment,{})}const C=i.Extension.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[d.Suggestion({pluginKey:new u.PluginKey("richtextSlashCommandPlugin"),editor:this.editor,char:"/",command:({editor:e,range:t,props:n})=>{const{view:o}=e;n.action({editor:e,range:t}),o.focus()},render:()=>{let e;return{onStart:t=>{t.clientRect&&(e=new i.ReactRenderer(r.SlashCommandNodeView,{props:t,editor:t.editor}),e.element.style.position="absolute",document.body.appendChild(e.element),a.updatePosition(t.editor,e.element))},onUpdate(t){e.updateProps(t),t.clientRect&&a.updatePosition(t.editor,e.element)},onKeyDown(t){var n;return t.event.key==="Escape"?(e.destroy(),e.element.remove(),!0):(n=e.ref)==null?void 0:n.onKeyDown(t)},onExit(){e&&(e.destroy(),e.element.remove())}}}})]}});exports.renderCommandListDefault=r.renderCommandListDefault;exports.useFilterCommandList=r.useFilterCommandList;exports.SlashCommand=C;exports.SlashCommandList=c;
|
package/lib/SlashCommand.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { E as i, R as a } from "./clsx-
|
|
1
|
+
import { E as i, R as a } from "./clsx-CDyrfCnw.js";
|
|
2
2
|
import { PluginKey as m } from "@tiptap/pm/state";
|
|
3
|
-
import { S as s } from "./index-
|
|
4
|
-
import { u, r as l, S as d } from "./SlashCommandNodeView-
|
|
5
|
-
import { a as b } from "./SlashCommandNodeView-
|
|
6
|
-
import { u as o } from "./updatePosition-
|
|
3
|
+
import { S as s } from "./index-CsSfYR30.js";
|
|
4
|
+
import { u, r as l, S as d } from "./SlashCommandNodeView-CYcf7mVz.js";
|
|
5
|
+
import { a as b } from "./SlashCommandNodeView-CYcf7mVz.js";
|
|
6
|
+
import { u as o } from "./updatePosition-e90ZrFWW.js";
|
|
7
7
|
import { jsx as f, Fragment as c } from "react/jsx-runtime";
|
|
8
8
|
import { useEffect as h } from "react";
|
|
9
|
-
import { u as C } from "./index-
|
|
9
|
+
import { u as C } from "./index-DZfkCNKr.js";
|
|
10
10
|
function E({ commandList: e }) {
|
|
11
11
|
const [, t] = u(), { t: r } = C();
|
|
12
12
|
return h(() => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("react/jsx-runtime"),u=require("react"),x=require("./index-Bt9LiArC.cjs");require("./theme.cjs");const b=require("./index-BrxL7y9p.cjs"),C=require("./index-NsYff_Ni.cjs");function q({t:n}){const a=[{name:"format",title:n("editor.slash.format"),commands:[]},{name:"insert",title:n("editor.slash.insert"),commands:[]}];return b.HEADINGS.forEach(e=>{a[0].commands.push({name:`heading${e}`,label:n(e==="Paragraph"?"editor.paragraph.tooltip":`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,isActive:t=>e==="Paragraph"?!1:t.isActive("heading",{level:e})||!1,action:({editor:t,range:l})=>{const s=b.HEADINGS.find(m=>t.isActive("heading",{level:m}));if(e==="Paragraph"){s!==void 0&&s!=="Paragraph"&&t.commands.toggleHeading({level:s}),t.chain().focus().deleteRange(l).run();return}if(e){t.chain().focus().deleteRange(l).setHeading({level:e}).run();return}t.chain().focus().deleteRange(l).run()}})}),a[0].commands.push({name:"bulletList",label:n("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",isActive:e=>e.isActive("bulletList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}}),a[0].commands.push({name:"orderedlist",label:n("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",isActive:e=>e.isActive("orderedList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}}),a[0].commands.push({name:"taskList",label:n("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],isActive:e=>e.isActive("taskList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}}),a[0].commands.push({name:"blockquote",label:n("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",isActive:e=>e.isActive("blockquote"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setBlockquote().run()}}),a[0].commands.push({name:"codeBlock",label:n("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),isActive:e=>e.isActive("codeBlock"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setCodeBlock().run()}}),a[1].commands.push({name:"image",label:n("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const l=x.EVENTS.UPLOAD_IMAGE(e.id);x.emit(l,!0)}}),a[1].commands.push({name:"table",label:n("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),a[1].commands.push({name:"horizontalRule",label:n("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}}),a[1].commands.push({name:"columns",label:n("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),a}function N(n,a){return n.map(t=>({...t,commands:t.commands.filter(l=>{const s=l.label.toLowerCase().trim(),m=a.toLowerCase().trim();if(l.aliases){const f=l.aliases.map(h=>h.toLowerCase().trim()),p=s.match(m),r=f.some(h=>h.match(m));return p||r}return s.match(m)})})).filter(t=>t.commands.length>0)}const y=C.y([]);function L(){const[n,a]=C.V(y);return[n,a]}function j(n,a){const[e]=L(),[t,l]=u.useState(0),[s,m]=u.useState(0),f=u.useRef(null),{t:p}=b.useLocale(),r=N(e,n.query),h=u.useRef([]);u.useImperativeHandle(a,()=>({onKeyDown:v})),u.useEffect(()=>{if(!f.current)return;const o=s*1e3+t,i=h.current[o];i&&i.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,s]);function v({event:o}){return o.key==="ArrowUp"?(A(),!0):o.key==="ArrowDown"?(R(),!0):o.key==="Enter"?(I(),!0):!1}function A(){var c;if(r.length===0)return!1;let o=t-1,i=s;o<0&&(i=s-1,o=((c=r[i])==null?void 0:c.commands.length)-1||0),i<0&&(i=r.length-1,o=r[i].commands.length-1),l(o),m(i)}function R(){if(r.length===0)return!1;const o=r[s].commands;let i=t+1,c=s;o.length-1<i&&(i=0,c=s+1),r.length-1<c&&(c=0),l(i),m(c)}function I(){if(r.length===0||s===-1||t===-1)return!1;w(s,t)}function w(o,i){const c=r[o].commands[i];n==null||n.command(c)}function k(o,i){w(o,i)}function H(o,i,c){h.current[o*1e3+i]=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-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:f,children:r!=null&&r.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:r==null?void 0:r.map((o,i)=>d.jsxs(u.Fragment,{children:[d.jsx(x.Label,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase",children:o.title}),o.commands.map((c,g)=>d.jsxs("button",{onClick:()=>k(i,g),ref:S=>H(i,g,S),className:x.cn("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",{"bg-item-active":s===i&&t===g}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(x.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${g}`))]},`slash-${o.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-foreground",children:p("editor.slash.empty")})})})}const E=u.forwardRef(j);exports.SlashCommandNodeView=E;exports.renderCommandListDefault=q;exports.useFilterCommandList=N;exports.useSignalCommandList=L;
|