Bỏ qua để đến nội dung

SDK Tiện ích mở rộng

Các tiện ích mở rộng drawtonomy là các ứng dụng web được lưu trữ trong iframe giao tiếp với trình chỉnh sửa thông qua postMessage. SDK cho bạn một client được kiểu hóa; dev-server cho bạn một trình chỉnh sửa cục bộ để phát triển dựa trên đó.

Trang này là một định hướng nhanh. Hướng dẫn đầy đủ — schema manifest, danh sách capabilities, giao thức message — nằm trong repo công khai:

Hướng dẫn Phát triển Tiện ích mở rộng (日本語)

Terminal window
# Editor on :3000
pnpm add -g @drawtonomy/dev-server
drawtonomy-dev-server
# Your extension on :3001
cd my-extension && pnpm dev --port 3001
open "http://localhost:3000/?ext=http://localhost:3001/manifest.json"
my-extension/
manifest.json
index.html
src/
manifest.json
{
"id": "my-extension",
"name": "My Extension",
"version": "1.0.0",
"entry": "./index.html",
"capabilities": ["shapes:read", "shapes:write", "ui:panel"]
}
src/main.ts
import { ExtensionClient, createVehicle } from '@drawtonomy/sdk'
const client = new ExtensionClient()
await client.ready()
document.getElementById('add')!.addEventListener('click', async () => {
await client.addShapes([createVehicle(0, 0, { templateId: 'sedan' })])
})

Các tiện ích mở rộng trong-cây là các ví dụ đầy đủ độ trung thực: