Skip to content

Drafts

Drafts 是一款适用于 Apple 平台(iPhone、iPad、Mac、Apple Watch)的强大文本捕获和自动化应用。它可以让您快速捕获文本,并通过操作(Actions)将文本发送到其他应用和服务。Protocol Launcher 允许您生成深度链接以在 Drafts 中创建、编辑和管理草稿。

使用方式

有两种使用此库的方式:

  • 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
  • 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。

生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。

选择安装方式

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

打开 Drafts

On-Demand
ts
import { open } from 'protocol-launcher/drafts'

const url = open()

打开现有草稿

On-Demand
ts
import { open } from 'protocol-launcher/drafts'

const url = open({
  uuid: 'UUID-TO-VALID-DRAFT',
})

通过标题打开草稿

On-Demand
ts
import { open } from 'protocol-launcher/drafts'

const url = open({
  title: 'MyDraft/Header Name',
})

创建新草稿

On-Demand
ts
import { create } from 'protocol-launcher/drafts'

const url = create({
  text: 'Hello World',
})

创建带标签的草稿

On-Demand
ts
import { create } from 'protocol-launcher/drafts'

const url = create({
  text: 'Hello World',
  tag: ['work', 'important'],
  flagged: true,
})

获取草稿内容

On-Demand
ts
import { get } from 'protocol-launcher/drafts'

const url = get({
  uuid: 'UUID-TO-VALID-DRAFT',
})

获取草稿内容(带返回参数)

On-Demand
ts
import { get } from 'protocol-launcher/drafts'

const url = get({
  uuid: 'UUID-TO-VALID-DRAFT',
  retParam: 'input',
})

搜索草稿

On-Demand
ts
import { search } from 'protocol-launcher/drafts'

const url = search({
  query: 'meeting',
  tag: 'work',
  folder: 'inbox',
})

追加文本到草稿

On-Demand
ts
import { append } from 'protocol-launcher/drafts'

const url = append({
  uuid: 'UUID-TO-VALID-DRAFT',
  text: 'TEXT-TO-ADD',
})

追加文本并执行操作

On-Demand
ts
import { append } from 'protocol-launcher/drafts'

const url = append({
  uuid: 'xxx',
  text: 'Suffix',
  action: 'MyAction',
})

在草稿开头添加文本

On-Demand
ts
import { prepend } from 'protocol-launcher/drafts'

const url = prepend({
  uuid: 'UUID-TO-VALID-DRAFT',
  text: 'TEXT-TO-ADD',
})

在草稿开头添加文本并带标签

On-Demand
ts
import { prepend } from 'protocol-launcher/drafts'

const url = prepend({
  uuid: 'xxx',
  text: 'Prefix',
  tag: ['work', 'important'],
})

捕获文本

On-Demand
ts
import { capture } from 'protocol-launcher/drafts'

const url = capture({
  text: 'Note',
  tag: 'work,important',
})

口述文本

On-Demand
ts
import { dictate } from 'protocol-launcher/drafts'

const url = dictate({
  locale: 'en-US',
  save: false,
  xSuccess: 'myapp://callback',
})

加载工作区

On-Demand
ts
import { workspace } from 'protocol-launcher/drafts'

const url = workspace({
  name: 'Default',
})

对文本执行操作

On-Demand
ts
import { runAction } from 'protocol-launcher/drafts'

const url = runAction({
  text: 'TEXT',
  action: 'VALID-ACTION-NAME',
})

快速搜索

On-Demand
ts
import { quickSearch } from 'protocol-launcher/drafts'

const url = quickSearch({
  query: 'QUERY-TEXT',
})

整理文本

On-Demand
ts
import { arrange } from 'protocol-launcher/drafts'

const url = arrange({
  text: 'unsorted list',
  retParam: 'input',
  xSuccess: 'myapp://callback',
})

操作搜索

On-Demand
ts
import { actionSearch } from 'protocol-launcher/drafts'

const url = actionSearch({
  query: 'QUERY-TEXT',
})

命令面板

On-Demand
ts
import { commandPalette } from 'protocol-launcher/drafts'

const url = commandPalette({
  query: 'QUERY-TEXT',
})

获取当前草稿

On-Demand
ts
import { getCurrentDraft } from 'protocol-launcher/drafts'

const url = getCurrentDraft({
  xSuccess: 'myapp://callback',
})

加载操作栏组

On-Demand
ts
import { loadActionBarGroup } from 'protocol-launcher/drafts'

const url = loadActionBarGroup({
  name: 'GROUP-NAME',
})

加载操作组

On-Demand
ts
import { loadActionGroup } from 'protocol-launcher/drafts'

const url = loadActionGroup({
  name: 'GROUP-NAME',
})

替换草稿中的范围

On-Demand
ts
import { replaceRange } from 'protocol-launcher/drafts'

const url = replaceRange({
  uuid: 'UUID-TO-VALID-DRAFT',
  text: 'TEXT-TO-INSERT',
  start: 0,
  length: 10,
})

扫描文档

On-Demand
ts
import { scanDocument } from 'protocol-launcher/drafts'

const url = scanDocument({
  save: false,
  retParam: 'input',
  xSuccess: 'myapp://callback',
})