mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +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,9 +1 @@
|
||||
import type { BlockCommands } from '@blocksuite/block-std';
|
||||
|
||||
import { insertEmbedLinkedDocCommand } from './insert-embed-linked-doc.js';
|
||||
|
||||
export const commands: BlockCommands = {
|
||||
insertEmbedLinkedDoc: insertEmbedLinkedDocCommand,
|
||||
};
|
||||
|
||||
export type { InsertedLinkType } from './insert-embed-linked-doc';
|
||||
export * from './insert-embed-linked-doc';
|
||||
|
||||
+4
-8
@@ -7,14 +7,10 @@ export type InsertedLinkType = {
|
||||
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
|
||||
} | null;
|
||||
|
||||
export const insertEmbedLinkedDocCommand: Command<
|
||||
never,
|
||||
'insertedLinkType',
|
||||
{
|
||||
docId: string;
|
||||
params?: ReferenceParams;
|
||||
}
|
||||
> = (ctx, next) => {
|
||||
export const insertEmbedLinkedDocCommand: Command<{
|
||||
docId: string;
|
||||
params?: ReferenceParams;
|
||||
}> = (ctx, next) => {
|
||||
const { docId, params, std } = ctx;
|
||||
const flavour = 'affine:embed-linked-doc';
|
||||
const targetStyle: EmbedCardStyle = 'vertical';
|
||||
|
||||
+5
-2
@@ -1,4 +1,7 @@
|
||||
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
EdgelessCRUDIdentifier,
|
||||
reassociateConnectorsCommand,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
EMBED_CARD_HEIGHT,
|
||||
EMBED_CARD_WIDTH,
|
||||
@@ -51,7 +54,7 @@ export class EmbedEdgelessLinkedDocBlockComponent extends toEdgelessEmbedBlock(
|
||||
surface
|
||||
);
|
||||
|
||||
this.std.command.exec('reassociateConnectors', {
|
||||
this.std.command.exec(reassociateConnectorsCommand, {
|
||||
oldId: id,
|
||||
newId,
|
||||
});
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
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 { EmbedLinkedDocBlockAdapterExtensions } from './adapters/extension.js';
|
||||
import { commands } from './commands/index.js';
|
||||
|
||||
export const EmbedLinkedDocBlockSpec: ExtensionType[] = [
|
||||
CommandExtension(commands),
|
||||
BlockViewExtension('affine:embed-linked-doc', model => {
|
||||
return model.parent?.flavour === 'affine:surface'
|
||||
? literal`affine-embed-edgeless-linked-doc-block`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './adapters';
|
||||
export type { InsertedLinkType } from './commands';
|
||||
export * from './commands';
|
||||
export * from './embed-linked-doc-block';
|
||||
export * from './embed-linked-doc-spec';
|
||||
|
||||
Reference in New Issue
Block a user