mirror of https://github.com/usememos/memos
feat: implement drag and drop for resource order in editor (#3337)
* Implement drag and drop for resource order in editor * chore: update * chore: update * chore: updatepull/3338/head
parent
5f207c8f0c
commit
3fbc4d8539
@ -0,0 +1,25 @@
|
||||
import { useSortable } from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
className: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const SortableItem: React.FC<Props> = ({ id, className, children }: Props) => {
|
||||
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });
|
||||
|
||||
const style = {
|
||||
transform: CSS.Transform.toString(transform),
|
||||
transition,
|
||||
};
|
||||
|
||||
return (
|
||||
<div ref={setNodeRef} style={style} {...attributes} {...listeners} className={className}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SortableItem;
|
||||
Loading…
Reference in New Issue