first commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { ReactScopeValueStore } from '@/features/ide-react/scope-value-store/react-scope-value-store'
|
||||
import customLocalStorage from '@/infrastructure/local-storage'
|
||||
import { DocumentContainer } from '@/features/ide-react/editor/document-container'
|
||||
|
||||
export type EditorScopeValue = {
|
||||
showSymbolPalette: false
|
||||
toggleSymbolPalette: () => void
|
||||
sharejs_doc: DocumentContainer | null
|
||||
open_doc_id: string | null
|
||||
open_doc_name: string | null
|
||||
opening: boolean
|
||||
trackChanges: boolean
|
||||
wantTrackChanges: boolean
|
||||
showVisual: boolean
|
||||
error_state: boolean
|
||||
}
|
||||
|
||||
export function populateEditorScope(
|
||||
store: ReactScopeValueStore,
|
||||
projectId: string
|
||||
) {
|
||||
store.set('project.name', null)
|
||||
|
||||
const editor: Omit<EditorScopeValue, 'showVisual'> = {
|
||||
showSymbolPalette: false,
|
||||
toggleSymbolPalette: () => {},
|
||||
sharejs_doc: null,
|
||||
open_doc_id: null,
|
||||
open_doc_name: null,
|
||||
opening: true,
|
||||
trackChanges: false,
|
||||
wantTrackChanges: false,
|
||||
error_state: false,
|
||||
}
|
||||
store.set('editor', editor)
|
||||
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ReactScopeValueStore } from '../scope-value-store/react-scope-value-store'
|
||||
import getMeta from '@/utils/meta'
|
||||
|
||||
const reviewPanelStorageKey = `ui.reviewPanelOpen.${getMeta('ol-project_id')}`
|
||||
|
||||
export default function populateLayoutScope(store: ReactScopeValueStore) {
|
||||
store.set('ui.view', 'editor')
|
||||
store.set('openFile', null)
|
||||
store.persisted('ui.chatOpen', false, 'ui.chatOpen')
|
||||
store.persisted('ui.reviewPanelOpen', false, reviewPanelStorageKey)
|
||||
store.set('ui.leftMenuShown', false)
|
||||
store.set('ui.miniReviewPanelVisible', false)
|
||||
store.set('ui.pdfLayout', 'sideBySide')
|
||||
}
|
||||
Reference in New Issue
Block a user