mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): improve std structure (#10993)
This commit is contained in:
14
blocksuite/framework/block-std/src/inline/range/active.ts
Normal file
14
blocksuite/framework/block-std/src/inline/range/active.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Check if the active element is in the editor host.
|
||||
* TODO(@mirone): this is a trade-off, we need to use separate awareness store for every store to make sure the selection is isolated.
|
||||
*
|
||||
* @param editorHost - The editor host element.
|
||||
* @returns Whether the active element is in the editor host.
|
||||
*/
|
||||
export function isActiveInEditor(editorHost: HTMLElement) {
|
||||
const currentActiveElement = document.activeElement;
|
||||
if (!currentActiveElement) return false;
|
||||
const currentEditorHost = currentActiveElement?.closest('editor-host');
|
||||
if (!currentEditorHost) return false;
|
||||
return currentEditorHost === editorHost;
|
||||
}
|
||||
Reference in New Issue
Block a user