mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-04 19:15:33 +08:00
refactor(editor): remove page root service (#12048)
This commit is contained in:
@@ -78,8 +78,7 @@ export class ImageResizeManager {
|
||||
const rootComponent = getClosestRootBlockComponent(this._activeComponent);
|
||||
if (
|
||||
rootComponent &&
|
||||
rootComponent.service.std.get(DocModeProvider).getEditorMode() ===
|
||||
'edgeless'
|
||||
rootComponent.std.get(DocModeProvider).getEditorMode() === 'edgeless'
|
||||
) {
|
||||
const viewport = rootComponent.std.get(GfxControllerIdentifier).viewport;
|
||||
this._zoom = viewport.zoom;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
RootBlockSchema,
|
||||
} from '@blocksuite/affine-model';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type { BlockStdScope } from '@blocksuite/std';
|
||||
import { BlockService, type BlockStdScope } from '@blocksuite/std';
|
||||
import type {
|
||||
GfxController,
|
||||
GfxModel,
|
||||
@@ -30,10 +30,12 @@ import {
|
||||
import { effect } from '@preact/signals-core';
|
||||
import clamp from 'lodash-es/clamp';
|
||||
|
||||
import { RootService } from '../root-service.js';
|
||||
import { getCursorMode } from './utils/query.js';
|
||||
|
||||
export class EdgelessRootService extends RootService implements SurfaceContext {
|
||||
export class EdgelessRootService
|
||||
extends BlockService
|
||||
implements SurfaceContext
|
||||
{
|
||||
static override readonly flavour = RootBlockSchema.model.flavour;
|
||||
|
||||
private readonly _surface: SurfaceBlockModel;
|
||||
|
||||
@@ -10,10 +10,8 @@ export * from './edgeless/edgeless-builtin-spec.js';
|
||||
export * from './edgeless/edgeless-root-spec.js';
|
||||
export * from './edgeless/index.js';
|
||||
export * from './page/page-root-block.js';
|
||||
export { PageRootService } from './page/page-root-service.js';
|
||||
export * from './page/page-root-spec.js';
|
||||
export * from './preview/preview-root-block.js';
|
||||
export { RootService } from './root-service.js';
|
||||
export * from './types.js';
|
||||
export * from './utils/index.js';
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import { query } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
|
||||
import { PageKeyboardManager } from '../keyboard/keyboard-manager.js';
|
||||
import type { PageRootService } from './page-root-service.js';
|
||||
|
||||
const DOC_BLOCK_CHILD_PADDING = 24;
|
||||
const DOC_BOTTOM_PADDING = 32;
|
||||
@@ -49,10 +48,7 @@ function testClickOnBlankArea(
|
||||
return state.raw.clientX < blankLeft || state.raw.clientX > blankRight;
|
||||
}
|
||||
|
||||
export class PageRootBlockComponent extends BlockComponent<
|
||||
RootBlockModel,
|
||||
PageRootService
|
||||
> {
|
||||
export class PageRootBlockComponent extends BlockComponent<RootBlockModel> {
|
||||
static override styles = css`
|
||||
editor-host:has(> affine-page-root, * > affine-page-root) {
|
||||
display: block;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { RootBlockSchema } from '@blocksuite/affine-model';
|
||||
|
||||
import { RootService } from '../root-service.js';
|
||||
|
||||
export class PageRootService extends RootService {
|
||||
static override readonly flavour = RootBlockSchema.model.flavour;
|
||||
}
|
||||
@@ -5,11 +5,9 @@ import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { PageClipboard } from '../clipboard/page-clipboard.js';
|
||||
import { CommonSpecs } from '../common-specs/index.js';
|
||||
import { PageRootService } from './page-root-service.js';
|
||||
|
||||
const PageCommonExtension: ExtensionType[] = [
|
||||
CommonSpecs,
|
||||
PageRootService,
|
||||
ViewportElementExtension('.affine-page-viewport'),
|
||||
].flat();
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { RootBlockSchema } from '@blocksuite/affine-model';
|
||||
import { BlockService } from '@blocksuite/std';
|
||||
|
||||
export abstract class RootService extends BlockService {
|
||||
static override readonly flavour = RootBlockSchema.model.flavour;
|
||||
}
|
||||
@@ -270,12 +270,8 @@ import snapshot from '../snapshots/edgeless/surface-ref.spec.ts/surface-ref.json
|
||||
describe('clipboard', () => {
|
||||
test('import surface-ref snapshot should render content correctly', async () => {
|
||||
await setupEditor('page');
|
||||
|
||||
const pageRoot = getDocRootBlock(doc, editor, 'page');
|
||||
const pageRootService = pageRoot.service;
|
||||
|
||||
const newDoc = await importFromSnapshot(
|
||||
pageRootService.collection,
|
||||
doc.workspace,
|
||||
snapshot as DocSnapshot
|
||||
);
|
||||
expect(newDoc).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user