Skip to content

Commit

Permalink
fix(editor): move insert link command to bookmark to remove ts ignore (
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Dec 27, 2024
1 parent fee8630 commit 1fbb462
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions blocksuite/affine/block-bookmark/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { BlockCommands } from '@blocksuite/block-std';

import { insertBookmarkCommand } from './insert-bookmark.js';
import { insertLinkByQuickSearchCommand } from './insert-link-by-quick-search.js';

export const commands: BlockCommands = {
insertBookmark: insertBookmarkCommand,
insertLinkByQuickSearch: insertLinkByQuickSearchCommand,
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type { InsertedLinkType } from '@blocksuite/affine-block-embed';
import { QuickSearchProvider } from '@blocksuite/affine-shared/services';
import type { Command } from '@blocksuite/block-std';

export type InsertedLinkType = {
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
} | null;

export const insertLinkByQuickSearchCommand: Command<
never,
'insertedLinkType'
Expand Down Expand Up @@ -34,7 +31,6 @@ export const insertLinkByQuickSearchCommand: Command<

// add normal link;
if ('externalUrl' in result) {
// @ts-expect-error FIXME: fix after bookmark refactor
std.command.exec('insertBookmark', { url: result.externalUrl });
return {
flavour: 'affine:bookmark',
Expand Down
2 changes: 2 additions & 0 deletions blocksuite/affine/block-bookmark/src/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BookmarkBlockComponent } from './bookmark-block';
import { BookmarkEdgelessBlockComponent } from './bookmark-edgeless-block';
import type { BookmarkBlockService } from './bookmark-service';
import type { insertBookmarkCommand } from './commands/insert-bookmark';
import type { insertLinkByQuickSearchCommand } from './commands/insert-link-by-quick-search';
import { BookmarkCard } from './components/bookmark-card';

export function effects() {
Expand All @@ -17,6 +18,7 @@ declare global {
namespace BlockSuite {
interface Commands {
insertBookmark: typeof insertBookmarkCommand;
insertLinkByQuickSearch: typeof insertLinkByQuickSearchCommand;
}
interface BlockServices {
'affine:bookmark': BookmarkBlockService;
Expand Down
12 changes: 5 additions & 7 deletions blocksuite/affine/block-embed/src/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import { EmbedHtmlBlockComponent } from './embed-html-block';
import { EmbedHtmlFullscreenToolbar } from './embed-html-block/components/fullscreen-toolbar';
import { EmbedEdgelessHtmlBlockComponent } from './embed-html-block/embed-edgeless-html-block';
import { EmbedLinkedDocBlockComponent } from './embed-linked-doc-block';
import type { insertEmbedLinkedDocCommand } from './embed-linked-doc-block/commands/insert-embed-linked-doc';
import type {
InsertedLinkType,
insertLinkByQuickSearchCommand,
} from './embed-linked-doc-block/commands/insert-link-by-quick-search';
insertEmbedLinkedDocCommand,
} from './embed-linked-doc-block/commands/insert-embed-linked-doc';
import { EmbedEdgelessLinkedDocBlockComponent } from './embed-linked-doc-block/embed-edgeless-linked-doc-block';
import type { EmbedLinkedDocBlockConfig } from './embed-linked-doc-block/embed-linked-doc-config';
import {
Expand Down Expand Up @@ -121,15 +120,14 @@ declare global {
'affine:embed-loom': EmbedLoomBlockService;
'affine:embed-youtube': EmbedYoutubeBlockService;
}
interface BlockConfigs {
'affine:embed-linked-doc': EmbedLinkedDocBlockConfig;
}
interface CommandContext {
insertedLinkType?: Promise<InsertedLinkType>;
}
interface BlockConfigs {
'affine:embed-linked-doc': EmbedLinkedDocBlockConfig;
}
interface Commands {
insertEmbedLinkedDoc: typeof insertEmbedLinkedDocCommand;
insertLinkByQuickSearch: typeof insertLinkByQuickSearchCommand;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { BlockCommands } from '@blocksuite/block-std';

import { insertEmbedLinkedDocCommand } from './insert-embed-linked-doc.js';
import { insertLinkByQuickSearchCommand } from './insert-link-by-quick-search.js';

export const commands: BlockCommands = {
insertEmbedLinkedDoc: insertEmbedLinkedDocCommand,
insertLinkByQuickSearch: insertLinkByQuickSearchCommand,
};

export type { InsertedLinkType } from './insert-embed-linked-doc';
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import type { Command } from '@blocksuite/block-std';

import { insertEmbedCard } from '../../common/insert-embed-card.js';

export type InsertedLinkType = {
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
} | null;

export const insertEmbedLinkedDocCommand: Command<
never,
'insertedLinkType',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './adapters/index.js';
export * from './embed-linked-doc-block.js';
export * from './embed-linked-doc-config.js';
export * from './embed-linked-doc-spec.js';
export * from './adapters';
export type { InsertedLinkType } from './commands';
export * from './embed-linked-doc-block';
export * from './embed-linked-doc-config';
export * from './embed-linked-doc-spec';

0 comments on commit 1fbb462

Please sign in to comment.