Skip to content

Joplin ​

Joplin 是一款用于组织笔记的开源笔记应用。Protocol Launcher 可以生成在 Joplin 中打开笔记、文件夹和标签的链接。

用法 ​

有两种方式使用此库:

  • On-Demand 从子路径导入,有利于 tree-shaking 并保持包体积较小。
  • Full Import 从根包导入,写起来更方便,但会包含所有应用模块。

生产构建建议使用 On-Demand;快速脚本或演示可以使用 Full Import。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

Joplin 外部链接使用 joplin://x-callback-url/<action>,并通过 id query 参数指定目标。官方文档列出了 openNote、openFolder 和 openTag,以及下方的桌面回调命令。回调 URL 必须使用已知应用 scheme 或 x-callback-url 主机;Joplin 不接受 HTTP 和 HTTPS 回调。

打开笔记 ​

通过 note ID 打开 Joplin 笔记。

On-Demand
ts
import { openNote } from 'protocol-launcher/joplin'

const url = openNote({
  id: 'REPLACE_WITH_NOTE_ID',
})

打开文件夹 ​

通过 folder ID 打开 Joplin 文件夹。

On-Demand
ts
import { openFolder } from 'protocol-launcher/joplin'

const url = openFolder({
  id: 'REPLACE_WITH_FOLDER_ID',
})

打开标签 ​

通过 tag ID 打开 Joplin 标签。

On-Demand
ts
import { openTag } from 'protocol-launcher/joplin'

const url = openTag({
  id: 'REPLACE_WITH_TAG_ID',
})

获取当前笔记 ​

仅支持桌面端。通过 x-callback-url 将选中的笔记返回调用应用。

On-Demand
ts
import { getCurrentNote } from 'protocol-launcher/joplin'

const url = getCurrentNote({
  xSuccess: 'hook://x-callback-url/setCurrentNode'
})

创建笔记 ​

仅支持桌面端。在当前笔记本创建笔记,通过回调返回标题和 URL。

On-Demand
ts
import { createNote } from 'protocol-launcher/joplin'

const url = createNote({
  title: 'Meeting notes',
  body: '# Agenda',
  xSuccess: 'hook://x-callback-url/setCurrentNode',
  xError: 'hook://x-callback-url/error'
})

官方文档 ​