-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): set doc mode and primary doc mode separately (#8359)
- Loading branch information
Showing
15 changed files
with
192 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/frontend/core/src/components/doc-properties/types/doc-primary-mode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
notify, | ||
PropertyValue, | ||
RadioGroup, | ||
type RadioItem, | ||
} from '@affine/component'; | ||
import { useI18n } from '@affine/i18n'; | ||
import type { DocMode } from '@blocksuite/affine/blocks'; | ||
import { DocService, useLiveData, useService } from '@toeverything/infra'; | ||
import { useCallback, useMemo } from 'react'; | ||
|
||
export const DocPrimaryModeValue = () => { | ||
const t = useI18n(); | ||
const doc = useService(DocService).doc; | ||
|
||
const primaryMode = useLiveData(doc.primaryMode$); | ||
|
||
const DocModeItems = useMemo<RadioItem[]>( | ||
() => [ | ||
{ | ||
value: 'page' as DocMode, | ||
label: t['Page'](), | ||
}, | ||
{ | ||
value: 'edgeless' as DocMode, | ||
label: t['Edgeless'](), | ||
}, | ||
], | ||
[t] | ||
); | ||
|
||
const handleChange = useCallback( | ||
(mode: DocMode) => { | ||
doc.setPrimaryMode(mode); | ||
notify.success({ | ||
title: | ||
mode === 'page' | ||
? t['com.affine.toastMessage.defaultMode.page.title']() | ||
: t['com.affine.toastMessage.defaultMode.edgeless.title'](), | ||
message: | ||
mode === 'page' | ||
? t['com.affine.toastMessage.defaultMode.page.message']() | ||
: t['com.affine.toastMessage.defaultMode.edgeless.message'](), | ||
}); | ||
}, | ||
[doc, t] | ||
); | ||
return ( | ||
<PropertyValue> | ||
<RadioGroup | ||
width={194} | ||
value={primaryMode} | ||
onChange={handleChange} | ||
items={DocModeItems} | ||
/> | ||
</PropertyValue> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"ar": 87, | ||
"ar": 86, | ||
"ca": 6, | ||
"da": 7, | ||
"de": 32, | ||
"en": 100, | ||
"es-AR": 16, | ||
"es-AR": 15, | ||
"es-CL": 18, | ||
"es": 16, | ||
"es": 15, | ||
"fr": 77, | ||
"hi": 2, | ||
"it": 1, | ||
"ja": 65, | ||
"ko": 92, | ||
"pl": 0, | ||
"pt-BR": 99, | ||
"ru": 85, | ||
"ru": 84, | ||
"sv-SE": 5, | ||
"ur": 3, | ||
"zh-Hans": 100, | ||
"zh-Hant": 100 | ||
"zh-Hant": 99 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.