fix(editor): move insert link command to bookmark to remove ts ignore (#9370)
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import type { BlockCommands } from '@blocksuite/block-std';
|
import type { BlockCommands } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { insertBookmarkCommand } from './insert-bookmark.js';
|
import { insertBookmarkCommand } from './insert-bookmark.js';
|
||||||
|
import { insertLinkByQuickSearchCommand } from './insert-link-by-quick-search.js';
|
||||||
|
|
||||||
export const commands: BlockCommands = {
|
export const commands: BlockCommands = {
|
||||||
insertBookmark: insertBookmarkCommand,
|
insertBookmark: insertBookmarkCommand,
|
||||||
|
insertLinkByQuickSearch: insertLinkByQuickSearchCommand,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
|
import type { InsertedLinkType } from '@blocksuite/affine-block-embed';
|
||||||
import { QuickSearchProvider } from '@blocksuite/affine-shared/services';
|
import { QuickSearchProvider } from '@blocksuite/affine-shared/services';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
export type InsertedLinkType = {
|
|
||||||
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
|
|
||||||
} | null;
|
|
||||||
|
|
||||||
export const insertLinkByQuickSearchCommand: Command<
|
export const insertLinkByQuickSearchCommand: Command<
|
||||||
never,
|
never,
|
||||||
'insertedLinkType'
|
'insertedLinkType'
|
||||||
@@ -34,7 +31,6 @@ export const insertLinkByQuickSearchCommand: Command<
|
|||||||
|
|
||||||
// add normal link;
|
// add normal link;
|
||||||
if ('externalUrl' in result) {
|
if ('externalUrl' in result) {
|
||||||
// @ts-expect-error FIXME: fix after bookmark refactor
|
|
||||||
std.command.exec('insertBookmark', { url: result.externalUrl });
|
std.command.exec('insertBookmark', { url: result.externalUrl });
|
||||||
return {
|
return {
|
||||||
flavour: 'affine:bookmark',
|
flavour: 'affine:bookmark',
|
||||||
@@ -2,6 +2,7 @@ import { BookmarkBlockComponent } from './bookmark-block';
|
|||||||
import { BookmarkEdgelessBlockComponent } from './bookmark-edgeless-block';
|
import { BookmarkEdgelessBlockComponent } from './bookmark-edgeless-block';
|
||||||
import type { BookmarkBlockService } from './bookmark-service';
|
import type { BookmarkBlockService } from './bookmark-service';
|
||||||
import type { insertBookmarkCommand } from './commands/insert-bookmark';
|
import type { insertBookmarkCommand } from './commands/insert-bookmark';
|
||||||
|
import type { insertLinkByQuickSearchCommand } from './commands/insert-link-by-quick-search';
|
||||||
import { BookmarkCard } from './components/bookmark-card';
|
import { BookmarkCard } from './components/bookmark-card';
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
@@ -17,6 +18,7 @@ declare global {
|
|||||||
namespace BlockSuite {
|
namespace BlockSuite {
|
||||||
interface Commands {
|
interface Commands {
|
||||||
insertBookmark: typeof insertBookmarkCommand;
|
insertBookmark: typeof insertBookmarkCommand;
|
||||||
|
insertLinkByQuickSearch: typeof insertLinkByQuickSearchCommand;
|
||||||
}
|
}
|
||||||
interface BlockServices {
|
interface BlockServices {
|
||||||
'affine:bookmark': BookmarkBlockService;
|
'affine:bookmark': BookmarkBlockService;
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ import { EmbedHtmlBlockComponent } from './embed-html-block';
|
|||||||
import { EmbedHtmlFullscreenToolbar } from './embed-html-block/components/fullscreen-toolbar';
|
import { EmbedHtmlFullscreenToolbar } from './embed-html-block/components/fullscreen-toolbar';
|
||||||
import { EmbedEdgelessHtmlBlockComponent } from './embed-html-block/embed-edgeless-html-block';
|
import { EmbedEdgelessHtmlBlockComponent } from './embed-html-block/embed-edgeless-html-block';
|
||||||
import { EmbedLinkedDocBlockComponent } from './embed-linked-doc-block';
|
import { EmbedLinkedDocBlockComponent } from './embed-linked-doc-block';
|
||||||
import type { insertEmbedLinkedDocCommand } from './embed-linked-doc-block/commands/insert-embed-linked-doc';
|
|
||||||
import type {
|
import type {
|
||||||
InsertedLinkType,
|
InsertedLinkType,
|
||||||
insertLinkByQuickSearchCommand,
|
insertEmbedLinkedDocCommand,
|
||||||
} from './embed-linked-doc-block/commands/insert-link-by-quick-search';
|
} from './embed-linked-doc-block/commands/insert-embed-linked-doc';
|
||||||
import { EmbedEdgelessLinkedDocBlockComponent } from './embed-linked-doc-block/embed-edgeless-linked-doc-block';
|
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 type { EmbedLinkedDocBlockConfig } from './embed-linked-doc-block/embed-linked-doc-config';
|
||||||
import {
|
import {
|
||||||
@@ -121,15 +120,14 @@ declare global {
|
|||||||
'affine:embed-loom': EmbedLoomBlockService;
|
'affine:embed-loom': EmbedLoomBlockService;
|
||||||
'affine:embed-youtube': EmbedYoutubeBlockService;
|
'affine:embed-youtube': EmbedYoutubeBlockService;
|
||||||
}
|
}
|
||||||
interface BlockConfigs {
|
|
||||||
'affine:embed-linked-doc': EmbedLinkedDocBlockConfig;
|
|
||||||
}
|
|
||||||
interface CommandContext {
|
interface CommandContext {
|
||||||
insertedLinkType?: Promise<InsertedLinkType>;
|
insertedLinkType?: Promise<InsertedLinkType>;
|
||||||
}
|
}
|
||||||
|
interface BlockConfigs {
|
||||||
|
'affine:embed-linked-doc': EmbedLinkedDocBlockConfig;
|
||||||
|
}
|
||||||
interface Commands {
|
interface Commands {
|
||||||
insertEmbedLinkedDoc: typeof insertEmbedLinkedDocCommand;
|
insertEmbedLinkedDoc: typeof insertEmbedLinkedDocCommand;
|
||||||
insertLinkByQuickSearch: typeof insertLinkByQuickSearchCommand;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { BlockCommands } from '@blocksuite/block-std';
|
import type { BlockCommands } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { insertEmbedLinkedDocCommand } from './insert-embed-linked-doc.js';
|
import { insertEmbedLinkedDocCommand } from './insert-embed-linked-doc.js';
|
||||||
import { insertLinkByQuickSearchCommand } from './insert-link-by-quick-search.js';
|
|
||||||
|
|
||||||
export const commands: BlockCommands = {
|
export const commands: BlockCommands = {
|
||||||
insertEmbedLinkedDoc: insertEmbedLinkedDocCommand,
|
insertEmbedLinkedDoc: insertEmbedLinkedDocCommand,
|
||||||
insertLinkByQuickSearch: insertLinkByQuickSearchCommand,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type { InsertedLinkType } from './insert-embed-linked-doc';
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import type { Command } from '@blocksuite/block-std';
|
|||||||
|
|
||||||
import { insertEmbedCard } from '../../common/insert-embed-card.js';
|
import { insertEmbedCard } from '../../common/insert-embed-card.js';
|
||||||
|
|
||||||
|
export type InsertedLinkType = {
|
||||||
|
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
|
||||||
|
} | null;
|
||||||
|
|
||||||
export const insertEmbedLinkedDocCommand: Command<
|
export const insertEmbedLinkedDocCommand: Command<
|
||||||
never,
|
never,
|
||||||
'insertedLinkType',
|
'insertedLinkType',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './adapters/index.js';
|
export * from './adapters';
|
||||||
export * from './embed-linked-doc-block.js';
|
export type { InsertedLinkType } from './commands';
|
||||||
export * from './embed-linked-doc-config.js';
|
export * from './embed-linked-doc-block';
|
||||||
export * from './embed-linked-doc-spec.js';
|
export * from './embed-linked-doc-config';
|
||||||
|
export * from './embed-linked-doc-spec';
|
||||||
|
|||||||
Reference in New Issue
Block a user