reactjs-tiptap-editor 1.0.8 → 1.0.10
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-t7e5GCJp.cjs → ActionMenuButton-BPdRqzDX.cjs} +1 -1
- package/lib/{ActionMenuButton-Cc0vy5hy.js → ActionMenuButton-CKTxYtl7.js} +2 -2
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +7 -7
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +3 -3
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +6 -6
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +3 -3
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -6
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +4 -4
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +3 -3
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +5 -5
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +8 -8
- package/lib/{Drawer-C6WTtcd0.js → Drawer-Cfx115up.js} +6 -6
- package/lib/{Drawer-DRdsK4f_.cjs → Drawer-hHj4Opkg.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +10 -9
- package/lib/{Excalidraw-gJ99kWdS.cjs → Excalidraw-8pWJ17Ye.cjs} +1 -1
- package/lib/{Excalidraw-DjO5sCC_.js → Excalidraw-CO93Tsmb.js} +7 -7
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +26 -26
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +3 -3
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +5 -5
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +5 -5
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +5 -5
- package/lib/History.cjs +1 -1
- package/lib/History.js +4 -4
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +3 -3
- package/lib/{Icon-prdLEHMN.js → Icon-D7GJZzoa.js} +1 -1
- package/lib/{Icon-DHNSWrSX.cjs → Icon-gtc3g-VK.cjs} +1 -1
- package/lib/{Iframe-CvymVtpM.cjs → Iframe-BmXO2c65.cjs} +1 -1
- package/lib/{Iframe-CERKUXQh.js → Iframe-DwhclppJ.js} +8 -8
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +13 -13
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +14 -14
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +3 -3
- package/lib/{Indent-BfEOOT5B.js → Indent-BOsymiZ7.js} +5 -5
- package/lib/{Indent-CE6kk62r.cjs → Indent-DPkMWfcv.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +3 -3
- package/lib/Katex-B1XbT8-X.cjs +4 -0
- package/lib/{Katex-5KNTSK8T.js → Katex-BYK-b9X2.js} +974 -941
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +5 -5
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-D6z0Yohc.cjs → LinkEditBlock-4-iRXH7m.cjs} +1 -1
- package/lib/{LinkEditBlock-CFkyS2Ze.js → LinkEditBlock-DgrLUMsJ.js} +32 -32
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +23 -22
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +26 -26
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +3 -3
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +9 -9
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +39 -266
- package/lib/SlashCommandNodeView-BpNNU7Sm.js +254 -0
- package/lib/SlashCommandNodeView-CQvMTXys.cjs +1 -0
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +3 -3
- package/lib/{Table-CWbY_hqo.js → Table-CT9R9Sdq.js} +5 -5
- package/lib/{Table-D9pRzwFU.cjs → Table-LnWGm2m8.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +3 -3
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +5 -5
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +5 -5
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +3 -3
- package/lib/{Twitter-D7NK3MZe.cjs → Twitter-Bo4JkBTL.cjs} +1 -1
- package/lib/{Twitter-BV7HA-MO.js → Twitter-mowilxRd.js} +46 -46
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +7 -7
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +2045 -1931
- package/lib/{button-0963_Pa8.js → button-CBO-WDXK.js} +1 -1
- package/lib/{button-Bxfjx9_Y.cjs → button-wt49IYwP.cjs} +1 -1
- package/lib/{checkbox-D4p6-UMt.js → checkbox-D1h32VWM.js} +1 -1
- package/lib/{checkbox-Q6FcMQW5.cjs → checkbox-DUcLSGZD.cjs} +1 -1
- package/lib/{dialog-B-9_Z5j2.js → dialog-DSvgtlDI.js} +1 -1
- package/lib/{dialog-D-oYxagG.cjs → dialog-DY868Uji.cjs} +1 -1
- package/lib/{dropdown-menu-par18QL5.js → dropdown-menu-B88Qn2KR.js} +3 -2
- package/lib/dropdown-menu-BripAeGB.cjs +1 -0
- package/lib/extensions/Katex/Katex.d.ts +1 -1
- package/lib/extensions/SlashCommand/types.d.ts +1 -0
- package/lib/index-9A6-kVBM.js +1351 -0
- package/lib/{index-pgx8gyoC.js → index-BIqaogQg.js} +201 -199
- package/lib/{index-BFXkgG1P.cjs → index-BvIJKpX1.cjs} +2 -1
- package/lib/index-Cv9Z6dyV.cjs +1 -0
- package/lib/{index-EKFybgpP.js → index-DKt5wfAc.js} +1 -1
- package/lib/{index-BimeTI7q.js → index-DRHrDScg.js} +1 -1
- package/lib/{index-BQ6ZdLsu.js → index-DmPwbBqm.js} +1 -1
- package/lib/{index-CbIQPoF6.js → index-sVScpCFG.js} +20 -20
- package/lib/index.cjs +1 -1
- package/lib/index.js +5 -5
- package/lib/{input-CZUkD6wF.cjs → input-BeD5GdMv.cjs} +1 -1
- package/lib/{input-cclJoUeC.js → input-Bx4uo4gO.js} +1 -1
- package/lib/{isNumber-8HKEgTkA.js → isNumber-DF0fU3ob.js} +1 -1
- package/lib/{label-CFaBdRGz.cjs → label--161UPH6.cjs} +1 -1
- package/lib/{label-aveW7pdK.js → label-uKG7RzFU.js} +1 -1
- package/lib/{popover-D5YZPv2r.js → popover-BVX8otO9.js} +1 -1
- package/lib/{popover-BWYZO_fD.cjs → popover-Csk538NC.cjs} +1 -1
- package/lib/{separator-B978cwAm.cjs → separator-DLRVddHS.cjs} +1 -1
- package/lib/{separator-BHjFVmZr.js → separator-DtrEdjAF.js} +4 -4
- package/lib/{store-BsBiawfz.cjs → store-B8IkVz1J.cjs} +1 -1
- package/lib/{store-BsMMRKFd.js → store-CsIFDUKR.js} +1 -1
- package/lib/style.css +1 -1
- package/lib/{tabs-Bj8EvAkY.js → tabs-BKpr0QQB.js} +1 -1
- package/lib/{tabs-CUMyiV80.cjs → tabs-DOasUMDU.cjs} +1 -1
- package/lib/{textarea-CClyW-74.js → textarea-Ba9OOzba.js} +1 -1
- package/lib/{textarea-BKb7LDw1.cjs → textarea-D9egO4qC.cjs} +1 -1
- package/lib/{throttle-BIkZV3Y_.js → throttle-DsowOft0.js} +1 -1
- package/lib/updatePosition-Bbd8ETMv.js +16 -0
- package/lib/updatePosition-M2IyqkI1.cjs +1 -0
- package/lib/{useButtonProps-StwAz7Ha.js → useButtonProps-C_bqxmHi.js} +14 -14
- package/lib/{useButtonProps-B0riSJs9.cjs → useButtonProps-DEtmDVPr.cjs} +1 -1
- package/package.json +1 -1
- package/lib/Katex-CJ2Fmvut.cjs +0 -4
- package/lib/dropdown-menu-r8XibZQU.cjs +0 -1
- package/lib/floating-ui.dom-U1vPFQ5f.js +0 -1151
- package/lib/floating-ui.dom-VCrc58uF.cjs +0 -1
- package/lib/updatePosition-GLTrgcib.js +0 -215
- package/lib/updatePosition-u2mTh3mG.cjs +0 -1
package/lib/Mermaid.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as q, c as Y } from "./throttle-
|
|
3
|
-
import { jsxs as
|
|
4
|
-
import { useState as m, useRef as K, useCallback as A, useEffect as
|
|
1
|
+
import { q as U, s as G, m as X, u as Z } from "./index-sVScpCFG.js";
|
|
2
|
+
import { a as q, c as Y } from "./throttle-DsowOft0.js";
|
|
3
|
+
import { jsxs as H, jsx as n, Fragment as J } from "react/jsx-runtime";
|
|
4
|
+
import { useState as m, useRef as K, useCallback as A, useEffect as R, useMemo as P } from "react";
|
|
5
5
|
import { s as Q, i as tt } from "./shortId-WJVkrvml.js";
|
|
6
|
-
import { A as et } from "./index-
|
|
7
|
-
import { B as rt } from "./button-
|
|
8
|
-
import { D as it, a as at, b as st, c as nt, d as ot } from "./dialog-
|
|
9
|
-
import { T as lt } from "./textarea-
|
|
6
|
+
import { A as et } from "./index-BIqaogQg.js";
|
|
7
|
+
import { B as rt } from "./button-CBO-WDXK.js";
|
|
8
|
+
import { D as it, a as at, b as st, c as nt, d as ot } from "./dialog-DSvgtlDI.js";
|
|
9
|
+
import { T as lt } from "./textarea-Ba9OOzba.js";
|
|
10
10
|
import { I as V, j as W, k as ct } from "./index-0OnGZkVF.js";
|
|
11
|
-
import { c as dt, u as ut, a as ht, f as mt } from "./useButtonProps-
|
|
11
|
+
import { c as dt, u as ut, a as ht, f as mt } from "./useButtonProps-C_bqxmHi.js";
|
|
12
12
|
import { d as gt } from "./file-BLas99n7.js";
|
|
13
13
|
const pt = `graph TB
|
|
14
14
|
a-->b`;
|
|
@@ -40,11 +40,11 @@ function Ot() {
|
|
|
40
40
|
theme: "base"
|
|
41
41
|
}), I(c);
|
|
42
42
|
};
|
|
43
|
-
return
|
|
43
|
+
return R(() => {
|
|
44
44
|
!g && d && o && E();
|
|
45
|
-
}, [d, o]),
|
|
45
|
+
}, [d, o]), R(() => {
|
|
46
46
|
!g && d && o && I(c);
|
|
47
|
-
}, [d && c]), /* @__PURE__ */
|
|
47
|
+
}, [d && c]), /* @__PURE__ */ H(
|
|
48
48
|
it,
|
|
49
49
|
{
|
|
50
50
|
onOpenChange: _,
|
|
@@ -62,14 +62,14 @@ function Ot() {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
) }),
|
|
65
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ H(st, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
|
|
66
66
|
/* @__PURE__ */ n(nt, { children: "Mermaid" }),
|
|
67
67
|
/* @__PURE__ */ n(
|
|
68
68
|
"div",
|
|
69
69
|
{
|
|
70
70
|
ref: B,
|
|
71
71
|
style: { height: "100%", border: "1px solid hsl(var(--border))" },
|
|
72
|
-
children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(J, { children: /* @__PURE__ */
|
|
72
|
+
children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(J, { children: /* @__PURE__ */ H("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
|
|
73
73
|
/* @__PURE__ */ n(
|
|
74
74
|
lt,
|
|
75
75
|
{
|
|
@@ -104,7 +104,7 @@ function Ot() {
|
|
|
104
104
|
onClick: async () => {
|
|
105
105
|
if (c !== "") {
|
|
106
106
|
if (c) {
|
|
107
|
-
const l = L.current.querySelector("svg"), { width: u, height:
|
|
107
|
+
const l = L.current.querySelector("svg"), { width: u, height: z } = l.getBoundingClientRect(), N = `mermaid-${Q()}.svg`;
|
|
108
108
|
let M = tt(l.outerHTML);
|
|
109
109
|
if (w) {
|
|
110
110
|
const r = gt(M, N);
|
|
@@ -116,7 +116,7 @@ function Ot() {
|
|
|
116
116
|
src: M,
|
|
117
117
|
alt: encodeURIComponent(c),
|
|
118
118
|
width: u,
|
|
119
|
-
height:
|
|
119
|
+
height: z
|
|
120
120
|
},
|
|
121
121
|
!!c
|
|
122
122
|
).run();
|
|
@@ -133,7 +133,7 @@ function Ot() {
|
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const C = {
|
|
137
137
|
TOP_LEFT: "tl",
|
|
138
138
|
TOP_RIGHT: "tr",
|
|
139
139
|
BOTTOM_LEFT: "bl",
|
|
@@ -147,10 +147,10 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
|
|
|
147
147
|
width: 0,
|
|
148
148
|
height: 0
|
|
149
149
|
}), [y] = m([
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
C.TOP_LEFT,
|
|
151
|
+
C.TOP_RIGHT,
|
|
152
|
+
C.BOTTOM_LEFT,
|
|
153
|
+
C.BOTTOM_RIGHT
|
|
154
154
|
]), [o, _] = m(!1), [L, d] = m({
|
|
155
155
|
x: 0,
|
|
156
156
|
y: 0,
|
|
@@ -227,23 +227,23 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
|
|
|
227
227
|
}), _(!1), I());
|
|
228
228
|
},
|
|
229
229
|
[o, I]
|
|
230
|
-
),
|
|
230
|
+
), z = A(() => {
|
|
231
231
|
document == null || document.addEventListener("mousemove", l, !0), document == null || document.addEventListener("mouseup", u, !0);
|
|
232
232
|
}, [l, u]), N = A(() => {
|
|
233
233
|
document == null || document.removeEventListener("mousemove", l, !0), document == null || document.removeEventListener("mouseup", u, !0);
|
|
234
234
|
}, [l, u]);
|
|
235
|
-
|
|
235
|
+
R(() => (o ? z() : N(), () => {
|
|
236
236
|
N();
|
|
237
|
-
}), [o,
|
|
237
|
+
}), [o, z, N]);
|
|
238
238
|
const M = P(() => new ResizeObserver(() => E()), [E]);
|
|
239
|
-
return
|
|
239
|
+
return R(() => (M.observe(e.view.dom), () => {
|
|
240
240
|
M.disconnect();
|
|
241
241
|
}), [e.view.dom, M]), /* @__PURE__ */ n(
|
|
242
242
|
U,
|
|
243
243
|
{
|
|
244
244
|
className: "image-view",
|
|
245
245
|
style: { ...O, width: "100%", textAlign: k },
|
|
246
|
-
children: /* @__PURE__ */
|
|
246
|
+
children: /* @__PURE__ */ H(
|
|
247
247
|
"div",
|
|
248
248
|
{
|
|
249
249
|
"data-drag-handle": !0,
|
package/lib/MoreMark.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-BBNITgNi.cjs"),r=require("react/jsx-runtime"),x=require("react"),h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-BBNITgNi.cjs"),r=require("react/jsx-runtime"),x=require("react"),h=require("./index-BvIJKpX1.cjs"),p=require("./dropdown-menu-BripAeGB.cjs"),b=require("./useButtonProps-DEtmDVPr.cjs"),f=require("./Icon-gtc3g-VK.cjs");var S=c.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),k=c.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function A(){const t=b.useButtonProps(m.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:u,dataState:o}=b.useActive(l),d=x.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(p.DropdownMenu,{children:[r.jsx(p.DropdownMenuTrigger,{asChild:!0,disabled:u,children:r.jsx(h.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(h.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(p.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,a)=>r.jsxs(p.DropdownMenuCheckboxItem,{checked:d===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(f.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:h.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${a}`))})]}):r.jsx(r.Fragment,{})}const m=c.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var a,g;const l=n.options.subscript,u=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((a=n.options.shortcutKeys)==null?void 0:a[0])??["mod","."]},d={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return l!==!1&&e.push(o),u!==!1&&e.push(d),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(M=>M.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(S.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(k.configure(this.options.superscript)),t}});exports.MoreMark=m;exports.RichTextMoreMark=A;
|
package/lib/MoreMark.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as h, m, E as b } from "./index-
|
|
1
|
+
import { M as h, m, E as b } from "./index-sVScpCFG.js";
|
|
2
2
|
import { jsx as e, Fragment as f, jsxs as d } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo as M } from "react";
|
|
4
|
-
import { A as x, M as A, g as S } from "./index-
|
|
5
|
-
import { D as k, a as v, b as y, c as T } from "./dropdown-menu-
|
|
6
|
-
import { u as K, b as w } from "./useButtonProps-
|
|
7
|
-
import { I as C } from "./Icon-
|
|
4
|
+
import { A as x, M as A, g as S } from "./index-BIqaogQg.js";
|
|
5
|
+
import { D as k, a as v, b as y, c as T } from "./dropdown-menu-B88Qn2KR.js";
|
|
6
|
+
import { u as K, b as w } from "./useButtonProps-C_bqxmHi.js";
|
|
7
|
+
import { I as C } from "./Icon-D7GJZzoa.js";
|
|
8
8
|
var H = h.create({
|
|
9
9
|
name: "subscript",
|
|
10
10
|
addOptions() {
|
package/lib/OrderedList.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-CApXPpjF.cjs"),r=require("react/jsx-runtime"),m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-CApXPpjF.cjs"),r=require("react/jsx-runtime"),m=require("./index-BvIJKpX1.cjs");require("react");const d=require("./useButtonProps-DEtmDVPr.cjs");function x(){const t=d.useButtonProps(c.name),{icon:e=void 0,tooltip:o=void 0,shortcutKeys:i=void 0,tooltipOptions:u={},action:s=void 0,isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:n,update:l}=d.useToggleActive(a),v=()=>{n||s&&(s(),l())};return t?r.jsx(m.ActionButton,{action:v,dataState:p,disabled:n,icon:e,shortcutKeys:i,tooltip:o,tooltipOptions:u}):r.jsx(r.Fragment,{})}const c=O.OrderedList.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:o,extension:i})=>({componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:i.options.shortcutKeys??["mod","shift","7"],tooltip:o("editor.orderedlist.tooltip")}})}}});exports.OrderedList=c;exports.RichTextOrderedList=x;
|
package/lib/OrderedList.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as u } from "./index-
|
|
1
|
+
import { O as u } from "./index-DRHrDScg.js";
|
|
2
2
|
import { jsx as n, Fragment as f } from "react/jsx-runtime";
|
|
3
|
-
import { A as l } from "./index-
|
|
3
|
+
import { A as l } from "./index-BIqaogQg.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { u as v, a as O } from "./useButtonProps-
|
|
5
|
+
import { u as v, a as O } from "./useButtonProps-C_bqxmHi.js";
|
|
6
6
|
function K() {
|
|
7
7
|
const t = v(A.name), {
|
|
8
8
|
icon: o = void 0,
|
package/lib/SearchAndReplace.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./index-BBNITgNi.cjs"),F=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),f=require("react"),Z=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./index-BBNITgNi.cjs"),F=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),f=require("react"),Z=require("./index-BvIJKpX1.cjs"),j=require("./button-wt49IYwP.cjs"),M=require("./input-BeD5GdMv.cjs"),k=require("./label--161UPH6.cjs"),$=require("./popover-Csk538NC.cjs"),_=require("./checkbox-DUcLSGZD.cjs"),B=require("./useButtonProps-DEtmDVPr.cjs"),ee=require("./index-FSRjMsxW.cjs"),V=require("./Icon-gtc3g-VK.cjs");function te(){const{t}=ee.useLocale(),e=B.useEditorInstance(),s=B.useButtonProps(W.name),{icon:n=void 0,tooltip:u=void 0,shortcutKeys:o=void 0,tooltipOptions:c={},action:x=void 0,isActive:h=void 0}=(s==null?void 0:s.componentProps)??{},{disabled:i}=B.useActive(h),[g,d]=f.useState(!1),[p,A]=f.useState(""),[T,N]=f.useState(""),[I,H]=f.useState(!1),[U,E]=f.useState(""),w=()=>{var r,l,R,m;E(`${((l=(r=e==null?void 0:e.storage)==null?void 0:r.searchAndReplace)==null?void 0:l.resultIndex)+1}/${(m=(R=e==null?void 0:e.storage)==null?void 0:R.searchAndReplace)==null?void 0:m.results.length}`)};f.useEffect(()=>{e&&w()},[e]);const z=()=>{i||x&&x()},y=(r=!1)=>{var l,R,m,v,S,D,q,O;e&&(r&&((R=(l=e==null?void 0:e.commands)==null?void 0:l.resetIndex)==null||R.call(l)),(v=(m=e==null?void 0:e.commands)==null?void 0:m.setSearchTerm)==null||v.call(m,p),(D=(S=e==null?void 0:e.commands)==null?void 0:S.setReplaceTerm)==null||D.call(S,T),(O=(q=e==null?void 0:e.commands)==null?void 0:q.setCaseSensitive)==null||O.call(q,I),w())},P=()=>{var v,S;if(!e)return;const{results:r,resultIndex:l}=e.storage.searchAndReplace,R=r[l];if(!R)return;(S=(v=e==null?void 0:e.commands)==null?void 0:v.setTextSelection)==null||S.call(v,R);const{node:m}=e.view.domAtPos(e.state.selection.anchor);m instanceof HTMLElement&&m.scrollIntoView({behavior:"smooth",block:"center"}),w()};f.useEffect(()=>{p.trim()||L(),p.trim()&&y(!0)},[p]),f.useEffect(()=>{T.trim()&&y()},[T]),f.useEffect(()=>{y(!0)},[I]);const G=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replace)==null||l.call(r),P()},J=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.nextSearchResult)==null||l.call(r),P()},Q=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.previousSearchResult)==null||l.call(r),P()},L=()=>{var r,l;A(""),N(""),(l=(r=e==null?void 0:e.commands)==null?void 0:r.resetIndex)==null||l.call(r),w()},X=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replaceAll)==null||l.call(r),E("0/0")};return s?a.jsxs($.Popover,{onOpenChange:d,open:g,children:[a.jsx($.PopoverTrigger,{asChild:!0,disabled:i,children:a.jsx(Z.ActionButton,{action:z,disabled:i,icon:n,shortcutKeys:o,tooltip:u,tooltipOptions:c})}),a.jsxs($.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(k.Label,{children:t("editor.search.dialog.text")}),a.jsx("span",{className:"richtext-font-semibold",children:U})]}),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(M.Input,{autoFocus:!0,className:"richtext-w-full",onChange:r=>A(r.target.value),placeholder:"Text",required:!0,type:"text",value:p}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:Q,children:a.jsx(V.IconComponent,{name:"ChevronUp"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:J,children:a.jsx(V.IconComponent,{name:"ChevronDown"})}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:L,children:"Clear"})]}),a.jsx(k.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(M.Input,{className:"richtext-w-80",onChange:r=>N(r.target.value),placeholder:"Text",required:!0,type:"text",value:T})})}),a.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1",children:[a.jsx(_.Checkbox,{checked:I,onCheckedChange:r=>{H(r),e.commands.setCaseSensitive(r)}}),a.jsx(k.Label,{children:t("editor.replace.caseSensitive")})]}),a.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[a.jsx(j.Button,{className:"richtext-flex-1",onClick:G,children:t("editor.replace.dialog.text")}),a.jsx(j.Button,{className:"richtext-flex-1",onClick:X,children:t("editor.replaceAll.dialog.text")})]})]})]}):a.jsx(a.Fragment,{})}const C=(t,e)=>e(t.tr);function se(t,e,s){return RegExp(e?t.replace(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`):t,s?"gu":"gui")}function re(t,e,s,n){const u=[],o=[];let c=[],x=0;if(!e)return{decorationsToReturn:b.DecorationSet.empty,results:[]};t==null||t.descendants((h,i)=>{h.isText?c[x]?c[x]={text:c[x].text+h.text,pos:c[x].pos}:c[x]={text:`${h.text}`,pos:i}:x+=1}),c=c.filter(Boolean);for(const h of c){const{text:i,pos:g}=h,d=Array.from(i.matchAll(e)).filter(([p])=>p.trim());for(const p of d){if(p[0]==="")break;p.index!==void 0&&o.push({from:g+p.index,to:g+p.index+p[0].length})}}for(const[h,i]of o.entries()){const g=h===n?`${s} ${s}-current`:s,d=b.Decoration.inline(i.from,i.to,{class:g});u.push(d)}return{decorationsToReturn:b.DecorationSet.create(t,u),results:o}}function K(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 ne(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:h,to:i}=n[u];return n[u]={to:i-x,from:h-x},[x,n]}function ce(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:h}=o[c];s.insertText(t,x,h);const i=ne(t,c,u,o);i&&(u=i[0],o=i[1])}n(s)}}const W=Y.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,C(s,n),!1),setReplaceTerm:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.replaceTerm=t,C(s,n),!1),setCaseSensitive:t=>({editor:e,state:s,dispatch:n})=>(e.storage.searchAndReplace.caseSensitive=t,C(s,n),!1),resetIndex:()=>({editor:t,state:e,dispatch:s})=>(t.storage.searchAndReplace.resultIndex=0,C(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?(K(n,[c],{state:e,dispatch:s}),t.storage.searchAndReplace.results.splice(o,1)):(K(n,u,{state:e,dispatch:s}),t.storage.searchAndReplace.results.shift()),C(e,s),!1},replaceAll:()=>({editor:t,tr:e,state:s,dispatch:n})=>{const{replaceTerm:u,results:o}=t.storage.searchAndReplace;return ce(u,o,{tr:e,dispatch:n}),t.storage.searchAndReplace.resultIndex=0,t.storage.searchAndReplace.results=[],C(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 F.Plugin({key:new F.PluginKey(`richtextCustomPlugin${this.name}`),state:{init:()=>b.DecorationSet.empty,apply({doc:c,docChanged:x},h){const{searchTerm:i,lastSearchTerm:g,caseSensitive:d,lastCaseSensitive:p,resultIndex:A,lastResultIndex:T}=t.storage.searchAndReplace;if(!x&&g===i&&p===d&&T===A)return h;if(n(i),u(d),o(A),!i)return t.storage.searchAndReplace.results=[],b.DecorationSet.empty;const{decorationsToReturn:N,results:I}=re(c,se(i,s,d),e,A);return t.storage.searchAndReplace.results=I,N}},props:{decorations(c){return this.getState(c)}}})]}});exports.RichTextSearchAndReplace=te;exports.SearchAndReplace=W;
|
package/lib/SearchAndReplace.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { E as Q } from "./index-
|
|
1
|
+
import { E as Q } from "./index-sVScpCFG.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 { A as ee } from "./index-
|
|
7
|
-
import { B as N } from "./button-
|
|
8
|
-
import { I as V } from "./input-
|
|
9
|
-
import { L as B } from "./label-
|
|
10
|
-
import { P as te, a as se, b as re } from "./popover-
|
|
11
|
-
import { C as ne } from "./checkbox-
|
|
12
|
-
import { c as ce, u as ae, b as le } from "./useButtonProps-
|
|
6
|
+
import { A as ee } from "./index-BIqaogQg.js";
|
|
7
|
+
import { B as N } from "./button-CBO-WDXK.js";
|
|
8
|
+
import { I as V } from "./input-Bx4uo4gO.js";
|
|
9
|
+
import { L as B } from "./label-uKG7RzFU.js";
|
|
10
|
+
import { P as te, a as se, b as re } from "./popover-BVX8otO9.js";
|
|
11
|
+
import { C as ne } from "./checkbox-D1h32VWM.js";
|
|
12
|
+
import { c as ce, u as ae, b as le } from "./useButtonProps-C_bqxmHi.js";
|
|
13
13
|
import { u as oe } from "./index-0OnGZkVF.js";
|
|
14
|
-
import { I as q } from "./Icon-
|
|
14
|
+
import { I as q } from "./Icon-D7GJZzoa.js";
|
|
15
15
|
function ye() {
|
|
16
16
|
const { t } = oe(), e = ce(), s = ae(pe.name), {
|
|
17
17
|
icon: n = void 0,
|
package/lib/SlashCommand.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 o=require("./index-BBNITgNi.cjs"),u=require("@tiptap/pm/state"),d=require("./index-Cv9Z6dyV.cjs"),r=require("./SlashCommandNodeView-CQvMTXys.cjs"),a=require("./updatePosition-M2IyqkI1.cjs"),s=require("react/jsx-runtime"),l=require("./index-FSRjMsxW.cjs"),m=require("react");function c({commandList:e}){const[,t]=r.useSignalCommandList(),{t:n}=l.useLocale();return m.useEffect(()=>{if(!(e!=null&&e.length)){const i=r.renderCommandListDefault({t:n});t(i);return}t(e)},[n,e]),s.jsx(s.Fragment,{})}const C=o.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:i}=e;n.action({editor:e,range:t}),i.focus()},render:()=>{let e;return{onStart:t=>{t.clientRect&&(e=new o.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,251 +1,24 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { PluginKey as
|
|
3
|
-
import { S as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
function J({ t }) {
|
|
18
|
-
const n = [
|
|
19
|
-
{
|
|
20
|
-
name: "format",
|
|
21
|
-
title: t("editor.slash.format"),
|
|
22
|
-
commands: []
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "insert",
|
|
26
|
-
title: t("editor.slash.insert"),
|
|
27
|
-
commands: []
|
|
28
|
-
}
|
|
29
|
-
];
|
|
30
|
-
return [1, 2, 3, 4, 5, 6].forEach((e) => {
|
|
31
|
-
n[0].commands.push({
|
|
32
|
-
name: `heading${e}`,
|
|
33
|
-
label: t(`editor.heading.h${e}.tooltip`),
|
|
34
|
-
aliases: [`h${e}`, "bt", `bt${e}`],
|
|
35
|
-
iconName: `Heading${e}`,
|
|
36
|
-
action: ({ editor: o, range: l }) => {
|
|
37
|
-
o.chain().focus().deleteRange(l).setHeading({ level: e }).run();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}), n[0].commands.push({
|
|
41
|
-
name: "bulletList",
|
|
42
|
-
label: t("editor.bulletlist.tooltip"),
|
|
43
|
-
aliases: ["ul", "yxlb"],
|
|
44
|
-
iconName: "List",
|
|
45
|
-
action: ({ editor: e, range: o }) => {
|
|
46
|
-
e.chain().focus().deleteRange(o).toggleBulletList().run();
|
|
47
|
-
}
|
|
48
|
-
}), n[0].commands.push({
|
|
49
|
-
name: "numberedList",
|
|
50
|
-
label: t("editor.orderedlist.tooltip"),
|
|
51
|
-
aliases: ["ol", "yxlb"],
|
|
52
|
-
iconName: "ListOrdered",
|
|
53
|
-
action: ({ editor: e, range: o }) => {
|
|
54
|
-
e.chain().focus().deleteRange(o).toggleOrderedList().run();
|
|
55
|
-
}
|
|
56
|
-
}), n[0].commands.push({
|
|
57
|
-
name: "taskList",
|
|
58
|
-
label: t("editor.tasklist.tooltip"),
|
|
59
|
-
iconName: "ListTodo",
|
|
60
|
-
description: "Task list with todo items",
|
|
61
|
-
aliases: ["todo"],
|
|
62
|
-
action: ({ editor: e, range: o }) => {
|
|
63
|
-
e.chain().focus().deleteRange(o).toggleTaskList().run();
|
|
64
|
-
}
|
|
65
|
-
}), n[0].commands.push({
|
|
66
|
-
name: "blockquote",
|
|
67
|
-
label: t("editor.blockquote.tooltip"),
|
|
68
|
-
description: "插入引入格式",
|
|
69
|
-
aliases: ["yr"],
|
|
70
|
-
iconName: "TextQuote",
|
|
71
|
-
action: ({ editor: e, range: o }) => {
|
|
72
|
-
e.chain().focus().deleteRange(o).setBlockquote().run();
|
|
73
|
-
}
|
|
74
|
-
}), n[0].commands.push({
|
|
75
|
-
name: "codeBlock",
|
|
76
|
-
label: t("editor.codeblock.tooltip"),
|
|
77
|
-
iconName: "Code2",
|
|
78
|
-
description: "Code block with syntax highlighting",
|
|
79
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
80
|
-
action: ({ editor: e, range: o }) => {
|
|
81
|
-
e.chain().focus().deleteRange(o).setCodeBlock().run();
|
|
82
|
-
}
|
|
83
|
-
}), n[1].commands.push({
|
|
84
|
-
name: "image",
|
|
85
|
-
label: t("editor.image.tooltip"),
|
|
86
|
-
iconName: "ImageUp",
|
|
87
|
-
description: "Insert a image",
|
|
88
|
-
aliases: ["image", "tp", "tupian"],
|
|
89
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
90
|
-
action: ({ editor: e, range: o }) => {
|
|
91
|
-
e.chain().focus().deleteRange(o).run(), F.setOpen(e.id, !0);
|
|
92
|
-
}
|
|
93
|
-
}), n[1].commands.push({
|
|
94
|
-
name: "video",
|
|
95
|
-
label: t("editor.video.tooltip"),
|
|
96
|
-
iconName: "Video",
|
|
97
|
-
description: "Insert a video",
|
|
98
|
-
aliases: ["video", "sp", "shipin"],
|
|
99
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
100
|
-
action: ({ editor: e, range: o }) => {
|
|
101
|
-
e.chain().focus().deleteRange(o).run(), _.setOpen(e.id, !0);
|
|
102
|
-
}
|
|
103
|
-
}), n[1].commands.push({
|
|
104
|
-
name: "table",
|
|
105
|
-
label: t("editor.table.tooltip"),
|
|
106
|
-
iconName: "Table",
|
|
107
|
-
description: "Insert a table",
|
|
108
|
-
aliases: ["table", "bg", "biaoge", "biao"],
|
|
109
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
110
|
-
action: ({ editor: e, range: o }) => {
|
|
111
|
-
e.chain().focus().deleteRange(o).insertTable({ rows: 3, cols: 3, withHeaderRow: !1 }).run();
|
|
112
|
-
}
|
|
113
|
-
}), n[1].commands.push({
|
|
114
|
-
name: "horizontalRule",
|
|
115
|
-
label: t("editor.horizontalrule.tooltip"),
|
|
116
|
-
iconName: "Minus",
|
|
117
|
-
description: "Insert a horizontal divider",
|
|
118
|
-
aliases: ["hr", "fgx", "fg"],
|
|
119
|
-
action: ({ editor: e, range: o }) => {
|
|
120
|
-
e.chain().focus().deleteRange(o).setHorizontalRule().run();
|
|
121
|
-
}
|
|
122
|
-
}), n[1].commands.push({
|
|
123
|
-
name: "columns",
|
|
124
|
-
label: t("editor.columns.tooltip"),
|
|
125
|
-
iconName: "Columns2",
|
|
126
|
-
description: "Add two column content",
|
|
127
|
-
action: ({ editor: e }) => {
|
|
128
|
-
e.chain().focus().insertColumns({ cols: 2 }).run();
|
|
129
|
-
}
|
|
130
|
-
}), n;
|
|
131
|
-
}
|
|
132
|
-
function W(t, n) {
|
|
133
|
-
return t.map((l) => ({
|
|
134
|
-
...l,
|
|
135
|
-
commands: l.commands.filter((c) => {
|
|
136
|
-
const u = c.label.toLowerCase().trim(), d = n.toLowerCase().trim();
|
|
137
|
-
if (c.aliases) {
|
|
138
|
-
const p = c.aliases.map((h) => h.toLowerCase().trim()), a = u.match(d), f = p.some((h) => h.match(d));
|
|
139
|
-
return a || f;
|
|
140
|
-
}
|
|
141
|
-
return u.match(d);
|
|
142
|
-
})
|
|
143
|
-
})).filter((l) => l.commands.length > 0);
|
|
144
|
-
}
|
|
145
|
-
const X = K([]);
|
|
146
|
-
function R() {
|
|
147
|
-
const [t, n] = M(X);
|
|
148
|
-
return [t, n];
|
|
149
|
-
}
|
|
150
|
-
function Y(t, n) {
|
|
151
|
-
const [e] = R(), [o, l] = C(0), [c, u] = C(0), d = N(null), { t: p } = y(), a = W(e, t.query), f = N([]);
|
|
152
|
-
G(n, () => ({
|
|
153
|
-
onKeyDown: h
|
|
154
|
-
})), v(() => {
|
|
155
|
-
if (!d.current)
|
|
156
|
-
return;
|
|
157
|
-
const r = c * 1e3 + o, i = f.current[r];
|
|
158
|
-
i && i.scrollIntoView({
|
|
159
|
-
behavior: "smooth",
|
|
160
|
-
block: "nearest"
|
|
161
|
-
});
|
|
162
|
-
}, [o, c]);
|
|
163
|
-
function h({ event: r }) {
|
|
164
|
-
return r.key === "ArrowUp" ? (I(), !0) : r.key === "ArrowDown" ? (L(), !0) : r.key === "Enter" ? (k(), !0) : !1;
|
|
165
|
-
}
|
|
166
|
-
function I() {
|
|
167
|
-
var s;
|
|
168
|
-
if (a.length === 0)
|
|
169
|
-
return !1;
|
|
170
|
-
let r = o - 1, i = c;
|
|
171
|
-
r < 0 && (i = c - 1, r = ((s = a[i]) == null ? void 0 : s.commands.length) - 1 || 0), i < 0 && (i = a.length - 1, r = a[i].commands.length - 1), l(r), u(i);
|
|
172
|
-
}
|
|
173
|
-
function L() {
|
|
174
|
-
if (a.length === 0)
|
|
175
|
-
return !1;
|
|
176
|
-
const r = a[c].commands;
|
|
177
|
-
let i = o + 1, s = c;
|
|
178
|
-
r.length - 1 < i && (i = 0, s = c + 1), a.length - 1 < s && (s = 0), l(i), u(s);
|
|
179
|
-
}
|
|
180
|
-
function k() {
|
|
181
|
-
if (a.length === 0 || c === -1 || o === -1)
|
|
182
|
-
return !1;
|
|
183
|
-
g(c, o);
|
|
184
|
-
}
|
|
185
|
-
function g(r, i) {
|
|
186
|
-
const s = a[r].commands[i];
|
|
187
|
-
t == null || t.command(s);
|
|
188
|
-
}
|
|
189
|
-
function S(r, i) {
|
|
190
|
-
g(r, i);
|
|
191
|
-
}
|
|
192
|
-
function E(r, i, s) {
|
|
193
|
-
f.current[r * 1e3 + i] = s;
|
|
194
|
-
}
|
|
195
|
-
return /* @__PURE__ */ m(
|
|
196
|
-
"div",
|
|
197
|
-
{
|
|
198
|
-
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",
|
|
199
|
-
"data-richtext-portal": !0,
|
|
200
|
-
ref: d,
|
|
201
|
-
children: a != null && a.length ? /* @__PURE__ */ m("div", { className: "richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5", children: a == null ? void 0 : a.map((r, i) => /* @__PURE__ */ w(O, { children: [
|
|
202
|
-
/* @__PURE__ */ m(T, { className: "richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ", children: r.title }),
|
|
203
|
-
r.commands.map((s, x) => /* @__PURE__ */ w(
|
|
204
|
-
"button",
|
|
205
|
-
{
|
|
206
|
-
onClick: () => S(i, x),
|
|
207
|
-
ref: (H) => E(i, x, H),
|
|
208
|
-
className: P("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-text-foreground 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 ", {
|
|
209
|
-
"bg-item-active": c === i && o === x
|
|
210
|
-
}),
|
|
211
|
-
children: [
|
|
212
|
-
s.iconUrl && /* @__PURE__ */ m(
|
|
213
|
-
"img",
|
|
214
|
-
{
|
|
215
|
-
alt: "",
|
|
216
|
-
className: "richtext-size-6",
|
|
217
|
-
src: s.iconUrl
|
|
218
|
-
}
|
|
219
|
-
),
|
|
220
|
-
s.iconName && /* @__PURE__ */ m(
|
|
221
|
-
j,
|
|
222
|
-
{
|
|
223
|
-
className: "!richtext-mr-1 !richtext-text-lg",
|
|
224
|
-
name: s.iconName
|
|
225
|
-
}
|
|
226
|
-
),
|
|
227
|
-
s.label
|
|
228
|
-
]
|
|
229
|
-
},
|
|
230
|
-
`command-${x}`
|
|
231
|
-
))
|
|
232
|
-
] }, `slash-${r.title}`)) }) : /* @__PURE__ */ m("div", { className: "richtext-p-3", children: /* @__PURE__ */ m("span", { className: "richtext-text-xs richtext-text-foreground", children: p("editor.slash.empty") }) })
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
const Z = z(Y);
|
|
237
|
-
function me({ commandList: t }) {
|
|
238
|
-
const [, n] = R(), { t: e } = y();
|
|
239
|
-
return v(() => {
|
|
240
|
-
if (!(t != null && t.length)) {
|
|
241
|
-
const o = J({ t: e });
|
|
242
|
-
n(o);
|
|
1
|
+
import { E as i, R as a } from "./index-sVScpCFG.js";
|
|
2
|
+
import { PluginKey as m } from "@tiptap/pm/state";
|
|
3
|
+
import { S as s } from "./index-9A6-kVBM.js";
|
|
4
|
+
import { u, r as l, S as d } from "./SlashCommandNodeView-BpNNU7Sm.js";
|
|
5
|
+
import { a as b } from "./SlashCommandNodeView-BpNNU7Sm.js";
|
|
6
|
+
import { u as o } from "./updatePosition-Bbd8ETMv.js";
|
|
7
|
+
import { jsx as f, Fragment as c } from "react/jsx-runtime";
|
|
8
|
+
import { u as h } from "./index-0OnGZkVF.js";
|
|
9
|
+
import { useEffect as C } from "react";
|
|
10
|
+
function E({ commandList: e }) {
|
|
11
|
+
const [, t] = u(), { t: r } = h();
|
|
12
|
+
return C(() => {
|
|
13
|
+
if (!(e != null && e.length)) {
|
|
14
|
+
const n = l({ t: r });
|
|
15
|
+
t(n);
|
|
243
16
|
return;
|
|
244
17
|
}
|
|
245
|
-
|
|
246
|
-
}, [
|
|
18
|
+
t(e);
|
|
19
|
+
}, [r, e]), /* @__PURE__ */ f(c, {});
|
|
247
20
|
}
|
|
248
|
-
const
|
|
21
|
+
const v = /* @__PURE__ */ i.create({
|
|
249
22
|
name: "richtextSlashCommand",
|
|
250
23
|
priority: 200,
|
|
251
24
|
// addOptions() {
|
|
@@ -257,8 +30,8 @@ const de = /* @__PURE__ */ A.create({
|
|
|
257
30
|
// },
|
|
258
31
|
addProseMirrorPlugins() {
|
|
259
32
|
return [
|
|
260
|
-
|
|
261
|
-
pluginKey: new
|
|
33
|
+
s({
|
|
34
|
+
pluginKey: new m("richtextSlashCommandPlugin"),
|
|
262
35
|
editor: this.editor,
|
|
263
36
|
char: "/",
|
|
264
37
|
// allowSpaces: true,
|
|
@@ -280,28 +53,28 @@ const de = /* @__PURE__ */ A.create({
|
|
|
280
53
|
// && isValidAfterContent
|
|
281
54
|
// );
|
|
282
55
|
// },
|
|
283
|
-
command: ({ editor:
|
|
284
|
-
const { view:
|
|
285
|
-
|
|
56
|
+
command: ({ editor: e, range: t, props: r }) => {
|
|
57
|
+
const { view: n } = e;
|
|
58
|
+
r.action({ editor: e, range: t }), n.focus();
|
|
286
59
|
},
|
|
287
60
|
render: () => {
|
|
288
|
-
let
|
|
61
|
+
let e;
|
|
289
62
|
return {
|
|
290
|
-
onStart: (
|
|
291
|
-
|
|
292
|
-
props:
|
|
293
|
-
editor:
|
|
294
|
-
}),
|
|
63
|
+
onStart: (t) => {
|
|
64
|
+
t.clientRect && (e = new a(d, {
|
|
65
|
+
props: t,
|
|
66
|
+
editor: t.editor
|
|
67
|
+
}), e.element.style.position = "absolute", document.body.appendChild(e.element), o(t.editor, e.element));
|
|
295
68
|
},
|
|
296
|
-
onUpdate(
|
|
297
|
-
|
|
69
|
+
onUpdate(t) {
|
|
70
|
+
e.updateProps(t), t.clientRect && o(t.editor, e.element);
|
|
298
71
|
},
|
|
299
|
-
onKeyDown(
|
|
300
|
-
var
|
|
301
|
-
return
|
|
72
|
+
onKeyDown(t) {
|
|
73
|
+
var r;
|
|
74
|
+
return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
|
|
302
75
|
},
|
|
303
76
|
onExit() {
|
|
304
|
-
|
|
77
|
+
e && (e.destroy(), e.element.remove());
|
|
305
78
|
}
|
|
306
79
|
};
|
|
307
80
|
}
|
|
@@ -310,8 +83,8 @@ const de = /* @__PURE__ */ A.create({
|
|
|
310
83
|
}
|
|
311
84
|
});
|
|
312
85
|
export {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
86
|
+
v as SlashCommand,
|
|
87
|
+
E as SlashCommandList,
|
|
88
|
+
l as renderCommandListDefault,
|
|
89
|
+
b as useFilterCommandList
|
|
317
90
|
};
|