diff --git a/packages/common/infra/src/modules/doc/constants.ts b/packages/common/infra/src/modules/doc/constants.ts
index 31a526fa8583b..cf1081908168a 100644
--- a/packages/common/infra/src/modules/doc/constants.ts
+++ b/packages/common/infra/src/modules/doc/constants.ts
@@ -11,4 +11,9 @@ export const BUILT_IN_CUSTOM_PROPERTY_TYPE = [
type: 'tags',
index: 'a0000001',
},
+ {
+ id: 'docPrimaryMode',
+ type: 'docPrimaryMode',
+ show: 'always-hide',
+ },
] as DocCustomPropertyInfo[];
diff --git a/packages/frontend/component/src/ui/property/property.css.ts b/packages/frontend/component/src/ui/property/property.css.ts
index a13f88d2b9361..a0a28e4c58ac7 100644
--- a/packages/frontend/component/src/ui/property/property.css.ts
+++ b/packages/frontend/component/src/ui/property/property.css.ts
@@ -65,6 +65,7 @@ export const hide = style({
export const propertyNameContainer = style({
display: 'flex',
flexDirection: 'column',
+ justifyContent: 'center',
position: 'relative',
borderRadius: 4,
fontSize: cssVar('fontSm'),
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
index 85b8a99dbcdaf..afe65515d8ad8 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
@@ -1,4 +1,4 @@
-import { toast } from '@affine/component';
+import { notify } from '@affine/component';
import {
Menu,
MenuItem,
@@ -74,6 +74,7 @@ export const PageHeaderMenuButton = ({
editorService.editor.doc.meta$.map(meta => meta.trash)
);
const currentMode = useLiveData(editorService.editor.mode$);
+ const primaryMode = useLiveData(editorService.editor.doc.primaryMode$);
const workbench = useService(WorkbenchService).workbench;
@@ -148,16 +149,22 @@ export const PageHeaderMenuButton = ({
}, [rename]);
const handleSwitchMode = useCallback(() => {
- editorService.editor.toggleMode();
+ const mode = primaryMode === 'page' ? 'edgeless' : 'page';
+ editorService.editor.doc.setPrimaryMode(mode);
track.$.header.docOptions.switchPageMode({
- mode: currentMode === 'page' ? 'edgeless' : 'page',
+ mode,
});
- toast(
- currentMode === 'page'
- ? t['com.affine.toastMessage.edgelessMode']()
- : t['com.affine.toastMessage.pageMode']()
- );
- }, [currentMode, editorService, t]);
+ notify.success({
+ title:
+ primaryMode === 'page'
+ ? t['com.affine.toastMessage.defaultMode.edgeless.title']()
+ : t['com.affine.toastMessage.defaultMode.page.title'](),
+ message:
+ primaryMode === 'page'
+ ? t['com.affine.toastMessage.defaultMode.edgeless.message']()
+ : t['com.affine.toastMessage.defaultMode.page.message'](),
+ });
+ }, [primaryMode, editorService, t]);
const handleMenuOpenChange = useCallback((open: boolean) => {
if (open) {
@@ -264,14 +271,13 @@ export const PageHeaderMenuButton = ({
)}
: }
+ prefixIcon={primaryMode === 'page' ? : }
data-testid="editor-option-menu-edgeless"
onSelect={handleSwitchMode}
>
- {t['Convert to ']()}
- {currentMode === 'page'
- ? t['com.affine.pageMode.edgeless']()
- : t['com.affine.pageMode.page']()}
+ {primaryMode === 'page'
+ ? t['com.affine.editorDefaultMode.edgeless']()
+ : t['com.affine.editorDefaultMode.page']()}