@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.cjs CHANGED
@@ -31,6 +31,7 @@ var middleware = require('zustand/middleware');
31
31
  var uuid = require('uuid');
32
32
  var react = require('@tiptap/react');
33
33
  var core = require('@tiptap/core');
34
+ var state = require('@tiptap/pm/state');
34
35
  var StarterKit = require('@tiptap/starter-kit');
35
36
  var TextAlign = require('@tiptap/extension-text-align');
36
37
  var extensionImage = require('@tiptap/extension-image');
@@ -6113,9 +6114,11 @@ function releaseStableImageSrc(src) {
6113
6114
  // src/components/FilePreviewViewer/config/utils.ts
6114
6115
  var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "avif", "heic", "heif"]);
6115
6116
  var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
6117
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm"]);
6116
6118
  var MIME_FILE_TYPES = [
6117
6119
  { pattern: /^data:image\//i, type: "image" },
6118
- { pattern: /^data:application\/pdf/i, type: "pdf" }
6120
+ { pattern: /^data:application\/pdf/i, type: "pdf" },
6121
+ { pattern: /^data:video\//i, type: "video" }
6119
6122
  ];
6120
6123
  function normalizeExtension(ext) {
6121
6124
  const lower = ext.replace(/^\./, "").toLowerCase();
@@ -6141,6 +6144,10 @@ function getExtensionFromSrc(src) {
6141
6144
  return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "jpg";
6142
6145
  }
6143
6146
  if (type === "pdf") return "pdf";
6147
+ if (type === "video") {
6148
+ const dataUrlMatch = src.match(/^data:video\/([a-zA-Z0-9+.-]+)/i);
6149
+ return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "mp4";
6150
+ }
6144
6151
  }
6145
6152
  try {
6146
6153
  const url = new URL(src, window.location.origin);
@@ -6161,9 +6168,13 @@ function inferTypeFromUrl(src) {
6161
6168
  const contentType = url.searchParams.get("content-type")?.toLowerCase();
6162
6169
  if (contentType?.includes("pdf")) return "pdf";
6163
6170
  if (contentType?.startsWith("image/")) return "image";
6171
+ if (contentType?.startsWith("video/")) return "video";
6164
6172
  if (pathname.includes(".pdf") || /\/pdf(?:\/|$)/i.test(pathname)) {
6165
6173
  return "pdf";
6166
6174
  }
6175
+ if (Array.from(VIDEO_EXTENSIONS).some((ext) => pathname.includes(`.${ext}`))) {
6176
+ return "video";
6177
+ }
6167
6178
  return "image";
6168
6179
  } catch {
6169
6180
  return null;
@@ -6174,6 +6185,7 @@ function getPreviewFileType(src) {
6174
6185
  if (extension) {
6175
6186
  if (PDF_EXTENSIONS.has(extension)) return "pdf";
6176
6187
  if (IMAGE_EXTENSIONS.has(extension)) return "image";
6188
+ if (VIDEO_EXTENSIONS.has(extension)) return "video";
6177
6189
  }
6178
6190
  for (const { pattern, type } of MIME_FILE_TYPES) {
6179
6191
  if (pattern.test(src)) return type;
@@ -6186,10 +6198,12 @@ function hasKnownExtension(filename) {
6186
6198
  const dotIndex = filename.lastIndexOf(".");
6187
6199
  if (dotIndex <= 0) return false;
6188
6200
  const ext = filename.slice(dotIndex + 1).toLowerCase();
6189
- return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext);
6201
+ return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext);
6190
6202
  }
6191
6203
  function defaultExtensionForType(fileType) {
6192
- return fileType === "pdf" ? "pdf" : "jpg";
6204
+ if (fileType === "pdf") return "pdf";
6205
+ if (fileType === "video") return "mp4";
6206
+ return "jpg";
6193
6207
  }
6194
6208
  function withExtension(name, extension, fileType) {
6195
6209
  if (extension && name.toLowerCase().endsWith(`.${extension}`)) return name;
@@ -6210,7 +6224,7 @@ function getFileLabel(src, index, fileTypeOverride) {
6210
6224
  }
6211
6225
  } catch {
6212
6226
  }
6213
- const labelPrefix = fileType === "pdf" ? "PDF" : "Image";
6227
+ const labelPrefix = fileType === "pdf" ? "PDF" : fileType === "video" ? "Video" : "Image";
6214
6228
  return withExtension(`${labelPrefix} ${index + 1}`, extension, fileType);
6215
6229
  }
6216
6230
  function getAdjacentIndexes(currentIndex, length) {
@@ -6252,11 +6266,14 @@ function FilePreviewViewerContent(props) {
6252
6266
  if (fileType === "pdf") {
6253
6267
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "preview-viewer-container w-[90vw] h-[85vh] max-w-[90vw] max-h-[85vh] flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("iframe", { src, title: alt, className: "w-full h-full rounded bg-white border-0" }) });
6254
6268
  }
6269
+ if (fileType === "video") {
6270
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "preview-viewer-container w-[90vw] h-[85vh] max-w-[90vw] max-h-[85vh] flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("video", { src, controls: true, className: "max-w-full max-h-full rounded bg-black" }) });
6271
+ }
6255
6272
  if (fileType === "unsupported") {
6256
6273
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center gap-3 max-w-md px-6 py-10 text-center", children: [
6257
6274
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "size-12 text-gray-300" }),
6258
6275
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium text-white", children: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD" }),
6259
- /* @__PURE__ */ jsxRuntime.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." })
6276
+ /* @__PURE__ */ jsxRuntime.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." })
6260
6277
  ] });
6261
6278
  }
6262
6279
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative max-w-[85vw] max-h-[85vh] w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "preview-viewer-container flex items-center justify-center w-full h-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -6404,6 +6421,8 @@ function FilePreviewViewerSession(props) {
6404
6421
  [fileTypes, currentIndex, currentFile]
6405
6422
  );
6406
6423
  const isImageFile2 = fileType === "image";
6424
+ const isVideoFile = fileType === "video";
6425
+ const isDownloadableFile = isImageFile2 || isVideoFile;
6407
6426
  const fileLabel = React6.useMemo(
6408
6427
  () => fileNames?.[currentIndex] ?? (currentFile ? getFileLabel(currentFile, currentIndex, fileTypes?.[currentIndex]) : ""),
6409
6428
  [currentFile, currentIndex, fileTypes, fileNames]
@@ -6421,7 +6440,7 @@ function FilePreviewViewerSession(props) {
6421
6440
  resetTransform();
6422
6441
  }, [fileArray.length, resetTransform]);
6423
6442
  const handleDownload = React6.useCallback(async () => {
6424
- if (!currentFile || !isImageFile2) return;
6443
+ if (!currentFile || !isDownloadableFile) return;
6425
6444
  try {
6426
6445
  const response = await fetch(currentFile);
6427
6446
  const blob = await response.blob();
@@ -6436,7 +6455,7 @@ function FilePreviewViewerSession(props) {
6436
6455
  } catch (error) {
6437
6456
  console.error("\uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328:", error);
6438
6457
  }
6439
- }, [currentFile, fileLabel, isImageFile2]);
6458
+ }, [currentFile, fileLabel, isDownloadableFile]);
6440
6459
  const handleZoomIn = React6.useCallback(() => {
6441
6460
  setZoom((prev) => Math.min(prev + 0.25, 3));
6442
6461
  }, []);
@@ -6513,7 +6532,7 @@ function FilePreviewViewerSession(props) {
6513
6532
  if (!currentFile) return null;
6514
6533
  const showZoom = features.zoom && isImageFile2;
6515
6534
  const showRotate = features.rotate && isImageFile2;
6516
- const showDownload = features.download && isImageFile2;
6535
+ const showDownload = features.download && isDownloadableFile;
6517
6536
  return /* @__PURE__ */ jsxRuntime.jsxs(
6518
6537
  "div",
6519
6538
  {
@@ -10506,6 +10525,161 @@ var MentionList = React6.forwardRef((props, ref) => {
10506
10525
  );
10507
10526
  });
10508
10527
  MentionList.displayName = "MentionList";
10528
+ var IMAGE_CLASS = "max-w-full h-auto rounded-lg my-4";
10529
+ var VIDEO_CLASS = "rich-editor-video";
10530
+ var MIN_WIDTH = 48;
10531
+ var ALIGN_OPTIONS = [
10532
+ { value: "left", Icon: lucideReact.AlignLeft, label: "\uC67C\uCABD\uC73C\uB85C \uC774\uB3D9" },
10533
+ { value: "center", Icon: lucideReact.AlignCenter, label: "\uAC00\uC6B4\uB370\uB85C \uC774\uB3D9" },
10534
+ { value: "right", Icon: lucideReact.AlignRight, label: "\uC624\uB978\uCABD\uC73C\uB85C \uC774\uB3D9" }
10535
+ ];
10536
+ function clamp(value, min, max) {
10537
+ return Math.min(Math.max(value, min), max);
10538
+ }
10539
+ function getNaturalSize(mediaEl) {
10540
+ if (mediaEl instanceof HTMLVideoElement) return [mediaEl.videoWidth, mediaEl.videoHeight];
10541
+ return [mediaEl.naturalWidth, mediaEl.naturalHeight];
10542
+ }
10543
+ function stopAndRun(fn) {
10544
+ return (e) => {
10545
+ e.preventDefault();
10546
+ e.stopPropagation();
10547
+ fn();
10548
+ };
10549
+ }
10550
+ function ResizableMediaNodeView(props) {
10551
+ const { node, updateAttributes, mediaType } = props;
10552
+ const { src, alt, title, width, height, align } = node.attrs;
10553
+ const aspectRatioRef = React6.useRef(null);
10554
+ const dragStateRef = React6.useRef(null);
10555
+ const [liveSize, setLiveSize] = React6.useState(null);
10556
+ const [isDragging, setIsDragging] = React6.useState(false);
10557
+ const attrWidth = width ? Number(width) : void 0;
10558
+ const attrHeight = height ? Number(height) : void 0;
10559
+ const currentWidth = liveSize?.width ?? attrWidth;
10560
+ const currentHeight = liveSize?.height ?? attrHeight;
10561
+ const currentAlign = align === "center" || align === "right" ? align : "left";
10562
+ if (attrWidth && attrHeight && !aspectRatioRef.current) {
10563
+ aspectRatioRef.current = attrHeight / attrWidth;
10564
+ }
10565
+ function captureNaturalSize(naturalWidth, naturalHeight) {
10566
+ if (!aspectRatioRef.current && naturalWidth > 0) {
10567
+ aspectRatioRef.current = naturalHeight / naturalWidth;
10568
+ }
10569
+ }
10570
+ function handleImageLoad(e) {
10571
+ captureNaturalSize(e.currentTarget.naturalWidth, e.currentTarget.naturalHeight);
10572
+ }
10573
+ function handleVideoLoadedMetadata(e) {
10574
+ captureNaturalSize(e.currentTarget.videoWidth, e.currentTarget.videoHeight);
10575
+ }
10576
+ function handlePointerDown(e) {
10577
+ e.preventDefault();
10578
+ e.stopPropagation();
10579
+ const mediaEl = e.currentTarget.previousElementSibling;
10580
+ if (!mediaEl) return;
10581
+ const [naturalWidth, naturalHeight] = getNaturalSize(mediaEl);
10582
+ captureNaturalSize(naturalWidth, naturalHeight);
10583
+ const startWidth = currentWidth ?? mediaEl.getBoundingClientRect().width;
10584
+ const editorRoot = mediaEl.closest(".tiptap");
10585
+ const maxWidth = editorRoot?.clientWidth ?? startWidth;
10586
+ dragStateRef.current = { startX: e.clientX, startWidth, maxWidth };
10587
+ e.currentTarget.setPointerCapture(e.pointerId);
10588
+ setIsDragging(true);
10589
+ }
10590
+ function handlePointerMove(e) {
10591
+ const dragState = dragStateRef.current;
10592
+ if (!dragState) return;
10593
+ const delta = e.clientX - dragState.startX;
10594
+ const ratio = aspectRatioRef.current ?? 1;
10595
+ const nextWidth = Math.round(clamp(dragState.startWidth + delta, MIN_WIDTH, dragState.maxWidth));
10596
+ const nextHeight = Math.round(nextWidth * ratio);
10597
+ setLiveSize({ width: nextWidth, height: nextHeight });
10598
+ }
10599
+ function handlePointerUp(e) {
10600
+ if (!dragStateRef.current) return;
10601
+ e.currentTarget.releasePointerCapture(e.pointerId);
10602
+ dragStateRef.current = null;
10603
+ setIsDragging(false);
10604
+ setLiveSize((size2) => {
10605
+ if (size2) {
10606
+ updateAttributes({
10607
+ width: size2.width,
10608
+ height: size2.height,
10609
+ style: `width: ${size2.width}px; height: ${size2.height}px;`
10610
+ });
10611
+ }
10612
+ return null;
10613
+ });
10614
+ }
10615
+ return /* @__PURE__ */ jsxRuntime.jsx(
10616
+ react.NodeViewWrapper,
10617
+ {
10618
+ className: "rich-editor-media-row",
10619
+ style: { textAlign: currentAlign },
10620
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn("rich-editor-media-view", isDragging && "is-dragging"), children: [
10621
+ mediaType === "video" ? /* @__PURE__ */ jsxRuntime.jsx(
10622
+ "video",
10623
+ {
10624
+ src,
10625
+ controls: true,
10626
+ width: currentWidth,
10627
+ height: currentHeight,
10628
+ className: VIDEO_CLASS,
10629
+ onLoadedMetadata: handleVideoLoadedMetadata
10630
+ }
10631
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
10632
+ "img",
10633
+ {
10634
+ src,
10635
+ alt: alt ?? "",
10636
+ title: title ?? void 0,
10637
+ width: currentWidth,
10638
+ height: currentHeight,
10639
+ className: IMAGE_CLASS,
10640
+ draggable: false,
10641
+ onLoad: handleImageLoad
10642
+ }
10643
+ ),
10644
+ /* @__PURE__ */ jsxRuntime.jsx(
10645
+ "div",
10646
+ {
10647
+ className: cn("rich-editor-resize-handle", isDragging && "is-dragging"),
10648
+ onPointerDown: handlePointerDown,
10649
+ onPointerMove: handlePointerMove,
10650
+ onPointerUp: handlePointerUp
10651
+ }
10652
+ ),
10653
+ isDragging && liveSize && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rich-editor-resize-label", children: [
10654
+ liveSize.width,
10655
+ " \xD7 ",
10656
+ liveSize.height
10657
+ ] }),
10658
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rich-editor-media-align-popover", children: ALIGN_OPTIONS.map(({ value, Icon: Icon2, label }) => /* @__PURE__ */ jsxRuntime.jsx(
10659
+ "button",
10660
+ {
10661
+ type: "button",
10662
+ "aria-label": label,
10663
+ title: label,
10664
+ className: cn(
10665
+ "rich-editor-media-align-btn",
10666
+ currentAlign === value && "is-active"
10667
+ ),
10668
+ onMouseDown: stopAndRun(() => updateAttributes({ align: value })),
10669
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: 14 })
10670
+ },
10671
+ value
10672
+ )) })
10673
+ ] })
10674
+ }
10675
+ );
10676
+ }
10677
+ function ResizableImageNodeView(props) {
10678
+ return /* @__PURE__ */ jsxRuntime.jsx(ResizableMediaNodeView, { ...props, mediaType: "image" });
10679
+ }
10680
+ function ResizableVideoNodeView(props) {
10681
+ return /* @__PURE__ */ jsxRuntime.jsx(ResizableMediaNodeView, { ...props, mediaType: "video" });
10682
+ }
10509
10683
 
10510
10684
  // src/components/RichEditor/config/extensions.ts
10511
10685
  function buildExtensions(config) {
@@ -10520,7 +10694,14 @@ function buildExtensions(config) {
10520
10694
  accentTextColor,
10521
10695
  zIndex
10522
10696
  } = config;
10523
- const exts = [extensionTextStyle.TextStyleKit, buildMarkResetOnEnter(), buildRedundantListMarkerStrip()];
10697
+ const exts = [
10698
+ extensionTextStyle.TextStyleKit,
10699
+ buildMarkResetOnEnter(),
10700
+ buildRedundantListMarkerStrip()
10701
+ ];
10702
+ if (toolbar.codeBlock !== false) {
10703
+ exts.push(buildCodeBlockMerge());
10704
+ }
10524
10705
  const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
10525
10706
  exts.push(
10526
10707
  StarterKit__default.default.configure({
@@ -10546,7 +10727,7 @@ function buildExtensions(config) {
10546
10727
  exts.push(buildCustomTextAlign());
10547
10728
  }
10548
10729
  if (toolbar.image) {
10549
- exts.push(buildCustomImage());
10730
+ exts.push(buildCustomImage(), buildCustomVideo());
10550
10731
  }
10551
10732
  if (toolbar.placeholder !== void 0) {
10552
10733
  exts.push(
@@ -10614,7 +10795,8 @@ function buildExtensions(config) {
10614
10795
  extensionTable.Table.configure({ resizable: true }),
10615
10796
  extensionTable.TableRow,
10616
10797
  extensionTable.TableHeader,
10617
- extensionTable.TableCell
10798
+ extensionTable.TableCell,
10799
+ buildTableCommands()
10618
10800
  );
10619
10801
  }
10620
10802
  return exts;
@@ -10647,6 +10829,17 @@ function buildCustomTextAlign() {
10647
10829
  defaultAlignment: "left"
10648
10830
  });
10649
10831
  }
10832
+ function buildAlignAttribute() {
10833
+ return {
10834
+ align: {
10835
+ default: null,
10836
+ renderHTML: (attrs) => {
10837
+ if (attrs.align !== "center" && attrs.align !== "right") return {};
10838
+ return { class: `rich-editor-align-${attrs.align}` };
10839
+ }
10840
+ }
10841
+ };
10842
+ }
10650
10843
  function buildCustomImage() {
10651
10844
  const CustomImage = extensionImage.Image.extend({
10652
10845
  addAttributes() {
@@ -10663,8 +10856,12 @@ function buildCustomImage() {
10663
10856
  style: {
10664
10857
  default: null,
10665
10858
  renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
10666
- }
10859
+ },
10860
+ ...buildAlignAttribute()
10667
10861
  };
10862
+ },
10863
+ addNodeView() {
10864
+ return react.ReactNodeViewRenderer(ResizableImageNodeView);
10668
10865
  }
10669
10866
  });
10670
10867
  return CustomImage.configure({
@@ -10673,6 +10870,134 @@ function buildCustomImage() {
10673
10870
  allowBase64: true
10674
10871
  });
10675
10872
  }
10873
+ function buildCustomVideo() {
10874
+ return core.Node.create({
10875
+ name: "video",
10876
+ group: "block",
10877
+ atom: true,
10878
+ selectable: true,
10879
+ addOptions() {
10880
+ return { HTMLAttributes: {} };
10881
+ },
10882
+ addAttributes() {
10883
+ return {
10884
+ src: { default: null },
10885
+ width: {
10886
+ default: null,
10887
+ renderHTML: (attrs) => attrs.width ? { width: attrs.width } : {}
10888
+ },
10889
+ height: {
10890
+ default: null,
10891
+ renderHTML: (attrs) => attrs.height ? { height: attrs.height } : {}
10892
+ },
10893
+ style: {
10894
+ default: null,
10895
+ renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
10896
+ },
10897
+ ...buildAlignAttribute()
10898
+ };
10899
+ },
10900
+ parseHTML() {
10901
+ return [{ tag: "video[src]" }];
10902
+ },
10903
+ renderHTML({ HTMLAttributes }) {
10904
+ return ["video", core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
10905
+ },
10906
+ addNodeView() {
10907
+ return react.ReactNodeViewRenderer(ResizableVideoNodeView);
10908
+ }
10909
+ }).configure({
10910
+ HTMLAttributes: { class: "rich-editor-video", controls: "true" }
10911
+ });
10912
+ }
10913
+ function buildTableCommands() {
10914
+ return core.Extension.create({
10915
+ name: "tableShortcuts",
10916
+ addCommands() {
10917
+ return {
10918
+ deleteLastRow: () => ({ tr, dispatch, state }) => {
10919
+ const { $anchor } = state.selection;
10920
+ let tableNode = null;
10921
+ let tableStart = 0;
10922
+ for (let depth = $anchor.depth; depth > 0; depth--) {
10923
+ const node = $anchor.node(depth);
10924
+ if (node.type.name === "table") {
10925
+ tableNode = node;
10926
+ tableStart = $anchor.start(depth);
10927
+ break;
10928
+ }
10929
+ }
10930
+ if (!tableNode) return false;
10931
+ let lastRowStart = 0;
10932
+ let lastRowSize = 0;
10933
+ let rowCount = 0;
10934
+ tableNode.forEach((child, offset) => {
10935
+ if (child.type.name !== "tableRow") return;
10936
+ rowCount++;
10937
+ lastRowStart = tableStart + offset;
10938
+ lastRowSize = child.nodeSize;
10939
+ });
10940
+ if (rowCount <= 1) return false;
10941
+ if (dispatch) {
10942
+ dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
10943
+ }
10944
+ return true;
10945
+ }
10946
+ };
10947
+ },
10948
+ addKeyboardShortcuts() {
10949
+ const mod = core.isMacOS() ? "Cmd" : "Alt";
10950
+ return {
10951
+ [`${mod}-Shift-g`]: ({ editor }) => {
10952
+ if (editor.isActive("table")) return false;
10953
+ return editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
10954
+ },
10955
+ [`${mod}-Shift-u`]: ({ editor }) => editor.chain().focus().addRowAfter().run(),
10956
+ [`${mod}-Shift-x`]: ({ editor }) => editor.chain().focus().deleteLastRow().run(),
10957
+ [`${mod}-Shift-k`]: ({ editor }) => editor.chain().focus().addColumnAfter().run(),
10958
+ [`${mod}-Shift-l`]: ({ editor }) => editor.chain().focus().deleteColumn().run()
10959
+ };
10960
+ }
10961
+ });
10962
+ }
10963
+ function buildCodeBlockMerge() {
10964
+ return core.Extension.create({
10965
+ name: "codeBlockMerge",
10966
+ addCommands() {
10967
+ return {
10968
+ toggleCodeBlockMerged: () => ({ editor, state: state$1, tr, dispatch, commands }) => {
10969
+ if (editor.isActive("codeBlock")) {
10970
+ return commands.toggleCodeBlock();
10971
+ }
10972
+ const { selection } = state$1;
10973
+ const blocks = [];
10974
+ state$1.doc.nodesBetween(selection.from, selection.to, (node) => {
10975
+ if (node.isTextblock) {
10976
+ blocks.push(node);
10977
+ return false;
10978
+ }
10979
+ return true;
10980
+ });
10981
+ if (blocks.length <= 1) {
10982
+ return commands.toggleCodeBlock();
10983
+ }
10984
+ const codeBlockType = state$1.schema.nodes.codeBlock;
10985
+ if (!codeBlockType) return commands.toggleCodeBlock();
10986
+ const mergedText = blocks.map((b) => b.textContent).join("\n");
10987
+ const newNode = mergedText ? codeBlockType.create(null, state$1.schema.text(mergedText)) : codeBlockType.create();
10988
+ if (dispatch) {
10989
+ const { from, to } = selection;
10990
+ tr.replaceWith(from, to, newNode);
10991
+ const cursorPos = Math.min(from + newNode.nodeSize - 1, tr.doc.content.size);
10992
+ tr.setSelection(state.TextSelection.create(tr.doc, cursorPos));
10993
+ dispatch(tr);
10994
+ }
10995
+ return true;
10996
+ }
10997
+ };
10998
+ }
10999
+ });
11000
+ }
10676
11001
  function buildMarkResetOnEnter() {
10677
11002
  return core.Extension.create({
10678
11003
  name: "markResetOnEnter",
@@ -10881,8 +11206,8 @@ function useRichEditorFiles(options = {}) {
10881
11206
  toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
10882
11207
  }
10883
11208
  if (maxFiles) {
10884
- const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
10885
- const currentCount = attachmentsRef.current.length + imageCount;
11209
+ const inlineMediaCount = editor ? (editor.getHTML().match(/<(img|video)\b/gi) ?? []).length : 0;
11210
+ const currentCount = attachmentsRef.current.length + inlineMediaCount;
10886
11211
  const remaining = Math.max(0, maxFiles - currentCount);
10887
11212
  if (accepted.length > remaining) {
10888
11213
  toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
@@ -10903,6 +11228,10 @@ function useRichEditorFiles(options = {}) {
10903
11228
  if (!editor) continue;
10904
11229
  editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
10905
11230
  editor.commands.setTextSelection(editor.state.selection.to);
11231
+ } else if (file.type.startsWith("video/")) {
11232
+ if (!editor) continue;
11233
+ editor.chain().focus().insertContent({ type: "video", attrs: { src: url } }).run();
11234
+ editor.commands.setTextSelection(editor.state.selection.to);
10906
11235
  } else {
10907
11236
  setAttachments((prev) => [
10908
11237
  ...prev,
@@ -11017,7 +11346,7 @@ function useRichEditor(options = {}) {
11017
11346
  onFileUpload,
11018
11347
  initialAttachments: initialSplit.attachments
11019
11348
  });
11020
- const [imageCount, setImageCount] = React6.useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
11349
+ const [imageCount, setImageCount] = React6.useState(() => (initialSplit.html.match(/<(img|video)\b/gi) ?? []).length);
11021
11350
  const attachmentsRef = React6.useRef(attachments);
11022
11351
  attachmentsRef.current = attachments;
11023
11352
  const editorRef = React6.useRef(null);
@@ -11061,7 +11390,7 @@ function useRichEditor(options = {}) {
11061
11390
  editorRef.current = editor;
11062
11391
  React6.useEffect(() => {
11063
11392
  if (!editor) return;
11064
- const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
11393
+ const sync = () => setImageCount((editor.getHTML().match(/<(img|video)\b/gi) ?? []).length);
11065
11394
  sync();
11066
11395
  editor.on("transaction", sync);
11067
11396
  return () => {
@@ -11253,9 +11582,9 @@ function TextColorPicker({ editor, colors, currentColor, onClose }) {
11253
11582
  ] });
11254
11583
  }
11255
11584
  function ToolbarButton(props) {
11256
- const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
11585
+ const { onMouseDown, active, disabled, title, variant = "default", children } = props;
11257
11586
  const theme = useRichEditorTheme();
11258
- const btn = /* @__PURE__ */ jsxRuntime.jsx(
11587
+ return /* @__PURE__ */ jsxRuntime.jsx(
11259
11588
  "button",
11260
11589
  {
11261
11590
  type: "button",
@@ -11270,8 +11599,6 @@ function ToolbarButton(props) {
11270
11599
  children
11271
11600
  }
11272
11601
  );
11273
- if (!tooltip) return btn;
11274
- return /* @__PURE__ */ jsxRuntime.jsx(Tooltip2, { content: tooltip, position: "bottom", asChild: true, children: btn });
11275
11602
  }
11276
11603
  function Divider() {
11277
11604
  const theme = useRichEditorTheme();
@@ -11284,6 +11611,10 @@ function cmd(fn) {
11284
11611
  fn();
11285
11612
  };
11286
11613
  }
11614
+ function tableShortcutLabel(letter) {
11615
+ const mod = core.isMacOS() ? "Cmd" : "Alt";
11616
+ return `${mod}+Shift+${letter.toUpperCase()}`;
11617
+ }
11287
11618
  function RichEditorToolbar(props) {
11288
11619
  const { editor, toolbar = {}, className, zIndex, onImageButtonClick } = props;
11289
11620
  const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
@@ -11353,7 +11684,7 @@ function RichEditorToolbar(props) {
11353
11684
  () => editor.chain().focus().toggleHeading({ level: 1 }).run()
11354
11685
  ),
11355
11686
  active: state.isH1,
11356
- title: "\uC81C\uBAA9 1 (H1)",
11687
+ title: "\uC81C\uBAA9 1 (Ctrl+Alt+1)",
11357
11688
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading1, { size: 16 })
11358
11689
  }
11359
11690
  ),
@@ -11364,7 +11695,7 @@ function RichEditorToolbar(props) {
11364
11695
  () => editor.chain().focus().toggleHeading({ level: 2 }).run()
11365
11696
  ),
11366
11697
  active: state.isH2,
11367
- title: "\uC81C\uBAA9 2 (H2)",
11698
+ title: "\uC81C\uBAA9 2 (Ctrl+Alt+2)",
11368
11699
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading2, { size: 16 })
11369
11700
  }
11370
11701
  ),
@@ -11375,7 +11706,7 @@ function RichEditorToolbar(props) {
11375
11706
  () => editor.chain().focus().toggleHeading({ level: 3 }).run()
11376
11707
  ),
11377
11708
  active: state.isH3,
11378
- title: "\uC81C\uBAA9 3 (H3)",
11709
+ title: "\uC81C\uBAA9 3 (Ctrl+Alt+3)",
11379
11710
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading3, { size: 16 })
11380
11711
  }
11381
11712
  ),
@@ -11386,7 +11717,7 @@ function RichEditorToolbar(props) {
11386
11717
  () => editor.chain().focus().toggleHeading({ level: 4 }).run()
11387
11718
  ),
11388
11719
  active: state.isH4,
11389
- title: "\uC81C\uBAA9 4 (H4)",
11720
+ title: "\uC81C\uBAA9 4 (Ctrl+Alt+4)",
11390
11721
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading4, { size: 16 })
11391
11722
  }
11392
11723
  ),
@@ -11415,7 +11746,7 @@ function RichEditorToolbar(props) {
11415
11746
  {
11416
11747
  onMouseDown: cmd(() => editor.chain().focus().toggleStrike().run()),
11417
11748
  active: state.isStrike,
11418
- title: "\uCDE8\uC18C\uC120",
11749
+ title: "\uCDE8\uC18C\uC120 (Ctrl+Shift+S)",
11419
11750
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Strikethrough, { size: 16 })
11420
11751
  }
11421
11752
  ),
@@ -11424,7 +11755,7 @@ function RichEditorToolbar(props) {
11424
11755
  {
11425
11756
  onMouseDown: cmd(() => editor.chain().focus().toggleCode().run()),
11426
11757
  active: state.isCode,
11427
- title: "\uC778\uB77C\uC778 \uCF54\uB4DC",
11758
+ title: "\uC778\uB77C\uC778 \uCF54\uB4DC (Ctrl+E)",
11428
11759
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { size: 16 })
11429
11760
  }
11430
11761
  ),
@@ -11521,7 +11852,7 @@ function RichEditorToolbar(props) {
11521
11852
  () => editor.chain().focus().toggleBulletList().run()
11522
11853
  ),
11523
11854
  active: state.isBulletList,
11524
- title: "\uAE00\uBA38\uB9AC \uAE30\uD638",
11855
+ title: "\uAE00\uBA38\uB9AC \uAE30\uD638 (Ctrl+Shift+8)",
11525
11856
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, { size: 16 })
11526
11857
  }
11527
11858
  ),
@@ -11532,7 +11863,7 @@ function RichEditorToolbar(props) {
11532
11863
  () => editor.chain().focus().toggleOrderedList().run()
11533
11864
  ),
11534
11865
  active: state.isOrderedList,
11535
- title: "\uBC88\uD638 \uBAA9\uB85D",
11866
+ title: "\uBC88\uD638 \uBAA9\uB85D (Ctrl+Shift+7)",
11536
11867
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListOrdered, { size: 16 })
11537
11868
  }
11538
11869
  ),
@@ -11543,7 +11874,7 @@ function RichEditorToolbar(props) {
11543
11874
  () => editor.chain().focus().toggleBlockquote().run()
11544
11875
  ),
11545
11876
  active: state.isBlockquote,
11546
- title: "\uC778\uC6A9\uAD6C",
11877
+ title: "\uC778\uC6A9\uAD6C (Ctrl+Shift+B)",
11547
11878
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Quote, { size: 16 })
11548
11879
  }
11549
11880
  ),
@@ -11551,10 +11882,10 @@ function RichEditorToolbar(props) {
11551
11882
  ToolbarButton,
11552
11883
  {
11553
11884
  onMouseDown: cmd(
11554
- () => editor.chain().focus().toggleCodeBlock().run()
11885
+ () => editor.chain().focus().toggleCodeBlockMerged().run()
11555
11886
  ),
11556
11887
  active: state.isCodeBlock,
11557
- title: "\uCF54\uB4DC \uBE14\uB85D",
11888
+ title: "\uCF54\uB4DC \uBE14\uB85D (Ctrl+Alt+C)",
11558
11889
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileCode, { size: 16 })
11559
11890
  }
11560
11891
  )
@@ -11577,7 +11908,7 @@ function RichEditorToolbar(props) {
11577
11908
  "button",
11578
11909
  {
11579
11910
  type: "button",
11580
- "aria-label": "\uD14C\uC774\uBE14 \uC0BD\uC785",
11911
+ "aria-label": `\uD14C\uC774\uBE14 \uC0BD\uC785 (${tableShortcutLabel("g")})`,
11581
11912
  className: cn(
11582
11913
  "flex h-8 w-8 cursor-pointer items-center justify-center rounded text-sm transition-colors",
11583
11914
  "disabled:cursor-not-allowed disabled:opacity-40",
@@ -11605,46 +11936,15 @@ function RichEditorToolbar(props) {
11605
11936
  ToolbarButton,
11606
11937
  {
11607
11938
  onMouseDown: cmd(() => editor.chain().focus().addRowAfter().run()),
11608
- title: "\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00",
11609
- tooltip: "\uD589 \uCD94\uAC00",
11939
+ title: `\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00 (${tableShortcutLabel("u")})`,
11610
11940
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 })
11611
11941
  }
11612
11942
  ),
11613
11943
  /* @__PURE__ */ jsxRuntime.jsx(
11614
11944
  ToolbarButton,
11615
11945
  {
11616
- onMouseDown: cmd(() => {
11617
- editor.chain().focus().command(({ tr, dispatch, state: state2 }) => {
11618
- const { $anchor } = state2.selection;
11619
- let tableNode = null;
11620
- let tableStart = 0;
11621
- for (let depth = $anchor.depth; depth > 0; depth--) {
11622
- const node = $anchor.node(depth);
11623
- if (node.type.name === "table") {
11624
- tableNode = node;
11625
- tableStart = $anchor.start(depth);
11626
- break;
11627
- }
11628
- }
11629
- if (!tableNode) return false;
11630
- let lastRowStart = 0;
11631
- let lastRowSize = 0;
11632
- let rowCount = 0;
11633
- tableNode.forEach((child, offset) => {
11634
- if (child.type.name !== "tableRow") return;
11635
- rowCount++;
11636
- lastRowStart = tableStart + offset;
11637
- lastRowSize = child.nodeSize;
11638
- });
11639
- if (rowCount <= 1) return false;
11640
- if (dispatch) {
11641
- dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
11642
- }
11643
- return true;
11644
- }).run();
11645
- }),
11646
- title: "\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C",
11647
- tooltip: "\uD589 \uC0AD\uC81C",
11946
+ onMouseDown: cmd(() => editor.chain().focus().deleteLastRow().run()),
11947
+ title: `\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C (${tableShortcutLabel("x")})`,
11648
11948
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { size: 14 })
11649
11949
  }
11650
11950
  ),
@@ -11653,8 +11953,7 @@ function RichEditorToolbar(props) {
11653
11953
  ToolbarButton,
11654
11954
  {
11655
11955
  onMouseDown: cmd(() => editor.chain().focus().addColumnAfter().run()),
11656
- title: "\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00",
11657
- tooltip: "\uC5F4 \uCD94\uAC00",
11956
+ title: `\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00 (${tableShortcutLabel("k")})`,
11658
11957
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R+" })
11659
11958
  }
11660
11959
  ),
@@ -11662,8 +11961,7 @@ function RichEditorToolbar(props) {
11662
11961
  ToolbarButton,
11663
11962
  {
11664
11963
  onMouseDown: cmd(() => editor.chain().focus().deleteColumn().run()),
11665
- title: "\uD604\uC7AC \uC5F4 \uC0AD\uC81C",
11666
- tooltip: "\uC5F4 \uC0AD\uC81C",
11964
+ title: `\uD604\uC7AC \uC5F4 \uC0AD\uC81C (${tableShortcutLabel("l")})`,
11667
11965
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R-" })
11668
11966
  }
11669
11967
  ),
@@ -11673,7 +11971,6 @@ function RichEditorToolbar(props) {
11673
11971
  {
11674
11972
  onMouseDown: cmd(() => editor.chain().focus().deleteTable().run()),
11675
11973
  title: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11676
- tooltip: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11677
11974
  variant: "destructive",
11678
11975
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 14 })
11679
11976
  }