🩹(frontent) change selector to block cmd+k
Multiple ctrl+k could open the search modal, we change the selector, now if the toolbar is displayed we don't open the search modal.
This commit is contained in:
@@ -15,7 +15,15 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchModal = useModal();
|
const searchModal = useModal();
|
||||||
const { authenticated } = useAuth();
|
const { authenticated } = useAuth();
|
||||||
useCmdK(searchModal.open);
|
useCmdK(() => {
|
||||||
|
const isEditorToolbarOpen =
|
||||||
|
document.getElementsByClassName('bn-formatting-toolbar').length > 0;
|
||||||
|
if (isEditorToolbarOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
searchModal.open();
|
||||||
|
});
|
||||||
const { togglePanel } = useLeftPanelStore();
|
const { togglePanel } = useLeftPanelStore();
|
||||||
|
|
||||||
const { mutate: createDoc } = useCreateDoc({
|
const { mutate: createDoc } = useCreateDoc({
|
||||||
|
|||||||
@@ -6,12 +6,6 @@ export const useCmdK = (callback: () => void) => {
|
|||||||
if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
|
if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const isProseMirrorFocused =
|
|
||||||
document.activeElement?.classList.contains('ProseMirror');
|
|
||||||
if (isProseMirrorFocused) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user