@aster-editor/word 0.4.2 → 0.5.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 +204 -81
- package/dist/docx/compare/align.d.ts +24 -0
- package/dist/docx/compare/align.d.ts.map +1 -0
- package/dist/docx/compare/align.js +217 -0
- package/dist/docx/compare/align.js.map +1 -0
- package/dist/docx/compare/compare-blocks.d.ts +29 -0
- package/dist/docx/compare/compare-blocks.d.ts.map +1 -0
- package/dist/docx/compare/compare-blocks.js +234 -0
- package/dist/docx/compare/compare-blocks.js.map +1 -0
- package/dist/docx/compare/compare-context.d.ts +25 -0
- package/dist/docx/compare/compare-context.d.ts.map +1 -0
- package/dist/docx/compare/compare-context.js +31 -0
- package/dist/docx/compare/compare-context.js.map +1 -0
- package/dist/docx/compare/compare-docx.d.ts +4 -0
- package/dist/docx/compare/compare-docx.d.ts.map +1 -0
- package/dist/docx/compare/compare-docx.js +173 -0
- package/dist/docx/compare/compare-docx.js.map +1 -0
- package/dist/docx/compare/compare-tables.d.ts +13 -0
- package/dist/docx/compare/compare-tables.d.ts.map +1 -0
- package/dist/docx/compare/compare-tables.js +47 -0
- package/dist/docx/compare/compare-tables.js.map +1 -0
- package/dist/docx/compare/model-borders.d.ts +27 -0
- package/dist/docx/compare/model-borders.d.ts.map +1 -0
- package/dist/docx/compare/model-borders.js +41 -0
- package/dist/docx/compare/model-borders.js.map +1 -0
- package/dist/docx/compare/model-paragraph.d.ts +25 -0
- package/dist/docx/compare/model-paragraph.d.ts.map +1 -0
- package/dist/docx/compare/model-paragraph.js +309 -0
- package/dist/docx/compare/model-paragraph.js.map +1 -0
- package/dist/docx/compare/model-sections.d.ts +11 -0
- package/dist/docx/compare/model-sections.d.ts.map +1 -0
- package/dist/docx/compare/model-sections.js +97 -0
- package/dist/docx/compare/model-sections.js.map +1 -0
- package/dist/docx/compare/model.d.ts +113 -0
- package/dist/docx/compare/model.d.ts.map +1 -0
- package/dist/docx/compare/model.js +214 -0
- package/dist/docx/compare/model.js.map +1 -0
- package/dist/docx/compare/parts.d.ts +40 -0
- package/dist/docx/compare/parts.d.ts.map +1 -0
- package/dist/docx/compare/parts.js +113 -0
- package/dist/docx/compare/parts.js.map +1 -0
- package/dist/docx/compare/tally.d.ts +23 -0
- package/dist/docx/compare/tally.d.ts.map +1 -0
- package/dist/docx/compare/tally.js +94 -0
- package/dist/docx/compare/tally.js.map +1 -0
- package/dist/docx/compare/types.d.ts +55 -0
- package/dist/docx/compare/types.d.ts.map +1 -0
- package/dist/docx/compare/types.js +2 -0
- package/dist/docx/compare/types.js.map +1 -0
- package/dist/docx/compare/values.d.ts +13 -0
- package/dist/docx/compare/values.d.ts.map +1 -0
- package/dist/docx/compare/values.js +44 -0
- package/dist/docx/compare/values.js.map +1 -0
- package/dist/docx/import-docx.d.ts.map +1 -1
- package/dist/docx/import-docx.js +65 -6
- package/dist/docx/import-docx.js.map +1 -1
- package/dist/docx/postprocess/strip-empty-paragraphs.d.ts +3 -0
- package/dist/docx/postprocess/strip-empty-paragraphs.d.ts.map +1 -1
- package/dist/docx/postprocess/strip-empty-paragraphs.js +7 -1
- package/dist/docx/postprocess/strip-empty-paragraphs.js.map +1 -1
- package/dist/docx/postprocess/types.d.ts +1 -1
- package/dist/docx/postprocess/types.d.ts.map +1 -1
- package/dist/docx/preprocess/variables.d.ts.map +1 -1
- package/dist/docx/preprocess/variables.js +2 -2
- package/dist/docx/preprocess/variables.js.map +1 -1
- package/dist/docx/preprocess/xml-utils.d.ts +7 -0
- package/dist/docx/preprocess/xml-utils.d.ts.map +1 -1
- package/dist/docx/preprocess/xml-utils.js +9 -0
- package/dist/docx/preprocess/xml-utils.js.map +1 -1
- package/dist/docx/reader/headers.d.ts +17 -0
- package/dist/docx/reader/headers.d.ts.map +1 -0
- package/dist/docx/reader/headers.js +64 -0
- package/dist/docx/reader/headers.js.map +1 -0
- package/dist/docx/reader/html.d.ts +12 -0
- package/dist/docx/reader/html.d.ts.map +1 -0
- package/dist/docx/reader/html.js +27 -0
- package/dist/docx/reader/html.js.map +1 -0
- package/dist/docx/reader/images.d.ts +27 -0
- package/dist/docx/reader/images.d.ts.map +1 -0
- package/dist/docx/reader/images.js +288 -0
- package/dist/docx/reader/images.js.map +1 -0
- package/dist/docx/reader/index.d.ts +10 -0
- package/dist/docx/reader/index.d.ts.map +1 -0
- package/dist/docx/reader/index.js +177 -0
- package/dist/docx/reader/index.js.map +1 -0
- package/dist/docx/reader/lists.d.ts +44 -0
- package/dist/docx/reader/lists.d.ts.map +1 -0
- package/dist/docx/reader/lists.js +360 -0
- package/dist/docx/reader/lists.js.map +1 -0
- package/dist/docx/reader/lost.d.ts +30 -0
- package/dist/docx/reader/lost.d.ts.map +1 -0
- package/dist/docx/reader/lost.js +215 -0
- package/dist/docx/reader/lost.js.map +1 -0
- package/dist/docx/reader/notes.d.ts +4 -0
- package/dist/docx/reader/notes.d.ts.map +1 -0
- package/dist/docx/reader/notes.js +112 -0
- package/dist/docx/reader/notes.js.map +1 -0
- package/dist/docx/reader/package.d.ts +16 -0
- package/dist/docx/reader/package.d.ts.map +1 -0
- package/dist/docx/reader/package.js +138 -0
- package/dist/docx/reader/package.js.map +1 -0
- package/dist/docx/reader/paragraphs.d.ts +15 -0
- package/dist/docx/reader/paragraphs.d.ts.map +1 -0
- package/dist/docx/reader/paragraphs.js +162 -0
- package/dist/docx/reader/paragraphs.js.map +1 -0
- package/dist/docx/reader/properties.d.ts +90 -0
- package/dist/docx/reader/properties.d.ts.map +1 -0
- package/dist/docx/reader/properties.js +402 -0
- package/dist/docx/reader/properties.js.map +1 -0
- package/dist/docx/reader/runs.d.ts +49 -0
- package/dist/docx/reader/runs.d.ts.map +1 -0
- package/dist/docx/reader/runs.js +442 -0
- package/dist/docx/reader/runs.js.map +1 -0
- package/dist/docx/reader/sections.d.ts +36 -0
- package/dist/docx/reader/sections.d.ts.map +1 -0
- package/dist/docx/reader/sections.js +158 -0
- package/dist/docx/reader/sections.js.map +1 -0
- package/dist/docx/reader/styles.d.ts +24 -0
- package/dist/docx/reader/styles.d.ts.map +1 -0
- package/dist/docx/reader/styles.js +383 -0
- package/dist/docx/reader/styles.js.map +1 -0
- package/dist/docx/reader/tables.d.ts +6 -0
- package/dist/docx/reader/tables.d.ts.map +1 -0
- package/dist/docx/reader/tables.js +175 -0
- package/dist/docx/reader/tables.js.map +1 -0
- package/dist/docx/reader/test-support.d.ts +25 -0
- package/dist/docx/reader/test-support.d.ts.map +1 -0
- package/dist/docx/reader/test-support.js +135 -0
- package/dist/docx/reader/test-support.js.map +1 -0
- package/dist/docx/reader/testing-blocks.d.ts +50 -0
- package/dist/docx/reader/testing-blocks.d.ts.map +1 -0
- package/dist/docx/reader/testing-blocks.js +302 -0
- package/dist/docx/reader/testing-blocks.js.map +1 -0
- package/dist/docx/reader/types.d.ts +181 -0
- package/dist/docx/reader/types.d.ts.map +1 -0
- package/dist/docx/reader/types.js +2 -0
- package/dist/docx/reader/types.js.map +1 -0
- package/dist/docx/reader/units-blocks.d.ts +75 -0
- package/dist/docx/reader/units-blocks.d.ts.map +1 -0
- package/dist/docx/reader/units-blocks.js +254 -0
- package/dist/docx/reader/units-blocks.js.map +1 -0
- package/dist/docx/reader/units.d.ts +72 -0
- package/dist/docx/reader/units.d.ts.map +1 -0
- package/dist/docx/reader/units.js +177 -0
- package/dist/docx/reader/units.js.map +1 -0
- package/dist/docx/types.d.ts +47 -2
- package/dist/docx/types.d.ts.map +1 -1
- package/dist/docx/writer/content-types.d.ts +30 -0
- package/dist/docx/writer/content-types.d.ts.map +1 -0
- package/dist/docx/writer/content-types.js +81 -0
- package/dist/docx/writer/content-types.js.map +1 -0
- package/dist/docx/writer/core-properties.d.ts +16 -0
- package/dist/docx/writer/core-properties.d.ts.map +1 -0
- package/dist/docx/writer/core-properties.js +64 -0
- package/dist/docx/writer/core-properties.js.map +1 -0
- package/dist/docx/writer/footnotes-merge.d.ts +30 -0
- package/dist/docx/writer/footnotes-merge.d.ts.map +1 -0
- package/dist/docx/writer/footnotes-merge.js +71 -0
- package/dist/docx/writer/footnotes-merge.js.map +1 -0
- package/dist/docx/writer/graft.d.ts +41 -0
- package/dist/docx/writer/graft.d.ts.map +1 -0
- package/dist/docx/writer/graft.js +277 -0
- package/dist/docx/writer/graft.js.map +1 -0
- package/dist/docx/writer/header-footer-graft.d.ts +34 -0
- package/dist/docx/writer/header-footer-graft.d.ts.map +1 -0
- package/dist/docx/writer/header-footer-graft.js +155 -0
- package/dist/docx/writer/header-footer-graft.js.map +1 -0
- package/dist/docx/writer/header-footer-variables.d.ts +25 -0
- package/dist/docx/writer/header-footer-variables.d.ts.map +1 -0
- package/dist/docx/writer/header-footer-variables.js +101 -0
- package/dist/docx/writer/header-footer-variables.js.map +1 -0
- package/dist/docx/writer/media.d.ts +32 -0
- package/dist/docx/writer/media.d.ts.map +1 -0
- package/dist/docx/writer/media.js +88 -0
- package/dist/docx/writer/media.js.map +1 -0
- package/dist/docx/writer/numbering-merge.d.ts +37 -0
- package/dist/docx/writer/numbering-merge.d.ts.map +1 -0
- package/dist/docx/writer/numbering-merge.js +140 -0
- package/dist/docx/writer/numbering-merge.js.map +1 -0
- package/dist/docx/writer/relationships.d.ts +63 -0
- package/dist/docx/writer/relationships.d.ts.map +1 -0
- package/dist/docx/writer/relationships.js +127 -0
- package/dist/docx/writer/relationships.js.map +1 -0
- package/dist/docx/writer/settings-merge.d.ts +21 -0
- package/dist/docx/writer/settings-merge.d.ts.map +1 -0
- package/dist/docx/writer/settings-merge.js +165 -0
- package/dist/docx/writer/settings-merge.js.map +1 -0
- package/dist/docx/writer/style-reconcile.d.ts +29 -0
- package/dist/docx/writer/style-reconcile.d.ts.map +1 -0
- package/dist/docx/writer/style-reconcile.js +319 -0
- package/dist/docx/writer/style-reconcile.js.map +1 -0
- package/dist/docx/writer/style-strip.d.ts +33 -0
- package/dist/docx/writer/style-strip.d.ts.map +1 -0
- package/dist/docx/writer/style-strip.js +267 -0
- package/dist/docx/writer/style-strip.js.map +1 -0
- package/dist/docx/writer/styles-merge.d.ts +57 -0
- package/dist/docx/writer/styles-merge.d.ts.map +1 -0
- package/dist/docx/writer/styles-merge.js +184 -0
- package/dist/docx/writer/styles-merge.js.map +1 -0
- package/dist/docx/writer/template.d.ts +48 -0
- package/dist/docx/writer/template.d.ts.map +1 -0
- package/dist/docx/writer/template.js +280 -0
- package/dist/docx/writer/template.js.map +1 -0
- package/dist/docx/writer/testing.d.ts +52 -0
- package/dist/docx/writer/testing.d.ts.map +1 -0
- package/dist/docx/writer/testing.js +318 -0
- package/dist/docx/writer/testing.js.map +1 -0
- package/dist/docx/writer/xml-io.d.ts +90 -0
- package/dist/docx/writer/xml-io.d.ts.map +1 -0
- package/dist/docx/writer/xml-io.js +215 -0
- package/dist/docx/writer/xml-io.js.map +1 -0
- package/dist/export/blocks.d.ts.map +1 -1
- package/dist/export/blocks.js +149 -12
- package/dist/export/blocks.js.map +1 -1
- package/dist/export/context.d.ts +34 -2
- package/dist/export/context.d.ts.map +1 -1
- package/dist/export/context.js +28 -2
- package/dist/export/context.js.map +1 -1
- package/dist/export/css.d.ts +58 -0
- package/dist/export/css.d.ts.map +1 -1
- package/dist/export/css.js +194 -0
- package/dist/export/css.js.map +1 -1
- package/dist/export/dom.d.ts +2 -0
- package/dist/export/dom.d.ts.map +1 -1
- package/dist/export/dom.js +2 -0
- package/dist/export/dom.js.map +1 -1
- package/dist/export/export-docx.d.ts +4 -0
- package/dist/export/export-docx.d.ts.map +1 -1
- package/dist/export/export-docx.js +57 -4
- package/dist/export/export-docx.js.map +1 -1
- package/dist/export/header-footer.d.ts +15 -1
- package/dist/export/header-footer.d.ts.map +1 -1
- package/dist/export/header-footer.js +37 -0
- package/dist/export/header-footer.js.map +1 -1
- package/dist/export/html-to-docx.d.ts +20 -2
- package/dist/export/html-to-docx.d.ts.map +1 -1
- package/dist/export/html-to-docx.js +40 -14
- package/dist/export/html-to-docx.js.map +1 -1
- package/dist/export/inline.d.ts +25 -3
- package/dist/export/inline.d.ts.map +1 -1
- package/dist/export/inline.js +91 -34
- package/dist/export/inline.js.map +1 -1
- package/dist/export/styles.d.ts +51 -7
- package/dist/export/styles.d.ts.map +1 -1
- package/dist/export/styles.js +121 -16
- package/dist/export/styles.js.map +1 -1
- package/dist/export/tables.d.ts.map +1 -1
- package/dist/export/tables.js +140 -12
- package/dist/export/tables.js.map +1 -1
- package/dist/export/types.d.ts +44 -5
- package/dist/export/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { importDocx } from '../import-docx';
|
|
2
|
+
import { createNumberingResolver } from '../reader/lists';
|
|
3
|
+
import { defaultXmlParse, openPackage, relsPathOf } from '../reader/package';
|
|
4
|
+
import { createStyleResolver } from '../reader/styles';
|
|
5
|
+
import { compareBlocks, headerFooterSummary, sameFields, } from './compare-blocks';
|
|
6
|
+
import { readDocumentModel } from './model';
|
|
7
|
+
import { compareParts, listParts } from './parts';
|
|
8
|
+
import { computeScore, Tally } from './tally';
|
|
9
|
+
import { ABSENT, fmt } from './values';
|
|
10
|
+
/**
|
|
11
|
+
* `compareDocx(original, result, options)` : ouvre les deux paquets, compare les parties
|
|
12
|
+
* annexes à l'octet, aligne les blocs des deux corps et compare leurs propriétés résolues
|
|
13
|
+
* (styles, docDefaults et thème de chaque document), puis les sections avec leurs en-têtes
|
|
14
|
+
* et pieds. Le score est la moyenne pondérée par groupe (`tally.ts`). Les objets non
|
|
15
|
+
* représentables sont ceux que `importDocx` (chemin stylé) signale pour chaque document.
|
|
16
|
+
*/
|
|
17
|
+
const HEADER_FOOTER_TYPES = ['default', 'first', 'even'];
|
|
18
|
+
const NOTES = [
|
|
19
|
+
'Une propriété est comptée quand au moins un des deux documents la pose ; une valeur ajoutée par le résultat compte comme perdue, une valeur absente des deux côtés ne compte pas. Les défauts de Word (alignement à gauche, espacement ou retrait nul, interligne simple, orientation portrait, une seule colonne) valent « absent ».',
|
|
20
|
+
'Les propriétés de paragraphe et de run sont résolues (docDefaults, thème, styles) dans chacun des deux documents, sans le style de tableau : les styles conditionnels de tableau (première ligne, bandes) ne sont pas comparés.',
|
|
21
|
+
'Images : nombre et dimensions (±1 px) seulement ; habillage, position des images ancrées et octets des médias (couverts par les parties du paquet) ne sont pas comparés.',
|
|
22
|
+
'Tableaux : bordures effectives telles que Word les rend (style de tableau, puis `w:tblBorders` selon la position de la cellule dans la grille, puis `w:tcBorders`, `nil` efface) ; côté tableau seules les bordures extérieures sont comparées. Largeur de cellule effective (`w:tcW`, sinon les colonnes de grille couvertes) ; largeurs de colonnes et de cellules à ±0,5 pt.',
|
|
23
|
+
'Saut de page explicite (`w:br w:type="page"`) : frontière de bloc, pas un caractère ; le paragraphe qui le précède porte `paragraph.pageBreakAfter`, un paragraphe réduit au saut se replie sur le précédent.',
|
|
24
|
+
'Champs de fusion (`MERGEFIELD` simple ou complexe) : modélisés par leur nom brut et leur résultat ; le texte du paragraphe inclut le résultat affiché par Word, `field.mergeField` compare la liste ordonnée des noms bruts (`"Nom Client"`, `nom_client` et `"NOM CLIENT"` sont trois champs distincts), et un `{{nom}}` en clair vaut un champ dont le nom normalisé est le même. Autres champs (page, date…) : seul le texte de résultat est comparé. Tabulations comparées comme caractère, taquets ignorés.',
|
|
25
|
+
'Révisions : le texte inséré est lu, le texte supprimé ignoré ; commentaires, signets, `w:proofErr` et `w:lastRenderedPageBreak` ne sont jamais comparés.',
|
|
26
|
+
];
|
|
27
|
+
/** Détection d’`ArrayBuffer` robuste aux realms (jsdom vs Node). */
|
|
28
|
+
function isArrayBuffer(input) {
|
|
29
|
+
return Object.prototype.toString.call(input) === '[object ArrayBuffer]';
|
|
30
|
+
}
|
|
31
|
+
async function toArrayBuffer(input, label) {
|
|
32
|
+
if (isArrayBuffer(input))
|
|
33
|
+
return input;
|
|
34
|
+
if (ArrayBuffer.isView(input)) {
|
|
35
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength).slice().buffer;
|
|
36
|
+
}
|
|
37
|
+
if (input && typeof input.arrayBuffer === 'function') {
|
|
38
|
+
return input.arrayBuffer();
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`compareDocx : ${label} doit être un File, un ArrayBuffer ou une vue typée`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Erreur typée pour les entrées illisibles, même nom et même préfixe de message que
|
|
44
|
+
* l'import (`DocxImportError`, `invalid-docx: …`, non exportés par `import-docx.ts`) : un
|
|
45
|
+
* intégrateur distingue un document hostile d'un bug du comparateur (R30-12).
|
|
46
|
+
*/
|
|
47
|
+
function invalidDocx(label, detail) {
|
|
48
|
+
const error = new Error(`invalid-docx: ${label} : ${detail}`);
|
|
49
|
+
error.name = 'DocxImportError';
|
|
50
|
+
return error;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ouvre un paquet et lit son modèle. Un zip sans partie principale, des octets qui ne sont
|
|
54
|
+
* pas un zip ou un XML illisible rejettent en `DocxImportError`, jamais une erreur JSZip
|
|
55
|
+
* ou `Error` nue.
|
|
56
|
+
*/
|
|
57
|
+
async function open(buffer, label) {
|
|
58
|
+
try {
|
|
59
|
+
const pkg = await openPackage(buffer, defaultXmlParse());
|
|
60
|
+
const [styles, numbering] = await Promise.all([
|
|
61
|
+
createStyleResolver(pkg),
|
|
62
|
+
createNumberingResolver(pkg),
|
|
63
|
+
]);
|
|
64
|
+
const model = await readDocumentModel(pkg, styles, numbering);
|
|
65
|
+
return { buffer, pkg, styles, numbering, model };
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw invalidDocx(label, error instanceof Error ? error.message : String(error));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function compareSections(a, b, ctx) {
|
|
72
|
+
const { tally } = ctx;
|
|
73
|
+
if (a.lang !== undefined || b.lang !== undefined) {
|
|
74
|
+
tally.record('section', 'section.lang', 'document', fmt(a.lang), fmt(b.lang));
|
|
75
|
+
}
|
|
76
|
+
tally.record('section', 'section.count', 'document', String(a.sections.length), String(b.sections.length));
|
|
77
|
+
a.sections.forEach((section, index) => {
|
|
78
|
+
const other = b.sections[index];
|
|
79
|
+
const where = `section ${String(index + 1)}`;
|
|
80
|
+
const record = (name, expected, actual) => {
|
|
81
|
+
if (expected === undefined && actual === undefined)
|
|
82
|
+
return;
|
|
83
|
+
tally.record('section', name, where, fmt(expected), other ? fmt(actual) : ABSENT);
|
|
84
|
+
};
|
|
85
|
+
record('section.type', section.type, other?.type);
|
|
86
|
+
record('section.pgSz', section.pageSize, other?.pageSize);
|
|
87
|
+
record('section.pgMar', section.margins, other?.margins);
|
|
88
|
+
record('section.cols', section.columns, other?.columns);
|
|
89
|
+
tally.record('section', 'section.titlePg', where, String(section.titlePage), other ? String(other.titlePage) : ABSENT);
|
|
90
|
+
for (const kind of ['header', 'footer']) {
|
|
91
|
+
const mine = kind === 'header' ? section.headers : section.footers;
|
|
92
|
+
const theirs = kind === 'header' ? other?.headers : other?.footers;
|
|
93
|
+
for (const type of HEADER_FOOTER_TYPES) {
|
|
94
|
+
const part = mine[type];
|
|
95
|
+
const otherPart = theirs?.[type];
|
|
96
|
+
if (!part && !otherPart)
|
|
97
|
+
continue;
|
|
98
|
+
const partWhere = `${where} ${kind === 'header' ? 'en-tête' : 'pied'} ${type}`;
|
|
99
|
+
const expected = part ? headerFooterSummary(part) : undefined;
|
|
100
|
+
const actual = otherPart ? headerFooterSummary(otherPart) : undefined;
|
|
101
|
+
// Même tolérance que pour le corps : `{{nom}}` en clair vaut un champ de fusion de
|
|
102
|
+
// même nom normalisé ; deux vrais champs ne valent que par leur nom brut.
|
|
103
|
+
const sameText = expected !== undefined &&
|
|
104
|
+
actual !== undefined &&
|
|
105
|
+
expected.placeholderText === actual.placeholderText &&
|
|
106
|
+
sameFields(expected.fields, actual.fields);
|
|
107
|
+
tally.record('header-footer', `${kind}.${type}.text`, partWhere, expected?.text ?? ABSENT, sameText ? expected.text : (actual?.text ?? ABSENT));
|
|
108
|
+
tally.record('header-footer', `${kind}.${type}.format`, partWhere, expected?.format ?? ABSENT, actual?.format ?? ABSENT);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function sameLost(a, b) {
|
|
114
|
+
return a.kind === b.kind && a.where === b.where && a.detail === b.detail && a.text === b.text;
|
|
115
|
+
}
|
|
116
|
+
/** Objets non représentables des deux documents, dédoublonnés ; un import qui échoue n'en ajoute aucun. */
|
|
117
|
+
async function collectLost(buffers) {
|
|
118
|
+
const lost = [];
|
|
119
|
+
for (const buffer of buffers) {
|
|
120
|
+
let found;
|
|
121
|
+
try {
|
|
122
|
+
found = (await importDocx(buffer, { fidelity: 'styled' })).lost;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
found = [];
|
|
126
|
+
}
|
|
127
|
+
for (const item of found)
|
|
128
|
+
if (!lost.some((known) => sameLost(known, item)))
|
|
129
|
+
lost.push(item);
|
|
130
|
+
}
|
|
131
|
+
return lost;
|
|
132
|
+
}
|
|
133
|
+
/** Compare un `.docx` d'origine et un résultat, propriété par propriété. Signature figée (`CompareDocx`). */
|
|
134
|
+
export const compareDocx = async (original, result, options = {}) => {
|
|
135
|
+
const ignoreRevisionIds = options.ignoreRevisionIds !== false;
|
|
136
|
+
const [a, b] = await Promise.all([
|
|
137
|
+
toArrayBuffer(original, "l'original").then((buffer) => open(buffer, "l'original")),
|
|
138
|
+
toArrayBuffer(result, 'le résultat').then((buffer) => open(buffer, 'le résultat')),
|
|
139
|
+
]);
|
|
140
|
+
const tally = new Tally();
|
|
141
|
+
const ctx = { tally, ignoreRevisionIds };
|
|
142
|
+
const excluded = new Set([
|
|
143
|
+
a.pkg.mainPart,
|
|
144
|
+
relsPathOf(a.pkg.mainPart),
|
|
145
|
+
'docProps/core.xml',
|
|
146
|
+
'docProps/app.xml',
|
|
147
|
+
]);
|
|
148
|
+
const parts = compareParts(await listParts(a.buffer), await listParts(b.buffer), {
|
|
149
|
+
prefixes: options.binaryParts,
|
|
150
|
+
excluded,
|
|
151
|
+
ignoreRevisionIds,
|
|
152
|
+
parseXml: defaultXmlParse(),
|
|
153
|
+
});
|
|
154
|
+
for (const { path, kept, summary } of parts.compared) {
|
|
155
|
+
tally.record('package-part', `part:${path}`, path, 'identique', kept ? 'identique' : summary);
|
|
156
|
+
}
|
|
157
|
+
compareBlocks(a.model.blocks, b.model.blocks, '', ctx);
|
|
158
|
+
compareSections(a.model, b.model, ctx);
|
|
159
|
+
const properties = tally.properties();
|
|
160
|
+
const notes = [...NOTES];
|
|
161
|
+
if (a.model.sections.length !== b.model.sections.length) {
|
|
162
|
+
notes.push(`Nombre de sections différent (${String(a.model.sections.length)} → ${String(b.model.sections.length)}) : les sections sont alignées par position.`);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
score: computeScore(properties),
|
|
166
|
+
properties,
|
|
167
|
+
identicalParts: parts.identical,
|
|
168
|
+
changedParts: parts.changed,
|
|
169
|
+
lost: await collectLost([a.buffer, b.buffer]),
|
|
170
|
+
notes,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=compare-docx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-docx.js","sourceRoot":"","sources":["../../../src/docx/compare/compare-docx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,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,cAAc,EAAE,QAAQ,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAChG,CAAC;IAED,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IACvD,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IACzB,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CACR,iCAAiC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,8CAA8C,CACpJ,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC;QAC/B,UAAU;QACV,cAAc,EAAE,KAAK,CAAC,SAAS;QAC/B,YAAY,EAAE,KAAK,CAAC,OAAO;QAC3B,IAAI,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7C,KAAK;KACN,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CompareContext } from './compare-context';
|
|
2
|
+
import type { BlockModel, TableModel } from './model';
|
|
3
|
+
/**
|
|
4
|
+
* Comparaison d'un tableau et de ses cellules : dimensions, style, largeur, alignement,
|
|
5
|
+
* bordures extérieures effectives, largeurs de colonnes (±0,5 pt), fusions, puis chaque
|
|
6
|
+
* cellule (bordures effectives, fond, largeur ±0,5 pt, alignement vertical) et ses blocs,
|
|
7
|
+
* comparés par le comparateur de blocs injecté pour ne pas créer de cycle d'imports.
|
|
8
|
+
*/
|
|
9
|
+
/** Comparateur de blocs injecté par `compare-blocks.ts`. */
|
|
10
|
+
export type BlockComparer = (original: readonly BlockModel[], result: readonly BlockModel[], prefix: string, ctx: CompareContext) => void;
|
|
11
|
+
/** Compare un tableau de l'original à son vis-à-vis (absent = tout perdu). */
|
|
12
|
+
export declare function compareTable(a: TableModel, b: TableModel | undefined, where: string, ctx: CompareContext, compareBlocks: BlockComparer): void;
|
|
13
|
+
//# sourceMappingURL=compare-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-tables.d.ts","sourceRoot":"","sources":["../../../src/docx/compare/compare-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjE;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,CAC1B,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,cAAc,KAChB,IAAI,CAAC;AAiDV,8EAA8E;AAC9E,wBAAgB,YAAY,CAC1B,CAAC,EAAE,UAAU,EACb,CAAC,EAAE,UAAU,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,cAAc,EACnB,aAAa,EAAE,aAAa,GAC3B,IAAI,CAmDN"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { MISSING, recordIfAny, recordWithin, WIDTH_TOLERANCE_PT, } from './compare-context';
|
|
2
|
+
import { fmt } from './values';
|
|
3
|
+
/** Fusions non triviales d'un tableau : `(ligne,colonne):gridSpan/vMerge`. */
|
|
4
|
+
function merges(table) {
|
|
5
|
+
const out = [];
|
|
6
|
+
table.rows.forEach((row, r) => {
|
|
7
|
+
row.forEach((cell, c) => {
|
|
8
|
+
if (cell.colspan > 1 || cell.vMerge) {
|
|
9
|
+
out.push(`(${String(r + 1)},${String(c + 1)}):${String(cell.colspan)}/${cell.vMerge ?? '-'}`);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
function compareCell(a, b, where, ctx, compareBlocks) {
|
|
16
|
+
const present = b !== undefined;
|
|
17
|
+
recordIfAny(ctx, 'table', 'table.cellBorders', where, a.borders, b?.borders, present);
|
|
18
|
+
recordIfAny(ctx, 'table', 'table.cellShading', where, a.shading, b?.shading, present);
|
|
19
|
+
recordWithin(ctx, 'table', 'table.cellWidth', where, a.widthPt, b?.widthPt, present, WIDTH_TOLERANCE_PT);
|
|
20
|
+
recordIfAny(ctx, 'table', 'table.cellVerticalAlign', where, a.verticalAlign, b?.verticalAlign, present);
|
|
21
|
+
compareBlocks(a.blocks, b?.blocks ?? [], where, ctx);
|
|
22
|
+
}
|
|
23
|
+
/** Compare un tableau de l'original à son vis-à-vis (absent = tout perdu). */
|
|
24
|
+
export function compareTable(a, b, where, ctx, compareBlocks) {
|
|
25
|
+
// Boucle plutôt que `Math.max(...spread)` : au-delà de ≈ 125 000 lignes, la pile d'appels débordait (R30-07).
|
|
26
|
+
const columns = (table) => table.rows.reduce((max, row) => Math.max(max, row.reduce((sum, cell) => sum + cell.colspan, 0)), 0);
|
|
27
|
+
const present = b !== undefined;
|
|
28
|
+
ctx.tally.record('table', 'table.rows', where, String(a.rows.length), b ? String(b.rows.length) : MISSING);
|
|
29
|
+
ctx.tally.record('table', 'table.columns', where, String(columns(a)), b ? String(columns(b)) : MISSING);
|
|
30
|
+
recordIfAny(ctx, 'table', 'table.style', where, a.styleId, b?.styleId, present);
|
|
31
|
+
recordIfAny(ctx, 'table', 'table.width', where, a.width, b?.width, present);
|
|
32
|
+
recordIfAny(ctx, 'table', 'table.align', where, a.align, b?.align, present);
|
|
33
|
+
recordIfAny(ctx, 'table', 'table.borders', where, a.borders, b?.borders, present);
|
|
34
|
+
recordWithin(ctx, 'table', 'table.columnWidths', where, a.columnWidthsPt, b?.columnWidthsPt, present, WIDTH_TOLERANCE_PT);
|
|
35
|
+
const mergesA = merges(a);
|
|
36
|
+
const mergesB = b ? merges(b) : [];
|
|
37
|
+
if (mergesA.length > 0 || mergesB.length > 0) {
|
|
38
|
+
ctx.tally.record('table', 'table.merges', where, fmt(mergesA), b ? fmt(mergesB) : MISSING);
|
|
39
|
+
}
|
|
40
|
+
a.rows.forEach((row, r) => {
|
|
41
|
+
row.forEach((cell, c) => {
|
|
42
|
+
const cellWhere = `${where} cellule (${String(r + 1)},${String(c + 1)})`;
|
|
43
|
+
compareCell(cell, b?.rows[r]?.[c], cellWhere, ctx, compareBlocks);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=compare-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-tables.js","sourceRoot":"","sources":["../../../src/docx/compare/compare-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAiB/B,8EAA8E;AAC9E,SAAS,MAAM,CAAC,KAAiB;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC5B,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACtB,IAAI,IAAI,CAAC,OAAO,GA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|
1
|
+
import type { BlockBorder } from '@aster-editor/core';
|
|
2
|
+
import type { TableStyleProps } from '../reader/types';
|
|
3
|
+
import { type BorderMap } from '../reader/units-blocks';
|
|
4
|
+
/**
|
|
5
|
+
* Bordures **effectives** d'un tableau et de ses cellules, telles que Word les rend : style
|
|
6
|
+
* de tableau, puis `w:tblBorders` (côtés extérieurs sur les cellules du bord, `insideH` /
|
|
7
|
+
* `insideV` ailleurs), puis `w:tcBorders` ; `nil` efface. Un côté sans bordure visible est
|
|
8
|
+
* omis, qu'il soit absent ou explicitement `nil` : deux documents qui distribuent les
|
|
9
|
+
* mêmes traits entre tableau et cellules se comparent égaux (L28c).
|
|
10
|
+
*/
|
|
11
|
+
/** Côtés d'une cellule ou d'un tableau (`between` n'existe que pour les paragraphes). */
|
|
12
|
+
export type CellSide = 'top' | 'right' | 'bottom' | 'left';
|
|
13
|
+
/** Bordures visibles par côté, sans `null` : l'absence vaut « pas de bordure ». */
|
|
14
|
+
export type EffectiveBorders = Partial<Record<CellSide, BlockBorder>>;
|
|
15
|
+
/** Position d'une cellule dans la grille : vrai pour chaque côté qui touche le bord du tableau. */
|
|
16
|
+
export type CellEdges = Readonly<Record<CellSide, boolean>>;
|
|
17
|
+
/** Bordures extérieures effectives du tableau : celles du style recouvertes par les directes. */
|
|
18
|
+
export declare function effectiveTableBorders(style: TableStyleProps | null, tblBorders: BorderMap): EffectiveBorders;
|
|
19
|
+
/**
|
|
20
|
+
* Bordures effectives d'une cellule. Le style de tableau est résolu par le lecteur en
|
|
21
|
+
* bordures extérieures et bordures de cellule (ses `insideH`/`insideV` ou ses `tcBorders`) :
|
|
22
|
+
* sur un bord, la bordure extérieure du style prime ; à l'intérieur, celle des cellules.
|
|
23
|
+
*/
|
|
24
|
+
export declare function effectiveCellBorders(style: TableStyleProps | null, tblBorders: BorderMap, tcBorders: BorderMap, edges: CellEdges): EffectiveBorders;
|
|
25
|
+
/** `undefined` quand aucun côté n'a de bordure, pour ne pas compter une propriété vide. */
|
|
26
|
+
export declare function nonEmptyBorders(borders: EffectiveBorders): EffectiveBorders | undefined;
|
|
27
|
+
//# sourceMappingURL=model-borders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-borders.d.ts","sourceRoot":"","sources":["../../../src/docx/compare/model-borders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjF;;;;;;GAMG;AAEH,yFAAyF;AACzF,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAI3D,mFAAmF;AACnF,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAEtE,mGAAmG;AACnG,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5D,iGAAiG;AACjG,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,UAAU,EAAE,SAAS,GACpB,gBAAgB,CASlB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,GAAG,IAAI,EAC7B,UAAU,EAAE,SAAS,EACrB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,SAAS,GACf,gBAAgB,CAclB;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,SAAS,CAEvF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { bordersBySide, withSide } from '../reader/units-blocks';
|
|
2
|
+
const CELL_SIDES = ['top', 'right', 'bottom', 'left'];
|
|
3
|
+
/** Bordures extérieures effectives du tableau : celles du style recouvertes par les directes. */
|
|
4
|
+
export function effectiveTableBorders(style, tblBorders) {
|
|
5
|
+
const fromStyle = bordersBySide(style?.borders);
|
|
6
|
+
const out = {};
|
|
7
|
+
for (const side of CELL_SIDES) {
|
|
8
|
+
const direct = tblBorders[side];
|
|
9
|
+
const border = direct === undefined ? fromStyle[side] : direct;
|
|
10
|
+
if (border)
|
|
11
|
+
out[side] = withSide(border, side);
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bordures effectives d'une cellule. Le style de tableau est résolu par le lecteur en
|
|
17
|
+
* bordures extérieures et bordures de cellule (ses `insideH`/`insideV` ou ses `tcBorders`) :
|
|
18
|
+
* sur un bord, la bordure extérieure du style prime ; à l'intérieur, celle des cellules.
|
|
19
|
+
*/
|
|
20
|
+
export function effectiveCellBorders(style, tblBorders, tcBorders, edges) {
|
|
21
|
+
const styleOuter = bordersBySide(style?.borders);
|
|
22
|
+
const styleCells = bordersBySide(style?.cellBorders);
|
|
23
|
+
const out = {};
|
|
24
|
+
for (const side of CELL_SIDES) {
|
|
25
|
+
const edge = edges[side];
|
|
26
|
+
const inside = side === 'top' || side === 'bottom' ? 'insideH' : 'insideV';
|
|
27
|
+
let border = tcBorders[side];
|
|
28
|
+
if (border === undefined)
|
|
29
|
+
border = edge ? tblBorders[side] : tblBorders[inside];
|
|
30
|
+
if (border === undefined)
|
|
31
|
+
border = edge ? (styleOuter[side] ?? styleCells[side]) : styleCells[side];
|
|
32
|
+
if (border)
|
|
33
|
+
out[side] = withSide(border, side);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** `undefined` quand aucun côté n'a de bordure, pour ne pas compter une propriété vide. */
|
|
38
|
+
export function nonEmptyBorders(borders) {
|
|
39
|
+
return Object.keys(borders).length > 0 ? borders : undefined;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=model-borders.js.map
|
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AAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3E,IAAI,MAAM,GAAmC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChF,IAAI,MAAM,KAAK,SAAS;YACtB,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5E,IAAI,MAAM;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,eAAe,CAAC,OAAyB;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FieldModel, ModelContext, ParagraphModel } from './model';
|
|
2
|
+
/** Nom brut et nom normalisé d'une instruction `MERGEFIELD`. */
|
|
3
|
+
interface MergeFieldName {
|
|
4
|
+
readonly raw: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Champs de fusion d'un texte canonique, dans l'ordre (`{{a}} … {{b}}` → `[a, b]`). Un
|
|
9
|
+
* `{{nom}}` qui commence à une position enregistrée dans `mergeFields` est un vrai champ
|
|
10
|
+
* (nom brut de l'instruction) ; tout autre est un `{{}}` en clair, dont le nom brut est
|
|
11
|
+
* l'intérieur des accolades et le nom normalisé celui des variables de l'import
|
|
12
|
+
* (`Numero Facture` → `numero_facture`), pour qu'il vaille le `MERGEFIELD` dont Aster l'a écrit.
|
|
13
|
+
*/
|
|
14
|
+
export declare function placeholderFields(placeholderText: string, mergeFields?: ReadonlyMap<number, MergeFieldName>): FieldModel[];
|
|
15
|
+
/**
|
|
16
|
+
* Lit un `w:p` : un paragraphe par segment séparé par un saut de page explicite. Le dernier
|
|
17
|
+
* segment, vide, est omis (« a<br page> » : Word ne rend rien après le saut) ; un paragraphe
|
|
18
|
+
* réduit à un saut donne un segment vide marqué `pageBreakAfter`, que `readBlocks` replie
|
|
19
|
+
* sur le paragraphe précédent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readParagraphs(p: Element, ctx: ModelContext): ParagraphModel[];
|
|
22
|
+
/** Vrai pour un paragraphe sans contenu visible : seul un saut de page le justifie. */
|
|
23
|
+
export declare function isBlankParagraph(paragraph: ParagraphModel): boolean;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=model-paragraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-paragraph.d.ts","sourceRoot":"","sources":["../../../src/docx/compare/model-paragraph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EAEZ,cAAc,EAEf,MAAM,SAAS,CAAC;AAyBjB,gEAAgE;AAChE,UAAU,cAAc;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AA+ED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,MAAM,EACvB,WAAW,GAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAa,GAC3D,UAAU,EAAE,CAad;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,cAAc,EAAE,CAiN9E;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAOnE"}
|