mirror of
https://github.com/xuquan-nikkkki/FolderFile-Splitter-Plugin.git
synced 2026-07-22 12:00:27 +00:00
fix: show file icon when drag files
This commit is contained in:
parent
b0d3327293
commit
3f54fdfa69
1 changed files with 15 additions and 3 deletions
|
|
@ -1,10 +1,14 @@
|
|||
import { TFile } from "obsidian";
|
||||
import { useDragLayer } from "react-dnd";
|
||||
import {
|
||||
FFS_DRAG_FILES_TYPE,
|
||||
FFS_DRAG_FOLDER_TYPE,
|
||||
} from "src/assets/constants";
|
||||
|
||||
const CustomDragLayer = () => {
|
||||
const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
||||
const { isDragging, currentOffset, itemType } = useDragLayer((monitor) => ({
|
||||
isDragging: monitor.isDragging(),
|
||||
item: monitor.getItem(),
|
||||
itemType: monitor.getItemType(),
|
||||
currentOffset: monitor.getClientOffset(),
|
||||
}));
|
||||
|
||||
|
|
@ -12,6 +16,14 @@ const CustomDragLayer = () => {
|
|||
return null;
|
||||
}
|
||||
|
||||
const renderDraggingIcon = () => {
|
||||
if (itemType === FFS_DRAG_FOLDER_TYPE) {
|
||||
return "📁";
|
||||
} else if (itemType === FFS_DRAG_FILES_TYPE) {
|
||||
return "📄";
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
|
@ -24,7 +36,7 @@ const CustomDragLayer = () => {
|
|||
zIndex: 100,
|
||||
}}
|
||||
>
|
||||
{item instanceof TFile ? "📄" : "📁"}
|
||||
{renderDraggingIcon()}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue