docxodus 8.0.0 → 9.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 +156 -31
- package/dist/editor-headerfooter.d.ts +39 -3
- package/dist/editor-headerfooter.d.ts.map +1 -1
- package/dist/editor-headerfooter.js +118 -2
- package/dist/editor-headerfooter.js.map +1 -1
- package/dist/editor-reconcile.d.ts +75 -0
- package/dist/editor-reconcile.d.ts.map +1 -0
- package/dist/editor-reconcile.js +125 -0
- package/dist/editor-reconcile.js.map +1 -0
- package/dist/editor.bundle.js +799 -42
- package/dist/editor.d.ts +121 -5
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +572 -31
- package/dist/editor.js.map +1 -1
- package/dist/embed.bundle.js +6569 -0
- package/dist/embed.d.ts +77 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.iife.js +6596 -0
- package/dist/embed.js +350 -0
- package/dist/embed.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/page-number-format.d.ts +22 -0
- package/dist/page-number-format.d.ts.map +1 -0
- package/dist/page-number-format.js +60 -0
- package/dist/page-number-format.js.map +1 -0
- package/dist/pagination.bundle.js +158 -21
- package/dist/pagination.d.ts +38 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +181 -29
- package/dist/pagination.js.map +1 -1
- package/dist/session.bundle.js +241 -4
- package/dist/session.d.ts +154 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +193 -4
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +192 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm +0 -0
- package/dist/wasm/_framework/DocumentFormat.OpenXml.Framework.wasm.br +0 -0
- package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm +0 -0
- package/dist/wasm/_framework/DocumentFormat.OpenXml.wasm.br +0 -0
- package/dist/wasm/_framework/Docxodus.wasm +0 -0
- package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.Concurrent.wasm +0 -0
- package/dist/wasm/_framework/System.Collections.Concurrent.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.Immutable.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.NonGeneric.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.Specialized.wasm.br +0 -0
- package/dist/wasm/_framework/System.Collections.wasm +0 -0
- package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
- package/dist/wasm/_framework/System.ComponentModel.Primitives.wasm.br +0 -0
- package/dist/wasm/_framework/System.ComponentModel.TypeConverter.wasm.br +0 -0
- package/dist/wasm/_framework/System.ComponentModel.wasm.br +0 -0
- package/dist/wasm/_framework/System.Console.wasm +0 -0
- package/dist/wasm/_framework/System.Console.wasm.br +0 -0
- package/dist/wasm/_framework/System.Diagnostics.Process.wasm +0 -0
- package/dist/wasm/_framework/System.Diagnostics.Process.wasm.br +0 -0
- package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
- package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
- package/dist/wasm/_framework/System.IO.Packaging.wasm +0 -0
- package/dist/wasm/_framework/System.IO.Packaging.wasm.br +0 -0
- package/dist/wasm/_framework/System.IO.Pipelines.wasm.br +0 -0
- package/dist/wasm/_framework/System.Linq.Expressions.wasm.br +0 -0
- package/dist/wasm/_framework/System.Linq.wasm +0 -0
- package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
- package/dist/wasm/_framework/System.Memory.wasm +0 -0
- package/dist/wasm/_framework/System.Memory.wasm.br +0 -0
- package/dist/wasm/_framework/System.Net.Http.wasm.br +0 -0
- package/dist/wasm/_framework/System.Net.Primitives.wasm.br +0 -0
- package/dist/wasm/_framework/System.ObjectModel.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.Uri.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
- package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.Xml.wasm +0 -0
- package/dist/wasm/_framework/System.Private.Xml.wasm.br +0 -0
- package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm.br +0 -0
- package/dist/wasm/_framework/System.Runtime.wasm +0 -0
- package/dist/wasm/_framework/System.Runtime.wasm.br +0 -0
- package/dist/wasm/_framework/System.Security.Cryptography.wasm.br +0 -0
- package/dist/wasm/_framework/System.Text.Encodings.Web.wasm.br +0 -0
- package/dist/wasm/_framework/System.Text.Json.wasm +0 -0
- package/dist/wasm/_framework/System.Text.Json.wasm.br +0 -0
- package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
- package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
- package/dist/wasm/_framework/System.Xml.Linq.wasm.br +0 -0
- package/dist/wasm/_framework/System.Xml.XDocument.wasm +0 -0
- package/dist/wasm/_framework/System.Xml.XDocument.wasm.br +0 -0
- package/dist/wasm/_framework/System.wasm.br +0 -0
- package/dist/wasm/_framework/dotnet.boot.js +22 -57
- package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
- package/dist/wasm/_framework/dotnet.js.br +0 -0
- package/dist/wasm/_framework/dotnet.native.js +0 -171
- package/dist/wasm/_framework/dotnet.native.js.br +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
- package/dist/wasm/_framework/dotnet.runtime.js.br +0 -0
- package/package.json +26 -5
- package/dist/wasm/_framework/System.Text.Encoding.Extensions.wasm +0 -0
- package/dist/wasm/_framework/System.Threading.Thread.wasm +0 -0
- package/dist/wasm/_framework/System.Threading.wasm +0 -0
- package/dist/wasm/_framework/System.Xml.ReaderWriter.wasm +0 -0
- package/dist/wasm/_framework/System.Xml.XPath.XDocument.wasm +0 -0
- package/dist/wasm/_framework/System.Xml.XPath.wasm +0 -0
- package/dist/wasm/_framework/dotnet.js.map +0 -1
- package/dist/wasm/_framework/dotnet.native.js.symbols +0 -5532
- package/dist/wasm/_framework/dotnet.runtime.js.map +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit-sequence diff for the editor's incremental structural repaint.
|
|
3
|
+
*
|
|
4
|
+
* After a structural op (insert table/row, footnote, delete block, undo/redo)
|
|
5
|
+
* the editor fetches the session's {@link RenderPlan} (`ListBlocks`) and diffs
|
|
6
|
+
* each container's unit sequence against the DOM's, so unchanged blocks keep
|
|
7
|
+
* their DOM nodes and only changed/created units re-render — replacing the
|
|
8
|
+
* whole-document remount that cost seconds on large documents.
|
|
9
|
+
*
|
|
10
|
+
* Pure functions only: DOM walking, rendering, and fallback policy live in
|
|
11
|
+
* `editor.ts` (`DocxEditor.reconcile`).
|
|
12
|
+
*/
|
|
13
|
+
/** The diff token for a unit: unid plus the container content signature. The DOM
|
|
14
|
+
* side composes the same token from a node's `data-anchor` + `data-render-sig`
|
|
15
|
+
* stamp, so a container whose inside changed diffs as an in-place substitution. */
|
|
16
|
+
export function tokenOf(unit) {
|
|
17
|
+
return unidOf(unit.id) + (unit.sig ? "|" + unit.sig : "");
|
|
18
|
+
}
|
|
19
|
+
/** unid ("a1b2…") from a full anchor id ("p:body:a1b2…"). */
|
|
20
|
+
export function unidOf(id) {
|
|
21
|
+
return id.substring(id.lastIndexOf(":") + 1);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* LCS diff of the DOM's unit-token sequence against the new plan's. Old entries
|
|
25
|
+
* are tokens (see {@link tokenOf} — bare unids for leaf blocks, `unid|sig` for
|
|
26
|
+
* containers). Equal tokens are interchangeable (content-addressed: equal token
|
|
27
|
+
* ⇒ equal content ⇒ equal rendering, up to position-dependent chrome the caller
|
|
28
|
+
* handles). O(n·m) — sequences are document block counts, a few hundred.
|
|
29
|
+
*/
|
|
30
|
+
export function diffUnits(oldUnids, newUnits) {
|
|
31
|
+
const n = oldUnids.length;
|
|
32
|
+
const m = newUnits.length;
|
|
33
|
+
const newUnids = newUnits.map(tokenOf);
|
|
34
|
+
// lcs[i][j] = LCS length of oldUnids[i..] vs newUnids[j..]
|
|
35
|
+
const lcs = Array.from({ length: n + 1 }, () => new Int32Array(m + 1));
|
|
36
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
37
|
+
for (let j = m - 1; j >= 0; j--) {
|
|
38
|
+
lcs[i][j] =
|
|
39
|
+
oldUnids[i] === newUnids[j]
|
|
40
|
+
? lcs[i + 1][j + 1] + 1
|
|
41
|
+
: Math.max(lcs[i + 1][j], lcs[i][j + 1]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const keep = new Map();
|
|
45
|
+
const removed = [];
|
|
46
|
+
const added = [];
|
|
47
|
+
let i = 0;
|
|
48
|
+
let j = 0;
|
|
49
|
+
while (i < n && j < m) {
|
|
50
|
+
if (oldUnids[i] === newUnids[j]) {
|
|
51
|
+
keep.set(j, i);
|
|
52
|
+
i++;
|
|
53
|
+
j++;
|
|
54
|
+
}
|
|
55
|
+
else if (lcs[i + 1][j] >= lcs[i][j + 1]) {
|
|
56
|
+
removed.push(i++);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
added.push(j++);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
while (i < n)
|
|
63
|
+
removed.push(i++);
|
|
64
|
+
while (j < m)
|
|
65
|
+
added.push(j++);
|
|
66
|
+
// Substitutions: an added index and a removed index with the same number of
|
|
67
|
+
// kept units before them — an in-place change of one unit.
|
|
68
|
+
const keptBeforeOld = (oi) => {
|
|
69
|
+
let c = 0;
|
|
70
|
+
for (const v of keep.values())
|
|
71
|
+
if (v < oi)
|
|
72
|
+
c++;
|
|
73
|
+
return c;
|
|
74
|
+
};
|
|
75
|
+
const keptBeforeNew = (nj) => {
|
|
76
|
+
let c = 0;
|
|
77
|
+
for (const k of keep.keys())
|
|
78
|
+
if (k < nj)
|
|
79
|
+
c++;
|
|
80
|
+
return c;
|
|
81
|
+
};
|
|
82
|
+
const substituted = [];
|
|
83
|
+
const usedRemoved = new Set();
|
|
84
|
+
for (const nj of added) {
|
|
85
|
+
const target = keptBeforeNew(nj);
|
|
86
|
+
for (const oi of removed) {
|
|
87
|
+
if (usedRemoved.has(oi))
|
|
88
|
+
continue;
|
|
89
|
+
if (keptBeforeOld(oi) === target) {
|
|
90
|
+
substituted.push({ oldIndex: oi, newIndex: nj });
|
|
91
|
+
usedRemoved.add(oi);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { keep, removed, added, substituted };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether this diff must fall back to a full remount:
|
|
100
|
+
* - a PURE li insert or removal (not an in-place substitution) — sibling list
|
|
101
|
+
* items renumber without their own XML changing, which a unit diff cannot see;
|
|
102
|
+
* - total churn above `threshold` (a remount is cheaper and simpler than
|
|
103
|
+
* rendering half the document block-by-block).
|
|
104
|
+
*
|
|
105
|
+
* `oldKinds[i]` is the kind of the old sequence's i-th unit (the DOM knows it).
|
|
106
|
+
* An li substitution deliberately does NOT force a remount — its list position
|
|
107
|
+
* is unchanged; the CALLER must still verify its list facts (numId/ilvl)
|
|
108
|
+
* survived, and remount when they changed.
|
|
109
|
+
*/
|
|
110
|
+
export function needsRemount(diff, newUnits, oldKinds, threshold = 40) {
|
|
111
|
+
if (diff.added.length + diff.removed.length > threshold)
|
|
112
|
+
return true;
|
|
113
|
+
const subNew = new Set(diff.substituted.map((s) => s.newIndex));
|
|
114
|
+
const subOld = new Set(diff.substituted.map((s) => s.oldIndex));
|
|
115
|
+
for (const j of diff.added) {
|
|
116
|
+
if (!subNew.has(j) && newUnits[j]?.kind === "li")
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
for (const i of diff.removed) {
|
|
120
|
+
if (!subOld.has(i) && oldKinds[i] === "li")
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=editor-reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-reconcile.js","sourceRoot":"","sources":["../src/editor-reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH;;oFAEoF;AACpF,MAAM,UAAU,OAAO,CAAC,IAAgB;IACtC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC5D,CAAC;AAyBD,6DAA6D;AAC7D,MAAM,UAAU,MAAM,CAAC,EAAU;IAC/B,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,QAAkB,EAAE,QAAsB;IAClE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC1B,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC1B,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvC,2DAA2D;IAC3D,MAAM,GAAG,GAAiB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,CAA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