@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 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');
@@ -1798,7 +1799,8 @@ var ToastManager = class _ToastManager {
1798
1799
  duration: props.duration ?? perType.duration ?? base.duration ?? 1500,
1799
1800
  style: Object.keys(style).length > 0 ? style : void 0,
1800
1801
  className: className || void 0,
1801
- iconTheme: props.iconTheme ?? perType.iconTheme ?? base.iconTheme
1802
+ iconTheme: props.iconTheme ?? perType.iconTheme ?? base.iconTheme,
1803
+ icon: props.icon ?? perType.icon ?? base.icon
1802
1804
  };
1803
1805
  }
1804
1806
  registerContainer(position, setToasts) {
@@ -2109,7 +2111,7 @@ function ToastItemCard(props) {
2109
2111
  onClick: handleClick,
2110
2112
  children: [
2111
2113
  toast2.props.icon || getDefaultIcon(toast2.props.type || "info", toast2.props.iconTheme),
2112
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 text-sm font-medium", children: toast2.props.toast }),
2114
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `flex-1 font-medium ${hasCustomStyle ? "" : "text-sm"}`, children: toast2.props.toast }),
2113
2115
  toast2.props.showCloseButton === true && /* @__PURE__ */ jsxRuntime.jsx(
2114
2116
  "button",
2115
2117
  {
@@ -6112,9 +6114,11 @@ function releaseStableImageSrc(src) {
6112
6114
  // src/components/FilePreviewViewer/config/utils.ts
6113
6115
  var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "webp", "svg", "bmp", "avif", "heic", "heif"]);
6114
6116
  var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
6117
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "mov", "webm"]);
6115
6118
  var MIME_FILE_TYPES = [
6116
6119
  { pattern: /^data:image\//i, type: "image" },
6117
- { pattern: /^data:application\/pdf/i, type: "pdf" }
6120
+ { pattern: /^data:application\/pdf/i, type: "pdf" },
6121
+ { pattern: /^data:video\//i, type: "video" }
6118
6122
  ];
6119
6123
  function normalizeExtension(ext) {
6120
6124
  const lower = ext.replace(/^\./, "").toLowerCase();
@@ -6140,6 +6144,10 @@ function getExtensionFromSrc(src) {
6140
6144
  return dataUrlMatch ? normalizeExtension(dataUrlMatch[1] ?? "") : "jpg";
6141
6145
  }
6142
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
+ }
6143
6151
  }
6144
6152
  try {
6145
6153
  const url = new URL(src, window.location.origin);
@@ -6160,9 +6168,13 @@ function inferTypeFromUrl(src) {
6160
6168
  const contentType = url.searchParams.get("content-type")?.toLowerCase();
6161
6169
  if (contentType?.includes("pdf")) return "pdf";
6162
6170
  if (contentType?.startsWith("image/")) return "image";
6171
+ if (contentType?.startsWith("video/")) return "video";
6163
6172
  if (pathname.includes(".pdf") || /\/pdf(?:\/|$)/i.test(pathname)) {
6164
6173
  return "pdf";
6165
6174
  }
6175
+ if (Array.from(VIDEO_EXTENSIONS).some((ext) => pathname.includes(`.${ext}`))) {
6176
+ return "video";
6177
+ }
6166
6178
  return "image";
6167
6179
  } catch {
6168
6180
  return null;
@@ -6173,6 +6185,7 @@ function getPreviewFileType(src) {
6173
6185
  if (extension) {
6174
6186
  if (PDF_EXTENSIONS.has(extension)) return "pdf";
6175
6187
  if (IMAGE_EXTENSIONS.has(extension)) return "image";
6188
+ if (VIDEO_EXTENSIONS.has(extension)) return "video";
6176
6189
  }
6177
6190
  for (const { pattern, type } of MIME_FILE_TYPES) {
6178
6191
  if (pattern.test(src)) return type;
@@ -6185,10 +6198,12 @@ function hasKnownExtension(filename) {
6185
6198
  const dotIndex = filename.lastIndexOf(".");
6186
6199
  if (dotIndex <= 0) return false;
6187
6200
  const ext = filename.slice(dotIndex + 1).toLowerCase();
6188
- return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext);
6201
+ return IMAGE_EXTENSIONS.has(ext) || PDF_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext);
6189
6202
  }
6190
6203
  function defaultExtensionForType(fileType) {
6191
- return fileType === "pdf" ? "pdf" : "jpg";
6204
+ if (fileType === "pdf") return "pdf";
6205
+ if (fileType === "video") return "mp4";
6206
+ return "jpg";
6192
6207
  }
6193
6208
  function withExtension(name, extension, fileType) {
6194
6209
  if (extension && name.toLowerCase().endsWith(`.${extension}`)) return name;
@@ -6209,7 +6224,7 @@ function getFileLabel(src, index, fileTypeOverride) {
6209
6224
  }
6210
6225
  } catch {
6211
6226
  }
6212
- const labelPrefix = fileType === "pdf" ? "PDF" : "Image";
6227
+ const labelPrefix = fileType === "pdf" ? "PDF" : fileType === "video" ? "Video" : "Image";
6213
6228
  return withExtension(`${labelPrefix} ${index + 1}`, extension, fileType);
6214
6229
  }
6215
6230
  function getAdjacentIndexes(currentIndex, length) {
@@ -6251,11 +6266,14 @@ function FilePreviewViewerContent(props) {
6251
6266
  if (fileType === "pdf") {
6252
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" }) });
6253
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
+ }
6254
6272
  if (fileType === "unsupported") {
6255
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: [
6256
6274
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "size-12 text-gray-300" }),
6257
6275
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium text-white", children: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD" }),
6258
- /* @__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." })
6259
6277
  ] });
6260
6278
  }
6261
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(
@@ -6403,6 +6421,8 @@ function FilePreviewViewerSession(props) {
6403
6421
  [fileTypes, currentIndex, currentFile]
6404
6422
  );
6405
6423
  const isImageFile2 = fileType === "image";
6424
+ const isVideoFile = fileType === "video";
6425
+ const isDownloadableFile = isImageFile2 || isVideoFile;
6406
6426
  const fileLabel = React6.useMemo(
6407
6427
  () => fileNames?.[currentIndex] ?? (currentFile ? getFileLabel(currentFile, currentIndex, fileTypes?.[currentIndex]) : ""),
6408
6428
  [currentFile, currentIndex, fileTypes, fileNames]
@@ -6420,7 +6440,7 @@ function FilePreviewViewerSession(props) {
6420
6440
  resetTransform();
6421
6441
  }, [fileArray.length, resetTransform]);
6422
6442
  const handleDownload = React6.useCallback(async () => {
6423
- if (!currentFile || !isImageFile2) return;
6443
+ if (!currentFile || !isDownloadableFile) return;
6424
6444
  try {
6425
6445
  const response = await fetch(currentFile);
6426
6446
  const blob = await response.blob();
@@ -6435,7 +6455,7 @@ function FilePreviewViewerSession(props) {
6435
6455
  } catch (error) {
6436
6456
  console.error("\uD30C\uC77C \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328:", error);
6437
6457
  }
6438
- }, [currentFile, fileLabel, isImageFile2]);
6458
+ }, [currentFile, fileLabel, isDownloadableFile]);
6439
6459
  const handleZoomIn = React6.useCallback(() => {
6440
6460
  setZoom((prev) => Math.min(prev + 0.25, 3));
6441
6461
  }, []);
@@ -6512,7 +6532,7 @@ function FilePreviewViewerSession(props) {
6512
6532
  if (!currentFile) return null;
6513
6533
  const showZoom = features.zoom && isImageFile2;
6514
6534
  const showRotate = features.rotate && isImageFile2;
6515
- const showDownload = features.download && isImageFile2;
6535
+ const showDownload = features.download && isDownloadableFile;
6516
6536
  return /* @__PURE__ */ jsxRuntime.jsxs(
6517
6537
  "div",
6518
6538
  {
@@ -10505,6 +10525,161 @@ var MentionList = React6.forwardRef((props, ref) => {
10505
10525
  );
10506
10526
  });
10507
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
+ }
10508
10683
 
10509
10684
  // src/components/RichEditor/config/extensions.ts
10510
10685
  function buildExtensions(config) {
@@ -10519,7 +10694,14 @@ function buildExtensions(config) {
10519
10694
  accentTextColor,
10520
10695
  zIndex
10521
10696
  } = config;
10522
- 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
+ }
10523
10705
  const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
10524
10706
  exts.push(
10525
10707
  StarterKit__default.default.configure({
@@ -10545,7 +10727,7 @@ function buildExtensions(config) {
10545
10727
  exts.push(buildCustomTextAlign());
10546
10728
  }
10547
10729
  if (toolbar.image) {
10548
- exts.push(buildCustomImage());
10730
+ exts.push(buildCustomImage(), buildCustomVideo());
10549
10731
  }
10550
10732
  if (toolbar.placeholder !== void 0) {
10551
10733
  exts.push(
@@ -10613,7 +10795,8 @@ function buildExtensions(config) {
10613
10795
  extensionTable.Table.configure({ resizable: true }),
10614
10796
  extensionTable.TableRow,
10615
10797
  extensionTable.TableHeader,
10616
- extensionTable.TableCell
10798
+ extensionTable.TableCell,
10799
+ buildTableCommands()
10617
10800
  );
10618
10801
  }
10619
10802
  return exts;
@@ -10646,6 +10829,17 @@ function buildCustomTextAlign() {
10646
10829
  defaultAlignment: "left"
10647
10830
  });
10648
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
+ }
10649
10843
  function buildCustomImage() {
10650
10844
  const CustomImage = extensionImage.Image.extend({
10651
10845
  addAttributes() {
@@ -10662,8 +10856,12 @@ function buildCustomImage() {
10662
10856
  style: {
10663
10857
  default: null,
10664
10858
  renderHTML: (attrs) => attrs.style ? { style: attrs.style } : {}
10665
- }
10859
+ },
10860
+ ...buildAlignAttribute()
10666
10861
  };
10862
+ },
10863
+ addNodeView() {
10864
+ return react.ReactNodeViewRenderer(ResizableImageNodeView);
10667
10865
  }
10668
10866
  });
10669
10867
  return CustomImage.configure({
@@ -10672,6 +10870,134 @@ function buildCustomImage() {
10672
10870
  allowBase64: true
10673
10871
  });
10674
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
+ }
10675
11001
  function buildMarkResetOnEnter() {
10676
11002
  return core.Extension.create({
10677
11003
  name: "markResetOnEnter",
@@ -10880,8 +11206,8 @@ function useRichEditorFiles(options = {}) {
10880
11206
  toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
10881
11207
  }
10882
11208
  if (maxFiles) {
10883
- const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
10884
- 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;
10885
11211
  const remaining = Math.max(0, maxFiles - currentCount);
10886
11212
  if (accepted.length > remaining) {
10887
11213
  toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
@@ -10902,6 +11228,10 @@ function useRichEditorFiles(options = {}) {
10902
11228
  if (!editor) continue;
10903
11229
  editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
10904
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);
10905
11235
  } else {
10906
11236
  setAttachments((prev) => [
10907
11237
  ...prev,
@@ -11016,7 +11346,7 @@ function useRichEditor(options = {}) {
11016
11346
  onFileUpload,
11017
11347
  initialAttachments: initialSplit.attachments
11018
11348
  });
11019
- 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);
11020
11350
  const attachmentsRef = React6.useRef(attachments);
11021
11351
  attachmentsRef.current = attachments;
11022
11352
  const editorRef = React6.useRef(null);
@@ -11060,7 +11390,7 @@ function useRichEditor(options = {}) {
11060
11390
  editorRef.current = editor;
11061
11391
  React6.useEffect(() => {
11062
11392
  if (!editor) return;
11063
- const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
11393
+ const sync = () => setImageCount((editor.getHTML().match(/<(img|video)\b/gi) ?? []).length);
11064
11394
  sync();
11065
11395
  editor.on("transaction", sync);
11066
11396
  return () => {
@@ -11252,9 +11582,9 @@ function TextColorPicker({ editor, colors, currentColor, onClose }) {
11252
11582
  ] });
11253
11583
  }
11254
11584
  function ToolbarButton(props) {
11255
- const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
11585
+ const { onMouseDown, active, disabled, title, variant = "default", children } = props;
11256
11586
  const theme = useRichEditorTheme();
11257
- const btn = /* @__PURE__ */ jsxRuntime.jsx(
11587
+ return /* @__PURE__ */ jsxRuntime.jsx(
11258
11588
  "button",
11259
11589
  {
11260
11590
  type: "button",
@@ -11269,8 +11599,6 @@ function ToolbarButton(props) {
11269
11599
  children
11270
11600
  }
11271
11601
  );
11272
- if (!tooltip) return btn;
11273
- return /* @__PURE__ */ jsxRuntime.jsx(Tooltip2, { content: tooltip, position: "bottom", asChild: true, children: btn });
11274
11602
  }
11275
11603
  function Divider() {
11276
11604
  const theme = useRichEditorTheme();
@@ -11283,6 +11611,10 @@ function cmd(fn) {
11283
11611
  fn();
11284
11612
  };
11285
11613
  }
11614
+ function tableShortcutLabel(letter) {
11615
+ const mod = core.isMacOS() ? "Cmd" : "Alt";
11616
+ return `${mod}+Shift+${letter.toUpperCase()}`;
11617
+ }
11286
11618
  function RichEditorToolbar(props) {
11287
11619
  const { editor, toolbar = {}, className, zIndex, onImageButtonClick } = props;
11288
11620
  const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
@@ -11352,7 +11684,7 @@ function RichEditorToolbar(props) {
11352
11684
  () => editor.chain().focus().toggleHeading({ level: 1 }).run()
11353
11685
  ),
11354
11686
  active: state.isH1,
11355
- title: "\uC81C\uBAA9 1 (H1)",
11687
+ title: "\uC81C\uBAA9 1 (Ctrl+Alt+1)",
11356
11688
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading1, { size: 16 })
11357
11689
  }
11358
11690
  ),
@@ -11363,7 +11695,7 @@ function RichEditorToolbar(props) {
11363
11695
  () => editor.chain().focus().toggleHeading({ level: 2 }).run()
11364
11696
  ),
11365
11697
  active: state.isH2,
11366
- title: "\uC81C\uBAA9 2 (H2)",
11698
+ title: "\uC81C\uBAA9 2 (Ctrl+Alt+2)",
11367
11699
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading2, { size: 16 })
11368
11700
  }
11369
11701
  ),
@@ -11374,7 +11706,7 @@ function RichEditorToolbar(props) {
11374
11706
  () => editor.chain().focus().toggleHeading({ level: 3 }).run()
11375
11707
  ),
11376
11708
  active: state.isH3,
11377
- title: "\uC81C\uBAA9 3 (H3)",
11709
+ title: "\uC81C\uBAA9 3 (Ctrl+Alt+3)",
11378
11710
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading3, { size: 16 })
11379
11711
  }
11380
11712
  ),
@@ -11385,7 +11717,7 @@ function RichEditorToolbar(props) {
11385
11717
  () => editor.chain().focus().toggleHeading({ level: 4 }).run()
11386
11718
  ),
11387
11719
  active: state.isH4,
11388
- title: "\uC81C\uBAA9 4 (H4)",
11720
+ title: "\uC81C\uBAA9 4 (Ctrl+Alt+4)",
11389
11721
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading4, { size: 16 })
11390
11722
  }
11391
11723
  ),
@@ -11414,7 +11746,7 @@ function RichEditorToolbar(props) {
11414
11746
  {
11415
11747
  onMouseDown: cmd(() => editor.chain().focus().toggleStrike().run()),
11416
11748
  active: state.isStrike,
11417
- title: "\uCDE8\uC18C\uC120",
11749
+ title: "\uCDE8\uC18C\uC120 (Ctrl+Shift+S)",
11418
11750
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Strikethrough, { size: 16 })
11419
11751
  }
11420
11752
  ),
@@ -11423,7 +11755,7 @@ function RichEditorToolbar(props) {
11423
11755
  {
11424
11756
  onMouseDown: cmd(() => editor.chain().focus().toggleCode().run()),
11425
11757
  active: state.isCode,
11426
- title: "\uC778\uB77C\uC778 \uCF54\uB4DC",
11758
+ title: "\uC778\uB77C\uC778 \uCF54\uB4DC (Ctrl+E)",
11427
11759
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { size: 16 })
11428
11760
  }
11429
11761
  ),
@@ -11520,7 +11852,7 @@ function RichEditorToolbar(props) {
11520
11852
  () => editor.chain().focus().toggleBulletList().run()
11521
11853
  ),
11522
11854
  active: state.isBulletList,
11523
- title: "\uAE00\uBA38\uB9AC \uAE30\uD638",
11855
+ title: "\uAE00\uBA38\uB9AC \uAE30\uD638 (Ctrl+Shift+8)",
11524
11856
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, { size: 16 })
11525
11857
  }
11526
11858
  ),
@@ -11531,7 +11863,7 @@ function RichEditorToolbar(props) {
11531
11863
  () => editor.chain().focus().toggleOrderedList().run()
11532
11864
  ),
11533
11865
  active: state.isOrderedList,
11534
- title: "\uBC88\uD638 \uBAA9\uB85D",
11866
+ title: "\uBC88\uD638 \uBAA9\uB85D (Ctrl+Shift+7)",
11535
11867
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListOrdered, { size: 16 })
11536
11868
  }
11537
11869
  ),
@@ -11542,7 +11874,7 @@ function RichEditorToolbar(props) {
11542
11874
  () => editor.chain().focus().toggleBlockquote().run()
11543
11875
  ),
11544
11876
  active: state.isBlockquote,
11545
- title: "\uC778\uC6A9\uAD6C",
11877
+ title: "\uC778\uC6A9\uAD6C (Ctrl+Shift+B)",
11546
11878
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Quote, { size: 16 })
11547
11879
  }
11548
11880
  ),
@@ -11550,10 +11882,10 @@ function RichEditorToolbar(props) {
11550
11882
  ToolbarButton,
11551
11883
  {
11552
11884
  onMouseDown: cmd(
11553
- () => editor.chain().focus().toggleCodeBlock().run()
11885
+ () => editor.chain().focus().toggleCodeBlockMerged().run()
11554
11886
  ),
11555
11887
  active: state.isCodeBlock,
11556
- title: "\uCF54\uB4DC \uBE14\uB85D",
11888
+ title: "\uCF54\uB4DC \uBE14\uB85D (Ctrl+Alt+C)",
11557
11889
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileCode, { size: 16 })
11558
11890
  }
11559
11891
  )
@@ -11576,7 +11908,7 @@ function RichEditorToolbar(props) {
11576
11908
  "button",
11577
11909
  {
11578
11910
  type: "button",
11579
- "aria-label": "\uD14C\uC774\uBE14 \uC0BD\uC785",
11911
+ "aria-label": `\uD14C\uC774\uBE14 \uC0BD\uC785 (${tableShortcutLabel("g")})`,
11580
11912
  className: cn(
11581
11913
  "flex h-8 w-8 cursor-pointer items-center justify-center rounded text-sm transition-colors",
11582
11914
  "disabled:cursor-not-allowed disabled:opacity-40",
@@ -11604,46 +11936,15 @@ function RichEditorToolbar(props) {
11604
11936
  ToolbarButton,
11605
11937
  {
11606
11938
  onMouseDown: cmd(() => editor.chain().focus().addRowAfter().run()),
11607
- title: "\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00",
11608
- tooltip: "\uD589 \uCD94\uAC00",
11939
+ title: `\uC544\uB798\uC5D0 \uD589 \uCD94\uAC00 (${tableShortcutLabel("u")})`,
11609
11940
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 })
11610
11941
  }
11611
11942
  ),
11612
11943
  /* @__PURE__ */ jsxRuntime.jsx(
11613
11944
  ToolbarButton,
11614
11945
  {
11615
- onMouseDown: cmd(() => {
11616
- editor.chain().focus().command(({ tr, dispatch, state: state2 }) => {
11617
- const { $anchor } = state2.selection;
11618
- let tableNode = null;
11619
- let tableStart = 0;
11620
- for (let depth = $anchor.depth; depth > 0; depth--) {
11621
- const node = $anchor.node(depth);
11622
- if (node.type.name === "table") {
11623
- tableNode = node;
11624
- tableStart = $anchor.start(depth);
11625
- break;
11626
- }
11627
- }
11628
- if (!tableNode) return false;
11629
- let lastRowStart = 0;
11630
- let lastRowSize = 0;
11631
- let rowCount = 0;
11632
- tableNode.forEach((child, offset) => {
11633
- if (child.type.name !== "tableRow") return;
11634
- rowCount++;
11635
- lastRowStart = tableStart + offset;
11636
- lastRowSize = child.nodeSize;
11637
- });
11638
- if (rowCount <= 1) return false;
11639
- if (dispatch) {
11640
- dispatch(tr.delete(lastRowStart, lastRowStart + lastRowSize));
11641
- }
11642
- return true;
11643
- }).run();
11644
- }),
11645
- title: "\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C",
11646
- tooltip: "\uD589 \uC0AD\uC81C",
11946
+ onMouseDown: cmd(() => editor.chain().focus().deleteLastRow().run()),
11947
+ title: `\uB9C8\uC9C0\uB9C9 \uD589 \uC0AD\uC81C (${tableShortcutLabel("x")})`,
11647
11948
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { size: 14 })
11648
11949
  }
11649
11950
  ),
@@ -11652,8 +11953,7 @@ function RichEditorToolbar(props) {
11652
11953
  ToolbarButton,
11653
11954
  {
11654
11955
  onMouseDown: cmd(() => editor.chain().focus().addColumnAfter().run()),
11655
- title: "\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00",
11656
- tooltip: "\uC5F4 \uCD94\uAC00",
11956
+ title: `\uC624\uB978\uCABD\uC5D0 \uC5F4 \uCD94\uAC00 (${tableShortcutLabel("k")})`,
11657
11957
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R+" })
11658
11958
  }
11659
11959
  ),
@@ -11661,8 +11961,7 @@ function RichEditorToolbar(props) {
11661
11961
  ToolbarButton,
11662
11962
  {
11663
11963
  onMouseDown: cmd(() => editor.chain().focus().deleteColumn().run()),
11664
- title: "\uD604\uC7AC \uC5F4 \uC0AD\uC81C",
11665
- tooltip: "\uC5F4 \uC0AD\uC81C",
11964
+ title: `\uD604\uC7AC \uC5F4 \uC0AD\uC81C (${tableShortcutLabel("l")})`,
11666
11965
  children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-xs font-bold leading-none", theme.toolbar.rText), children: "R-" })
11667
11966
  }
11668
11967
  ),
@@ -11672,7 +11971,6 @@ function RichEditorToolbar(props) {
11672
11971
  {
11673
11972
  onMouseDown: cmd(() => editor.chain().focus().deleteTable().run()),
11674
11973
  title: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11675
- tooltip: "\uD14C\uC774\uBE14 \uC0AD\uC81C",
11676
11974
  variant: "destructive",
11677
11975
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 14 })
11678
11976
  }