Skip to content

1Writer

1Writer 是一款强大的 iOS Markdown 文本编辑器,支持 Dropbox、Google Drive 和 iCloud。Protocol Launcher 允许您生成深度链接,使用 onewriter:// URL scheme 和 x-callback-url 协议在 1Writer 中创建、编辑和管理文档。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

创建文档

创建新文档。

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

const url = create({
  path: 'Dropbox/Documents',
  name: 'Notes.txt',
  text: 'Hello world',
})

替换文档

替换文档内容。

On-Demand
ts
import { replace } from 'protocol-launcher/1writer'

const url = replace({
  path: 'Dropbox/Documents/Notes.txt',
  text: 'Hello world',
})

替换选中内容

替换当前编辑文档中的选中文本。

On-Demand
ts
import { replaceSelection } from 'protocol-launcher/1writer'

const url = replaceSelection({
  text: 'New text',
})

获取内容

获取文档内容。

On-Demand
ts
import { content } from 'protocol-launcher/1writer'

const url = content({
  path: 'Dropbox/Documents/Notes.txt',
})

打开文档

打开现有文档。

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

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

追加内容

向现有文档追加内容。

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

const url = append({
  path: 'Dropbox/Documents/Notes.txt',
  text: 'Hello world',
})

前置内容

向现有文档开头添加内容。

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

const url = prepend({
  path: 'Dropbox/Documents/Notes.txt',
  text: 'Hello world',
})