Skip to content

iA Writer

iA Writer 是一款适用于 macOS、iPadOS 和 iOS 的专注写作应用。Protocol Launcher 允许您生成 iA Writer URL Commands,使用 ia-writer:// URL scheme,并支持 x-callback-url。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

打开文档

如果找到现有文档则在编辑器中打开,否则打开新的空文档。

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

const url = open({
  path: '/Drafts/Notes.txt',
})

新建文件

在编辑器中打开一个新文档。

On-Demand
ts
import { newFile } from 'protocol-launcher/ia-writer'

const url = newFile({
  path: '/Drafts/Meeting Notes.txt',
  text: '# Meeting Notes\n\n',
  author: 'AI',
})

快速搜索

使用给定查询打开 Quick Search。

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

const url = quickSearch({
  query: 'meeting notes',
})

读取文件

读取并返回文件内容。iA Writer 的数据命令需要 auth-token,并会在 x-success 上返回 pathtext 参数。

On-Demand
ts
import { read } from 'protocol-launcher/ia-writer'

const url = read({
  authToken: 'REPLACE_WITH_YOUR_TOKEN',
  path: '/Drafts/Notes.txt',
  xSuccess: 'myapp://callback',
})

写入文件

创建或修改现有文件,并返回文件内容。iA Writer 的数据命令需要 auth-token,并会在 x-success 上返回 pathtext 参数。

On-Demand
ts
import { write } from 'protocol-launcher/ia-writer'

const url = write({
  authToken: 'REPLACE_WITH_YOUR_TOKEN',
  path: '/Drafts/Notes.txt',
  text: 'Hello world',
  mode: 'add',
  addLocation: 'end',
  addPadding: 'paragraph',
  author: 'AI',
  xSuccess: 'myapp://callback',
})

版本信息

返回 iA Writer 应用版本和 URL scheme 版本。iA Writer 会在 x-success 上返回 scheme-versionapp-version 参数。

On-Demand
ts
import { version } from 'protocol-launcher/ia-writer'

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

官方文档