mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
**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`
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { type Container, createIdentifier } from '@blocksuite/global/di';
|
|
import {
|
|
type BlockStdScope,
|
|
StdIdentifier,
|
|
WidgetViewExtension,
|
|
} from '@blocksuite/std';
|
|
import { Extension, type ExtensionType } from '@blocksuite/store';
|
|
import { literal, unsafeStatic } from 'lit/static-html.js';
|
|
|
|
import { defaultSlashMenuConfig } from './config';
|
|
import { AFFINE_SLASH_MENU_WIDGET } from './consts';
|
|
import type { SlashMenuConfig } from './types';
|
|
import { mergeSlashMenuConfigs } from './utils';
|
|
|
|
export class SlashMenuExtension extends Extension {
|
|
config: SlashMenuConfig;
|
|
|
|
static override setup(di: Container) {
|
|
WidgetViewExtension(
|
|
'affine:page',
|
|
AFFINE_SLASH_MENU_WIDGET,
|
|
literal`${unsafeStatic(AFFINE_SLASH_MENU_WIDGET)}`
|
|
).setup(di);
|
|
|
|
di.add(this, [StdIdentifier]);
|
|
|
|
SlashMenuConfigExtension('default', defaultSlashMenuConfig).setup(di);
|
|
}
|
|
|
|
constructor(readonly std: BlockStdScope) {
|
|
super();
|
|
this.config = mergeSlashMenuConfigs(
|
|
this.std.provider.getAll(SlashMenuConfigIdentifier)
|
|
);
|
|
}
|
|
}
|
|
|
|
export const SlashMenuConfigIdentifier = createIdentifier<SlashMenuConfig>(
|
|
`${AFFINE_SLASH_MENU_WIDGET}-config`
|
|
);
|
|
|
|
export function SlashMenuConfigExtension(
|
|
id: string,
|
|
config: SlashMenuConfig
|
|
): ExtensionType {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(SlashMenuConfigIdentifier(id), config);
|
|
},
|
|
};
|
|
}
|