@coco-vexel/coco-office-editor 1.0.1 → 1.0.2

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.
Files changed (51) hide show
  1. package/README.md +33 -1
  2. package/dist/index.cjs +352 -99
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +5 -4
  5. package/dist/index.d.ts +5 -4
  6. package/dist/index.js +353 -101
  7. package/dist/index.js.map +1 -1
  8. package/dist/{model-DB6aN6uJ.d.cts → model-DNNBhhCB.d.cts} +4 -3
  9. package/dist/{model-DB6aN6uJ.d.ts → model-DNNBhhCB.d.ts} +4 -3
  10. package/dist/{native-B6B649CC.d.ts → native-OrEUvS8p.d.ts} +5 -1
  11. package/dist/native-TMv552dv.d.cts +317 -0
  12. package/dist/native-TMv552dv.d.ts +317 -0
  13. package/dist/{native-Ct9nN06K.d.cts → native-f2y3N8N5.d.cts} +5 -1
  14. package/dist/ppt-native.cjs +129 -59
  15. package/dist/ppt-native.cjs.map +1 -1
  16. package/dist/ppt-native.d.cts +1 -1
  17. package/dist/ppt-native.d.ts +1 -1
  18. package/dist/ppt-native.js +130 -60
  19. package/dist/ppt-native.js.map +1 -1
  20. package/dist/ppt.cjs +129 -58
  21. package/dist/ppt.cjs.map +1 -1
  22. package/dist/ppt.d.cts +3 -306
  23. package/dist/ppt.d.ts +3 -306
  24. package/dist/ppt.js +130 -60
  25. package/dist/ppt.js.map +1 -1
  26. package/dist/read-only-1_LQCO1d.d.cts +7 -0
  27. package/dist/read-only-1_LQCO1d.d.ts +7 -0
  28. package/dist/spreadsheet.cjs +114 -17
  29. package/dist/spreadsheet.cjs.map +1 -1
  30. package/dist/spreadsheet.d.cts +15 -3
  31. package/dist/spreadsheet.d.ts +15 -3
  32. package/dist/spreadsheet.js +114 -18
  33. package/dist/spreadsheet.js.map +1 -1
  34. package/dist/word-editing.d.cts +1 -1
  35. package/dist/word-editing.d.ts +1 -1
  36. package/dist/word-native.cjs +132 -23
  37. package/dist/word-native.cjs.map +1 -1
  38. package/dist/word-native.d.cts +2 -2
  39. package/dist/word-native.d.ts +2 -2
  40. package/dist/word-native.js +132 -23
  41. package/dist/word-native.js.map +1 -1
  42. package/dist/word-prosemirror.d.cts +1 -1
  43. package/dist/word-prosemirror.d.ts +1 -1
  44. package/dist/word.cjs +145 -23
  45. package/dist/word.cjs.map +1 -1
  46. package/dist/word.d.cts +5 -4
  47. package/dist/word.d.ts +5 -4
  48. package/dist/word.js +145 -24
  49. package/dist/word.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/styles/editor.css +1 -0
package/README.md CHANGED
@@ -38,7 +38,10 @@ Create `index.html`:
38
38
  Create `main.js`, then run `npx vite` and open the printed HTTP URL:
39
39
 
40
40
  ```js
41
- import { buildPptEditorViewFromPptx, renderNativePptEditor } from '@coco-vexel/coco-office-editor/ppt';
41
+ import {
42
+ buildPptEditorViewFromPptx,
43
+ renderNativePptEditor,
44
+ } from '@coco-vexel/coco-office-editor/ppt';
42
45
 
43
46
  const input = document.querySelector('#file');
44
47
  const save = document.querySelector('#save');
@@ -102,6 +105,33 @@ This is an unstyled integration shell; the native PPT renderer supplies its edit
102
105
 
103
106
  All import paths above start with `@coco-vexel/coco-office-editor`. If your app directly imports Core (for example to apply Word changes), declare it explicitly with `npm install @coco-vexel/coco-office`. Examples below named `host`, `xlsxBytes` or `persistWorkbook` are integration fragments: supply your own mount, file bytes and persistence callback.
104
107
 
108
+ ### Read-only preview
109
+
110
+ All three native editors accept `readOnly: true` at mount time and expose
111
+ `isReadOnly()` / `setReadOnly(readOnly)`. Read-only mode is enforced by the
112
+ Word runtime, spreadsheet runtime, and PPT session as well as their DOM event
113
+ handlers. Programmatic spreadsheet and PPT mutations reject with
114
+ `EditorReadOnlyError` (`code: 'EDITOR_READ_ONLY'`); Word's synchronous command
115
+ contract reports the same condition through `canDispatch() === false` and
116
+ `dispatch() === false`.
117
+
118
+ Read-only preview intentionally keeps scrolling, zoom owned by the host,
119
+ selection/copy, links, worksheet switching, and slide navigation available.
120
+ It blocks typing, IME, cut/paste/drop, formatting, structure changes,
121
+ drag/resize, undo/redo, and mutation APIs. Navigation and selection do not emit
122
+ change events or advance revisions. Spreadsheet sort/filter/freeze operations
123
+ remain blocked because they currently modify the workbook rather than a
124
+ separate view state.
125
+
126
+ PPT hosts that render their own navigator can also pass `showSlideList: false`:
127
+
128
+ ```ts
129
+ const preview = renderNativePptEditor(host, view, {
130
+ readOnly: true,
131
+ showSlideList: false,
132
+ });
133
+ ```
134
+
105
135
  Word custom Shadow DOM integration needs stylesheet text via `styleText`; Vite supports `@coco-vexel/coco-office-editor/styles.css?inline`. Other bundlers must provide an equivalent CSS-string loader. The `?inline` suffix is a Vite feature, not a portable JavaScript import. Spreadsheet's default isolated renderer and the default PPT renderer manage their surfaces. Use a mount with an explicit nonzero height.
106
136
 
107
137
  The complete three-format file/open/edit/export flow, including Word export diagnostics, is in the [public demo source](https://github.com/coco-vexel/coco-office/blob/main/packages/editor/demo/main.js). No private product dependency is needed. These editors are experimental; file round-trip success does not certify visual parity or support for every advanced object.
@@ -159,6 +189,7 @@ import '@coco-vexel/coco-office-editor/styles.css';
159
189
 
160
190
  const documentView = await buildWordEditorViewFromDocx(docxBytes);
161
191
  const editor = renderNativeWordEditor(host, documentView, {
192
+ readOnly: false,
162
193
  contextMenu: true,
163
194
  // Pass the bundled editor CSS text when the host uses Shadow DOM isolation.
164
195
  // Vite hosts can load it with: import editorStyles from '../styles/editor.css?inline';
@@ -297,6 +328,7 @@ import { renderSpreadsheetEditor } from '@coco-vexel/coco-office-editor/spreadsh
297
328
 
298
329
  const editor = await renderSpreadsheetEditor(host, xlsxBytes, {
299
330
  workbookId: 'browser-document.xlsx',
331
+ readOnly: false,
300
332
  showSheetTabs: true,
301
333
  // Shadow DOM isolation is enabled by default; use 'none' only for legacy hosts.
302
334
  styleIsolation: 'shadow',