Skip to content

Commit

Permalink
Remove preview support
Browse files Browse the repository at this point in the history
  • Loading branch information
jks-liu committed Sep 3, 2021
1 parent 79b0beb commit 985b32a
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 49 deletions.
7 changes: 2 additions & 5 deletions README.origin.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ ___
## 🖍 内容创作
<a name = "write"></a>

新建一个后缀名为`.md`的文件,若不需要数学公式,只需要按照你最熟悉的 Markdown 语法写即可,右键点击 `Zhihu: Preview` 可预览答案:

<p align="center">
<img src="https://raw.githubusercontent.com/niudai/ImageHost/master/zhihu/preview.gif" style="box-shadow: 2px 2px 8px 0px #5dd8fd;border-radius: 6px;"/></p>
新建一个后缀名为`.md`的文件,若不需要数学公式,只需要按照你最熟悉的 Markdown 语法写即可。

### Latex 语法支持

Expand Down Expand Up @@ -313,7 +310,7 @@ $$
<p align="center">
<img src="https://raw.githubusercontent.com/niudai/ImageHost/master/zhihu/2020-02-08-20-02-37.png" style="box-shadow: 2px 2px 8px 0px #5dd8fd;border-radius: 6px;"/></p>

左侧的为 `Zhihu: Publish`(发布答案),右侧的为 `Zhihu: Preview` (预览答案)
左侧的为 `Zhihu: Publish`(发布答案),右侧已删除

## ⌨ 快捷键

Expand Down
19 changes: 0 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"onCommand:zhihu.openWebView",
"onCommand:zhihu.publish",
"onCommand:zhihu.jianshuPublish",
"onCommand:zhihu.preview",
"onCommand:zhihu.search",
"onCommand:zhihu.login",
"onCommand:zhihu.logout",
Expand Down Expand Up @@ -147,14 +146,6 @@
"dark": "res/media/dark/delete.svg"
}
},
{
"command": "zhihu.preview",
"title": "Zhihu: Preview",
"icon": {
"light": "res/media/light/preview.svg",
"dark": "res/media/dark/preview.svg"
}
},
{
"command": "zhihu.uploadImageFromClipboard",
"title": "Zhihu: Paste Image From Clipboard"
Expand Down Expand Up @@ -224,11 +215,6 @@
"when": "resourceLangId == markdown",
"group": "zhihu@0"
},
{
"command": "zhihu.preview",
"when": "resourceLangId == markdown",
"group": "zhihu@1"
},
{
"command": "zhihu.uploadImageFromExplorer",
"when": "resourceLangId == markdown",
Expand All @@ -240,11 +226,6 @@
"command": "zhihu.publish",
"when": "resourceLangId == markdown",
"group": "navigation@0"
},
{
"command": "zhihu.preview",
"when": "resourceLangId == markdown",
"group": "navigation@1"
}
],
"explorer/context": [
Expand Down
1 change: 0 additions & 1 deletion res/media/dark/preview.svg

This file was deleted.

1 change: 0 additions & 1 deletion res/media/light/preview.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerTextEditorCommand('zhihu.publish', (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
publishService.publish(textEditor, edit);
})
vscode.commands.registerTextEditorCommand('zhihu.preview', (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => {
vscode.commands.executeCommand('markdown.showPreviewToSide');
})
vscode.commands.registerCommand('zhihu.uploadImageFromClipboard', async () => {
pasteService.uploadImageFromClipboard()
})
Expand Down
20 changes: 0 additions & 20 deletions src/service/publish.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,6 @@ export class PublishService {
})
}

preview(textEdtior: vscode.TextEditor, edit: vscode.TextEditorEdit) {
let text = textEdtior.document.getText();
const url: URL = this.shebangParser(text);
// get rid of shebang line
if (url) text = text.slice(text.indexOf('\n') + 1);
const html = this.zhihuMdParser.render(text);
this.webviewService.renderHtml({
title: '预览',
pugTemplatePath: join(getExtensionPath(), TemplatePath, 'pre-publish.pug'),
pugObjects: {
title: '答案预览',
content: html
},
showOptions: {
viewColumn: vscode.ViewColumn.Beside,
preserveFocus: true
}
});
}

async publish(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) {
const text = textEditor.document.getText();
// text = text + "\n\n>本文使用 [WPL/s](https://zhuanlan.zhihu.com/p/390528313) 发布 [@GitHub](https://github.com/jks-liu/WPL-s)";
Expand Down

0 comments on commit 985b32a

Please sign in to comment.