mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 02:21:51 +08:00
feat(editor): root block extension (#12063)
Closes: BS-3202 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new root block store and view extensions, enhancing modularity and integration options for root block functionality. - Exported the EdgelessLocker class for broader usage. - **Improvements** - Updated export paths for root block modules, enabling clearer and more flexible module access. - Enhanced view extension setup to better tailor user interface and interactions based on context. - **Removals** - Removed legacy migrating store and view extension logic, streamlining extension management and reducing unused code. - Removed multiple deprecated block specifications and common extension collections to simplify the codebase. - Deleted AI page root block specification, retaining only lifecycle watcher functionality. - **Chores** - Updated dependencies and project references to support new extension loader integration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import { effects as blockRootEffects } from '@blocksuite/affine-block-root/effects';
|
||||
import { effects as fragmentDocTitleEffects } from '@blocksuite/affine-fragment-doc-title/effects';
|
||||
import { effects as fragmentFramePanelEffects } from '@blocksuite/affine-fragment-frame-panel/effects';
|
||||
import { effects as fragmentOutlineEffects } from '@blocksuite/affine-fragment-outline/effects';
|
||||
|
||||
export function effects() {
|
||||
blockRootEffects();
|
||||
|
||||
fragmentDocTitleEffects();
|
||||
fragmentFramePanelEffects();
|
||||
fragmentOutlineEffects();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import {
|
||||
RootBlockHtmlAdapterExtension,
|
||||
RootBlockMarkdownAdapterExtension,
|
||||
RootBlockNotionHtmlAdapterExtension,
|
||||
} from '@blocksuite/affine-block-root';
|
||||
import {
|
||||
type StoreExtensionContext,
|
||||
StoreExtensionProvider,
|
||||
} from '@blocksuite/affine-ext-loader';
|
||||
import { RootBlockSchemaExtension } from '@blocksuite/affine-model';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
const defaultBlockHtmlAdapterMatchers = [RootBlockHtmlAdapterExtension];
|
||||
|
||||
const defaultBlockMarkdownAdapterMatchers = [RootBlockMarkdownAdapterExtension];
|
||||
|
||||
const defaultBlockNotionHtmlAdapterMatchers: ExtensionType[] = [
|
||||
RootBlockNotionHtmlAdapterExtension,
|
||||
];
|
||||
|
||||
function getHtmlAdapterExtensions(): ExtensionType[] {
|
||||
return [...defaultBlockHtmlAdapterMatchers];
|
||||
}
|
||||
|
||||
function getMarkdownAdapterExtensions(): ExtensionType[] {
|
||||
return [...defaultBlockMarkdownAdapterMatchers];
|
||||
}
|
||||
|
||||
function getNotionHtmlAdapterExtensions(): ExtensionType[] {
|
||||
return [...defaultBlockNotionHtmlAdapterMatchers];
|
||||
}
|
||||
|
||||
const MigratingStoreExtensions: ExtensionType[] = [
|
||||
RootBlockSchemaExtension,
|
||||
|
||||
getHtmlAdapterExtensions(),
|
||||
getMarkdownAdapterExtensions(),
|
||||
getNotionHtmlAdapterExtensions(),
|
||||
].flat();
|
||||
|
||||
export class MigratingStoreExtension extends StoreExtensionProvider {
|
||||
override name = 'migrating';
|
||||
|
||||
override setup(context: StoreExtensionContext) {
|
||||
super.setup(context);
|
||||
context.register(MigratingStoreExtensions);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,6 @@ import {
|
||||
} from '@blocksuite/affine-ext-loader';
|
||||
|
||||
import { effects } from './effects';
|
||||
import {
|
||||
MigratingEdgelessEditorBlockSpecs,
|
||||
MigratingPageEditorBlockSpecs,
|
||||
MigratingPreviewEdgelessEditorBlockSpecs,
|
||||
MigratingPreviewPageEditorBlockSpecs,
|
||||
} from './migrating';
|
||||
|
||||
export class MigratingViewExtension extends ViewExtensionProvider {
|
||||
override name = 'migrating';
|
||||
@@ -21,22 +15,5 @@ export class MigratingViewExtension extends ViewExtensionProvider {
|
||||
|
||||
override setup(context: ViewExtensionContext) {
|
||||
super.setup(context);
|
||||
const scope = context.scope;
|
||||
if (scope === 'preview-page') {
|
||||
context.register(MigratingPreviewPageEditorBlockSpecs);
|
||||
return;
|
||||
}
|
||||
if (scope === 'preview-edgeless') {
|
||||
context.register(MigratingPreviewEdgelessEditorBlockSpecs);
|
||||
return;
|
||||
}
|
||||
if (scope === 'page' || scope === 'mobile-page') {
|
||||
context.register(MigratingPageEditorBlockSpecs);
|
||||
return;
|
||||
}
|
||||
if (scope === 'edgeless' || scope === 'mobile-edgeless') {
|
||||
context.register(MigratingEdgelessEditorBlockSpecs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import {
|
||||
EdgelessBuiltInSpecs,
|
||||
PageRootBlockSpec,
|
||||
PreviewEdgelessRootBlockSpec,
|
||||
PreviewPageRootBlockSpec,
|
||||
ReadOnlyClipboard,
|
||||
} from '@blocksuite/affine-block-root';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
export const MigratingEdgelessEditorBlockSpecs: ExtensionType[] = [
|
||||
EdgelessBuiltInSpecs,
|
||||
].flat();
|
||||
|
||||
export const MigratingPageEditorBlockSpecs: ExtensionType[] = [
|
||||
PageRootBlockSpec,
|
||||
].flat();
|
||||
|
||||
export const MigratingPreviewEdgelessEditorBlockSpecs: ExtensionType[] = [
|
||||
PreviewEdgelessRootBlockSpec,
|
||||
ReadOnlyClipboard,
|
||||
].flat();
|
||||
|
||||
export const MigratingPreviewPageEditorBlockSpecs: ExtensionType[] = [
|
||||
PreviewPageRootBlockSpec,
|
||||
ReadOnlyClipboard,
|
||||
].flat();
|
||||
@@ -13,6 +13,7 @@ import { LatexStoreExtension } from '@blocksuite/affine-block-latex/store';
|
||||
import { ListStoreExtension } from '@blocksuite/affine-block-list/store';
|
||||
import { NoteStoreExtension } from '@blocksuite/affine-block-note/store';
|
||||
import { ParagraphStoreExtension } from '@blocksuite/affine-block-paragraph/store';
|
||||
import { RootStoreExtension } from '@blocksuite/affine-block-root/store';
|
||||
import { SurfaceStoreExtension } from '@blocksuite/affine-block-surface/store';
|
||||
import { SurfaceRefStoreExtension } from '@blocksuite/affine-block-surface-ref/store';
|
||||
import { TableStoreExtension } from '@blocksuite/affine-block-table/store';
|
||||
@@ -29,8 +30,6 @@ import { LinkStoreExtension } from '@blocksuite/affine-inline-link/store';
|
||||
import { InlinePresetStoreExtension } from '@blocksuite/affine-inline-preset/store';
|
||||
import { ReferenceStoreExtension } from '@blocksuite/affine-inline-reference/store';
|
||||
|
||||
import { MigratingStoreExtension } from './migrating-store';
|
||||
|
||||
export function getInternalStoreExtensions() {
|
||||
return [
|
||||
FoundationStoreExtension,
|
||||
@@ -53,6 +52,7 @@ export function getInternalStoreExtensions() {
|
||||
SurfaceRefStoreExtension,
|
||||
TableStoreExtension,
|
||||
SurfaceStoreExtension,
|
||||
RootStoreExtension,
|
||||
|
||||
FootnoteStoreExtension,
|
||||
LinkStoreExtension,
|
||||
@@ -66,7 +66,5 @@ export function getInternalStoreExtensions() {
|
||||
ConnectorStoreExtension,
|
||||
GroupStoreExtension,
|
||||
TextStoreExtension,
|
||||
|
||||
MigratingStoreExtension,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { LatexViewExtension } from '@blocksuite/affine-block-latex/view';
|
||||
import { ListViewExtension } from '@blocksuite/affine-block-list/view';
|
||||
import { NoteViewExtension } from '@blocksuite/affine-block-note/view';
|
||||
import { ParagraphViewExtension } from '@blocksuite/affine-block-paragraph/view';
|
||||
import { RootViewExtension } from '@blocksuite/affine-block-root/view';
|
||||
import { SurfaceViewExtension } from '@blocksuite/affine-block-surface/view';
|
||||
import { SurfaceRefViewExtension } from '@blocksuite/affine-block-surface-ref/view';
|
||||
import { TableViewExtension } from '@blocksuite/affine-block-table/view';
|
||||
@@ -84,6 +85,7 @@ export function getInternalViewExtensions() {
|
||||
SurfaceRefViewExtension,
|
||||
TableViewExtension,
|
||||
SurfaceViewExtension,
|
||||
RootViewExtension,
|
||||
|
||||
// Inline
|
||||
FootnoteViewExtension,
|
||||
|
||||
Reference in New Issue
Block a user