mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-22 00:37:05 +08:00
refactor(editor): remove dead code (#11709)
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
type SurfaceBlockModel,
|
||||
type SurfaceContext,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import { TemplateJob } from '@blocksuite/affine-gfx-template';
|
||||
import {
|
||||
type ConnectorElementModel,
|
||||
RootBlockSchema,
|
||||
@@ -39,8 +38,6 @@ export class EdgelessRootService extends RootService implements SurfaceContext {
|
||||
|
||||
private readonly _surface: SurfaceBlockModel;
|
||||
|
||||
TemplateJob = TemplateJob;
|
||||
|
||||
get blocks(): GfxBlockElementModel[] {
|
||||
return this.layer.blocks;
|
||||
}
|
||||
|
||||
@@ -1,48 +1,6 @@
|
||||
import { RootBlockSchema } from '@blocksuite/affine-model';
|
||||
import {
|
||||
getBlockSelectionsCommand,
|
||||
getImageSelectionsCommand,
|
||||
getSelectedBlocksCommand,
|
||||
getTextSelectionCommand,
|
||||
} from '@blocksuite/affine-shared/commands';
|
||||
import type { BlockComponent } from '@blocksuite/std';
|
||||
import { BlockService } from '@blocksuite/std';
|
||||
|
||||
import type { RootBlockComponent } from './types.js';
|
||||
|
||||
export abstract class RootService extends BlockService {
|
||||
static override readonly flavour = RootBlockSchema.model.flavour;
|
||||
|
||||
get selectedBlocks() {
|
||||
let result: BlockComponent[] = [];
|
||||
this.std.command
|
||||
.chain()
|
||||
.tryAll(chain => [
|
||||
chain.pipe(getTextSelectionCommand),
|
||||
chain.pipe(getImageSelectionsCommand),
|
||||
chain.pipe(getBlockSelectionsCommand),
|
||||
])
|
||||
.pipe(getSelectedBlocksCommand)
|
||||
.pipe(({ selectedBlocks }) => {
|
||||
if (!selectedBlocks) return;
|
||||
result = selectedBlocks;
|
||||
})
|
||||
.run();
|
||||
return result;
|
||||
}
|
||||
|
||||
get selectedModels() {
|
||||
return this.selectedBlocks.map(block => block.model);
|
||||
}
|
||||
|
||||
get viewportElement() {
|
||||
const rootId = this.std.store.root?.id;
|
||||
if (!rootId) return null;
|
||||
const rootComponent = this.std.view.getBlock(
|
||||
rootId
|
||||
) as RootBlockComponent | null;
|
||||
if (!rootComponent) return null;
|
||||
const viewportElement = rootComponent.viewportElement;
|
||||
return viewportElement;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user