mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
refactor(editor): move extension to store (#9552)
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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[] = [
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user