mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 20:41:50 +08:00
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
type StoreExtensionContext,
|
||||
StoreExtensionProvider,
|
||||
} from '@blocksuite/affine-ext-loader';
|
||||
import { NoteBlockSchemaExtension } from '@blocksuite/affine-model';
|
||||
import { z } from 'zod';
|
||||
|
||||
import {
|
||||
DocNoteBlockAdapterExtensions,
|
||||
EdgelessNoteBlockAdapterExtensions,
|
||||
} from './adapters';
|
||||
|
||||
const optionsSchema = z.object({
|
||||
mode: z.enum(['doc', 'edgeless']).optional(),
|
||||
});
|
||||
|
||||
export class NoteStoreExtension extends StoreExtensionProvider<
|
||||
z.infer<typeof optionsSchema>
|
||||
> {
|
||||
override name = 'affine-note-block';
|
||||
|
||||
override schema = optionsSchema;
|
||||
|
||||
override setup(
|
||||
context: StoreExtensionContext,
|
||||
options?: z.infer<typeof optionsSchema>
|
||||
) {
|
||||
super.setup(context);
|
||||
context.register(NoteBlockSchemaExtension);
|
||||
if (options?.mode === 'edgeless') {
|
||||
context.register(EdgelessNoteBlockAdapterExtensions);
|
||||
} else {
|
||||
context.register(DocNoteBlockAdapterExtensions);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user