mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Store editor selection on a per-user rather than per-project basis (#16246)
* Store editor selection on a per-user rather than per-project basis * set code editor if rich_text=false * format fix GitOrigin-RevId: 8efc33b682de211162e674839e6b891ec04e542e
This commit is contained in:
committed by
Copybot
parent
b0028a2789
commit
da2f7ff153
+22
-4
@@ -1,4 +1,5 @@
|
||||
import { ReactScopeValueStore } from '@/features/ide-react/scope-value-store/react-scope-value-store'
|
||||
import customLocalStorage from '@/infrastructure/local-storage'
|
||||
|
||||
export function populateEditorScope(
|
||||
store: ReactScopeValueStore,
|
||||
@@ -23,8 +24,25 @@ export function populateEditorScope(
|
||||
newSourceEditor: true,
|
||||
error_state: false,
|
||||
})
|
||||
store.persisted('editor.showVisual', false, `editor.mode.${projectId}`, {
|
||||
toPersisted: showVisual => (showVisual ? 'rich-text' : 'source'),
|
||||
fromPersisted: mode => mode === 'rich-text',
|
||||
})
|
||||
store.persisted(
|
||||
'editor.showVisual',
|
||||
showVisualFallbackValue(projectId),
|
||||
`editor.lastUsedMode`,
|
||||
{
|
||||
toPersisted: showVisual => (showVisual ? 'visual' : 'code'),
|
||||
fromPersisted: mode => mode === 'visual',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function showVisualFallbackValue(projectId: string) {
|
||||
const editorModeKey = `editor.mode.${projectId}`
|
||||
const editorModeVal = customLocalStorage.getItem(editorModeKey)
|
||||
|
||||
if (editorModeVal) {
|
||||
// clean up the old key
|
||||
customLocalStorage.removeItem(editorModeKey)
|
||||
}
|
||||
|
||||
return editorModeVal === 'rich-text'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user