myrole-docx-editor 0.1.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/README.md +107 -0
- package/dist/chunks/sdk-BKkeAoJT.js +15065 -0
- package/dist/chunks/sdk-BKkeAoJT.js.map +1 -0
- package/dist/chunks/vars-blockly-C-cJRHx8.js +42 -0
- package/dist/chunks/vars-blockly-C-cJRHx8.js.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/react.js +36 -0
- package/dist/react.js.map +1 -0
- package/dist/types/packages/docx-editor/src/chrome.d.ts +28 -0
- package/dist/types/packages/docx-editor/src/commands.d.ts +16 -0
- package/dist/types/packages/docx-editor/src/comments.d.ts +24 -0
- package/dist/types/packages/docx-editor/src/editor.d.ts +293 -0
- package/dist/types/packages/docx-editor/src/embed.d.ts +7 -0
- package/dist/types/packages/docx-editor/src/font-manifest.d.ts +7 -0
- package/dist/types/packages/docx-editor/src/fonts.d.ts +5 -0
- package/dist/types/packages/docx-editor/src/html.d.ts +13 -0
- package/dist/types/packages/docx-editor/src/index.d.ts +20 -0
- package/dist/types/packages/docx-editor/src/inspector-ui.d.ts +6 -0
- package/dist/types/packages/docx-editor/src/inspector.d.ts +101 -0
- package/dist/types/packages/docx-editor/src/react.d.ts +24 -0
- package/dist/types/packages/docx-editor/src/ruler.d.ts +4 -0
- package/dist/types/packages/docx-editor/src/sdk.d.ts +85 -0
- package/dist/types/packages/docx-editor/src/ui/icons.d.ts +2 -0
- package/dist/types/packages/docx-editor/src/ui/shell.d.ts +57 -0
- package/dist/types/packages/docx-editor/src/variables.d.ts +68 -0
- package/dist/types/packages/docx-editor/src/vars-blockly.d.ts +9 -0
- package/dist/types/packages/docx-editor/src/vars-complete.d.ts +60 -0
- package/dist/types/packages/docx-editor/src/vars-library.d.ts +59 -0
- package/dist/types/packages/docx-editor/src/vars-panel.d.ts +38 -0
- package/dist/types/packages/docx-model/src/edit.d.ts +64 -0
- package/dist/types/packages/docx-model/src/editor.d.ts +254 -0
- package/dist/types/packages/docx-model/src/fonts.d.ts +60 -0
- package/dist/types/packages/docx-model/src/heal.d.ts +28 -0
- package/dist/types/packages/docx-model/src/index.d.ts +113 -0
- package/dist/types/packages/docx-model/src/insert.d.ts +30 -0
- package/dist/types/packages/docx-model/src/layout.d.ts +411 -0
- package/dist/types/packages/docx-model/src/numbering.d.ts +63 -0
- package/dist/types/packages/docx-model/src/paste.d.ts +51 -0
- package/dist/types/packages/docx-model/src/rels.d.ts +18 -0
- package/dist/types/packages/docx-model/src/spans.d.ts +69 -0
- package/dist/types/packages/docx-model/src/styles.d.ts +42 -0
- package/dist/types/packages/docx-model/src/tables.d.ts +196 -0
- package/dist/types/packages/docx-model/src/textbox.d.ts +61 -0
- package/dist/types/packages/docx-render/src/border.d.ts +39 -0
- package/dist/types/packages/docx-render/src/document.d.ts +55 -0
- package/dist/types/packages/docx-render/src/font-advances.d.ts +1 -0
- package/dist/types/packages/docx-render/src/hit.d.ts +94 -0
- package/dist/types/packages/docx-render/src/index.d.ts +12 -0
- package/dist/types/packages/docx-render/src/metrics.d.ts +6 -0
- package/dist/types/packages/docx-render/src/node-ctx.d.ts +36 -0
- package/dist/types/packages/docx-render/src/paragraph.d.ts +18 -0
- package/dist/types/packages/docx-render/src/parts.d.ts +40 -0
- package/dist/types/packages/docx-render/src/renderer.d.ts +251 -0
- package/dist/types/packages/docx-render/src/table.d.ts +15 -0
- package/dist/types/packages/docx-render/src/text.d.ts +396 -0
- package/dist/types/packages/docx-render/src/types.d.ts +514 -0
- package/dist/types/packages/docx-tags/src/add-comments.d.ts +2 -0
- package/dist/types/packages/docx-tags/src/comments.d.ts +19 -0
- package/dist/types/packages/docx-tags/src/grammar.d.ts +71 -0
- package/dist/types/packages/docx-tags/src/highlight.d.ts +22 -0
- package/dist/types/packages/docx-tags/src/index.d.ts +4 -0
- package/dist/types/packages/docx-tags/src/scan.d.ts +27 -0
- package/dist/types/packages/docx-vars/src/audit.d.ts +44 -0
- package/dist/types/packages/docx-vars/src/blockify.d.ts +61 -0
- package/dist/types/packages/docx-vars/src/blocks.d.ts +46 -0
- package/dist/types/packages/docx-vars/src/describe.d.ts +21 -0
- package/dist/types/packages/docx-vars/src/generate.d.ts +11 -0
- package/dist/types/packages/docx-vars/src/icons.d.ts +52 -0
- package/dist/types/packages/docx-vars/src/idioms.d.ts +36 -0
- package/dist/types/packages/docx-vars/src/index.d.ts +31 -0
- package/dist/types/packages/docx-vars/src/labels.d.ts +42 -0
- package/dist/types/packages/docx-vars/src/library.d.ts +47 -0
- package/dist/types/packages/docx-vars/src/phrase.d.ts +3 -0
- package/dist/types/packages/docx-vars/src/picker.d.ts +19 -0
- package/dist/types/packages/docx-vars/src/plugin.d.ts +126 -0
- package/dist/types/packages/docx-vars/src/plugins.d.ts +29 -0
- package/dist/types/packages/docx-vars/src/preview.d.ts +25 -0
- package/dist/types/packages/docx-vars/src/scenario.d.ts +20 -0
- package/dist/types/packages/docx-vars/src/substitute.d.ts +28 -0
- package/dist/types/packages/docx-vars/src/sync.d.ts +56 -0
- package/dist/types/packages/docx-vars/src/target-canvas.d.ts +66 -0
- package/dist/types/packages/docx-vars/src/tokens.d.ts +18 -0
- package/dist/types/packages/fonts/src/advances.d.ts +90 -0
- package/dist/types/packages/fonts/src/aliases.d.ts +27 -0
- package/dist/types/packages/fonts/src/families.d.ts +1 -0
- package/dist/types/packages/fonts/src/load.d.ts +25 -0
- package/dist/types/packages/fonts/src/metrics.d.ts +44 -0
- package/fonts/ttf/abadi-mt-condensed-extra-bold-400-normal.ttf +0 -0
- package/fonts/ttf/abadi-mt-condensed-light-400-normal.ttf +0 -0
- package/fonts/ttf/angsana-new-400-italic.ttf +0 -0
- package/fonts/ttf/angsana-new-400-normal.ttf +0 -0
- package/fonts/ttf/angsana-new-700-italic.ttf +0 -0
- package/fonts/ttf/angsana-new-700-normal.ttf +0 -0
- package/fonts/ttf/apple-color-emoji-400-normal.ttf +0 -0
- package/fonts/ttf/apple-symbols-400-normal.ttf +0 -0
- package/fonts/ttf/aptos-400-italic.ttf +0 -0
- package/fonts/ttf/aptos-400-normal.ttf +0 -0
- package/fonts/ttf/aptos-700-italic.ttf +0 -0
- package/fonts/ttf/aptos-700-normal.ttf +0 -0
- package/fonts/ttf/aptos-narrow-400-italic.ttf +0 -0
- package/fonts/ttf/aptos-narrow-400-normal.ttf +0 -0
- package/fonts/ttf/aptos-narrow-700-italic.ttf +0 -0
- package/fonts/ttf/aptos-narrow-700-normal.ttf +0 -0
- package/fonts/ttf/arial-400-italic.ttf +0 -0
- package/fonts/ttf/arial-400-normal.ttf +0 -0
- package/fonts/ttf/arial-700-italic.ttf +0 -0
- package/fonts/ttf/arial-700-normal.ttf +0 -0
- package/fonts/ttf/arial-black-700-normal.ttf +0 -0
- package/fonts/ttf/arial-hebrew-400-normal.ttf +0 -0
- package/fonts/ttf/arial-hebrew-700-normal.ttf +0 -0
- package/fonts/ttf/arial-narrow-400-italic.ttf +0 -0
- package/fonts/ttf/arial-narrow-400-normal.ttf +0 -0
- package/fonts/ttf/arial-narrow-700-italic.ttf +0 -0
- package/fonts/ttf/arial-narrow-700-normal.ttf +0 -0
- package/fonts/ttf/arial-rounded-mt-bold-400-normal.ttf +0 -0
- package/fonts/ttf/arial-unicode-ms-400-normal.ttf +0 -0
- package/fonts/ttf/avenir-400-italic.ttf +0 -0
- package/fonts/ttf/avenir-400-normal.ttf +0 -0
- package/fonts/ttf/avenir-700-normal.ttf +0 -0
- package/fonts/ttf/avenir-black-700-normal.ttf +0 -0
- package/fonts/ttf/avenir-book-400-normal.ttf +0 -0
- package/fonts/ttf/avenir-heavy-700-italic.ttf +0 -0
- package/fonts/ttf/avenir-heavy-700-normal.ttf +0 -0
- package/fonts/ttf/avenir-light-400-italic.ttf +0 -0
- package/fonts/ttf/avenir-light-400-normal.ttf +0 -0
- package/fonts/ttf/avenir-next-400-italic.ttf +0 -0
- package/fonts/ttf/avenir-next-400-normal.ttf +0 -0
- package/fonts/ttf/avenir-next-700-italic.ttf +0 -0
- package/fonts/ttf/avenir-next-700-normal.ttf +0 -0
- package/fonts/ttf/baskerville-old-face-400-normal.ttf +0 -0
- package/fonts/ttf/batang-400-normal.ttf +0 -0
- package/fonts/ttf/bauhaus-93-400-normal.ttf +0 -0
- package/fonts/ttf/big-caslon-400-normal.ttf +0 -0
- package/fonts/ttf/bookman-old-style-400-italic.ttf +0 -0
- package/fonts/ttf/bookman-old-style-400-normal.ttf +0 -0
- package/fonts/ttf/bookman-old-style-700-italic.ttf +0 -0
- package/fonts/ttf/bookman-old-style-700-normal.ttf +0 -0
- package/fonts/ttf/calibri-400-italic.ttf +0 -0
- package/fonts/ttf/calibri-400-normal.ttf +0 -0
- package/fonts/ttf/calibri-700-italic.ttf +0 -0
- package/fonts/ttf/calibri-700-normal.ttf +0 -0
- package/fonts/ttf/calibri-light-400-italic.ttf +0 -0
- package/fonts/ttf/calibri-light-400-normal.ttf +0 -0
- package/fonts/ttf/cambria-400-italic.ttf +0 -0
- package/fonts/ttf/cambria-400-normal.ttf +0 -0
- package/fonts/ttf/cambria-700-italic.ttf +0 -0
- package/fonts/ttf/cambria-700-normal.ttf +0 -0
- package/fonts/ttf/cambria-math-400-normal.ttf +0 -0
- package/fonts/ttf/candara-400-italic.ttf +0 -0
- package/fonts/ttf/candara-400-normal.ttf +0 -0
- package/fonts/ttf/candara-700-italic.ttf +0 -0
- package/fonts/ttf/candara-700-normal.ttf +0 -0
- package/fonts/ttf/century-400-normal.ttf +0 -0
- package/fonts/ttf/century-gothic-400-italic.ttf +0 -0
- package/fonts/ttf/century-gothic-400-normal.ttf +0 -0
- package/fonts/ttf/century-gothic-700-italic.ttf +0 -0
- package/fonts/ttf/century-gothic-700-normal.ttf +0 -0
- package/fonts/ttf/century-schoolbook-400-italic.ttf +0 -0
- package/fonts/ttf/century-schoolbook-400-normal.ttf +0 -0
- package/fonts/ttf/century-schoolbook-700-italic.ttf +0 -0
- package/fonts/ttf/century-schoolbook-700-normal.ttf +0 -0
- package/fonts/ttf/comic-sans-ms-400-normal.ttf +0 -0
- package/fonts/ttf/comic-sans-ms-700-normal.ttf +0 -0
- package/fonts/ttf/consolas-400-italic.ttf +0 -0
- package/fonts/ttf/consolas-400-normal.ttf +0 -0
- package/fonts/ttf/consolas-700-normal.ttf +0 -0
- package/fonts/ttf/corbel-400-italic.ttf +0 -0
- package/fonts/ttf/corbel-400-normal.ttf +0 -0
- package/fonts/ttf/corbel-700-italic.ttf +0 -0
- package/fonts/ttf/corbel-700-normal.ttf +0 -0
- package/fonts/ttf/cordia-new-400-italic.ttf +0 -0
- package/fonts/ttf/cordia-new-400-normal.ttf +0 -0
- package/fonts/ttf/cordia-new-700-italic.ttf +0 -0
- package/fonts/ttf/cordia-new-700-normal.ttf +0 -0
- package/fonts/ttf/courier-400-normal.ttf +0 -0
- package/fonts/ttf/courier-new-400-italic.ttf +0 -0
- package/fonts/ttf/courier-new-400-normal.ttf +0 -0
- package/fonts/ttf/courier-new-700-normal.ttf +0 -0
- package/fonts/ttf/dengxian-400-normal.ttf +0 -0
- package/fonts/ttf/dengxian-700-normal.ttf +0 -0
- package/fonts/ttf/dengxian-light-400-normal.ttf +0 -0
- package/fonts/ttf/didot-400-italic.ttf +0 -0
- package/fonts/ttf/didot-400-normal.ttf +0 -0
- package/fonts/ttf/didot-700-normal.ttf +0 -0
- package/fonts/ttf/edwardian-script-itc-400-normal.ttf +0 -0
- package/fonts/ttf/euphemia-ucas-400-italic.ttf +0 -0
- package/fonts/ttf/euphemia-ucas-400-normal.ttf +0 -0
- package/fonts/ttf/euphemia-ucas-700-normal.ttf +0 -0
- package/fonts/ttf/eurostile-400-normal.ttf +0 -0
- package/fonts/ttf/eurostile-700-normal.ttf +0 -0
- package/fonts/ttf/franklin-gothic-book-400-italic.ttf +0 -0
- package/fonts/ttf/franklin-gothic-book-400-normal.ttf +0 -0
- package/fonts/ttf/franklin-gothic-demi-400-italic.ttf +0 -0
- package/fonts/ttf/franklin-gothic-demi-400-normal.ttf +0 -0
- package/fonts/ttf/franklin-gothic-demi-cond-400-normal.ttf +0 -0
- package/fonts/ttf/franklin-gothic-medium-400-italic.ttf +0 -0
- package/fonts/ttf/franklin-gothic-medium-400-normal.ttf +0 -0
- package/fonts/ttf/franklin-gothic-medium-cond-400-normal.ttf +0 -0
- package/fonts/ttf/futura-400-italic.ttf +0 -0
- package/fonts/ttf/futura-400-normal.ttf +0 -0
- package/fonts/ttf/futura-700-normal.ttf +0 -0
- package/fonts/ttf/garamond-400-italic.ttf +0 -0
- package/fonts/ttf/garamond-400-normal.ttf +0 -0
- package/fonts/ttf/garamond-700-italic.ttf +0 -0
- package/fonts/ttf/garamond-700-normal.ttf +0 -0
- package/fonts/ttf/geneva-400-normal.ttf +0 -0
- package/fonts/ttf/georgia-400-italic.ttf +0 -0
- package/fonts/ttf/georgia-400-normal.ttf +0 -0
- package/fonts/ttf/georgia-700-normal.ttf +0 -0
- package/fonts/ttf/gill-sans-400-italic.ttf +0 -0
- package/fonts/ttf/gill-sans-400-normal.ttf +0 -0
- package/fonts/ttf/gill-sans-700-italic.ttf +0 -0
- package/fonts/ttf/gill-sans-700-normal.ttf +0 -0
- package/fonts/ttf/gill-sans-light-400-italic.ttf +0 -0
- package/fonts/ttf/gill-sans-light-400-normal.ttf +0 -0
- package/fonts/ttf/gill-sans-mt-400-italic.ttf +0 -0
- package/fonts/ttf/gill-sans-mt-400-normal.ttf +0 -0
- package/fonts/ttf/gill-sans-mt-700-italic.ttf +0 -0
- package/fonts/ttf/gill-sans-mt-700-normal.ttf +0 -0
- package/fonts/ttf/helvetica-400-italic.ttf +0 -0
- package/fonts/ttf/helvetica-400-normal.ttf +0 -0
- package/fonts/ttf/helvetica-700-italic.ttf +0 -0
- package/fonts/ttf/helvetica-700-normal.ttf +0 -0
- package/fonts/ttf/helvetica-neue-400-italic.ttf +0 -0
- package/fonts/ttf/helvetica-neue-400-normal.ttf +0 -0
- package/fonts/ttf/helvetica-neue-700-italic.ttf +0 -0
- package/fonts/ttf/helvetica-neue-700-normal.ttf +0 -0
- package/fonts/ttf/hoefler-text-400-italic.ttf +0 -0
- package/fonts/ttf/hoefler-text-400-normal.ttf +0 -0
- package/fonts/ttf/hoefler-text-700-italic.ttf +0 -0
- package/fonts/ttf/hoefler-text-700-normal.ttf +0 -0
- package/fonts/ttf/lucida-grande-400-normal.ttf +0 -0
- package/fonts/ttf/lucida-grande-700-normal.ttf +0 -0
- package/fonts/ttf/lucida-sans-400-italic.ttf +0 -0
- package/fonts/ttf/lucida-sans-400-normal.ttf +0 -0
- package/fonts/ttf/lucida-sans-700-italic.ttf +0 -0
- package/fonts/ttf/lucida-sans-700-normal.ttf +0 -0
- package/fonts/ttf/lucida-sans-unicode-400-normal.ttf +0 -0
- package/fonts/ttf/malgun-gothic-400-normal.ttf +0 -0
- package/fonts/ttf/malgun-gothic-700-normal.ttf +0 -0
- package/fonts/ttf/mangal-400-normal.ttf +0 -0
- package/fonts/ttf/mangal-700-normal.ttf +0 -0
- package/fonts/ttf/microsoft-sans-serif-400-normal.ttf +0 -0
- package/fonts/ttf/microsoft-yahei-400-normal.ttf +0 -0
- package/fonts/ttf/microsoft-yahei-700-normal.ttf +0 -0
- package/fonts/ttf/microsoft-yi-baiti-400-normal.ttf +0 -0
- package/fonts/ttf/monotype-sorts-400-normal.ttf +0 -0
- package/fonts/ttf/ms-gothic-400-normal.ttf +0 -0
- package/fonts/ttf/ms-mincho-400-normal.ttf +0 -0
- package/fonts/ttf/ms-ui-gothic-400-normal.ttf +0 -0
- package/fonts/ttf/new-york-400-italic.ttf +0 -0
- package/fonts/ttf/new-york-400-normal.ttf +0 -0
- package/fonts/ttf/news-gothic-mt-400-italic.ttf +0 -0
- package/fonts/ttf/news-gothic-mt-400-normal.ttf +0 -0
- package/fonts/ttf/news-gothic-mt-700-italic.ttf +0 -0
- package/fonts/ttf/news-gothic-mt-700-normal.ttf +0 -0
- package/fonts/ttf/nsimsun-400-normal.ttf +0 -0
- package/fonts/ttf/optima-400-italic.ttf +0 -0
- package/fonts/ttf/optima-400-normal.ttf +0 -0
- package/fonts/ttf/optima-700-italic.ttf +0 -0
- package/fonts/ttf/optima-700-normal.ttf +0 -0
- package/fonts/ttf/palatino-400-italic.ttf +0 -0
- package/fonts/ttf/palatino-400-normal.ttf +0 -0
- package/fonts/ttf/palatino-700-italic.ttf +0 -0
- package/fonts/ttf/palatino-700-normal.ttf +0 -0
- package/fonts/ttf/palatino-linotype-400-italic.ttf +0 -0
- package/fonts/ttf/palatino-linotype-400-normal.ttf +0 -0
- package/fonts/ttf/palatino-linotype-700-italic.ttf +0 -0
- package/fonts/ttf/palatino-linotype-700-normal.ttf +0 -0
- package/fonts/ttf/pmingliu-400-normal.ttf +0 -0
- package/fonts/ttf/pt-mono-400-normal.ttf +0 -0
- package/fonts/ttf/pt-mono-700-normal.ttf +0 -0
- package/fonts/ttf/segoe-ui-symbol-400-normal.ttf +0 -0
- package/fonts/ttf/simsun-400-normal.ttf +0 -0
- package/fonts/ttf/skia-400-normal.ttf +0 -0
- package/fonts/ttf/stencil-400-normal.ttf +0 -0
- package/fonts/ttf/symbol-400-normal.ttf +0 -0
- package/fonts/ttf/tahoma-400-normal.ttf +0 -0
- package/fonts/ttf/tahoma-700-normal.ttf +0 -0
- package/fonts/ttf/times-400-italic.ttf +0 -0
- package/fonts/ttf/times-400-normal.ttf +0 -0
- package/fonts/ttf/times-700-italic.ttf +0 -0
- package/fonts/ttf/times-700-normal.ttf +0 -0
- package/fonts/ttf/times-new-roman-400-italic.ttf +0 -0
- package/fonts/ttf/times-new-roman-400-normal.ttf +0 -0
- package/fonts/ttf/times-new-roman-700-italic.ttf +0 -0
- package/fonts/ttf/times-new-roman-700-normal.ttf +0 -0
- package/fonts/ttf/trebuchet-ms-400-italic.ttf +0 -0
- package/fonts/ttf/trebuchet-ms-400-normal.ttf +0 -0
- package/fonts/ttf/trebuchet-ms-700-italic.ttf +0 -0
- package/fonts/ttf/trebuchet-ms-700-normal.ttf +0 -0
- package/fonts/ttf/tw-cen-mt-400-normal.ttf +0 -0
- package/fonts/ttf/tw-cen-mt-700-normal.ttf +0 -0
- package/fonts/ttf/tw-cen-mt-condensed-400-normal.ttf +0 -0
- package/fonts/ttf/tw-cen-mt-condensed-700-normal.ttf +0 -0
- package/fonts/ttf/verdana-400-italic.ttf +0 -0
- package/fonts/ttf/verdana-400-normal.ttf +0 -0
- package/fonts/ttf/verdana-700-italic.ttf +0 -0
- package/fonts/ttf/verdana-700-normal.ttf +0 -0
- package/fonts/ttf/webdings-400-normal.ttf +0 -0
- package/fonts/ttf/wingdings-2-400-normal.ttf +0 -0
- package/fonts/ttf/wingdings-3-400-normal.ttf +0 -0
- package/fonts/ttf/wingdings-400-normal.ttf +0 -0
- package/fonts/ttf/yu-gothic-light-400-normal.ttf +0 -0
- package/fonts/ttf/yu-mincho-400-normal.ttf +0 -0
- package/fonts/ttf/yu-mincho-700-normal.ttf +0 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# myrole-docx-editor
|
|
2
|
+
|
|
3
|
+
The MyRole `.docx` engine as an embeddable SDK: a Word-faithful renderer and
|
|
4
|
+
editor on canvas, the template-variables layer, and a Word-like chrome — in
|
|
5
|
+
one call, with a React component.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add myrole-docx-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Vanilla
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createDocxEditor } from 'myrole-docx-editor'
|
|
15
|
+
|
|
16
|
+
const editor = createDocxEditor(document.getElementById('app'), {
|
|
17
|
+
onSave: (bytes) => upload(bytes), // called after a quiet period, and on tab change
|
|
18
|
+
})
|
|
19
|
+
await editor.load(file) // File, Blob, ArrayBuffer, Uint8Array or URL
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The container needs a height (`height: 100vh`, or a flex parent). The SDK
|
|
23
|
+
injects its own stylesheet; nothing else to import.
|
|
24
|
+
|
|
25
|
+
## React
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { DocxEditor, useDocxEditor } from 'myrole-docx-editor/react'
|
|
29
|
+
|
|
30
|
+
function Page({ file }) {
|
|
31
|
+
const ref = useDocxEditor()
|
|
32
|
+
return (
|
|
33
|
+
<DocxEditor
|
|
34
|
+
ref={ref}
|
|
35
|
+
src={file}
|
|
36
|
+
style={{ height: '100vh' }}
|
|
37
|
+
onSave={(bytes) => upload(bytes)}
|
|
38
|
+
onReady={(h) => h.showPanel('variables')}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`src` changes reload the document in place; the other props are read at
|
|
45
|
+
mount. `ref.current` is the same handle `createDocxEditor` returns.
|
|
46
|
+
|
|
47
|
+
## Options
|
|
48
|
+
|
|
49
|
+
| option | default | |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `chrome` | `'full'` | `'full'` ribbon, rulers, panels · `'viewer'` read-only pages under a slim header · `'none'` pages only |
|
|
52
|
+
| `readOnly` | `false` | the caret moves and the selection copies, nothing edits |
|
|
53
|
+
| `theme` | `'system'` | `'light'`, `'dark'`, `'system'` |
|
|
54
|
+
| `fontsUrl` | next to the bundle | the directory that holds `ttf/` — see Fonts |
|
|
55
|
+
| `onSave` | – | autosave target; the `.docx` bytes |
|
|
56
|
+
| `onChange`, `onReady` | – | |
|
|
57
|
+
| `zoom` | `1` | |
|
|
58
|
+
| `rulers`, `statusBar` | `true` | |
|
|
59
|
+
| `panel` | `null` | open on `'variables'` or `'inspector'` |
|
|
60
|
+
| `values` | sample set | values for the generated-document preview |
|
|
61
|
+
| `library` | – | `{ fields: [{ path, label?, desc? }], snippets: [{ id, title, code, category?, desc? }], builtinSnippets? }` — offered in the Bibliothèque panel, the ribbon's Variable button and the autocompletion, before what the document already uses |
|
|
62
|
+
| `comments` | `true` | Word's comments as marks on the text; click one for its balloon; « Commentaires » on the Affichage tab toggles them |
|
|
63
|
+
| `maxPages` | – | a guard against a runaway layout |
|
|
64
|
+
|
|
65
|
+
## Handle
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
editor.load(src) editor.save(): Uint8Array editor.download('contrat.docx')
|
|
69
|
+
editor.editor // the low-level editor: commands, selection, format, undo…
|
|
70
|
+
editor.document // the OOXML model
|
|
71
|
+
editor.setZoom(1.25) editor.setTheme('dark') editor.setReadOnly(true)
|
|
72
|
+
editor.showPanel('variables') editor.fileName('contrat.docx') editor.pages()
|
|
73
|
+
editor.variables.tags() editor.variables.preview(true, values)
|
|
74
|
+
editor.comments() editor.showComments(false)
|
|
75
|
+
editor.on('change' | 'selection' | 'render' | 'save' | 'load' | 'zoom', fn)
|
|
76
|
+
editor.destroy()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The low-level editor is the same object extensions get: `registerCommand`
|
|
80
|
+
adds a ribbon button, `registerDecorations` adds marks anchored to text,
|
|
81
|
+
`format` / `formatPara` / `setMargins` / `table` / `insertImage` edit the
|
|
82
|
+
model, `undo` / `redo` / `save` do what they say.
|
|
83
|
+
|
|
84
|
+
## Fonts
|
|
85
|
+
|
|
86
|
+
The engine measures with 219 subset faces shipped under `fonts/ttf/`
|
|
87
|
+
(33 MB, loaded on demand). They are declared at runtime from
|
|
88
|
+
`fontsUrl`, which defaults to `fonts/` next to the bundle. If your bundler
|
|
89
|
+
does not keep that directory next to the output, serve it yourself:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
createDocxEditor(el, { fontsUrl: '/static/docx-fonts/' }) // …/docx-fonts/ttf/*.ttf
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Copy `node_modules/myrole-docx-editor/fonts` there, or point at a CDN.
|
|
96
|
+
|
|
97
|
+
## Read-only render
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { renderDocx } from 'myrole-docx-editor'
|
|
101
|
+
const { pages } = await renderDocx(url, hiddenDiv) // HTMLCanvasElement[]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Publishing
|
|
105
|
+
|
|
106
|
+
`pnpm build` writes `dist/` (ESM, one chunk per entry, types) and packs the
|
|
107
|
+
fonts. CI publishes on a `v*` tag; see `.gitlab-ci.yml` at the repository root.
|