编写 AnyMenu 词典
编写 AnyMenu 词典
无论是哪种词典或脚本
你均可以参考官方词典的写法,进行仿写:
https://github.com/any-menu/any-menu/tree/main/store/dict
Warning
(若目前软件版本为beta版,仅建议仅使用官方的脚本而非自主开发,api有可能会改。如ctx对象)
(后续也可能支持 typescript 并以继承 plugin 类的方式开发插件 (like obsidian))
词典类补充
支持格式: toml, txt, json
toml格式
会进入多级菜单
- label: string | 搜索框检索的显示, 菜单的显示
- key: string | 菜单的检索的输入
- detail: "md"|"command_ob"|undefined | 输出的类型
- md | 则有预览
- command_ob | 则是obsidian的命令id (仅ob环境可用)
- callback: string | 搜索框检索的输出, 菜单的输出
json格式
不会进入多级菜单
- title: string | 搜索框检索的输出
- keyword: string | 搜索框检索的输入
- description: string | 搜索框检索的显示
txt格式
不会进入多级菜单
使用 tab 进行分割
- 第一列 | 搜索框检索的输入 & 显示
- 第二列 | 搜索框检索的输出
脚本类补充
支持格式: js
对于脚本,或参考api接口: PluginInterface https://github.com/any-menu/any-menu/blob/main/src/Core/pluginManager/PluginInterface.ts
开发者的草稿 (读者不需要看)
解耦快捷键/脚本 与 面板内容:
快捷键与功能/打开面板的对应: 一共有三种路线:
- src\Obsidian\src\contextmenu\index.ts:show_panel() 注册 Obsidian 命令/快捷键
- show_panel -> AMPanel.show
- src\module\focus.ts:toggleWindow() 注册 Tauri 全局快捷键与打开面板
且有黑白名单机制- toggleWindow -> showWindow -> AMPanel.show
- src-tauri\src\ad_shortcut.rs 注册 Tauri 高级快捷键与打开面板
- app_handle.emit("active-window-toggle", ...) -> toggleWindow -> (同上)