mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-04 23:32:31 +03:00
feat(core): impl the Doc Info and Bi-Directional Links display settings (#7991)
https://github.com/user-attachments/assets/a469254c-a2ea-4cf4-837e-f9a8bbe5b378
This commit is contained in:
parent
09ab922572
commit
65a87196d5
@ -3,6 +3,7 @@ import { Button, IconButton, Menu, MenuItem, Tooltip } from '@affine/component';
|
|||||||
import { useCurrentWorkspacePropertiesAdapter } from '@affine/core/hooks/use-affine-adapter';
|
import { useCurrentWorkspacePropertiesAdapter } from '@affine/core/hooks/use-affine-adapter';
|
||||||
import { track } from '@affine/core/mixpanel';
|
import { track } from '@affine/core/mixpanel';
|
||||||
import { DocLinksService } from '@affine/core/modules/doc-link';
|
import { DocLinksService } from '@affine/core/modules/doc-link';
|
||||||
|
import { EditorSettingService } from '@affine/core/modules/editor-settting';
|
||||||
import type {
|
import type {
|
||||||
PageInfoCustomProperty,
|
PageInfoCustomProperty,
|
||||||
PageInfoCustomPropertyMeta,
|
PageInfoCustomPropertyMeta,
|
||||||
@ -588,16 +589,21 @@ export const PagePropertiesTableHeader = ({
|
|||||||
const manager = useContext(managerContext);
|
const manager = useContext(managerContext);
|
||||||
|
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
const { docLinksServices } = useServices({
|
const {
|
||||||
|
docLinksServices,
|
||||||
|
docService,
|
||||||
|
workspaceService,
|
||||||
|
editorSettingService,
|
||||||
|
} = useServices({
|
||||||
DocLinksServices: DocLinksService,
|
DocLinksServices: DocLinksService,
|
||||||
|
DocService,
|
||||||
|
WorkspaceService,
|
||||||
|
EditorSettingService,
|
||||||
});
|
});
|
||||||
const docBacklinks = docLinksServices.backlinks;
|
const docBacklinks = docLinksServices.backlinks;
|
||||||
const backlinks = useLiveData(docBacklinks.backlinks$);
|
const backlinks = useLiveData(docBacklinks.backlinks$);
|
||||||
|
|
||||||
const { docService, workspaceService } = useServices({
|
const settings = useLiveData(editorSettingService.editorSetting.settings$);
|
||||||
DocService,
|
|
||||||
WorkspaceService,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { syncing, retrying, serverClock } = useLiveData(
|
const { syncing, retrying, serverClock } = useLiveData(
|
||||||
workspaceService.workspace.engine.doc.docState$(docService.doc.id)
|
workspaceService.workspace.engine.doc.docState$(docService.doc.id)
|
||||||
@ -690,31 +696,33 @@ export const PagePropertiesTableHeader = ({
|
|||||||
{dTimestampElement}
|
{dTimestampElement}
|
||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider />
|
||||||
<div className={styles.tableHeaderSecondaryRow}>
|
{settings.displayDocInfo ? (
|
||||||
<div className={clsx(!open ? styles.pageInfoDimmed : null)}>
|
<div className={styles.tableHeaderSecondaryRow}>
|
||||||
{t['com.affine.page-properties.page-info']()}
|
<div className={clsx(!open ? styles.pageInfoDimmed : null)}>
|
||||||
</div>
|
{t['com.affine.page-properties.page-info']()}
|
||||||
{properties.length === 0 || manager.readonly ? null : (
|
|
||||||
<PagePropertiesSettingsPopup>
|
|
||||||
<IconButton data-testid="page-info-show-more" size="20">
|
|
||||||
<MoreHorizontalIcon />
|
|
||||||
</IconButton>
|
|
||||||
</PagePropertiesSettingsPopup>
|
|
||||||
)}
|
|
||||||
<Collapsible.Trigger asChild role="button" onClick={handleCollapse}>
|
|
||||||
<div
|
|
||||||
className={styles.tableHeaderCollapseButtonWrapper}
|
|
||||||
data-testid="page-info-collapse"
|
|
||||||
>
|
|
||||||
<IconButton size="20">
|
|
||||||
<ToggleExpandIcon
|
|
||||||
className={styles.collapsedIcon}
|
|
||||||
data-collapsed={!open}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
</div>
|
||||||
</Collapsible.Trigger>
|
{properties.length === 0 || manager.readonly ? null : (
|
||||||
</div>
|
<PagePropertiesSettingsPopup>
|
||||||
|
<IconButton data-testid="page-info-show-more" size="20">
|
||||||
|
<MoreHorizontalIcon />
|
||||||
|
</IconButton>
|
||||||
|
</PagePropertiesSettingsPopup>
|
||||||
|
)}
|
||||||
|
<Collapsible.Trigger asChild role="button" onClick={handleCollapse}>
|
||||||
|
<div
|
||||||
|
className={styles.tableHeaderCollapseButtonWrapper}
|
||||||
|
data-testid="page-info-collapse"
|
||||||
|
>
|
||||||
|
<IconButton size="20">
|
||||||
|
<ToggleExpandIcon
|
||||||
|
className={styles.collapsedIcon}
|
||||||
|
data-collapsed={!open}
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</Collapsible.Trigger>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,6 @@ export const BiDirectionalLinkPanel = () => {
|
|||||||
|
|
||||||
const links = useLiveData(docLinksService.links.links$);
|
const links = useLiveData(docLinksService.links.links$);
|
||||||
const backlinks = useLiveData(docLinksService.backlinks.backlinks$);
|
const backlinks = useLiveData(docLinksService.backlinks.backlinks$);
|
||||||
|
|
||||||
const handleClickShow = useCallback(() => {
|
const handleClickShow = useCallback(() => {
|
||||||
setShow(!show);
|
setShow(!show);
|
||||||
}, [show]);
|
}, [show]);
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
useLitPortalFactory,
|
useLitPortalFactory,
|
||||||
} from '@affine/component';
|
} from '@affine/component';
|
||||||
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
|
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
|
||||||
|
import { EditorSettingService } from '@affine/core/modules/editor-settting';
|
||||||
import { PeekViewService } from '@affine/core/modules/peek-view';
|
import { PeekViewService } from '@affine/core/modules/peek-view';
|
||||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||||
import type { DocMode } from '@blocksuite/blocks';
|
import type { DocMode } from '@blocksuite/blocks';
|
||||||
@ -145,6 +146,8 @@ export const BlocksuiteDocEditor = forwardRef<
|
|||||||
const activeView = useLiveData(workbench.activeView$);
|
const activeView = useLiveData(workbench.activeView$);
|
||||||
const hash = useLiveData(activeView.location$).hash;
|
const hash = useLiveData(activeView.location$).hash;
|
||||||
|
|
||||||
|
const editorSettingService = useService(EditorSettingService);
|
||||||
|
|
||||||
const onDocRef = useCallback(
|
const onDocRef = useCallback(
|
||||||
(el: PageEditor) => {
|
(el: PageEditor) => {
|
||||||
docRef.current = el;
|
docRef.current = el;
|
||||||
@ -178,6 +181,8 @@ export const BlocksuiteDocEditor = forwardRef<
|
|||||||
|
|
||||||
const [specs, portals] = usePatchSpecs(page, !!shared, 'page');
|
const [specs, portals] = usePatchSpecs(page, !!shared, 'page');
|
||||||
|
|
||||||
|
const settings = useLiveData(editorSettingService.editorSetting.settings$);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.affineDocViewport} style={{ height: '100%' }}>
|
<div className={styles.affineDocViewport} style={{ height: '100%' }}>
|
||||||
@ -202,7 +207,9 @@ export const BlocksuiteDocEditor = forwardRef<
|
|||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
) : null}
|
) : null}
|
||||||
{!page.readonly ? <BiDirectionalLinkPanel /> : null}
|
{!page.readonly && settings.displayBiDirectionalLink ? (
|
||||||
|
<BiDirectionalLinkPanel />
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{portals}
|
{portals}
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user