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
@@ -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.