@farmzone/fz-react-ui 1.1.15 → 1.1.17

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
@@ -492,7 +492,7 @@ function Input2(props) {
492
492
  onBlur,
493
493
  maxLength,
494
494
  allowLeadingSpace = true,
495
- allowMiddleSpace = true,
495
+ // allowMiddleSpace = true,
496
496
  allowTrailingSpace = true,
497
497
  ...rest
498
498
  } = props;
@@ -570,11 +570,12 @@ function Input2(props) {
570
570
  } else {
571
571
  event.target.value = sanitized;
572
572
  }
573
- } else if (!allowLeadingSpace || !allowMiddleSpace) {
573
+ } else if (!allowLeadingSpace || !allowTrailingSpace) {
574
574
  const { leading, core, trailing } = splitSpaceRuns(value);
575
575
  const nextLeading = allowLeadingSpace ? leading : "";
576
- const nextCore = allowMiddleSpace ? core : core.replace(/ /g, "");
577
- const sanitized = nextLeading + nextCore + trailing;
576
+ const nextCore = core;
577
+ const nextTrailing = allowTrailingSpace ? trailing : "";
578
+ const sanitized = nextLeading + nextCore + nextTrailing;
578
579
  if (sanitized !== value) {
579
580
  event.target.value = sanitized;
580
581
  }
@@ -593,16 +594,6 @@ function Input2(props) {
593
594
  }
594
595
  onKeyDown?.(event);
595
596
  };
596
- const handleBlur = (event) => {
597
- if (!allowTrailingSpace && type !== "number" && type !== "money") {
598
- const trimmed = event.currentTarget.value.replace(/ +$/, "");
599
- if (trimmed !== event.currentTarget.value) {
600
- event.currentTarget.value = trimmed;
601
- onChange?.(event);
602
- }
603
- }
604
- onBlur?.(event);
605
- };
606
597
  const inputBlock = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative m-0", children: [
607
598
  leftIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground absolute top-1/2 left-3 -translate-y-1/2 transform", children: leftIcon }),
608
599
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -623,7 +614,7 @@ function Input2(props) {
623
614
  maxLength: type === "money" ? void 0 : maxLength,
624
615
  onChange: handleChange,
625
616
  onKeyDown: handleKeyDown,
626
- onBlur: handleBlur,
617
+ onBlur,
627
618
  ...rest
628
619
  }
629
620
  ),
@@ -1820,10 +1811,12 @@ var ToastManager = class _ToastManager {
1820
1811
  const props = this.resolveProps(rawProps);
1821
1812
  const position = props.position || "top-center";
1822
1813
  const duration = props.duration !== void 0 ? props.duration : 1500;
1814
+ const isSameToast = (other) => (other.props.type ?? "info") === (props.type ?? "info") && other.props.toast === props.toast;
1823
1815
  if (props.id) {
1824
1816
  for (const [pos, toasts] of this.toasts.entries()) {
1825
1817
  const existing = toasts.find((t) => t.id === props.id);
1826
1818
  if (existing) {
1819
+ if (isSameToast(existing)) return existing.id;
1827
1820
  if (existing.timer) clearTimeout(existing.timer);
1828
1821
  const updated = toasts.filter((t) => t.id !== props.id);
1829
1822
  this.toasts.set(pos, updated);
@@ -1834,7 +1827,9 @@ var ToastManager = class _ToastManager {
1834
1827
  }
1835
1828
  }
1836
1829
  const positionToasts = this.toasts.get(position) || [];
1837
- if (positionToasts.length > 0) {
1830
+ const existingAtPosition = positionToasts[0];
1831
+ if (existingAtPosition) {
1832
+ if (isSameToast(existingAtPosition)) return existingAtPosition.id;
1838
1833
  positionToasts.forEach((toast2) => {
1839
1834
  if (toast2.timer) clearTimeout(toast2.timer);
1840
1835
  });
@@ -2656,8 +2651,33 @@ function useCalendarState(props) {
2656
2651
  handleSelectOpenChange
2657
2652
  };
2658
2653
  }
2654
+
2655
+ // src/components/Modal/ui/modalStack.ts
2656
+ var stack = [];
2657
+ function push(id) {
2658
+ stack = [...stack, id];
2659
+ return stack.length;
2660
+ }
2661
+ function pop(id) {
2662
+ stack = stack.filter((s) => s !== id);
2663
+ }
2664
+ function isTop(id) {
2665
+ return stack.at(-1) === id;
2666
+ }
2667
+ function size() {
2668
+ return stack.length;
2669
+ }
2670
+ var modalStack = { push, pop, isTop, size };
2671
+
2672
+ // src/components/DatePicker/calendar/hooks/useFloatingCalendarPosition.ts
2659
2673
  var CALENDAR_GAP = 4;
2660
2674
  var CALENDAR_MIN_WIDTH = 280;
2675
+ function resolveCalendarZIndex() {
2676
+ const depth = modalStack.size();
2677
+ if (depth === 0) return CALENDAR_PORTAL_Z_INDEX;
2678
+ const topModalContentZ = Z_INDEX.MODAL + Math.max(0, depth - 1) * Z_INDEX.MODAL_Z_STEP;
2679
+ return Math.max(CALENDAR_PORTAL_Z_INDEX, topModalContentZ + (Z_INDEX.CALENDAR_PORTAL - Z_INDEX.MODAL));
2680
+ }
2661
2681
  function useFloatingCalendarPosition(anchorRef, isOpen2, placement, align = "start") {
2662
2682
  const [style, setStyle] = React6.useState({ position: "fixed", visibility: "hidden" });
2663
2683
  React6.useLayoutEffect(() => {
@@ -2666,7 +2686,7 @@ function useFloatingCalendarPosition(anchorRef, isOpen2, placement, align = "sta
2666
2686
  const rect = anchorRef.current.getBoundingClientRect();
2667
2687
  const base = {
2668
2688
  position: "fixed",
2669
- zIndex: CALENDAR_PORTAL_Z_INDEX,
2689
+ zIndex: resolveCalendarZIndex(),
2670
2690
  minWidth: CALENDAR_MIN_WIDTH,
2671
2691
  visibility: "visible",
2672
2692
  ...align === "end" ? { left: rect.left } : { right: window.innerWidth - rect.right }
@@ -3259,25 +3279,24 @@ function SearchBar(props) {
3259
3279
  function DebouncedButton(props) {
3260
3280
  const { debounceDelay = 300, onClick, className, ...rest } = props;
3261
3281
  const [isDebouncing, setIsDebouncing] = React6.useState(false);
3282
+ const onClickRef = React6.useRef(onClick);
3283
+ onClickRef.current = onClick;
3262
3284
  const debouncedOnClick = React6.useMemo(() => {
3263
- if (!onClick) return void 0;
3264
3285
  return esToolkit.debounce((event) => {
3265
3286
  setIsDebouncing(false);
3266
- onClick(event);
3287
+ onClickRef.current?.(event);
3267
3288
  }, debounceDelay);
3268
- }, [debounceDelay, onClick]);
3289
+ }, [debounceDelay]);
3269
3290
  React6.useEffect(() => {
3270
3291
  return () => {
3271
- debouncedOnClick?.cancel();
3292
+ debouncedOnClick.cancel();
3272
3293
  setIsDebouncing(false);
3273
3294
  };
3274
3295
  }, [debouncedOnClick]);
3275
3296
  const handleClick = (event) => {
3276
- if (debouncedOnClick) {
3297
+ if (onClickRef.current) {
3277
3298
  setIsDebouncing(true);
3278
3299
  debouncedOnClick(event);
3279
- } else {
3280
- onClick?.(event);
3281
3300
  }
3282
3301
  };
3283
3302
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3685,23 +3704,6 @@ function Empty(props) {
3685
3704
  }
3686
3705
  return root2;
3687
3706
  }
3688
-
3689
- // src/components/Modal/ui/modalStack.ts
3690
- var stack = [];
3691
- function push(id) {
3692
- stack = [...stack, id];
3693
- return stack.length;
3694
- }
3695
- function pop(id) {
3696
- stack = stack.filter((s) => s !== id);
3697
- }
3698
- function isTop(id) {
3699
- return stack.at(-1) === id;
3700
- }
3701
- function size() {
3702
- return stack.length;
3703
- }
3704
- var modalStack = { push, pop, isTop, size };
3705
3707
  function ModalContent(props) {
3706
3708
  const { ref, children, className, zIndex, ...rest } = props;
3707
3709
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -10688,8 +10690,90 @@ function createKeyboardHandler(codeBlockEmptyEnterRef, onSubmitRef) {
10688
10690
  };
10689
10691
  }
10690
10692
 
10693
+ // src/components/RichEditor/config/fileHandlers.ts
10694
+ function createPasteHandler(processFilesRef) {
10695
+ return (_view, event) => {
10696
+ const files = Array.from(event.clipboardData?.files ?? []);
10697
+ if (files.length === 0) return false;
10698
+ event.preventDefault();
10699
+ processFilesRef.current(files);
10700
+ return true;
10701
+ };
10702
+ }
10703
+ function createDropHandler(processFilesRef) {
10704
+ return (_view, event) => {
10705
+ const files = Array.from(event.dataTransfer?.files ?? []);
10706
+ if (files.length === 0) return false;
10707
+ event.preventDefault();
10708
+ processFilesRef.current(files);
10709
+ return true;
10710
+ };
10711
+ }
10712
+ var FORMAT_EXT_ALIASES = {
10713
+ JPG: ["jpg", "jpeg"],
10714
+ JPEG: ["jpg", "jpeg"]
10715
+ };
10716
+ function expandFormats(fileFormat) {
10717
+ const exts = /* @__PURE__ */ new Set();
10718
+ for (const format of fileFormat) {
10719
+ const key = format.toUpperCase();
10720
+ const aliases = FORMAT_EXT_ALIASES[key] ?? [format.toLowerCase()];
10721
+ aliases.forEach((ext) => exts.add(ext));
10722
+ }
10723
+ return exts;
10724
+ }
10725
+ function extOf(fileName) {
10726
+ return fileName.split(".").pop()?.toLowerCase() ?? "";
10727
+ }
10728
+ function buildAcceptAttribute(fileFormat) {
10729
+ if (!fileFormat || fileFormat.length === 0) return void 0;
10730
+ return Array.from(expandFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
10731
+ }
10732
+ function useRichEditorFiles(options = {}) {
10733
+ const { fileFormat, onFileUpload } = options;
10734
+ const [attachments, setAttachments] = React6.useState([]);
10735
+ const [isUploading, setIsUploading] = React6.useState(false);
10736
+ const removeAttachment = React6.useCallback((id) => {
10737
+ setAttachments((prev) => prev.filter((a) => a.id !== id));
10738
+ }, []);
10739
+ const processFiles = React6.useCallback(
10740
+ async (files, editor) => {
10741
+ const allowedExts = fileFormat ? expandFormats(fileFormat) : null;
10742
+ const accepted = allowedExts ? files.filter((f) => allowedExts.has(extOf(f.name))) : files;
10743
+ if (accepted.length === 0) return;
10744
+ setIsUploading(true);
10745
+ try {
10746
+ for (const file of accepted) {
10747
+ const url = await (onFileUpload ? onFileUpload(file) : URL.createObjectURL(file));
10748
+ if (file.type.startsWith("image/")) {
10749
+ if (!editor) continue;
10750
+ editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
10751
+ editor.commands.setTextSelection(editor.state.selection.to);
10752
+ } else {
10753
+ setAttachments((prev) => [
10754
+ ...prev,
10755
+ {
10756
+ id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
10757
+ name: file.name,
10758
+ size: file.size,
10759
+ mimeType: file.type,
10760
+ file,
10761
+ url
10762
+ }
10763
+ ]);
10764
+ }
10765
+ }
10766
+ } finally {
10767
+ setIsUploading(false);
10768
+ }
10769
+ },
10770
+ [fileFormat, onFileUpload]
10771
+ );
10772
+ return { attachments, processFiles, removeAttachment, isUploading };
10773
+ }
10774
+
10691
10775
  // src/components/RichEditor/hooks/useRichEditor.ts
10692
- var DEFAULT_EDITOR_CLASS = "focus:outline-none";
10776
+ var DEFAULT_EDITOR_CLASS = "focus:outline-none h-full";
10693
10777
  function useRichEditor(options = {}) {
10694
10778
  const {
10695
10779
  defaultValue,
@@ -10706,6 +10790,8 @@ function useRichEditor(options = {}) {
10706
10790
  autofocus,
10707
10791
  editorClassName,
10708
10792
  additionalExtensions = [],
10793
+ fileFormat,
10794
+ onFileUpload,
10709
10795
  onChange,
10710
10796
  onSubmit
10711
10797
  } = options;
@@ -10714,6 +10800,15 @@ function useRichEditor(options = {}) {
10714
10800
  onChangeRef.current = onChange;
10715
10801
  const onSubmitRef = React6.useRef(onSubmit);
10716
10802
  onSubmitRef.current = onSubmit;
10803
+ const { attachments, processFiles, removeAttachment, isUploading } = useRichEditorFiles({
10804
+ fileFormat,
10805
+ onFileUpload
10806
+ });
10807
+ const editorRef = React6.useRef(null);
10808
+ const processFilesRef = React6.useRef(() => {
10809
+ });
10810
+ processFilesRef.current = (files) => processFiles(files, editorRef.current);
10811
+ const imageFeatureEnabled = toolbar.image !== false;
10717
10812
  const extensions = [
10718
10813
  ...buildExtensions({
10719
10814
  toolbar,
@@ -10736,16 +10831,21 @@ function useRichEditor(options = {}) {
10736
10831
  attributes: {
10737
10832
  class: cn(DEFAULT_EDITOR_CLASS, editorClassName)
10738
10833
  },
10739
- handleKeyDown: createKeyboardHandler(codeBlockEmptyEnterRef, onSubmitRef)
10834
+ handleKeyDown: createKeyboardHandler(codeBlockEmptyEnterRef, onSubmitRef),
10835
+ ...imageFeatureEnabled ? {
10836
+ handlePaste: createPasteHandler(processFilesRef),
10837
+ handleDrop: createDropHandler(processFilesRef)
10838
+ } : {}
10740
10839
  },
10741
10840
  content: defaultValue ?? "",
10742
10841
  onUpdate: ({ editor: editor2 }) => {
10743
10842
  onChangeRef.current?.(editor2.getHTML());
10744
10843
  }
10745
10844
  });
10845
+ editorRef.current = editor;
10746
10846
  React6.useEffect(() => {
10747
- if (editor) editor.setEditable(editable);
10748
- }, [editor, editable]);
10847
+ if (editor) editor.setEditable(editable && !isUploading);
10848
+ }, [editor, editable, isUploading]);
10749
10849
  return {
10750
10850
  editor,
10751
10851
  getHTML: () => editor?.getHTML() ?? "",
@@ -10759,9 +10859,11 @@ function useRichEditor(options = {}) {
10759
10859
  focus: () => {
10760
10860
  editor?.commands.focus();
10761
10861
  },
10762
- isEmpty: editor?.isEmpty ?? true
10763
- // attachments,
10764
- // removeAttachment,
10862
+ isEmpty: editor?.isEmpty ?? true,
10863
+ attachments,
10864
+ removeAttachment,
10865
+ processFiles: processFilesRef.current,
10866
+ isUploading
10765
10867
  };
10766
10868
  }
10767
10869
  var MAX_COLS = 8;
@@ -10950,7 +11052,7 @@ function cmd(fn) {
10950
11052
  };
10951
11053
  }
10952
11054
  function RichEditorToolbar(props) {
10953
- const { editor, toolbar = {}, className, zIndex } = props;
11055
+ const { editor, toolbar = {}, className, zIndex, onImageButtonClick } = props;
10954
11056
  const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
10955
11057
  const theme = useRichEditorTheme();
10956
11058
  const [tablePickerOpen, setTablePickerOpen] = React6.useState(false);
@@ -11224,6 +11326,17 @@ function RichEditorToolbar(props) {
11224
11326
  }
11225
11327
  )
11226
11328
  ] }),
11329
+ toolbar.image !== false && onImageButtonClick && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11330
+ /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
11331
+ /* @__PURE__ */ jsxRuntime.jsx(
11332
+ ToolbarButton,
11333
+ {
11334
+ onMouseDown: cmd(onImageButtonClick),
11335
+ title: "\uC774\uBBF8\uC9C0/\uD30C\uC77C \uC0BD\uC785",
11336
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { size: 16 })
11337
+ }
11338
+ )
11339
+ ] }),
11227
11340
  toolbar.table && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11228
11341
  /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
11229
11342
  /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: tablePickerOpen, onOpenChange: setTablePickerOpen, children: [
@@ -11338,6 +11451,130 @@ function RichEditorToolbar(props) {
11338
11451
  }
11339
11452
  );
11340
11453
  }
11454
+ function RichEditorDropZone(props) {
11455
+ const { children, className, "data-rich-editor-theme": themeAttr } = props;
11456
+ const theme = useRichEditorTheme();
11457
+ const [isDragging, setIsDragging] = React6.useState(false);
11458
+ const counterRef = React6.useRef(0);
11459
+ const handleDragEnter = (e) => {
11460
+ if (!e.dataTransfer.types.includes("Files")) return;
11461
+ e.preventDefault();
11462
+ counterRef.current++;
11463
+ setIsDragging(true);
11464
+ };
11465
+ const handleDragLeave = (_e) => {
11466
+ counterRef.current = Math.max(0, counterRef.current - 1);
11467
+ if (counterRef.current === 0) setIsDragging(false);
11468
+ };
11469
+ const handleDragOver = (e) => {
11470
+ if (e.dataTransfer.types.includes("Files")) e.preventDefault();
11471
+ };
11472
+ const handleDrop = (e) => {
11473
+ e.preventDefault();
11474
+ counterRef.current = 0;
11475
+ setIsDragging(false);
11476
+ };
11477
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11478
+ "div",
11479
+ {
11480
+ className: cn("relative", className),
11481
+ "data-rich-editor-theme": themeAttr,
11482
+ onDragEnter: handleDragEnter,
11483
+ onDragLeave: handleDragLeave,
11484
+ onDragOver: handleDragOver,
11485
+ onDrop: handleDrop,
11486
+ children: [
11487
+ children,
11488
+ isDragging && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-lg border-2 border-dashed", theme.dropZone.overlay), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
11489
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 28, strokeWidth: 1.5 }),
11490
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "\uD30C\uC77C\uC744 \uC5EC\uAE30\uC5D0 \uB193\uC73C\uC138\uC694" }),
11491
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-xs", theme.dropZone.subText), children: "\uC774\uBBF8\uC9C0 \u2192 \uBCF8\uBB38 \uC0BD\uC785 \xA0\xB7\xA0 \uADF8 \uC678 \uD30C\uC77C \u2192 \uD558\uB2E8 \uCCA8\uBD80" })
11492
+ ] }) })
11493
+ ]
11494
+ }
11495
+ );
11496
+ }
11497
+ var EXT_STYLE = {
11498
+ pdf: "bg-red-100 text-red-700",
11499
+ doc: "bg-blue-100 text-blue-700",
11500
+ docx: "bg-blue-100 text-blue-700",
11501
+ hwp: "bg-blue-100 text-blue-700",
11502
+ xls: "bg-green-100 text-green-700",
11503
+ xlsx: "bg-green-100 text-green-700",
11504
+ csv: "bg-emerald-100 text-emerald-700",
11505
+ ppt: "bg-orange-100 text-orange-700",
11506
+ pptx: "bg-orange-100 text-orange-700",
11507
+ zip: "bg-gray-200 text-gray-700",
11508
+ rar: "bg-gray-200 text-gray-700",
11509
+ "7z": "bg-gray-200 text-gray-700",
11510
+ mp4: "bg-purple-100 text-purple-700",
11511
+ mov: "bg-purple-100 text-purple-700",
11512
+ avi: "bg-purple-100 text-purple-700",
11513
+ mp3: "bg-pink-100 text-pink-700",
11514
+ wav: "bg-pink-100 text-pink-700",
11515
+ txt: "bg-gray-100 text-gray-600",
11516
+ json: "bg-yellow-100 text-yellow-700",
11517
+ xml: "bg-yellow-100 text-yellow-700",
11518
+ js: "bg-yellow-100 text-yellow-700",
11519
+ ts: "bg-blue-100 text-blue-700",
11520
+ html: "bg-orange-100 text-orange-700",
11521
+ css: "bg-sky-100 text-sky-700"
11522
+ };
11523
+ function formatSize(bytes) {
11524
+ if (bytes < 1024) return `${bytes} B`;
11525
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
11526
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
11527
+ }
11528
+ function RichEditorFileList(props) {
11529
+ const { attachments, onRemove, renderFilePreview } = props;
11530
+ const theme = useRichEditorTheme();
11531
+ if (attachments.length === 0) return null;
11532
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("px-3 py-2.5", theme.fileList.wrapper), children: [
11533
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cn("mb-1.5 text-[11px] font-medium uppercase tracking-wide", theme.fileList.label), children: [
11534
+ "\uCCA8\uBD80\uD30C\uC77C (",
11535
+ attachments.length,
11536
+ ")"
11537
+ ] }),
11538
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: attachments.map((attachment) => {
11539
+ if (renderFilePreview) {
11540
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderFilePreview(attachment, () => onRemove(attachment.id)) }, attachment.id);
11541
+ }
11542
+ const ext = attachment.name.split(".").pop()?.toLowerCase() ?? "";
11543
+ const extStyle = EXT_STYLE[ext] ?? "bg-gray-100 text-gray-600";
11544
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11545
+ "div",
11546
+ {
11547
+ className: cn("flex items-center gap-2 rounded-md px-2.5 py-1.5 shadow-xs", theme.fileList.item),
11548
+ children: [
11549
+ /* @__PURE__ */ jsxRuntime.jsx(
11550
+ "span",
11551
+ {
11552
+ className: cn(
11553
+ "shrink-0 rounded px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide",
11554
+ extStyle
11555
+ ),
11556
+ children: ext || "FILE"
11557
+ }
11558
+ ),
11559
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("max-w-[140px] truncate text-xs", theme.fileList.itemName), children: attachment.name }),
11560
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("shrink-0 text-[11px]", theme.fileList.itemSize), children: formatSize(attachment.size) }),
11561
+ /* @__PURE__ */ jsxRuntime.jsx(
11562
+ "button",
11563
+ {
11564
+ type: "button",
11565
+ onClick: () => onRemove(attachment.id),
11566
+ title: "\uCCA8\uBD80\uD30C\uC77C \uC81C\uAC70",
11567
+ className: cn("flex h-4 w-4 shrink-0 items-center justify-center rounded-full", theme.fileList.removeBtn),
11568
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 10 })
11569
+ }
11570
+ )
11571
+ ]
11572
+ },
11573
+ attachment.id
11574
+ );
11575
+ }) })
11576
+ ] });
11577
+ }
11341
11578
  var DEFAULT_TOOLBAR = {
11342
11579
  heading: [1, 2, 3, 4],
11343
11580
  bold: true,
@@ -11361,7 +11598,7 @@ function RichEditorContent(props) {
11361
11598
  return /* @__PURE__ */ jsxRuntime.jsx(
11362
11599
  "div",
11363
11600
  {
11364
- className: cn("rich-editor-content cursor-text", className),
11601
+ className: cn("rich-editor-content flex-1 cursor-text", className),
11365
11602
  style,
11366
11603
  onMouseDown: (e) => {
11367
11604
  if (!editor) return;
@@ -11397,7 +11634,10 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11397
11634
  zIndex,
11398
11635
  themeTokens,
11399
11636
  editable = true,
11400
- autofocus
11637
+ autofocus,
11638
+ fileFormat,
11639
+ onFileUpload,
11640
+ renderFilePreview
11401
11641
  }, ref) {
11402
11642
  const showToolbar = toolbar !== false;
11403
11643
  const toolbarOptions = typeof toolbar === "object" ? toolbar : {};
@@ -11414,7 +11654,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11414
11654
  },
11415
11655
  [onChange]
11416
11656
  );
11417
- const { editor } = useRichEditor({
11657
+ const { editor, attachments, removeAttachment, processFiles, isUploading } = useRichEditor({
11418
11658
  defaultValue: value ?? defaultValue,
11419
11659
  toolbar: activeToolbar,
11420
11660
  mentionUsers,
@@ -11429,9 +11669,12 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11429
11669
  editable,
11430
11670
  autofocus,
11431
11671
  editorClassName,
11672
+ fileFormat,
11673
+ onFileUpload,
11432
11674
  onChange: handleChange,
11433
11675
  onSubmit
11434
11676
  });
11677
+ const fileInputRef = React6.useRef(null);
11435
11678
  React6.useEffect(() => {
11436
11679
  if (!editor || value === void 0) return;
11437
11680
  if (isInternalChangeRef.current) {
@@ -11459,11 +11702,13 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11459
11702
  get isEmpty() {
11460
11703
  return editor?.isEmpty ?? true;
11461
11704
  },
11705
+ attachments,
11462
11706
  editor
11463
11707
  }),
11464
- [editor]
11708
+ [editor, attachments]
11465
11709
  );
11466
11710
  const isToolbarVisible = showToolbar && editable;
11711
+ const imageFeatureEnabled = activeToolbar.image !== false;
11467
11712
  const baseTheme = RICH_EDITOR_THEMES[theme];
11468
11713
  const resolvedTheme = themeTokens ? {
11469
11714
  ...baseTheme,
@@ -11486,10 +11731,37 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11486
11731
  {
11487
11732
  editor,
11488
11733
  toolbar: activeToolbar,
11489
- zIndex
11734
+ zIndex,
11735
+ onImageButtonClick: imageFeatureEnabled ? () => fileInputRef.current?.click() : void 0
11490
11736
  }
11491
11737
  ),
11492
- /* @__PURE__ */ jsxRuntime.jsx(
11738
+ imageFeatureEnabled && /* @__PURE__ */ jsxRuntime.jsx(
11739
+ "input",
11740
+ {
11741
+ ref: fileInputRef,
11742
+ type: "file",
11743
+ multiple: true,
11744
+ accept: buildAcceptAttribute(fileFormat),
11745
+ className: "hidden",
11746
+ onChange: (e) => {
11747
+ const files = Array.from(e.target.files ?? []);
11748
+ if (files.length > 0) processFiles(files);
11749
+ e.target.value = "";
11750
+ }
11751
+ }
11752
+ ),
11753
+ imageFeatureEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, children: [
11754
+ /* @__PURE__ */ jsxRuntime.jsx(
11755
+ RichEditorContent,
11756
+ {
11757
+ editor,
11758
+ className: cn("p-4", bodyClassName),
11759
+ minHeight,
11760
+ maxHeight
11761
+ }
11762
+ ),
11763
+ isUploading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(Loading, { size: "lg" }) })
11764
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
11493
11765
  RichEditorContent,
11494
11766
  {
11495
11767
  editor,
@@ -11497,6 +11769,14 @@ var RichEditor = React6.forwardRef(function RichEditor2({
11497
11769
  minHeight,
11498
11770
  maxHeight
11499
11771
  }
11772
+ ),
11773
+ imageFeatureEnabled && /* @__PURE__ */ jsxRuntime.jsx(
11774
+ RichEditorFileList,
11775
+ {
11776
+ attachments,
11777
+ onRemove: removeAttachment,
11778
+ renderFilePreview
11779
+ }
11500
11780
  )
11501
11781
  ]
11502
11782
  }