@farmzone/fz-react-ui 1.2.3 → 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.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';
@@ -6077,9 +6078,11 @@ function releaseStableImageSrc(src) {
6077
6078
  // src/components/FilePreviewViewer/config/utils.ts
6078
6079
  var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "avif", "heic", "heif"]);
6079
6080
  var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
6081
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm"]);
6080
6082
  var MIME_FILE_TYPES = [
6081
6083
  { pattern: /^data:image\//i, type: "image" },
6082
- { pattern: /^data:application\/pdf/i, type: "pdf" }
6084
+ { pattern: /^data:application\/pdf/i, type: "pdf" },
6085
+ { pattern: /^data:video\//i, type: "video" }
6083
6086
  ];
6084
6087
  function normalizeExtension(ext) {
6085
6088
  const lower = ext.replace(/^\./, "").toLowerCase();
@@ -6105,6 +6108,10 @@ function getExtensionFromSrc(src) {
6105
6108
  return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "jpg";
6106
6109
  }
6107
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
+ }
6108
6115
  }
6109
6116
  try {
6110
6117
  const url = new URL(src, window.location.origin);
@@ -6125,9 +6132,13 @@ function inferTypeFromUrl(src) {
6125
6132
  const contentType = url.searchParams.get("content-type")?.toLowerCase();
6126
6133
  if (contentType?.includes("pdf")) return "pdf";
6127
6134
  if (contentType?.startsWith("image/")) return "image";
6135
+ if (contentType?.startsWith("video/")) return "video";
6128
6136
  if (pathname.includes(".pdf") || /\/pdf(?:\/|$)/i.test(pathname)) {
6129
6137
  return "pdf";
6130
6138
  }
6139
+ if (Array.from(VIDEO_EXTENSIONS).some((ext) => pathname.includes(`.${ext}`))) {
6140
+ return "video";
6141
+ }
6131
6142
  return "image";
6132
6143
  } catch {
6133
6144
  return null;
@@ -6138,6 +6149,7 @@ function getPreviewFileType(src) {
6138
6149
  if (extension) {
6139
6150
  if (PDF_EXTENSIONS.has(extension)) return "pdf";
6140
6151
  if (IMAGE_EXTENSIONS.has(extension)) return "image";
6152
+ if (VIDEO_EXTENSIONS.has(extension)) return "video";
6141
6153
  }
6142
6154
  for (const { pattern, type } of MIME_FILE_TYPES) {
6143
6155
  if (pattern.test(src)) return type;
@@ -6150,10 +6162,12 @@ function hasKnownExtension(filename) {
6150
6162
  const dotIndex = filename.lastIndexOf(".");
6151
6163
  if (dotIndex <= 0) return false;
6152
6164
  const ext = filename.slice(dotIndex + 1).toLowerCase();
6153
- return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext);
6165
+ return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext);
6154
6166
  }
6155
6167
  function defaultExtensionForType(fileType) {
6156
- return fileType === "pdf" ? "pdf" : "jpg";
6168
+ if (fileType === "pdf") return "pdf";
6169
+ if (fileType === "video") return "mp4";
6170
+ return "jpg";
6157
6171
  }
6158
6172
  function withExtension(name, extension, fileType) {
6159
6173
  if (extension && name.toLowerCase().endsWith(`.${extension}`)) return name;
@@ -6174,7 +6188,7 @@ function getFileLabel(src, index, fileTypeOverride) {
6174
6188
  }
6175
6189
  } catch {
6176
6190
  }
6177
- const labelPrefix = fileType === "pdf" ? "PDF" : "Image";
6191
+ const labelPrefix = fileType === "pdf" ? "PDF" : fileType === "video" ? "Video" : "Image";
6178
6192
  return withExtension(`${labelPrefix} ${index + 1}`, extension, fileType);
6179
6193
  }
6180
6194
  function getAdjacentIndexes(currentIndex, length) {
@@ -6216,11 +6230,14 @@ function FilePreviewViewerContent(props) {
6216
6230
  if (fileType === "pdf") {
6217
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" }) });
6218
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
+ }
6219
6236
  if (fileType === "unsupported") {
6220
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: [
6221
6238
  /* @__PURE__ */ jsx(FileText, { className: "size-12 text-gray-300" }),
6222
6239
  /* @__PURE__ */ jsx("p", { className: "text-lg font-medium text-white", children: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD" }),
6223
- /* @__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." })
6224
6241
  ] });
6225
6242
  }
6226
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(
@@ -6368,6 +6385,8 @@ function FilePreviewViewerSession(props) {
6368
6385
  [fileTypes, currentIndex, currentFile]
6369
6386
  );
6370
6387
  const isImageFile2 = fileType === "image";
6388
+ const isVideoFile = fileType === "video";
6389
+ const isDownloadableFile = isImageFile2 || isVideoFile;
6371
6390
  const fileLabel = useMemo(
6372
6391
  () => fileNames?.[currentIndex] ?? (currentFile ? getFileLabel(currentFile, currentIndex, fileTypes?.[currentIndex]) : ""),
6373
6392
  [currentFile, currentIndex, fileTypes, fileNames]
@@ -6385,7 +6404,7 @@ function FilePreviewViewerSession(props) {
6385
6404
  resetTransform();
6386
6405
  }, [fileArray.length, resetTransform]);
6387
6406
  const handleDownload = useCallback(async () => {
6388
- if (!currentFile || !isImageFile2) return;
6407
+ if (!currentFile || !isDownloadableFile) return;
6389
6408
  try {
6390
6409
  const response = await fetch(currentFile);
6391
6410
  const blob = await response.blob();
@@ -6400,7 +6419,7 @@ function FilePreviewViewerSession(props) {
6400
6419
  } catch (error) {
6401
6420
  console.error("\uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328:", error);
6402
6421
  }
6403
- }, [currentFile, fileLabel, isImageFile2]);
6422
+ }, [currentFile, fileLabel, isDownloadableFile]);
6404
6423
  const handleZoomIn = useCallback(() => {
6405
6424
  setZoom((prev) => Math.min(prev + 0.25, 3));
6406
6425
  }, []);
@@ -6477,7 +6496,7 @@ function FilePreviewViewerSession(props) {
6477
6496
  if (!currentFile) return null;
6478
6497
  const showZoom = features.zoom && isImageFile2;
6479
6498
  const showRotate = features.rotate && isImageFile2;
6480
- const showDownload = features.download && isImageFile2;
6499
+ const showDownload = features.download && isDownloadableFile;
6481
6500
  return /* @__PURE__ */ jsxs(
6482
6501
  "div",
6483
6502
  {
@@ -10470,6 +10489,161 @@ var MentionList = forwardRef((props, ref) => {
10470
10489
  );
10471
10490
  });
10472
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
+ }
10473
10647
 
10474
10648
  // src/components/RichEditor/config/extensions.ts
10475
10649
  function buildExtensions(config) {
@@ -10484,7 +10658,14 @@ function buildExtensions(config) {
10484
10658
  accentTextColor,
10485
10659
  zIndex
10486
10660
  } = config;
10487
- const exts = [TextStyleKit, buildMarkResetOnEnter(), buildRedundantListMarkerStrip()];
10661
+ const exts = [
10662
+ TextStyleKit,
10663
+ buildMarkResetOnEnter(),
10664
+ buildRedundantListMarkerStrip()
10665
+ ];
10666
+ if (toolbar.codeBlock !== false) {
10667
+ exts.push(buildCodeBlockMerge());
10668
+ }
10488
10669
  const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
10489
10670
  exts.push(
10490
10671
  StarterKit.configure({
@@ -10510,7 +10691,7 @@ function buildExtensions(config) {
10510
10691
  exts.push(buildCustomTextAlign());
10511
10692
  }
10512
10693
  if (toolbar.image) {
10513
- exts.push(buildCustomImage());
10694
+ exts.push(buildCustomImage(), buildCustomVideo());
10514
10695
  }
10515
10696
  if (toolbar.placeholder !== void 0) {
10516
10697
  exts.push(
@@ -10578,7 +10759,8 @@ function buildExtensions(config) {
10578
10759
  Table$2.configure({ resizable: true }),
10579
10760
  TableRow,
10580
10761
  TableHeader$1,
10581
- TableCell
10762
+ TableCell,
10763
+ buildTableCommands()
10582
10764
  );
10583
10765
  }
10584
10766
  return exts;
@@ -10611,6 +10793,17 @@ function buildCustomTextAlign() {
10611
10793
  defaultAlignment: "left"
10612
10794
  });
10613
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
+ }
10614
10807
  function buildCustomImage() {
10615
10808
  const CustomImage = Image$1.extend({
10616
10809
  addAttributes() {
@@ -10627,8 +10820,12 @@ function buildCustomImage() {
10627
10820
  style: {
10628
10821
  default: null,
10629
10822
  renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
10630
- }
10823
+ },
10824
+ ...buildAlignAttribute()
10631
10825
  };
10826
+ },
10827
+ addNodeView() {
10828
+ return ReactNodeViewRenderer(ResizableImageNodeView);
10632
10829
  }
10633
10830
  });
10634
10831
  return CustomImage.configure({
@@ -10637,6 +10834,134 @@ function buildCustomImage() {
10637
10834
  allowBase64: true
10638
10835
  });
10639
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
+ }
10640
10965
  function buildMarkResetOnEnter() {
10641
10966
  return Extension.create({
10642
10967
  name: "markResetOnEnter",
@@ -10845,8 +11170,8 @@ function useRichEditorFiles(options = {}) {
10845
11170
  toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
10846
11171
  }
10847
11172
  if (maxFiles) {
10848
- const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
10849
- const currentCount = attachmentsRef.current.length + imageCount;
11173
+ const inlineMediaCount = editor ? (editor.getHTML().match(/<(img|video)\b/gi) ?? []).length : 0;
11174
+ const currentCount = attachmentsRef.current.length + inlineMediaCount;
10850
11175
  const remaining = Math.max(0, maxFiles - currentCount);
10851
11176
  if (accepted.length > remaining) {
10852
11177
  toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
@@ -10867,6 +11192,10 @@ function useRichEditorFiles(options = {}) {
10867
11192
  if (!editor) continue;
10868
11193
  editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
10869
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);
10870
11199
  } else {
10871
11200
  setAttachments((prev) => [
10872
11201
  ...prev,
@@ -10981,7 +11310,7 @@ function useRichEditor(options = {}) {
10981
11310
  onFileUpload,
10982
11311
  initialAttachments: initialSplit.attachments
10983
11312
  });
10984
- const [imageCount, setImageCount] = useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
11313
+ const [imageCount, setImageCount] = useState(() => (initialSplit.html.match(/<(img|video)\b/gi) ?? []).length);
10985
11314
  const attachmentsRef = useRef(attachments);
10986
11315
  attachmentsRef.current = attachments;
10987
11316
  const editorRef = useRef(null);
@@ -11025,7 +11354,7 @@ function useRichEditor(options = {}) {
11025
11354
  editorRef.current = editor;
11026
11355
  useEffect(() => {
11027
11356
  if (!editor) return;
11028
- const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
11357
+ const sync = () => setImageCount((editor.getHTML().match(/<(img|video)\b/gi) ?? []).length);
11029
11358
  sync();
11030
11359
  editor.on("transaction", sync);
11031
11360
  return () => {
@@ -11217,9 +11546,9 @@ function TextColorPicker({ editor, colors, currentColor, onClose }) {
11217
11546
  ] });
11218
11547
  }
11219
11548
  function ToolbarButton(props) {
11220
- const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
11549
+ const { onMouseDown, active, disabled, title, variant = "default", children } = props;
11221
11550
  const theme = useRichEditorTheme();
11222
- const btn = /* @__PURE__ */ jsx(
11551
+ return /* @__PURE__ */ jsx(
11223
11552
  "button",
11224
11553
  {
11225
11554
  type: "button",
@@ -11234,8 +11563,6 @@ function ToolbarButton(props) {
11234
11563
  children
11235
11564
  }
11236
11565
  );
11237
- if (!tooltip) return btn;
11238
- return /* @__PURE__ */ jsx(Tooltip2, { content: tooltip, position: "bottom", asChild: true, children: btn });
11239
11566
  }
11240
11567
  function Divider() {
11241
11568
  const theme = useRichEditorTheme();
@@ -11248,6 +11575,10 @@ function cmd(fn) {
11248
11575
  fn();
11249
11576
  };
11250
11577
  }
11578
+ function tableShortcutLabel(letter) {
11579
+ const mod = isMacOS() ? "Cmd" : "Alt";
11580
+ return `${mod}+Shift+${letter.toUpperCase()}`;
11581
+ }
11251
11582
  function RichEditorToolbar(props) {
11252
11583
  const { editor, toolbar = {}, className, zIndex, onImageButtonClick } = props;
11253
11584
  const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
@@ -11317,7 +11648,7 @@ function RichEditorToolbar(props) {
11317
11648
  () => editor.chain().focus().toggleHeading({ level: 1 }).run()
11318
11649
  ),
11319
11650
  active: state.isH1,
11320
- title: "\uC81C\uBAA9 1 (H1)",
11651
+ title: "\uC81C\uBAA9 1 (Ctrl+Alt+1)",
11321
11652
  children: /* @__PURE__ */ jsx(Heading1, { size: 16 })
11322
11653
  }
11323
11654
  ),
@@ -11328,7 +11659,7 @@ function RichEditorToolbar(props) {
11328
11659
  () => editor.chain().focus().toggleHeading({ level: 2 }).run()
11329
11660
  ),
11330
11661
  active: state.isH2,
11331
- title: "\uC81C\uBAA9 2 (H2)",
11662
+ title: "\uC81C\uBAA9 2 (Ctrl+Alt+2)",
11332
11663
  children: /* @__PURE__ */ jsx(Heading2, { size: 16 })
11333
11664
  }
11334
11665
  ),
@@ -11339,7 +11670,7 @@ function RichEditorToolbar(props) {
11339
11670
  () => editor.chain().focus().toggleHeading({ level: 3 }).run()
11340
11671
  ),
11341
11672
  active: state.isH3,
11342
- title: "\uC81C\uBAA9 3 (H3)",
11673
+ title: "\uC81C\uBAA9 3 (Ctrl+Alt+3)",
11343
11674
  children: /* @__PURE__ */ jsx(Heading3, { size: 16 })
11344
11675
  }
11345
11676
  ),
@@ -11350,7 +11681,7 @@ function RichEditorToolbar(props) {
11350
11681
  () => editor.chain().focus().toggleHeading({ level: 4 }).run()
11351
11682
  ),
11352
11683
  active: state.isH4,
11353
- title: "\uC81C\uBAA9 4 (H4)",
11684
+ title: "\uC81C\uBAA9 4 (Ctrl+Alt+4)",
11354
11685
  children: /* @__PURE__ */ jsx(Heading4, { size: 16 })
11355
11686
  }
11356
11687
  ),
@@ -11379,7 +11710,7 @@ function RichEditorToolbar(props) {
11379
11710
  {
11380
11711
  onMouseDown: cmd(() => editor.chain().focus().toggleStrike().run()),
11381
11712
  active: state.isStrike,
11382
- title: "\uCDE8\uC18C\uC120",
11713
+ title: "\uCDE8\uC18C\uC120 (Ctrl+Shift+S)",
11383
11714
  children: /* @__PURE__ */ jsx(Strikethrough, { size: 16 })
11384
11715
  }
11385
11716
  ),
@@ -11388,7 +11719,7 @@ function RichEditorToolbar(props) {
11388
11719
  {
11389
11720
  onMouseDown: cmd(() => editor.chain().focus().toggleCode().run()),
11390
11721
  active: state.isCode,
11391
- title: "\uC778\uB77C\uC778 \uCF54\uB4DC",
11722
+ title: "\uC778\uB77C\uC778 \uCF54\uB4DC (Ctrl+E)",
11392
11723
  children: /* @__PURE__ */ jsx(Code, { size: 16 })
11393
11724
  }
11394
11725
  ),
@@ -11485,7 +11816,7 @@ function RichEditorToolbar(props) {
11485
11816
  () => editor.chain().focus().toggleBulletList().run()
11486
11817
  ),
11487
11818
  active: state.isBulletList,
11488
- title: "\uAE00\uBA38\uB9AC \uAE30\uD638",
11819
+ title: "\uAE00\uBA38\uB9AC \uAE30\uD638 (Ctrl+Shift+8)",
11489
11820
  children: /* @__PURE__ */ jsx(List, { size: 16 })
11490
11821
  }
11491
11822
  ),
@@ -11496,7 +11827,7 @@ function RichEditorToolbar(props) {
11496
11827
  () => editor.chain().focus().toggleOrderedList().run()
11497
11828
  ),
11498
11829
  active: state.isOrderedList,
11499
- title: "\uBC88\uD638 \uBAA9\uB85D",
11830
+ title: "\uBC88\uD638 \uBAA9\uB85D (Ctrl+Shift+7)",
11500
11831
  children: /* @__PURE__ */ jsx(ListOrdered, { size: 16 })
11501
11832
  }
11502
11833
  ),
@@ -11507,7 +11838,7 @@ function RichEditorToolbar(props) {
11507
11838
  () => editor.chain().focus().toggleBlockquote().run()
11508
11839
  ),
11509
11840
  active: state.isBlockquote,
11510
- title: "\uC778\uC6A9\uAD6C",
11841
+ title: "\uC778\uC6A9\uAD6C (Ctrl+Shift+B)",
11511
11842
  children: /* @__PURE__ */ jsx(Quote, { size: 16 })
11512
11843
  }
11513
11844
  ),
@@ -11515,10 +11846,10 @@ function RichEditorToolbar(props) {
11515
11846
  ToolbarButton,
11516
11847
  {
11517
11848
  onMouseDown: cmd(
11518
- () => editor.chain().focus().toggleCodeBlock().run()
11849
+ () => editor.chain().focus().toggleCodeBlockMerged().run()
11519
11850
  ),
11520
11851
  active: state.isCodeBlock,
11521
- title: "\uCF54\uB4DC \uBE14\uB85D",
11852
+ title: "\uCF54\uB4DC \uBE14\uB85D (Ctrl+Alt+C)",
11522
11853
  children: /* @__PURE__ */ jsx(FileCode, { size: 16 })
11523
11854
  }
11524
11855
  )
@@ -11541,7 +11872,7 @@ function RichEditorToolbar(props) {
11541
11872
  "button",
11542
11873
  {
11543
11874
  type: "button",
11544
- "aria-label": "\uD14C\uC774\uBE14 \uC0BD\uC785",
11875
+ "aria-label": `\uD14C\uC774\uBE14 \uC0BD\uC785 (${tableShortcutLabel("g")})`,
11545
11876
  className: cn(
11546
11877
  "flex h-8 w-8 cursor-pointer items-center justify-center rounded text-sm transition-colors",
11547
11878
  "disabled:cursor-not-allowed disabled:opacity-40",
@@ -11569,46 +11900,15 @@ function RichEditorToolbar(props) {
11569
11900
  ToolbarButton,
11570
11901
  {
11571
11902
  onMouseDown: cmd(() => editor.chain().focus().addRowAfter().run()),
11572
- title: "\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00",
11573
- tooltip: "\uD589 \uCD94\uAC00",
11903
+ title: `\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00 (${tableShortcutLabel("u")})`,
11574
11904
  children: /* @__PURE__ */ jsx(Plus, { size: 14 })
11575
11905
  }
11576
11906
  ),
11577
11907
  /* @__PURE__ */ jsx(
11578
11908
  ToolbarButton,
11579
11909
  {
11580
- onMouseDown: cmd(() => {
11581
- editor.chain().focus().command(({ tr, dispatch, state: state2 }) => {
11582
- const { $anchor } = state2.selection;
11583
- let tableNode = null;
11584
- let tableStart = 0;
11585
- for (let depth = $anchor.depth; depth > 0; depth--) {
11586
- const node = $anchor.node(depth);
11587
- if (node.type.name === "table") {
11588
- tableNode = node;
11589
- tableStart = $anchor.start(depth);
11590
- break;
11591
- }
11592
- }
11593
- if (!tableNode) return false;
11594
- let lastRowStart = 0;
11595
- let lastRowSize = 0;
11596
- let rowCount = 0;
11597
- tableNode.forEach((child, offset) => {
11598
- if (child.type.name !== "tableRow") return;
11599
- rowCount++;
11600
- lastRowStart = tableStart + offset;
11601
- lastRowSize = child.nodeSize;
11602
- });
11603
- if (rowCount <= 1) return false;
11604
- if (dispatch) {
11605
- dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
11606
- }
11607
- return true;
11608
- }).run();
11609
- }),
11610
- title: "\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C",
11611
- tooltip: "\uD589 \uC0AD\uC81C",
11910
+ onMouseDown: cmd(() => editor.chain().focus().deleteLastRow().run()),
11911
+ title: `\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C (${tableShortcutLabel("x")})`,
11612
11912
  children: /* @__PURE__ */ jsx(Minus, { size: 14 })
11613
11913
  }
11614
11914
  ),
@@ -11617,8 +11917,7 @@ function RichEditorToolbar(props) {
11617
11917
  ToolbarButton,
11618
11918
  {
11619
11919
  onMouseDown: cmd(() => editor.chain().focus().addColumnAfter().run()),
11620
- title: "\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00",
11621
- tooltip: "\uC5F4 \uCD94\uAC00",
11920
+ title: `\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00 (${tableShortcutLabel("k")})`,
11622
11921
  children: /* @__PURE__ */ jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R+" })
11623
11922
  }
11624
11923
  ),
@@ -11626,8 +11925,7 @@ function RichEditorToolbar(props) {
11626
11925
  ToolbarButton,
11627
11926
  {
11628
11927
  onMouseDown: cmd(() => editor.chain().focus().deleteColumn().run()),
11629
- title: "\uD604\uC7AC \uC5F4 \uC0AD\uC81C",
11630
- tooltip: "\uC5F4 \uC0AD\uC81C",
11928
+ title: `\uD604\uC7AC \uC5F4 \uC0AD\uC81C (${tableShortcutLabel("l")})`,
11631
11929
  children: /* @__PURE__ */ jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R-" })
11632
11930
  }
11633
11931
  ),
@@ -11637,7 +11935,6 @@ function RichEditorToolbar(props) {
11637
11935
  {
11638
11936
  onMouseDown: cmd(() => editor.chain().focus().deleteTable().run()),
11639
11937
  title: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11640
- tooltip: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11641
11938
  variant: "destructive",
11642
11939
  children: /* @__PURE__ */ jsx(Trash2, { size: 14 })
11643
11940
  }