@farmzone/fz-react-ui 1.1.17 → 1.2.0
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 +204 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +205 -32
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9370,7 +9370,7 @@ function BaseUploader(props) {
|
|
|
9370
9370
|
const errors = [];
|
|
9371
9371
|
for (const file of incoming) {
|
|
9372
9372
|
if (!checkAccept(file, accept)) {
|
|
9373
|
-
errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD
|
|
9373
|
+
errors.push(`${file.name}: \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD\uC785\uB2C8\uB2E4.`);
|
|
9374
9374
|
continue;
|
|
9375
9375
|
}
|
|
9376
9376
|
if (maxSize && file.size > maxSize) {
|
|
@@ -10434,7 +10434,7 @@ function buildExtensions(config) {
|
|
|
10434
10434
|
accentTextColor,
|
|
10435
10435
|
zIndex
|
|
10436
10436
|
} = config;
|
|
10437
|
-
const exts = [extensionTextStyle.TextStyleKit, buildMarkResetOnEnter()];
|
|
10437
|
+
const exts = [extensionTextStyle.TextStyleKit, buildMarkResetOnEnter(), buildRedundantListMarkerStrip()];
|
|
10438
10438
|
const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
|
|
10439
10439
|
exts.push(
|
|
10440
10440
|
StarterKit__default.default.configure({
|
|
@@ -10610,6 +10610,36 @@ function buildMarkResetOnEnter() {
|
|
|
10610
10610
|
}
|
|
10611
10611
|
});
|
|
10612
10612
|
}
|
|
10613
|
+
function buildRedundantListMarkerStrip() {
|
|
10614
|
+
const bulletMarkerRegex = /^\s*([-+*])\s$/;
|
|
10615
|
+
const orderedMarkerRegex = /^(\d+)\.\s$/;
|
|
10616
|
+
function makeRule(listTypeName, regex) {
|
|
10617
|
+
return new core.InputRule({
|
|
10618
|
+
find: regex,
|
|
10619
|
+
handler: ({ state, range, chain }) => {
|
|
10620
|
+
const { $from } = state.selection;
|
|
10621
|
+
if ($from.depth < 2) return null;
|
|
10622
|
+
const parent = $from.node($from.depth - 1);
|
|
10623
|
+
const grandparent = $from.node($from.depth - 2);
|
|
10624
|
+
if (parent.type.name !== "listItem" || grandparent.type.name !== listTypeName) {
|
|
10625
|
+
return null;
|
|
10626
|
+
}
|
|
10627
|
+
chain().deleteRange(range).run();
|
|
10628
|
+
return void 0;
|
|
10629
|
+
}
|
|
10630
|
+
});
|
|
10631
|
+
}
|
|
10632
|
+
return core.Extension.create({
|
|
10633
|
+
name: "redundantListMarkerStrip",
|
|
10634
|
+
priority: 200,
|
|
10635
|
+
addInputRules() {
|
|
10636
|
+
return [
|
|
10637
|
+
makeRule("bulletList", bulletMarkerRegex),
|
|
10638
|
+
makeRule("orderedList", orderedMarkerRegex)
|
|
10639
|
+
];
|
|
10640
|
+
}
|
|
10641
|
+
});
|
|
10642
|
+
}
|
|
10613
10643
|
|
|
10614
10644
|
// src/components/RichEditor/config/keyboardHandlers.ts
|
|
10615
10645
|
function createKeyboardHandler(codeBlockEmptyEnterRef, onSubmitRef) {
|
|
@@ -10700,20 +10730,24 @@ function createPasteHandler(processFilesRef) {
|
|
|
10700
10730
|
return true;
|
|
10701
10731
|
};
|
|
10702
10732
|
}
|
|
10733
|
+
var RICH_EDITOR_DROP_HANDLED = "__richEditorDropHandled";
|
|
10703
10734
|
function createDropHandler(processFilesRef) {
|
|
10704
10735
|
return (_view, event) => {
|
|
10705
10736
|
const files = Array.from(event.dataTransfer?.files ?? []);
|
|
10706
10737
|
if (files.length === 0) return false;
|
|
10707
10738
|
event.preventDefault();
|
|
10739
|
+
event[RICH_EDITOR_DROP_HANDLED] = true;
|
|
10708
10740
|
processFilesRef.current(files);
|
|
10709
10741
|
return true;
|
|
10710
10742
|
};
|
|
10711
10743
|
}
|
|
10744
|
+
|
|
10745
|
+
// src/lib/fileFormat.ts
|
|
10712
10746
|
var FORMAT_EXT_ALIASES = {
|
|
10713
10747
|
JPG: ["jpg", "jpeg"],
|
|
10714
10748
|
JPEG: ["jpg", "jpeg"]
|
|
10715
10749
|
};
|
|
10716
|
-
function
|
|
10750
|
+
function expandFileFormats(fileFormat) {
|
|
10717
10751
|
const exts = /* @__PURE__ */ new Set();
|
|
10718
10752
|
for (const format of fileFormat) {
|
|
10719
10753
|
const key = format.toUpperCase();
|
|
@@ -10722,29 +10756,63 @@ function expandFormats(fileFormat) {
|
|
|
10722
10756
|
}
|
|
10723
10757
|
return exts;
|
|
10724
10758
|
}
|
|
10725
|
-
function
|
|
10759
|
+
function getFileExtension(fileName) {
|
|
10726
10760
|
return fileName.split(".").pop()?.toLowerCase() ?? "";
|
|
10727
10761
|
}
|
|
10728
10762
|
function buildAcceptAttribute(fileFormat) {
|
|
10729
10763
|
if (!fileFormat || fileFormat.length === 0) return void 0;
|
|
10730
|
-
return Array.from(
|
|
10764
|
+
return Array.from(expandFileFormats(fileFormat)).map((ext) => `.${ext}`).join(",");
|
|
10731
10765
|
}
|
|
10766
|
+
function splitFilesByFormat(files, fileFormat) {
|
|
10767
|
+
if (!fileFormat || fileFormat.length === 0) return { accepted: [...files], rejected: [] };
|
|
10768
|
+
const allowedExts = expandFileFormats(fileFormat);
|
|
10769
|
+
const accepted = [];
|
|
10770
|
+
const rejected = [];
|
|
10771
|
+
for (const file of files) {
|
|
10772
|
+
(allowedExts.has(getFileExtension(file.name)) ? accepted : rejected).push(file);
|
|
10773
|
+
}
|
|
10774
|
+
return { accepted, rejected };
|
|
10775
|
+
}
|
|
10776
|
+
|
|
10777
|
+
// src/components/RichEditor/hooks/useRichEditorFiles.ts
|
|
10732
10778
|
function useRichEditorFiles(options = {}) {
|
|
10733
|
-
const { fileFormat, onFileUpload } = options;
|
|
10734
|
-
const [attachments, setAttachments] = React6.useState([]);
|
|
10779
|
+
const { fileFormat, maxFiles, onFileUpload, initialAttachments } = options;
|
|
10780
|
+
const [attachments, setAttachments] = React6.useState(() => initialAttachments ?? []);
|
|
10781
|
+
const attachmentsRef = React6.useRef(attachments);
|
|
10782
|
+
attachmentsRef.current = attachments;
|
|
10735
10783
|
const [isUploading, setIsUploading] = React6.useState(false);
|
|
10736
10784
|
const removeAttachment = React6.useCallback((id) => {
|
|
10737
10785
|
setAttachments((prev) => prev.filter((a) => a.id !== id));
|
|
10738
10786
|
}, []);
|
|
10787
|
+
const hydrateAttachments = React6.useCallback((loaded) => {
|
|
10788
|
+
setAttachments(loaded);
|
|
10789
|
+
}, []);
|
|
10739
10790
|
const processFiles = React6.useCallback(
|
|
10740
10791
|
async (files, editor) => {
|
|
10741
|
-
const
|
|
10742
|
-
|
|
10792
|
+
const { accepted: splitAccepted, rejected: rejectedByFormat } = splitFilesByFormat(files, fileFormat);
|
|
10793
|
+
let accepted = splitAccepted;
|
|
10794
|
+
if (rejectedByFormat.length > 0) {
|
|
10795
|
+
toast.error("\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uD655\uC7A5\uC790\uC785\uB2C8\uB2E4.");
|
|
10796
|
+
}
|
|
10797
|
+
if (maxFiles) {
|
|
10798
|
+
const imageCount = editor ? (editor.getHTML().match(/<img\b/gi) ?? []).length : 0;
|
|
10799
|
+
const currentCount = attachmentsRef.current.length + imageCount;
|
|
10800
|
+
const remaining = Math.max(0, maxFiles - currentCount);
|
|
10801
|
+
if (accepted.length > remaining) {
|
|
10802
|
+
toast.error(`\uD30C\uC77C\uC740 \uCD5C\uB300 ${maxFiles}\uAC1C\uAE4C\uC9C0 \uCCA8\uBD80\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
10803
|
+
}
|
|
10804
|
+
accepted = accepted.slice(0, remaining);
|
|
10805
|
+
}
|
|
10743
10806
|
if (accepted.length === 0) return;
|
|
10744
10807
|
setIsUploading(true);
|
|
10745
10808
|
try {
|
|
10746
10809
|
for (const file of accepted) {
|
|
10747
|
-
|
|
10810
|
+
let url;
|
|
10811
|
+
try {
|
|
10812
|
+
url = await (onFileUpload ? onFileUpload(file) : URL.createObjectURL(file));
|
|
10813
|
+
} catch {
|
|
10814
|
+
continue;
|
|
10815
|
+
}
|
|
10748
10816
|
if (file.type.startsWith("image/")) {
|
|
10749
10817
|
if (!editor) continue;
|
|
10750
10818
|
editor.chain().focus().insertContent({ type: "image", attrs: { src: url } }).run();
|
|
@@ -10767,9 +10835,60 @@ function useRichEditorFiles(options = {}) {
|
|
|
10767
10835
|
setIsUploading(false);
|
|
10768
10836
|
}
|
|
10769
10837
|
},
|
|
10770
|
-
[fileFormat, onFileUpload]
|
|
10838
|
+
[fileFormat, maxFiles, onFileUpload]
|
|
10771
10839
|
);
|
|
10772
|
-
return { attachments, processFiles, removeAttachment, isUploading };
|
|
10840
|
+
return { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading };
|
|
10841
|
+
}
|
|
10842
|
+
|
|
10843
|
+
// src/components/RichEditor/config/attachmentSerialization.ts
|
|
10844
|
+
var ATTACHMENTS_CONTAINER_ATTR = "data-rich-editor-attachments";
|
|
10845
|
+
var ATTACHMENT_ITEM_ATTR = "data-rich-editor-attachment";
|
|
10846
|
+
function escapeHtmlAttr(value) {
|
|
10847
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
10848
|
+
}
|
|
10849
|
+
function escapeHtmlText(value) {
|
|
10850
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
10851
|
+
}
|
|
10852
|
+
function serializeAttachmentsBlock(attachments) {
|
|
10853
|
+
if (attachments.length === 0) return "";
|
|
10854
|
+
const items = attachments.map((attachment) => {
|
|
10855
|
+
const href = escapeHtmlAttr(attachment.url);
|
|
10856
|
+
const name = escapeHtmlAttr(attachment.name);
|
|
10857
|
+
return `<a ${ATTACHMENT_ITEM_ATTR}="true" href="${href}" data-name="${name}" data-size="${attachment.size}" data-mime="${escapeHtmlAttr(attachment.mimeType)}">${escapeHtmlText(attachment.name)}</a>`;
|
|
10858
|
+
}).join("");
|
|
10859
|
+
return `<div ${ATTACHMENTS_CONTAINER_ATTR}="true">${items}</div>`;
|
|
10860
|
+
}
|
|
10861
|
+
function splitAttachmentsFromHtml(html) {
|
|
10862
|
+
if (!html || !html.includes(ATTACHMENTS_CONTAINER_ATTR) || typeof DOMParser === "undefined") {
|
|
10863
|
+
return { html, attachments: [] };
|
|
10864
|
+
}
|
|
10865
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
10866
|
+
const container2 = doc.body.querySelector(`[${ATTACHMENTS_CONTAINER_ATTR}]`);
|
|
10867
|
+
if (!container2) {
|
|
10868
|
+
return { html, attachments: [] };
|
|
10869
|
+
}
|
|
10870
|
+
const attachments = Array.from(
|
|
10871
|
+
container2.querySelectorAll(`[${ATTACHMENT_ITEM_ATTR}]`)
|
|
10872
|
+
).map((el, index) => {
|
|
10873
|
+
const url = el.getAttribute("href") ?? "";
|
|
10874
|
+
const name = el.getAttribute("data-name") ?? el.textContent ?? `file-${index}`;
|
|
10875
|
+
const mimeType = el.getAttribute("data-mime") ?? "";
|
|
10876
|
+
const size2 = Number(el.getAttribute("data-size") ?? "0") || 0;
|
|
10877
|
+
return {
|
|
10878
|
+
id: `loaded-${index}-${Math.random().toString(36).slice(2)}`,
|
|
10879
|
+
name,
|
|
10880
|
+
size: size2,
|
|
10881
|
+
mimeType,
|
|
10882
|
+
file: new File([], name, { type: mimeType }),
|
|
10883
|
+
url
|
|
10884
|
+
};
|
|
10885
|
+
});
|
|
10886
|
+
container2.remove();
|
|
10887
|
+
return { html: doc.body.innerHTML, attachments };
|
|
10888
|
+
}
|
|
10889
|
+
function composeRichEditorHtml(bodyHtml, attachments) {
|
|
10890
|
+
const block = serializeAttachmentsBlock(attachments);
|
|
10891
|
+
return block ? `${bodyHtml}${block}` : bodyHtml;
|
|
10773
10892
|
}
|
|
10774
10893
|
|
|
10775
10894
|
// src/components/RichEditor/hooks/useRichEditor.ts
|
|
@@ -10791,6 +10910,7 @@ function useRichEditor(options = {}) {
|
|
|
10791
10910
|
editorClassName,
|
|
10792
10911
|
additionalExtensions = [],
|
|
10793
10912
|
fileFormat,
|
|
10913
|
+
maxFiles,
|
|
10794
10914
|
onFileUpload,
|
|
10795
10915
|
onChange,
|
|
10796
10916
|
onSubmit
|
|
@@ -10800,10 +10920,20 @@ function useRichEditor(options = {}) {
|
|
|
10800
10920
|
onChangeRef.current = onChange;
|
|
10801
10921
|
const onSubmitRef = React6.useRef(onSubmit);
|
|
10802
10922
|
onSubmitRef.current = onSubmit;
|
|
10803
|
-
const
|
|
10923
|
+
const initialSplitRef = React6.useRef(null);
|
|
10924
|
+
if (initialSplitRef.current === null) {
|
|
10925
|
+
initialSplitRef.current = splitAttachmentsFromHtml(defaultValue ?? "");
|
|
10926
|
+
}
|
|
10927
|
+
const initialSplit = initialSplitRef.current;
|
|
10928
|
+
const { attachments, processFiles, removeAttachment, hydrateAttachments, isUploading } = useRichEditorFiles({
|
|
10804
10929
|
fileFormat,
|
|
10805
|
-
|
|
10930
|
+
maxFiles,
|
|
10931
|
+
onFileUpload,
|
|
10932
|
+
initialAttachments: initialSplit.attachments
|
|
10806
10933
|
});
|
|
10934
|
+
const [imageCount, setImageCount] = React6.useState(() => (initialSplit.html.match(/<img\b/gi) ?? []).length);
|
|
10935
|
+
const attachmentsRef = React6.useRef(attachments);
|
|
10936
|
+
attachmentsRef.current = attachments;
|
|
10807
10937
|
const editorRef = React6.useRef(null);
|
|
10808
10938
|
const processFilesRef = React6.useRef(() => {
|
|
10809
10939
|
});
|
|
@@ -10837,21 +10967,36 @@ function useRichEditor(options = {}) {
|
|
|
10837
10967
|
handleDrop: createDropHandler(processFilesRef)
|
|
10838
10968
|
} : {}
|
|
10839
10969
|
},
|
|
10840
|
-
content:
|
|
10970
|
+
content: initialSplit.html,
|
|
10841
10971
|
onUpdate: ({ editor: editor2 }) => {
|
|
10842
|
-
onChangeRef.current?.(editor2.getHTML());
|
|
10972
|
+
onChangeRef.current?.(composeRichEditorHtml(editor2.getHTML(), attachmentsRef.current));
|
|
10843
10973
|
}
|
|
10844
10974
|
});
|
|
10845
10975
|
editorRef.current = editor;
|
|
10976
|
+
React6.useEffect(() => {
|
|
10977
|
+
if (!editor) return;
|
|
10978
|
+
const sync = () => setImageCount((editor.getHTML().match(/<img\b/gi) ?? []).length);
|
|
10979
|
+
sync();
|
|
10980
|
+
editor.on("transaction", sync);
|
|
10981
|
+
return () => {
|
|
10982
|
+
editor.off("transaction", sync);
|
|
10983
|
+
};
|
|
10984
|
+
}, [editor]);
|
|
10985
|
+
React6.useEffect(() => {
|
|
10986
|
+
if (!editor) return;
|
|
10987
|
+
onChangeRef.current?.(composeRichEditorHtml(editor.getHTML(), attachments));
|
|
10988
|
+
}, [attachments]);
|
|
10846
10989
|
React6.useEffect(() => {
|
|
10847
10990
|
if (editor) editor.setEditable(editable && !isUploading);
|
|
10848
10991
|
}, [editor, editable, isUploading]);
|
|
10849
10992
|
return {
|
|
10850
10993
|
editor,
|
|
10851
|
-
getHTML: () => editor?.getHTML() ?? "",
|
|
10994
|
+
getHTML: () => composeRichEditorHtml(editor?.getHTML() ?? "", attachments),
|
|
10852
10995
|
getJSON: () => editor?.getJSON() ?? {},
|
|
10853
10996
|
setContent: (html) => {
|
|
10854
|
-
|
|
10997
|
+
const split = splitAttachmentsFromHtml(html);
|
|
10998
|
+
editor?.commands.setContent(split.html);
|
|
10999
|
+
hydrateAttachments(split.attachments);
|
|
10855
11000
|
},
|
|
10856
11001
|
clearContent: () => {
|
|
10857
11002
|
editor?.commands.clearContent();
|
|
@@ -10861,7 +11006,9 @@ function useRichEditor(options = {}) {
|
|
|
10861
11006
|
},
|
|
10862
11007
|
isEmpty: editor?.isEmpty ?? true,
|
|
10863
11008
|
attachments,
|
|
11009
|
+
attachmentCount: imageCount + attachments.length,
|
|
10864
11010
|
removeAttachment,
|
|
11011
|
+
hydrateAttachments,
|
|
10865
11012
|
processFiles: processFilesRef.current,
|
|
10866
11013
|
isUploading
|
|
10867
11014
|
};
|
|
@@ -11452,7 +11599,7 @@ function RichEditorToolbar(props) {
|
|
|
11452
11599
|
);
|
|
11453
11600
|
}
|
|
11454
11601
|
function RichEditorDropZone(props) {
|
|
11455
|
-
const { children, className, "data-rich-editor-theme": themeAttr } = props;
|
|
11602
|
+
const { children, className, "data-rich-editor-theme": themeAttr, onDropFiles } = props;
|
|
11456
11603
|
const theme = useRichEditorTheme();
|
|
11457
11604
|
const [isDragging, setIsDragging] = React6.useState(false);
|
|
11458
11605
|
const counterRef = React6.useRef(0);
|
|
@@ -11473,6 +11620,9 @@ function RichEditorDropZone(props) {
|
|
|
11473
11620
|
e.preventDefault();
|
|
11474
11621
|
counterRef.current = 0;
|
|
11475
11622
|
setIsDragging(false);
|
|
11623
|
+
if (e.nativeEvent[RICH_EDITOR_DROP_HANDLED]) return;
|
|
11624
|
+
const files = Array.from(e.dataTransfer.files ?? []);
|
|
11625
|
+
if (files.length > 0) onDropFiles?.(files);
|
|
11476
11626
|
};
|
|
11477
11627
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11478
11628
|
"div",
|
|
@@ -11636,8 +11786,10 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11636
11786
|
editable = true,
|
|
11637
11787
|
autofocus,
|
|
11638
11788
|
fileFormat,
|
|
11789
|
+
maxFiles,
|
|
11639
11790
|
onFileUpload,
|
|
11640
|
-
renderFilePreview
|
|
11791
|
+
renderFilePreview,
|
|
11792
|
+
fileCountUIRender
|
|
11641
11793
|
}, ref) {
|
|
11642
11794
|
const showToolbar = toolbar !== false;
|
|
11643
11795
|
const toolbarOptions = typeof toolbar === "object" ? toolbar : {};
|
|
@@ -11654,7 +11806,17 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11654
11806
|
},
|
|
11655
11807
|
[onChange]
|
|
11656
11808
|
);
|
|
11657
|
-
const {
|
|
11809
|
+
const {
|
|
11810
|
+
editor,
|
|
11811
|
+
attachments,
|
|
11812
|
+
attachmentCount,
|
|
11813
|
+
removeAttachment,
|
|
11814
|
+
hydrateAttachments,
|
|
11815
|
+
processFiles,
|
|
11816
|
+
isUploading,
|
|
11817
|
+
getHTML,
|
|
11818
|
+
setContent
|
|
11819
|
+
} = useRichEditor({
|
|
11658
11820
|
defaultValue: value ?? defaultValue,
|
|
11659
11821
|
toolbar: activeToolbar,
|
|
11660
11822
|
mentionUsers,
|
|
@@ -11670,6 +11832,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11670
11832
|
autofocus,
|
|
11671
11833
|
editorClassName,
|
|
11672
11834
|
fileFormat,
|
|
11835
|
+
maxFiles,
|
|
11673
11836
|
onFileUpload,
|
|
11674
11837
|
onChange: handleChange,
|
|
11675
11838
|
onSubmit
|
|
@@ -11681,18 +11844,18 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11681
11844
|
isInternalChangeRef.current = false;
|
|
11682
11845
|
return;
|
|
11683
11846
|
}
|
|
11684
|
-
if (
|
|
11685
|
-
|
|
11847
|
+
if (getHTML() !== value) {
|
|
11848
|
+
const split = splitAttachmentsFromHtml(value);
|
|
11849
|
+
editor.commands.setContent(split.html, { emitUpdate: false });
|
|
11850
|
+
hydrateAttachments(split.attachments);
|
|
11686
11851
|
}
|
|
11687
11852
|
}, [value, editor]);
|
|
11688
11853
|
React6.useImperativeHandle(
|
|
11689
11854
|
ref,
|
|
11690
11855
|
() => ({
|
|
11691
|
-
getHTML
|
|
11856
|
+
getHTML,
|
|
11692
11857
|
getJSON: () => editor?.getJSON() ?? {},
|
|
11693
|
-
setContent
|
|
11694
|
-
editor?.commands.setContent(html);
|
|
11695
|
-
},
|
|
11858
|
+
setContent,
|
|
11696
11859
|
clearContent: () => {
|
|
11697
11860
|
editor?.commands.clearContent();
|
|
11698
11861
|
},
|
|
@@ -11705,7 +11868,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11705
11868
|
attachments,
|
|
11706
11869
|
editor
|
|
11707
11870
|
}),
|
|
11708
|
-
[editor, attachments]
|
|
11871
|
+
[editor, attachments, getHTML, setContent]
|
|
11709
11872
|
);
|
|
11710
11873
|
const isToolbarVisible = showToolbar && editable;
|
|
11711
11874
|
const imageFeatureEnabled = activeToolbar.image !== false;
|
|
@@ -11719,7 +11882,8 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11719
11882
|
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
11720
11883
|
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
11721
11884
|
};
|
|
11722
|
-
|
|
11885
|
+
const showFileCountUI = imageFeatureEnabled && !!fileCountUIRender;
|
|
11886
|
+
const editorBox = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11723
11887
|
"div",
|
|
11724
11888
|
{
|
|
11725
11889
|
className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
|
|
@@ -11750,7 +11914,7 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11750
11914
|
}
|
|
11751
11915
|
}
|
|
11752
11916
|
),
|
|
11753
|
-
imageFeatureEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, children: [
|
|
11917
|
+
imageFeatureEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(RichEditorDropZone, { className: "flex flex-1 flex-col", "data-rich-editor-theme": theme, onDropFiles: processFiles, children: [
|
|
11754
11918
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11755
11919
|
RichEditorContent,
|
|
11756
11920
|
{
|
|
@@ -11780,7 +11944,16 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11780
11944
|
)
|
|
11781
11945
|
]
|
|
11782
11946
|
}
|
|
11783
|
-
)
|
|
11947
|
+
);
|
|
11948
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RichEditorThemeProvider, { value: resolvedTheme, children: showFileCountUI ? (
|
|
11949
|
+
// 바깥에 position: relative 한 단만 더 둬서, fileCountUIRender가 돌려주는 요소가
|
|
11950
|
+
// absolute 포지션이면 에디터 박스 기준으로 겹쳐 뜨고, 일반 요소면 박스 바로 아래
|
|
11951
|
+
// 자연스러운 흐름으로 이어진다 — 호출부가 className 하나로 두 경우를 모두 고를 수 있다.
|
|
11952
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
11953
|
+
editorBox,
|
|
11954
|
+
fileCountUIRender({ count: attachmentCount, max: maxFiles })
|
|
11955
|
+
] })
|
|
11956
|
+
) : editorBox });
|
|
11784
11957
|
});
|
|
11785
11958
|
var RichEditor_default = RichEditor;
|
|
11786
11959
|
function useDetailController(params = {}) {
|