@farmzone/fz-react-ui 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +371 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +373 -75
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,8 +28,9 @@ import { useDaumPostcodePopup } from 'react-daum-postcode';
|
|
|
28
28
|
import { create } from 'zustand';
|
|
29
29
|
import { createJSONStorage, persist } from 'zustand/middleware';
|
|
30
30
|
import { v4 } from 'uuid';
|
|
31
|
-
import { useEditor, useEditorState, EditorContent, ReactRenderer } from '@tiptap/react';
|
|
32
|
-
import { Extension, InputRule } from '@tiptap/core';
|
|
31
|
+
import { useEditor, useEditorState, EditorContent, ReactRenderer, ReactNodeViewRenderer, NodeViewWrapper } from '@tiptap/react';
|
|
32
|
+
import { isMacOS, Extension, Node, mergeAttributes, InputRule } from '@tiptap/core';
|
|
33
|
+
import { TextSelection } from '@tiptap/pm/state';
|
|
33
34
|
import StarterKit from '@tiptap/starter-kit';
|
|
34
35
|
import TextAlign from '@tiptap/extension-text-align';
|
|
35
36
|
import { Image as Image$1 } from '@tiptap/extension-image';
|
|
@@ -1762,7 +1763,8 @@ var ToastManager = class _ToastManager {
|
|
|
1762
1763
|
duration: props.duration ?? perType.duration ?? base.duration ?? 1500,
|
|
1763
1764
|
style: Object.keys(style).length > 0 ? style : void 0,
|
|
1764
1765
|
className: className || void 0,
|
|
1765
|
-
iconTheme: props.iconTheme ?? perType.iconTheme ?? base.iconTheme
|
|
1766
|
+
iconTheme: props.iconTheme ?? perType.iconTheme ?? base.iconTheme,
|
|
1767
|
+
icon: props.icon ?? perType.icon ?? base.icon
|
|
1766
1768
|
};
|
|
1767
1769
|
}
|
|
1768
1770
|
registerContainer(position, setToasts) {
|
|
@@ -2073,7 +2075,7 @@ function ToastItemCard(props) {
|
|
|
2073
2075
|
onClick: handleClick,
|
|
2074
2076
|
children: [
|
|
2075
2077
|
toast2.props.icon || getDefaultIcon(toast2.props.type || "info", toast2.props.iconTheme),
|
|
2076
|
-
/* @__PURE__ */ jsx("span", { className:
|
|
2078
|
+
/* @__PURE__ */ jsx("span", { className: `flex-1 font-medium ${hasCustomStyle ? "" : "text-sm"}`, children: toast2.props.toast }),
|
|
2077
2079
|
toast2.props.showCloseButton === true && /* @__PURE__ */ jsx(
|
|
2078
2080
|
"button",
|
|
2079
2081
|
{
|
|
@@ -6076,9 +6078,11 @@ function releaseStableImageSrc(src) {
|
|
|
6076
6078
|
// src/components/FilePreviewViewer/config/utils.ts
|
|
6077
6079
|
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "avif", "heic", "heif"]);
|
|
6078
6080
|
var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
|
|
6081
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm"]);
|
|
6079
6082
|
var MIME_FILE_TYPES = [
|
|
6080
6083
|
{ pattern: /^data:image\//i, type: "image" },
|
|
6081
|
-
{ pattern: /^data:application\/pdf/i, type: "pdf" }
|
|
6084
|
+
{ pattern: /^data:application\/pdf/i, type: "pdf" },
|
|
6085
|
+
{ pattern: /^data:video\//i, type: "video" }
|
|
6082
6086
|
];
|
|
6083
6087
|
function normalizeExtension(ext) {
|
|
6084
6088
|
const lower = ext.replace(/^\./, "").toLowerCase();
|
|
@@ -6104,6 +6108,10 @@ function getExtensionFromSrc(src) {
|
|
|
6104
6108
|
return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "jpg";
|
|
6105
6109
|
}
|
|
6106
6110
|
if (type === "pdf") return "pdf";
|
|
6111
|
+
if (type === "video") {
|
|
6112
|
+
const dataUrlMatch = src.match(/^data:video\/([a-zA-Z0-9+.-]+)/i);
|
|
6113
|
+
return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "mp4";
|
|
6114
|
+
}
|
|
6107
6115
|
}
|
|
6108
6116
|
try {
|
|
6109
6117
|
const url = new URL(src, window.location.origin);
|
|
@@ -6124,9 +6132,13 @@ function inferTypeFromUrl(src) {
|
|
|
6124
6132
|
const contentType = url.searchParams.get("content-type")?.toLowerCase();
|
|
6125
6133
|
if (contentType?.includes("pdf")) return "pdf";
|
|
6126
6134
|
if (contentType?.startsWith("image/")) return "image";
|
|
6135
|
+
if (contentType?.startsWith("video/")) return "video";
|
|
6127
6136
|
if (pathname.includes(".pdf") || /\/pdf(?:\/|$)/i.test(pathname)) {
|
|
6128
6137
|
return "pdf";
|
|
6129
6138
|
}
|
|
6139
|
+
if (Array.from(VIDEO_EXTENSIONS).some((ext) => pathname.includes(`.${ext}`))) {
|
|
6140
|
+
return "video";
|
|
6141
|
+
}
|
|
6130
6142
|
return "image";
|
|
6131
6143
|
} catch {
|
|
6132
6144
|
return null;
|
|
@@ -6137,6 +6149,7 @@ function getPreviewFileType(src) {
|
|
|
6137
6149
|
if (extension) {
|
|
6138
6150
|
if (PDF_EXTENSIONS.has(extension)) return "pdf";
|
|
6139
6151
|
if (IMAGE_EXTENSIONS.has(extension)) return "image";
|
|
6152
|
+
if (VIDEO_EXTENSIONS.has(extension)) return "video";
|
|
6140
6153
|
}
|
|
6141
6154
|
for (const { pattern, type } of MIME_FILE_TYPES) {
|
|
6142
6155
|
if (pattern.test(src)) return type;
|
|
@@ -6149,10 +6162,12 @@ function hasKnownExtension(filename) {
|
|
|
6149
6162
|
const dotIndex = filename.lastIndexOf(".");
|
|
6150
6163
|
if (dotIndex <= 0) return false;
|
|
6151
6164
|
const ext = filename.slice(dotIndex + 1).toLowerCase();
|
|
6152
|
-
return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext);
|
|
6165
|
+
return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext);
|
|
6153
6166
|
}
|
|
6154
6167
|
function defaultExtensionForType(fileType) {
|
|
6155
|
-
|
|
6168
|
+
if (fileType === "pdf") return "pdf";
|
|
6169
|
+
if (fileType === "video") return "mp4";
|
|
6170
|
+
return "jpg";
|
|
6156
6171
|
}
|
|
6157
6172
|
function withExtension(name, extension, fileType) {
|
|
6158
6173
|
if (extension && name.toLowerCase().endsWith(`.${extension}`)) return name;
|
|
@@ -6173,7 +6188,7 @@ function getFileLabel(src, index, fileTypeOverride) {
|
|
|
6173
6188
|
}
|
|
6174
6189
|
} catch {
|
|
6175
6190
|
}
|
|
6176
|
-
const labelPrefix = fileType === "pdf" ? "PDF" : "Image";
|
|
6191
|
+
const labelPrefix = fileType === "pdf" ? "PDF" : fileType === "video" ? "Video" : "Image";
|
|
6177
6192
|
return withExtension(`${labelPrefix} ${index + 1}`, extension, fileType);
|
|
6178
6193
|
}
|
|
6179
6194
|
function getAdjacentIndexes(currentIndex, length) {
|
|
@@ -6215,11 +6230,14 @@ function FilePreviewViewerContent(props) {
|
|
|
6215
6230
|
if (fileType === "pdf") {
|
|
6216
6231
|
return /* @__PURE__ */ jsx("div", { className: "preview-viewer-container w-[90vw] h-[85vh] max-w-[90vw] max-h-[85vh] flex items-center justify-center", children: /* @__PURE__ */ jsx("iframe", { src, title: alt, className: "w-full h-full rounded bg-white border-0" }) });
|
|
6217
6232
|
}
|
|
6233
|
+
if (fileType === "video") {
|
|
6234
|
+
return /* @__PURE__ */ jsx("div", { className: "preview-viewer-container w-[90vw] h-[85vh] max-w-[90vw] max-h-[85vh] flex items-center justify-center", children: /* @__PURE__ */ jsx("video", { src, controls: true, className: "max-w-full max-h-full rounded bg-black" }) });
|
|
6235
|
+
}
|
|
6218
6236
|
if (fileType === "unsupported") {
|
|
6219
6237
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-3 max-w-md px-6 py-10 text-center", children: [
|
|
6220
6238
|
/* @__PURE__ */ jsx(FileText, { className: "size-12 text-gray-300" }),
|
|
6221
6239
|
/* @__PURE__ */ jsx("p", { className: "text-lg font-medium text-white", children: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD" }),
|
|
6222
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-300 leading-relaxed", children: "\uC774\uBBF8\uC9C0, PDF \uD615\uC2DD\uB9CC \uBBF8\uB9AC\uBCF4\uAE30\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4." })
|
|
6240
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-300 leading-relaxed", children: "\uC774\uBBF8\uC9C0, PDF, \uB3D9\uC601\uC0C1 \uD615\uC2DD\uB9CC \uBBF8\uB9AC\uBCF4\uAE30\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4." })
|
|
6223
6241
|
] });
|
|
6224
6242
|
}
|
|
6225
6243
|
return /* @__PURE__ */ jsx("div", { className: "relative max-w-[85vw] max-h-[85vh] w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "preview-viewer-container flex items-center justify-center w-full h-full overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
@@ -6367,6 +6385,8 @@ function FilePreviewViewerSession(props) {
|
|
|
6367
6385
|
[fileTypes, currentIndex, currentFile]
|
|
6368
6386
|
);
|
|
6369
6387
|
const isImageFile2 = fileType === "image";
|
|
6388
|
+
const isVideoFile = fileType === "video";
|
|
6389
|
+
const isDownloadableFile = isImageFile2 || isVideoFile;
|
|
6370
6390
|
const fileLabel = useMemo(
|
|
6371
6391
|
() => fileNames?.[currentIndex] ?? (currentFile ? getFileLabel(currentFile, currentIndex, fileTypes?.[currentIndex]) : ""),
|
|
6372
6392
|
[currentFile, currentIndex, fileTypes, fileNames]
|
|
@@ -6384,7 +6404,7 @@ function FilePreviewViewerSession(props) {
|
|
|
6384
6404
|
resetTransform();
|
|
6385
6405
|
}, [fileArray.length, resetTransform]);
|
|
6386
6406
|
const handleDownload = useCallback(async () => {
|
|
6387
|
-
if (!currentFile || !
|
|
6407
|
+
if (!currentFile || !isDownloadableFile) return;
|
|
6388
6408
|
try {
|
|
6389
6409
|
const response = await fetch(currentFile);
|
|
6390
6410
|
const blob = await response.blob();
|
|
@@ -6399,7 +6419,7 @@ function FilePreviewViewerSession(props) {
|
|
|
6399
6419
|
} catch (error) {
|
|
6400
6420
|
console.error("\uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328:", error);
|
|
6401
6421
|
}
|
|
6402
|
-
}, [currentFile, fileLabel,
|
|
6422
|
+
}, [currentFile, fileLabel, isDownloadableFile]);
|
|
6403
6423
|
const handleZoomIn = useCallback(() => {
|
|
6404
6424
|
setZoom((prev) => Math.min(prev + 0.25, 3));
|
|
6405
6425
|
}, []);
|
|
@@ -6476,7 +6496,7 @@ function FilePreviewViewerSession(props) {
|
|
|
6476
6496
|
if (!currentFile) return null;
|
|
6477
6497
|
const showZoom = features.zoom && isImageFile2;
|
|
6478
6498
|
const showRotate = features.rotate && isImageFile2;
|
|
6479
|
-
const showDownload = features.download &&
|
|
6499
|
+
const showDownload = features.download && isDownloadableFile;
|
|
6480
6500
|
return /* @__PURE__ */ jsxs(
|
|
6481
6501
|
"div",
|
|
6482
6502
|
{
|
|
@@ -10469,6 +10489,161 @@ var MentionList = forwardRef((props, ref) => {
|
|
|
10469
10489
|
);
|
|
10470
10490
|
});
|
|
10471
10491
|
MentionList.displayName = "MentionList";
|
|
10492
|
+
var IMAGE_CLASS = "max-w-full h-auto rounded-lg my-4";
|
|
10493
|
+
var VIDEO_CLASS = "rich-editor-video";
|
|
10494
|
+
var MIN_WIDTH = 48;
|
|
10495
|
+
var ALIGN_OPTIONS = [
|
|
10496
|
+
{ value: "left", Icon: AlignLeft, label: "\uC67C\uCABD\uC73C\uB85C \uC774\uB3D9" },
|
|
10497
|
+
{ value: "center", Icon: AlignCenter, label: "\uAC00\uC6B4\uB370\uB85C \uC774\uB3D9" },
|
|
10498
|
+
{ value: "right", Icon: AlignRight, label: "\uC624\uB978\uCABD\uC73C\uB85C \uC774\uB3D9" }
|
|
10499
|
+
];
|
|
10500
|
+
function clamp(value, min, max) {
|
|
10501
|
+
return Math.min(Math.max(value, min), max);
|
|
10502
|
+
}
|
|
10503
|
+
function getNaturalSize(mediaEl) {
|
|
10504
|
+
if (mediaEl instanceof HTMLVideoElement) return [mediaEl.videoWidth, mediaEl.videoHeight];
|
|
10505
|
+
return [mediaEl.naturalWidth, mediaEl.naturalHeight];
|
|
10506
|
+
}
|
|
10507
|
+
function stopAndRun(fn) {
|
|
10508
|
+
return (e) => {
|
|
10509
|
+
e.preventDefault();
|
|
10510
|
+
e.stopPropagation();
|
|
10511
|
+
fn();
|
|
10512
|
+
};
|
|
10513
|
+
}
|
|
10514
|
+
function ResizableMediaNodeView(props) {
|
|
10515
|
+
const { node, updateAttributes, mediaType } = props;
|
|
10516
|
+
const { src, alt, title, width, height, align } = node.attrs;
|
|
10517
|
+
const aspectRatioRef = useRef(null);
|
|
10518
|
+
const dragStateRef = useRef(null);
|
|
10519
|
+
const [liveSize, setLiveSize] = useState(null);
|
|
10520
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
10521
|
+
const attrWidth = width ? Number(width) : void 0;
|
|
10522
|
+
const attrHeight = height ? Number(height) : void 0;
|
|
10523
|
+
const currentWidth = liveSize?.width ?? attrWidth;
|
|
10524
|
+
const currentHeight = liveSize?.height ?? attrHeight;
|
|
10525
|
+
const currentAlign = align === "center" || align === "right" ? align : "left";
|
|
10526
|
+
if (attrWidth && attrHeight && !aspectRatioRef.current) {
|
|
10527
|
+
aspectRatioRef.current = attrHeight / attrWidth;
|
|
10528
|
+
}
|
|
10529
|
+
function captureNaturalSize(naturalWidth, naturalHeight) {
|
|
10530
|
+
if (!aspectRatioRef.current && naturalWidth > 0) {
|
|
10531
|
+
aspectRatioRef.current = naturalHeight / naturalWidth;
|
|
10532
|
+
}
|
|
10533
|
+
}
|
|
10534
|
+
function handleImageLoad(e) {
|
|
10535
|
+
captureNaturalSize(e.currentTarget.naturalWidth, e.currentTarget.naturalHeight);
|
|
10536
|
+
}
|
|
10537
|
+
function handleVideoLoadedMetadata(e) {
|
|
10538
|
+
captureNaturalSize(e.currentTarget.videoWidth, e.currentTarget.videoHeight);
|
|
10539
|
+
}
|
|
10540
|
+
function handlePointerDown(e) {
|
|
10541
|
+
e.preventDefault();
|
|
10542
|
+
e.stopPropagation();
|
|
10543
|
+
const mediaEl = e.currentTarget.previousElementSibling;
|
|
10544
|
+
if (!mediaEl) return;
|
|
10545
|
+
const [naturalWidth, naturalHeight] = getNaturalSize(mediaEl);
|
|
10546
|
+
captureNaturalSize(naturalWidth, naturalHeight);
|
|
10547
|
+
const startWidth = currentWidth ?? mediaEl.getBoundingClientRect().width;
|
|
10548
|
+
const editorRoot = mediaEl.closest(".tiptap");
|
|
10549
|
+
const maxWidth = editorRoot?.clientWidth ?? startWidth;
|
|
10550
|
+
dragStateRef.current = { startX: e.clientX, startWidth, maxWidth };
|
|
10551
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
10552
|
+
setIsDragging(true);
|
|
10553
|
+
}
|
|
10554
|
+
function handlePointerMove(e) {
|
|
10555
|
+
const dragState = dragStateRef.current;
|
|
10556
|
+
if (!dragState) return;
|
|
10557
|
+
const delta = e.clientX - dragState.startX;
|
|
10558
|
+
const ratio = aspectRatioRef.current ?? 1;
|
|
10559
|
+
const nextWidth = Math.round(clamp(dragState.startWidth + delta, MIN_WIDTH, dragState.maxWidth));
|
|
10560
|
+
const nextHeight = Math.round(nextWidth * ratio);
|
|
10561
|
+
setLiveSize({ width: nextWidth, height: nextHeight });
|
|
10562
|
+
}
|
|
10563
|
+
function handlePointerUp(e) {
|
|
10564
|
+
if (!dragStateRef.current) return;
|
|
10565
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
10566
|
+
dragStateRef.current = null;
|
|
10567
|
+
setIsDragging(false);
|
|
10568
|
+
setLiveSize((size2) => {
|
|
10569
|
+
if (size2) {
|
|
10570
|
+
updateAttributes({
|
|
10571
|
+
width: size2.width,
|
|
10572
|
+
height: size2.height,
|
|
10573
|
+
style: `width: ${size2.width}px; height: ${size2.height}px;`
|
|
10574
|
+
});
|
|
10575
|
+
}
|
|
10576
|
+
return null;
|
|
10577
|
+
});
|
|
10578
|
+
}
|
|
10579
|
+
return /* @__PURE__ */ jsx(
|
|
10580
|
+
NodeViewWrapper,
|
|
10581
|
+
{
|
|
10582
|
+
className: "rich-editor-media-row",
|
|
10583
|
+
style: { textAlign: currentAlign },
|
|
10584
|
+
children: /* @__PURE__ */ jsxs("span", { className: cn("rich-editor-media-view", isDragging && "is-dragging"), children: [
|
|
10585
|
+
mediaType === "video" ? /* @__PURE__ */ jsx(
|
|
10586
|
+
"video",
|
|
10587
|
+
{
|
|
10588
|
+
src,
|
|
10589
|
+
controls: true,
|
|
10590
|
+
width: currentWidth,
|
|
10591
|
+
height: currentHeight,
|
|
10592
|
+
className: VIDEO_CLASS,
|
|
10593
|
+
onLoadedMetadata: handleVideoLoadedMetadata
|
|
10594
|
+
}
|
|
10595
|
+
) : /* @__PURE__ */ jsx(
|
|
10596
|
+
"img",
|
|
10597
|
+
{
|
|
10598
|
+
src,
|
|
10599
|
+
alt: alt ?? "",
|
|
10600
|
+
title: title ?? void 0,
|
|
10601
|
+
width: currentWidth,
|
|
10602
|
+
height: currentHeight,
|
|
10603
|
+
className: IMAGE_CLASS,
|
|
10604
|
+
draggable: false,
|
|
10605
|
+
onLoad: handleImageLoad
|
|
10606
|
+
}
|
|
10607
|
+
),
|
|
10608
|
+
/* @__PURE__ */ jsx(
|
|
10609
|
+
"div",
|
|
10610
|
+
{
|
|
10611
|
+
className: cn("rich-editor-resize-handle", isDragging && "is-dragging"),
|
|
10612
|
+
onPointerDown: handlePointerDown,
|
|
10613
|
+
onPointerMove: handlePointerMove,
|
|
10614
|
+
onPointerUp: handlePointerUp
|
|
10615
|
+
}
|
|
10616
|
+
),
|
|
10617
|
+
isDragging && liveSize && /* @__PURE__ */ jsxs("div", { className: "rich-editor-resize-label", children: [
|
|
10618
|
+
liveSize.width,
|
|
10619
|
+
" \xD7 ",
|
|
10620
|
+
liveSize.height
|
|
10621
|
+
] }),
|
|
10622
|
+
/* @__PURE__ */ jsx("div", { className: "rich-editor-media-align-popover", children: ALIGN_OPTIONS.map(({ value, Icon: Icon2, label }) => /* @__PURE__ */ jsx(
|
|
10623
|
+
"button",
|
|
10624
|
+
{
|
|
10625
|
+
type: "button",
|
|
10626
|
+
"aria-label": label,
|
|
10627
|
+
title: label,
|
|
10628
|
+
className: cn(
|
|
10629
|
+
"rich-editor-media-align-btn",
|
|
10630
|
+
currentAlign === value && "is-active"
|
|
10631
|
+
),
|
|
10632
|
+
onMouseDown: stopAndRun(() => updateAttributes({ align: value })),
|
|
10633
|
+
children: /* @__PURE__ */ jsx(Icon2, { size: 14 })
|
|
10634
|
+
},
|
|
10635
|
+
value
|
|
10636
|
+
)) })
|
|
10637
|
+
] })
|
|
10638
|
+
}
|
|
10639
|
+
);
|
|
10640
|
+
}
|
|
10641
|
+
function ResizableImageNodeView(props) {
|
|
10642
|
+
return /* @__PURE__ */ jsx(ResizableMediaNodeView, { ...props, mediaType: "image" });
|
|
10643
|
+
}
|
|
10644
|
+
function ResizableVideoNodeView(props) {
|
|
10645
|
+
return /* @__PURE__ */ jsx(ResizableMediaNodeView, { ...props, mediaType: "video" });
|
|
10646
|
+
}
|
|
10472
10647
|
|
|
10473
10648
|
// src/components/RichEditor/config/extensions.ts
|
|
10474
10649
|
function buildExtensions(config) {
|
|
@@ -10483,7 +10658,14 @@ function buildExtensions(config) {
|
|
|
10483
10658
|
accentTextColor,
|
|
10484
10659
|
zIndex
|
|
10485
10660
|
} = config;
|
|
10486
|
-
const exts = [
|
|
10661
|
+
const exts = [
|
|
10662
|
+
TextStyleKit,
|
|
10663
|
+
buildMarkResetOnEnter(),
|
|
10664
|
+
buildRedundantListMarkerStrip()
|
|
10665
|
+
];
|
|
10666
|
+
if (toolbar.codeBlock !== false) {
|
|
10667
|
+
exts.push(buildCodeBlockMerge());
|
|
10668
|
+
}
|
|
10487
10669
|
const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
|
|
10488
10670
|
exts.push(
|
|
10489
10671
|
StarterKit.configure({
|
|
@@ -10509,7 +10691,7 @@ function buildExtensions(config) {
|
|
|
10509
10691
|
exts.push(buildCustomTextAlign());
|
|
10510
10692
|
}
|
|
10511
10693
|
if (toolbar.image) {
|
|
10512
|
-
exts.push(buildCustomImage());
|
|
10694
|
+
exts.push(buildCustomImage(), buildCustomVideo());
|
|
10513
10695
|
}
|
|
10514
10696
|
if (toolbar.placeholder !== void 0) {
|
|
10515
10697
|
exts.push(
|
|
@@ -10577,7 +10759,8 @@ function buildExtensions(config) {
|
|
|
10577
10759
|
Table$2.configure({ resizable: true }),
|
|
10578
10760
|
TableRow,
|
|
10579
10761
|
TableHeader$1,
|
|
10580
|
-
TableCell
|
|
10762
|
+
TableCell,
|
|
10763
|
+
buildTableCommands()
|
|
10581
10764
|
);
|
|
10582
10765
|
}
|
|
10583
10766
|
return exts;
|
|
@@ -10610,6 +10793,17 @@ function buildCustomTextAlign() {
|
|
|
10610
10793
|
defaultAlignment: "left"
|
|
10611
10794
|
});
|
|
10612
10795
|
}
|
|
10796
|
+
function buildAlignAttribute() {
|
|
10797
|
+
return {
|
|
10798
|
+
align: {
|
|
10799
|
+
default: null,
|
|
10800
|
+
renderHTML: (attrs) => {
|
|
10801
|
+
if (attrs.align !== "center" && attrs.align !== "right") return {};
|
|
10802
|
+
return { class: `rich-editor-align-${attrs.align}` };
|
|
10803
|
+
}
|
|
10804
|
+
}
|
|
10805
|
+
};
|
|
10806
|
+
}
|
|
10613
10807
|
function buildCustomImage() {
|
|
10614
10808
|
const CustomImage = Image$1.extend({
|
|
10615
10809
|
addAttributes() {
|
|
@@ -10626,8 +10820,12 @@ function buildCustomImage() {
|
|
|
10626
10820
|
style: {
|
|
10627
10821
|
default: null,
|
|
10628
10822
|
renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
|
|
10629
|
-
}
|
|
10823
|
+
},
|
|
10824
|
+
...buildAlignAttribute()
|
|
10630
10825
|
};
|
|
10826
|
+
},
|
|
10827
|
+
addNodeView() {
|
|
10828
|
+
return ReactNodeViewRenderer(ResizableImageNodeView);
|
|
10631
10829
|
}
|
|
10632
10830
|
});
|
|
10633
10831
|
return CustomImage.configure({
|
|
@@ -10636,6 +10834,134 @@ function buildCustomImage() {
|
|
|
10636
10834
|
allowBase64: true
|
|
10637
10835
|
});
|
|
10638
10836
|
}
|
|
10837
|
+
function buildCustomVideo() {
|
|
10838
|
+
return Node.create({
|
|
10839
|
+
name: "video",
|
|
10840
|
+
group: "block",
|
|
10841
|
+
atom: true,
|
|
10842
|
+
selectable: true,
|
|
10843
|
+
addOptions() {
|
|
10844
|
+
return { HTMLAttributes: {} };
|
|
10845
|
+
},
|
|
10846
|
+
addAttributes() {
|
|
10847
|
+
return {
|
|
10848
|
+
src: { default: null },
|
|
10849
|
+
width: {
|
|
10850
|
+
default: null,
|
|
10851
|
+
renderHTML: (attrs) => attrs.width ? { width: attrs.width } : {}
|
|
10852
|
+
},
|
|
10853
|
+
height: {
|
|
10854
|
+
default: null,
|
|
10855
|
+
renderHTML: (attrs) => attrs.height ? { height: attrs.height } : {}
|
|
10856
|
+
},
|
|
10857
|
+
style: {
|
|
10858
|
+
default: null,
|
|
10859
|
+
renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
|
|
10860
|
+
},
|
|
10861
|
+
...buildAlignAttribute()
|
|
10862
|
+
};
|
|
10863
|
+
},
|
|
10864
|
+
parseHTML() {
|
|
10865
|
+
return [{ tag: "video[src]" }];
|
|
10866
|
+
},
|
|
10867
|
+
renderHTML({ HTMLAttributes }) {
|
|
10868
|
+
return ["video", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
10869
|
+
},
|
|
10870
|
+
addNodeView() {
|
|
10871
|
+
return ReactNodeViewRenderer(ResizableVideoNodeView);
|
|
10872
|
+
}
|
|
10873
|
+
}).configure({
|
|
10874
|
+
HTMLAttributes: { class: "rich-editor-video", controls: "true" }
|
|
10875
|
+
});
|
|
10876
|
+
}
|
|
10877
|
+
function buildTableCommands() {
|
|
10878
|
+
return Extension.create({
|
|
10879
|
+
name: "tableShortcuts",
|
|
10880
|
+
addCommands() {
|
|
10881
|
+
return {
|
|
10882
|
+
deleteLastRow: () => ({ tr, dispatch, state }) => {
|
|
10883
|
+
const { $anchor } = state.selection;
|
|
10884
|
+
let tableNode = null;
|
|
10885
|
+
let tableStart = 0;
|
|
10886
|
+
for (let depth = $anchor.depth; depth > 0; depth--) {
|
|
10887
|
+
const node = $anchor.node(depth);
|
|
10888
|
+
if (node.type.name === "table") {
|
|
10889
|
+
tableNode = node;
|
|
10890
|
+
tableStart = $anchor.start(depth);
|
|
10891
|
+
break;
|
|
10892
|
+
}
|
|
10893
|
+
}
|
|
10894
|
+
if (!tableNode) return false;
|
|
10895
|
+
let lastRowStart = 0;
|
|
10896
|
+
let lastRowSize = 0;
|
|
10897
|
+
let rowCount = 0;
|
|
10898
|
+
tableNode.forEach((child, offset) => {
|
|
10899
|
+
if (child.type.name !== "tableRow") return;
|
|
10900
|
+
rowCount++;
|
|
10901
|
+
lastRowStart = tableStart + offset;
|
|
10902
|
+
lastRowSize = child.nodeSize;
|
|
10903
|
+
});
|
|
10904
|
+
if (rowCount <= 1) return false;
|
|
10905
|
+
if (dispatch) {
|
|
10906
|
+
dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
|
|
10907
|
+
}
|
|
10908
|
+
return true;
|
|
10909
|
+
}
|
|
10910
|
+
};
|
|
10911
|
+
},
|
|
10912
|
+
addKeyboardShortcuts() {
|
|
10913
|
+
const mod = isMacOS() ? "Cmd" : "Alt";
|
|
10914
|
+
return {
|
|
10915
|
+
[`${mod}-Shift-g`]: ({ editor }) => {
|
|
10916
|
+
if (editor.isActive("table")) return false;
|
|
10917
|
+
return editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
10918
|
+
},
|
|
10919
|
+
[`${mod}-Shift-u`]: ({ editor }) => editor.chain().focus().addRowAfter().run(),
|
|
10920
|
+
[`${mod}-Shift-x`]: ({ editor }) => editor.chain().focus().deleteLastRow().run(),
|
|
10921
|
+
[`${mod}-Shift-k`]: ({ editor }) => editor.chain().focus().addColumnAfter().run(),
|
|
10922
|
+
[`${mod}-Shift-l`]: ({ editor }) => editor.chain().focus().deleteColumn().run()
|
|
10923
|
+
};
|
|
10924
|
+
}
|
|
10925
|
+
});
|
|
10926
|
+
}
|
|
10927
|
+
function buildCodeBlockMerge() {
|
|
10928
|
+
return Extension.create({
|
|
10929
|
+
name: "codeBlockMerge",
|
|
10930
|
+
addCommands() {
|
|
10931
|
+
return {
|
|
10932
|
+
toggleCodeBlockMerged: () => ({ editor, state, tr, dispatch, commands }) => {
|
|
10933
|
+
if (editor.isActive("codeBlock")) {
|
|
10934
|
+
return commands.toggleCodeBlock();
|
|
10935
|
+
}
|
|
10936
|
+
const { selection } = state;
|
|
10937
|
+
const blocks = [];
|
|
10938
|
+
state.doc.nodesBetween(selection.from, selection.to, (node) => {
|
|
10939
|
+
if (node.isTextblock) {
|
|
10940
|
+
blocks.push(node);
|
|
10941
|
+
return false;
|
|
10942
|
+
}
|
|
10943
|
+
return true;
|
|
10944
|
+
});
|
|
10945
|
+
if (blocks.length <= 1) {
|
|
10946
|
+
return commands.toggleCodeBlock();
|
|
10947
|
+
}
|
|
10948
|
+
const codeBlockType = state.schema.nodes.codeBlock;
|
|
10949
|
+
if (!codeBlockType) return commands.toggleCodeBlock();
|
|
10950
|
+
const mergedText = blocks.map((b) => b.textContent).join("\n");
|
|
10951
|
+
const newNode = mergedText ? codeBlockType.create(null, state.schema.text(mergedText)) : codeBlockType.create();
|
|
10952
|
+
if (dispatch) {
|
|
10953
|
+
const { from, to } = selection;
|
|
10954
|
+
tr.replaceWith(from, to, newNode);
|
|
10955
|
+
const cursorPos = Math.min(from + newNode.nodeSize - 1, tr.doc.content.size);
|
|
10956
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
10957
|
+
dispatch(tr);
|
|
10958
|
+
}
|
|
10959
|
+
return true;
|
|
10960
|
+
}
|
|
10961
|
+
};
|
|
10962
|
+
}
|
|
10963
|
+
});
|
|
10964
|
+
}
|
|
10639
10965
|
function buildMarkResetOnEnter() {
|
|
10640
10966
|
return Extension.create({
|
|
10641
10967
|
name: "markResetOnEnter",
|
|
@@ -10844,8 +11170,8 @@ function useRichEditorFiles(options = {}) {
|
|
|
10844
11170
|
toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
|
|
10845
11171
|
}
|
|
10846
11172
|
if (maxFiles) {
|
|
10847
|
-
const
|
|
10848
|
-
const currentCount = attachmentsRef.current.length +
|
|
11173
|
+
const inlineMediaCount = editor ? (editor.getHTML().match(/<(img|video)\b/gi) ?? []).length : 0;
|
|
11174
|
+
const currentCount = attachmentsRef.current.length + inlineMediaCount;
|
|
10849
11175
|
const remaining = Math.max(0, maxFiles - currentCount);
|
|
10850
11176
|
if (accepted.length > remaining) {
|
|
10851
11177
|
toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
@@ -10866,6 +11192,10 @@ function useRichEditorFiles(options = {}) {
|
|
|
10866
11192
|
if (!editor) continue;
|
|
10867
11193
|
editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
|
|
10868
11194
|
editor.commands.setTextSelection(editor.state.selection.to);
|
|
11195
|
+
} else if (file.type.startsWith("video/")) {
|
|
11196
|
+
if (!editor) continue;
|
|
11197
|
+
editor.chain().focus().insertContent({ type: "video", attrs: { src: url } }).run();
|
|
11198
|
+
editor.commands.setTextSelection(editor.state.selection.to);
|
|
10869
11199
|
} else {
|
|
10870
11200
|
setAttachments((prev) => [
|
|
10871
11201
|
...prev,
|
|
@@ -10980,7 +11310,7 @@ function useRichEditor(options = {}) {
|
|
|
10980
11310
|
onFileUpload,
|
|
10981
11311
|
initialAttachments: initialSplit.attachments
|
|
10982
11312
|
});
|
|
10983
|
-
const [imageCount, setImageCount] = useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
|
|
11313
|
+
const [imageCount, setImageCount] = useState(() => (initialSplit.html.match(/<(img|video)\b/gi) ?? []).length);
|
|
10984
11314
|
const attachmentsRef = useRef(attachments);
|
|
10985
11315
|
attachmentsRef.current = attachments;
|
|
10986
11316
|
const editorRef = useRef(null);
|
|
@@ -11024,7 +11354,7 @@ function useRichEditor(options = {}) {
|
|
|
11024
11354
|
editorRef.current = editor;
|
|
11025
11355
|
useEffect(() => {
|
|
11026
11356
|
if (!editor) return;
|
|
11027
|
-
const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
|
|
11357
|
+
const sync = () => setImageCount((editor.getHTML().match(/<(img|video)\b/gi) ?? []).length);
|
|
11028
11358
|
sync();
|
|
11029
11359
|
editor.on("transaction", sync);
|
|
11030
11360
|
return () => {
|
|
@@ -11216,9 +11546,9 @@ function TextColorPicker({ editor, colors, currentColor, onClose }) {
|
|
|
11216
11546
|
] });
|
|
11217
11547
|
}
|
|
11218
11548
|
function ToolbarButton(props) {
|
|
11219
|
-
const { onMouseDown, active, disabled, title,
|
|
11549
|
+
const { onMouseDown, active, disabled, title, variant = "default", children } = props;
|
|
11220
11550
|
const theme = useRichEditorTheme();
|
|
11221
|
-
|
|
11551
|
+
return /* @__PURE__ */ jsx(
|
|
11222
11552
|
"button",
|
|
11223
11553
|
{
|
|
11224
11554
|
type: "button",
|
|
@@ -11233,8 +11563,6 @@ function ToolbarButton(props) {
|
|
|
11233
11563
|
children
|
|
11234
11564
|
}
|
|
11235
11565
|
);
|
|
11236
|
-
if (!tooltip) return btn;
|
|
11237
|
-
return /* @__PURE__ */ jsx(Tooltip2, { content: tooltip, position: "bottom", asChild: true, children: btn });
|
|
11238
11566
|
}
|
|
11239
11567
|
function Divider() {
|
|
11240
11568
|
const theme = useRichEditorTheme();
|
|
@@ -11247,6 +11575,10 @@ function cmd(fn) {
|
|
|
11247
11575
|
fn();
|
|
11248
11576
|
};
|
|
11249
11577
|
}
|
|
11578
|
+
function tableShortcutLabel(letter) {
|
|
11579
|
+
const mod = isMacOS() ? "Cmd" : "Alt";
|
|
11580
|
+
return `${mod}+Shift+${letter.toUpperCase()}`;
|
|
11581
|
+
}
|
|
11250
11582
|
function RichEditorToolbar(props) {
|
|
11251
11583
|
const { editor, toolbar = {}, className, zIndex, onImageButtonClick } = props;
|
|
11252
11584
|
const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
|
|
@@ -11316,7 +11648,7 @@ function RichEditorToolbar(props) {
|
|
|
11316
11648
|
() => editor.chain().focus().toggleHeading({ level: 1 }).run()
|
|
11317
11649
|
),
|
|
11318
11650
|
active: state.isH1,
|
|
11319
|
-
title: "\uC81C\uBAA9 1 (
|
|
11651
|
+
title: "\uC81C\uBAA9 1 (Ctrl+Alt+1)",
|
|
11320
11652
|
children: /* @__PURE__ */ jsx(Heading1, { size: 16 })
|
|
11321
11653
|
}
|
|
11322
11654
|
),
|
|
@@ -11327,7 +11659,7 @@ function RichEditorToolbar(props) {
|
|
|
11327
11659
|
() => editor.chain().focus().toggleHeading({ level: 2 }).run()
|
|
11328
11660
|
),
|
|
11329
11661
|
active: state.isH2,
|
|
11330
|
-
title: "\uC81C\uBAA9 2 (
|
|
11662
|
+
title: "\uC81C\uBAA9 2 (Ctrl+Alt+2)",
|
|
11331
11663
|
children: /* @__PURE__ */ jsx(Heading2, { size: 16 })
|
|
11332
11664
|
}
|
|
11333
11665
|
),
|
|
@@ -11338,7 +11670,7 @@ function RichEditorToolbar(props) {
|
|
|
11338
11670
|
() => editor.chain().focus().toggleHeading({ level: 3 }).run()
|
|
11339
11671
|
),
|
|
11340
11672
|
active: state.isH3,
|
|
11341
|
-
title: "\uC81C\uBAA9 3 (
|
|
11673
|
+
title: "\uC81C\uBAA9 3 (Ctrl+Alt+3)",
|
|
11342
11674
|
children: /* @__PURE__ */ jsx(Heading3, { size: 16 })
|
|
11343
11675
|
}
|
|
11344
11676
|
),
|
|
@@ -11349,7 +11681,7 @@ function RichEditorToolbar(props) {
|
|
|
11349
11681
|
() => editor.chain().focus().toggleHeading({ level: 4 }).run()
|
|
11350
11682
|
),
|
|
11351
11683
|
active: state.isH4,
|
|
11352
|
-
title: "\uC81C\uBAA9 4 (
|
|
11684
|
+
title: "\uC81C\uBAA9 4 (Ctrl+Alt+4)",
|
|
11353
11685
|
children: /* @__PURE__ */ jsx(Heading4, { size: 16 })
|
|
11354
11686
|
}
|
|
11355
11687
|
),
|
|
@@ -11378,7 +11710,7 @@ function RichEditorToolbar(props) {
|
|
|
11378
11710
|
{
|
|
11379
11711
|
onMouseDown: cmd(() => editor.chain().focus().toggleStrike().run()),
|
|
11380
11712
|
active: state.isStrike,
|
|
11381
|
-
title: "\uCDE8\uC18C\uC120",
|
|
11713
|
+
title: "\uCDE8\uC18C\uC120 (Ctrl+Shift+S)",
|
|
11382
11714
|
children: /* @__PURE__ */ jsx(Strikethrough, { size: 16 })
|
|
11383
11715
|
}
|
|
11384
11716
|
),
|
|
@@ -11387,7 +11719,7 @@ function RichEditorToolbar(props) {
|
|
|
11387
11719
|
{
|
|
11388
11720
|
onMouseDown: cmd(() => editor.chain().focus().toggleCode().run()),
|
|
11389
11721
|
active: state.isCode,
|
|
11390
|
-
title: "\uC778\uB77C\uC778 \uCF54\uB4DC",
|
|
11722
|
+
title: "\uC778\uB77C\uC778 \uCF54\uB4DC (Ctrl+E)",
|
|
11391
11723
|
children: /* @__PURE__ */ jsx(Code, { size: 16 })
|
|
11392
11724
|
}
|
|
11393
11725
|
),
|
|
@@ -11484,7 +11816,7 @@ function RichEditorToolbar(props) {
|
|
|
11484
11816
|
() => editor.chain().focus().toggleBulletList().run()
|
|
11485
11817
|
),
|
|
11486
11818
|
active: state.isBulletList,
|
|
11487
|
-
title: "\uAE00\uBA38\uB9AC \uAE30\uD638",
|
|
11819
|
+
title: "\uAE00\uBA38\uB9AC \uAE30\uD638 (Ctrl+Shift+8)",
|
|
11488
11820
|
children: /* @__PURE__ */ jsx(List, { size: 16 })
|
|
11489
11821
|
}
|
|
11490
11822
|
),
|
|
@@ -11495,7 +11827,7 @@ function RichEditorToolbar(props) {
|
|
|
11495
11827
|
() => editor.chain().focus().toggleOrderedList().run()
|
|
11496
11828
|
),
|
|
11497
11829
|
active: state.isOrderedList,
|
|
11498
|
-
title: "\uBC88\uD638 \uBAA9\uB85D",
|
|
11830
|
+
title: "\uBC88\uD638 \uBAA9\uB85D (Ctrl+Shift+7)",
|
|
11499
11831
|
children: /* @__PURE__ */ jsx(ListOrdered, { size: 16 })
|
|
11500
11832
|
}
|
|
11501
11833
|
),
|
|
@@ -11506,7 +11838,7 @@ function RichEditorToolbar(props) {
|
|
|
11506
11838
|
() => editor.chain().focus().toggleBlockquote().run()
|
|
11507
11839
|
),
|
|
11508
11840
|
active: state.isBlockquote,
|
|
11509
|
-
title: "\uC778\uC6A9\uAD6C",
|
|
11841
|
+
title: "\uC778\uC6A9\uAD6C (Ctrl+Shift+B)",
|
|
11510
11842
|
children: /* @__PURE__ */ jsx(Quote, { size: 16 })
|
|
11511
11843
|
}
|
|
11512
11844
|
),
|
|
@@ -11514,10 +11846,10 @@ function RichEditorToolbar(props) {
|
|
|
11514
11846
|
ToolbarButton,
|
|
11515
11847
|
{
|
|
11516
11848
|
onMouseDown: cmd(
|
|
11517
|
-
() => editor.chain().focus().
|
|
11849
|
+
() => editor.chain().focus().toggleCodeBlockMerged().run()
|
|
11518
11850
|
),
|
|
11519
11851
|
active: state.isCodeBlock,
|
|
11520
|
-
title: "\uCF54\uB4DC \uBE14\uB85D",
|
|
11852
|
+
title: "\uCF54\uB4DC \uBE14\uB85D (Ctrl+Alt+C)",
|
|
11521
11853
|
children: /* @__PURE__ */ jsx(FileCode, { size: 16 })
|
|
11522
11854
|
}
|
|
11523
11855
|
)
|
|
@@ -11540,7 +11872,7 @@ function RichEditorToolbar(props) {
|
|
|
11540
11872
|
"button",
|
|
11541
11873
|
{
|
|
11542
11874
|
type: "button",
|
|
11543
|
-
"aria-label":
|
|
11875
|
+
"aria-label": `\uD14C\uC774\uBE14 \uC0BD\uC785 (${tableShortcutLabel("g")})`,
|
|
11544
11876
|
className: cn(
|
|
11545
11877
|
"flex h-8 w-8 cursor-pointer items-center justify-center rounded text-sm transition-colors",
|
|
11546
11878
|
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
@@ -11568,46 +11900,15 @@ function RichEditorToolbar(props) {
|
|
|
11568
11900
|
ToolbarButton,
|
|
11569
11901
|
{
|
|
11570
11902
|
onMouseDown: cmd(() => editor.chain().focus().addRowAfter().run()),
|
|
11571
|
-
title:
|
|
11572
|
-
tooltip: "\uD589 \uCD94\uAC00",
|
|
11903
|
+
title: `\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00 (${tableShortcutLabel("u")})`,
|
|
11573
11904
|
children: /* @__PURE__ */ jsx(Plus, { size: 14 })
|
|
11574
11905
|
}
|
|
11575
11906
|
),
|
|
11576
11907
|
/* @__PURE__ */ jsx(
|
|
11577
11908
|
ToolbarButton,
|
|
11578
11909
|
{
|
|
11579
|
-
onMouseDown: cmd(() =>
|
|
11580
|
-
|
|
11581
|
-
const { $anchor } = state2.selection;
|
|
11582
|
-
let tableNode = null;
|
|
11583
|
-
let tableStart = 0;
|
|
11584
|
-
for (let depth = $anchor.depth; depth > 0; depth--) {
|
|
11585
|
-
const node = $anchor.node(depth);
|
|
11586
|
-
if (node.type.name === "table") {
|
|
11587
|
-
tableNode = node;
|
|
11588
|
-
tableStart = $anchor.start(depth);
|
|
11589
|
-
break;
|
|
11590
|
-
}
|
|
11591
|
-
}
|
|
11592
|
-
if (!tableNode) return false;
|
|
11593
|
-
let lastRowStart = 0;
|
|
11594
|
-
let lastRowSize = 0;
|
|
11595
|
-
let rowCount = 0;
|
|
11596
|
-
tableNode.forEach((child, offset) => {
|
|
11597
|
-
if (child.type.name !== "tableRow") return;
|
|
11598
|
-
rowCount++;
|
|
11599
|
-
lastRowStart = tableStart + offset;
|
|
11600
|
-
lastRowSize = child.nodeSize;
|
|
11601
|
-
});
|
|
11602
|
-
if (rowCount <= 1) return false;
|
|
11603
|
-
if (dispatch) {
|
|
11604
|
-
dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
|
|
11605
|
-
}
|
|
11606
|
-
return true;
|
|
11607
|
-
}).run();
|
|
11608
|
-
}),
|
|
11609
|
-
title: "\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C",
|
|
11610
|
-
tooltip: "\uD589 \uC0AD\uC81C",
|
|
11910
|
+
onMouseDown: cmd(() => editor.chain().focus().deleteLastRow().run()),
|
|
11911
|
+
title: `\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C (${tableShortcutLabel("x")})`,
|
|
11611
11912
|
children: /* @__PURE__ */ jsx(Minus, { size: 14 })
|
|
11612
11913
|
}
|
|
11613
11914
|
),
|
|
@@ -11616,8 +11917,7 @@ function RichEditorToolbar(props) {
|
|
|
11616
11917
|
ToolbarButton,
|
|
11617
11918
|
{
|
|
11618
11919
|
onMouseDown: cmd(() => editor.chain().focus().addColumnAfter().run()),
|
|
11619
|
-
title:
|
|
11620
|
-
tooltip: "\uC5F4 \uCD94\uAC00",
|
|
11920
|
+
title: `\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00 (${tableShortcutLabel("k")})`,
|
|
11621
11921
|
children: /* @__PURE__ */ jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R+" })
|
|
11622
11922
|
}
|
|
11623
11923
|
),
|
|
@@ -11625,8 +11925,7 @@ function RichEditorToolbar(props) {
|
|
|
11625
11925
|
ToolbarButton,
|
|
11626
11926
|
{
|
|
11627
11927
|
onMouseDown: cmd(() => editor.chain().focus().deleteColumn().run()),
|
|
11628
|
-
title:
|
|
11629
|
-
tooltip: "\uC5F4 \uC0AD\uC81C",
|
|
11928
|
+
title: `\uD604\uC7AC \uC5F4 \uC0AD\uC81C (${tableShortcutLabel("l")})`,
|
|
11630
11929
|
children: /* @__PURE__ */ jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R-" })
|
|
11631
11930
|
}
|
|
11632
11931
|
),
|
|
@@ -11636,7 +11935,6 @@ function RichEditorToolbar(props) {
|
|
|
11636
11935
|
{
|
|
11637
11936
|
onMouseDown: cmd(() => editor.chain().focus().deleteTable().run()),
|
|
11638
11937
|
title: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
|
|
11639
|
-
tooltip: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
|
|
11640
11938
|
variant: "destructive",
|
|
11641
11939
|
children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
|
|
11642
11940
|
}
|