mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
feat(editor): insert embed doc with quick search by default (#12165)
Close [BS-3404](https://linear.app/affine-design/issue/BS-3404/通过embed-doc时,插入的doc还是card-view,应该要默认embed-view) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to insert and display embedded synced documents, supporting different link types based on editor mode and user preferences. - Introduced new UI interactions and view options for embedded synced documents in edgeless mode. - **Bug Fixes** - Updated UI selectors and preference keys to ensure consistent behavior and correct application of user settings. - **Tests** - Added and updated end-to-end tests for embedding synced documents, including header interactions and viewport fitting. - Improved test coverage for quick search insertion and edgeless embed synced doc features. - **Chores** - Renamed settings and updated exports to align with new embedding functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -2,9 +2,14 @@ import { insertEmbedIframeWithUrlCommand } from '@blocksuite/affine-block-embed'
|
||||
import {
|
||||
type InsertedLinkType,
|
||||
insertEmbedLinkedDocCommand,
|
||||
insertEmbedSyncedDocCommand,
|
||||
type LinkableFlavour,
|
||||
} from '@blocksuite/affine-block-embed-doc';
|
||||
import { QuickSearchProvider } from '@blocksuite/affine-shared/services';
|
||||
import {
|
||||
DocModeProvider,
|
||||
EditorSettingProvider,
|
||||
QuickSearchProvider,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import type { Command } from '@blocksuite/std';
|
||||
|
||||
import { insertBookmarkCommand } from './insert-bookmark';
|
||||
@@ -26,12 +31,26 @@ export const insertLinkByQuickSearchCommand: Command<
|
||||
|
||||
// add linked doc
|
||||
if ('docId' in result) {
|
||||
std.command.exec(insertEmbedLinkedDocCommand, {
|
||||
const editorMode = std.get(DocModeProvider).getEditorMode();
|
||||
const editorSettings = std.get(EditorSettingProvider);
|
||||
let flavour: LinkableFlavour = 'affine:embed-linked-doc';
|
||||
if (editorMode === 'edgeless') {
|
||||
flavour =
|
||||
editorSettings.setting$.value.docCanvasPreferView ?? flavour;
|
||||
}
|
||||
|
||||
const insertCommand =
|
||||
flavour === 'affine:embed-linked-doc'
|
||||
? insertEmbedLinkedDocCommand
|
||||
: insertEmbedSyncedDocCommand;
|
||||
|
||||
std.command.exec(insertCommand, {
|
||||
docId: result.docId,
|
||||
params: result.params,
|
||||
});
|
||||
|
||||
return {
|
||||
flavour: 'affine:embed-linked-doc',
|
||||
flavour,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user