Skip to content

Craft

Craft 是一个强大、美观的工具,用于创建文档、管理任务和组织您的工作和生活。Protocol Launcher 允许您生成深度链接以在 Craft 中打开和创建内容。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

打开应用

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

const url = open()

打开文档

On-Demand
ts
import { openDocument } from 'protocol-launcher/craft'

const url = openDocument({
  spaceId: 'abc-123',
  blockId: 'xyz-789',
})

创建文档

On-Demand
ts
import { createDocument } from 'protocol-launcher/craft'

const url = createDocument({
  spaceId: 'abc-123',
  title: 'My Note',
  content: 'Hello **World**',
  folderId: '',
})

创建新文档

On-Demand
ts
import { createNewDocument } from 'protocol-launcher/craft'

const url = createNewDocument()

创建块

On-Demand
ts
import { createBlock } from 'protocol-launcher/craft'

const url = createBlock({
  parentBlockId: 'doc-123',
  spaceId: 'abc-123',
  content: 'New content',
  index: 9999,
})

打开每日笔记

On-Demand
ts
import { openDailyNote } from 'protocol-launcher/craft'

const url = openDailyNote({
  spaceId: 'abc-123',
  type: 'today',
})

打开搜索

On-Demand
ts
import { openSearch } from 'protocol-launcher/craft'

const url = openSearch({
  spaceId: 'abc-123',
  query: 'vacation plans',
})

打开空间

On-Demand
ts
import { openSpace } from 'protocol-launcher/craft'

const url = openSpace({
  spaceId: 'abc-123',
  tab: 'calendar',
})