chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions
@@ -0,0 +1,35 @@
import { BlockService } from '@blocksuite/block-std';
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
import { type SurfaceBlockModel, SurfaceBlockSchema } from './surface-model.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();
this.surface = this.doc.getBlockByFlavour(
'affine:surface'
)[0] as SurfaceBlockModel;
if (!this.surface) {
const disposable = this.doc.slots.blockUpdated.on(payload => {
if (payload.flavour === 'affine:surface') {
disposable.dispose();
const surface = this.doc.getBlockById(
payload.id
) as SurfaceBlockModel | null;
if (!surface) return;
this.surface = surface;
}
});
}
}
}