mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
3324a14202
[web] Remove angular settings dependency when renaming a project in editor top bar GitOrigin-RevId: 45a8b71fc84135f5291217f613cc95aea7192c35
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import type {
|
|
FontFamily,
|
|
LineHeight,
|
|
OverallTheme,
|
|
} from '../../source-editor/extensions/theme'
|
|
import type {
|
|
Keybindings,
|
|
PdfViewer,
|
|
ProjectCompiler,
|
|
} from '../../../../../types/project-settings'
|
|
import { sendMB } from '../../../infrastructure/event-tracking'
|
|
import { postJSON } from '../../../infrastructure/fetch-json'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
export type UserSettings = {
|
|
pdfViewer: PdfViewer
|
|
autoComplete: boolean
|
|
autoPairDelimiters: boolean
|
|
syntaxValidation: boolean
|
|
editorTheme: string
|
|
overallTheme: OverallTheme
|
|
mode: Keybindings
|
|
fontSize: string
|
|
fontFamily: FontFamily
|
|
lineHeight: LineHeight
|
|
}
|
|
|
|
export type ProjectSettings = {
|
|
compiler: ProjectCompiler
|
|
imageName: string
|
|
rootDocId: string
|
|
spellCheckLanguage: string
|
|
name: string
|
|
}
|
|
|
|
type SaveUserSettings = Partial<
|
|
UserSettings & {
|
|
spellCheckLanguage: ProjectSettings['spellCheckLanguage']
|
|
}
|
|
>
|
|
|
|
export function saveUserSettings(
|
|
key: keyof SaveUserSettings,
|
|
value: SaveUserSettings[keyof SaveUserSettings]
|
|
) {
|
|
sendMB('setting-changed', {
|
|
changedSetting: key,
|
|
changedSettingVal: value,
|
|
})
|
|
|
|
postJSON('/user/settings', {
|
|
body: {
|
|
[key]: value,
|
|
},
|
|
}).catch(debugConsole.error)
|
|
}
|
|
|
|
export const saveProjectSettings = async (
|
|
projectId: string,
|
|
data: Partial<ProjectSettings>
|
|
) => {
|
|
await postJSON<never>(`/project/${projectId}/settings`, {
|
|
body: {
|
|
...data,
|
|
},
|
|
})
|
|
}
|