1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/gui/NoteEditor/utils/getWindowCommandPriority.ts
Henry Heino 4a88d6ff7a
Desktop: Multiple window support (#11181)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-11-08 15:32:05 +00:00

16 lines
522 B
TypeScript

import { RefObject } from 'react';
const getWindowCommandPriority = <T extends HTMLElement> (contentContainer: RefObject<T>) => {
if (!contentContainer.current) return 0;
const containerDocument = contentContainer.current.getRootNode() as Document;
if (!containerDocument || !containerDocument.hasFocus()) return 0;
if (contentContainer.current.contains(containerDocument.activeElement)) {
return 2;
}
// Container document has focus, but not this editor.
return 1;
};
export default getWindowCommandPriority;