mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-19 00:10:39 +08: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,
|
TodayIcon,
|
||||||
} from '@blocksuite/icons/rc';
|
} from '@blocksuite/icons/rc';
|
||||||
import type { DocCollection } from '@blocksuite/store';
|
import type { DocCollection } from '@blocksuite/store';
|
||||||
import { useService } from '@toeverything/infra';
|
import { DocsService, useLiveData, useService } from '@toeverything/infra';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import {
|
import {
|
||||||
type PropsWithChildren,
|
type PropsWithChildren,
|
||||||
@@ -38,6 +38,7 @@ export interface PageReferenceRendererOptions {
|
|||||||
// Link to block or element
|
// Link to block or element
|
||||||
linkToNode?: boolean;
|
linkToNode?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use a function to be rendered in the lit renderer
|
// use a function to be rendered in the lit renderer
|
||||||
export function pageReferenceRenderer({
|
export function pageReferenceRenderer({
|
||||||
pageId,
|
pageId,
|
||||||
@@ -86,28 +87,31 @@ export function AffinePageReference({
|
|||||||
pageId,
|
pageId,
|
||||||
docCollection,
|
docCollection,
|
||||||
wrapper: Wrapper,
|
wrapper: Wrapper,
|
||||||
mode = 'page',
|
|
||||||
params,
|
params,
|
||||||
}: {
|
}: {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
docCollection: DocCollection;
|
docCollection: DocCollection;
|
||||||
wrapper?: React.ComponentType<PropsWithChildren>;
|
wrapper?: React.ComponentType<PropsWithChildren>;
|
||||||
mode?: DocMode;
|
|
||||||
params?: URLSearchParams;
|
params?: URLSearchParams;
|
||||||
}) {
|
}) {
|
||||||
|
const t = useI18n();
|
||||||
const pageMetaHelper = useDocMetaHelper();
|
const pageMetaHelper = useDocMetaHelper();
|
||||||
const journalHelper = useJournalHelper(docCollection);
|
const journalHelper = useJournalHelper(docCollection);
|
||||||
const t = useI18n();
|
const docsService = useService(DocsService);
|
||||||
|
const mode = useLiveData(docsService.list.primaryMode$(pageId));
|
||||||
|
|
||||||
let linkWithMode: DocMode | null = null;
|
let linkWithMode: DocMode | null = null;
|
||||||
let linkToNode = false;
|
let linkToNode = false;
|
||||||
if (params) {
|
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');
|
linkToNode = params.has('blockIds') || params.has('elementIds');
|
||||||
}
|
}
|
||||||
|
|
||||||
const el = pageReferenceRenderer({
|
const el = pageReferenceRenderer({
|
||||||
docMode: linkWithMode ?? mode,
|
docMode: linkWithMode ?? mode ?? 'page',
|
||||||
pageId,
|
pageId,
|
||||||
pageMetaHelper,
|
pageMetaHelper,
|
||||||
journalHelper,
|
journalHelper,
|
||||||
|
|||||||
@@ -97,12 +97,11 @@ const usePatchSpecs = (page: Doc, shared: boolean, mode: DocMode) => {
|
|||||||
<AffinePageReference
|
<AffinePageReference
|
||||||
docCollection={page.collection}
|
docCollection={page.collection}
|
||||||
pageId={pageId}
|
pageId={pageId}
|
||||||
mode={mode}
|
|
||||||
params={params}
|
params={params}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}, [mode, page.collection]);
|
}, [page.collection]);
|
||||||
|
|
||||||
const specs = useMemo(() => {
|
const specs = useMemo(() => {
|
||||||
const enableAI = featureFlagService.flags.enable_ai.value;
|
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user