@underverse-ui/underverse 0.2.79 → 0.2.81
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/dist/index.cjs +508 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +498 -216
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15132,7 +15132,7 @@ function useSmartLocale() {
|
|
|
15132
15132
|
}
|
|
15133
15133
|
|
|
15134
15134
|
// ../../components/ui/UEditor/UEditor.tsx
|
|
15135
|
-
import { useEffect as
|
|
15135
|
+
import { useEffect as useEffect28, useMemo as useMemo16 } from "react";
|
|
15136
15136
|
import { useTranslations as useTranslations7 } from "next-intl";
|
|
15137
15137
|
import { useEditor, EditorContent } from "@tiptap/react";
|
|
15138
15138
|
|
|
@@ -15156,7 +15156,6 @@ import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
|
15156
15156
|
import History2 from "@tiptap/extension-history";
|
|
15157
15157
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
15158
15158
|
import Link3 from "@tiptap/extension-link";
|
|
15159
|
-
import Image3 from "@tiptap/extension-image";
|
|
15160
15159
|
import { TextStyle } from "@tiptap/extension-text-style";
|
|
15161
15160
|
import Color from "@tiptap/extension-color";
|
|
15162
15161
|
import Highlight from "@tiptap/extension-highlight";
|
|
@@ -18462,6 +18461,7 @@ function createKey(name) {
|
|
|
18462
18461
|
// ../../components/ui/UEditor/clipboard-images.ts
|
|
18463
18462
|
function getImageFiles(dataTransfer) {
|
|
18464
18463
|
if (!dataTransfer) return [];
|
|
18464
|
+
const itemFiles = [];
|
|
18465
18465
|
const byKey = /* @__PURE__ */ new Map();
|
|
18466
18466
|
for (const item of Array.from(dataTransfer.items ?? [])) {
|
|
18467
18467
|
if (item.kind !== "file") continue;
|
|
@@ -18470,6 +18470,8 @@ function getImageFiles(dataTransfer) {
|
|
|
18470
18470
|
if (!file) continue;
|
|
18471
18471
|
byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
|
|
18472
18472
|
}
|
|
18473
|
+
itemFiles.push(...Array.from(byKey.values()));
|
|
18474
|
+
if (itemFiles.length > 0) return itemFiles;
|
|
18473
18475
|
for (const file of Array.from(dataTransfer.files ?? [])) {
|
|
18474
18476
|
if (!file.type.startsWith("image/")) continue;
|
|
18475
18477
|
byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
|
|
@@ -18549,13 +18551,229 @@ var ClipboardImages = Extension2.create({
|
|
|
18549
18551
|
}
|
|
18550
18552
|
});
|
|
18551
18553
|
|
|
18554
|
+
// ../../components/ui/UEditor/resizable-image.tsx
|
|
18555
|
+
import { useEffect as useEffect25, useRef as useRef22, useState as useState43 } from "react";
|
|
18556
|
+
import Image3 from "@tiptap/extension-image";
|
|
18557
|
+
import { mergeAttributes } from "@tiptap/core";
|
|
18558
|
+
import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";
|
|
18559
|
+
import { jsx as jsx69, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
18560
|
+
var MIN_IMAGE_SIZE_PX = 40;
|
|
18561
|
+
var AXIS_LOCK_THRESHOLD_PX = 4;
|
|
18562
|
+
function toNullableNumber(value) {
|
|
18563
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
18564
|
+
if (typeof value === "string") {
|
|
18565
|
+
const parsed = Number.parseInt(value, 10);
|
|
18566
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
18567
|
+
}
|
|
18568
|
+
return null;
|
|
18569
|
+
}
|
|
18570
|
+
function clamp4(value, min, max) {
|
|
18571
|
+
return Math.min(max, Math.max(min, value));
|
|
18572
|
+
}
|
|
18573
|
+
function ResizableImageNodeView(props) {
|
|
18574
|
+
const { node, selected, updateAttributes, editor, getPos } = props;
|
|
18575
|
+
const wrapperRef = useRef22(null);
|
|
18576
|
+
const imgRef = useRef22(null);
|
|
18577
|
+
const [isHovered, setIsHovered] = useState43(false);
|
|
18578
|
+
const [isResizing, setIsResizing] = useState43(false);
|
|
18579
|
+
const widthAttr = toNullableNumber(node.attrs["width"]);
|
|
18580
|
+
const heightAttr = toNullableNumber(node.attrs["height"]);
|
|
18581
|
+
const textAlign = String(node.attrs["textAlign"] ?? "");
|
|
18582
|
+
const dragStateRef = useRef22(null);
|
|
18583
|
+
useEffect25(() => {
|
|
18584
|
+
const img = imgRef.current;
|
|
18585
|
+
if (!img) return;
|
|
18586
|
+
img.style.width = widthAttr ? `${widthAttr}px` : "";
|
|
18587
|
+
img.style.height = heightAttr ? `${heightAttr}px` : "";
|
|
18588
|
+
}, [widthAttr, heightAttr]);
|
|
18589
|
+
const selectNode = () => {
|
|
18590
|
+
const pos = typeof getPos === "function" ? getPos() : null;
|
|
18591
|
+
if (typeof pos === "number") editor.commands.setNodeSelection(pos);
|
|
18592
|
+
};
|
|
18593
|
+
const onResizePointerDown = (event) => {
|
|
18594
|
+
event.preventDefault();
|
|
18595
|
+
event.stopPropagation();
|
|
18596
|
+
const img = imgRef.current;
|
|
18597
|
+
const wrapper = wrapperRef.current;
|
|
18598
|
+
if (!img || !wrapper) return;
|
|
18599
|
+
selectNode();
|
|
18600
|
+
const rect = img.getBoundingClientRect();
|
|
18601
|
+
const editorEl = wrapper.closest(".ProseMirror");
|
|
18602
|
+
const maxW = editorEl ? editorEl.getBoundingClientRect().width : Number.POSITIVE_INFINITY;
|
|
18603
|
+
const startW = Math.max(MIN_IMAGE_SIZE_PX, rect.width);
|
|
18604
|
+
const startH = Math.max(MIN_IMAGE_SIZE_PX, rect.height);
|
|
18605
|
+
const aspect = startH > 0 ? startW / startH : 1;
|
|
18606
|
+
dragStateRef.current = {
|
|
18607
|
+
pointerId: event.pointerId,
|
|
18608
|
+
startX: event.clientX,
|
|
18609
|
+
startY: event.clientY,
|
|
18610
|
+
startW,
|
|
18611
|
+
startH,
|
|
18612
|
+
lastW: startW,
|
|
18613
|
+
lastH: startH,
|
|
18614
|
+
axis: null,
|
|
18615
|
+
aspect,
|
|
18616
|
+
maxW: Math.max(MIN_IMAGE_SIZE_PX, maxW)
|
|
18617
|
+
};
|
|
18618
|
+
setIsResizing(true);
|
|
18619
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
18620
|
+
};
|
|
18621
|
+
const onResizePointerMove = (event) => {
|
|
18622
|
+
const drag = dragStateRef.current;
|
|
18623
|
+
const img = imgRef.current;
|
|
18624
|
+
if (!drag || !img) return;
|
|
18625
|
+
if (event.pointerId !== drag.pointerId) return;
|
|
18626
|
+
const dx = event.clientX - drag.startX;
|
|
18627
|
+
const dy = event.clientY - drag.startY;
|
|
18628
|
+
let nextW = drag.startW;
|
|
18629
|
+
let nextH = drag.startH;
|
|
18630
|
+
if (event.ctrlKey) {
|
|
18631
|
+
if (Math.abs(dx) >= Math.abs(dy)) {
|
|
18632
|
+
nextW = clamp4(drag.startW + dx, MIN_IMAGE_SIZE_PX, drag.maxW);
|
|
18633
|
+
nextH = clamp4(nextW / drag.aspect, MIN_IMAGE_SIZE_PX, Number.POSITIVE_INFINITY);
|
|
18634
|
+
} else {
|
|
18635
|
+
nextH = clamp4(drag.startH + dy, MIN_IMAGE_SIZE_PX, Number.POSITIVE_INFINITY);
|
|
18636
|
+
nextW = clamp4(nextH * drag.aspect, MIN_IMAGE_SIZE_PX, drag.maxW);
|
|
18637
|
+
}
|
|
18638
|
+
} else {
|
|
18639
|
+
if (!drag.axis && (Math.abs(dx) > AXIS_LOCK_THRESHOLD_PX || Math.abs(dy) > AXIS_LOCK_THRESHOLD_PX)) {
|
|
18640
|
+
drag.axis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
|
|
18641
|
+
}
|
|
18642
|
+
if (drag.axis === "x") nextW = clamp4(drag.startW + dx, MIN_IMAGE_SIZE_PX, drag.maxW);
|
|
18643
|
+
if (drag.axis === "y") nextH = clamp4(drag.startH + dy, MIN_IMAGE_SIZE_PX, Number.POSITIVE_INFINITY);
|
|
18644
|
+
}
|
|
18645
|
+
drag.lastW = nextW;
|
|
18646
|
+
drag.lastH = nextH;
|
|
18647
|
+
img.style.width = `${Math.round(nextW)}px`;
|
|
18648
|
+
img.style.height = `${Math.round(nextH)}px`;
|
|
18649
|
+
};
|
|
18650
|
+
const finishResize = () => {
|
|
18651
|
+
const drag = dragStateRef.current;
|
|
18652
|
+
dragStateRef.current = null;
|
|
18653
|
+
setIsResizing(false);
|
|
18654
|
+
if (!drag) return;
|
|
18655
|
+
updateAttributes({
|
|
18656
|
+
width: Math.round(drag.lastW),
|
|
18657
|
+
height: Math.round(drag.lastH)
|
|
18658
|
+
});
|
|
18659
|
+
};
|
|
18660
|
+
const onResizePointerUp = (event) => {
|
|
18661
|
+
const drag = dragStateRef.current;
|
|
18662
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
18663
|
+
event.preventDefault();
|
|
18664
|
+
event.stopPropagation();
|
|
18665
|
+
finishResize();
|
|
18666
|
+
};
|
|
18667
|
+
const onResizePointerCancel = (event) => {
|
|
18668
|
+
const drag = dragStateRef.current;
|
|
18669
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
18670
|
+
event.preventDefault();
|
|
18671
|
+
event.stopPropagation();
|
|
18672
|
+
finishResize();
|
|
18673
|
+
};
|
|
18674
|
+
const showHandle = selected || isHovered || isResizing;
|
|
18675
|
+
const wrapperAlignClass = textAlign === "center" ? "mx-auto" : textAlign === "right" ? "ml-auto" : textAlign === "justify" ? "mx-auto" : "";
|
|
18676
|
+
const wrapperWidthClass = "w-fit";
|
|
18677
|
+
return /* @__PURE__ */ jsxs61(
|
|
18678
|
+
NodeViewWrapper,
|
|
18679
|
+
{
|
|
18680
|
+
as: "div",
|
|
18681
|
+
ref: wrapperRef,
|
|
18682
|
+
className: ["relative block align-middle max-w-full my-4", wrapperWidthClass, wrapperAlignClass].filter(Boolean).join(" "),
|
|
18683
|
+
onMouseEnter: () => setIsHovered(true),
|
|
18684
|
+
onMouseLeave: () => setIsHovered(false),
|
|
18685
|
+
onClick: (e) => {
|
|
18686
|
+
e.stopPropagation();
|
|
18687
|
+
selectNode();
|
|
18688
|
+
},
|
|
18689
|
+
contentEditable: false,
|
|
18690
|
+
children: [
|
|
18691
|
+
/* @__PURE__ */ jsx69(
|
|
18692
|
+
"img",
|
|
18693
|
+
{
|
|
18694
|
+
ref: imgRef,
|
|
18695
|
+
src: String(node.attrs["src"] ?? ""),
|
|
18696
|
+
alt: String(node.attrs["alt"] ?? ""),
|
|
18697
|
+
title: String(node.attrs["title"] ?? ""),
|
|
18698
|
+
draggable: "true",
|
|
18699
|
+
className: [
|
|
18700
|
+
"block rounded-lg max-w-full",
|
|
18701
|
+
selected ? "ring-2 ring-primary/60 ring-offset-2 ring-offset-background" : "",
|
|
18702
|
+
isResizing ? "select-none" : ""
|
|
18703
|
+
].join(" "),
|
|
18704
|
+
style: {
|
|
18705
|
+
width: widthAttr ? `${widthAttr}px` : void 0,
|
|
18706
|
+
height: heightAttr ? `${heightAttr}px` : void 0
|
|
18707
|
+
}
|
|
18708
|
+
}
|
|
18709
|
+
),
|
|
18710
|
+
showHandle && /* @__PURE__ */ jsx69(
|
|
18711
|
+
"div",
|
|
18712
|
+
{
|
|
18713
|
+
"aria-hidden": "true",
|
|
18714
|
+
onPointerDown: onResizePointerDown,
|
|
18715
|
+
onPointerMove: onResizePointerMove,
|
|
18716
|
+
onPointerUp: onResizePointerUp,
|
|
18717
|
+
onPointerCancel: onResizePointerCancel,
|
|
18718
|
+
className: [
|
|
18719
|
+
"absolute -right-1 -bottom-1 h-3 w-3 rounded-sm",
|
|
18720
|
+
"bg-primary border border-background shadow-sm",
|
|
18721
|
+
"cursor-nwse-resize",
|
|
18722
|
+
"opacity-90 hover:opacity-100"
|
|
18723
|
+
].join(" ")
|
|
18724
|
+
}
|
|
18725
|
+
)
|
|
18726
|
+
]
|
|
18727
|
+
}
|
|
18728
|
+
);
|
|
18729
|
+
}
|
|
18730
|
+
var ResizableImage = Image3.extend({
|
|
18731
|
+
addAttributes() {
|
|
18732
|
+
const parentAttrs = this.parent?.() ?? {};
|
|
18733
|
+
return {
|
|
18734
|
+
...parentAttrs,
|
|
18735
|
+
width: {
|
|
18736
|
+
default: null,
|
|
18737
|
+
parseHTML: (element) => {
|
|
18738
|
+
const raw = element.getAttribute("width") || element.style.width || "";
|
|
18739
|
+
const parsed = Number.parseInt(raw, 10);
|
|
18740
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
18741
|
+
},
|
|
18742
|
+
renderHTML: (attrs) => typeof attrs.width === "number" ? { width: attrs.width } : {}
|
|
18743
|
+
},
|
|
18744
|
+
height: {
|
|
18745
|
+
default: null,
|
|
18746
|
+
parseHTML: (element) => {
|
|
18747
|
+
const raw = element.getAttribute("height") || element.style.height || "";
|
|
18748
|
+
const parsed = Number.parseInt(raw, 10);
|
|
18749
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
18750
|
+
},
|
|
18751
|
+
renderHTML: (attrs) => typeof attrs.height === "number" ? { height: attrs.height } : {}
|
|
18752
|
+
}
|
|
18753
|
+
};
|
|
18754
|
+
},
|
|
18755
|
+
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
18756
|
+
return ["img", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes2)];
|
|
18757
|
+
},
|
|
18758
|
+
addNodeView() {
|
|
18759
|
+
return ReactNodeViewRenderer(ResizableImageNodeView);
|
|
18760
|
+
}
|
|
18761
|
+
}).configure({
|
|
18762
|
+
allowBase64: true,
|
|
18763
|
+
HTMLAttributes: {
|
|
18764
|
+
class: "rounded-lg max-w-full my-4"
|
|
18765
|
+
}
|
|
18766
|
+
});
|
|
18767
|
+
var resizable_image_default = ResizableImage;
|
|
18768
|
+
|
|
18552
18769
|
// ../../components/ui/UEditor/extensions.ts
|
|
18553
18770
|
var lowlight = createLowlight(common);
|
|
18554
18771
|
function buildUEditorExtensions({
|
|
18555
18772
|
placeholder,
|
|
18556
18773
|
maxCharacters,
|
|
18557
18774
|
uploadImage,
|
|
18558
|
-
imageInsertMode = "base64"
|
|
18775
|
+
imageInsertMode = "base64",
|
|
18776
|
+
editable = true
|
|
18559
18777
|
}) {
|
|
18560
18778
|
return [
|
|
18561
18779
|
Document,
|
|
@@ -18612,12 +18830,7 @@ function buildUEditorExtensions({
|
|
|
18612
18830
|
class: "text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer"
|
|
18613
18831
|
}
|
|
18614
18832
|
}),
|
|
18615
|
-
|
|
18616
|
-
allowBase64: true,
|
|
18617
|
-
HTMLAttributes: {
|
|
18618
|
-
class: "rounded-lg max-w-full h-auto my-4"
|
|
18619
|
-
}
|
|
18620
|
-
}),
|
|
18833
|
+
resizable_image_default,
|
|
18621
18834
|
ClipboardImages.configure({ upload: uploadImage, insertMode: imageInsertMode }),
|
|
18622
18835
|
TextStyle,
|
|
18623
18836
|
Color,
|
|
@@ -18625,7 +18838,7 @@ function buildUEditorExtensions({
|
|
|
18625
18838
|
multicolor: true
|
|
18626
18839
|
}),
|
|
18627
18840
|
TextAlign.configure({
|
|
18628
|
-
types: ["heading", "paragraph"]
|
|
18841
|
+
types: ["heading", "paragraph", "image"]
|
|
18629
18842
|
}),
|
|
18630
18843
|
Table3.configure({
|
|
18631
18844
|
resizable: true,
|
|
@@ -18659,7 +18872,7 @@ function buildUEditorExtensions({
|
|
|
18659
18872
|
}
|
|
18660
18873
|
|
|
18661
18874
|
// ../../components/ui/UEditor/toolbar.tsx
|
|
18662
|
-
import
|
|
18875
|
+
import React60, { useRef as useRef24, useState as useState45 } from "react";
|
|
18663
18876
|
import { useTranslations as useTranslations4 } from "next-intl";
|
|
18664
18877
|
import {
|
|
18665
18878
|
AlignCenter,
|
|
@@ -18700,7 +18913,7 @@ import {
|
|
|
18700
18913
|
import { useMemo as useMemo14 } from "react";
|
|
18701
18914
|
import { useTranslations as useTranslations2 } from "next-intl";
|
|
18702
18915
|
import { X as X14 } from "lucide-react";
|
|
18703
|
-
import { jsx as
|
|
18916
|
+
import { jsx as jsx70, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
18704
18917
|
var useEditorColors = () => {
|
|
18705
18918
|
const t = useTranslations2("UEditor");
|
|
18706
18919
|
const textColors = useMemo14(
|
|
@@ -18737,9 +18950,9 @@ var EditorColorPalette = ({
|
|
|
18737
18950
|
currentColor,
|
|
18738
18951
|
onSelect,
|
|
18739
18952
|
label
|
|
18740
|
-
}) => /* @__PURE__ */
|
|
18741
|
-
/* @__PURE__ */
|
|
18742
|
-
/* @__PURE__ */
|
|
18953
|
+
}) => /* @__PURE__ */ jsxs62("div", { className: "p-2", children: [
|
|
18954
|
+
/* @__PURE__ */ jsx70("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wider px-2", children: label }),
|
|
18955
|
+
/* @__PURE__ */ jsx70("div", { className: "grid grid-cols-4 gap-1.5 mt-2", children: colors.map((c) => /* @__PURE__ */ jsxs62(
|
|
18743
18956
|
"button",
|
|
18744
18957
|
{
|
|
18745
18958
|
type: "button",
|
|
@@ -18752,8 +18965,8 @@ var EditorColorPalette = ({
|
|
|
18752
18965
|
style: { backgroundColor: c.color || "transparent" },
|
|
18753
18966
|
title: c.name,
|
|
18754
18967
|
children: [
|
|
18755
|
-
c.color === "" && /* @__PURE__ */
|
|
18756
|
-
c.color === "inherit" && /* @__PURE__ */
|
|
18968
|
+
c.color === "" && /* @__PURE__ */ jsx70(X14, { className: "w-4 h-4 text-muted-foreground" }),
|
|
18969
|
+
c.color === "inherit" && /* @__PURE__ */ jsx70("span", { className: "text-xs font-medium", children: "A" })
|
|
18757
18970
|
]
|
|
18758
18971
|
},
|
|
18759
18972
|
c.name
|
|
@@ -18761,30 +18974,36 @@ var EditorColorPalette = ({
|
|
|
18761
18974
|
] });
|
|
18762
18975
|
|
|
18763
18976
|
// ../../components/ui/UEditor/inputs.tsx
|
|
18764
|
-
import { useEffect as
|
|
18977
|
+
import { useEffect as useEffect26, useRef as useRef23, useState as useState44 } from "react";
|
|
18765
18978
|
import { useTranslations as useTranslations3 } from "next-intl";
|
|
18766
18979
|
import { Check as Check9, X as X15 } from "lucide-react";
|
|
18767
|
-
import { jsx as
|
|
18980
|
+
import { jsx as jsx71, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
18981
|
+
function normalizeUrl(raw) {
|
|
18982
|
+
const url = raw.trim();
|
|
18983
|
+
if (!url) return "";
|
|
18984
|
+
if (url.startsWith("#") || url.startsWith("/")) return url;
|
|
18985
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(url)) return url;
|
|
18986
|
+
return `https://${url}`;
|
|
18987
|
+
}
|
|
18768
18988
|
var LinkInput = ({
|
|
18769
18989
|
onSubmit,
|
|
18770
18990
|
onCancel,
|
|
18771
18991
|
initialUrl = ""
|
|
18772
18992
|
}) => {
|
|
18773
18993
|
const t = useTranslations3("UEditor");
|
|
18774
|
-
const [url, setUrl] =
|
|
18775
|
-
const inputRef =
|
|
18776
|
-
|
|
18994
|
+
const [url, setUrl] = useState44(initialUrl);
|
|
18995
|
+
const inputRef = useRef23(null);
|
|
18996
|
+
useEffect26(() => {
|
|
18777
18997
|
inputRef.current?.focus();
|
|
18778
18998
|
inputRef.current?.select();
|
|
18779
18999
|
}, []);
|
|
18780
19000
|
const handleSubmit = (e) => {
|
|
18781
19001
|
e.preventDefault();
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
}
|
|
19002
|
+
const normalized = normalizeUrl(url);
|
|
19003
|
+
if (normalized) onSubmit(normalized);
|
|
18785
19004
|
};
|
|
18786
|
-
return /* @__PURE__ */
|
|
18787
|
-
/* @__PURE__ */
|
|
19005
|
+
return /* @__PURE__ */ jsxs63("form", { onSubmit: handleSubmit, className: "flex items-center gap-2 p-2", children: [
|
|
19006
|
+
/* @__PURE__ */ jsx71(
|
|
18788
19007
|
"input",
|
|
18789
19008
|
{
|
|
18790
19009
|
ref: inputRef,
|
|
@@ -18795,16 +19014,16 @@ var LinkInput = ({
|
|
|
18795
19014
|
className: "flex-1 px-3 py-2 text-sm bg-muted/50 border-0 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
18796
19015
|
}
|
|
18797
19016
|
),
|
|
18798
|
-
/* @__PURE__ */
|
|
18799
|
-
/* @__PURE__ */
|
|
19017
|
+
/* @__PURE__ */ jsx71("button", { type: "submit", className: "p-2 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors", children: /* @__PURE__ */ jsx71(Check9, { className: "w-4 h-4" }) }),
|
|
19018
|
+
/* @__PURE__ */ jsx71("button", { type: "button", onClick: onCancel, className: "p-2 rounded-lg hover:bg-muted transition-colors text-muted-foreground", children: /* @__PURE__ */ jsx71(X15, { className: "w-4 h-4" }) })
|
|
18800
19019
|
] });
|
|
18801
19020
|
};
|
|
18802
19021
|
var ImageInput = ({ onSubmit, onCancel }) => {
|
|
18803
19022
|
const t = useTranslations3("UEditor");
|
|
18804
|
-
const [url, setUrl] =
|
|
18805
|
-
const [alt, setAlt] =
|
|
18806
|
-
const inputRef =
|
|
18807
|
-
|
|
19023
|
+
const [url, setUrl] = useState44("");
|
|
19024
|
+
const [alt, setAlt] = useState44("");
|
|
19025
|
+
const inputRef = useRef23(null);
|
|
19026
|
+
useEffect26(() => {
|
|
18808
19027
|
inputRef.current?.focus();
|
|
18809
19028
|
}, []);
|
|
18810
19029
|
const handleSubmit = (e) => {
|
|
@@ -18813,10 +19032,10 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
18813
19032
|
onSubmit(url, alt);
|
|
18814
19033
|
}
|
|
18815
19034
|
};
|
|
18816
|
-
return /* @__PURE__ */
|
|
18817
|
-
/* @__PURE__ */
|
|
18818
|
-
/* @__PURE__ */
|
|
18819
|
-
/* @__PURE__ */
|
|
19035
|
+
return /* @__PURE__ */ jsxs63("form", { onSubmit: handleSubmit, className: "p-3 space-y-3", children: [
|
|
19036
|
+
/* @__PURE__ */ jsxs63("div", { children: [
|
|
19037
|
+
/* @__PURE__ */ jsx71("label", { className: "text-xs font-medium text-muted-foreground", children: t("imageInput.urlLabel") }),
|
|
19038
|
+
/* @__PURE__ */ jsx71(
|
|
18820
19039
|
"input",
|
|
18821
19040
|
{
|
|
18822
19041
|
ref: inputRef,
|
|
@@ -18828,9 +19047,9 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
18828
19047
|
}
|
|
18829
19048
|
)
|
|
18830
19049
|
] }),
|
|
18831
|
-
/* @__PURE__ */
|
|
18832
|
-
/* @__PURE__ */
|
|
18833
|
-
/* @__PURE__ */
|
|
19050
|
+
/* @__PURE__ */ jsxs63("div", { children: [
|
|
19051
|
+
/* @__PURE__ */ jsx71("label", { className: "text-xs font-medium text-muted-foreground", children: t("imageInput.altLabel") }),
|
|
19052
|
+
/* @__PURE__ */ jsx71(
|
|
18834
19053
|
"input",
|
|
18835
19054
|
{
|
|
18836
19055
|
type: "text",
|
|
@@ -18841,8 +19060,8 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
18841
19060
|
}
|
|
18842
19061
|
)
|
|
18843
19062
|
] }),
|
|
18844
|
-
/* @__PURE__ */
|
|
18845
|
-
/* @__PURE__ */
|
|
19063
|
+
/* @__PURE__ */ jsxs63("div", { className: "flex gap-2", children: [
|
|
19064
|
+
/* @__PURE__ */ jsx71(
|
|
18846
19065
|
"button",
|
|
18847
19066
|
{
|
|
18848
19067
|
type: "submit",
|
|
@@ -18851,13 +19070,13 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
18851
19070
|
children: t("imageInput.addBtn")
|
|
18852
19071
|
}
|
|
18853
19072
|
),
|
|
18854
|
-
/* @__PURE__ */
|
|
19073
|
+
/* @__PURE__ */ jsx71("button", { type: "button", onClick: onCancel, className: "px-4 py-2 rounded-lg hover:bg-muted transition-colors text-muted-foreground", children: t("imageInput.cancelBtn") })
|
|
18855
19074
|
] })
|
|
18856
19075
|
] });
|
|
18857
19076
|
};
|
|
18858
19077
|
|
|
18859
19078
|
// ../../components/ui/UEditor/toolbar.tsx
|
|
18860
|
-
import { Fragment as Fragment26, jsx as
|
|
19079
|
+
import { Fragment as Fragment26, jsx as jsx72, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
18861
19080
|
function fileToDataUrl2(file) {
|
|
18862
19081
|
return new Promise((resolve, reject) => {
|
|
18863
19082
|
const reader = new FileReader();
|
|
@@ -18866,13 +19085,16 @@ function fileToDataUrl2(file) {
|
|
|
18866
19085
|
reader.readAsDataURL(file);
|
|
18867
19086
|
});
|
|
18868
19087
|
}
|
|
18869
|
-
var ToolbarButton =
|
|
18870
|
-
const button = /* @__PURE__ */
|
|
19088
|
+
var ToolbarButton = React60.forwardRef(({ onClick, onMouseDown, active, disabled, children, title, className }, ref) => {
|
|
19089
|
+
const button = /* @__PURE__ */ jsx72(
|
|
18871
19090
|
"button",
|
|
18872
19091
|
{
|
|
18873
19092
|
ref,
|
|
18874
19093
|
type: "button",
|
|
18875
|
-
onMouseDown: (e) =>
|
|
19094
|
+
onMouseDown: (e) => {
|
|
19095
|
+
onMouseDown?.(e);
|
|
19096
|
+
e.preventDefault();
|
|
19097
|
+
},
|
|
18876
19098
|
onClick,
|
|
18877
19099
|
disabled,
|
|
18878
19100
|
className: cn(
|
|
@@ -18887,12 +19109,12 @@ var ToolbarButton = React59.forwardRef(({ onClick, active, disabled, children, t
|
|
|
18887
19109
|
}
|
|
18888
19110
|
);
|
|
18889
19111
|
if (title) {
|
|
18890
|
-
return /* @__PURE__ */
|
|
19112
|
+
return /* @__PURE__ */ jsx72(Tooltip, { content: title, placement: "top", delay: { open: 500, close: 0 }, children: button });
|
|
18891
19113
|
}
|
|
18892
19114
|
return button;
|
|
18893
19115
|
});
|
|
18894
19116
|
ToolbarButton.displayName = "ToolbarButton";
|
|
18895
|
-
var ToolbarDivider = () => /* @__PURE__ */
|
|
19117
|
+
var ToolbarDivider = () => /* @__PURE__ */ jsx72("div", { className: "w-px h-6 bg-border/50 mx-1" });
|
|
18896
19118
|
var EditorToolbar = ({
|
|
18897
19119
|
editor,
|
|
18898
19120
|
variant,
|
|
@@ -18901,10 +19123,10 @@ var EditorToolbar = ({
|
|
|
18901
19123
|
}) => {
|
|
18902
19124
|
const t = useTranslations4("UEditor");
|
|
18903
19125
|
const { textColors, highlightColors } = useEditorColors();
|
|
18904
|
-
const [showImageInput, setShowImageInput] =
|
|
18905
|
-
const fileInputRef =
|
|
18906
|
-
const [isUploadingImage, setIsUploadingImage] =
|
|
18907
|
-
const [imageUploadError, setImageUploadError] =
|
|
19126
|
+
const [showImageInput, setShowImageInput] = useState45(false);
|
|
19127
|
+
const fileInputRef = useRef24(null);
|
|
19128
|
+
const [isUploadingImage, setIsUploadingImage] = useState45(false);
|
|
19129
|
+
const [imageUploadError, setImageUploadError] = useState45(null);
|
|
18908
19130
|
const insertImageFiles = async (files) => {
|
|
18909
19131
|
if (files.length === 0) return;
|
|
18910
19132
|
setIsUploadingImage(true);
|
|
@@ -18923,40 +19145,40 @@ var EditorToolbar = ({
|
|
|
18923
19145
|
setIsUploadingImage(false);
|
|
18924
19146
|
};
|
|
18925
19147
|
if (variant === "minimal") {
|
|
18926
|
-
return /* @__PURE__ */
|
|
18927
|
-
/* @__PURE__ */
|
|
18928
|
-
/* @__PURE__ */
|
|
19148
|
+
return /* @__PURE__ */ jsxs64("div", { className: "flex items-center gap-1 p-2 border-b bg-muted/30", children: [
|
|
19149
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ jsx72(BoldIcon, { className: "w-4 h-4" }) }),
|
|
19150
|
+
/* @__PURE__ */ jsx72(
|
|
18929
19151
|
ToolbarButton,
|
|
18930
19152
|
{
|
|
18931
19153
|
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
18932
19154
|
active: editor.isActive("italic"),
|
|
18933
19155
|
title: t("toolbar.italic"),
|
|
18934
|
-
children: /* @__PURE__ */
|
|
19156
|
+
children: /* @__PURE__ */ jsx72(ItalicIcon, { className: "w-4 h-4" })
|
|
18935
19157
|
}
|
|
18936
19158
|
),
|
|
18937
|
-
/* @__PURE__ */
|
|
19159
|
+
/* @__PURE__ */ jsx72(
|
|
18938
19160
|
ToolbarButton,
|
|
18939
19161
|
{
|
|
18940
19162
|
onClick: () => editor.chain().focus().toggleBulletList().run(),
|
|
18941
19163
|
active: editor.isActive("bulletList"),
|
|
18942
19164
|
title: t("toolbar.bulletList"),
|
|
18943
|
-
children: /* @__PURE__ */
|
|
19165
|
+
children: /* @__PURE__ */ jsx72(ListIcon, { className: "w-4 h-4" })
|
|
18944
19166
|
}
|
|
18945
19167
|
)
|
|
18946
19168
|
] });
|
|
18947
19169
|
}
|
|
18948
|
-
return /* @__PURE__ */
|
|
18949
|
-
/* @__PURE__ */
|
|
19170
|
+
return /* @__PURE__ */ jsxs64("div", { className: "flex flex-wrap items-center gap-1 p-2 border-b bg-linear-to-r from-muted/30 to-transparent", children: [
|
|
19171
|
+
/* @__PURE__ */ jsxs64(
|
|
18950
19172
|
DropdownMenu,
|
|
18951
19173
|
{
|
|
18952
|
-
trigger: /* @__PURE__ */
|
|
19174
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
18953
19175
|
}, title: t("toolbar.textStyle"), className: "px-2 w-auto gap-1", children: [
|
|
18954
|
-
/* @__PURE__ */
|
|
18955
|
-
/* @__PURE__ */
|
|
19176
|
+
/* @__PURE__ */ jsx72(Type2, { className: "w-4 h-4" }),
|
|
19177
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
18956
19178
|
] }),
|
|
18957
19179
|
children: [
|
|
18958
|
-
/* @__PURE__ */
|
|
18959
|
-
/* @__PURE__ */
|
|
19180
|
+
/* @__PURE__ */ jsx72(DropdownMenuItem, { icon: Type2, label: t("toolbar.normal"), onClick: () => editor.chain().focus().setParagraph().run(), active: editor.isActive("paragraph") }),
|
|
19181
|
+
/* @__PURE__ */ jsx72(
|
|
18960
19182
|
DropdownMenuItem,
|
|
18961
19183
|
{
|
|
18962
19184
|
icon: Heading1Icon,
|
|
@@ -18966,7 +19188,7 @@ var EditorToolbar = ({
|
|
|
18966
19188
|
shortcut: "Ctrl+Alt+1"
|
|
18967
19189
|
}
|
|
18968
19190
|
),
|
|
18969
|
-
/* @__PURE__ */
|
|
19191
|
+
/* @__PURE__ */ jsx72(
|
|
18970
19192
|
DropdownMenuItem,
|
|
18971
19193
|
{
|
|
18972
19194
|
icon: Heading2Icon,
|
|
@@ -18976,7 +19198,7 @@ var EditorToolbar = ({
|
|
|
18976
19198
|
shortcut: "Ctrl+Alt+2"
|
|
18977
19199
|
}
|
|
18978
19200
|
),
|
|
18979
|
-
/* @__PURE__ */
|
|
19201
|
+
/* @__PURE__ */ jsx72(
|
|
18980
19202
|
DropdownMenuItem,
|
|
18981
19203
|
{
|
|
18982
19204
|
icon: Heading3Icon,
|
|
@@ -18989,46 +19211,46 @@ var EditorToolbar = ({
|
|
|
18989
19211
|
]
|
|
18990
19212
|
}
|
|
18991
19213
|
),
|
|
18992
|
-
/* @__PURE__ */
|
|
18993
|
-
/* @__PURE__ */
|
|
18994
|
-
/* @__PURE__ */
|
|
19214
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19215
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ jsx72(BoldIcon, { className: "w-4 h-4" }) }),
|
|
19216
|
+
/* @__PURE__ */ jsx72(
|
|
18995
19217
|
ToolbarButton,
|
|
18996
19218
|
{
|
|
18997
19219
|
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
18998
19220
|
active: editor.isActive("italic"),
|
|
18999
19221
|
title: t("toolbar.italic"),
|
|
19000
|
-
children: /* @__PURE__ */
|
|
19222
|
+
children: /* @__PURE__ */ jsx72(ItalicIcon, { className: "w-4 h-4" })
|
|
19001
19223
|
}
|
|
19002
19224
|
),
|
|
19003
|
-
/* @__PURE__ */
|
|
19225
|
+
/* @__PURE__ */ jsx72(
|
|
19004
19226
|
ToolbarButton,
|
|
19005
19227
|
{
|
|
19006
19228
|
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
19007
19229
|
active: editor.isActive("underline"),
|
|
19008
19230
|
title: t("toolbar.underline"),
|
|
19009
|
-
children: /* @__PURE__ */
|
|
19231
|
+
children: /* @__PURE__ */ jsx72(UnderlineIcon, { className: "w-4 h-4" })
|
|
19010
19232
|
}
|
|
19011
19233
|
),
|
|
19012
|
-
/* @__PURE__ */
|
|
19234
|
+
/* @__PURE__ */ jsx72(
|
|
19013
19235
|
ToolbarButton,
|
|
19014
19236
|
{
|
|
19015
19237
|
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
19016
19238
|
active: editor.isActive("strike"),
|
|
19017
19239
|
title: t("toolbar.strike"),
|
|
19018
|
-
children: /* @__PURE__ */
|
|
19240
|
+
children: /* @__PURE__ */ jsx72(StrikethroughIcon, { className: "w-4 h-4" })
|
|
19019
19241
|
}
|
|
19020
19242
|
),
|
|
19021
|
-
/* @__PURE__ */
|
|
19022
|
-
/* @__PURE__ */
|
|
19023
|
-
/* @__PURE__ */
|
|
19243
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().toggleCode().run(), active: editor.isActive("code"), title: t("toolbar.code"), children: /* @__PURE__ */ jsx72(CodeIcon, { className: "w-4 h-4" }) }),
|
|
19244
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19245
|
+
/* @__PURE__ */ jsx72(
|
|
19024
19246
|
DropdownMenu,
|
|
19025
19247
|
{
|
|
19026
|
-
trigger: /* @__PURE__ */
|
|
19248
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19027
19249
|
}, title: t("colors.textColor"), children: [
|
|
19028
|
-
/* @__PURE__ */
|
|
19029
|
-
/* @__PURE__ */
|
|
19250
|
+
/* @__PURE__ */ jsx72(Palette2, { className: "w-4 h-4" }),
|
|
19251
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19030
19252
|
] }),
|
|
19031
|
-
children: /* @__PURE__ */
|
|
19253
|
+
children: /* @__PURE__ */ jsx72(
|
|
19032
19254
|
EditorColorPalette,
|
|
19033
19255
|
{
|
|
19034
19256
|
colors: textColors,
|
|
@@ -19045,15 +19267,15 @@ var EditorToolbar = ({
|
|
|
19045
19267
|
)
|
|
19046
19268
|
}
|
|
19047
19269
|
),
|
|
19048
|
-
/* @__PURE__ */
|
|
19270
|
+
/* @__PURE__ */ jsx72(
|
|
19049
19271
|
DropdownMenu,
|
|
19050
19272
|
{
|
|
19051
|
-
trigger: /* @__PURE__ */
|
|
19273
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19052
19274
|
}, active: editor.isActive("highlight"), title: t("colors.highlight"), children: [
|
|
19053
|
-
/* @__PURE__ */
|
|
19054
|
-
/* @__PURE__ */
|
|
19275
|
+
/* @__PURE__ */ jsx72(Highlighter, { className: "w-4 h-4" }),
|
|
19276
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19055
19277
|
] }),
|
|
19056
|
-
children: /* @__PURE__ */
|
|
19278
|
+
children: /* @__PURE__ */ jsx72(
|
|
19057
19279
|
EditorColorPalette,
|
|
19058
19280
|
{
|
|
19059
19281
|
colors: highlightColors,
|
|
@@ -19070,17 +19292,17 @@ var EditorToolbar = ({
|
|
|
19070
19292
|
)
|
|
19071
19293
|
}
|
|
19072
19294
|
),
|
|
19073
|
-
/* @__PURE__ */
|
|
19074
|
-
/* @__PURE__ */
|
|
19295
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19296
|
+
/* @__PURE__ */ jsxs64(
|
|
19075
19297
|
DropdownMenu,
|
|
19076
19298
|
{
|
|
19077
|
-
trigger: /* @__PURE__ */
|
|
19299
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19078
19300
|
}, title: t("toolbar.alignment"), children: [
|
|
19079
|
-
/* @__PURE__ */
|
|
19080
|
-
/* @__PURE__ */
|
|
19301
|
+
/* @__PURE__ */ jsx72(AlignLeft, { className: "w-4 h-4" }),
|
|
19302
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19081
19303
|
] }),
|
|
19082
19304
|
children: [
|
|
19083
|
-
/* @__PURE__ */
|
|
19305
|
+
/* @__PURE__ */ jsx72(
|
|
19084
19306
|
DropdownMenuItem,
|
|
19085
19307
|
{
|
|
19086
19308
|
icon: AlignLeft,
|
|
@@ -19089,7 +19311,7 @@ var EditorToolbar = ({
|
|
|
19089
19311
|
active: editor.isActive({ textAlign: "left" })
|
|
19090
19312
|
}
|
|
19091
19313
|
),
|
|
19092
|
-
/* @__PURE__ */
|
|
19314
|
+
/* @__PURE__ */ jsx72(
|
|
19093
19315
|
DropdownMenuItem,
|
|
19094
19316
|
{
|
|
19095
19317
|
icon: AlignCenter,
|
|
@@ -19098,7 +19320,7 @@ var EditorToolbar = ({
|
|
|
19098
19320
|
active: editor.isActive({ textAlign: "center" })
|
|
19099
19321
|
}
|
|
19100
19322
|
),
|
|
19101
|
-
/* @__PURE__ */
|
|
19323
|
+
/* @__PURE__ */ jsx72(
|
|
19102
19324
|
DropdownMenuItem,
|
|
19103
19325
|
{
|
|
19104
19326
|
icon: AlignRight,
|
|
@@ -19107,7 +19329,7 @@ var EditorToolbar = ({
|
|
|
19107
19329
|
active: editor.isActive({ textAlign: "right" })
|
|
19108
19330
|
}
|
|
19109
19331
|
),
|
|
19110
|
-
/* @__PURE__ */
|
|
19332
|
+
/* @__PURE__ */ jsx72(
|
|
19111
19333
|
DropdownMenuItem,
|
|
19112
19334
|
{
|
|
19113
19335
|
icon: AlignJustify,
|
|
@@ -19119,17 +19341,17 @@ var EditorToolbar = ({
|
|
|
19119
19341
|
]
|
|
19120
19342
|
}
|
|
19121
19343
|
),
|
|
19122
|
-
/* @__PURE__ */
|
|
19123
|
-
/* @__PURE__ */
|
|
19344
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19345
|
+
/* @__PURE__ */ jsxs64(
|
|
19124
19346
|
DropdownMenu,
|
|
19125
19347
|
{
|
|
19126
|
-
trigger: /* @__PURE__ */
|
|
19348
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19127
19349
|
}, title: t("toolbar.bulletList"), children: [
|
|
19128
|
-
/* @__PURE__ */
|
|
19129
|
-
/* @__PURE__ */
|
|
19350
|
+
/* @__PURE__ */ jsx72(ListIcon, { className: "w-4 h-4" }),
|
|
19351
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19130
19352
|
] }),
|
|
19131
19353
|
children: [
|
|
19132
|
-
/* @__PURE__ */
|
|
19354
|
+
/* @__PURE__ */ jsx72(
|
|
19133
19355
|
DropdownMenuItem,
|
|
19134
19356
|
{
|
|
19135
19357
|
icon: ListIcon,
|
|
@@ -19139,7 +19361,7 @@ var EditorToolbar = ({
|
|
|
19139
19361
|
shortcut: "Ctrl+Shift+8"
|
|
19140
19362
|
}
|
|
19141
19363
|
),
|
|
19142
|
-
/* @__PURE__ */
|
|
19364
|
+
/* @__PURE__ */ jsx72(
|
|
19143
19365
|
DropdownMenuItem,
|
|
19144
19366
|
{
|
|
19145
19367
|
icon: ListOrderedIcon,
|
|
@@ -19149,7 +19371,7 @@ var EditorToolbar = ({
|
|
|
19149
19371
|
shortcut: "Ctrl+Shift+7"
|
|
19150
19372
|
}
|
|
19151
19373
|
),
|
|
19152
|
-
/* @__PURE__ */
|
|
19374
|
+
/* @__PURE__ */ jsx72(
|
|
19153
19375
|
DropdownMenuItem,
|
|
19154
19376
|
{
|
|
19155
19377
|
icon: ListTodo2,
|
|
@@ -19162,16 +19384,16 @@ var EditorToolbar = ({
|
|
|
19162
19384
|
]
|
|
19163
19385
|
}
|
|
19164
19386
|
),
|
|
19165
|
-
/* @__PURE__ */
|
|
19387
|
+
/* @__PURE__ */ jsxs64(
|
|
19166
19388
|
DropdownMenu,
|
|
19167
19389
|
{
|
|
19168
|
-
trigger: /* @__PURE__ */
|
|
19390
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19169
19391
|
}, title: t("toolbar.quote"), children: [
|
|
19170
|
-
/* @__PURE__ */
|
|
19171
|
-
/* @__PURE__ */
|
|
19392
|
+
/* @__PURE__ */ jsx72(QuoteIcon, { className: "w-4 h-4" }),
|
|
19393
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19172
19394
|
] }),
|
|
19173
19395
|
children: [
|
|
19174
|
-
/* @__PURE__ */
|
|
19396
|
+
/* @__PURE__ */ jsx72(
|
|
19175
19397
|
DropdownMenuItem,
|
|
19176
19398
|
{
|
|
19177
19399
|
icon: QuoteIcon,
|
|
@@ -19181,7 +19403,7 @@ var EditorToolbar = ({
|
|
|
19181
19403
|
shortcut: "Ctrl+Shift+B"
|
|
19182
19404
|
}
|
|
19183
19405
|
),
|
|
19184
|
-
/* @__PURE__ */
|
|
19406
|
+
/* @__PURE__ */ jsx72(
|
|
19185
19407
|
DropdownMenuItem,
|
|
19186
19408
|
{
|
|
19187
19409
|
icon: FileCode2,
|
|
@@ -19194,15 +19416,15 @@ var EditorToolbar = ({
|
|
|
19194
19416
|
]
|
|
19195
19417
|
}
|
|
19196
19418
|
),
|
|
19197
|
-
/* @__PURE__ */
|
|
19419
|
+
/* @__PURE__ */ jsx72(
|
|
19198
19420
|
DropdownMenu,
|
|
19199
19421
|
{
|
|
19200
|
-
trigger: /* @__PURE__ */
|
|
19422
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19201
19423
|
}, title: t("toolbar.image"), children: [
|
|
19202
|
-
/* @__PURE__ */
|
|
19203
|
-
/* @__PURE__ */
|
|
19424
|
+
/* @__PURE__ */ jsx72(ImageIcon2, { className: "w-4 h-4" }),
|
|
19425
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19204
19426
|
] }),
|
|
19205
|
-
children: showImageInput ? /* @__PURE__ */
|
|
19427
|
+
children: showImageInput ? /* @__PURE__ */ jsx72(
|
|
19206
19428
|
ImageInput,
|
|
19207
19429
|
{
|
|
19208
19430
|
onSubmit: (url, alt) => {
|
|
@@ -19211,9 +19433,9 @@ var EditorToolbar = ({
|
|
|
19211
19433
|
},
|
|
19212
19434
|
onCancel: () => setShowImageInput(false)
|
|
19213
19435
|
}
|
|
19214
|
-
) : /* @__PURE__ */
|
|
19215
|
-
/* @__PURE__ */
|
|
19216
|
-
/* @__PURE__ */
|
|
19436
|
+
) : /* @__PURE__ */ jsxs64(Fragment26, { children: [
|
|
19437
|
+
/* @__PURE__ */ jsx72(DropdownMenuItem, { icon: LinkIcon, label: t("imageInput.addFromUrl"), onClick: () => setShowImageInput(true) }),
|
|
19438
|
+
/* @__PURE__ */ jsx72(
|
|
19217
19439
|
DropdownMenuItem,
|
|
19218
19440
|
{
|
|
19219
19441
|
icon: Upload2,
|
|
@@ -19222,8 +19444,8 @@ var EditorToolbar = ({
|
|
|
19222
19444
|
onClick: () => fileInputRef.current?.click()
|
|
19223
19445
|
}
|
|
19224
19446
|
),
|
|
19225
|
-
imageUploadError && /* @__PURE__ */
|
|
19226
|
-
/* @__PURE__ */
|
|
19447
|
+
imageUploadError && /* @__PURE__ */ jsx72(DropdownMenuItem, { label: imageUploadError, disabled: true, destructive: true }),
|
|
19448
|
+
/* @__PURE__ */ jsx72(
|
|
19227
19449
|
"input",
|
|
19228
19450
|
{
|
|
19229
19451
|
ref: fileInputRef,
|
|
@@ -19241,18 +19463,18 @@ var EditorToolbar = ({
|
|
|
19241
19463
|
] })
|
|
19242
19464
|
}
|
|
19243
19465
|
),
|
|
19244
|
-
/* @__PURE__ */
|
|
19466
|
+
/* @__PURE__ */ jsxs64(
|
|
19245
19467
|
DropdownMenu,
|
|
19246
19468
|
{
|
|
19247
|
-
trigger: /* @__PURE__ */
|
|
19469
|
+
trigger: /* @__PURE__ */ jsxs64(ToolbarButton, { onClick: () => {
|
|
19248
19470
|
}, title: t("toolbar.table"), children: [
|
|
19249
|
-
/* @__PURE__ */
|
|
19250
|
-
/* @__PURE__ */
|
|
19471
|
+
/* @__PURE__ */ jsx72(TableIcon, { className: "w-4 h-4" }),
|
|
19472
|
+
/* @__PURE__ */ jsx72(ChevronDown5, { className: "w-3 h-3" })
|
|
19251
19473
|
] }),
|
|
19252
19474
|
children: [
|
|
19253
|
-
/* @__PURE__ */
|
|
19254
|
-
/* @__PURE__ */
|
|
19255
|
-
/* @__PURE__ */
|
|
19475
|
+
/* @__PURE__ */ jsx72(DropdownMenuItem, { icon: TableIcon, label: t("tableMenu.insert3x3"), onClick: () => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }),
|
|
19476
|
+
/* @__PURE__ */ jsx72("div", { className: "my-1 border-t" }),
|
|
19477
|
+
/* @__PURE__ */ jsx72(
|
|
19256
19478
|
DropdownMenuItem,
|
|
19257
19479
|
{
|
|
19258
19480
|
icon: ArrowDown,
|
|
@@ -19261,7 +19483,7 @@ var EditorToolbar = ({
|
|
|
19261
19483
|
disabled: !editor.can().addColumnBefore()
|
|
19262
19484
|
}
|
|
19263
19485
|
),
|
|
19264
|
-
/* @__PURE__ */
|
|
19486
|
+
/* @__PURE__ */ jsx72(
|
|
19265
19487
|
DropdownMenuItem,
|
|
19266
19488
|
{
|
|
19267
19489
|
icon: ArrowDown,
|
|
@@ -19270,7 +19492,7 @@ var EditorToolbar = ({
|
|
|
19270
19492
|
disabled: !editor.can().addColumnAfter()
|
|
19271
19493
|
}
|
|
19272
19494
|
),
|
|
19273
|
-
/* @__PURE__ */
|
|
19495
|
+
/* @__PURE__ */ jsx72(
|
|
19274
19496
|
DropdownMenuItem,
|
|
19275
19497
|
{
|
|
19276
19498
|
icon: ArrowRight,
|
|
@@ -19279,7 +19501,7 @@ var EditorToolbar = ({
|
|
|
19279
19501
|
disabled: !editor.can().addRowBefore()
|
|
19280
19502
|
}
|
|
19281
19503
|
),
|
|
19282
|
-
/* @__PURE__ */
|
|
19504
|
+
/* @__PURE__ */ jsx72(
|
|
19283
19505
|
DropdownMenuItem,
|
|
19284
19506
|
{
|
|
19285
19507
|
icon: ArrowRight,
|
|
@@ -19288,8 +19510,8 @@ var EditorToolbar = ({
|
|
|
19288
19510
|
disabled: !editor.can().addRowAfter()
|
|
19289
19511
|
}
|
|
19290
19512
|
),
|
|
19291
|
-
/* @__PURE__ */
|
|
19292
|
-
/* @__PURE__ */
|
|
19513
|
+
/* @__PURE__ */ jsx72("div", { className: "my-1 border-t" }),
|
|
19514
|
+
/* @__PURE__ */ jsx72(
|
|
19293
19515
|
DropdownMenuItem,
|
|
19294
19516
|
{
|
|
19295
19517
|
icon: Trash2,
|
|
@@ -19298,8 +19520,8 @@ var EditorToolbar = ({
|
|
|
19298
19520
|
disabled: !editor.can().deleteColumn()
|
|
19299
19521
|
}
|
|
19300
19522
|
),
|
|
19301
|
-
/* @__PURE__ */
|
|
19302
|
-
/* @__PURE__ */
|
|
19523
|
+
/* @__PURE__ */ jsx72(DropdownMenuItem, { icon: Trash2, label: t("tableMenu.deleteRow"), onClick: () => editor.chain().focus().deleteRow().run(), disabled: !editor.can().deleteRow() }),
|
|
19524
|
+
/* @__PURE__ */ jsx72(
|
|
19303
19525
|
DropdownMenuItem,
|
|
19304
19526
|
{
|
|
19305
19527
|
icon: Trash2,
|
|
@@ -19311,17 +19533,17 @@ var EditorToolbar = ({
|
|
|
19311
19533
|
]
|
|
19312
19534
|
}
|
|
19313
19535
|
),
|
|
19314
|
-
/* @__PURE__ */
|
|
19315
|
-
/* @__PURE__ */
|
|
19316
|
-
/* @__PURE__ */
|
|
19317
|
-
/* @__PURE__ */
|
|
19318
|
-
/* @__PURE__ */
|
|
19319
|
-
/* @__PURE__ */
|
|
19536
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19537
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().toggleSubscript().run(), active: editor.isActive("subscript"), title: t("toolbar.subscript"), children: /* @__PURE__ */ jsx72(SubscriptIcon, { className: "w-4 h-4" }) }),
|
|
19538
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().toggleSuperscript().run(), active: editor.isActive("superscript"), title: t("toolbar.superscript"), children: /* @__PURE__ */ jsx72(SuperscriptIcon, { className: "w-4 h-4" }) }),
|
|
19539
|
+
/* @__PURE__ */ jsx72(ToolbarDivider, {}),
|
|
19540
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().undo().run(), disabled: !editor.can().undo(), title: t("toolbar.undo"), children: /* @__PURE__ */ jsx72(UndoIcon, { className: "w-4 h-4" }) }),
|
|
19541
|
+
/* @__PURE__ */ jsx72(ToolbarButton, { onClick: () => editor.chain().focus().redo().run(), disabled: !editor.can().redo(), title: t("toolbar.redo"), children: /* @__PURE__ */ jsx72(RedoIcon, { className: "w-4 h-4" }) })
|
|
19320
19542
|
] });
|
|
19321
19543
|
};
|
|
19322
19544
|
|
|
19323
19545
|
// ../../components/ui/UEditor/menus.tsx
|
|
19324
|
-
import { useCallback as useCallback12, useEffect as
|
|
19546
|
+
import { useCallback as useCallback12, useEffect as useEffect27, useMemo as useMemo15, useRef as useRef25, useState as useState46 } from "react";
|
|
19325
19547
|
import { createPortal as createPortal9 } from "react-dom";
|
|
19326
19548
|
import { useTranslations as useTranslations5 } from "next-intl";
|
|
19327
19549
|
import {
|
|
@@ -19347,11 +19569,11 @@ import {
|
|
|
19347
19569
|
Underline as UnderlineIcon2,
|
|
19348
19570
|
Strikethrough as StrikethroughIcon2
|
|
19349
19571
|
} from "lucide-react";
|
|
19350
|
-
import { jsx as
|
|
19572
|
+
import { jsx as jsx73, jsxs as jsxs65 } from "react/jsx-runtime";
|
|
19351
19573
|
var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
19352
19574
|
const t = useTranslations5("UEditor");
|
|
19353
|
-
const [selectedIndex, setSelectedIndex] =
|
|
19354
|
-
const menuRef =
|
|
19575
|
+
const [selectedIndex, setSelectedIndex] = useState46(0);
|
|
19576
|
+
const menuRef = useRef25(null);
|
|
19355
19577
|
const allCommands = useMemo15(
|
|
19356
19578
|
() => [
|
|
19357
19579
|
{
|
|
@@ -19428,10 +19650,10 @@ var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
|
19428
19650
|
const lowerFilter = filterText.toLowerCase();
|
|
19429
19651
|
return allCommands.filter((cmd) => cmd.label.toLowerCase().includes(lowerFilter) || cmd.description.toLowerCase().includes(lowerFilter));
|
|
19430
19652
|
}, [allCommands, filterText]);
|
|
19431
|
-
|
|
19653
|
+
useEffect27(() => {
|
|
19432
19654
|
setSelectedIndex(0);
|
|
19433
19655
|
}, [filterText]);
|
|
19434
|
-
|
|
19656
|
+
useEffect27(() => {
|
|
19435
19657
|
const selectedElement = menuRef.current?.querySelector(`[data-index="${selectedIndex}"]`);
|
|
19436
19658
|
selectedElement?.scrollIntoView({ block: "nearest" });
|
|
19437
19659
|
}, [selectedIndex]);
|
|
@@ -19445,7 +19667,7 @@ var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
|
19445
19667
|
},
|
|
19446
19668
|
[commands, onClose]
|
|
19447
19669
|
);
|
|
19448
|
-
|
|
19670
|
+
useEffect27(() => {
|
|
19449
19671
|
const handleKeyDown = (e) => {
|
|
19450
19672
|
if (commands.length === 0) return;
|
|
19451
19673
|
if (e.key === "ArrowDown") {
|
|
@@ -19466,11 +19688,11 @@ var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
|
19466
19688
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
19467
19689
|
}, [commands, selectedIndex, selectCommand, onClose]);
|
|
19468
19690
|
if (commands.length === 0) {
|
|
19469
|
-
return /* @__PURE__ */
|
|
19691
|
+
return /* @__PURE__ */ jsx73("div", { className: "w-72 p-4 text-center text-muted-foreground text-sm", children: t("slashCommand.noResults") });
|
|
19470
19692
|
}
|
|
19471
|
-
return /* @__PURE__ */
|
|
19472
|
-
/* @__PURE__ */
|
|
19473
|
-
/* @__PURE__ */
|
|
19693
|
+
return /* @__PURE__ */ jsxs65("div", { ref: menuRef, className: "w-72 max-h-80 overflow-y-auto", children: [
|
|
19694
|
+
/* @__PURE__ */ jsx73("div", { className: "px-3 py-2 border-b", children: /* @__PURE__ */ jsx73("span", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wider", children: t("slashCommand.basicBlocks") }) }),
|
|
19695
|
+
/* @__PURE__ */ jsx73("div", { className: "p-1", children: commands.map((cmd, index) => /* @__PURE__ */ jsxs65(
|
|
19474
19696
|
"button",
|
|
19475
19697
|
{
|
|
19476
19698
|
type: "button",
|
|
@@ -19483,19 +19705,19 @@ var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
|
19483
19705
|
selectedIndex === index ? "bg-accent" : "hover:bg-accent/50"
|
|
19484
19706
|
),
|
|
19485
19707
|
children: [
|
|
19486
|
-
/* @__PURE__ */
|
|
19708
|
+
/* @__PURE__ */ jsx73(
|
|
19487
19709
|
"div",
|
|
19488
19710
|
{
|
|
19489
19711
|
className: cn(
|
|
19490
19712
|
"flex items-center justify-center w-10 h-10 rounded-lg mr-3 transition-colors",
|
|
19491
19713
|
selectedIndex === index ? "bg-primary/10" : "bg-muted/50 group-hover:bg-muted"
|
|
19492
19714
|
),
|
|
19493
|
-
children: /* @__PURE__ */
|
|
19715
|
+
children: /* @__PURE__ */ jsx73(cmd.icon, { className: cn("w-5 h-5", selectedIndex === index ? "text-primary" : "text-muted-foreground") })
|
|
19494
19716
|
}
|
|
19495
19717
|
),
|
|
19496
|
-
/* @__PURE__ */
|
|
19497
|
-
/* @__PURE__ */
|
|
19498
|
-
/* @__PURE__ */
|
|
19718
|
+
/* @__PURE__ */ jsxs65("div", { className: "text-left", children: [
|
|
19719
|
+
/* @__PURE__ */ jsx73("div", { className: cn("text-sm font-medium", selectedIndex === index && "text-primary"), children: cmd.label }),
|
|
19720
|
+
/* @__PURE__ */ jsx73("div", { className: "text-xs text-muted-foreground", children: cmd.description })
|
|
19499
19721
|
] })
|
|
19500
19722
|
]
|
|
19501
19723
|
},
|
|
@@ -19505,43 +19727,64 @@ var SlashCommandMenu = ({ editor, onClose, filterText = "" }) => {
|
|
|
19505
19727
|
};
|
|
19506
19728
|
var FloatingMenuContent = ({ editor }) => {
|
|
19507
19729
|
const t = useTranslations5("UEditor");
|
|
19508
|
-
const [showCommands, setShowCommands] =
|
|
19730
|
+
const [showCommands, setShowCommands] = useState46(false);
|
|
19509
19731
|
if (showCommands) {
|
|
19510
|
-
return /* @__PURE__ */
|
|
19732
|
+
return /* @__PURE__ */ jsx73(SlashCommandMenu, { editor, onClose: () => setShowCommands(false) });
|
|
19511
19733
|
}
|
|
19512
|
-
return /* @__PURE__ */
|
|
19734
|
+
return /* @__PURE__ */ jsxs65(
|
|
19513
19735
|
"button",
|
|
19514
19736
|
{
|
|
19515
19737
|
type: "button",
|
|
19516
19738
|
onClick: () => setShowCommands(true),
|
|
19517
19739
|
className: "flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-accent transition-all group",
|
|
19518
19740
|
children: [
|
|
19519
|
-
/* @__PURE__ */
|
|
19520
|
-
/* @__PURE__ */
|
|
19741
|
+
/* @__PURE__ */ jsx73(Plus, { className: "w-4 h-4 text-muted-foreground group-hover:text-foreground" }),
|
|
19742
|
+
/* @__PURE__ */ jsx73("span", { className: "text-sm text-muted-foreground group-hover:text-foreground", children: t("floatingMenu.addBlock") })
|
|
19521
19743
|
]
|
|
19522
19744
|
}
|
|
19523
19745
|
);
|
|
19524
19746
|
};
|
|
19525
|
-
var BubbleMenuContent = ({
|
|
19747
|
+
var BubbleMenuContent = ({
|
|
19748
|
+
editor,
|
|
19749
|
+
onKeepOpenChange
|
|
19750
|
+
}) => {
|
|
19526
19751
|
const t = useTranslations5("UEditor");
|
|
19527
19752
|
const { textColors, highlightColors } = useEditorColors();
|
|
19528
|
-
const [showLinkInput, setShowLinkInput] =
|
|
19529
|
-
const [showEditorColorPalette, setShowEditorColorPalette] =
|
|
19753
|
+
const [showLinkInput, setShowLinkInput] = useState46(false);
|
|
19754
|
+
const [showEditorColorPalette, setShowEditorColorPalette] = useState46(false);
|
|
19755
|
+
useEffect27(() => {
|
|
19756
|
+
onKeepOpenChange?.(showLinkInput);
|
|
19757
|
+
}, [onKeepOpenChange, showLinkInput]);
|
|
19758
|
+
useEffect27(() => {
|
|
19759
|
+
if (!showLinkInput) return;
|
|
19760
|
+
const close2 = () => setShowLinkInput(false);
|
|
19761
|
+
editor.on("selectionUpdate", close2);
|
|
19762
|
+
editor.on("blur", close2);
|
|
19763
|
+
return () => {
|
|
19764
|
+
editor.off("selectionUpdate", close2);
|
|
19765
|
+
editor.off("blur", close2);
|
|
19766
|
+
};
|
|
19767
|
+
}, [editor, showLinkInput]);
|
|
19530
19768
|
if (showLinkInput) {
|
|
19531
|
-
return /* @__PURE__ */
|
|
19769
|
+
return /* @__PURE__ */ jsx73(
|
|
19532
19770
|
LinkInput,
|
|
19533
19771
|
{
|
|
19534
19772
|
initialUrl: editor.getAttributes("link").href || "",
|
|
19535
19773
|
onSubmit: (url) => {
|
|
19536
19774
|
editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
19775
|
+
setShowLinkInput(false);
|
|
19776
|
+
requestAnimationFrame(() => editor.commands.focus());
|
|
19537
19777
|
},
|
|
19538
|
-
onCancel: () =>
|
|
19778
|
+
onCancel: () => {
|
|
19779
|
+
setShowLinkInput(false);
|
|
19780
|
+
requestAnimationFrame(() => editor.commands.focus());
|
|
19781
|
+
}
|
|
19539
19782
|
}
|
|
19540
19783
|
);
|
|
19541
19784
|
}
|
|
19542
19785
|
if (showEditorColorPalette) {
|
|
19543
|
-
return /* @__PURE__ */
|
|
19544
|
-
/* @__PURE__ */
|
|
19786
|
+
return /* @__PURE__ */ jsxs65("div", { className: "w-48", children: [
|
|
19787
|
+
/* @__PURE__ */ jsx73(
|
|
19545
19788
|
EditorColorPalette,
|
|
19546
19789
|
{
|
|
19547
19790
|
colors: textColors,
|
|
@@ -19556,8 +19799,8 @@ var BubbleMenuContent = ({ editor }) => {
|
|
|
19556
19799
|
label: t("colors.textColor")
|
|
19557
19800
|
}
|
|
19558
19801
|
),
|
|
19559
|
-
/* @__PURE__ */
|
|
19560
|
-
/* @__PURE__ */
|
|
19802
|
+
/* @__PURE__ */ jsx73("div", { className: "border-t my-1" }),
|
|
19803
|
+
/* @__PURE__ */ jsx73(
|
|
19561
19804
|
EditorColorPalette,
|
|
19562
19805
|
{
|
|
19563
19806
|
colors: highlightColors,
|
|
@@ -19572,7 +19815,7 @@ var BubbleMenuContent = ({ editor }) => {
|
|
|
19572
19815
|
label: t("colors.highlight")
|
|
19573
19816
|
}
|
|
19574
19817
|
),
|
|
19575
|
-
/* @__PURE__ */
|
|
19818
|
+
/* @__PURE__ */ jsx73("div", { className: "p-2 border-t", children: /* @__PURE__ */ jsx73(
|
|
19576
19819
|
"button",
|
|
19577
19820
|
{
|
|
19578
19821
|
type: "button",
|
|
@@ -19583,53 +19826,71 @@ var BubbleMenuContent = ({ editor }) => {
|
|
|
19583
19826
|
) })
|
|
19584
19827
|
] });
|
|
19585
19828
|
}
|
|
19586
|
-
return /* @__PURE__ */
|
|
19587
|
-
/* @__PURE__ */
|
|
19588
|
-
/* @__PURE__ */
|
|
19589
|
-
/* @__PURE__ */
|
|
19829
|
+
return /* @__PURE__ */ jsxs65("div", { className: "flex items-center gap-0.5 p-1", children: [
|
|
19830
|
+
/* @__PURE__ */ jsx73(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ jsx73(BoldIcon2, { className: "w-4 h-4" }) }),
|
|
19831
|
+
/* @__PURE__ */ jsx73(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ jsx73(ItalicIcon2, { className: "w-4 h-4" }) }),
|
|
19832
|
+
/* @__PURE__ */ jsx73(
|
|
19590
19833
|
ToolbarButton,
|
|
19591
19834
|
{
|
|
19592
19835
|
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
19593
19836
|
active: editor.isActive("underline"),
|
|
19594
19837
|
title: t("toolbar.underline"),
|
|
19595
|
-
children: /* @__PURE__ */
|
|
19838
|
+
children: /* @__PURE__ */ jsx73(UnderlineIcon2, { className: "w-4 h-4" })
|
|
19596
19839
|
}
|
|
19597
19840
|
),
|
|
19598
|
-
/* @__PURE__ */
|
|
19599
|
-
/* @__PURE__ */
|
|
19600
|
-
/* @__PURE__ */
|
|
19601
|
-
/* @__PURE__ */
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19841
|
+
/* @__PURE__ */ jsx73(ToolbarButton, { onClick: () => editor.chain().focus().toggleStrike().run(), active: editor.isActive("strike"), title: t("toolbar.strike"), children: /* @__PURE__ */ jsx73(StrikethroughIcon2, { className: "w-4 h-4" }) }),
|
|
19842
|
+
/* @__PURE__ */ jsx73(ToolbarButton, { onClick: () => editor.chain().focus().toggleCode().run(), active: editor.isActive("code"), title: t("toolbar.code"), children: /* @__PURE__ */ jsx73(CodeIcon2, { className: "w-4 h-4" }) }),
|
|
19843
|
+
/* @__PURE__ */ jsx73("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
19844
|
+
/* @__PURE__ */ jsx73(
|
|
19845
|
+
ToolbarButton,
|
|
19846
|
+
{
|
|
19847
|
+
onMouseDown: () => {
|
|
19848
|
+
onKeepOpenChange?.(true);
|
|
19849
|
+
},
|
|
19850
|
+
onClick: () => {
|
|
19851
|
+
setShowLinkInput(true);
|
|
19852
|
+
},
|
|
19853
|
+
active: editor.isActive("link"),
|
|
19854
|
+
title: t("toolbar.link"),
|
|
19855
|
+
children: /* @__PURE__ */ jsx73(LinkIcon2, { className: "w-4 h-4" })
|
|
19856
|
+
}
|
|
19857
|
+
),
|
|
19858
|
+
/* @__PURE__ */ jsx73(ToolbarButton, { onClick: () => setShowEditorColorPalette(true), title: t("colors.textColor"), children: /* @__PURE__ */ jsx73(Palette3, { className: "w-4 h-4" }) }),
|
|
19859
|
+
/* @__PURE__ */ jsx73("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
19860
|
+
/* @__PURE__ */ jsx73(
|
|
19605
19861
|
ToolbarButton,
|
|
19606
19862
|
{
|
|
19607
19863
|
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
19608
19864
|
active: editor.isActive("subscript"),
|
|
19609
19865
|
title: t("toolbar.subscript"),
|
|
19610
|
-
children: /* @__PURE__ */
|
|
19866
|
+
children: /* @__PURE__ */ jsx73(SubscriptIcon2, { className: "w-4 h-4" })
|
|
19611
19867
|
}
|
|
19612
19868
|
),
|
|
19613
|
-
/* @__PURE__ */
|
|
19869
|
+
/* @__PURE__ */ jsx73(
|
|
19614
19870
|
ToolbarButton,
|
|
19615
19871
|
{
|
|
19616
19872
|
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
19617
19873
|
active: editor.isActive("superscript"),
|
|
19618
19874
|
title: t("toolbar.superscript"),
|
|
19619
|
-
children: /* @__PURE__ */
|
|
19875
|
+
children: /* @__PURE__ */ jsx73(SuperscriptIcon2, { className: "w-4 h-4" })
|
|
19620
19876
|
}
|
|
19621
19877
|
)
|
|
19622
19878
|
] });
|
|
19623
19879
|
};
|
|
19624
19880
|
var CustomBubbleMenu = ({ editor }) => {
|
|
19625
|
-
const [isVisible, setIsVisible] =
|
|
19626
|
-
const [position, setPosition] =
|
|
19627
|
-
const menuRef =
|
|
19628
|
-
|
|
19881
|
+
const [isVisible, setIsVisible] = useState46(false);
|
|
19882
|
+
const [position, setPosition] = useState46({ top: 0, left: 0 });
|
|
19883
|
+
const menuRef = useRef25(null);
|
|
19884
|
+
const keepOpenRef = useRef25(false);
|
|
19885
|
+
const setKeepOpen = useCallback12((next) => {
|
|
19886
|
+
keepOpenRef.current = next;
|
|
19887
|
+
if (next) setIsVisible(true);
|
|
19888
|
+
}, []);
|
|
19889
|
+
useEffect27(() => {
|
|
19629
19890
|
const updatePosition = () => {
|
|
19630
19891
|
const { state, view } = editor;
|
|
19631
19892
|
const { from, to, empty } = state.selection;
|
|
19632
|
-
if (empty || !view.hasFocus()) {
|
|
19893
|
+
if (!keepOpenRef.current && (empty || !view.hasFocus())) {
|
|
19633
19894
|
setIsVisible(false);
|
|
19634
19895
|
return;
|
|
19635
19896
|
}
|
|
@@ -19640,7 +19901,9 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
19640
19901
|
setPosition({ top, left });
|
|
19641
19902
|
setIsVisible(true);
|
|
19642
19903
|
};
|
|
19643
|
-
const handleBlur = () =>
|
|
19904
|
+
const handleBlur = () => {
|
|
19905
|
+
if (!keepOpenRef.current) setIsVisible(false);
|
|
19906
|
+
};
|
|
19644
19907
|
editor.on("selectionUpdate", updatePosition);
|
|
19645
19908
|
editor.on("focus", updatePosition);
|
|
19646
19909
|
editor.on("blur", handleBlur);
|
|
@@ -19652,7 +19915,7 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
19652
19915
|
}, [editor]);
|
|
19653
19916
|
if (!isVisible) return null;
|
|
19654
19917
|
return createPortal9(
|
|
19655
|
-
/* @__PURE__ */
|
|
19918
|
+
/* @__PURE__ */ jsx73(
|
|
19656
19919
|
"div",
|
|
19657
19920
|
{
|
|
19658
19921
|
ref: menuRef,
|
|
@@ -19663,16 +19926,22 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
19663
19926
|
transform: "translate(-50%, -100%)"
|
|
19664
19927
|
},
|
|
19665
19928
|
onMouseDown: (e) => e.preventDefault(),
|
|
19666
|
-
children: /* @__PURE__ */
|
|
19929
|
+
children: /* @__PURE__ */ jsx73(
|
|
19930
|
+
BubbleMenuContent,
|
|
19931
|
+
{
|
|
19932
|
+
editor,
|
|
19933
|
+
onKeepOpenChange: setKeepOpen
|
|
19934
|
+
}
|
|
19935
|
+
)
|
|
19667
19936
|
}
|
|
19668
19937
|
),
|
|
19669
19938
|
document.body
|
|
19670
19939
|
);
|
|
19671
19940
|
};
|
|
19672
19941
|
var CustomFloatingMenu = ({ editor }) => {
|
|
19673
|
-
const [isVisible, setIsVisible] =
|
|
19674
|
-
const [position, setPosition] =
|
|
19675
|
-
|
|
19942
|
+
const [isVisible, setIsVisible] = useState46(false);
|
|
19943
|
+
const [position, setPosition] = useState46({ top: 0, left: 0 });
|
|
19944
|
+
useEffect27(() => {
|
|
19676
19945
|
const updatePosition = () => {
|
|
19677
19946
|
const { state, view } = editor;
|
|
19678
19947
|
const { $from, empty } = state.selection;
|
|
@@ -19699,7 +19968,7 @@ var CustomFloatingMenu = ({ editor }) => {
|
|
|
19699
19968
|
}, [editor]);
|
|
19700
19969
|
if (!isVisible) return null;
|
|
19701
19970
|
return createPortal9(
|
|
19702
|
-
/* @__PURE__ */
|
|
19971
|
+
/* @__PURE__ */ jsx73(
|
|
19703
19972
|
"div",
|
|
19704
19973
|
{
|
|
19705
19974
|
className: "fixed z-50 rounded-2xl border border-border bg-card text-card-foreground shadow-lg backdrop-blur-sm overflow-hidden animate-in fade-in-0 slide-in-from-bottom-2",
|
|
@@ -19709,7 +19978,7 @@ var CustomFloatingMenu = ({ editor }) => {
|
|
|
19709
19978
|
transform: "translate(-50%, -100%)"
|
|
19710
19979
|
},
|
|
19711
19980
|
onMouseDown: (e) => e.preventDefault(),
|
|
19712
|
-
children: /* @__PURE__ */
|
|
19981
|
+
children: /* @__PURE__ */ jsx73(FloatingMenuContent, { editor })
|
|
19713
19982
|
}
|
|
19714
19983
|
),
|
|
19715
19984
|
document.body
|
|
@@ -19718,25 +19987,25 @@ var CustomFloatingMenu = ({ editor }) => {
|
|
|
19718
19987
|
|
|
19719
19988
|
// ../../components/ui/UEditor/CharacterCount.tsx
|
|
19720
19989
|
import { useTranslations as useTranslations6 } from "next-intl";
|
|
19721
|
-
import { jsxs as
|
|
19990
|
+
import { jsxs as jsxs66 } from "react/jsx-runtime";
|
|
19722
19991
|
var CharacterCountDisplay = ({ editor, maxCharacters }) => {
|
|
19723
19992
|
const t = useTranslations6("UEditor");
|
|
19724
19993
|
const storage = editor.storage;
|
|
19725
19994
|
const characterCount = storage.characterCount?.characters?.() ?? 0;
|
|
19726
19995
|
const wordCount = storage.characterCount?.words?.() ?? 0;
|
|
19727
19996
|
const percentage = maxCharacters ? Math.round(characterCount / maxCharacters * 100) : 0;
|
|
19728
|
-
return /* @__PURE__ */
|
|
19729
|
-
/* @__PURE__ */
|
|
19997
|
+
return /* @__PURE__ */ jsxs66("div", { className: "flex items-center gap-3 px-3 py-2 text-xs text-muted-foreground border-t bg-muted/20", children: [
|
|
19998
|
+
/* @__PURE__ */ jsxs66("span", { children: [
|
|
19730
19999
|
wordCount,
|
|
19731
20000
|
" ",
|
|
19732
20001
|
t("words")
|
|
19733
20002
|
] }),
|
|
19734
|
-
/* @__PURE__ */
|
|
20003
|
+
/* @__PURE__ */ jsxs66("span", { children: [
|
|
19735
20004
|
characterCount,
|
|
19736
20005
|
" ",
|
|
19737
20006
|
t("characters")
|
|
19738
20007
|
] }),
|
|
19739
|
-
maxCharacters && /* @__PURE__ */
|
|
20008
|
+
maxCharacters && /* @__PURE__ */ jsxs66("span", { className: cn(percentage > 90 && "text-destructive", percentage > 100 && "font-bold"), children: [
|
|
19740
20009
|
characterCount,
|
|
19741
20010
|
"/",
|
|
19742
20011
|
maxCharacters
|
|
@@ -19745,7 +20014,7 @@ var CharacterCountDisplay = ({ editor, maxCharacters }) => {
|
|
|
19745
20014
|
};
|
|
19746
20015
|
|
|
19747
20016
|
// ../../components/ui/UEditor/UEditor.tsx
|
|
19748
|
-
import { jsx as
|
|
20017
|
+
import { jsx as jsx74, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
19749
20018
|
var UEditor = ({
|
|
19750
20019
|
content = "",
|
|
19751
20020
|
onChange,
|
|
@@ -19769,8 +20038,8 @@ var UEditor = ({
|
|
|
19769
20038
|
const t = useTranslations7("UEditor");
|
|
19770
20039
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
19771
20040
|
const extensions = useMemo16(
|
|
19772
|
-
() => buildUEditorExtensions({ placeholder: effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode }),
|
|
19773
|
-
[effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode]
|
|
20041
|
+
() => buildUEditorExtensions({ placeholder: effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode, editable }),
|
|
20042
|
+
[effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode, editable]
|
|
19774
20043
|
);
|
|
19775
20044
|
const editor = useEditor({
|
|
19776
20045
|
immediatelyRender: false,
|
|
@@ -19786,6 +20055,19 @@ var UEditor = ({
|
|
|
19786
20055
|
event.stopPropagation();
|
|
19787
20056
|
}
|
|
19788
20057
|
return false;
|
|
20058
|
+
},
|
|
20059
|
+
click: (view, event) => {
|
|
20060
|
+
if (!(event instanceof MouseEvent)) return false;
|
|
20061
|
+
if (event.button !== 0) return false;
|
|
20062
|
+
const target = event.target;
|
|
20063
|
+
const anchor = target?.closest?.("a[href]");
|
|
20064
|
+
const href = anchor?.getAttribute("href") ?? "";
|
|
20065
|
+
if (!href) return false;
|
|
20066
|
+
if (!view.state.selection.empty) return false;
|
|
20067
|
+
event.preventDefault();
|
|
20068
|
+
event.stopPropagation();
|
|
20069
|
+
window.open(href, "_blank", "noopener,noreferrer");
|
|
20070
|
+
return true;
|
|
19789
20071
|
}
|
|
19790
20072
|
},
|
|
19791
20073
|
attributes: {
|
|
@@ -19864,7 +20146,7 @@ var UEditor = ({
|
|
|
19864
20146
|
onJsonChange?.(editor2.getJSON());
|
|
19865
20147
|
}
|
|
19866
20148
|
});
|
|
19867
|
-
|
|
20149
|
+
useEffect28(() => {
|
|
19868
20150
|
if (editor && content !== editor.getHTML()) {
|
|
19869
20151
|
if (editor.isEmpty && content) {
|
|
19870
20152
|
editor.commands.setContent(content);
|
|
@@ -19872,7 +20154,7 @@ var UEditor = ({
|
|
|
19872
20154
|
}
|
|
19873
20155
|
}, [content, editor]);
|
|
19874
20156
|
if (!editor) {
|
|
19875
|
-
return /* @__PURE__ */
|
|
20157
|
+
return /* @__PURE__ */ jsx74(
|
|
19876
20158
|
"div",
|
|
19877
20159
|
{
|
|
19878
20160
|
className: cn("w-full rounded-lg border bg-background flex items-center justify-center text-muted-foreground", className),
|
|
@@ -19881,7 +20163,7 @@ var UEditor = ({
|
|
|
19881
20163
|
}
|
|
19882
20164
|
);
|
|
19883
20165
|
}
|
|
19884
|
-
return /* @__PURE__ */
|
|
20166
|
+
return /* @__PURE__ */ jsxs67(
|
|
19885
20167
|
"div",
|
|
19886
20168
|
{
|
|
19887
20169
|
className: cn(
|
|
@@ -19893,10 +20175,10 @@ var UEditor = ({
|
|
|
19893
20175
|
className
|
|
19894
20176
|
),
|
|
19895
20177
|
children: [
|
|
19896
|
-
editable && showToolbar && /* @__PURE__ */
|
|
19897
|
-
editable && showBubbleMenu && /* @__PURE__ */
|
|
19898
|
-
editable && showFloatingMenu && /* @__PURE__ */
|
|
19899
|
-
/* @__PURE__ */
|
|
20178
|
+
editable && showToolbar && /* @__PURE__ */ jsx74(EditorToolbar, { editor, variant, uploadImage, imageInsertMode }),
|
|
20179
|
+
editable && showBubbleMenu && /* @__PURE__ */ jsx74(CustomBubbleMenu, { editor }),
|
|
20180
|
+
editable && showFloatingMenu && /* @__PURE__ */ jsx74(CustomFloatingMenu, { editor }),
|
|
20181
|
+
/* @__PURE__ */ jsx74(
|
|
19900
20182
|
EditorContent,
|
|
19901
20183
|
{
|
|
19902
20184
|
editor,
|
|
@@ -19907,7 +20189,7 @@ var UEditor = ({
|
|
|
19907
20189
|
}
|
|
19908
20190
|
}
|
|
19909
20191
|
),
|
|
19910
|
-
showCharacterCount && /* @__PURE__ */
|
|
20192
|
+
showCharacterCount && /* @__PURE__ */ jsx74(CharacterCountDisplay, { editor, maxCharacters })
|
|
19911
20193
|
]
|
|
19912
20194
|
}
|
|
19913
20195
|
);
|