feat: change cursor when drag

This commit is contained in:
SaikaSakura
2022-07-26 18:49:18 +08:00
parent 9cc55d7f63
commit 8b8529c1be
10 changed files with 100 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
import {
AsyncBlock,
BlockEditor,
SelectEventTypes,
SelectionInfo,
SelectionSettingsMap,
@@ -202,3 +203,21 @@ export const useOnSelectStartWith = (
};
}, [editor, cb, blockId]);
};
/**
*
* hooks run when drag state change
* @export
*/
export const useIsOnDrag = (editor: BlockEditor) => {
const editorInstance = editor;
const [isOnDrag, setIsOnDrag] = useState(false);
useEffect(() => {
const callback = (isDrag: boolean) => setIsOnDrag(isDrag);
editorInstance.dragDropManager.onDragStateChange(callback);
return () => {
editorInstance.dragDropManager.offDragStateChange(callback);
};
}, [editorInstance]);
return isOnDrag;
};