mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: remember last used theme
This commit is contained in:
1 parent
7acaf00e78
commit
2bad82ab81
2 files changed
+8
-3
No files matched your search
@@ -9,6 +9,9 @@ import './monaco.styl';
|
|||||||
|
|
||||||
export default monaco;
|
export default monaco;
|
||||||
export const customOptions: monaco.editor.IStandaloneDiffEditorConstructionOptions = JSON.parse(localStorage.getItem('editor.config') || '{}');
|
export const customOptions: monaco.editor.IStandaloneDiffEditorConstructionOptions = JSON.parse(localStorage.getItem('editor.config') || '{}');
|
||||||
|
export function saveCustomOptions() {
|
||||||
|
localStorage.setItem('editor.config', JSON.stringify(customOptions));
|
||||||
|
}
|
||||||
|
|
||||||
const loaded = {};
|
const loaded = {};
|
||||||
async function fetchTheme(id: string, label: string) {
|
async function fetchTheme(id: string, label: string) {
|
||||||
@@ -29,7 +32,7 @@ class ChangeThemeAction extends EditorAction {
|
|||||||
super({
|
super({
|
||||||
id: 'hydro.changeEditorTheme',
|
id: 'hydro.changeEditorTheme',
|
||||||
label: i18n('Change Theme'),
|
label: i18n('Change Theme'),
|
||||||
alias: [i18n('Change Theme'), 'Change Theme'],
|
alias: 'Change Theme',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +58,7 @@ class ChangeThemeAction extends EditorAction {
|
|||||||
}
|
}
|
||||||
await fetchTheme(selected.command, selected.label);
|
await fetchTheme(selected.command, selected.label);
|
||||||
customOptions.theme = selected.command;
|
customOptions.theme = selected.command;
|
||||||
|
saveCustomOptions();
|
||||||
return monaco.editor.setTheme(selected.command);
|
return monaco.editor.setTheme(selected.command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,11 +159,12 @@ export function registerAction(
|
|||||||
editor.onDidChangeConfiguration(() => {
|
editor.onDidChangeConfiguration(() => {
|
||||||
const current = editor.getOption(monaco.editor.EditorOptions.fontSize.id);
|
const current = editor.getOption(monaco.editor.EditorOptions.fontSize.id);
|
||||||
customOptions.fontSize = current;
|
customOptions.fontSize = current;
|
||||||
localStorage.setItem('editor.config', JSON.stringify(customOptions));
|
saveCustomOptions();
|
||||||
});
|
});
|
||||||
if (model.getLanguageId() === 'markdown') {
|
if (model.getLanguageId() === 'markdown') {
|
||||||
const suggestWidget = (editor.getContribution('editor.contrib.suggestController') as any).widget?.value;
|
const suggestWidget = (editor.getContribution('editor.contrib.suggestController') as any).widget?.value;
|
||||||
if (suggestWidget?._setDetailsVisible) suggestWidget._setDetailsVisible(true);
|
if (suggestWidget?._setDetailsVisible) suggestWidget._setDetailsVisible(true);
|
||||||
handlePasteEvent(editor);
|
handlePasteEvent(editor);
|
||||||
}
|
}
|
||||||
|
return loadThemePromise;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.33.3",
|
"version": "4.33.4",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
Reference in new issue
Block a user