reactjs-tiptap-editor 0.3.29 → 0.3.31
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-5Y8QcYxD.cjs → ActionMenuButton-BCgqJsST.cjs} +1 -1
- package/lib/{ActionMenuButton-Cs9DM_16.js → ActionMenuButton-D97K0UWT.js} +5 -5
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.d.cts +4 -4
- package/lib/Attachment.d.ts +4 -4
- package/lib/Attachment.js +1 -1
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.d.cts +4 -4
- package/lib/Blockquote.d.ts +4 -4
- package/lib/Blockquote.js +1 -1
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +4 -4
- package/lib/Bold.d.ts +4 -4
- package/lib/Bold.js +1 -1
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +4 -4
- package/lib/BulletList.d.ts +4 -4
- package/lib/BulletList.js +1 -1
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +4 -4
- package/lib/Clear.d.ts +4 -4
- package/lib/Clear.js +1 -1
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +4 -4
- package/lib/Code.d.ts +4 -4
- package/lib/Code.js +1 -1
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.d.cts +4 -4
- package/lib/CodeBlock.d.ts +4 -4
- package/lib/CodeBlock.js +3 -2
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +4 -4
- package/lib/CodeView.d.ts +4 -4
- package/lib/CodeView.js +1 -1
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +4 -4
- package/lib/Color.d.ts +4 -4
- package/lib/Color.js +2 -2
- package/lib/Document.d.cts +4 -4
- package/lib/Document.d.ts +4 -4
- package/lib/Drawer-5Q_-WRhc.cjs +1 -0
- package/lib/{Drawer-BCmNLh31.js → Drawer-BHkje8ys.js} +250 -249
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +4 -4
- package/lib/Drawer.d.ts +4 -4
- package/lib/Drawer.js +2 -2
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +4 -4
- package/lib/Emoji.d.ts +4 -4
- package/lib/Emoji.js +22 -21
- package/lib/Excalidraw-CG498239.js +290 -0
- package/lib/Excalidraw-GUVW-IqC.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +4 -4
- package/lib/Excalidraw.d.ts +4 -4
- package/lib/Excalidraw.js +1 -1
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +4 -4
- package/lib/ExportPdf.d.ts +4 -4
- package/lib/ExportPdf.js +1 -1
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +4 -4
- package/lib/ExportWord.d.ts +4 -4
- package/lib/ExportWord.js +1 -1
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +4 -4
- package/lib/FontFamily.d.ts +4 -4
- package/lib/FontFamily.js +11 -10
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +4 -4
- package/lib/FontSize.d.ts +4 -4
- package/lib/FontSize.js +6 -5
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +4 -4
- package/lib/FormatPainter.d.ts +4 -4
- package/lib/FormatPainter.js +1 -1
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +4 -4
- package/lib/Heading.d.ts +4 -4
- package/lib/Heading.js +32 -31
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +4 -4
- package/lib/Highlight.d.ts +4 -4
- package/lib/Highlight.js +1 -1
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +4 -4
- package/lib/History.d.ts +4 -4
- package/lib/History.js +1 -1
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +4 -4
- package/lib/HorizontalRule.d.ts +4 -4
- package/lib/HorizontalRule.js +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +4 -4
- package/lib/Iframe.d.ts +4 -4
- package/lib/Iframe.js +1 -1
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +4 -4
- package/lib/Image.d.ts +4 -4
- package/lib/Image.js +1 -1
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +4 -4
- package/lib/ImageGif.d.ts +4 -4
- package/lib/ImageGif.js +1 -1
- package/lib/ImportWord.cjs +2 -2
- package/lib/ImportWord.d.cts +4 -4
- package/lib/ImportWord.d.ts +4 -4
- package/lib/ImportWord.js +3 -2
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +4 -4
- package/lib/Indent.d.ts +4 -4
- package/lib/Indent.js +1 -1
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +4 -4
- package/lib/Italic.d.ts +4 -4
- package/lib/Italic.js +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +4 -4
- package/lib/Katex.d.ts +4 -4
- package/lib/Katex.js +41 -40
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +4 -4
- package/lib/LineHeight.d.ts +4 -4
- package/lib/LineHeight.js +17 -16
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +4 -4
- package/lib/Link.d.ts +4 -4
- package/lib/Link.js +1 -1
- package/lib/ListItem.d.cts +4 -4
- package/lib/ListItem.d.ts +4 -4
- package/lib/Mention.d.cts +4 -4
- package/lib/Mention.d.ts +4 -4
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +4 -4
- package/lib/Mermaid.d.ts +4 -4
- package/lib/Mermaid.js +138 -137
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +4 -4
- package/lib/MoreMark.d.ts +4 -4
- package/lib/MoreMark.js +1 -1
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +4 -4
- package/lib/MultiColumn.d.ts +4 -4
- package/lib/MultiColumn.js +1 -1
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +4 -4
- package/lib/OrderedList.d.ts +4 -4
- package/lib/OrderedList.js +1 -1
- package/lib/{RichTextEditor-DsUcQSbm.cjs → RichTextEditor-DWlLqTl9.cjs} +4 -4
- package/lib/{RichTextEditor-e6q30rbV.js → RichTextEditor-KP2Rgcqe.js} +18 -44
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +4 -4
- package/lib/SearchAndReplace.d.ts +4 -4
- package/lib/SearchAndReplace.js +68 -67
- package/lib/Selection.d.cts +4 -4
- package/lib/Selection.d.ts +4 -4
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +4 -4
- package/lib/SlashCommand.d.ts +4 -4
- package/lib/SlashCommand.js +1 -1
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +4 -4
- package/lib/Strike.d.ts +4 -4
- package/lib/Strike.js +1 -1
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +4 -4
- package/lib/SubAndSuperScript.d.ts +4 -4
- package/lib/SubAndSuperScript.js +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.d.cts +4 -4
- package/lib/Table.d.ts +4 -4
- package/lib/Table.js +2 -1
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +4 -4
- package/lib/TableOfContent.d.ts +4 -4
- package/lib/TableOfContent.js +50 -49
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +4 -4
- package/lib/TaskList.d.ts +4 -4
- package/lib/TaskList.js +1 -1
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +4 -4
- package/lib/TextAlign.d.ts +4 -4
- package/lib/TextAlign.js +8 -7
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +4 -4
- package/lib/TextBubble.d.ts +4 -4
- package/lib/TextBubble.js +1 -1
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +4 -4
- package/lib/TextDirection.d.ts +4 -4
- package/lib/TextDirection.js +14 -13
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +4 -4
- package/lib/TextUnderline.d.ts +4 -4
- package/lib/TextUnderline.js +1 -1
- package/lib/TrailingNode.d.cts +4 -4
- package/lib/TrailingNode.d.ts +4 -4
- package/lib/{Twitter-Wb7cD3M-.js → Twitter-99ivY5qv.js} +62 -61
- package/lib/{Twitter-D2Osj8qP.cjs → Twitter-BvfvUtNT.cjs} +2 -2
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +4 -4
- package/lib/Twitter.d.ts +4 -4
- package/lib/Twitter.js +1 -1
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +4 -4
- package/lib/Video.d.ts +4 -4
- package/lib/Video.js +1 -1
- package/lib/bubble-extra.cjs +1 -1
- package/lib/bubble-extra.d.cts +4 -4
- package/lib/bubble-extra.d.ts +4 -4
- package/lib/bubble-extra.js +5 -5
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +5 -4
- package/lib/index.d.ts +5 -4
- package/lib/index.js +2 -2
- package/lib/locale-bundle.d.cts +4 -4
- package/lib/locale-bundle.d.ts +4 -4
- package/lib/style.css +1 -1
- package/lib/{textarea-Csmx5x-_.js → textarea-CktfkXNe.js} +1 -1
- package/lib/{textarea-BVbzd9-k.cjs → textarea-DdH64g04.cjs} +1 -1
- package/package.json +1 -1
- package/lib/Drawer-DCAp7eZF.cjs +0 -1
- package/lib/Excalidraw-BI50RQL-.cjs +0 -1
- package/lib/Excalidraw-CYPcjYZB.js +0 -289
|
@@ -5900,6 +5900,7 @@ function ix(e) {
|
|
|
5900
5900
|
F,
|
|
5901
5901
|
{
|
|
5902
5902
|
tooltip: e == null ? void 0 : e.tooltip,
|
|
5903
|
+
tooltipOptions: e == null ? void 0 : e.tooltipOptions,
|
|
5903
5904
|
isActive: e == null ? void 0 : e.isActive,
|
|
5904
5905
|
disabled: e == null ? void 0 : e.disabled,
|
|
5905
5906
|
children: /* @__PURE__ */ l(ye, { name: e == null ? void 0 : e.icon })
|
|
@@ -6800,7 +6801,8 @@ function xx(e) {
|
|
|
6800
6801
|
{
|
|
6801
6802
|
action: () => i(!0),
|
|
6802
6803
|
icon: e.icon,
|
|
6803
|
-
tooltip: e.tooltip
|
|
6804
|
+
tooltip: e.tooltip,
|
|
6805
|
+
tooltipOptions: e.tooltipOptions
|
|
6804
6806
|
}
|
|
6805
6807
|
) }),
|
|
6806
6808
|
/* @__PURE__ */ R(Rr, { children: [
|
|
@@ -7344,41 +7346,9 @@ const Rx = {
|
|
|
7344
7346
|
props: {
|
|
7345
7347
|
handlePaste: (r, n) => {
|
|
7346
7348
|
var a;
|
|
7347
|
-
|
|
7348
|
-
return;
|
|
7349
|
-
if ([...n.clipboardData.files || []].some((s) => s.type === "text/html"))
|
|
7350
|
-
return !1;
|
|
7351
|
-
if (n.clipboardData.items.length == 2) {
|
|
7352
|
-
n.clipboardData.items[0].getAsString((s) => {
|
|
7353
|
-
let c = "";
|
|
7354
|
-
if (s.replace(/src\s*=\s*"(.*)"/, (u, f) => c = f), c && typeof c == "string") {
|
|
7355
|
-
const u = r.state.schema.nodes.image.create({
|
|
7356
|
-
src: c
|
|
7357
|
-
}), f = r.state.tr.replaceSelectionWith(u);
|
|
7358
|
-
r.dispatch(f);
|
|
7359
|
-
}
|
|
7360
|
-
});
|
|
7361
|
-
return;
|
|
7362
|
-
}
|
|
7363
|
-
return Tx(r, n, t);
|
|
7349
|
+
return n.clipboardData && n.clipboardData.files && ((a = n.clipboardData.files) == null ? void 0 : a.length) ? [...n.clipboardData.files || []].some((s) => s.type === "text/html") ? !1 : Tx(r, n, t) : void 0;
|
|
7364
7350
|
},
|
|
7365
|
-
handleDrop: (r, n, i, o) =>
|
|
7366
|
-
if (!(n instanceof DragEvent) || !n.dataTransfer)
|
|
7367
|
-
return !1;
|
|
7368
|
-
if (n.dataTransfer.items.length == 2) {
|
|
7369
|
-
n.dataTransfer.items[0].getAsString((a) => {
|
|
7370
|
-
let s = "";
|
|
7371
|
-
if (a.replace(/src\s*=\s*"(.*)"/, (c, u) => s = u), s && typeof s == "string") {
|
|
7372
|
-
const c = r.state.schema.nodes.image.create({
|
|
7373
|
-
src: s
|
|
7374
|
-
}), u = r.state.tr.replaceSelectionWith(c);
|
|
7375
|
-
r.dispatch(u);
|
|
7376
|
-
}
|
|
7377
|
-
});
|
|
7378
|
-
return;
|
|
7379
|
-
}
|
|
7380
|
-
return Ex(r, n, o, t), !1;
|
|
7381
|
-
}
|
|
7351
|
+
handleDrop: (r, n, i, o) => (!(n instanceof DragEvent) || !n.dataTransfer || Ex(r, n, o, t), !1)
|
|
7382
7352
|
}
|
|
7383
7353
|
})
|
|
7384
7354
|
];
|
|
@@ -7482,15 +7452,13 @@ function Mx({ selectImage: e, apiKey: t, provider: r, children: n }) {
|
|
|
7482
7452
|
type: "text"
|
|
7483
7453
|
}
|
|
7484
7454
|
) }),
|
|
7485
|
-
/* @__PURE__ */ l("div", { className: "richtext-max-h-[280px] richtext-overflow-y-auto", children: /* @__PURE__ */ l("div", { className: "richtext-grid richtext-grid-cols-2 richtext-gap-1 ", children: i != null && i.length ? i == null ? void 0 : i.map((f) => /* @__PURE__ */ l(
|
|
7455
|
+
/* @__PURE__ */ l("div", { className: "richtext-max-h-[280px] !richtext-max-w-[400px] richtext-overflow-y-auto", children: /* @__PURE__ */ l("div", { className: "richtext-grid richtext-grid-cols-2 richtext-gap-1 ", children: i != null && i.length ? i == null ? void 0 : i.map((f) => /* @__PURE__ */ l(
|
|
7486
7456
|
"img",
|
|
7487
7457
|
{
|
|
7488
7458
|
alt: "",
|
|
7489
|
-
className: "richtext-cursor-pointer richtext-text-center",
|
|
7490
|
-
height: f.height,
|
|
7459
|
+
className: "richtext-cursor-pointer richtext-object-contain richtext-text-center",
|
|
7491
7460
|
onClick: () => e(f.src),
|
|
7492
|
-
src: f.src
|
|
7493
|
-
width: f.width
|
|
7461
|
+
src: f.src
|
|
7494
7462
|
},
|
|
7495
7463
|
f.id
|
|
7496
7464
|
)) : /* @__PURE__ */ l("p", { children: "No GIFs found" }) }) })
|
|
@@ -7512,7 +7480,8 @@ function Lx({ editor: e, icon: t, provider: r, apiKey: n, ...i }) {
|
|
|
7512
7480
|
F,
|
|
7513
7481
|
{
|
|
7514
7482
|
icon: t,
|
|
7515
|
-
tooltip: i == null ? void 0 : i.tooltip
|
|
7483
|
+
tooltip: i == null ? void 0 : i.tooltip,
|
|
7484
|
+
tooltipOptions: i == null ? void 0 : i.tooltipOptions
|
|
7516
7485
|
}
|
|
7517
7486
|
)
|
|
7518
7487
|
}
|
|
@@ -7842,7 +7811,8 @@ function Dx(e) {
|
|
|
7842
7811
|
{
|
|
7843
7812
|
action: () => c(!0),
|
|
7844
7813
|
icon: e.icon,
|
|
7845
|
-
tooltip: e.tooltip
|
|
7814
|
+
tooltip: e.tooltip,
|
|
7815
|
+
tooltipOptions: e.tooltipOptions
|
|
7846
7816
|
}
|
|
7847
7817
|
) }),
|
|
7848
7818
|
/* @__PURE__ */ R(Rr, { children: [
|
|
@@ -12324,7 +12294,7 @@ function Z2({ editor: e, disabled: t, toolbar: r }) {
|
|
|
12324
12294
|
children: /* @__PURE__ */ l("div", { className: "richtext-relative richtext-flex richtext-flex-wrap richtext-h-auto richtext-gap-y-1 richtext-gap-x-1", children: c })
|
|
12325
12295
|
}
|
|
12326
12296
|
), s = o.map((c, u) => {
|
|
12327
|
-
var d, h;
|
|
12297
|
+
var d, h, p, m;
|
|
12328
12298
|
const f = c.button.component;
|
|
12329
12299
|
return /* @__PURE__ */ R("div", { className: "richtext-flex richtext-items-center", children: [
|
|
12330
12300
|
(c == null ? void 0 : c.spacer) && /* @__PURE__ */ l(Ge, { orientation: "vertical", className: "!richtext-h-[16px] !richtext-mx-[10px]" }),
|
|
@@ -12332,7 +12302,11 @@ function Z2({ editor: e, disabled: t, toolbar: r }) {
|
|
|
12332
12302
|
f,
|
|
12333
12303
|
{
|
|
12334
12304
|
...c.button.componentProps,
|
|
12335
|
-
disabled: t || ((h = (d = c == null ? void 0 : c.button) == null ? void 0 : d.componentProps) == null ? void 0 : h.disabled)
|
|
12305
|
+
disabled: t || ((h = (d = c == null ? void 0 : c.button) == null ? void 0 : d.componentProps) == null ? void 0 : h.disabled),
|
|
12306
|
+
tooltipOptions: {
|
|
12307
|
+
...(m = (p = c == null ? void 0 : c.button) == null ? void 0 : p.componentProps) == null ? void 0 : m.tooltipOptions,
|
|
12308
|
+
side: (r == null ? void 0 : r.tooltipSide) ?? "top"
|
|
12309
|
+
}
|
|
12336
12310
|
}
|
|
12337
12311
|
),
|
|
12338
12312
|
(c == null ? void 0 : c.divider) && /* @__PURE__ */ l(Ge, { orientation: "vertical", className: "!richtext-h-auto !richtext-mx-2" })
|
package/lib/SearchAndReplace.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./index-ByRfqzMr.cjs"),P=require("scroll-into-view-if-needed"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./index-ByRfqzMr.cjs"),P=require("scroll-into-view-if-needed"),a=require("react/jsx-runtime"),f=require("react"),c=require("./RichTextEditor-DWlLqTl9.cjs"),A=require("./index-D_A0TBRA.cjs");function w({editor:e,...t}){const{t:s}=A.useLocale(),[i,n]=f.useState(-1),[r,l]=f.useState([]),[o,x]=f.useState(""),[u,h]=f.useState(""),[m,C]=f.useState(!1),[T,I]=f.useState(!1);return f.useEffect(()=>{m||(x(""),h(""),n(-1),l([]),e.commands.setSearchTerm(""),e.commands.setReplaceTerm(""))},[e,m]),f.useEffect(()=>{m&&e&&e.commands&&e.commands.setSearchTerm&&e.commands.setSearchTerm(o)},[m,o,e]),f.useEffect(()=>{m&&e&&e.commands&&e.commands.setReplaceTerm&&e.commands.setReplaceTerm(u)},[m,u,e]),f.useEffect(()=>{if(!e)return;const d=e.extensionManager.extensions.find(R=>R.name===j.name);if(!d)return;const p=()=>{if(!m)return;const R=d?d.storage.currentIndex:-1,v=d?d.storage.results:[];n(E=>E!==R?R:E),l(E=>c.deepEqual(E,v)?E:v)};return c.listenEvent(c.EVENTS.SEARCH_REPLCE,p),()=>{d&&c.listenEvent(c.EVENTS.SEARCH_REPLCE,p)}},[m,e]),a.jsxs(c.Popover,{onOpenChange:C,open:m,children:[a.jsx(c.PopoverTrigger,{asChild:!0,disabled:t==null?void 0:t.disabled,children:a.jsx(c.ActionButton,{disabled:t==null?void 0:t.disabled,isActive:t==null?void 0:t.isActive,tooltip:t==null?void 0:t.tooltip,tooltipOptions:t==null?void 0:t.tooltipOptions,children:a.jsx(c.IconComponent,{name:t==null?void 0:t.icon})})}),a.jsxs(c.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(c.Label,{children:s("editor.search.dialog.text")}),a.jsx("span",{className:"richtext-font-semibold",children:r.length>0?`${i+1}/${r.length}`:"0/0"})]}),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(c.Input,{autoFocus:!0,className:"richtext-w-full",onChange:d=>x(d.target.value),placeholder:"Text",required:!0,type:"text",value:o}),a.jsx(c.Button,{className:"richtext-flex-1",disabled:r.length===0,onClick:e.commands.goToPrevSearchResult,children:a.jsx(c.IconComponent,{name:"ChevronUp"})}),a.jsx(c.Button,{className:"richtext-flex-1",disabled:r.length===0,onClick:e.commands.goToNextSearchResult,children:a.jsx(c.IconComponent,{name:"ChevronDown"})})]}),a.jsx(c.Label,{className:"richtext-mb-[6px]",children:s("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(c.Input,{className:"richtext-w-80",onChange:d=>h(d.target.value),placeholder:"Text",required:!0,type:"text",value:u})})}),a.jsxs("div",{className:"richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2",children:[a.jsx(c.Switch,{checked:T,onCheckedChange:d=>{I(d),e.commands.setCaseSensitive(d)}}),a.jsx(c.Label,{children:s("editor.replace.caseSensitive")})]}),a.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[a.jsx(c.Button,{className:"richtext-flex-1",disabled:r.length===0,onClick:e.commands.replace,children:s("editor.replace.dialog.text")}),a.jsx(c.Button,{className:"richtext-flex-1",disabled:r.length===0,onClick:e.commands.replaceAll,children:s("editor.replaceAll.dialog.text")})]})]})]})}const S=(e,t)=>t(e.tr);function V(e,t,s){return RegExp(t?e.replace(/[$()*+./?[\\\]^{|}-]/g,String.raw`\$&`):e,s?"gu":"gui")}function L(e,t,s){const i=[];let n=[];const r=[];let l=0;if(!t)return{decorationsToReturn:[],results:[]};e==null||e.descendants((o,x)=>{o.isText?n[l]?n[l]={text:n[l].text+o.text,pos:n[l].pos}:n[l]={text:`${o.text}`,pos:x}:l+=1}),n=n.filter(Boolean);for(const{text:o,pos:x}of n){const u=[...o.matchAll(t)];for(const h of u){if(h[0]==="")break;h.index!==void 0&&r.push({from:x+h.index,to:x+h.index+h[0].length})}}for(const o of r)i.push(g.Decoration.inline(o.from,o.to,{class:s}));return{decorationsToReturn:i,results:r}}function b(e,t,{state:s,dispatch:i}){if(!t[0])return;const{from:r,to:l}=t[0];i&&i(s.tr.insertText(e,r,l))}function y(e,t,s,i){const n=t+1;if(!i[n])return null;const{from:r,to:l}=i[t],o=l-r-e.length+s,{from:x,to:u}=i[n];return i[n]={to:u-o,from:x-o},[o,i]}function D(e,t,{tr:s,dispatch:i}){let n=0,r=t.slice();if(r.length===0)return!1;for(let l=0;l<r.length;l+=1){const{from:o,to:x}=r[l];s.insertText(e,o,x);const u=y(e,l,n,r);u&&(n=u[0],r=u[1])}return i(s),!0}function N({view:e,tr:t,searchResults:s,searchResultCurrentClass:i,gotoIndex:n}){const r=s[n];if(r){const l=t.setMeta("directDecoration",{fromPos:r.from,toPos:r.to,attrs:{class:i}});return e==null||e.dispatch(l),setTimeout(()=>{const o=window.document.querySelector(`.${i}`);o&&P(o,{behavior:"smooth",scrollMode:"if-needed"})},0),!0}return!1}const j=g.Extension.create({name:"search",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),searchTerm:"",replaceTerm:"",results:[],currentIndex:0,searchResultClass:"search-result",searchResultCurrentClass:"search-result-current",caseSensitive:!1,disableRegex:!1,onChange:()=>{},button:({editor:t,t:s})=>({component:w,componentProps:{action:()=>{},icon:"SearchAndReplace",tooltip:s("editor.searchAndReplace.tooltip"),isActive:()=>!1,disabled:!1,editor:t}})}},addStorage(){return{results:[],currentIndex:-1}},addCommands(){return{setSearchTerm:e=>({state:t,dispatch:s})=>(this.options.searchTerm=e,this.storage.results=[],this.storage.currentIndex=0,c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),S(t,s),!1),setReplaceTerm:e=>({state:t,dispatch:s})=>(this.options.replaceTerm=e,S(t,s),!1),setCaseSensitive:e=>({state:t,dispatch:s})=>(this.options.caseSensitive=e,S(t,s),!1),replace:()=>({state:e,dispatch:t})=>{const{replaceTerm:s}=this.options,{currentIndex:i,results:n}=this.storage,r=n[i];return r?(b(s,[r],{state:e,dispatch:t}),this.storage.results.splice(i,1)):(b(s,n,{state:e,dispatch:t}),this.storage.results.shift()),c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),S(e,t),!1},replaceAll:()=>({state:e,tr:t,dispatch:s})=>{const{replaceTerm:i}=this.options,{results:n}=this.storage;return D(i,n,{tr:t,dispatch:s}),this.storage.currentIndex=-1,this.storage.results=[],c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),S(e,s),!1},goToPrevSearchResult:()=>({view:e,tr:t})=>{const{searchResultCurrentClass:s}=this.options,{currentIndex:i,results:n}=this.storage,r=(i+n.length-1)%n.length;return this.storage.currentIndex=r,c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),N({view:e,tr:t,searchResults:n,searchResultCurrentClass:s,gotoIndex:r})},goToNextSearchResult:()=>({view:e,tr:t})=>{const{searchResultCurrentClass:s}=this.options,{currentIndex:i,results:n}=this.storage,r=(i+1)%n.length;return this.storage.currentIndex=r,this.options.onChange&&this.options.onChange(),c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),N({view:e,tr:t,searchResults:n,searchResultCurrentClass:s,gotoIndex:r})}}},addProseMirrorPlugins(){const e=this;return[new g.Plugin({key:new g.PluginKey("search"),state:{init(){return g.DecorationSet.empty},apply(t){const{doc:s,docChanged:i}=t,{searchTerm:n,searchResultClass:r,searchResultCurrentClass:l,disableRegex:o,caseSensitive:x}=e.options;if(i||n){const{decorationsToReturn:u,results:h}=L(s,V(n,o,x),r);if(e.storage.results=h,e.storage.currentIndex>h.length-1&&(e.storage.currentIndex=0),c.dispatchEvent(c.EVENTS.SEARCH_REPLCE),t.getMeta("directDecoration")){const{fromPos:m,toPos:C,attrs:T}=t.getMeta("directDecoration");u.push(g.Decoration.inline(m,C,T))}else h.length>0&&(u[0]=g.Decoration.inline(h[0].from,h[0].to,{class:l}));return g.DecorationSet.create(s,u)}return g.DecorationSet.empty}},props:{decorations(t){return this.getState(t)}}})]}});exports.SearchAndReplace=j;
|
|
@@ -149,8 +149,8 @@ declare module '@tiptap/core' {
|
|
|
149
149
|
|
|
150
150
|
declare module '@tiptap/core' {
|
|
151
151
|
interface Commands<ReturnType> {
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
excalidraw: {
|
|
153
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -158,8 +158,8 @@ declare module '@tiptap/core' {
|
|
|
158
158
|
|
|
159
159
|
declare module '@tiptap/core' {
|
|
160
160
|
interface Commands<ReturnType> {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
exportPdf: {
|
|
162
|
+
exportToPdf: () => ReturnType;
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -149,8 +149,8 @@ declare module '@tiptap/core' {
|
|
|
149
149
|
|
|
150
150
|
declare module '@tiptap/core' {
|
|
151
151
|
interface Commands<ReturnType> {
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
excalidraw: {
|
|
153
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -158,8 +158,8 @@ declare module '@tiptap/core' {
|
|
|
158
158
|
|
|
159
159
|
declare module '@tiptap/core' {
|
|
160
160
|
interface Commands<ReturnType> {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
exportPdf: {
|
|
162
|
+
exportToPdf: () => ReturnType;
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
}
|
package/lib/SearchAndReplace.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { E as _, P as M, a as $, b as N, D as P } from "./index-DI9T3iLd.js";
|
|
2
2
|
import q from "scroll-into-view-if-needed";
|
|
3
3
|
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
4
|
-
import { useState as g, useEffect as
|
|
5
|
-
import { l as k, E as d, P as B, m as
|
|
4
|
+
import { useState as g, useEffect as p } from "react";
|
|
5
|
+
import { l as k, E as d, P as B, m as O, A as j, k as A, n as F, L as I, o as y, B as T, S as W, p as K, q as R } from "./RichTextEditor-KP2Rgcqe.js";
|
|
6
6
|
import { u as U } from "./index-CsK90iVd.js";
|
|
7
7
|
function z({ editor: e, ...t }) {
|
|
8
|
-
const { t: s } = U(), [c,
|
|
9
|
-
return
|
|
10
|
-
x || (u(""), h(""),
|
|
11
|
-
}, [e, x]),
|
|
8
|
+
const { t: s } = U(), [c, n] = g(-1), [r, i] = g([]), [a, u] = g(""), [l, h] = g(""), [x, v] = g(!1), [b, V] = g(!1);
|
|
9
|
+
return p(() => {
|
|
10
|
+
x || (u(""), h(""), n(-1), i([]), e.commands.setSearchTerm(""), e.commands.setReplaceTerm(""));
|
|
11
|
+
}, [e, x]), p(() => {
|
|
12
12
|
x && e && e.commands && e.commands.setSearchTerm && e.commands.setSearchTerm(a);
|
|
13
|
-
}, [x, a, e]),
|
|
13
|
+
}, [x, a, e]), p(() => {
|
|
14
14
|
x && e && e.commands && e.commands.setReplaceTerm && e.commands.setReplaceTerm(l);
|
|
15
|
-
}, [x, l, e]),
|
|
15
|
+
}, [x, l, e]), p(() => {
|
|
16
16
|
if (!e)
|
|
17
17
|
return;
|
|
18
|
-
const m = e.extensionManager.extensions.find((
|
|
18
|
+
const m = e.extensionManager.extensions.find((E) => E.name === Y.name);
|
|
19
19
|
if (!m)
|
|
20
20
|
return;
|
|
21
21
|
const w = () => {
|
|
22
22
|
if (!x)
|
|
23
23
|
return;
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const E = m ? m.storage.currentIndex : -1, L = m ? m.storage.results : [];
|
|
25
|
+
n((C) => C !== E ? E : C), i((C) => K(C, L) ? C : L);
|
|
26
26
|
};
|
|
27
27
|
return k(d.SEARCH_REPLCE, w), () => {
|
|
28
28
|
m && k(d.SEARCH_REPLCE, w);
|
|
@@ -34,23 +34,24 @@ function z({ editor: e, ...t }) {
|
|
|
34
34
|
open: x,
|
|
35
35
|
children: [
|
|
36
36
|
/* @__PURE__ */ o(
|
|
37
|
-
|
|
37
|
+
O,
|
|
38
38
|
{
|
|
39
39
|
asChild: !0,
|
|
40
40
|
disabled: t == null ? void 0 : t.disabled,
|
|
41
41
|
children: /* @__PURE__ */ o(
|
|
42
|
-
|
|
42
|
+
j,
|
|
43
43
|
{
|
|
44
44
|
disabled: t == null ? void 0 : t.disabled,
|
|
45
45
|
isActive: t == null ? void 0 : t.isActive,
|
|
46
46
|
tooltip: t == null ? void 0 : t.tooltip,
|
|
47
|
+
tooltipOptions: t == null ? void 0 : t.tooltipOptions,
|
|
47
48
|
children: /* @__PURE__ */ o(A, { name: t == null ? void 0 : t.icon })
|
|
48
49
|
}
|
|
49
50
|
)
|
|
50
51
|
}
|
|
51
52
|
),
|
|
52
53
|
/* @__PURE__ */ f(
|
|
53
|
-
|
|
54
|
+
F,
|
|
54
55
|
{
|
|
55
56
|
align: "start",
|
|
56
57
|
className: "richtext-w-full",
|
|
@@ -59,7 +60,7 @@ function z({ editor: e, ...t }) {
|
|
|
59
60
|
children: [
|
|
60
61
|
/* @__PURE__ */ f("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
|
|
61
62
|
/* @__PURE__ */ o(I, { children: s("editor.search.dialog.text") }),
|
|
62
|
-
/* @__PURE__ */ o("span", { className: "richtext-font-semibold", children:
|
|
63
|
+
/* @__PURE__ */ o("span", { className: "richtext-font-semibold", children: r.length > 0 ? `${c + 1}/${r.length}` : "0/0" })
|
|
63
64
|
] }),
|
|
64
65
|
/* @__PURE__ */ f("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
|
|
65
66
|
/* @__PURE__ */ o(
|
|
@@ -78,7 +79,7 @@ function z({ editor: e, ...t }) {
|
|
|
78
79
|
T,
|
|
79
80
|
{
|
|
80
81
|
className: "richtext-flex-1",
|
|
81
|
-
disabled:
|
|
82
|
+
disabled: r.length === 0,
|
|
82
83
|
onClick: e.commands.goToPrevSearchResult,
|
|
83
84
|
children: /* @__PURE__ */ o(A, { name: "ChevronUp" })
|
|
84
85
|
}
|
|
@@ -87,7 +88,7 @@ function z({ editor: e, ...t }) {
|
|
|
87
88
|
T,
|
|
88
89
|
{
|
|
89
90
|
className: "richtext-flex-1",
|
|
90
|
-
disabled:
|
|
91
|
+
disabled: r.length === 0,
|
|
91
92
|
onClick: e.commands.goToNextSearchResult,
|
|
92
93
|
children: /* @__PURE__ */ o(A, { name: "ChevronDown" })
|
|
93
94
|
}
|
|
@@ -122,7 +123,7 @@ function z({ editor: e, ...t }) {
|
|
|
122
123
|
T,
|
|
123
124
|
{
|
|
124
125
|
className: "richtext-flex-1",
|
|
125
|
-
disabled:
|
|
126
|
+
disabled: r.length === 0,
|
|
126
127
|
onClick: e.commands.replace,
|
|
127
128
|
children: s("editor.replace.dialog.text")
|
|
128
129
|
}
|
|
@@ -131,7 +132,7 @@ function z({ editor: e, ...t }) {
|
|
|
131
132
|
T,
|
|
132
133
|
{
|
|
133
134
|
className: "richtext-flex-1",
|
|
134
|
-
disabled:
|
|
135
|
+
disabled: r.length === 0,
|
|
135
136
|
onClick: e.commands.replaceAll,
|
|
136
137
|
children: s("editor.replaceAll.dialog.text")
|
|
137
138
|
}
|
|
@@ -144,78 +145,78 @@ function z({ editor: e, ...t }) {
|
|
|
144
145
|
}
|
|
145
146
|
);
|
|
146
147
|
}
|
|
147
|
-
const
|
|
148
|
+
const S = (e, t) => t(e.tr);
|
|
148
149
|
function G(e, t, s) {
|
|
149
150
|
return RegExp(t ? e.replace(/[$()*+./?[\\\]^{|}-]/g, String.raw`\$&`) : e, s ? "gu" : "gui");
|
|
150
151
|
}
|
|
151
152
|
function J(e, t, s) {
|
|
152
153
|
const c = [];
|
|
153
|
-
let
|
|
154
|
-
const
|
|
154
|
+
let n = [];
|
|
155
|
+
const r = [];
|
|
155
156
|
let i = 0;
|
|
156
157
|
if (!t)
|
|
157
158
|
return { decorationsToReturn: [], results: [] };
|
|
158
159
|
e == null || e.descendants((a, u) => {
|
|
159
|
-
a.isText ?
|
|
160
|
-
text:
|
|
161
|
-
pos:
|
|
162
|
-
} :
|
|
160
|
+
a.isText ? n[i] ? n[i] = {
|
|
161
|
+
text: n[i].text + a.text,
|
|
162
|
+
pos: n[i].pos
|
|
163
|
+
} : n[i] = {
|
|
163
164
|
text: `${a.text}`,
|
|
164
165
|
pos: u
|
|
165
166
|
} : i += 1;
|
|
166
|
-
}),
|
|
167
|
-
for (const { text: a, pos: u } of
|
|
167
|
+
}), n = n.filter(Boolean);
|
|
168
|
+
for (const { text: a, pos: u } of n) {
|
|
168
169
|
const l = [...a.matchAll(t)];
|
|
169
170
|
for (const h of l) {
|
|
170
171
|
if (h[0] === "")
|
|
171
172
|
break;
|
|
172
|
-
h.index !== void 0 &&
|
|
173
|
+
h.index !== void 0 && r.push({
|
|
173
174
|
from: u + h.index,
|
|
174
175
|
to: u + h.index + h[0].length
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
|
-
for (const a of
|
|
179
|
+
for (const a of r)
|
|
179
180
|
c.push(N.inline(a.from, a.to, { class: s }));
|
|
180
181
|
return {
|
|
181
182
|
decorationsToReturn: c,
|
|
182
|
-
results:
|
|
183
|
+
results: r
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
186
|
function D(e, t, { state: s, dispatch: c }) {
|
|
186
187
|
if (!t[0])
|
|
187
188
|
return;
|
|
188
|
-
const { from:
|
|
189
|
-
c && c(s.tr.insertText(e,
|
|
189
|
+
const { from: r, to: i } = t[0];
|
|
190
|
+
c && c(s.tr.insertText(e, r, i));
|
|
190
191
|
}
|
|
191
192
|
function Q(e, t, s, c) {
|
|
192
|
-
const
|
|
193
|
-
if (!c[
|
|
193
|
+
const n = t + 1;
|
|
194
|
+
if (!c[n])
|
|
194
195
|
return null;
|
|
195
|
-
const { from:
|
|
196
|
-
return c[
|
|
196
|
+
const { from: r, to: i } = c[t], a = i - r - e.length + s, { from: u, to: l } = c[n];
|
|
197
|
+
return c[n] = {
|
|
197
198
|
to: l - a,
|
|
198
199
|
from: u - a
|
|
199
200
|
}, [a, c];
|
|
200
201
|
}
|
|
201
202
|
function X(e, t, { tr: s, dispatch: c }) {
|
|
202
|
-
let
|
|
203
|
-
if (
|
|
203
|
+
let n = 0, r = t.slice();
|
|
204
|
+
if (r.length === 0)
|
|
204
205
|
return !1;
|
|
205
|
-
for (let i = 0; i <
|
|
206
|
-
const { from: a, to: u } =
|
|
206
|
+
for (let i = 0; i < r.length; i += 1) {
|
|
207
|
+
const { from: a, to: u } = r[i];
|
|
207
208
|
s.insertText(e, a, u);
|
|
208
|
-
const l = Q(e, i,
|
|
209
|
-
l && (
|
|
209
|
+
const l = Q(e, i, n, r);
|
|
210
|
+
l && (n = l[0], r = l[1]);
|
|
210
211
|
}
|
|
211
212
|
return c(s), !0;
|
|
212
213
|
}
|
|
213
|
-
function H({ view: e, tr: t, searchResults: s, searchResultCurrentClass: c, gotoIndex:
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
214
|
+
function H({ view: e, tr: t, searchResults: s, searchResultCurrentClass: c, gotoIndex: n }) {
|
|
215
|
+
const r = s[n];
|
|
216
|
+
if (r) {
|
|
216
217
|
const i = t.setMeta("directDecoration", {
|
|
217
|
-
fromPos:
|
|
218
|
-
toPos:
|
|
218
|
+
fromPos: r.from,
|
|
219
|
+
toPos: r.to,
|
|
219
220
|
attrs: { class: c }
|
|
220
221
|
});
|
|
221
222
|
return e == null || e.dispatch(i), setTimeout(() => {
|
|
@@ -263,35 +264,35 @@ const Y = /* @__PURE__ */ _.create({
|
|
|
263
264
|
},
|
|
264
265
|
addCommands() {
|
|
265
266
|
return {
|
|
266
|
-
setSearchTerm: (e) => ({ state: t, dispatch: s }) => (this.options.searchTerm = e, this.storage.results = [], this.storage.currentIndex = 0, R(d.SEARCH_REPLCE),
|
|
267
|
-
setReplaceTerm: (e) => ({ state: t, dispatch: s }) => (this.options.replaceTerm = e,
|
|
268
|
-
setCaseSensitive: (e) => ({ state: t, dispatch: s }) => (this.options.caseSensitive = e,
|
|
267
|
+
setSearchTerm: (e) => ({ state: t, dispatch: s }) => (this.options.searchTerm = e, this.storage.results = [], this.storage.currentIndex = 0, R(d.SEARCH_REPLCE), S(t, s), !1),
|
|
268
|
+
setReplaceTerm: (e) => ({ state: t, dispatch: s }) => (this.options.replaceTerm = e, S(t, s), !1),
|
|
269
|
+
setCaseSensitive: (e) => ({ state: t, dispatch: s }) => (this.options.caseSensitive = e, S(t, s), !1),
|
|
269
270
|
replace: () => ({ state: e, dispatch: t }) => {
|
|
270
|
-
const { replaceTerm: s } = this.options, { currentIndex: c, results:
|
|
271
|
-
return
|
|
271
|
+
const { replaceTerm: s } = this.options, { currentIndex: c, results: n } = this.storage, r = n[c];
|
|
272
|
+
return r ? (D(s, [r], { state: e, dispatch: t }), this.storage.results.splice(c, 1)) : (D(s, n, { state: e, dispatch: t }), this.storage.results.shift()), R(d.SEARCH_REPLCE), S(e, t), !1;
|
|
272
273
|
},
|
|
273
274
|
replaceAll: () => ({ state: e, tr: t, dispatch: s }) => {
|
|
274
|
-
const { replaceTerm: c } = this.options, { results:
|
|
275
|
-
return X(c,
|
|
275
|
+
const { replaceTerm: c } = this.options, { results: n } = this.storage;
|
|
276
|
+
return X(c, n, { tr: t, dispatch: s }), this.storage.currentIndex = -1, this.storage.results = [], R(d.SEARCH_REPLCE), S(e, s), !1;
|
|
276
277
|
},
|
|
277
278
|
goToPrevSearchResult: () => ({ view: e, tr: t }) => {
|
|
278
|
-
const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results:
|
|
279
|
-
return this.storage.currentIndex =
|
|
279
|
+
const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: n } = this.storage, r = (c + n.length - 1) % n.length;
|
|
280
|
+
return this.storage.currentIndex = r, R(d.SEARCH_REPLCE), H({
|
|
280
281
|
view: e,
|
|
281
282
|
tr: t,
|
|
282
|
-
searchResults:
|
|
283
|
+
searchResults: n,
|
|
283
284
|
searchResultCurrentClass: s,
|
|
284
|
-
gotoIndex:
|
|
285
|
+
gotoIndex: r
|
|
285
286
|
});
|
|
286
287
|
},
|
|
287
288
|
goToNextSearchResult: () => ({ view: e, tr: t }) => {
|
|
288
|
-
const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results:
|
|
289
|
-
return this.storage.currentIndex =
|
|
289
|
+
const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: n } = this.storage, r = (c + 1) % n.length;
|
|
290
|
+
return this.storage.currentIndex = r, this.options.onChange && this.options.onChange(), R(d.SEARCH_REPLCE), H({
|
|
290
291
|
view: e,
|
|
291
292
|
tr: t,
|
|
292
|
-
searchResults:
|
|
293
|
+
searchResults: n,
|
|
293
294
|
searchResultCurrentClass: s,
|
|
294
|
-
gotoIndex:
|
|
295
|
+
gotoIndex: r
|
|
295
296
|
});
|
|
296
297
|
}
|
|
297
298
|
};
|
|
@@ -306,12 +307,12 @@ const Y = /* @__PURE__ */ _.create({
|
|
|
306
307
|
return P.empty;
|
|
307
308
|
},
|
|
308
309
|
apply(t) {
|
|
309
|
-
const { doc: s, docChanged: c } = t, { searchTerm:
|
|
310
|
-
if (c ||
|
|
310
|
+
const { doc: s, docChanged: c } = t, { searchTerm: n, searchResultClass: r, searchResultCurrentClass: i, disableRegex: a, caseSensitive: u } = e.options;
|
|
311
|
+
if (c || n) {
|
|
311
312
|
const { decorationsToReturn: l, results: h } = J(
|
|
312
313
|
s,
|
|
313
|
-
G(
|
|
314
|
-
|
|
314
|
+
G(n, a, u),
|
|
315
|
+
r
|
|
315
316
|
);
|
|
316
317
|
if (e.storage.results = h, e.storage.currentIndex > h.length - 1 && (e.storage.currentIndex = 0), R(d.SEARCH_REPLCE), t.getMeta("directDecoration")) {
|
|
317
318
|
const { fromPos: x, toPos: v, attrs: b } = t.getMeta("directDecoration");
|
package/lib/Selection.d.cts
CHANGED
|
@@ -61,8 +61,8 @@ declare module '@tiptap/core' {
|
|
|
61
61
|
|
|
62
62
|
declare module '@tiptap/core' {
|
|
63
63
|
interface Commands<ReturnType> {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
excalidraw: {
|
|
65
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -70,8 +70,8 @@ declare module '@tiptap/core' {
|
|
|
70
70
|
|
|
71
71
|
declare module '@tiptap/core' {
|
|
72
72
|
interface Commands<ReturnType> {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
exportPdf: {
|
|
74
|
+
exportToPdf: () => ReturnType;
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
}
|
package/lib/Selection.d.ts
CHANGED
|
@@ -61,8 +61,8 @@ declare module '@tiptap/core' {
|
|
|
61
61
|
|
|
62
62
|
declare module '@tiptap/core' {
|
|
63
63
|
interface Commands<ReturnType> {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
excalidraw: {
|
|
65
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -70,8 +70,8 @@ declare module '@tiptap/core' {
|
|
|
70
70
|
|
|
71
71
|
declare module '@tiptap/core' {
|
|
72
72
|
interface Commands<ReturnType> {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
exportPdf: {
|
|
74
|
+
exportToPdf: () => ReturnType;
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
}
|
package/lib/SlashCommand.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./index-ByRfqzMr.cjs"),O=require("./dom-dataset-Byuf1YmW.cjs"),q=require("./index-BI-IcZcN.cjs"),D=require("tippy.js"),f=require("react/jsx-runtime"),x=require("react"),b=require("./RichTextEditor-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./index-ByRfqzMr.cjs"),O=require("./dom-dataset-Byuf1YmW.cjs"),q=require("./index-BI-IcZcN.cjs"),D=require("tippy.js"),f=require("react/jsx-runtime"),x=require("react"),b=require("./RichTextEditor-DWlLqTl9.cjs"),h=require("./index-D_A0TBRA.cjs");function P(i,d){var k,N;const[t,n]=x.useState(0),[e,o]=x.useState(0),r=x.useRef(null),{t:s}=h.useLocale(),u=x.useRef([]);x.useImperativeHandle(d,()=>({onKeyDown:g})),x.useEffect(()=>{if(!r.current)return;const l=e*1e3+t,c=u.current[l];c&&c.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,e]);function g({event:l}){return l.key==="ArrowUp"?(C(),!0):l.key==="ArrowDown"?(R(),!0):l.key==="Enter"?(L(),!0):!1}function C(){var m;if(i.items.length===0)return!1;let l=t-1,c=e;l<0&&(c=e-1,l=((m=i.items[c])==null?void 0:m.commands.length)-1||0),c<0&&(c=i.items.length-1,l=i.items[c].commands.length-1),n(l),o(c)}function R(){if(i.items.length===0)return!1;const l=i.items[e].commands;let c=t+1,m=e;l.length-1<c&&(c=0,m=e+1),i.items.length-1<m&&(m=0),n(c),o(m)}function L(){if(i.items.length===0||e===-1||t===-1)return!1;v(e,t)}function v(l,c){const m=i.items[l].commands[c];i.command(m)}function H(l,c){v(l,c)}function I(l,c,m){u.current[l*1e3+c]=m}return f.jsx("div",{className:"richtext-mb-8 richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-auto richtext-rounded-lg !richtext-border !richtext-border-neutral-200 !richtext-bg-white richtext-p-1 !richtext-text-black richtext-shadow-sm dark:!richtext-border-neutral-800 dark:!richtext-bg-black",ref:r,children:(k=i==null?void 0:i.items)!=null&&k.length?f.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:(N=i==null?void 0:i.items)==null?void 0:N.map((l,c)=>f.jsxs(x.Fragment,{children:[f.jsx("div",{className:"richtext-col-[1/-1] richtext-mx-2 richtext-mt-2 richtext-select-none richtext-text-[0.65rem] richtext-font-semibold richtext-uppercase richtext-tracking-wider !richtext-text-neutral-500 first:richtext-mt-0.5",children:l.title}),l.commands.map((m,y)=>f.jsxs("button",{onClick:()=>H(c,y),ref:S=>I(c,y,S),className:b.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm !richtext-text-neutral-800 dark:!richtext-text-neutral-200 richtext-text-left richtext-w-full richtext-rounded-sm richtext-outline-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"slash-command-active":e===c&&t===y}),children:[m.iconUrl&&f.jsx("img",{alt:"",className:"richtext-size-6",src:m.iconUrl}),m.iconName&&f.jsx(b.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:m.iconName}),m.label]},`command-${y}`))]},`slash-${l.title}`))}):f.jsx("div",{className:"richtext-p-3",children:f.jsx("span",{className:"richtext-text-xs richtext-text-gray-800 dark:richtext-text-gray-100",children:s("editor.slash.empty")})})})}const $=x.forwardRef(P),j={setOpen:(i,d)=>{b.dispatchEvent(b.EVENTS.UPLOAD_VIDEO(i),d)}};function B(i,d){const t=[{name:"format",title:h.localeActions.t("editor.slash.format"),commands:[]},{name:"insert",title:h.localeActions.t("editor.slash.insert"),commands:[]}];return i.forEach(n=>{n.name.toLowerCase()==="heading"&&n.options.levels.forEach(e=>{t[0].commands.push({name:`heading${e}`,label:h.localeActions.t(`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,action:({editor:o,range:r})=>{o.chain().focus().deleteRange(r).setHeading({level:e}).run()}})}),n.name.toLowerCase()==="bulletlist"&&t[0].commands.push({name:"bulletList",label:h.localeActions.t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleBulletList().run()}}),n.name.toLowerCase()==="orderedlist"&&t[0].commands.push({name:"numberedList",label:h.localeActions.t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleOrderedList().run()}}),n.name.toLowerCase()==="tasklist"&&t[0].commands.push({name:"taskList",label:h.localeActions.t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleTaskList().run()}}),n.name.toLowerCase()==="blockquote"&&t[0].commands.push({name:"blockquote",label:h.localeActions.t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setBlockquote().run()}}),n.name.toLowerCase()==="codeblock"&&t[0].commands.push({name:"codeBlock",label:h.localeActions.t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setCodeBlock().run()}}),n.name.toLowerCase()===b.Image$1.name&&t[1].commands.push({name:"image",label:h.localeActions.t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),b.actionDialogImage.setOpen(e.id,!0)}}),n.name.toLowerCase()===b.Video.name&&t[1].commands.push({name:"video",label:h.localeActions.t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),j.setOpen(e.id,!0)}}),n.name.toLowerCase()==="table"&&t[1].commands.push({name:"table",label:h.localeActions.t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),n.name.toLowerCase()==="horizontalrule"&&t[1].commands.push({name:"horizontalRule",label:h.localeActions.t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setHorizontalRule().run()}}),n.name.toLowerCase()==="columns"&&t[1].commands.push({name:"columns",label:h.localeActions.t("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),d==null||d(n,t)}),t}const w="slashCommand";let a;const E=A.Extension.create({name:w,priority:200,onCreate(){a=D("body",{interactive:!0,trigger:"manual",placement:"bottom-start",theme:"slash-command",maxWidth:"16rem",offset:[16,8],popperOptions:{strategy:"fixed",modifiers:[{name:"flip",enabled:!1}]}})},addProseMirrorPlugins(){return[q.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new A.PluginKey(w),allow:({state:i,range:d})=>{var g,C,R;const t=i.doc.resolve(d.from),n=t.depth===1,e=t.parent.type.name==="paragraph",o=((g=t.parent.textContent)==null?void 0:g.charAt(0))==="/",r=this.editor.isActive("column"),s=(R=t.parent.textContent)==null?void 0:R.slice(Math.max(0,(C=t.parent.textContent)==null?void 0:C.indexOf("/"))),u=!(s!=null&&s.endsWith(" "));return(n&&e&&o||r&&e&&o)&&u},command:({editor:i,range:d,props:t})=>{const{view:n}=i;t.action({editor:i,range:d}),n.focus()},items:({query:i,editor:d})=>B(d.extensionManager.extensions,this.options.renderGroupItem).map(r=>({...r,commands:r.commands.filter(s=>{const u=s.label.toLowerCase().trim(),g=i.toLowerCase().trim();if(s.aliases){const C=s.aliases.map(v=>v.toLowerCase().trim()),R=u.match(g),L=C.some(v=>v.match(g));return R||L}return u.match(g)}).filter(s=>s.shouldBeHidden?!s.shouldBeHidden(this.editor):!0)})).filter(r=>r.commands.length>0).map(r=>({...r,commands:r.commands.map(s=>({...s,isEnabled:!0}))})),render:()=>{let i,d=null;return{onStart:t=>{var o;i=new O.ReactRenderer($,{props:t,editor:t.editor});const{view:n}=t.editor,e=()=>{if(!t.clientRect)return t.editor.storage[w].rect;const r=t.clientRect();if(!r)return t.editor.storage[w].rect;let s=r.y;if(r.top+i.element.offsetHeight+40>window.innerHeight){const u=r.top+i.element.offsetHeight-window.innerHeight+40;s=r.y-u}return new DOMRect(r.x,s,r.width,r.height)};d=()=>{a==null||a[0].setProps({getReferenceClientRect:e})},(o=n.dom.parentElement)==null||o.addEventListener("scroll",d),a==null||a[0].setProps({getReferenceClientRect:e,appendTo:()=>document.body,content:i.element}),a==null||a[0].show()},onUpdate(t){var r;i.updateProps(t);const{view:n}=t.editor,e=()=>{if(!t.clientRect)return t.editor.storage[w].rect;const s=t.clientRect();return s?new DOMRect(s.x,s.y,s.width,s.height):t.editor.storage[w].rect},o=()=>{a==null||a[0].setProps({getReferenceClientRect:e})};(r=n.dom.parentElement)==null||r.addEventListener("scroll",o),t.editor.storage[w].rect=t.clientRect?e():{width:0,height:0,left:0,top:0,right:0,bottom:0},a==null||a[0].setProps({getReferenceClientRect:e})},onKeyDown(t){var n;return t.event.key==="Escape"?(a==null||a[0].hide(),!0):(a!=null&&a[0].state.isShown||a==null||a[0].show(),(n=i.ref)==null?void 0:n.onKeyDown(t))},onExit(t){var n;if(a==null||a[0].hide(),d){const{view:e}=t.editor;(n=e.dom.parentElement)==null||n.removeEventListener("scroll",d)}i.destroy()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}});exports.SlashCommand=E;exports.default=E;
|
package/lib/SlashCommand.d.cts
CHANGED
|
@@ -88,8 +88,8 @@ declare module '@tiptap/core' {
|
|
|
88
88
|
|
|
89
89
|
declare module '@tiptap/core' {
|
|
90
90
|
interface Commands<ReturnType> {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
excalidraw: {
|
|
92
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -97,8 +97,8 @@ declare module '@tiptap/core' {
|
|
|
97
97
|
|
|
98
98
|
declare module '@tiptap/core' {
|
|
99
99
|
interface Commands<ReturnType> {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
exportPdf: {
|
|
101
|
+
exportToPdf: () => ReturnType;
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
}
|
package/lib/SlashCommand.d.ts
CHANGED
|
@@ -88,8 +88,8 @@ declare module '@tiptap/core' {
|
|
|
88
88
|
|
|
89
89
|
declare module '@tiptap/core' {
|
|
90
90
|
interface Commands<ReturnType> {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
excalidraw: {
|
|
92
|
+
setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -97,8 +97,8 @@ declare module '@tiptap/core' {
|
|
|
97
97
|
|
|
98
98
|
declare module '@tiptap/core' {
|
|
99
99
|
interface Commands<ReturnType> {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
exportPdf: {
|
|
101
|
+
exportToPdf: () => ReturnType;
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
}
|