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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type DocxDocument } from '../../docx-model/src/index';
|
|
2
|
+
import type { LineTrace } from '../../docx-render/src/index';
|
|
3
|
+
export interface InspectorData {
|
|
4
|
+
/** Métadonnées du document */
|
|
5
|
+
meta: {
|
|
6
|
+
title?: string;
|
|
7
|
+
author?: string;
|
|
8
|
+
lastModifiedBy?: string;
|
|
9
|
+
created?: string;
|
|
10
|
+
modified?: string;
|
|
11
|
+
revision?: string;
|
|
12
|
+
application?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Mise en page */
|
|
15
|
+
page: {
|
|
16
|
+
widthPt: number;
|
|
17
|
+
heightPt: number;
|
|
18
|
+
marginTopPt: number;
|
|
19
|
+
marginRightPt: number;
|
|
20
|
+
marginBottomPt: number;
|
|
21
|
+
marginLeftPt: number;
|
|
22
|
+
orient?: string;
|
|
23
|
+
columns?: number;
|
|
24
|
+
columnGapPt?: number;
|
|
25
|
+
defaultFont?: string;
|
|
26
|
+
defaultSizePt?: number;
|
|
27
|
+
};
|
|
28
|
+
/** Sections */
|
|
29
|
+
sections: Array<{
|
|
30
|
+
index: number;
|
|
31
|
+
widthPt: number;
|
|
32
|
+
heightPt: number;
|
|
33
|
+
marginsPt: {
|
|
34
|
+
top: number;
|
|
35
|
+
right: number;
|
|
36
|
+
bottom: number;
|
|
37
|
+
left: number;
|
|
38
|
+
};
|
|
39
|
+
columns: number;
|
|
40
|
+
orient?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Statistiques */
|
|
43
|
+
stats: {
|
|
44
|
+
paragraphs: number;
|
|
45
|
+
runs: number;
|
|
46
|
+
characters: number;
|
|
47
|
+
words: number;
|
|
48
|
+
lineBreaks: number;
|
|
49
|
+
tables: number;
|
|
50
|
+
images: number;
|
|
51
|
+
comments: number;
|
|
52
|
+
bookmarks: number;
|
|
53
|
+
hyperlinks: number;
|
|
54
|
+
embeddedFonts: number;
|
|
55
|
+
xmlParts: number;
|
|
56
|
+
binParts: number;
|
|
57
|
+
};
|
|
58
|
+
/** Polices */
|
|
59
|
+
fonts: {
|
|
60
|
+
embedded: Array<{
|
|
61
|
+
family: string;
|
|
62
|
+
style: string;
|
|
63
|
+
sizeKB: number;
|
|
64
|
+
}>;
|
|
65
|
+
used: Array<{
|
|
66
|
+
family: string;
|
|
67
|
+
runs: number;
|
|
68
|
+
percent: number;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
/** Assets binaires */
|
|
72
|
+
assets: Array<{
|
|
73
|
+
path: string;
|
|
74
|
+
type: string;
|
|
75
|
+
sizeKB: number;
|
|
76
|
+
}>;
|
|
77
|
+
/** Commentaires Word */
|
|
78
|
+
comments: Array<{
|
|
79
|
+
id: string;
|
|
80
|
+
author: string;
|
|
81
|
+
date?: string;
|
|
82
|
+
text: string;
|
|
83
|
+
paragraphs?: number[];
|
|
84
|
+
}>;
|
|
85
|
+
/** Tags de template ({{ }} et {% %}) */
|
|
86
|
+
tags: Array<{
|
|
87
|
+
paragraph: number;
|
|
88
|
+
raw: string;
|
|
89
|
+
kind: string;
|
|
90
|
+
}>;
|
|
91
|
+
/** Positions des lignes dessinées (depuis onLine) */
|
|
92
|
+
lines?: LineTrace[];
|
|
93
|
+
/** Blocs du body */
|
|
94
|
+
blocks: Array<{
|
|
95
|
+
type: string;
|
|
96
|
+
index: number;
|
|
97
|
+
sectionIndex: number;
|
|
98
|
+
details?: string;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
export declare function inspect(doc: DocxDocument, lines?: LineTrace[]): InspectorData;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The React face of the SDK.
|
|
3
|
+
*
|
|
4
|
+
* <DocxEditor src={file} onSave={(bytes) => upload(bytes)} style={{ height: '100vh' }} />
|
|
5
|
+
*
|
|
6
|
+
* The component owns one `createDocxEditor` for its lifetime; `src` changes
|
|
7
|
+
* reload the document in place, every other option is read at mount. React is
|
|
8
|
+
* an optional peer: nothing here runs unless `myrole-docx-editor/react` is
|
|
9
|
+
* imported.
|
|
10
|
+
*/
|
|
11
|
+
import { type CSSProperties } from 'react';
|
|
12
|
+
import { type DocxEditorHandle, type DocxEditorOptions } from './sdk';
|
|
13
|
+
export interface DocxEditorProps extends Omit<DocxEditorOptions, 'onReady'> {
|
|
14
|
+
/** the document: bytes, a Blob/File, or a URL */
|
|
15
|
+
src?: ArrayBuffer | Uint8Array | Blob | string;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
/** the handle, once mounted */
|
|
19
|
+
onReady?: (editor: DocxEditorHandle) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const DocxEditor: import("react").ForwardRefExoticComponent<DocxEditorProps & import("react").RefAttributes<DocxEditorHandle | null>>;
|
|
22
|
+
/** A ref to hand to `<DocxEditor ref={…}>`, and the handle once it exists. */
|
|
23
|
+
export declare function useDocxEditor(): import("react").RefObject<DocxEditorHandle | null>;
|
|
24
|
+
export type { DocxEditorHandle, DocxEditorOptions } from './sdk';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK: one call mounts the Word-like editor in an element.
|
|
3
|
+
*
|
|
4
|
+
* const h = createDocxEditor(el, { onSave: (bytes) => upload(bytes) })
|
|
5
|
+
* await h.load(file)
|
|
6
|
+
*
|
|
7
|
+
* Everything the app did in `main.ts` lives here — the document pipeline
|
|
8
|
+
* (fonts, embedded faces, images, headers and footers, anchored text boxes,
|
|
9
|
+
* the variables layer), the editor, the chrome — behind one handle, so the
|
|
10
|
+
* host page owns nothing but a `<div>`.
|
|
11
|
+
*
|
|
12
|
+
* One editor per page. The inspector, the variables panel and the bench read
|
|
13
|
+
* a few elements by id (`#info`, `#pages`, `#inspector`…); two editors on one
|
|
14
|
+
* page would share them. ponytail: scope the ids to the root the day a page
|
|
15
|
+
* needs two editors.
|
|
16
|
+
*/
|
|
17
|
+
import { type DocxDocument } from '../../docx-model/src/index';
|
|
18
|
+
import type { Tag } from '../../docx-tags/src/index';
|
|
19
|
+
import { type Editor } from './editor';
|
|
20
|
+
import { type LibraryExtras } from './vars-library';
|
|
21
|
+
import { type CommentRange } from './comments';
|
|
22
|
+
export type ChromeMode = 'full' | 'viewer' | 'none';
|
|
23
|
+
export type Theme = 'light' | 'dark' | 'system';
|
|
24
|
+
export type DocxEditorEvent = 'load' | 'change' | 'selection' | 'render' | 'save' | 'context' | 'zoom';
|
|
25
|
+
export interface DocxEditorOptions {
|
|
26
|
+
/** `full`: ribbon, rulers, panels. `viewer`: read-only pages under a slim header. `none`: pages only. */
|
|
27
|
+
chrome?: ChromeMode;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
theme?: Theme;
|
|
30
|
+
/** directory that holds `ttf/` — see `fonts.ts` */
|
|
31
|
+
fontsUrl?: string | URL;
|
|
32
|
+
/** hard cap on the page count — a guard against a runaway layout, never an alignment */
|
|
33
|
+
maxPages?: number;
|
|
34
|
+
/** the document after a quiet period, and on tab change — where autosave goes */
|
|
35
|
+
onSave?: (bytes: Uint8Array) => void | Promise<void>;
|
|
36
|
+
onChange?: () => void;
|
|
37
|
+
onReady?: (handle: DocxEditorHandle) => void;
|
|
38
|
+
zoom?: number;
|
|
39
|
+
rulers?: boolean;
|
|
40
|
+
statusBar?: boolean;
|
|
41
|
+
fileName?: string;
|
|
42
|
+
/** preview values; when absent the preview deduces a sample set from the tags */
|
|
43
|
+
values?: Record<string, unknown>;
|
|
44
|
+
/** open the editor on the last-used side panel */
|
|
45
|
+
panel?: 'variables' | 'inspector' | null;
|
|
46
|
+
/** the fields and snippets the application offers, beyond what the document already uses */
|
|
47
|
+
library?: LibraryExtras;
|
|
48
|
+
/** show Word's comments as marks on the text (default true) */
|
|
49
|
+
comments?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface DocxEditorHandle {
|
|
52
|
+
load(src: ArrayBuffer | Uint8Array | Blob | string): Promise<void>;
|
|
53
|
+
/** the document as .docx bytes, now */
|
|
54
|
+
save(): Uint8Array;
|
|
55
|
+
/** triggers the browser download */
|
|
56
|
+
download(name?: string): void;
|
|
57
|
+
/** the low-level editor: commands, selection, formatting — `null` before the first load */
|
|
58
|
+
readonly editor: Editor | null;
|
|
59
|
+
readonly document: DocxDocument | null;
|
|
60
|
+
readonly root: HTMLElement;
|
|
61
|
+
pages(): number;
|
|
62
|
+
fileName(name?: string): string;
|
|
63
|
+
setZoom(z: number): void;
|
|
64
|
+
getZoom(): number;
|
|
65
|
+
setTheme(t: Theme): void;
|
|
66
|
+
setReadOnly(on: boolean): void;
|
|
67
|
+
showPanel(p: 'variables' | 'inspector' | null): void;
|
|
68
|
+
/** Word's comments of the open document, with their ranges */
|
|
69
|
+
comments(): CommentRange[];
|
|
70
|
+
showComments(on: boolean): void;
|
|
71
|
+
variables: {
|
|
72
|
+
tags(): Tag[];
|
|
73
|
+
/** show the GENERATED document: values interpolated, false sections hidden */
|
|
74
|
+
preview(on: boolean, values?: Record<string, unknown>): Promise<void>;
|
|
75
|
+
previewOn(): boolean;
|
|
76
|
+
};
|
|
77
|
+
on(ev: DocxEditorEvent, fn: (payload?: unknown) => void): () => void;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
}
|
|
80
|
+
/** The paragraph styles a document declares — what the Styles gallery lists. */
|
|
81
|
+
export declare function paragraphStyles(doc: DocxDocument): {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
}[];
|
|
85
|
+
export declare function createDocxEditor(container: HTMLElement, options?: DocxEditorOptions): DocxEditorHandle;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type ChromeMode = 'full' | 'viewer' | 'none';
|
|
2
|
+
export type Theme = 'light' | 'dark' | 'system';
|
|
3
|
+
export type Panel = 'variables' | 'inspector';
|
|
4
|
+
export interface ShellHost {
|
|
5
|
+
open(file: File): void;
|
|
6
|
+
save(): void;
|
|
7
|
+
zoom(z: number): void;
|
|
8
|
+
panel(p: Panel | null): void;
|
|
9
|
+
rename(name: string): void;
|
|
10
|
+
}
|
|
11
|
+
export interface ShellOptions {
|
|
12
|
+
mode: ChromeMode;
|
|
13
|
+
theme: Theme;
|
|
14
|
+
rulers: boolean;
|
|
15
|
+
statusBar: boolean;
|
|
16
|
+
fileName: string;
|
|
17
|
+
host: ShellHost;
|
|
18
|
+
}
|
|
19
|
+
export interface Shell {
|
|
20
|
+
root: HTMLElement;
|
|
21
|
+
pagesEl: HTMLElement;
|
|
22
|
+
mainEl: HTMLElement;
|
|
23
|
+
ribbonEl: HTMLElement;
|
|
24
|
+
rulerH: HTMLElement;
|
|
25
|
+
rulerV: HTMLElement;
|
|
26
|
+
varsEl: HTMLElement;
|
|
27
|
+
inspectorEl: HTMLElement;
|
|
28
|
+
statusEl: HTMLElement;
|
|
29
|
+
/** the composition line the bench reads (« N page(s) ») */
|
|
30
|
+
info: HTMLElement;
|
|
31
|
+
/** what happens while a document opens, step by step */
|
|
32
|
+
loader: Loader;
|
|
33
|
+
setFileName(name: string): void;
|
|
34
|
+
setSaveState(s: string): void;
|
|
35
|
+
setPages(n: number): void;
|
|
36
|
+
setWords(n: number): void;
|
|
37
|
+
setPosition(page: number, pages: number, selChars: number): void;
|
|
38
|
+
setZoom(z: number): void;
|
|
39
|
+
setTheme(t: Theme): void;
|
|
40
|
+
theme(): Theme;
|
|
41
|
+
setRulers(on: boolean): void;
|
|
42
|
+
rulers(): boolean;
|
|
43
|
+
setStatusBar(on: boolean): void;
|
|
44
|
+
setReadOnly(on: boolean): void;
|
|
45
|
+
showPanel(p: Panel | null): void;
|
|
46
|
+
panel(): Panel | null;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
export interface Loader {
|
|
50
|
+
start(name: string): void;
|
|
51
|
+
/** closes the previous step with its elapsed time and opens this one */
|
|
52
|
+
step(label: string, detail?: string): void;
|
|
53
|
+
done(summary: string): void;
|
|
54
|
+
fail(message: string): void;
|
|
55
|
+
}
|
|
56
|
+
export declare const ZOOM_STEPS: number[];
|
|
57
|
+
export declare function mountShell(container: HTMLElement, o: ShellOptions): Shell;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { MarkRect } from '../../docx-render/src/index';
|
|
2
|
+
import type { StyledParagraph } from '../../docx-model/src/index';
|
|
3
|
+
import { type Tag } from '../../docx-tags/src/index';
|
|
4
|
+
import { type Evaluated } from '../../docx-vars/src/index';
|
|
5
|
+
/**
|
|
6
|
+
* Les variables d'une matrice, dans l'éditeur.
|
|
7
|
+
*
|
|
8
|
+
* Le POC variables avait montré qu'un tag peut s'afficher en badge lisible et
|
|
9
|
+
* s'éditer en blocs. Il ne pouvait pas les ÉCRIRE : « rien n'est écrit dans le
|
|
10
|
+
* docx », disait sa page de limites. Ici le document est éditable, et c'est ce
|
|
11
|
+
* qui change tout — un badge n'est plus une vue, c'est une poignée.
|
|
12
|
+
*
|
|
13
|
+
* Trois pièces, dans cet ordre — l'inverse ne peut produire que du recouvrement :
|
|
14
|
+
*
|
|
15
|
+
* 1. **mesurer** les badges hors écran, à la largeur utile de la page ;
|
|
16
|
+
* 2. **composer** en donnant au renderer une BOÎTE de cette taille à la place
|
|
17
|
+
* du texte du tag — il l'écarte comme un mot insécable ;
|
|
18
|
+
* 3. **poser** chaque badge dans la boîte que le renderer lui a gardée.
|
|
19
|
+
*
|
|
20
|
+
* La boîte garde le texte du tag. Elle ne le dessine pas — mais le rang de
|
|
21
|
+
* chaque caractère qui SUIT dans le paragraphe en dépend, et un curseur posé
|
|
22
|
+
* après un badge écrirait sinon quatorze caractères trop tôt.
|
|
23
|
+
*/
|
|
24
|
+
export interface VarsHost {
|
|
25
|
+
/** Texte de chaque paragraphe, tel que les EXTENSIONS le voient. */
|
|
26
|
+
paras(): string[];
|
|
27
|
+
/** Curseur courant, pour les extensions qui s'y intéressent. */
|
|
28
|
+
caret(): {
|
|
29
|
+
para: number;
|
|
30
|
+
offset: number;
|
|
31
|
+
} | null;
|
|
32
|
+
/** Le badge a été choisi : à l'hôte d'ouvrir ce qu'il veut. */
|
|
33
|
+
onSelect(tag: Tag): void;
|
|
34
|
+
/** Redemande une composition — une extension a changé d'avis. */
|
|
35
|
+
refresh(): void;
|
|
36
|
+
}
|
|
37
|
+
export interface Variables {
|
|
38
|
+
/**
|
|
39
|
+
* Relit les tags et remesure leurs badges.
|
|
40
|
+
*
|
|
41
|
+
* On scanne le texte des paragraphes STYLÉS, pas celui du modèle : c'est lui
|
|
42
|
+
* que le renderer compose et que le curseur adresse. Une tabulation ou un
|
|
43
|
+
* saut de ligne suffisent à les faire diverger, et les badges se posaient
|
|
44
|
+
* alors à côté de leur tag.
|
|
45
|
+
*/
|
|
46
|
+
rescan(pageWidthPx: number, styled: StyledParagraph[]): void;
|
|
47
|
+
/** Les tags lus au dernier passage. */
|
|
48
|
+
tags(): Tag[];
|
|
49
|
+
/** Le tag qui porte cette adresse, s'il y en a un. */
|
|
50
|
+
at(para: number, off: number): Tag | undefined;
|
|
51
|
+
/** Remplace le texte des tags par des boîtes de la taille de leur badge. */
|
|
52
|
+
substitute(styled: StyledParagraph[]): StyledParagraph[];
|
|
53
|
+
/**
|
|
54
|
+
* APERÇU — le document GÉNÉRÉ, à la place des badges.
|
|
55
|
+
*
|
|
56
|
+
* `null` pour revenir aux badges. Avec une évaluation, chaque tag de valeur
|
|
57
|
+
* rend son résultat et les sections fausses masquent leur contenu : c'est le
|
|
58
|
+
* document que la génération produira, composé par le même moteur et à la
|
|
59
|
+
* même fidélité que le reste. L'atelier des variables savait le faire depuis
|
|
60
|
+
* le début ; l'éditeur, non — il ne montrait que les tags.
|
|
61
|
+
*/
|
|
62
|
+
setPreview(ev: Evaluated | null): void;
|
|
63
|
+
/** Pose les badges dans les boîtes que le renderer a publiées. */
|
|
64
|
+
place(layers: HTMLElement[], rects: MarkRect[]): void;
|
|
65
|
+
/** Met en évidence le badge d'un tag — ou aucun. */
|
|
66
|
+
highlight(id: number | null): void;
|
|
67
|
+
}
|
|
68
|
+
export declare function createVariables(host: VarsHost): Variables;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BlockJson } from '../../docx-vars/src/index';
|
|
2
|
+
import type { Tag } from '../../docx-tags/src/index';
|
|
3
|
+
export interface BlocklyView {
|
|
4
|
+
load(tree: BlockJson): void;
|
|
5
|
+
read(): BlockJson | null;
|
|
6
|
+
resize(): void;
|
|
7
|
+
dispose(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function mountBlockly(holder: HTMLElement, onChange: () => void, tags: () => Tag[]): BlocklyView;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type LibEntry } from './vars-library';
|
|
2
|
+
import type { Tag } from '../../docx-tags/src/index';
|
|
3
|
+
/**
|
|
4
|
+
* L'autocomplétion, dans le document.
|
|
5
|
+
*
|
|
6
|
+
* Elle ne se déclenche pas n'importe où — une liste qui s'ouvre pendant qu'on
|
|
7
|
+
* rédige une phrase est une nuisance. Deux endroits, et deux seulement :
|
|
8
|
+
*
|
|
9
|
+
* - **dans un tag ouvert** (`{{` ou `{%` sans fermeture avant le curseur) :
|
|
10
|
+
* champs et fonctions, c'est-à-dire ce qui a le droit d'y figurer ;
|
|
11
|
+
* - **après un `/` en début de mot** : les extraits, comme partout ailleurs
|
|
12
|
+
* depuis que Notion en a fait une convention.
|
|
13
|
+
*
|
|
14
|
+
* Le clavier passe AVANT l'éditeur : la capture est posée sur le champ de
|
|
15
|
+
* frappe, et les flèches, Entrée, Tab et Échap ne redescendent pas jusqu'à lui
|
|
16
|
+
* tant que la liste est ouverte. Sans ça, ↓ déplacerait le curseur dans la page
|
|
17
|
+
* pendant qu'on parcourt la liste.
|
|
18
|
+
*/
|
|
19
|
+
export interface CompleteHost {
|
|
20
|
+
/** Le champ invisible qui reçoit la frappe — c'est là qu'on capture. */
|
|
21
|
+
input: HTMLElement;
|
|
22
|
+
tags(): Tag[];
|
|
23
|
+
/** Texte d'un paragraphe du corps. */
|
|
24
|
+
textOf(para: number): string;
|
|
25
|
+
/** Où est le curseur, ou `null`. */
|
|
26
|
+
caret(): {
|
|
27
|
+
para: number;
|
|
28
|
+
off: number;
|
|
29
|
+
} | null;
|
|
30
|
+
/** Remplace une plage du paragraphe courant par ce texte. */
|
|
31
|
+
replace(para: number, from: number, to: number, text: string): void;
|
|
32
|
+
/** Where to hang the list; by default under the page's caret. */
|
|
33
|
+
anchor?(): DOMRect | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface Completer {
|
|
36
|
+
/** À rappeler après chaque frappe : ouvre, met à jour ou referme. */
|
|
37
|
+
refresh(): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
open(): boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Ce qu'on est en train de taper, et ce qu'on a le droit d'y proposer. */
|
|
42
|
+
interface Context {
|
|
43
|
+
para: number;
|
|
44
|
+
/** plage du fragment à remplacer */
|
|
45
|
+
from: number;
|
|
46
|
+
to: number;
|
|
47
|
+
prefix: string;
|
|
48
|
+
kinds: LibEntry['kind'][];
|
|
49
|
+
/** ce qu'on insère : le code entier, ou seulement l'expression */
|
|
50
|
+
as: 'code' | 'expr';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Lit le contexte de frappe autour du curseur.
|
|
54
|
+
*
|
|
55
|
+
* On regarde le texte AVANT le curseur seulement : ce qui suit n'appartient
|
|
56
|
+
* pas encore à ce qu'on écrit.
|
|
57
|
+
*/
|
|
58
|
+
export declare function contextAt(text: string, off: number): Context | null;
|
|
59
|
+
export declare function createCompleter(host: CompleteHost): Completer;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Tag } from '../../docx-tags/src/index';
|
|
2
|
+
import { type IconName } from '../../docx-vars/src/index';
|
|
3
|
+
/**
|
|
4
|
+
* La bibliothèque : ce qu'on peut poser dans un document.
|
|
5
|
+
*
|
|
6
|
+
* Trois natures, et l'ordre n'est pas indifférent — il suit ce que le corpus
|
|
7
|
+
* dit du travail réel. Les CHAMPS d'abord, parce que l'écrasante majorité des
|
|
8
|
+
* variables sont des accès de champ simples. Les FONCTIONS ensuite. Les
|
|
9
|
+
* EXTRAITS enfin, qui sont ce qui manque le plus au rédacteur de matrice : il
|
|
10
|
+
* ne réécrit pas un champ, il réécrit un paragraphe conditionnel entier.
|
|
11
|
+
*
|
|
12
|
+
* Chaque entrée sait ce qu'elle INSÈRE — c'est la seule chose que l'hôte a
|
|
13
|
+
* besoin de savoir d'elle.
|
|
14
|
+
*/
|
|
15
|
+
export interface LibEntry {
|
|
16
|
+
kind: 'champ' | 'fonction' | 'extrait';
|
|
17
|
+
key: string;
|
|
18
|
+
label: string;
|
|
19
|
+
sub: string;
|
|
20
|
+
icon: IconName;
|
|
21
|
+
/** Ce que l'entrée pose dans le document. */
|
|
22
|
+
code: string;
|
|
23
|
+
/** Ce qu'on met dans une expression, sans les accolades. */
|
|
24
|
+
expr: string;
|
|
25
|
+
desc?: string;
|
|
26
|
+
}
|
|
27
|
+
/** A field the host declares — what the matrix MAY use, beyond what it already does. */
|
|
28
|
+
export interface LibraryField {
|
|
29
|
+
/** `salarie.nom` */
|
|
30
|
+
path: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
desc?: string;
|
|
33
|
+
}
|
|
34
|
+
/** A snippet the host declares — a whole block, ready to paste. */
|
|
35
|
+
export interface LibrarySnippet {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
code: string;
|
|
39
|
+
category?: string;
|
|
40
|
+
desc?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface LibraryExtras {
|
|
43
|
+
fields?: LibraryField[];
|
|
44
|
+
snippets?: LibrarySnippet[];
|
|
45
|
+
/** keep the built-in snippets next to the host's (default true) */
|
|
46
|
+
builtinSnippets?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare function configureLibrary(x: LibraryExtras): void;
|
|
49
|
+
export declare function libraryEntries(tags: Tag[]): LibEntry[];
|
|
50
|
+
/** Filtre sans accent ni casse — on cherche « majore », on trouve « Majoré ». */
|
|
51
|
+
export declare const fold: (s: string) => string;
|
|
52
|
+
export declare function filterEntries(all: LibEntry[], kind: string, query: string): LibEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* Une ligne de bibliothèque, telle qu'elle s'affiche partout.
|
|
55
|
+
*
|
|
56
|
+
* La même dans le panneau et dans l'autocomplétion du document : ce qu'on
|
|
57
|
+
* apprend d'un endroit vaut pour l'autre.
|
|
58
|
+
*/
|
|
59
|
+
export declare function entryRow(e: LibEntry): HTMLElement;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Tag } from '../../docx-tags/src/index';
|
|
2
|
+
/**
|
|
3
|
+
* Le panneau des variables : lire un tag, l'éditer, en poser un nouveau.
|
|
4
|
+
*
|
|
5
|
+
* C'est la boucle que le POC avait ouverte sans pouvoir la fermer — il savait
|
|
6
|
+
* lire un tag, le montrer en blocs et regénérer son code, mais « rien n'est
|
|
7
|
+
* écrit dans le docx ». Ici *Appliquer* passe par les gestes du modèle : la
|
|
8
|
+
* plage du tag est remplacée, l'annulation la ramène, et la composition
|
|
9
|
+
* incrémentale ne refait que la page touchée.
|
|
10
|
+
*
|
|
11
|
+
* Deux façons de voir les blocs, parce qu'elles ne servent pas à la même chose :
|
|
12
|
+
*
|
|
13
|
+
* - **Blocs** (par défaut) — du DOM qui se replie. Il remplit le panneau à
|
|
14
|
+
* n'importe quelle largeur, sans zoom ni défilement horizontal.
|
|
15
|
+
* - **Blockly** — le canvas, chargé à la demande. Il ne se replie pas, mais il
|
|
16
|
+
* sait ce que le DOM ne fait pas encore aussi bien : restructurer librement
|
|
17
|
+
* une expression au glisser-déposer.
|
|
18
|
+
*
|
|
19
|
+
* L'ARBRE est le même dans les deux : `blockify` le produit, `blockToTag` le
|
|
20
|
+
* relit. Basculer d'un mode à l'autre ne perd rien.
|
|
21
|
+
*/
|
|
22
|
+
export interface VarsPanelHost {
|
|
23
|
+
/** Remplace la plage d'un tag par ce texte, à travers l'éditeur. */
|
|
24
|
+
apply(tag: Tag, text: string): void;
|
|
25
|
+
/** Pose ce texte au curseur. */
|
|
26
|
+
insert(text: string): void;
|
|
27
|
+
/** Tous les tags du document — la bibliothèque de champs s'en déduit. */
|
|
28
|
+
tags(): Tag[];
|
|
29
|
+
}
|
|
30
|
+
export interface VarsPanel {
|
|
31
|
+
/** Montre un tag. `null` referme le panneau. */
|
|
32
|
+
show(tag: Tag | null): void;
|
|
33
|
+
/** Ouvre la bibliothèque, sans tag. */
|
|
34
|
+
library(): void;
|
|
35
|
+
current(): Tag | null;
|
|
36
|
+
open(): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function mountVarsPanel(root: HTMLElement, host: VarsPanelHost): VarsPanel;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type DocxDocument } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* Réécriture d'une plage de caractères dans le document.
|
|
4
|
+
*
|
|
5
|
+
* C'est la brique qui manquait pour éditer : jusqu'ici tout se lisait, rien ne
|
|
6
|
+
* repartait dans le docx. Elle repose entièrement sur le **découpage de run** —
|
|
7
|
+
* une plage partage presque toujours son `<w:r>` avec du texte voisin, et on ne
|
|
8
|
+
* peut pas remplacer l'une sans préserver l'autre, mise en forme comprise.
|
|
9
|
+
*
|
|
10
|
+
* L'adresse est celle de `spans.ts` : un rang de paragraphe et des bornes de
|
|
11
|
+
* caractères. C'est la MÊME que celle que le curseur rend à l'écran, et c'est
|
|
12
|
+
* volontaire — sans quoi l'éditeur écrirait à côté de ce qu'on a cliqué.
|
|
13
|
+
*
|
|
14
|
+
* ponytail: la substitution reste du texte par du texte, dans UN paragraphe.
|
|
15
|
+
* Insérer des images ou franchir une frontière de paragraphe viendra quand
|
|
16
|
+
* l'éditeur en aura besoin.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Remplace `[from, to)` du paragraphe `para` par `text`.
|
|
20
|
+
*
|
|
21
|
+
* Le texte inséré hérite de la mise en forme du run qui portait le début de la
|
|
22
|
+
* plage : c'est ce que fait Word quand on tape au milieu d'un mot en gras.
|
|
23
|
+
* Une plage vide insère au point.
|
|
24
|
+
*
|
|
25
|
+
* Renvoie `false` sans rien modifier quand la plage traverse deux conteneurs
|
|
26
|
+
* inline différents (moitié dans un `w:hyperlink`, moitié dehors) — la
|
|
27
|
+
* remplacer d'un seul découpage sortirait du texte de son conteneur.
|
|
28
|
+
*/
|
|
29
|
+
export declare function replaceRange(doc: DocxDocument, para: number, from: number, to: number, text: string, part?: string): boolean;
|
|
30
|
+
export interface TagSite {
|
|
31
|
+
/** rang du tag dans l'ordre du document, aligné sur `scanTags` */
|
|
32
|
+
index: number;
|
|
33
|
+
raw: string;
|
|
34
|
+
/** index du paragraphe */
|
|
35
|
+
para: number;
|
|
36
|
+
/** bornes du tag dans le TEXTE du paragraphe — la même adresse qu'un curseur */
|
|
37
|
+
from: number;
|
|
38
|
+
to: number;
|
|
39
|
+
/** false si le tag reste éclaté sur plusieurs conteneurs — non réécrivable */
|
|
40
|
+
writable: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tous les emplacements de tag, dans l'ordre du document.
|
|
44
|
+
*
|
|
45
|
+
* À appeler sur un document déjà soigné : un tag encore éclaté est signalé
|
|
46
|
+
* `writable: false` plutôt que réécrit de travers.
|
|
47
|
+
*/
|
|
48
|
+
export declare function tagSites(doc: DocxDocument): TagSite[];
|
|
49
|
+
/**
|
|
50
|
+
* Remplace le texte des tags désignés par leur rang.
|
|
51
|
+
*
|
|
52
|
+
* Le document est **soigné d'abord** : sans ça un tag éclaté par Word n'est
|
|
53
|
+
* adressable dans aucun run. Les réécritures sont appliquées de droite à
|
|
54
|
+
* gauche dans chaque paragraphe, pour que les positions déjà calculées restent
|
|
55
|
+
* valides. Renvoie les rangs effectivement réécrits.
|
|
56
|
+
*/
|
|
57
|
+
export declare function replaceTags(doc: DocxDocument, replacements: Map<number, string>): number[];
|
|
58
|
+
/**
|
|
59
|
+
* Réécrit chaque tag par lui-même.
|
|
60
|
+
*
|
|
61
|
+
* C'est le test qui compte : découper un run puis y remettre exactement le même
|
|
62
|
+
* texte doit être **neutre**. Si le document change, le découpage est faux.
|
|
63
|
+
*/
|
|
64
|
+
export declare function rewriteIdentity(doc: DocxDocument): number[];
|