mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 09:52:49 +08:00
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:
@@ -1,15 +1,15 @@
|
||||
import '@blocksuite/affine-shared/commands';
|
||||
|
||||
import { TableModelFlavour } from '@blocksuite/affine-model';
|
||||
import { generateFractionalIndexingKeyBetween } from '@blocksuite/affine-shared/utils';
|
||||
import type { BlockCommands, Command } from '@blocksuite/block-std';
|
||||
import { nanoid, Text } from '@blocksuite/store';
|
||||
import type { Command } from '@blocksuite/block-std';
|
||||
import { type BlockModel, nanoid, Text } from '@blocksuite/store';
|
||||
export const insertTableBlockCommand: Command<
|
||||
'selectedModels',
|
||||
'insertedTableBlockId',
|
||||
{
|
||||
place?: 'after' | 'before';
|
||||
removeEmptyLine?: boolean;
|
||||
selectedModels?: BlockModel[];
|
||||
},
|
||||
{
|
||||
insertedTableBlockId: string;
|
||||
}
|
||||
> = (ctx, next) => {
|
||||
const { selectedModels, place, removeEmptyLine, std } = ctx;
|
||||
@@ -61,7 +61,3 @@ export const insertTableBlockCommand: Command<
|
||||
|
||||
next({ insertedTableBlockId: blockId });
|
||||
};
|
||||
|
||||
export const tableCommands: BlockCommands = {
|
||||
insertTableBlock: insertTableBlockCommand,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { AddButton } from './add-button';
|
||||
import type { insertTableBlockCommand } from './commands';
|
||||
import { SelectionLayer } from './selection-layer';
|
||||
import { TableBlockComponent } from './table-block';
|
||||
import { TableCell } from './table-cell';
|
||||
@@ -10,15 +9,3 @@ export function effects() {
|
||||
customElements.define('affine-table-add-button', AddButton);
|
||||
customElements.define('affine-table-selection-layer', SelectionLayer);
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface CommandContext {
|
||||
insertedTableBlockId?: string;
|
||||
}
|
||||
|
||||
interface Commands {
|
||||
insertTableBlock: typeof insertTableBlockCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +107,4 @@ export class TableSelection extends BaseSelection {
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface Selection {
|
||||
table: typeof TableSelection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const TableSelectionExtension = SelectionExtension(TableSelection);
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import { TableModelFlavour } from '@blocksuite/affine-model';
|
||||
import {
|
||||
BlockViewExtension,
|
||||
CommandExtension,
|
||||
FlavourExtension,
|
||||
} from '@blocksuite/block-std';
|
||||
import { BlockViewExtension, FlavourExtension } from '@blocksuite/block-std';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { TableBlockAdapterExtensions } from './adapters/extension.js';
|
||||
import { tableCommands } from './commands.js';
|
||||
|
||||
export const TableBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension(TableModelFlavour),
|
||||
CommandExtension(tableCommands),
|
||||
BlockViewExtension(TableModelFlavour, literal`affine-table`),
|
||||
TableBlockAdapterExtensions,
|
||||
].flat();
|
||||
|
||||
Reference in New Issue
Block a user