reactjs-tiptap-editor 1.0.11 → 1.0.12
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-DTXFBdGX.js → ActionMenuButton-BKqin6Kz.js} +17 -13
- package/lib/ActionMenuButton-CPPHERbq.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +24 -21
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +7 -5
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +11 -9
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +14 -12
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +11 -9
- package/lib/CodeBlock.cjs +39 -39
- package/lib/CodeBlock.js +842 -948
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +10 -8
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +20 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -5
- package/lib/{Drawer-D0yQ0wR7.js → Drawer-DUPsBE0H.js} +18 -17
- package/lib/Drawer-fplzqNI6.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +19 -17
- package/lib/{Excalidraw-CO4IRHmG.js → Excalidraw-BEzpvRLx.js} +33 -32
- package/lib/Excalidraw-qjnQspLq.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +7 -5
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +7 -5
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -8
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +13 -12
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +25 -24
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +9 -7
- package/lib/History.cjs +1 -1
- package/lib/History.js +18 -15
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +7 -5
- package/lib/Icon-CiR8RqdQ.cjs +1 -0
- package/lib/Icon-ONE1AwKo.js +12 -0
- package/lib/{Iframe-BEO28NPs.js → Iframe-CBTnv2mk.js} +45 -43
- package/lib/Iframe-DsUNJ2n2.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +52 -50
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +55 -53
- package/lib/ImportWord.cjs +31 -31
- package/lib/ImportWord.js +12 -10
- package/lib/{Indent-CXurBbOr.js → Indent-B00o0P0M.js} +26 -24
- package/lib/Indent-CaGP0qTp.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +12 -10
- package/lib/Katex-XsfpKgJU.cjs +4 -0
- package/lib/{Katex-Bvj469K1.js → Katex-x370CSXZ.js} +27 -25
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +17 -15
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DjXUEubR.js → LinkEditBlock-C_ipl3EA.js} +27 -25
- package/lib/{LinkEditBlock-8ePAZ-G1.cjs → LinkEditBlock-xt88G5fb.cjs} +2 -2
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +29 -28
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -22
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -8
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +48 -46
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-BT5ystah.cjs +1 -0
- package/lib/{SlashCommandNodeView-CcqL8ymb.js → SlashCommandNodeView-DX6axvLs.js} +74 -65
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +7 -5
- package/lib/Table-DSRSwtXx.cjs +9 -0
- package/lib/{Table-9Y0Cg8Ab.js → Table-DidusYID.js} +10 -8
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +15 -13
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +20 -17
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +20 -17
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -5
- package/lib/Twitter-CBuVBQM1.cjs +1 -0
- package/lib/{Twitter-DWwd0vHR.js → Twitter-D58T0Zt3.js} +59 -57
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +27 -25
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +70 -68
- package/lib/{button-RnHbJfd-.js → button-9_8t7ca7.js} +4 -3
- package/lib/button-Cs9TroWr.cjs +1 -0
- package/lib/{checkbox-CTEN0q4y.cjs → checkbox-BQRKTXXr.cjs} +1 -1
- package/lib/{checkbox-CLSoR1Qj.js → checkbox-DnkkV6qo.js} +1 -1
- package/lib/{index-BBNITgNi.cjs → clsx-CXbNJWDD.cjs} +13 -13
- package/lib/{index-sVScpCFG.js → clsx-DmuN0U_8.js} +228 -228
- package/lib/{dialog-CMC9hsCo.cjs → dialog-BS3zm-T9.cjs} +1 -1
- package/lib/{dialog-D_HCtKvc.js → dialog-DhayAPvV.js} +1 -1
- package/lib/{dropdown-menu-DKSAS-w_.cjs → dropdown-menu-CxwWX0yj.cjs} +1 -1
- package/lib/{dropdown-menu-66q7Ofc5.js → dropdown-menu-DQqKeZcx.js} +1 -1
- package/lib/events.constant-Dq21NPdV.cjs +1 -0
- package/lib/events.constant-do95b767.js +21 -0
- package/lib/{index-CApXPpjF.cjs → index-BCzvbrf5.cjs} +1 -1
- package/lib/{index-0OnGZkVF.js → index-BDX1uE62.js} +78 -312
- package/lib/index-CBFmXCcU.cjs +1 -0
- package/lib/{index-DmPwbBqm.js → index-CKmT9KAQ.js} +1 -1
- package/lib/index-CVFzP1Dc.cjs +1 -0
- package/lib/index-CX4pNJlH.cjs +1 -0
- package/lib/index-CjhjjJsN.cjs +1 -0
- package/lib/index-Cs6cp0Y6.cjs +1 -0
- package/lib/{index-9A6-kVBM.js → index-D1jd7elj.js} +1 -1
- package/lib/{index-C3zg3DPB.js → index-D9JOHlso.js} +493 -1186
- package/lib/{index-DRHrDScg.js → index-DdEmgiAA.js} +1 -1
- package/lib/{index-DKt5wfAc.js → index-DvvwJvau.js} +23 -23
- package/lib/index-EAK64CCA.js +425 -0
- package/lib/{index--nUS7Y66.cjs → index-neeeY2o7.cjs} +3 -3
- package/lib/index.cjs +9 -2
- package/lib/index.js +142 -26
- package/lib/{input-D555880-.cjs → input-BJ7ihMq-.cjs} +1 -1
- package/lib/{input-CvyMYMZG.js → input-YoheBL2D.js} +1 -1
- package/lib/{isNumber-Bv1Qhmw8.cjs → isNumber-BTYSVlKo.cjs} +1 -1
- package/lib/{isNumber-DF0fU3ob.js → isNumber-DmQXlKp3.js} +1 -1
- package/lib/label-C8PLcjFI.js +19 -0
- package/lib/label-Y7_hvqf2.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +6 -7
- package/lib/locales/index.d.ts +3 -4316
- package/lib/{popover-BSzR_R01.cjs → popover-BiSrlM4j.cjs} +1 -1
- package/lib/{popover-B7ec5-u2.js → popover-CWmTzHSy.js} +1 -1
- package/lib/react-BEoMZB61.cjs +1 -0
- package/lib/react-c9FSfB30.js +27 -0
- package/lib/separator-C-DKMYmg.js +329 -0
- package/lib/separator-CJ_adziN.cjs +1 -0
- package/lib/store/EditorEditableReactive.d.ts +1 -0
- package/lib/store/ThemeColorReactive.d.ts +1 -0
- package/lib/store/commandList.d.ts +1 -1
- package/lib/store/store.d.ts +6 -7
- package/lib/store-BKMaw1AW.cjs +1 -0
- package/lib/store-DG7cMfET.js +10 -0
- package/lib/{tabs-BTwiZkWd.cjs → tabs-DpHSMyF_.cjs} +1 -1
- package/lib/{tabs-CWr9HYaM.js → tabs-DxlKKM-N.js} +1 -1
- package/lib/{textarea-BdeLXbp8.js → textarea-D7m-apUh.js} +1 -1
- package/lib/{textarea-Yetl_PZi.cjs → textarea-DU9RMi6u.cjs} +1 -1
- package/lib/theme/theme.d.ts +5 -0
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +37 -8
- package/lib/{throttle-DsowOft0.js → throttle-BRtichEP.js} +1 -1
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-BYvLnjCL.cjs +1 -0
- package/lib/toggle-Bxwwb_Kp.js +99 -0
- package/lib/tooltip-BTy5CRrN.js +24 -0
- package/lib/tooltip-COvf4_R-.cjs +1 -0
- package/lib/{updatePosition-Bbd8ETMv.js → updatePosition-CUukgu-Q.js} +2 -2
- package/lib/updatePosition-Cjuj2E26.cjs +1 -0
- package/lib/{useButtonProps-cMoicZgd.js → useButtonProps-CfYtuEnd.js} +48 -36
- package/lib/useButtonProps-CydzndG1.cjs +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +0 -5
- package/package.json +3 -3
- package/lib/ActionMenuButton-BLlse5KO.cjs +0 -1
- package/lib/Drawer-kv6BU_6O.cjs +0 -1
- package/lib/Excalidraw-B82ThkJA.cjs +0 -1
- package/lib/Icon-DRuJhcHK.js +0 -10
- package/lib/Icon-DXePECFW.cjs +0 -1
- package/lib/Iframe-03dn9wcM.cjs +0 -1
- package/lib/Indent-Cqjdn3Jt.cjs +0 -1
- package/lib/Katex-DdWTV5NJ.cjs +0 -4
- package/lib/SlashCommandNodeView-Bl_gwZJB.cjs +0 -1
- package/lib/Table-DBGjezZK.cjs +0 -9
- package/lib/Twitter-Cnvt7GBg.cjs +0 -1
- package/lib/button-BW5bDPz_.cjs +0 -1
- package/lib/events.constant-DQYeJpu5.cjs +0 -1
- package/lib/events.constant-wrlJ_7JZ.js +0 -26
- package/lib/index-BZ6DfR2r.cjs +0 -1
- package/lib/index-C838s-or.cjs +0 -8
- package/lib/index-Cv9Z6dyV.cjs +0 -1
- package/lib/index-FSRjMsxW.cjs +0 -1
- package/lib/label-DsOYPjAo.js +0 -18
- package/lib/label-E6jF3Xud.cjs +0 -1
- package/lib/separator-JaTTqb3J.js +0 -241
- package/lib/separator-PGnA-6Hr.cjs +0 -1
- package/lib/store/ProviderUniqueId.d.ts +0 -6
- package/lib/store-Cf7tFiiI.js +0 -10
- package/lib/store-oDk-lTPM.cjs +0 -1
- package/lib/throttle-BM3Bmbf_.cjs +0 -1
- package/lib/updatePosition-M2IyqkI1.cjs +0 -1
- package/lib/useButtonProps-DfnJiJLV.cjs +0 -1
package/lib/MoreMark.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./clsx-CXbNJWDD.cjs"),r=require("react/jsx-runtime"),M=require("react"),x=require("./toggle-BYvLnjCL.cjs");require("./index-CX4pNJlH.cjs");require("./theme.cjs");const p=require("./dropdown-menu-CxwWX0yj.cjs"),h=require("./useButtonProps-CydzndG1.cjs"),f=require("./index-CBFmXCcU.cjs"),S=require("./Icon-CiR8RqdQ.cjs");var k=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()}}}),A=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 v(){const t=h.useButtonProps(b.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}=h.useActive(l),d=M.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(x.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(f.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(S.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 b=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(k.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(A.configure(this.options.superscript)),t}});exports.MoreMark=b;exports.RichTextMoreMark=v;
|
package/lib/MoreMark.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { M as h, m, E as b } from "./
|
|
1
|
+
import { M as h, m, E as b } from "./clsx-DmuN0U_8.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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import { A as x } from "./toggle-Bxwwb_Kp.js";
|
|
5
|
+
import "./index-D9JOHlso.js";
|
|
6
|
+
import "./theme.js";
|
|
7
|
+
import { D as A, a as S, b as k, c as v } from "./dropdown-menu-DQqKeZcx.js";
|
|
8
|
+
import { u as y, b as T, g as K } from "./useButtonProps-CfYtuEnd.js";
|
|
9
|
+
import { M as w } from "./index-EAK64CCA.js";
|
|
10
|
+
import { I as C } from "./Icon-ONE1AwKo.js";
|
|
8
11
|
var H = h.create({
|
|
9
12
|
name: "subscript",
|
|
10
13
|
addOptions() {
|
|
@@ -76,16 +79,16 @@ var H = h.create({
|
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
|
-
function
|
|
80
|
-
const t =
|
|
82
|
+
function q() {
|
|
83
|
+
const t = y(D.name), {
|
|
81
84
|
icon: s = void 0,
|
|
82
|
-
tooltip:
|
|
85
|
+
tooltip: o = void 0,
|
|
83
86
|
items: i = [],
|
|
84
87
|
isActive: a = void 0
|
|
85
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState:
|
|
86
|
-
return t ? /* @__PURE__ */ d(
|
|
88
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: n } = T(a), p = M(() => (n == null ? void 0 : n.title) || "", [n]);
|
|
89
|
+
return t ? /* @__PURE__ */ d(A, { children: [
|
|
87
90
|
/* @__PURE__ */ e(
|
|
88
|
-
|
|
91
|
+
S,
|
|
89
92
|
{
|
|
90
93
|
asChild: !0,
|
|
91
94
|
disabled: c,
|
|
@@ -95,14 +98,14 @@ function F() {
|
|
|
95
98
|
customClass: "!richtext-w-12 richtext-h-12",
|
|
96
99
|
disabled: c,
|
|
97
100
|
icon: s,
|
|
98
|
-
tooltip:
|
|
99
|
-
children: /* @__PURE__ */ e(
|
|
101
|
+
tooltip: o,
|
|
102
|
+
children: /* @__PURE__ */ e(w, { className: "richtext-size-3 richtext-text-gray-500" })
|
|
100
103
|
}
|
|
101
104
|
)
|
|
102
105
|
}
|
|
103
106
|
),
|
|
104
|
-
/* @__PURE__ */ e(
|
|
105
|
-
|
|
107
|
+
/* @__PURE__ */ e(k, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
|
|
108
|
+
v,
|
|
106
109
|
{
|
|
107
110
|
checked: p === r.title,
|
|
108
111
|
className: "richtext-flex richtext-items-center richtext-gap-3",
|
|
@@ -110,7 +113,7 @@ function F() {
|
|
|
110
113
|
children: [
|
|
111
114
|
/* @__PURE__ */ e(C, { name: r == null ? void 0 : r.icon }),
|
|
112
115
|
/* @__PURE__ */ e("span", { className: "richtext-ml-1", children: r.title }),
|
|
113
|
-
!!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children:
|
|
116
|
+
!!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children: K(r.shortcutKeys) })
|
|
114
117
|
]
|
|
115
118
|
},
|
|
116
119
|
`more-mark-${u}`
|
|
@@ -125,24 +128,24 @@ const D = /* @__PURE__ */ b.create({
|
|
|
125
128
|
var t;
|
|
126
129
|
return {
|
|
127
130
|
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
128
|
-
button({ editor: s, extension:
|
|
131
|
+
button({ editor: s, extension: o, t: i }) {
|
|
129
132
|
var u, l;
|
|
130
|
-
const a =
|
|
133
|
+
const a = o.options.subscript, c = o.options.superscript, n = {
|
|
131
134
|
action: () => s.commands.toggleSubscript(),
|
|
132
135
|
isActive: () => s.isActive("subscript") || !1,
|
|
133
136
|
disabled: !s.can().toggleSubscript(),
|
|
134
137
|
icon: "Subscript",
|
|
135
138
|
title: i("editor.subscript.tooltip"),
|
|
136
|
-
shortcutKeys: ((u =
|
|
139
|
+
shortcutKeys: ((u = o.options.shortcutKeys) == null ? void 0 : u[0]) ?? ["mod", "."]
|
|
137
140
|
}, p = {
|
|
138
141
|
action: () => s.commands.toggleSuperscript(),
|
|
139
142
|
isActive: () => s.isActive("superscript") || !1,
|
|
140
143
|
disabled: !s.can().toggleSuperscript(),
|
|
141
144
|
icon: "Superscript",
|
|
142
145
|
title: i("editor.superscript.tooltip"),
|
|
143
|
-
shortcutKeys: ((l =
|
|
146
|
+
shortcutKeys: ((l = o.options.shortcutKeys) == null ? void 0 : l[1]) ?? ["mod", ","]
|
|
144
147
|
}, r = [];
|
|
145
|
-
return a !== !1 && r.push(
|
|
148
|
+
return a !== !1 && r.push(n), c !== !1 && r.push(p), {
|
|
146
149
|
// component: ActionMoreButton,
|
|
147
150
|
componentProps: {
|
|
148
151
|
icon: "Type",
|
|
@@ -162,5 +165,5 @@ const D = /* @__PURE__ */ b.create({
|
|
|
162
165
|
});
|
|
163
166
|
export {
|
|
164
167
|
D as MoreMark,
|
|
165
|
-
|
|
168
|
+
q as RichTextMoreMark
|
|
166
169
|
};
|
package/lib/OrderedList.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index-BCzvbrf5.cjs"),r=require("react/jsx-runtime"),g=require("./toggle-BYvLnjCL.cjs");require("react");require("./index-CX4pNJlH.cjs");require("./theme.cjs");const d=require("./useButtonProps-CydzndG1.cjs");function m(){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(g.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=m;
|
package/lib/OrderedList.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { O as u } from "./index-
|
|
1
|
+
import { O as u } from "./index-DdEmgiAA.js";
|
|
2
2
|
import { jsx as n, Fragment as f } from "react/jsx-runtime";
|
|
3
|
-
import { A as l } from "./
|
|
3
|
+
import { A as l } from "./toggle-Bxwwb_Kp.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import "./index-D9JOHlso.js";
|
|
6
|
+
import "./theme.js";
|
|
7
|
+
import { u as v, a as O } from "./useButtonProps-CfYtuEnd.js";
|
|
8
|
+
function B() {
|
|
7
9
|
const t = v(A.name), {
|
|
8
10
|
icon: o = void 0,
|
|
9
11
|
tooltip: i = void 0,
|
|
@@ -11,14 +13,14 @@ function K() {
|
|
|
11
13
|
tooltipOptions: d = {},
|
|
12
14
|
action: r = void 0,
|
|
13
15
|
isActive: c = void 0
|
|
14
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState:
|
|
15
|
-
s || r && (r(),
|
|
16
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { dataState: p, disabled: s, update: a } = O(c), m = () => {
|
|
17
|
+
s || r && (r(), a());
|
|
16
18
|
};
|
|
17
19
|
return t ? /* @__PURE__ */ n(
|
|
18
20
|
l,
|
|
19
21
|
{
|
|
20
22
|
action: m,
|
|
21
|
-
dataState:
|
|
23
|
+
dataState: p,
|
|
22
24
|
disabled: s,
|
|
23
25
|
icon: o,
|
|
24
26
|
shortcutKeys: e,
|
|
@@ -49,5 +51,5 @@ const A = /* @__PURE__ */ u.extend({
|
|
|
49
51
|
});
|
|
50
52
|
export {
|
|
51
53
|
A as OrderedList,
|
|
52
|
-
|
|
54
|
+
B as RichTextOrderedList
|
|
53
55
|
};
|
package/lib/SearchAndReplace.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("./clsx-CXbNJWDD.cjs"),F=require("@tiptap/pm/state"),b=require("@tiptap/pm/view"),a=require("react/jsx-runtime"),f=require("react"),Z=require("./toggle-BYvLnjCL.cjs");require("./index-CX4pNJlH.cjs");require("./theme.cjs");const j=require("./button-Cs9TroWr.cjs"),M=require("./input-BJ7ihMq-.cjs"),k=require("./label-Y7_hvqf2.cjs"),B=require("./popover-BiSrlM4j.cjs"),_=require("./checkbox-BQRKTXXr.cjs"),E=require("./useButtonProps-CydzndG1.cjs"),ee=require("./index-CVFzP1Dc.cjs"),V=require("./Icon-CiR8RqdQ.cjs");function te(){const{t}=ee.useLocale(),e=E.useEditorInstance(),s=E.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}=E.useActive(h),[g,d]=f.useState(!1),[p,A]=f.useState(""),[T,N]=f.useState(""),[I,H]=f.useState(!1),[U,L]=f.useState(""),q=()=>{var r,l,R,m;L(`${((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&&q()},[e]);const z=()=>{i||x&&x()},y=(r=!1)=>{var l,R,m,v,S,D,w,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=(w=e==null?void 0:e.commands)==null?void 0:w.setCaseSensitive)==null||O.call(w,I),q())},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"}),q()};f.useEffect(()=>{p.trim()||$(),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()},$=()=>{var r,l;A(""),N(""),(l=(r=e==null?void 0:e.commands)==null?void 0:r.resetIndex)==null||l.call(r),q()},X=()=>{var r,l;(l=(r=e==null?void 0:e.commands)==null?void 0:r.replaceAll)==null||l.call(r),L("0/0")};return s?a.jsxs(B.Popover,{onOpenChange:d,open:g,children:[a.jsx(B.PopoverTrigger,{asChild:!0,disabled:i,children:a.jsx(Z.ActionButton,{action:z,disabled:i,icon:n,shortcutKeys:o,tooltip:u,tooltipOptions:c})}),a.jsxs(B.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:$,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,26 +1,28 @@
|
|
|
1
|
-
import { E as Q } from "./
|
|
1
|
+
import { E as Q } from "./clsx-DmuN0U_8.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 "./
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
import { A as ee } from "./toggle-Bxwwb_Kp.js";
|
|
7
|
+
import "./index-D9JOHlso.js";
|
|
8
|
+
import "./theme.js";
|
|
9
|
+
import { B as N } from "./button-9_8t7ca7.js";
|
|
10
|
+
import { I as V } from "./input-YoheBL2D.js";
|
|
11
|
+
import { L as B } from "./label-C8PLcjFI.js";
|
|
12
|
+
import { P as te, a as se, b as re } from "./popover-CWmTzHSy.js";
|
|
13
|
+
import { C as ne } from "./checkbox-DnkkV6qo.js";
|
|
14
|
+
import { c as ce, u as ae, b as le } from "./useButtonProps-CfYtuEnd.js";
|
|
15
|
+
import { u as oe } from "./index-BDX1uE62.js";
|
|
16
|
+
import { I as q } from "./Icon-ONE1AwKo.js";
|
|
17
|
+
function ke() {
|
|
18
|
+
const { t } = oe(), e = ce(), s = ae(pe.name), {
|
|
17
19
|
icon: n = void 0,
|
|
18
20
|
tooltip: i = void 0,
|
|
19
21
|
shortcutKeys: l = void 0,
|
|
20
22
|
tooltipOptions: c = {},
|
|
21
|
-
action:
|
|
22
|
-
isActive:
|
|
23
|
-
} = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } =
|
|
23
|
+
action: m = void 0,
|
|
24
|
+
isActive: h = void 0
|
|
25
|
+
} = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = le(h), [f, d] = b(!1), [p, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, D] = b(""), y = () => {
|
|
24
26
|
var r, a, g, x;
|
|
25
27
|
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}`);
|
|
26
28
|
};
|
|
@@ -28,7 +30,7 @@ function ye() {
|
|
|
28
30
|
e && y();
|
|
29
31
|
}, [e]);
|
|
30
32
|
const H = () => {
|
|
31
|
-
o ||
|
|
33
|
+
o || m && m();
|
|
32
34
|
}, L = (r = !1) => {
|
|
33
35
|
var a, g, x, R, v, F, P, O;
|
|
34
36
|
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 = (P = e == null ? void 0 : e.commands) == null ? void 0 : P.setCaseSensitive) == null || O.call(P, I), y());
|
|
@@ -67,13 +69,13 @@ function ye() {
|
|
|
67
69
|
(a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), D("0/0");
|
|
68
70
|
};
|
|
69
71
|
return s ? /* @__PURE__ */ T(
|
|
70
|
-
|
|
72
|
+
te,
|
|
71
73
|
{
|
|
72
74
|
onOpenChange: d,
|
|
73
75
|
open: f,
|
|
74
76
|
children: [
|
|
75
77
|
/* @__PURE__ */ u(
|
|
76
|
-
|
|
78
|
+
se,
|
|
77
79
|
{
|
|
78
80
|
asChild: !0,
|
|
79
81
|
disabled: o,
|
|
@@ -91,7 +93,7 @@ function ye() {
|
|
|
91
93
|
}
|
|
92
94
|
),
|
|
93
95
|
/* @__PURE__ */ T(
|
|
94
|
-
|
|
96
|
+
re,
|
|
95
97
|
{
|
|
96
98
|
align: "start",
|
|
97
99
|
className: "richtext-w-full",
|
|
@@ -154,7 +156,7 @@ function ye() {
|
|
|
154
156
|
) }) }),
|
|
155
157
|
/* @__PURE__ */ T("div", { className: "richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1", children: [
|
|
156
158
|
/* @__PURE__ */ u(
|
|
157
|
-
|
|
159
|
+
ne,
|
|
158
160
|
{
|
|
159
161
|
checked: I,
|
|
160
162
|
onCheckedChange: (r) => {
|
|
@@ -198,23 +200,23 @@ function ie(t, e, s) {
|
|
|
198
200
|
}
|
|
199
201
|
function ue(t, e, s, n) {
|
|
200
202
|
const i = [], l = [];
|
|
201
|
-
let c = [],
|
|
203
|
+
let c = [], m = 0;
|
|
202
204
|
if (!e)
|
|
203
205
|
return {
|
|
204
206
|
decorationsToReturn: $.empty,
|
|
205
207
|
results: []
|
|
206
208
|
};
|
|
207
|
-
t == null || t.descendants((
|
|
208
|
-
|
|
209
|
-
text: c[
|
|
210
|
-
pos: c[
|
|
211
|
-
} : c[
|
|
212
|
-
text: `${
|
|
209
|
+
t == null || t.descendants((h, o) => {
|
|
210
|
+
h.isText ? c[m] ? c[m] = {
|
|
211
|
+
text: c[m].text + h.text,
|
|
212
|
+
pos: c[m].pos
|
|
213
|
+
} : c[m] = {
|
|
214
|
+
text: `${h.text}`,
|
|
213
215
|
pos: o
|
|
214
|
-
} :
|
|
216
|
+
} : m += 1;
|
|
215
217
|
}), c = c.filter(Boolean);
|
|
216
|
-
for (const
|
|
217
|
-
const { text: o, pos: f } =
|
|
218
|
+
for (const h of c) {
|
|
219
|
+
const { text: o, pos: f } = h, d = Array.from(o.matchAll(e)).filter(
|
|
218
220
|
([p]) => p.trim()
|
|
219
221
|
);
|
|
220
222
|
for (const p of d) {
|
|
@@ -225,8 +227,8 @@ function ue(t, e, s, n) {
|
|
|
225
227
|
});
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
|
-
for (const [
|
|
229
|
-
const f =
|
|
230
|
+
for (const [h, o] of l.entries()) {
|
|
231
|
+
const f = h === n ? `${s} ${s}-current` : s, d = Z.inline(o.from, o.to, {
|
|
230
232
|
class: f
|
|
231
233
|
});
|
|
232
234
|
i.push(d);
|
|
@@ -241,22 +243,22 @@ function K(t, e, { state: s, dispatch: n }) {
|
|
|
241
243
|
const { from: l, to: c } = e[0];
|
|
242
244
|
n && n(s.tr.insertText(t, l, c));
|
|
243
245
|
}
|
|
244
|
-
function
|
|
246
|
+
function me(t, e, s, n) {
|
|
245
247
|
const i = e + 1;
|
|
246
248
|
if (!n[i]) return null;
|
|
247
|
-
const { from: l, to: c } = n[e],
|
|
249
|
+
const { from: l, to: c } = n[e], m = c - l - t.length + s, { from: h, to: o } = n[i];
|
|
248
250
|
return n[i] = {
|
|
249
|
-
to: o -
|
|
250
|
-
from:
|
|
251
|
-
}, [
|
|
251
|
+
to: o - m,
|
|
252
|
+
from: h - m
|
|
253
|
+
}, [m, n];
|
|
252
254
|
}
|
|
253
|
-
function
|
|
255
|
+
function he(t, e, { tr: s, dispatch: n }) {
|
|
254
256
|
let i = 0, l = e.slice();
|
|
255
257
|
if (l.length !== 0) {
|
|
256
258
|
for (let c = 0; c < l.length; c += 1) {
|
|
257
|
-
const { from:
|
|
258
|
-
s.insertText(t,
|
|
259
|
-
const o =
|
|
259
|
+
const { from: m, to: h } = l[c];
|
|
260
|
+
s.insertText(t, m, h);
|
|
261
|
+
const o = me(
|
|
260
262
|
t,
|
|
261
263
|
c,
|
|
262
264
|
i,
|
|
@@ -327,7 +329,7 @@ const pe = Q.create({
|
|
|
327
329
|
},
|
|
328
330
|
replaceAll: () => ({ editor: t, tr: e, state: s, dispatch: n }) => {
|
|
329
331
|
const { replaceTerm: i, results: l } = t.storage.searchAndReplace;
|
|
330
|
-
return
|
|
332
|
+
return he(i, l, { tr: e, dispatch: n }), t.storage.searchAndReplace.resultIndex = 0, t.storage.searchAndReplace.results = [], C(s, n), !1;
|
|
331
333
|
}
|
|
332
334
|
};
|
|
333
335
|
},
|
|
@@ -338,7 +340,7 @@ const pe = Q.create({
|
|
|
338
340
|
key: new Y(`richtextCustomPlugin${this.name}`),
|
|
339
341
|
state: {
|
|
340
342
|
init: () => $.empty,
|
|
341
|
-
apply({ doc: c, docChanged:
|
|
343
|
+
apply({ doc: c, docChanged: m }, h) {
|
|
342
344
|
const {
|
|
343
345
|
searchTerm: o,
|
|
344
346
|
lastSearchTerm: f,
|
|
@@ -347,8 +349,8 @@ const pe = Q.create({
|
|
|
347
349
|
resultIndex: A,
|
|
348
350
|
lastResultIndex: S
|
|
349
351
|
} = t.storage.searchAndReplace;
|
|
350
|
-
if (!
|
|
351
|
-
return
|
|
352
|
+
if (!m && f === o && p === d && S === A)
|
|
353
|
+
return h;
|
|
352
354
|
if (n(o), i(d), l(A), !o)
|
|
353
355
|
return t.storage.searchAndReplace.results = [], $.empty;
|
|
354
356
|
const { decorationsToReturn: w, results: I } = ue(
|
|
@@ -370,6 +372,6 @@ const pe = Q.create({
|
|
|
370
372
|
}
|
|
371
373
|
});
|
|
372
374
|
export {
|
|
373
|
-
|
|
375
|
+
ke as RichTextSearchAndReplace,
|
|
374
376
|
pe as SearchAndReplace
|
|
375
377
|
};
|
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 i=require("./clsx-CXbNJWDD.cjs"),u=require("@tiptap/pm/state"),d=require("./index-Cs6cp0Y6.cjs"),r=require("./SlashCommandNodeView-BT5ystah.cjs"),a=require("./updatePosition-Cjuj2E26.cjs"),s=require("react/jsx-runtime"),l=require("./index-CVFzP1Dc.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 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,11 +1,11 @@
|
|
|
1
|
-
import { E as i, R as a } from "./
|
|
1
|
+
import { E as i, R as a } from "./clsx-DmuN0U_8.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-D1jd7elj.js";
|
|
4
|
+
import { u, r as l, S as d } from "./SlashCommandNodeView-DX6axvLs.js";
|
|
5
|
+
import { a as b } from "./SlashCommandNodeView-DX6axvLs.js";
|
|
6
|
+
import { u as o } from "./updatePosition-CUukgu-Q.js";
|
|
7
7
|
import { jsx as f, Fragment as c } from "react/jsx-runtime";
|
|
8
|
-
import { u as h } from "./index-
|
|
8
|
+
import { u as h } from "./index-BDX1uE62.js";
|
|
9
9
|
import { useEffect as C } from "react";
|
|
10
10
|
function E({ commandList: e }) {
|
|
11
11
|
const [, t] = u(), { t: r } = h();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("react/jsx-runtime"),m=require("react"),S=require("./index-CX4pNJlH.cjs");require("./theme.cjs");const y=require("./label-Y7_hvqf2.cjs"),b=require("./index-CVFzP1Dc.cjs"),E=require("./store-BKMaw1AW.cjs"),w=require("./events.constant-Dq21NPdV.cjs"),j=require("./react-BEoMZB61.cjs"),D=require("./Icon-CiR8RqdQ.cjs"),B={setOpen:(i,o)=>{w.dispatchEvent(w.EVENTS.UPLOAD_VIDEO(i),o)}};function $({t:i}){const o=[{name:"format",title:i("editor.slash.format"),commands:[]},{name:"insert",title:i("editor.slash.insert"),commands:[]}];return b.HEADINGS.forEach(e=>{o[0].commands.push({name:`heading${e}`,label:i(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 a=b.HEADINGS.find(u=>t.isActive("heading",{level:u}));if(e==="Paragraph"){a!==void 0&&a!=="Paragraph"&&t.commands.toggleHeading({level:a}),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()}})}),o[0].commands.push({name:"bulletList",label:i("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()}}),o[0].commands.push({name:"orderedlist",label:i("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()}}),o[0].commands.push({name:"taskList",label:i("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()}}),o[0].commands.push({name:"blockquote",label:i("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()}}),o[0].commands.push({name:"codeBlock",label:i("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()}}),o[1].commands.push({name:"image",label:i("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(),E.actionDialogImage.setOpen(e.id,!0)}}),o[1].commands.push({name:"video",label:i("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run(),B.setOpen(e.id,!0)}}),o[1].commands.push({name:"table",label:i("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()}}),o[1].commands.push({name:"horizontalRule",label:i("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()}}),o[1].commands.push({name:"columns",label:i("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),o}function C(i,o){return i.map(l=>({...l,commands:l.commands.filter(a=>{const u=a.label.toLowerCase().trim(),h=o.toLowerCase().trim();if(a.aliases){const p=a.aliases.map(x=>x.toLowerCase().trim()),r=u.match(h),f=p.some(x=>x.match(h));return r||f}return u.match(h)})})).filter(l=>l.commands.length>0)}const L=j.create((i=>({commandList:[],setCommandList:o=>{i(()=>({commandList:o}))}})));function N(){const i=L(e=>e.commandList),o=L(e=>e.setCommandList);return[i,o]}function G(i,o){const[e]=N(),[t,l]=m.useState(0),[a,u]=m.useState(0),h=m.useRef(null),{t:p}=b.useLocale(),r=C(e,i.query),f=m.useRef([]);m.useImperativeHandle(o,()=>({onKeyDown:x})),m.useEffect(()=>{if(!h.current)return;const s=a*1e3+t,n=f.current[s];n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,a]);function x({event:s}){return s.key==="ArrowUp"?(A(),!0):s.key==="ArrowDown"?(R(),!0):s.key==="Enter"?(I(),!0):!1}function A(){var c;if(r.length===0)return!1;let s=t-1,n=a;s<0&&(n=a-1,s=((c=r[n])==null?void 0:c.commands.length)-1||0),n<0&&(n=r.length-1,s=r[n].commands.length-1),l(s),u(n)}function R(){if(r.length===0)return!1;const s=r[a].commands;let n=t+1,c=a;s.length-1<n&&(n=0,c=a+1),r.length-1<c&&(c=0),l(n),u(c)}function I(){if(r.length===0||a===-1||t===-1)return!1;v(a,t)}function v(s,n){const c=r[s].commands[n];i==null||i.command(c)}function k(s,n){v(s,n)}function q(s,n,c){f.current[s*1e3+n]=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:h,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((s,n)=>d.jsxs(m.Fragment,{children:[d.jsx(y.Label,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ",children:s.title}),s.commands.map((c,g)=>d.jsxs("button",{onClick:()=>k(n,g),ref:H=>q(n,g,H),className:S.cn("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 ",{"bg-item-active":a===n&&t===g}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(D.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${g}`))]},`slash-${s.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 V=m.forwardRef(G);exports.SlashCommandNodeView=V;exports.renderCommandListDefault=$;exports.useFilterCommandList=C;exports.useSignalCommandList=N;
|