Skip to content

Textastic

Textastic 是一款适用于 iOS、iPadOS 和 macOS 的强大文本编辑器,支持超过 80 种编程和标记语言的语法高亮。Protocol Launcher 允许您生成深度链接以在 Textastic 中打开、创建和编辑文件。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

打开应用

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

const url = open()

打开文件

On-Demand
ts
import { openFile } from 'protocol-launcher/textastic'

const url = openFile({
  path: 'example.com',
  name: 'index.html',
})

新建文件

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

const url = newFile({
  name: 'foo.txt',
  text: 'bar',
})

追加文本

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

const url = append({
  location: 'iCloud',
  name: 'clipboard.txt',
})

替换文本

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

const url = replace({
  location: 'iCloud',
  name: 'scratchpad.txt',
  text: 'foo',
})

重新加载自定义

On-Demand
ts
import { reloadCustomizations } from 'protocol-launcher/textastic'

const url = reloadCustomizations()