refactor(editor): remove dependency of command global types (#9903)

Closes: [BS-2216](https://linear.app/affine-design/issue/BS-2216/remove-global-types-in-command)
This commit is contained in:
Saul-Mirone
2025-01-27 12:28:46 +00:00
parent 4b549e0484
commit 17bf75e843
170 changed files with 1461 additions and 2124 deletions

View File

@@ -1,8 +1,14 @@
import { deleteTextCommand } from '@blocksuite/affine-components/rich-text';
import {
HtmlAdapter,
pasteMiddleware,
PlainTextAdapter,
} from '@blocksuite/affine-shared/adapters';
import {
getBlockIndexCommand,
getBlockSelectionsCommand,
getTextSelectionCommand,
} from '@blocksuite/affine-shared/commands';
import {
type BlockComponent,
Clipboard,
@@ -40,13 +46,13 @@ export class CodeClipboardController {
this._std.command
.chain()
.try(cmd => [
cmd.getTextSelection().inline<'currentSelectionPath'>((ctx, next) => {
cmd.pipe(getTextSelectionCommand).pipe((ctx, next) => {
const textSelection = ctx.currentTextSelection;
if (!textSelection) return;
const end = textSelection.to ?? textSelection.from;
next({ currentSelectionPath: end.blockId });
}),
cmd.getBlockSelections().inline<'currentSelectionPath'>((ctx, next) => {
cmd.pipe(getBlockSelectionsCommand).pipe((ctx, next) => {
const currentBlockSelections = ctx.currentBlockSelections;
if (!currentBlockSelections) return;
const blockSelection = currentBlockSelections.at(-1);
@@ -54,9 +60,9 @@ export class CodeClipboardController {
next({ currentSelectionPath: blockSelection.blockId });
}),
])
.getBlockIndex()
.try(cmd => [cmd.getTextSelection().deleteText()])
.inline((ctx, next) => {
.pipe(getBlockIndexCommand)
.try(cmd => [cmd.pipe(getTextSelectionCommand).pipe(deleteTextCommand)])
.pipe((ctx, next) => {
if (!ctx.parentBlock) {
return;
}