From dd8f318587ab592742067adad5bdc863f4312e4f Mon Sep 17 00:00:00 2001 From: cweijan Date: Tue, 5 Mar 2024 02:31:04 +0800 Subject: [PATCH] Upper case theme name. --- package.json | 6 +++--- resource/vditor/css/theme/{auto.css => Auto.css} | 0 resource/vditor/css/theme/{light.css => Light.css} | 0 .../css/theme/{solarized.css => Solarized.css} | 0 resource/vditor/index.css | 6 ++++++ resource/vditor/util.js | 8 ++++++++ src/provider/markdownEditorProvider.ts | 12 ++++++++++-- 7 files changed, 27 insertions(+), 5 deletions(-) rename resource/vditor/css/theme/{auto.css => Auto.css} (100%) rename resource/vditor/css/theme/{light.css => Light.css} (100%) rename resource/vditor/css/theme/{solarized.css => Solarized.css} (100%) diff --git a/package.json b/package.json index 3bc167f..feb6426 100755 --- a/package.json +++ b/package.json @@ -461,9 +461,9 @@ "vscode-office.editorTheme": { "type": "string", "enum": [ - "light", - "auto", - "solarized" + "Auto", + "Light", + "Solarized" ], "default": "light", "markdownDescription": "The theme for the Markdown editor." diff --git a/resource/vditor/css/theme/auto.css b/resource/vditor/css/theme/Auto.css similarity index 100% rename from resource/vditor/css/theme/auto.css rename to resource/vditor/css/theme/Auto.css diff --git a/resource/vditor/css/theme/light.css b/resource/vditor/css/theme/Light.css similarity index 100% rename from resource/vditor/css/theme/light.css rename to resource/vditor/css/theme/Light.css diff --git a/resource/vditor/css/theme/solarized.css b/resource/vditor/css/theme/Solarized.css similarity index 100% rename from resource/vditor/css/theme/solarized.css rename to resource/vditor/css/theme/Solarized.css diff --git a/resource/vditor/index.css b/resource/vditor/index.css index fe1394f..1702ce4 100644 --- a/resource/vditor/index.css +++ b/resource/vditor/index.css @@ -21,4 +21,10 @@ a { .win32 *{ text-shadow: 0 0 0.55px #7c7c7cdd; +} + +.vditor-toolbar__item .vditor-tooltipped[data-type="selectTheme"]{ + width: 55px; + font-size: 14px; + color: var(--vscode-charts-red); } \ No newline at end of file diff --git a/resource/vditor/util.js b/resource/vditor/util.js index bdcb8a4..5495fd9 100644 --- a/resource/vditor/util.js +++ b/resource/vditor/util.js @@ -87,6 +87,14 @@ export async function getToolbar(resPath) { }, { name: 'upload', tipPosition: 'e' }, "|", + { + name:'selectTheme', + tipPosition: 's', tip: 'Select Theme', + icon: 'Theme:', + click() { + handler.emit("theme") + } + }, { tipPosition: 's', tip: 'Select Theme', icon: await loadRes(`${resPath}/icon/theme.svg`), diff --git a/src/provider/markdownEditorProvider.ts b/src/provider/markdownEditorProvider.ts index f3fea2e..a4b5345 100644 --- a/src/provider/markdownEditorProvider.ts +++ b/src/provider/markdownEditorProvider.ts @@ -114,8 +114,16 @@ export class MarkdownEditorProvider implements vscode.CustomTextEditorProvider { }).on("export", (option) => { vscode.commands.executeCommand('workbench.action.files.save'); new MarkdownService(this.context).exportMarkdown(uri, option) - }).on("theme", () => { - vscode.commands.executeCommand('workbench.action.selectTheme'); + }).on("theme", async (theme) => { + if (!theme) { + const themes = ["Auto", "Light", "Solarized"] + const editorTheme = Global.getConfig('editorTheme'); + const themeItems: vscode.QuickPickItem[] = themes.map(theme => ({ label: theme, description: theme == editorTheme ? 'Current' : undefined })) + theme = await vscode.window.showQuickPick(themeItems, { placeHolder: "Select Editor Theme" }); + if (!theme) return + } + handler.emit('theme', theme.label) + Global.updateConfig('editorTheme', theme.label) }).on("saveOutline", (enable) => { config.update("openOutline", enable, true) }).on('developerTool', () => {