mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 01:49:51 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from './toolbar.js';
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { MenuItemGroup } from '@blocksuite/affine-components/toolbar';
|
||||
import type { BlockStdScope, EditorHost } from '@blocksuite/block-std';
|
||||
import type { GfxModel } from '@blocksuite/block-std/gfx';
|
||||
import type { BlockModel, Doc } from '@blocksuite/store';
|
||||
|
||||
export abstract class MenuContext {
|
||||
abstract get doc(): Doc;
|
||||
|
||||
get firstElement(): GfxModel | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract get host(): EditorHost;
|
||||
|
||||
abstract get selectedBlockModels(): BlockModel[];
|
||||
|
||||
abstract get std(): BlockStdScope;
|
||||
|
||||
// Sometimes we need to close the menu.
|
||||
close() {}
|
||||
|
||||
isElement() {
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract isEmpty(): boolean;
|
||||
|
||||
abstract isMultiple(): boolean;
|
||||
|
||||
abstract isSingle(): boolean;
|
||||
}
|
||||
|
||||
export interface ToolbarMoreMenuConfig {
|
||||
configure: <T extends MenuContext>(
|
||||
groups: MenuItemGroup<T>[]
|
||||
) => MenuItemGroup<T>[];
|
||||
}
|
||||
|
||||
export function getMoreMenuConfig(std: BlockStdScope): ToolbarMoreMenuConfig {
|
||||
return {
|
||||
configure: <T extends MenuContext>(groups: MenuItemGroup<T>[]) => groups,
|
||||
...std.getConfig('affine:page')?.toolbarMoreMenu,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user