@stll/docx-core 0.21.0 → 0.23.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/dist/document-CKwRw-01.js +153 -0
- package/dist/{document-Bu82QPAC.d.ts → document-o2RiAASq.d.ts} +292 -38
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +77 -2
- package/dist/index.js +202 -39
- package/dist/model/document.d.ts +2 -2
- package/dist/model/document.js +2 -2
- package/package.json +1 -1
- package/dist/document-D6wZrAko.js +0 -66
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
//#region src/model/content.ts
|
|
2
|
-
const OOXML_SYMBOL_CHARACTER_PATTERN = /^[\dA-Fa-f]{4}$/u;
|
|
3
|
-
/** Whether a symbol character is exactly four hexadecimal digits. */
|
|
4
|
-
const isOoxmlSymbolCharacter = (value) => OOXML_SYMBOL_CHARACTER_PATTERN.test(value);
|
|
5
|
-
/** Raw XML handling modes for drawings that Folio cannot model completely. */
|
|
6
|
-
const DRAWING_RAW_XML_MODES = {
|
|
7
|
-
PRESERVE_ONLY: "preserveOnly",
|
|
8
|
-
/** The modeled image is a rendered preview of richer markup, so regeneration cannot reproduce the drawing. */
|
|
9
|
-
PREVIEW_ONLY: "previewOnly"
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Largest value a revision id (`w:id`) may carry: 2^31 - 1.
|
|
13
|
-
*
|
|
14
|
-
* `w:id` on `<w:ins>`/`<w:del>` comes from `CT_Markup`, typed
|
|
15
|
-
* `ST_DecimalNumber` — which ECMA-376 defines as an unbounded integer. The
|
|
16
|
-
* bound below is an implementation limit: conforming consumers read
|
|
17
|
-
* `ST_DecimalNumber` into a signed 32-bit int, and a value past this bound
|
|
18
|
-
* overflows on load and surfaces as an unreadable document. Port of
|
|
19
|
-
* eigenpal/docx-editor#1093.
|
|
20
|
-
*/
|
|
21
|
-
const MAX_REVISION_ID = 2147483647;
|
|
22
|
-
/**
|
|
23
|
-
* Coerce any revision id — including one parsed from an untrusted DOCX — into
|
|
24
|
-
* the range serialized `w:id` attributes may occupy.
|
|
25
|
-
*
|
|
26
|
-
* - Malformed (negative, fractional, `NaN`, `Infinity`): collapse to `0`.
|
|
27
|
-
* - Well-formed but out of range: fold modulo the range (not clamp) so a
|
|
28
|
-
* contiguous run of overflowing ids stays distinguishable.
|
|
29
|
-
*/
|
|
30
|
-
function normalizeRevisionId(id) {
|
|
31
|
-
if (!Number.isInteger(id) || id < 0) return 0;
|
|
32
|
-
if (id > 2147483647) return id % 2147483648;
|
|
33
|
-
return id;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The kinds a paragraph-mark tracked change can be (ECMA-376 §17.13.5).
|
|
37
|
-
*
|
|
38
|
-
* Written as a child of `<w:pPr><w:rPr>` — `<w:ins/>` when the paragraph
|
|
39
|
-
* break itself was inserted in track-changes mode (the user pressed Enter
|
|
40
|
-
* mid-paragraph), `<w:del/>` when the paragraph break is pending deletion
|
|
41
|
-
* (Backspace at paragraph start or Delete at paragraph end). The mark is
|
|
42
|
-
* independent of the inline runs the paragraph carries.
|
|
43
|
-
*
|
|
44
|
-
* A relocated paragraph's break is `<w:moveFrom/>` at the source and
|
|
45
|
-
* `<w:moveTo/>` at the destination. They resolve exactly as `del` and `ins`
|
|
46
|
-
* do — a move is a deletion and an insertion that a reader is told belong
|
|
47
|
-
* together — but they are not those kinds: writing `w:del` on a moved
|
|
48
|
-
* paragraph's mark reports the relocation as a deletion as well.
|
|
49
|
-
*/
|
|
50
|
-
const PARAGRAPH_MARK_CHANGE_KINDS = Object.freeze([
|
|
51
|
-
"moveFrom",
|
|
52
|
-
"moveTo",
|
|
53
|
-
"ins",
|
|
54
|
-
"del"
|
|
55
|
-
]);
|
|
56
|
-
const REVIEW_CARRIERS = { TERMINAL_TABLE: "terminal-table" };
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/model/document.ts
|
|
59
|
-
/** DOCX package conformance classes. */
|
|
60
|
-
const DOCX_CONFORMANCE_CLASSES = Object.freeze({
|
|
61
|
-
STRICT: "strict",
|
|
62
|
-
TRANSITIONAL: "transitional",
|
|
63
|
-
UNKNOWN: "unknown"
|
|
64
|
-
});
|
|
65
|
-
//#endregion
|
|
66
|
-
export { REVIEW_CARRIERS as a, PARAGRAPH_MARK_CHANGE_KINDS as i, DRAWING_RAW_XML_MODES as n, isOoxmlSymbolCharacter as o, MAX_REVISION_ID as r, normalizeRevisionId as s, DOCX_CONFORMANCE_CLASSES as t };
|