refactor(editor): reduce getService (#10100)

This commit is contained in:
Saul-Mirone
2025-02-11 12:26:01 +00:00
parent dbf0f9dc20
commit 6b78d2dcf2
33 changed files with 189 additions and 300 deletions

View File

@@ -19,6 +19,7 @@ import './left-side-panel.js';
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ShadowlessElement } from '@blocksuite/block-std';
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
import {
ColorScheme,
ColorVariables,
@@ -28,7 +29,6 @@ import {
type DocMode,
DocModeProvider,
download,
EdgelessRootService,
ExportManager,
FontFamilyVariables,
HtmlAdapterFactoryIdentifier,
@@ -210,10 +210,6 @@ export class StarterDebugMenu extends ShadowlessElement {
this.editor.mode = value;
}
get rootService() {
return this.editor.std?.getService('affine:page');
}
private _addNote() {
const rootModel = this.doc.root;
if (!rootModel) return;
@@ -544,18 +540,8 @@ export class StarterDebugMenu extends ShadowlessElement {
private _present() {
if (!this.editor.std || !this.editor.host) return;
const rootService = this.editor.std.getService('affine:page');
if (!(rootService instanceof EdgelessRootService)) {
toast(
this.editor.host,
'The presentation mode is only available on edgeless mode.',
3000
);
return;
}
const edgelessRootService = rootService as EdgelessRootService;
edgelessRootService?.gfx.tool.setTool('frameNavigator', {
const gfx = this.editor.std.get(GfxControllerIdentifier);
gfx.tool.setTool('frameNavigator', {
mode: 'fit',
});
}