mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): reorg block specs (#9421)
This commit is contained in:
@@ -14,13 +14,7 @@ import {
|
||||
DataViewBlockSpec,
|
||||
DividerBlockSpec,
|
||||
EditPropsStore,
|
||||
EmbedFigmaBlockSpec,
|
||||
EmbedGithubBlockSpec,
|
||||
EmbedHtmlBlockSpec,
|
||||
EmbedLinkedDocBlockSpec,
|
||||
EmbedLoomBlockSpec,
|
||||
EmbedSyncedDocBlockSpec,
|
||||
EmbedYoutubeBlockSpec,
|
||||
EmbedExtensions,
|
||||
ImageBlockSpec,
|
||||
LatexBlockSpec,
|
||||
ListBlockSpec,
|
||||
@@ -30,7 +24,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
|
||||
const CommonBlockSpecs: ExtensionType[] = [
|
||||
RefNodeSlotsExtension(),
|
||||
RefNodeSlotsExtension,
|
||||
EditPropsStore,
|
||||
RichTextExtensions,
|
||||
LatexBlockSpec,
|
||||
@@ -38,16 +32,9 @@ const CommonBlockSpecs: ExtensionType[] = [
|
||||
DatabaseBlockSpec,
|
||||
DataViewBlockSpec,
|
||||
DividerBlockSpec,
|
||||
EmbedExtensions,
|
||||
BookmarkBlockSpec,
|
||||
EmbedFigmaBlockSpec,
|
||||
EmbedGithubBlockSpec,
|
||||
EmbedYoutubeBlockSpec,
|
||||
EmbedLoomBlockSpec,
|
||||
EmbedHtmlBlockSpec,
|
||||
EmbedSyncedDocBlockSpec,
|
||||
EmbedLinkedDocBlockSpec,
|
||||
AttachmentBlockSpec,
|
||||
// special
|
||||
AdapterFactoryExtensions,
|
||||
].flat();
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import { isNewTabTrigger } from '@affine/core/utils';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { track } from '@affine/track';
|
||||
import {
|
||||
type BlockService,
|
||||
BlockServiceWatcher,
|
||||
BlockViewIdentifier,
|
||||
ConfigIdentifier,
|
||||
@@ -44,7 +43,6 @@ import type {
|
||||
PeekViewService as BSPeekViewService,
|
||||
QuickSearchResult,
|
||||
RootBlockConfig,
|
||||
RootService,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import {
|
||||
AffineSlashMenuWidget,
|
||||
@@ -81,21 +79,15 @@ export type ReferenceReactRenderer = (
|
||||
|
||||
const logger = new DebugLogger('affine::spec-patchers');
|
||||
|
||||
function patchSpecService<Service extends BlockService = BlockService>(
|
||||
function patchSpecService(
|
||||
flavour: string,
|
||||
onMounted: (service: Service) => (() => void) | void,
|
||||
onWidgetConnected?: (component: WidgetComponent) => void
|
||||
) {
|
||||
class TempServiceWatcher extends BlockServiceWatcher {
|
||||
static override readonly flavour = flavour;
|
||||
override mounted() {
|
||||
super.mounted();
|
||||
const disposable = onMounted(this.blockService as any);
|
||||
const disposableGroup = this.blockService.disposables;
|
||||
if (disposable) {
|
||||
disposableGroup.add(disposable);
|
||||
}
|
||||
|
||||
if (onWidgetConnected) {
|
||||
disposableGroup.add(
|
||||
this.blockService.specSlots.widgetConnected.on(({ component }) => {
|
||||
@@ -424,9 +416,8 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
|
||||
},
|
||||
});
|
||||
|
||||
const SlashMenuQuickSearchExtension = patchSpecService<RootService>(
|
||||
const SlashMenuQuickSearchExtension = patchSpecService(
|
||||
'affine:page',
|
||||
() => {},
|
||||
(component: WidgetComponent) => {
|
||||
if (component instanceof AffineSlashMenuWidget) {
|
||||
component.config.items.forEach(item => {
|
||||
|
||||
Reference in New Issue
Block a user