typora_plugin Documentation

Typora plugin. Feature enhancement tool | Typora 插件,功能增强工具

RAW Doc

File: README.md

English | 简体中文

Plugin List

Plugin:Navigation & Management Feature Default
window_tab Window Tab Bar
search_multi Multi-Fields File Searcher
auto_number Auto numbering
bookmark Bookmark manager ×
cursor_history Cursor History ×
preferences Preferences
updater One-click plugin update
asset_root_redirect Resource Redirection ×
repository Manage opened folders ×
Plugin:Enhance Editing Feature Default
collapse_paragraph Chapter Folding ×
collapse_list List Folding ×
collapse_table Table Folding ×
md_padding Chinese-English Text Spacer
slash_commands Slash Commands
mouse_gestures Mouse Gestures ×
templater File Templater
fence_enhance Enhance Fence
right_outline Right Outline
commander Commander
command_palette Command Palette
right_click_menu Right-Click Menu
pie_menu Pie menu ×
datatables Enhance Table ×
resize_table Table Resizer
resize_image Image Resizer
easy_modify Editing tools
editor_width_slider Adjust writing area width
cjk_symbol_pairing CJK Symbol Pairing
text_stylize Text stylization
resource_manager Resource Management
markdownlint Markdownlint Check
export_enhance Avoid image loss when exporting to HTML/PDF ×
html_editor Preview and edit HTML in the main editor ×
Plugin:View & Theme Feature Default
dark Dark mode
no_image No image mode
blur Blur mode
myopic_defocus Defocus Comfort Mode
read_only Read-only mode
truncate_text Hide content to improve performance for large files ×
image_viewer Image viewer
diagram_enhance Diagram zoom, pan, fullscreen, and resize ×
static_markers Static Markers ×
sidebar_enhance Drag & drop to rearrange、Display non-Markdown files、Keep Fold State
Plugin:Component Feature Default
markmap Provides Markmap support
echarts Provides Echarts support
chart Provides Chart.js support
drawIO Provides DrawIO support
abc Provides abc.js support
calendar Provides tui.calendar support
wavedrom Provides WaveDrom support
marp Provides Marp support
plantUML Provides PlantUML support ×
callouts Provides Callouts support
kanban Kanban
timeline Timeline
chat Chat
Plugin:Advanced Feature Default
hotkeys Hotkey registration center (Advanced)
action_buttons Add function buttons in the lower right corner (Advanced)
remote_control Typora Automation (Advanced) ×
cipher Encrypt files ×
ripgrep Search files using ripgrep ×
article_uploader One-click upload blog to supported platforms ×

If you have other needs or find bugs, feel free to open an issue. PRs are also welcome. If you find this project helpful, please give me a star ⭐

Q&A

  • Is my Typora supported? Typora's version should be ≥ 0.9.98 (the last free version).
  • How to modify plugin configurations? Right-click menu -> Interactive Plugins -> Preferences. Respect all user choices. Any plugin or feature can be permanently enabled/disabled.
  • How to upgrade plugins? Right-click menu -> Interactive Plugins -> Preferences -> Check for Updates.
  • How to uninstall plugins? Right-click menu -> Interactive Plugins -> Preferences -> Uninstall Plugins.
  • Does it support Typora for Mac? I don't have a Mac device, so I haven't tested it.
  • Any other questions? Please ask AI Wiki.

How to Use: Windows/Linux Platform

Visit Installation Tutorial

  1. Download the plugin source code package and unzip it.

  2. Go to the Typora installation path and find the folder A containing window.html.

    • For the official version of Typora, the path is ./resources/window.html.

    • For the beta version of Typora, the path is ./resources/app/window.html.

  3. Paste the unzipped plugin folder into folder A.

  4. Go to the folder A/plugin/bin/.

    • Windows: Right-Click on the file install_windows.ps1. Select 'Run with PowerShell'.
    • Linux: Run install_linux.sh as administrator.
  5. Verification: Restart Typora, right-click in the main text area, and if you see the plugin items, everything is fine.

Official Version Beta Version
Steps 2-3
Windows Linux
Step 4

How to Use: Archlinux Platform

Currently, this method is only for the Archlinux platform, see aur/typora-plugin

sh
yay -S typora-plugin

Plugin Usage Instructions

All plugins provide seven usage methods:

  • Keyboard enthusiasts:
    • Command Palette (see command_palette plugin)
    • Slash commands (see slash_commands plugin)
    • Shortcut keys (see hotkeys plugin)
  • Mouse enthusiasts:
    • Right-click in the main text area (see right_click_menu plugin)
    • Mouse gestures (see mouse_gestures plugin)
    • Quick buttons (see action_buttons plugin)
    • Pie menu(see pie_menu plugin)

window_tab

search_multi

By using Google search syntax and combining different criteria to accurately search for files.

auto_number

Unlike other implementations using theme CSS, this plugin perfectly solves the problem of no numbering in the sidebar after exporting to PDF by modifying the built-in function :)

bookmark

Usage:

  1. Use alt + click on the text content to bookmark.
  2. This will automatically bring up the bookmark manager. Click on the bookmark above to jump to the bookmark.

cursor_history

  • hotkey for the previous cursor: alt+←
  • hotkey for the next cursor: alt+→

This plugin is disabled by default and needs to be manually enabled.

preferences

Preferences

updater

Upgrade Plugin.

asset_root_redirect

If you mainly use Obsidian or Joplin to manage files and occasionally use Typora to open files, you will encounter a problem: both Obsidian and Joplin put local resources in the same directory, but Typora defaults to using relative paths to reference local resources.

This plugin is disabled by default and needs to be manually enabled.

repository

Records folders explicitly opened by Typora and provides a manager for searching, sorting, assigning aliases, opening, or removing records. Removing a record never deletes the real folder. Data is stored in local storage under the repository.data key.

This plugin is disabled by default. Configure a hotkey in Preferences or invoke repository.call through action_buttons.

Enhance Editing

collapse_paragraph

collapse_list

Fold/expand unordered lists, ordered lists, task lists.

collapse_table

Fold/expand tables.

md_padding

Add spaces between Chinese and English, Chinese and numbers when mixed.

slash_commands

Similar to Notion's slash command.

mouse_gestures

Mouse gestures in Typora.

templater

Similar to Obsidian's file template function, quickly create files based on templates.

fence_enhance

right_outline

Typora's sidebar cannot display both [File] and [Outline] simultaneously. To solve this problem, this plugin adds an [Outline] on the right.

commander

command_palette

Similar to VSCode's command palette (Ctrl+Shift+P)

right_click_menu

All plugins support direct invocation through the right-click menu. Mouse enthusiasts can use the right-click menu as the main way to call all plugins.

pie_menu

Pie Menu. Usage:

  • Open circular menu: Ctrl + right mouse button
  • Rotate circular menu: Middle mouse button
  • Pin the circular menu, so it doesn't automatically disappear: Left mouse button in the middle of the circle
  • Expand the circular menu, so it doesn't automatically collapse: Right mouse button in the middle of the circle

datatables

Enhance tables. Provides functions such as search, filter, pagination, and sorting.

Usage: Place the cursor on the table -> Right-click menu -> Interactive Plugins -> Table Enhancement.

resize_table

ctrl + mouse drag: Modify the row height and column width of the table.

resize_image

alt + mouse scroll: Adjust the image size.

easy_modify

This plugin is a collection of commonly used editing tools, currently including:

  1. Copy title path
  2. Promote the title level of the selected paragraph
  3. Demote the title level of the selected paragraph
  4. Convert line break CRLF to LF
  5. Convert line break LF to CRLF
  6. Remove invisible characters
  7. Generate mind map based on the document outline: mindmap
  8. Generate mind map based on the document outline: graph
  9. Extract selected text to a new file
  10. Add trailing spaces

editor_width_slider

Adjust the width of the writing area.

cjk_symbol_pairing

Automatically pair symbols when typing 《 【 ( ' " 「.

text_stylize

resource_manager

Resource management, cleanup of unused images

markdownlint

Check whether the current file complies with the markdown best practices.

export_enhance

When exporting HTML/PDF, convert images to base64 to avoid image loss.

html_editor

Opens .html and .htm files in Typora's main editor with source, preview, and split views, live preview, element inspection, related-document navigation, and save conflict checks.

Preview scripts and network resources are disabled by default. Enable PREVIEW_ALLOW_SCRIPTS or PREVIEW_ALLOW_NETWORK only for trusted files.

This plugin is disabled by default and needs to be manually enabled.

View & Theme

dark

Dark Mode

no_image

No Image Mode

blur

After enabling, only the currently focused component is visible, the rest are blurred. It can be used to prevent peeking.

This plugin can only be used with the official version of Typora.

myopic_defocus

Defocus Comfort Mode

read_only

In read-only mode, the document cannot be edited (after enabling, the bottom right corner of the statistics area will show ReadOnly).

truncate_text

The rendering performance of large files in Typora is very poor. Use this plugin to temporarily hide content (just hide the display, not modify the file) to improve rendering performance. It can also be used to prevent peeking.

Principle: By setting the display style of DOM elements to none, elements are hidden so that they do not occupy a position in the rendering tree, and operations on hidden elements do not cause reflow of other elements.

image_viewer

One-stop image viewing, and provides simple image editing.

diagram_enhance

Adds cursor-centered zoom, drag panning, touch gestures, original-DOM fullscreen viewing, and eight-direction container resizing to Typora diagrams. The context-menu action resets the current diagram's zoom and position.

This plugin is disabled by default and needs to be manually enabled.

static_markers

Say goodbye to distracting format refreshes. This plugin keeps your Markdown syntax markers always visible and static.

This plugin disables the auto-hiding feature for syntax markers in WYSIWYG mode. It ensures that all Markdown characters—like **, ##, and _—remain persistently visible around your text, just as they would in a source code editor.

This plugin is disabled by default and needs to be manually enabled.

  • Drag & drop outline to rearrange
  • Display non-Markdown files in the sidebar
  • Keep Fold Outline State
  • Customize Sidebar File Icons
  • Display File Count

Component

markmap

echarts

chart

drawIO

abc

calendar

wavedrom

marp

Use markdown to create PPT.

plantUML

Due to the B/S architecture of plantUML, a rendering server is required. Suggest using Docker to install:

bash
docker pull plantuml/plantuml-server:jetty
docker run -d --name plantuml-server -p 8080:8080 plantuml/plantuml-server:jetty

callouts

kanban

timeline

chat

Advanced

hotkeys

This plugin is an advanced plugin, only available to users with a JavaScript background.

Bind hotkeys to [any plugin system function] or [any custom function] in a declarative form.

action_buttons

This plugin is an advanced plugin, only available to users with a JavaScript background.

Similar to hotkeys, set function buttons for [any plugin system function] in a declarative form.

remote_control

Expose all capabilities including the typora-plugin in the form of JSON RPC for external manipulation of Typora.

For specific usage, please refer to README.md.

This plugin is an advanced plugin, only available to developers. After enabling this plugin, the external will have both node and browser environments, which can fully control the computer, so if you are not a developer, please do not enable it.

cipher

Encrypt File.

ripgrep

Typora comes with ripgrep. This plugin supports using the built-in ripgrep to search files.

To use this plugin, you need to be familiar with the ripgrep tool. This plugin is disabled by default and needs to be manually enabled.

article_uploader

The user clicks or uses a shortcut key to trigger the automatic publishing function of the current article. The program automatically publishes blog articles to major platforms according to user configuration.

For specific usage, refer to: README.md. Taking uploading to CSDN as an example, the GIF is as follows:

Acknowledgements

Conclusion

This project follows the MIT license, feel free to enjoy it.

If you find it useful, please give it a star ⭐, and feel free to recommend it to like-minded friends.


File: plugin/article_uploader/README.md

自动上传文章插件

由于CSDN是直接逆向的接口,上传文章大概是2-3s,两个selenium自动化的平台上传时间长一点,20s左右

原因

​ 有谁跟我一样,每次写完博客想发布时都得重新登一次wp(因为我隐藏了wp登录的url,防爆破的),wp登录又奇慢无比,手动把标题和文章粘贴过去,设置标签、分类,封面图,慢慢的,5分钟-10分钟就过去了。如果先发到其他平台,还是得手动访问、复制、粘贴、设置标签。

​ 但是,我这个插件完完全全可以解决这个问题,配置好配置文件,每次写完博客,右键点击,或者指定快捷键,只需要把typora挂在后台,你就可以去写代码或者干其他事情了。实在是太方便了!!!

​ 虽然每个平台都是我要手动逆向或者用selenium自动化适配,但是我本人是一个博客重度玩家,我也一直在用这个插件,所以不用担心用着用着不维护了的问题,不过话说国内这些平台也不会有事没事改请求参数或者页面结构。下面给出支持平台和未来特性:

平台支持

  • CSDN

  • 博客园

  • WordPress

  • vitepress&hexo

  • 微信公众号

  • 自建博客

特性支持

  • 一键上传,自动识别文章标题

  • 定时发布&延时发布

  • 标签、分类、封面图

未来不会支持

  • 批量发布(批量发布容易被风控,且这个应该是一次性脚本做的事情)
  • 知乎平台

配置

❗版本提示:插件使用的selenium谷歌驱动是125.0.2的,需要保证本机有Google Chrome。如果发布失败,需要检查版本号。方法:

  1. 你可以访问这个链接获取脚本匹配的谷歌浏览器版本下载 ,或者你可以访问Release 自动发布博客依赖 进行下载

  2. 使用npm安装的同学你也可以修改package.json下方chromedriver版本号以匹配你的版本

建议关闭自动更新,不然可能会有版本问题,但是我一直都是在更新半年了好像也没出现问题

引入依赖

默认两个插件是启用的,但需要引入一些依赖:

首先在typora resources\packages.json 中,追加下面这个依赖

json
"dependencies": {
    "chromedriver": "^125.0.2",
    "marked": "^12.0.2",
    "selenium-webdriver": "^4.21.0"
}

如下图

  1. 如果你是程序开发人员,电脑有node环境,在当前路径下,运行npm i即可

    ⚠️ 运行之前先把之前的node_modules包的几个依赖给备份一下(如下),下载好再粘回来。使用npm下载依赖会删除原有包

  2. 如果你是小白,请下载这个压缩包Release 自动发布博客依赖 ,解压到node_modules文件夹即可

自定义配置

下载完成以后,有两处可供配置。

  1. 配置插件显示隐藏、插件名称、快捷键等信息,与插件配置相同,参考:typora_plugin/plugin/global/settings/README.md

  2. 配置个人信息,这些信息在plugin\global\settings\settings.default.toml文件的 article_uploader 配置,参照注释

关于cookie的获取,登录后随便找个异步请求把所有cookie值粘过来即可

启用

如果您想要启用,首先进入.\plugin\global\settings,找到settings.user.toml文件(初次使用需要先拷贝settings.default.toml一份,具体参考作者文档typora_plugin/plugin/global/settings/README.md。

启用article_uploader插件并在右键菜单配置中添加下面这个配置

toml
[[right_click_menu.MENUS]]
NAME = "上传到所有平台"
LIST = [
    "article_uploader.upload_to_all_site"
]
[[right_click_menu.MENUS]]
NAME = "上传到单个平台"
LIST = [
    "article_uploader.upload_to_csdn",
    "article_uploader.upload_to_wordpress",
    "article_uploader.upload_to_cn_blog"
]

实现原理

具体实现还是在本项目上做扩展,具体实现代码继承结构抽象出来如下

mermaid
graph TD
    A[BasePlugin] --> B[uploadUtil]
    B --> C[uploadToCNBlogPlugin]
    B --> D[uploadToCSDN]
    B --> E[uploadToWordPress]
    B --> F[uploadToAllPlatform]

CSDN

CSDN是通过逆向发布文章接口实现的,分析了一下请求,流程是这样的(其实第一个请求文章就发出去了)

mermaid
sequenceDiagram
    participant A as 用户
    participant B as 服务端

    A->>B: 第一次POST请求,携带参数
    B-->>A: 返回文章id
    A->>B: 拿着文章id向另一个接口再发一次POST请求
    B-->>A: 返回成功标识

​ 两个请求其实都是大差不差的,具体的参数就是要逆向的参数有x-ca-nonce、x-ca-signature这两个参数其他,其他两个x开头的是固定的。

  • 第一个参数是随机数的意思,一看格式UUID没跑了
  • 第二个不知道用的啥加密算法,正常情况是需要去代码里面逆向的,结果服务端给我返回了一个message: 'HMAC signature does not match' },跟我说是HMAC算法,直接搜参数名一打断点就搜到了,js实现加密逻辑即可。

ℹ️关于cookie,应该能撑一个月,截止到我写文章已经两天了,现在cookie还是没问题

WordPress&博客园

​ 发现逆向还是挺累的,用户还需要定期更新cookie,这两个网站用selenium自动化。就是枯燥无味的找输入框,点按钮,进frame,执行赋值脚本。

❗wp同学需要注意,你的md编辑器一定要是wordpress自带的,因为我只适配了这个富文本编辑器。如下

未来拓展思路

​ 标签、分类、封面图、定时发布、演示发布特性的添加,我的思路是结合本插件中的文件模版功能和斜杠命令功能,精准把所有参数都切割出来,考虑缺省功能。