mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
fix(core): reference link icon (#8223)
Closes [AF-1384](https://linear.app/affine-design/issue/AF-1384/edgeless-reference-icon-在fail版本中显示不正确)
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
TodayIcon,
|
||||
} from '@blocksuite/icons/rc';
|
||||
import type { DocCollection } from '@blocksuite/store';
|
||||
import { useService } from '@toeverything/infra';
|
||||
import { DocsService, useLiveData, useService } from '@toeverything/infra';
|
||||
import { nanoid } from 'nanoid';
|
||||
import {
|
||||
type PropsWithChildren,
|
||||
@@ -38,6 +38,7 @@ export interface PageReferenceRendererOptions {
|
||||
// Link to block or element
|
||||
linkToNode?: boolean;
|
||||
}
|
||||
|
||||
// use a function to be rendered in the lit renderer
|
||||
export function pageReferenceRenderer({
|
||||
pageId,
|
||||
@@ -86,28 +87,31 @@ export function AffinePageReference({
|
||||
pageId,
|
||||
docCollection,
|
||||
wrapper: Wrapper,
|
||||
mode = 'page',
|
||||
params,
|
||||
}: {
|
||||
pageId: string;
|
||||
docCollection: DocCollection;
|
||||
wrapper?: React.ComponentType<PropsWithChildren>;
|
||||
mode?: DocMode;
|
||||
params?: URLSearchParams;
|
||||
}) {
|
||||
const t = useI18n();
|
||||
const pageMetaHelper = useDocMetaHelper();
|
||||
const journalHelper = useJournalHelper(docCollection);
|
||||
const t = useI18n();
|
||||
const docsService = useService(DocsService);
|
||||
const mode = useLiveData(docsService.list.primaryMode$(pageId));
|
||||
|
||||
let linkWithMode: DocMode | null = null;
|
||||
let linkToNode = false;
|
||||
if (params) {
|
||||
linkWithMode = params.get('mode') as DocMode;
|
||||
const m = params.get('mode');
|
||||
if (m && (m === 'page' || m === 'edgeless')) {
|
||||
linkWithMode = m as DocMode;
|
||||
}
|
||||
linkToNode = params.has('blockIds') || params.has('elementIds');
|
||||
}
|
||||
|
||||
const el = pageReferenceRenderer({
|
||||
docMode: linkWithMode ?? mode,
|
||||
docMode: linkWithMode ?? mode ?? 'page',
|
||||
pageId,
|
||||
pageMetaHelper,
|
||||
journalHelper,
|
||||
|
||||
@@ -97,12 +97,11 @@ const usePatchSpecs = (page: Doc, shared: boolean, mode: DocMode) => {
|
||||
<AffinePageReference
|
||||
docCollection={page.collection}
|
||||
pageId={pageId}
|
||||
mode={mode}
|
||||
params={params}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}, [mode, page.collection]);
|
||||
}, [page.collection]);
|
||||
|
||||
const specs = useMemo(() => {
|
||||
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||
|
||||
Reference in New Issue
Block a user