mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 09:21:24 +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,7 +1 @@
|
||||
import type { BlockCommands } from '@blocksuite/block-std';
|
||||
|
||||
import { insertEdgelessTextCommand } from './insert-edgeless-text.js';
|
||||
|
||||
export const commands: BlockCommands = {
|
||||
insertEdgelessText: insertEdgelessTextCommand,
|
||||
};
|
||||
export { insertEdgelessTextCommand } from './insert-edgeless-text.js';
|
||||
|
||||
@@ -14,11 +14,12 @@ import {
|
||||
} from '../edgeless-text-block.js';
|
||||
|
||||
export const insertEdgelessTextCommand: Command<
|
||||
never,
|
||||
'textId',
|
||||
{
|
||||
x: number;
|
||||
y: number;
|
||||
},
|
||||
{
|
||||
textId: string;
|
||||
}
|
||||
> = (ctx, next) => {
|
||||
const { std, x, y } = ctx;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { TextUtils } from '@blocksuite/affine-block-surface';
|
||||
import { formatBlockCommand } from '@blocksuite/affine-components/rich-text';
|
||||
import type { EdgelessTextBlockModel } from '@blocksuite/affine-model';
|
||||
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
||||
@@ -98,21 +99,21 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
||||
);
|
||||
|
||||
if (key === 'fontStyle') {
|
||||
command.exec('formatBlock', {
|
||||
command.exec(formatBlockCommand, {
|
||||
blockSelections,
|
||||
styles: {
|
||||
italic: null,
|
||||
},
|
||||
});
|
||||
} else if (key === 'color') {
|
||||
command.exec('formatBlock', {
|
||||
command.exec(formatBlockCommand, {
|
||||
blockSelections,
|
||||
styles: {
|
||||
color: null,
|
||||
},
|
||||
});
|
||||
} else if (key === 'fontWeight') {
|
||||
command.exec('formatBlock', {
|
||||
command.exec(formatBlockCommand, {
|
||||
blockSelections,
|
||||
styles: {
|
||||
bold: null,
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { BlockViewExtension, CommandExtension } from '@blocksuite/block-std';
|
||||
import { BlockViewExtension } from '@blocksuite/block-std';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { commands } from './commands/index.js';
|
||||
|
||||
export const EdgelessTextBlockSpec: ExtensionType[] = [
|
||||
CommandExtension(commands),
|
||||
BlockViewExtension('affine:edgeless-text', literal`affine-edgeless-text`),
|
||||
];
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
import type { insertEdgelessTextCommand } from './commands/insert-edgeless-text';
|
||||
import { EdgelessTextBlockComponent } from './edgeless-text-block';
|
||||
|
||||
export function effects() {
|
||||
customElements.define('affine-edgeless-text', EdgelessTextBlockComponent);
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface CommandContext {
|
||||
textId?: string;
|
||||
}
|
||||
interface Commands {
|
||||
insertEdgelessText: typeof insertEdgelessTextCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import type * as CommandType from '@blocksuite/affine-shared/commands';
|
||||
|
||||
declare type _GLOBAL_ = typeof CommandType;
|
||||
|
||||
export * from './commands';
|
||||
export * from './edgeless-text-block.js';
|
||||
export * from './edgeless-text-spec.js';
|
||||
|
||||
Reference in New Issue
Block a user