Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(editor): improve std structure (#10993)

Saul-Mironea9b53839a668
diff --git a/blocksuite/framework/block-std/src/extension/index.ts b/blocksuite/framework/block-std/src/extension/index.ts
index 1c2fe198e6..3c63543420 100644
--- a/blocksuite/framework/block-std/src/extension/index.ts
+++ b/blocksuite/framework/block-std/src/extension/index.ts
@@ -6,4 +6,5 @@ export * from './flavour.js';
export * from './keymap.js';
export * from './lifecycle-watcher.js';
export * from './service.js';
+export * from './service-manager.js';
export * from './widget-view-map.js';
diff --git a/blocksuite/framework/block-std/src/service/index.ts b/blocksuite/framework/block-std/src/extension/service-manager.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/service/index.ts
rename to blocksuite/framework/block-std/src/extension/service-manager.ts
diff --git a/blocksuite/framework/block-std/src/index.ts b/blocksuite/framework/block-std/src/index.ts
index 1167b51d01..fbd2f453f7 100644
--- a/blocksuite/framework/block-std/src/index.ts
+++ b/blocksuite/framework/block-std/src/index.ts
@@ -3,9 +3,8 @@ export * from './command/index.js';
export * from './event/index.js';
export * from './extension/index.js';
export * from './identifier.js';
-export * from './range/index.js';
+export * from './inline/index.js';
export * from './scope/index.js';
export * from './selection/index.js';
-export * from './service/index.js';
export * from './spec/index.js';
export * from './view/index.js';
diff --git a/blocksuite/framework/block-std/src/inline/index.ts b/blocksuite/framework/block-std/src/inline/index.ts
new file mode 100644
index 0000000000..f298acd3c9
--- /dev/null
+++ b/blocksuite/framework/block-std/src/inline/index.ts
@@ -0,0 +1 @@
+export * from './range';
diff --git a/blocksuite/framework/block-std/src/range/active.ts b/blocksuite/framework/block-std/src/inline/range/active.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/range/active.ts
rename to blocksuite/framework/block-std/src/inline/range/active.ts
diff --git a/blocksuite/framework/block-std/src/range/consts.ts b/blocksuite/framework/block-std/src/inline/range/consts.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/range/consts.ts
rename to blocksuite/framework/block-std/src/inline/range/consts.ts
diff --git a/blocksuite/framework/block-std/src/range/index.ts b/blocksuite/framework/block-std/src/inline/range/index.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/range/index.ts
rename to blocksuite/framework/block-std/src/inline/range/index.ts
diff --git a/blocksuite/framework/block-std/src/range/inline-range-provider.ts b/blocksuite/framework/block-std/src/inline/range/inline-range-provider.ts
similarity index 95%
rename from blocksuite/framework/block-std/src/range/inline-range-provider.ts
rename to blocksuite/framework/block-std/src/inline/range/inline-range-provider.ts
index 1d2dd51d60..7a56b7c23a 100644
--- a/blocksuite/framework/block-std/src/range/inline-range-provider.ts
+++ b/blocksuite/framework/block-std/src/inline/range/inline-range-provider.ts
@@ -1,8 +1,8 @@
import type { InlineRange, InlineRangeProvider } from '@blocksuite/inline';
import { signal } from '@preact/signals-core';
-import { TextSelection } from '../selection/index.js';
-import type { BlockComponent } from '../view/element/block-component.js';
+import { TextSelection } from '../../selection/index.js';
+import type { BlockComponent } from '../../view/element/block-component.js';
import { isActiveInEditor } from './active.js';
export const getInlineRangeProvider: (
diff --git a/blocksuite/framework/block-std/src/range/range-binding.ts b/blocksuite/framework/block-std/src/inline/range/range-binding.ts
similarity index 98%
rename from blocksuite/framework/block-std/src/range/range-binding.ts
rename to blocksuite/framework/block-std/src/inline/range/range-binding.ts
index 4c0b9478b5..58b10ed19e 100644
--- a/blocksuite/framework/block-std/src/range/range-binding.ts
+++ b/blocksuite/framework/block-std/src/inline/range/range-binding.ts
@@ -1,9 +1,9 @@
import type { BaseSelection, BlockModel } from '@blocksuite/store';
import throttle from 'lodash-es/throttle';
-import { TextSelection } from '../selection/index.js';
-import type { BlockComponent } from '../view/element/block-component.js';
-import { BLOCK_ID_ATTR } from '../view/index.js';
+import { TextSelection } from '../../selection/index.js';
+import type { BlockComponent } from '../../view/element/block-component.js';
+import { BLOCK_ID_ATTR } from '../../view/index.js';
import { isActiveInEditor } from './active.js';
import { RANGE_SYNC_EXCLUDE_ATTR } from './consts.js';
import type { RangeManager } from './range-manager.js';
diff --git a/blocksuite/framework/block-std/src/range/range-manager.ts b/blocksuite/framework/block-std/src/inline/range/range-manager.ts
similarity index 96%
rename from blocksuite/framework/block-std/src/range/range-manager.ts
rename to blocksuite/framework/block-std/src/inline/range/range-manager.ts
index c647e4d018..98ed85ae8f 100644
--- a/blocksuite/framework/block-std/src/range/range-manager.ts
+++ b/blocksuite/framework/block-std/src/inline/range/range-manager.ts
@@ -1,9 +1,9 @@
import { INLINE_ROOT_ATTR, type InlineRootElement } from '@blocksuite/inline';
-import { LifeCycleWatcher } from '../extension/index.js';
-import { TextSelection } from '../selection/index.js';
-import type { BlockComponent } from '../view/element/block-component.js';
-import { BLOCK_ID_ATTR } from '../view/index.js';
+import { LifeCycleWatcher } from '../../extension/index.js';
+import { TextSelection } from '../../selection/index.js';
+import type { BlockComponent } from '../../view/element/block-component.js';
+import { BLOCK_ID_ATTR } from '../../view/index.js';
import { RANGE_QUERY_EXCLUDE_ATTR, RANGE_SYNC_EXCLUDE_ATTR } from './consts.js';
import { RangeBinding } from './range-binding.js';
diff --git a/blocksuite/framework/block-std/src/scope/block-std-scope.ts b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
index 456f3145d2..7d030dbddc 100644
--- a/blocksuite/framework/block-std/src/scope/block-std-scope.ts
+++ b/blocksuite/framework/block-std/src/scope/block-std-scope.ts
@@ -11,6 +11,7 @@ import { CommandManager } from '../command/index.js';
import { UIEventDispatcher } from '../event/index.js';
import { DndController } from '../extension/dnd/index.js';
import { EditorLifeCycleExtension } from '../extension/editor-life-cycle.js';
+import { ServiceManager } from '../extension/service-manager.js';
import { GfxController } from '../gfx/controller.js';
import { GridManager, LayerManager } from '../gfx/index.js';
import { GfxSelectionManager } from '../gfx/selection.js';
@@ -21,8 +22,7 @@ import {
LifeCycleWatcherIdentifier,
StdIdentifier,
} from '../identifier.js';
-import { RangeManager } from '../range/index.js';
-import { ServiceManager } from '../service/index.js';
+import { RangeManager } from '../inline/index.js';
import { EditorHost } from '../view/element/index.js';
import { ViewStore } from '../view/view-store.js';
diff --git a/blocksuite/framework/block-std/src/selection/variants/block.ts b/blocksuite/framework/block-std/src/selection/block.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/selection/variants/block.ts
rename to blocksuite/framework/block-std/src/selection/block.ts
diff --git a/blocksuite/framework/block-std/src/selection/variants/cursor.ts b/blocksuite/framework/block-std/src/selection/cursor.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/selection/variants/cursor.ts
rename to blocksuite/framework/block-std/src/selection/cursor.ts
diff --git a/blocksuite/framework/block-std/src/selection/index.ts b/blocksuite/framework/block-std/src/selection/index.ts
index 8ac7bfc5bc..80fdcf7a70 100644
--- a/blocksuite/framework/block-std/src/selection/index.ts
+++ b/blocksuite/framework/block-std/src/selection/index.ts
@@ -1 +1,4 @@
-export * from './variants/index.js';
+export * from './block.js';
+export * from './cursor.js';
+export * from './surface.js';
+export * from './text.js';
diff --git a/blocksuite/framework/block-std/src/selection/variants/surface.ts b/blocksuite/framework/block-std/src/selection/surface.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/selection/variants/surface.ts
rename to blocksuite/framework/block-std/src/selection/surface.ts
diff --git a/blocksuite/framework/block-std/src/selection/variants/text.ts b/blocksuite/framework/block-std/src/selection/text.ts
similarity index 100%
rename from blocksuite/framework/block-std/src/selection/variants/text.ts
rename to blocksuite/framework/block-std/src/selection/text.ts
diff --git a/blocksuite/framework/block-std/src/selection/variants/index.ts b/blocksuite/framework/block-std/src/selection/variants/index.ts
deleted file mode 100644
index 80fdcf7a70..0000000000
--- a/blocksuite/framework/block-std/src/selection/variants/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from './block.js';
-export * from './cursor.js';
-export * from './surface.js';
-export * from './text.js';
diff --git a/blocksuite/framework/block-std/src/view/element/lit-host.ts b/blocksuite/framework/block-std/src/view/element/lit-host.ts
index 534195c24c..dfc39be782 100644
--- a/blocksuite/framework/block-std/src/view/element/lit-host.ts
+++ b/blocksuite/framework/block-std/src/view/element/lit-host.ts
@@ -18,7 +18,7 @@ import { html, type StaticValue, unsafeStatic } from 'lit/static-html.js';
import type { CommandManager } from '../../command/index.js';
import type { UIEventDispatcher } from '../../event/index.js';
import { WidgetViewIdentifier } from '../../identifier.js';
-import type { RangeManager } from '../../range/index.js';
+import type { RangeManager } from '../../inline/index.js';
import type { BlockStdScope } from '../../scope/block-std-scope.js';
import { PropTypes, requiredProperties } from '../decorators/index.js';
import type { ViewStore } from '../view-store.js';