fundon
2024-09-20 03:42:08 +00:00
parent e3e15c6134
commit 661594aec8
4 changed files with 71 additions and 30 deletions

View File

@@ -377,7 +377,6 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
(item.name === 'Linked Doc' || item.name === 'Link')
) {
item.action = async ({ rootComponent }) => {
// TODO(@Mirone): fix the type
// @ts-expect-error fixme
const { success, insertedLinkType } =
// @ts-expect-error fixme
@@ -385,7 +384,6 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
if (!success) return;
// TODO(@Mirone): fix the type
insertedLinkType
?.then(
(type: {
@@ -394,17 +392,17 @@ export function patchQuickSearchService(framework: FrameworkProvider) {
const flavour = type?.flavour;
if (!flavour) return;
if (flavour === 'affine:bookmark') {
track.doc.editor.slashMenu.bookmark();
return;
}
if (flavour === 'affine:embed-linked-doc') {
track.doc.editor.slashMenu.linkDoc({
control: 'linkDoc',
});
return;
}
if (flavour === 'affine:bookmark') {
track.doc.editor.slashMenu.bookmark();
return;
}
}
)
.catch(console.error);

View File

@@ -1,3 +1,4 @@
import { toURLSearchParams } from '@affine/core/utils';
import type { DocMode } from '@blocksuite/blocks';
import { createContext, useCallback, useContext, useMemo } from 'react';
import type { NavigateFunction, NavigateOptions } from 'react-router-dom';
@@ -45,11 +46,8 @@ export function useNavigateHelper() {
elementIds?: string[],
logic: RouteLogic = RouteLogic.PUSH
) => {
const search = new URLSearchParams();
if (mode) search.append('mode', mode);
if (blockIds?.length) search.append('blockIds', blockIds.join(','));
if (elementIds?.length) search.append('elementIds', elementIds.join(','));
const query = search.size > 0 ? `?${search.toString()}` : '';
const search = toURLSearchParams({ mode, blockIds, elementIds });
const query = search?.size ? `?${search.toString()}` : '';
return navigate(`/workspace/${workspaceId}/${pageId}${query}`, {
replace: logic === RouteLogic.REPLACE,
});