mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
refactor: remove unused surface service (#11339)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Command } from '@blocksuite/std';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
||||
|
||||
import { SurfaceBlockService } from '../surface-service';
|
||||
import type { SurfaceBlockModel } from '../surface-model';
|
||||
|
||||
/**
|
||||
* Re-associate bindings for block that have been converted.
|
||||
@@ -13,14 +14,14 @@ export const reassociateConnectorsCommand: Command<{
|
||||
newId: string;
|
||||
}> = (ctx, next) => {
|
||||
const { oldId, newId } = ctx;
|
||||
const service = ctx.std.get(SurfaceBlockService);
|
||||
if (!oldId || !newId || !service) {
|
||||
const gfx = ctx.std.get(GfxControllerIdentifier);
|
||||
if (!oldId || !newId || !gfx.surface) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
const surface = service.surface;
|
||||
const connectors = surface.getConnectors(oldId);
|
||||
const surface = gfx.surface;
|
||||
const connectors = (surface as SurfaceBlockModel).getConnectors(oldId);
|
||||
for (const { id, source, target } of connectors) {
|
||||
if (source.id === oldId) {
|
||||
surface.updateElement(id, {
|
||||
|
||||
@@ -56,7 +56,6 @@ export {
|
||||
SurfaceBlockSchema,
|
||||
SurfaceBlockSchemaExtension,
|
||||
} from './surface-model.js';
|
||||
export type { SurfaceBlockService } from './surface-service.js';
|
||||
export {
|
||||
EdgelessSurfaceBlockSpec,
|
||||
PageSurfaceBlockSpec,
|
||||
|
||||
@@ -2,12 +2,8 @@ import { BlockComponent } from '@blocksuite/std';
|
||||
import { nothing } from 'lit';
|
||||
|
||||
import type { SurfaceBlockModel } from './surface-model.js';
|
||||
import type { SurfaceBlockService } from './surface-service.js';
|
||||
|
||||
export class SurfaceBlockVoidComponent extends BlockComponent<
|
||||
SurfaceBlockModel,
|
||||
SurfaceBlockService
|
||||
> {
|
||||
export class SurfaceBlockVoidComponent extends BlockComponent<SurfaceBlockModel> {
|
||||
override render() {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
} from './renderer/elements/index.js';
|
||||
import { OverlayIdentifier } from './renderer/overlay.js';
|
||||
import type { SurfaceBlockModel } from './surface-model.js';
|
||||
import type { SurfaceBlockService } from './surface-service.js';
|
||||
|
||||
export interface SurfaceContext {
|
||||
viewport: Viewport;
|
||||
@@ -31,10 +30,7 @@ export interface SurfaceContext {
|
||||
};
|
||||
}
|
||||
|
||||
export class SurfaceBlockComponent extends BlockComponent<
|
||||
SurfaceBlockModel,
|
||||
SurfaceBlockService
|
||||
> {
|
||||
export class SurfaceBlockComponent extends BlockComponent<SurfaceBlockModel> {
|
||||
static isConnector = (element: unknown): element is ConnectorElementModel => {
|
||||
return element instanceof ConnectorElementModel;
|
||||
};
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { BlockService } from '@blocksuite/std';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
||||
|
||||
import { type SurfaceBlockModel, SurfaceBlockSchema } from './surface-model.js';
|
||||
import { getSurfaceBlock } from './utils/get-surface-block.js';
|
||||
|
||||
export class SurfaceBlockService extends BlockService {
|
||||
static override readonly flavour = SurfaceBlockSchema.model.flavour;
|
||||
|
||||
surface!: SurfaceBlockModel;
|
||||
|
||||
get layer() {
|
||||
return this.std.get(GfxControllerIdentifier).layer;
|
||||
}
|
||||
|
||||
override mounted(): void {
|
||||
super.mounted();
|
||||
|
||||
const surface = getSurfaceBlock(this.doc);
|
||||
|
||||
// FIXME: BS-2271
|
||||
this.surface = surface!;
|
||||
|
||||
if (!this.surface) {
|
||||
const disposable = this.doc.slots.blockUpdated.subscribe(payload => {
|
||||
if (payload.flavour === 'affine:surface') {
|
||||
disposable.unsubscribe();
|
||||
const surface = this.doc.getModelById(
|
||||
payload.id
|
||||
) as SurfaceBlockModel | null;
|
||||
if (!surface) return;
|
||||
this.surface = surface;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,9 @@ import {
|
||||
EdgelessLegacySlotExtension,
|
||||
} from './extensions';
|
||||
import { ExportManagerExtension } from './extensions/export-manager/export-manager';
|
||||
import { SurfaceBlockService } from './surface-service';
|
||||
|
||||
const CommonSurfaceBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:surface'),
|
||||
SurfaceBlockService,
|
||||
EdgelessCRUDExtension,
|
||||
EdgelessLegacySlotExtension,
|
||||
ExportManagerExtension,
|
||||
|
||||
Reference in New Issue
Block a user