fix(editor): ref on click slots should not be global (#9830)

fix AF-2129
This commit is contained in:
pengx17
2025-01-22 05:20:55 +00:00
parent 720a596559
commit 4c665594d6
15 changed files with 47 additions and 20 deletions

View File

@@ -30,7 +30,10 @@ import { pageHistoryModalAtom } from '../../../components/atoms/page-history';
import { useBlockSuiteMetaHelper } from './use-block-suite-meta-helper';
import { useExportPage } from './use-export-page';
export function useRegisterBlocksuiteEditorCommands(editor: Editor) {
export function useRegisterBlocksuiteEditorCommands(
editor: Editor,
active: boolean
) {
const doc = useService(DocService).doc;
const docId = doc.id;
const mode = useLiveData(editor.mode$);
@@ -82,6 +85,10 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) {
const openInAppService = useServiceOptional(OpenInAppService);
useEffect(() => {
if (!active) {
return;
}
const unsubs: Array<() => void> = [];
const preconditionStrategy = () =>
PreconditionStrategy.InPaperOrEdgeless && !trash;
@@ -375,5 +382,6 @@ export function useRegisterBlocksuiteEditorCommands(editor: Editor) {
defaultPageWidth,
checked,
openInAppService,
active,
]);
}

View File

@@ -25,6 +25,9 @@ export function useRegisterCopyLinkCommands({
});
useEffect(() => {
if (!isActiveView) {
return;
}
const unsubs: Array<() => void> = [];
unsubs.push(