diff --git a/README-CN.md b/README-CN.md index b9b664a..5f615cb 100644 --- a/README-CN.md +++ b/README-CN.md @@ -19,7 +19,6 @@ 编辑器使用说明: [禁用方式看这里](https://github.com/cweijan/vscode-office?tab=readme-ov-file#markdown) - 编辑方式: 直接通过vscode打开md文件. -- 配置 `vscode-office.autoTheme": false`可将编辑器设置为亮白色. - 点击以下按钮可打开VSCode内置编辑器. ![img](image/README-CN/1640579182342.png) - 在编辑器打开右键菜单可将markdown导出为pdf, docx或者html, pdf依赖于chromium, 可通过 `vscode-office.chromiumPath`配置chromium浏览器路径. diff --git a/README-TW.md b/README-TW.md index f6acbee..3b4b348 100644 --- a/README-TW.md +++ b/README-TW.md @@ -19,7 +19,6 @@ 編輯器使用說明: [禁用方式看這裡](https://github.com/cweijan/vscode-office?tab=readme-ov-file#markdown) * 編輯方式:直接透過 VS Code 開啟 `md` 檔案 -* 配置 `vscode-office.autoTheme": false` 可將編輯器設定為亮白色 * 點選以下按鈕可開啟 VSCode 內建編輯器 ![img](image/README-CN/1640579182342.png) * 在編輯器開啟右鍵選單可將 Markdown 匯出為 PDF、DOCX 或者 HTML、PDF 依賴於 Chromium,可透過 `vscode-office.chromiumPath` 配置 Chromium 瀏覽器路徑 diff --git a/package.json b/package.json index 2ca8d62..3bc167f 100755 --- a/package.json +++ b/package.json @@ -458,6 +458,16 @@ "default": true, "description": "Preview code in markdown." }, + "vscode-office.editorTheme": { + "type": "string", + "enum": [ + "light", + "auto", + "solarized" + ], + "default": "light", + "markdownDescription": "The theme for the Markdown editor." + }, "vscode-office.previewCodeHighlight.style": { "type": "string", "enum": [ @@ -507,11 +517,6 @@ "default": true, "markdownDescription": "Show line numbers in markdown preview code window. Only applies when `#vscode-office.previewCode#` is enabled." }, - "vscode-office.autoTheme": { - "type": "boolean", - "default": true, - "description": "Viewer follow vscode theme." - }, "vscode-office.editorLanguage": { "type": "string", "enum": [ diff --git a/resource/vditor/index.js b/resource/vditor/index.js index ec667e9..1acb596 100644 --- a/resource/vditor/index.js +++ b/resource/vditor/index.js @@ -16,9 +16,7 @@ loadConfigs() handler.on("open", async (md) => { const { config, language } = md; - if (config.autoTheme) { - addAutoTheme(md.rootPath) - } + addAutoTheme(md.rootPath, config.editorTheme) const editor = new Vditor('vditor', { value: md.content, _lutePath: md.rootPath + '/lute.min.js', @@ -91,9 +89,12 @@ handler.on("open", async (md) => { }).emit("init") -function addAutoTheme(rootPath) { +function addAutoTheme(rootPath, theme) { + if (theme == 'light') return; importCSS(rootPath, 'base.css') importCSS(rootPath, 'theme/auto.css') + if (theme == 'auto') return; + importCSS(rootPath, `theme/${theme}.css`) } function importCSS(rootPath, path) { diff --git a/src/provider/officeViewerProvider.ts b/src/provider/officeViewerProvider.ts index 6875380..9545b07 100644 --- a/src/provider/officeViewerProvider.ts +++ b/src/provider/officeViewerProvider.ts @@ -106,7 +106,6 @@ export class OfficeViewerProvider implements vscode.CustomReadonlyEditorProvider if (htmlPath != null) { webview.html = Util.buildPath(readFileSync(this.extensionPath + "/resource/" + htmlPath, 'utf8'), webview, this.extensionPath + "/resource") - .replace("$autoTheme", `${Global.getConfig('autoTheme')}`) } }