refactor(editor): move extension to store (#9552)

This commit is contained in:
Saul-Mirone
2025-01-06 15:15:14 +00:00
parent 46c8c4a408
commit f778d1a28a
127 changed files with 170 additions and 207 deletions

View File

@@ -1,9 +1,8 @@
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import type { Blocks } from '@blocksuite/store';
import type { Blocks, ExtensionType } from '@blocksuite/store';
import { html } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import type { ExtensionType } from '../extension/index.js';
import { BlockStdScope } from '../scope/index.js';
import { ShadowlessElement } from '../view/index.js';

View File

@@ -1,8 +1,9 @@
import './test-block.js';
import type { ExtensionType } from '@blocksuite/store';
import { literal } from 'lit/static-html.js';
import { BlockViewExtension, type ExtensionType } from '../extension/index.js';
import { BlockViewExtension } from '../extension/index.js';
import type { HeadingBlockModel } from './test-schema.js';
export const testSpecs: ExtensionType[] = [

View File

@@ -1,6 +1,7 @@
import type { ExtensionType } from '@blocksuite/store';
import { BlockViewIdentifier } from '../identifier.js';
import type { BlockViewType } from '../spec/type.js';
import type { ExtensionType } from './extension.js';
/**
* Create a block view extension.

View File

@@ -1,6 +1,7 @@
import type { ExtensionType } from '@blocksuite/store';
import { CommandIdentifier } from '../identifier.js';
import type { BlockCommands } from '../spec/index.js';
import type { ExtensionType } from './extension.js';
/**
* Create a command extension.

View File

@@ -1,5 +1,6 @@
import type { ExtensionType } from '@blocksuite/store';
import { ConfigIdentifier } from '../identifier.js';
import type { ExtensionType } from './extension.js';
/**
* Create a config extension.

View File

@@ -1,17 +0,0 @@
import type { Container } from '@blocksuite/global/di';
/**
* Generic extension.
* Extensions are used to set up the dependency injection container.
* In most cases, you won't need to use this class directly.
* We provide helper classes like `CommandExtension` and `BlockViewExtension` to make it easier to create extensions.
*/
export abstract class Extension {
static setup(_di: Container): void {
// do nothing
}
}
export interface ExtensionType {
setup(di: Container): void;
}

View File

@@ -1,5 +1,6 @@
import type { ExtensionType } from '@blocksuite/store';
import { BlockFlavourIdentifier } from '../identifier.js';
import type { ExtensionType } from './extension.js';
/**
* Create a flavour extension.

View File

@@ -1,7 +1,6 @@
export * from './block-view.js';
export * from './command.js';
export * from './config.js';
export * from './extension.js';
export * from './flavour.js';
export * from './keymap.js';
export * from './lifecycle-watcher.js';

View File

@@ -1,7 +1,8 @@
import type { ExtensionType } from '@blocksuite/store';
import type { EventOptions, UIEventHandler } from '../event/index.js';
import { KeymapIdentifier } from '../identifier.js';
import type { BlockStdScope } from '../scope/index.js';
import type { ExtensionType } from './extension.js';
let id = 1;

View File

@@ -1,9 +1,9 @@
import type { Container } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { Extension } from '@blocksuite/store';
import { LifeCycleWatcherIdentifier, StdIdentifier } from '../identifier.js';
import type { BlockStdScope } from '../scope/index.js';
import { Extension } from './extension.js';
/**
* A life cycle watcher is an extension that watches the life cycle of the editor.

View File

@@ -1,6 +1,7 @@
import type { ExtensionType } from '@blocksuite/store';
import { SelectionIdentifier } from '../identifier.js';
import type { SelectionConstructor } from '../selection/index.js';
import type { ExtensionType } from './extension.js';
export function SelectionExtension(
selectionCtor: SelectionConstructor

View File

@@ -1,6 +1,7 @@
import type { Container } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { DisposableGroup } from '@blocksuite/global/utils';
import { Extension } from '@blocksuite/store';
import type { EventName, UIEventHandler } from '../event/index.js';
import {
@@ -10,7 +11,6 @@ import {
} from '../identifier.js';
import type { BlockStdScope } from '../scope/index.js';
import { getSlots } from '../spec/index.js';
import { Extension } from './extension.js';
/**
* @deprecated

View File

@@ -1,6 +1,7 @@
import type { ExtensionType } from '@blocksuite/store';
import { WidgetViewMapIdentifier } from '../identifier.js';
import type { WidgetViewMapType } from '../spec/type.js';
import type { ExtensionType } from './extension.js';
/**
* Create a widget view map extension.

View File

@@ -1,7 +1,7 @@
import { type Container, createIdentifier } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { Extension } from '@blocksuite/store';
import { Extension } from '../extension/extension.js';
import type { GfxController } from './controller.js';
import { GfxControllerIdentifier } from './identifiers.js';

View File

@@ -1,7 +1,7 @@
import { type Container, createIdentifier } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { Extension } from '@blocksuite/store';
import { Extension } from '../extension/extension.js';
import { LifeCycleWatcher } from '../extension/lifecycle-watcher.js';
import { StdIdentifier } from '../identifier.js';
import type { BlockStdScope } from '../scope/block-std-scope.js';

View File

@@ -1,9 +1,9 @@
import { type Container, createIdentifier } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { DisposableGroup } from '@blocksuite/global/utils';
import { Extension } from '@blocksuite/store';
import type { PointerEventState } from '../../event/index.js';
import { Extension } from '../../extension/extension.js';
import type { GfxController } from '../controller.js';
import { GfxControllerIdentifier } from '../identifiers.js';
import type { ToolEventTarget } from './tool-controller.js';

View File

@@ -5,9 +5,9 @@ import {
DisposableGroup,
type IVec,
} from '@blocksuite/global/utils';
import type { Extension } from '@blocksuite/store';
import type { PointerEventState } from '../../event/index.js';
import type { Extension } from '../../extension/extension.js';
import type { EditorHost } from '../../view/index.js';
import type { GfxController } from '../index.js';
import type { GfxElementGeometry, PointTestOptions } from '../model/base.js';

View File

@@ -1,12 +1,17 @@
import type { ServiceProvider } from '@blocksuite/global/di';
import { Container } from '@blocksuite/global/di';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { type Blocks, Job, type JobMiddleware } from '@blocksuite/store';
import {
type Blocks,
type ExtensionType,
Job,
type JobMiddleware,
} from '@blocksuite/store';
import { Clipboard } from '../clipboard/index.js';
import { CommandManager } from '../command/index.js';
import { UIEventDispatcher } from '../event/index.js';
import type { BlockService, ExtensionType } from '../extension/index.js';
import type { BlockService } from '../extension/index.js';
import { GfxController } from '../gfx/controller.js';
import { GfxSelectionManager } from '../gfx/selection.js';
import { SurfaceMiddlewareExtension } from '../gfx/surface-middleware.js';