kindy-editor 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CAPABILITIES.md +39 -0
- package/CHANGELOG.md +56 -0
- package/GUIDE.md +190 -0
- package/MIGRATION.md +46 -0
- package/README.md +198 -253
- package/README.zh-CN.md +41 -192
- package/dist/assets/docx.worker-9ZRUe-2j.js +243 -0
- package/dist/kindy-core.cjs +786 -0
- package/dist/kindy-core.js +738 -0
- package/dist/kindy-editor.cjs +421 -76
- package/dist/kindy-editor.css +1 -1
- package/dist/kindy-editor.d.ts +165 -169
- package/dist/kindy-editor.js +55210 -30323
- package/dist/types/core/adapters/legacy.d.ts +9 -0
- package/dist/types/core/adapters/memory.d.ts +87 -0
- package/dist/types/core/adapters/rest.d.ts +27 -0
- package/dist/types/core/client.d.ts +47 -0
- package/dist/types/core/collaboration.d.ts +30 -0
- package/dist/types/core/editor-state.d.ts +47 -0
- package/dist/types/core/emitter.d.ts +19 -0
- package/dist/types/core/errors.d.ts +13 -0
- package/dist/types/core/index.d.ts +10 -0
- package/dist/types/core/state.d.ts +9 -0
- package/dist/types/core/types.d.ts +235 -0
- package/docs/README.md +15 -0
- package/docs/api-reference.md +510 -0
- package/docs/completion-roadmap.md +62 -0
- package/docs/getting-started.md +180 -0
- package/docs/performance.md +149 -0
- package/docs/plugin-development.md +100 -0
- package/docs/ui-engine.md +242 -0
- package/openapi/document-api.yaml +267 -0
- package/package.json +59 -9
- package/dist/kindy-editor.iife.js +0 -148
package/CAPABILITIES.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Kindy DOCX Compatibility Matrix
|
|
2
|
+
|
|
3
|
+
Chỉ đánh dấu “Supported” khi có automated fixture/test tương ứng. “Preview” là khả năng editor/browser, không phải Word layout engine.
|
|
4
|
+
|
|
5
|
+
| Capability | v2.0 | Ghi chú |
|
|
6
|
+
|---|---:|---|
|
|
7
|
+
| Unicode/tiếng Việt | Supported | OOXML text round-trip test |
|
|
8
|
+
| Bold/italic/underline/strike | Supported | Semantic marks |
|
|
9
|
+
| Font, size, color | Supported | Basic `textStyle` mapping |
|
|
10
|
+
| Paragraph alignment, line spacing, indent | Supported | Profile cơ bản |
|
|
11
|
+
| Heading 1–6 | Supported | Word heading styles |
|
|
12
|
+
| Bullet/number list | Supported | Numbering profile cơ bản |
|
|
13
|
+
| Table, colspan, rowspan | Supported | `gridSpan` và vertical merge `vMerge` có round-trip test |
|
|
14
|
+
| Inline/block image | Supported | DrawingML, VML và `mc:AlternateContent`; ưu tiên fallback browser-safe; ảnh import có `AssetReference` |
|
|
15
|
+
| Hyperlink | Supported | External hyperlink |
|
|
16
|
+
| Global page size/orientation/margins | Supported | Đơn vị canonical là cm |
|
|
17
|
+
| Manual page break | Supported | Import tách thành semantic block `pageBreak`; editor chừa đúng phần trắng còn lại của trang |
|
|
18
|
+
| Automatic page preview | Preview | Chừa phần còn lại của trang và page gap giữa các top-level block; status bar hiển thị/điều hướng `Trang hiện tại / tổng trang` |
|
|
19
|
+
| OOXML validation/report | Supported | ZIP/content types/feature detection |
|
|
20
|
+
| Browser print | Supported | Chromium visual regression cần chạy trong CI ứng dụng |
|
|
21
|
+
| PDF Blob deterministic | Not supported | Dùng print/Save as PDF |
|
|
22
|
+
| Multiple sections | Supported v2.1 | Stable `sectionBreak`, per-section size/orientation/margin/page-number metadata; pagination và print đổi geometry theo section. Editing canvas vẫn là một ProseMirror surface, không phải Word layout engine |
|
|
23
|
+
| Header/footer sub-document | Supported v2.1 codec | Default/first/even, ảnh header và relationship parts có golden test; banner header được giữ tỷ lệ và lặp trong page preview |
|
|
24
|
+
| Page-number variants | Supported v2.1 codec | Page-number start, different-first và odd/even header/footer trong profile |
|
|
25
|
+
| Comments DOCX round-trip | Supported v2.2 | Range, thread, reply và resolved state qua comments/commentsExtended parts |
|
|
26
|
+
| Track Changes DOCX round-trip | Supported v2.2 | `w:ins`/`w:del`, author/timestamp, insert/delete/replace transaction, accept/reject, undo/redo và table text có test |
|
|
27
|
+
| Yjs realtime | Adapter available | Ứng dụng chủ cung cấp provider/server |
|
|
28
|
+
| Floating image | Best effort | Chuyển thành inline image và báo `FLOATING_IMAGE_FLATTENED` |
|
|
29
|
+
| EMF/WMF/TIFF, SmartArt, macros, equations | Not supported | Báo compatibility warning/best-effort |
|
|
30
|
+
|
|
31
|
+
Automatic pagination là browser preview và có thể khác Word do font metrics, printer driver và Word layout rules. v2.0 không chèn page gap vào giữa một top-level node quá cao (ví dụ một bảng cao hơn một trang); node đó được hiển thị liên tục để không phá cấu trúc/selection. Print CSS cho phép browser ngắt theo hàng, nhưng vị trí có thể khác Word.
|
|
32
|
+
|
|
33
|
+
Các profile v2.1/v2.2 là opt-in qua `profile` của codec hoặc `docxProfile` của workspace; mặc định vẫn là v2.0. Import có thể nhúng `PNG`, `JPEG`, `GIF`, `SVG`, `WebP`, `BMP` vào state. Serializer strict ghi trực tiếp `PNG`, `JPEG`, `GIF`, `BMP`; `SVG`, `WebP`, `EMF`, `WMF`, `TIFF` hoặc URL không xác định được liệt kê trong `CompatibilityReport` và cần chuyển đổi trước khi export.
|
|
34
|
+
|
|
35
|
+
File vừa import, chưa chỉnh sửa có một đường tải riêng qua `DocumentRecord.originalSource`; SDK trả lại artifact `original-docx` nên giữ nguyên byte và mọi feature Word chưa hiểu. Sau revision chỉnh sửa đầu tiên, tài liệu được serialize từ JSON và bảng capability phía trên là giới hạn cam kết—không có bảo đảm 100% với toàn bộ OOXML.
|
|
36
|
+
|
|
37
|
+
## Giới hạn hiệu năng v2.0
|
|
38
|
+
|
|
39
|
+
Import parser chạy trong Web Worker, nhưng editing surface vẫn render document trong một ProseMirror instance liên tục. Compatibility “Supported” không đồng nghĩa mọi file 100–200 trang đều đạt cùng typing latency. Hệ thống tích hợp phải benchmark corpus thật theo [`docs/performance.md`](./docs/performance.md) trước khi đặt SLA.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
Breaking release chuyển Kindy Editor thành DOCX Document Library SDK.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `KindyDocumentState` v2 làm canonical editing state.
|
|
10
|
+
- `DocumentLibraryClient` và `DocumentApiAdapter` contract.
|
|
11
|
+
- REST, Memory và legacy callback adapters.
|
|
12
|
+
- `KindyDocumentLibrary`, `KindyDocumentExplorer`, `KindyVersionPanel`.
|
|
13
|
+
- Responsive `KindyDocumentLibraryShell`, theme tokens và locale message contract.
|
|
14
|
+
- Autosave có debounce/cancellation và optimistic concurrency.
|
|
15
|
+
- Version preview read-only, restore và workspace status UI.
|
|
16
|
+
- DOCX import Worker, compatibility report và OOXML export thật.
|
|
17
|
+
- Browser print/Save as PDF flow.
|
|
18
|
+
- OpenAPI contract và REST mock transport.
|
|
19
|
+
- Tiptap engine adapter và Yjs collaboration adapter boundary.
|
|
20
|
+
- Compatibility profiles v2.1 cho section/header/footer/page numbering và v2.2 cho comments/Track Changes.
|
|
21
|
+
- Section-aware pagination/print, header/footer variants và Yjs workspace lifecycle.
|
|
22
|
+
- Corpus benchmark text/mixed 100–200 trang và measurement cache theo block.
|
|
23
|
+
- Playwright E2E production cho import/edit/autosave/version/restore/export/print và benchmark 100 trang.
|
|
24
|
+
- LibreOffice headless golden gate xác nhận DOCX v2.2 mở/convert PDF không yêu cầu repair.
|
|
25
|
+
- Packed-consumer smoke test cho ESM core, Vue UI, stylesheet và relative DOCX Worker URL.
|
|
26
|
+
- Reproducible npm lockfile và CI dùng `npm ci` trên cả unit, LibreOffice và browser E2E jobs.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Vue 3/Tiptap vẫn là UI/editor engine mặc định.
|
|
31
|
+
- HTML không còn là state lưu trữ dài hạn.
|
|
32
|
+
- PDF API là `preparePrint()`/`print()`, không phải deterministic PDF Blob.
|
|
33
|
+
- DOCX fidelity được định nghĩa theo Kindy Compatibility Profile.
|
|
34
|
+
- Track Changes ghi nhận insert/delete/replace transaction, kể cả lệnh xóa từ API/toolbar.
|
|
35
|
+
- State sync mặc định 300ms; demo autosave 5 giây để tránh chặn input trên tài liệu dài.
|
|
36
|
+
- Loại dependency runtime `@umoteam/editor-external` không sử dụng và thay SVG build plugin bằng sprite generator nội bộ.
|
|
37
|
+
- Dependency audit đầy đủ không còn advisory tại thời điểm chốt release candidate local.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- Print iframe trước đây có thể rỗng do gán sai Vue ref.
|
|
42
|
+
- Find/Replace, TOC, scroll page tracking và trạng thái before-unload dùng đúng Vue ref.
|
|
43
|
+
- Ảnh DOCX body/header, section break, page geometry và metadata numbering được round-trip theo profile.
|
|
44
|
+
- Bộ đếm ký tự cập nhật reactive; mở document không còn tạo dirty/autosave giả.
|
|
45
|
+
- `KindyEditor.getState()` giữ assets, sections và header/footer variants.
|
|
46
|
+
- ESM entry không còn import CSS ngầm; ứng dụng import `kindy-editor/style` đúng một lần như public guide. Node/SSR dùng subpath `kindy-editor/core`.
|
|
47
|
+
- DOCX Worker trong package resolve tương đối theo `import.meta.url`, không còn hard-code base path của demo `/kindy-editor/`.
|
|
48
|
+
|
|
49
|
+
### Removed from public promise
|
|
50
|
+
|
|
51
|
+
- Backend/storage/auth tích hợp sẵn.
|
|
52
|
+
- API v1 đầy đủ.
|
|
53
|
+
- HTML Blob giả đuôi `.docx`.
|
|
54
|
+
- AI/collaboration/IO placeholder chưa hoàn thiện trong public build.
|
|
55
|
+
|
|
56
|
+
Xem [Migration v1 → v2](./MIGRATION.md).
|
package/GUIDE.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Hướng dẫn tích hợp Document Library SDK v2
|
|
2
|
+
|
|
3
|
+
## 1. Ranh giới trách nhiệm
|
|
4
|
+
|
|
5
|
+
Kindy SDK chịu trách nhiệm:
|
|
6
|
+
|
|
7
|
+
- Hiển thị responsive `DocumentLibraryShell`, Explorer, Editor và VersionPanel.
|
|
8
|
+
- Chuẩn hóa trạng thái UI `idle/dirty/saving/saved/read-only/preview/conflict/error`.
|
|
9
|
+
- Chuyển DOCX thuộc compatibility profile sang ProseMirror JSON.
|
|
10
|
+
- Validate OOXML, báo feature ngoài profile và export OOXML DOCX thật.
|
|
11
|
+
- Debounce autosave, cancellation, event và optimistic concurrency.
|
|
12
|
+
- Chuẩn hóa API client, REST adapter và error codes.
|
|
13
|
+
|
|
14
|
+
Server ứng dụng chủ chịu trách nhiệm:
|
|
15
|
+
|
|
16
|
+
- User, authentication, authorization và tenant isolation.
|
|
17
|
+
- Database metadata, object storage, retention, backup và audit log.
|
|
18
|
+
- Sinh revision/version bền vững, chống ghi đè đồng thời.
|
|
19
|
+
- Malware scanning, quota, rate limiting và signed URL nếu sử dụng.
|
|
20
|
+
- Yjs provider/WebSocket server nếu bật realtime.
|
|
21
|
+
|
|
22
|
+
## 1.1. UI engine và lifecycle
|
|
23
|
+
|
|
24
|
+
`KindyDocumentLibrary` là orchestration component; `KindyDocumentLibraryShell` chỉ làm layout. Luồng mở tài liệu chuẩn:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
Explorer open event
|
|
28
|
+
→ client.open(documentId)
|
|
29
|
+
→ adapter.loadState
|
|
30
|
+
→ migrate KindyDocumentState
|
|
31
|
+
→ mount KindyEditor
|
|
32
|
+
→ apply capabilities.edit
|
|
33
|
+
→ ready/opened events
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Không để Explorer, toolbar tùy biến hoặc application component ghi thẳng storage. Mọi save/version/artifact phải đi qua workspace handle, `DocumentLibraryClient` hoặc adapter để giữ `baseRevisionId` và event semantics.
|
|
37
|
+
|
|
38
|
+
Khi preview một version cũ, workspace chỉ load snapshot read-only và giữ live snapshot riêng. Chỉ `restoreVersion` mới thay state hiện hành ở backend. Chi tiết UI, slots và theme nằm tại [`docs/ui-engine.md`](./docs/ui-engine.md).
|
|
39
|
+
|
|
40
|
+
Workspace mặc định dùng preset `Contract`: page-only, toolbar compact và loại toàn bộ công cụ web/diagram/chuyển đổi tiếng Trung. Không cần truyền cấu hình để có giao diện này. Chỉ dùng `editorOptions` khi ứng dụng chủ chủ động mở rộng UI; xem [`docs/ui-engine.md`](./docs/ui-engine.md#preset-contract-mặc-định).
|
|
41
|
+
|
|
42
|
+
## 2. Dữ liệu lưu trên server
|
|
43
|
+
|
|
44
|
+
Một triển khai tối thiểu thường có:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
documents
|
|
48
|
+
id, title, file_name, folder_id, tags, metadata
|
|
49
|
+
current_revision_id, current_version_id, created_at, updated_at
|
|
50
|
+
|
|
51
|
+
document_revisions
|
|
52
|
+
id, document_id, base_revision_id, state_json, reason
|
|
53
|
+
client_mutation_id (unique per document), created_at, created_by
|
|
54
|
+
|
|
55
|
+
document_versions
|
|
56
|
+
id, document_id, revision_id, number, label, created_at, created_by
|
|
57
|
+
|
|
58
|
+
document_artifacts
|
|
59
|
+
id, document_id, version_id, format, object_key
|
|
60
|
+
file_name, mime_type, size, checksum, created_at
|
|
61
|
+
|
|
62
|
+
folders
|
|
63
|
+
id, parent_id, name
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`state_json` là `KindyDocumentState`. Không dùng HTML làm state lâu dài. Artifact `original-docx` phải giữ nguyên bytes người dùng upload; artifact `docx` là output của serializer. Record import phải liên kết artifact gốc với revision đầu tiên:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"originalSource": {
|
|
71
|
+
"artifactId": "artifact-original-1",
|
|
72
|
+
"revisionId": "rev-import-1",
|
|
73
|
+
"format": "original-docx",
|
|
74
|
+
"fileName": "hop-dong.docx"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 3. Save và conflict
|
|
80
|
+
|
|
81
|
+
`PUT /documents/{id}/state` nhận:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"state": { "schemaVersion": "2.0", "content": {}, "page": {}, "assets": [] },
|
|
86
|
+
"baseRevisionId": "rev-10",
|
|
87
|
+
"reason": "autosave",
|
|
88
|
+
"clientMutationId": "70f8..."
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Transaction phía server:
|
|
93
|
+
|
|
94
|
+
1. Lock hoặc compare-and-swap document.
|
|
95
|
+
2. Nếu `current_revision_id !== baseRevisionId`, trả HTTP 409 với code `VERSION_CONFLICT`.
|
|
96
|
+
3. Nếu `clientMutationId` đã xử lý, trả lại kết quả cũ (idempotency).
|
|
97
|
+
4. Ghi revision mới và cập nhật `current_revision_id` atomically.
|
|
98
|
+
5. Với manual save, có thể tạo version bền vững và trả trong `version`.
|
|
99
|
+
|
|
100
|
+
SDK dừng autosave sau conflict. Ứng dụng chủ phải cho người dùng reload hoặc tạo document copy; không nên tự merge âm thầm.
|
|
101
|
+
|
|
102
|
+
## 4. Import DOCX
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
File input
|
|
106
|
+
→ Worker validate ZIP/OOXML
|
|
107
|
+
→ compatibility report
|
|
108
|
+
→ semantic conversion
|
|
109
|
+
→ người dùng xác nhận warning
|
|
110
|
+
→ POST /documents/import (original file + JSON + report)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Response của `/documents/import` phải có `originalSource`. Nếu người dùng tải xuống khi current revision vẫn bằng `originalSource.revisionId`, workspace dùng artifact gốc nên kết quả byte-for-byte giống file upload. Sau khi state đã được save thành revision mới, workspace dùng serializer và áp dụng compatibility profile; không được quảng bá đây là Word-fidelity 100%.
|
|
114
|
+
|
|
115
|
+
Các guard server vẫn bắt buộc dù client đã validate:
|
|
116
|
+
|
|
117
|
+
- Extension, MIME, magic bytes và OOXML content types.
|
|
118
|
+
- Giới hạn compressed size, uncompressed size, số ZIP entry và compression ratio.
|
|
119
|
+
- Từ chối encrypted/password-protected package.
|
|
120
|
+
- Virus/malware scanning.
|
|
121
|
+
- Không tin file name hoặc URL do client gửi.
|
|
122
|
+
|
|
123
|
+
## 5. Export DOCX và print/PDF
|
|
124
|
+
|
|
125
|
+
`exportDocx(state)` mặc định strict. Khi có node ngoài profile, hàm ném `DOCX_UNSUPPORTED`. UI có thể hiển thị report rồi gọi lại `{ mode: 'best-effort' }` sau khi người dùng xác nhận.
|
|
126
|
+
|
|
127
|
+
Profile mặc định là `kindy-docx-v2.0`. Dùng `{ profile: 'kindy-docx-v2.1' }`
|
|
128
|
+
cho sections/header/footer và `kindy-docx-v2.2` cho comments/Track Changes.
|
|
129
|
+
Workspace nhận prop `docxProfile` tương ứng; không tự nâng profile âm thầm.
|
|
130
|
+
|
|
131
|
+
DOCX output là ZIP/OOXML từ package `docx`; test phải kiểm tra `word/document.xml` và mở qua LibreOffice/Word mà không repair.
|
|
132
|
+
|
|
133
|
+
Ảnh import hỗ trợ DrawingML, VML và `mc:AlternateContent` có fallback render được. Browser có thể hiển thị PNG/JPEG/GIF/SVG/WebP/BMP, nhưng serializer DOCX strict chỉ ghi trực tiếp PNG/JPEG/GIF/BMP. SVG/WebP, EMF/WMF/TIFF và nguồn ảnh không xác định phải sinh compatibility warning hoặc được hệ thống chủ chuyển đổi trước khi export.
|
|
134
|
+
|
|
135
|
+
PDF v2.0:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
await workspace.preparePrint()
|
|
139
|
+
workspace.print()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Nếu hệ thống cần PDF Blob deterministic hoặc render server-side, đó là service của ứng dụng chủ và nằm ngoài runtime browser của SDK.
|
|
143
|
+
|
|
144
|
+
## 6. Auth và transport
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const adapter = createRestDocumentAdapter({
|
|
148
|
+
baseUrl: '/document-api',
|
|
149
|
+
transport: async (url, init) => fetch(url, {
|
|
150
|
+
...init,
|
|
151
|
+
credentials: 'include',
|
|
152
|
+
headers: {
|
|
153
|
+
...init?.headers,
|
|
154
|
+
Authorization: `Bearer ${await getAccessToken()}`,
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Không đưa access token vào Kindy state, asset metadata, localStorage hoặc log. Backend phải kiểm tra quyền trên từng document/artifact/version; quyền UI chỉ giúp ẩn thao tác, không phải security boundary.
|
|
161
|
+
|
|
162
|
+
## 7. Audit
|
|
163
|
+
|
|
164
|
+
Audit phía server tối thiểu gồm: actor, tenant, document, action, revision/version, timestamp, result, IP/request ID và client mutation ID. Không log toàn bộ nội dung hợp đồng hay token. Các action quan trọng: import, view, save, export, artifact download, restore, permission denied và conflict.
|
|
165
|
+
|
|
166
|
+
## 8. Realtime
|
|
167
|
+
|
|
168
|
+
`YjsCollaborationAdapter` chỉ nhận `providerFactory`:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const collaboration = createYjsCollaborationAdapter({
|
|
172
|
+
providerFactory: ({ documentId, user, editor }) => createCompanyYjsProvider({ documentId, user, editor }),
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
SDK không tạo WebSocket URL và không ship server. Provider phải xử lý auth, reconnect, awareness và document isolation.
|
|
177
|
+
|
|
178
|
+
## 9. Contract test
|
|
179
|
+
|
|
180
|
+
Chạy cùng một test suite với Memory adapter, REST mock và adapter thật. Tối thiểu kiểm tra create → load → save → conflict → versions → restore → artifact. OpenAPI không quy định auth bắt buộc để không khóa kiến trúc của hệ thống tích hợp.
|
|
181
|
+
|
|
182
|
+
## 10. Production checklist
|
|
183
|
+
|
|
184
|
+
- Chạy `npm run typecheck`, `npm test` và `npm run build` với đúng package lock.
|
|
185
|
+
- Validate OpenAPI implementation bằng contract test.
|
|
186
|
+
- Kiểm tra permission ở backend, không chỉ dựa vào `document.capabilities` trên UI.
|
|
187
|
+
- Test import/export bằng golden DOCX corpus và Microsoft Word/LibreOffice.
|
|
188
|
+
- Test responsive layout và keyboard navigation sau khi override theme.
|
|
189
|
+
- Benchmark corpus 100 trang của hệ thống theo [`docs/performance.md`](./docs/performance.md).
|
|
190
|
+
- Thiết lập backup/restore object storage và database; SDK không thực hiện backup.
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Migration v1 → v2
|
|
2
|
+
|
|
3
|
+
v2 là breaking release.
|
|
4
|
+
|
|
5
|
+
## State
|
|
6
|
+
|
|
7
|
+
V1 thường lưu HTML hoặc raw ProseMirror JSON. V2 lưu:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const state = migrateDocumentState(rawProseMirrorJson)
|
|
11
|
+
// { schemaVersion: '2.0', content, page, assets }
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
SDK tự migrate lúc mở; server chỉ ghi state mới sau lần save kế tiếp.
|
|
15
|
+
|
|
16
|
+
## Save callback
|
|
17
|
+
|
|
18
|
+
Khuyến nghị thay `onSave`/`onFileUpload` bằng `DocumentApiAdapter`. Giai đoạn chuyển tiếp:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const adapter = createLegacyCallbackAdapter({
|
|
22
|
+
async onSave({ state }) {
|
|
23
|
+
await oldSaveEndpoint(state)
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Legacy adapter phục vụ migration, không mô phỏng đầy đủ backend/versioning v1.
|
|
29
|
+
|
|
30
|
+
## DOCX
|
|
31
|
+
|
|
32
|
+
V1 Word toolbar tạo HTML Blob mang đuôi `.docx`. V2 tạo ZIP/OOXML thật bằng `exportDocx`. Import state không còn lấy HTML layout từ `docx-preview`; `docx-preview` không phải canonical converter.
|
|
33
|
+
|
|
34
|
+
## PDF
|
|
35
|
+
|
|
36
|
+
Xóa mọi code kỳ vọng `exportPdf()` trả Blob. Dùng `preparePrint()` và `print()`.
|
|
37
|
+
|
|
38
|
+
## Mount helper
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const { app, instance, unmount } = mountKindyEditor(element, options)
|
|
42
|
+
instance.getState()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
V2 trả thêm `instance` là editor handle.
|
|
46
|
+
|