mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 09:59:55 +08:00
refactor(editor): unify directories naming (#11516)
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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