Skip to content

Commit 65a8719

Browse files
committed
feat(core): impl the Doc Info and Bi-Directional Links display settings (#7991)
https://github.com/user-attachments/assets/a469254c-a2ea-4cf4-837e-f9a8bbe5b378
1 parent 09ab922 commit 65a8719

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

packages/frontend/core/src/components/affine/page-properties/table.tsx

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button, IconButton, Menu, MenuItem, Tooltip } from '@affine/component';
33
import { useCurrentWorkspacePropertiesAdapter } from '@affine/core/hooks/use-affine-adapter';
44
import { track } from '@affine/core/mixpanel';
55
import { DocLinksService } from '@affine/core/modules/doc-link';
6+
import { EditorSettingService } from '@affine/core/modules/editor-settting';
67
import type {
78
PageInfoCustomProperty,
89
PageInfoCustomPropertyMeta,
@@ -588,16 +589,21 @@ export const PagePropertiesTableHeader = ({
588589
const manager = useContext(managerContext);
589590

590591
const t = useI18n();
591-
const { docLinksServices } = useServices({
592+
const {
593+
docLinksServices,
594+
docService,
595+
workspaceService,
596+
editorSettingService,
597+
} = useServices({
592598
DocLinksServices: DocLinksService,
599+
DocService,
600+
WorkspaceService,
601+
EditorSettingService,
593602
});
594603
const docBacklinks = docLinksServices.backlinks;
595604
const backlinks = useLiveData(docBacklinks.backlinks$);
596605

597-
const { docService, workspaceService } = useServices({
598-
DocService,
599-
WorkspaceService,
600-
});
606+
const settings = useLiveData(editorSettingService.editorSetting.settings$);
601607

602608
const { syncing, retrying, serverClock } = useLiveData(
603609
workspaceService.workspace.engine.doc.docState$(docService.doc.id)
@@ -690,31 +696,33 @@ export const PagePropertiesTableHeader = ({
690696
{dTimestampElement}
691697
</div>
692698
<Divider />
693-
<div className={styles.tableHeaderSecondaryRow}>
694-
<div className={clsx(!open ? styles.pageInfoDimmed : null)}>
695-
{t['com.affine.page-properties.page-info']()}
696-
</div>
697-
{properties.length === 0 || manager.readonly ? null : (
698-
<PagePropertiesSettingsPopup>
699-
<IconButton data-testid="page-info-show-more" size="20">
700-
<MoreHorizontalIcon />
701-
</IconButton>
702-
</PagePropertiesSettingsPopup>
703-
)}
704-
<Collapsible.Trigger asChild role="button" onClick={handleCollapse}>
705-
<div
706-
className={styles.tableHeaderCollapseButtonWrapper}
707-
data-testid="page-info-collapse"
708-
>
709-
<IconButton size="20">
710-
<ToggleExpandIcon
711-
className={styles.collapsedIcon}
712-
data-collapsed={!open}
713-
/>
714-
</IconButton>
699+
{settings.displayDocInfo ? (
700+
<div className={styles.tableHeaderSecondaryRow}>
701+
<div className={clsx(!open ? styles.pageInfoDimmed : null)}>
702+
{t['com.affine.page-properties.page-info']()}
715703
</div>
716-
</Collapsible.Trigger>
717-
</div>
704+
{properties.length === 0 || manager.readonly ? null : (
705+
<PagePropertiesSettingsPopup>
706+
<IconButton data-testid="page-info-show-more" size="20">
707+
<MoreHorizontalIcon />
708+
</IconButton>
709+
</PagePropertiesSettingsPopup>
710+
)}
711+
<Collapsible.Trigger asChild role="button" onClick={handleCollapse}>
712+
<div
713+
className={styles.tableHeaderCollapseButtonWrapper}
714+
data-testid="page-info-collapse"
715+
>
716+
<IconButton size="20">
717+
<ToggleExpandIcon
718+
className={styles.collapsedIcon}
719+
data-collapsed={!open}
720+
/>
721+
</IconButton>
722+
</div>
723+
</Collapsible.Trigger>
724+
</div>
725+
) : null}
718726
</div>
719727
);
720728
};

packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const BiDirectionalLinkPanel = () => {
1818

1919
const links = useLiveData(docLinksService.links.links$);
2020
const backlinks = useLiveData(docLinksService.backlinks.backlinks$);
21-
2221
const handleClickShow = useCallback(() => {
2322
setShow(!show);
2423
}, [show]);

packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
useLitPortalFactory,
55
} from '@affine/component';
66
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
7+
import { EditorSettingService } from '@affine/core/modules/editor-settting';
78
import { PeekViewService } from '@affine/core/modules/peek-view';
89
import { WorkbenchService } from '@affine/core/modules/workbench';
910
import type { DocMode } from '@blocksuite/blocks';
@@ -145,6 +146,8 @@ export const BlocksuiteDocEditor = forwardRef<
145146
const activeView = useLiveData(workbench.activeView$);
146147
const hash = useLiveData(activeView.location$).hash;
147148

149+
const editorSettingService = useService(EditorSettingService);
150+
148151
const onDocRef = useCallback(
149152
(el: PageEditor) => {
150153
docRef.current = el;
@@ -178,6 +181,8 @@ export const BlocksuiteDocEditor = forwardRef<
178181

179182
const [specs, portals] = usePatchSpecs(page, !!shared, 'page');
180183

184+
const settings = useLiveData(editorSettingService.editorSetting.settings$);
185+
181186
return (
182187
<>
183188
<div className={styles.affineDocViewport} style={{ height: '100%' }}>
@@ -202,7 +207,9 @@ export const BlocksuiteDocEditor = forwardRef<
202207
}}
203208
></div>
204209
) : null}
205-
{!page.readonly ? <BiDirectionalLinkPanel /> : null}
210+
{!page.readonly && settings.displayBiDirectionalLink ? (
211+
<BiDirectionalLinkPanel />
212+
) : null}
206213
</div>
207214
{portals}
208215
</>

0 commit comments

Comments
 (0)