@stll/folio-core 0.33.0 → 0.33.2
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/ai-edits/apply.d.ts +15 -0
- package/dist/ai-edits/apply.js +135 -24
- package/dist/ai-edits/headless.d.ts +47 -3
- package/dist/ai-edits/headless.js +53 -3
- package/dist/ai-edits/index.d.ts +1 -1
- package/dist/ai-edits/snapshot.d.ts +19 -1
- package/dist/ai-edits/snapshot.js +25 -3
- package/dist/ai-edits/table-geometry.d.ts +56 -0
- package/dist/ai-edits/table-geometry.js +217 -0
- package/dist/ai-edits/table-row-column-mutations.d.ts +34 -16
- package/dist/ai-edits/table-row-column-mutations.js +12 -4
- package/dist/ai-edits/table-template.d.ts +60 -0
- package/dist/ai-edits/table-template.js +176 -0
- package/dist/ai-edits/types.d.ts +7 -0
- package/dist/compare/__fixtures__/body-sequence.d.ts +86 -4
- package/dist/compare/__fixtures__/body-sequence.js +169 -12
- package/dist/compare/compare.d.ts +15 -8
- package/dist/compare/compare.js +138 -34
- package/dist/compare/plan.d.ts +31 -1
- package/dist/compare/plan.js +277 -28
- package/dist/compare/reproducible-package.d.ts +7 -3
- package/dist/compare/reproducible-package.js +20 -3
- package/dist/compare/types.d.ts +20 -3
- package/dist/compare/types.js +13 -1
- package/dist/compare/verification.d.ts +49 -2
- package/dist/compare/verification.js +115 -1
- package/dist/compat/eigenpal.d.ts +5 -5
- package/dist/compat/eigenpal.js +3 -3
- package/dist/document-operations.d.ts +10 -1
- package/dist/document-operations.js +3 -2
- package/dist/docx/appVersionNormalization.d.ts +49 -0
- package/dist/docx/appVersionNormalization.js +74 -0
- package/dist/docx/blockContentParser.js +3 -2
- package/dist/docx/drawingUtils.js +4 -3
- package/dist/docx/hyperlinkParser.d.ts +9 -1
- package/dist/docx/hyperlinkParser.js +19 -13
- package/dist/docx/paraIdRangeNormalization.d.ts +40 -0
- package/dist/docx/paraIdRangeNormalization.js +64 -0
- package/dist/docx/paragraphParser.js +82 -6
- package/dist/docx/revisionIdNormalization.d.ts +15 -1
- package/dist/docx/revisionIdNormalization.js +22 -4
- package/dist/docx/rezip.d.ts +13 -1
- package/dist/docx/rezip.js +80 -21
- package/dist/docx/runParser.js +9 -8
- package/dist/docx/sdtProperties.js +4 -3
- package/dist/docx/selectiveSave.js +7 -6
- package/dist/docx/serializer/commentSerializer.d.ts +1 -1
- package/dist/docx/serializer/commentSerializer.js +43 -19
- package/dist/docx/serializer/documentSerializer.d.ts +3 -1
- package/dist/docx/serializer/documentSerializer.js +42 -78
- package/dist/docx/serializer/fontTableSerializer.js +8 -5
- package/dist/docx/serializer/headerFooterSerializer.d.ts +4 -1
- package/dist/docx/serializer/headerFooterSerializer.js +34 -29
- package/dist/docx/serializer/noteSerializer.js +34 -30
- package/dist/docx/serializer/numberingSerializer.js +8 -4
- package/dist/docx/serializer/paragraphSerializer.js +45 -21
- package/dist/docx/serializer/partNamespaces.d.ts +78 -0
- package/dist/docx/serializer/partNamespaces.js +324 -0
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/settingsSerializer.js +8 -2
- package/dist/docx/serializer/stylesSerializer.js +8 -5
- package/dist/docx/serializer/tableSerializer.js +107 -27
- package/dist/docx/serializer/themeSerializer.js +10 -2
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/strictValueEncodings.gen.d.ts +15 -0
- package/dist/docx/strictValueEncodings.gen.js +275 -0
- package/dist/docx/tableParser.d.ts +0 -6
- package/dist/docx/tableParser.js +52 -7
- package/dist/docx/transitionalSpelling.d.ts +23 -0
- package/dist/docx/transitionalSpelling.js +36 -0
- package/dist/docx/universalMeasure.d.ts +20 -0
- package/dist/docx/universalMeasure.js +32 -0
- package/dist/docx/verbatimCapture.d.ts +20 -0
- package/dist/docx/verbatimCapture.js +131 -0
- package/dist/docx/vmlImageParser.js +4 -3
- package/dist/docx/watermarkParser.js +4 -3
- package/dist/docx/xmlParser.d.ts +23 -2
- package/dist/docx/xmlParser.js +43 -11
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/prosemirror/commands/comments.js +8 -2
- package/dist/prosemirror/containerFinalParagraph.d.ts +47 -0
- package/dist/prosemirror/containerFinalParagraph.js +92 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +15 -4
- package/dist/prosemirror/conversion/toProseDoc.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +5 -0
- package/dist/prosemirror/schema/marks.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +22 -0
- package/dist/server.d.ts +1 -1
- package/dist/types/block-id.d.ts +12 -1
- package/dist/types/block-id.js +17 -1
- package/dist/utils/canonicalJson.d.ts +14 -0
- package/dist/utils/canonicalJson.js +19 -0
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen.js";
|
|
2
|
+
import { isStrictNamespaceUri, toTransitionalNamespaceUri, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
3
|
+
import { roundHalfAwayFromZero, universalMeasureAs } from "./universalMeasure.js";
|
|
4
|
+
import { elementToXml, getLocalName } from "./xmlParser.js";
|
|
5
|
+
import { TaggedError } from "better-result";
|
|
6
|
+
//#region src/docx/verbatimCapture.ts
|
|
7
|
+
/**
|
|
8
|
+
* The one way to turn parsed markup into a string a rebuilt part replays.
|
|
9
|
+
*
|
|
10
|
+
* folio parses Strict and Transitional packages and rebuilds every package as
|
|
11
|
+
* Transitional. Modeled properties are re-serialized, so they come out
|
|
12
|
+
* Transitional whatever the source was; content the parser keeps verbatim —
|
|
13
|
+
* raw property XML, drawing and shape bodies, text-box markup, unmodeled
|
|
14
|
+
* extensions — does not, and a Strict fragment copied under a Transitional root
|
|
15
|
+
* changes meaning: the namespaces it declares stay Strict while the root is
|
|
16
|
+
* not, and its values are spelled the way Strict spells them (`155.85pt`,
|
|
17
|
+
* `20%`) where the Transitional attribute is a number.
|
|
18
|
+
*
|
|
19
|
+
* A fragment is therefore converted here, at capture, where its own namespace
|
|
20
|
+
* scope still says which conformance class produced it. Nothing downstream has
|
|
21
|
+
* to know: {@link captureVerbatimXml} is the only producer of replayed markup,
|
|
22
|
+
* and a fragment that carries no Strict namespace passes through byte for byte.
|
|
23
|
+
*/
|
|
24
|
+
/** A Strict fragment uses a namespace that has no Transitional counterpart. */
|
|
25
|
+
var UntranslatableStrictNamespaceError = class extends TaggedError("UntranslatableStrictNamespaceError") {};
|
|
26
|
+
const TRANSITIONAL_URIS = new Set(TRANSITIONAL_NAMESPACE_BY_STRICT_URI.values());
|
|
27
|
+
/**
|
|
28
|
+
* Drawing extensions the repository has no schema for.
|
|
29
|
+
*
|
|
30
|
+
* `wp14:pctWidth` and its siblings are Microsoft vocabularies, but they are
|
|
31
|
+
* DrawingML by construction and DrawingML has one integer encoding for a
|
|
32
|
+
* percentage, so a Strict producer's `20%` there converts like `a:alpha`'s.
|
|
33
|
+
* Lengths are left alone: only an attribute's own type says what unit its
|
|
34
|
+
* number counts, and guessing one would corrupt the value silently.
|
|
35
|
+
*/
|
|
36
|
+
const DRAWING_EXTENSION_MARKERS = [
|
|
37
|
+
"/wordprocessingCanvas",
|
|
38
|
+
"/wordprocessingDrawing",
|
|
39
|
+
"/wordprocessingGroup",
|
|
40
|
+
"/wordprocessingInk",
|
|
41
|
+
"/wordprocessingShape"
|
|
42
|
+
];
|
|
43
|
+
const isUnschemadDrawingNamespace = (uri) => !TRANSITIONAL_URIS.has(uri) && DRAWING_EXTENSION_MARKERS.some((marker) => uri.includes(marker));
|
|
44
|
+
/** `-?12.5%`: the one shape ECMA-376 gives a percentage that carries its unit. */
|
|
45
|
+
const PERCENTAGE = /^(-?[0-9]+(?:\.[0-9]+)?)%$/u;
|
|
46
|
+
const NUMBERS_PER_PERCENT = {
|
|
47
|
+
fiftiethPercent: 50,
|
|
48
|
+
thousandthPercent: 1e3,
|
|
49
|
+
wholePercent: 1
|
|
50
|
+
};
|
|
51
|
+
/** The Transitional spelling of one Strict-produced value, or the value unchanged. */
|
|
52
|
+
const transitionalValue = (value, namespaceUri, encoding) => {
|
|
53
|
+
const measureUnit = encoding?.measure;
|
|
54
|
+
if (measureUnit !== void 0) {
|
|
55
|
+
const measure = universalMeasureAs(value, measureUnit);
|
|
56
|
+
if (measure !== void 0) return String(measure);
|
|
57
|
+
}
|
|
58
|
+
const percentage = PERCENTAGE.exec(value);
|
|
59
|
+
if (percentage === null) return value;
|
|
60
|
+
const percentUnit = encoding?.percent ?? (isUnschemadDrawingNamespace(namespaceUri) ? "thousandthPercent" : void 0);
|
|
61
|
+
if (percentUnit === void 0) return value;
|
|
62
|
+
return String(roundHalfAwayFromZero(Number(percentage[1]) * NUMBERS_PER_PERCENT[percentUnit]));
|
|
63
|
+
};
|
|
64
|
+
const originOf = (element, inherited) => {
|
|
65
|
+
const uri = element.namespaceUri;
|
|
66
|
+
if (uri === void 0) return inherited;
|
|
67
|
+
if (isStrictNamespaceUri(uri)) return "strict";
|
|
68
|
+
if (uri.startsWith("http://purl.oclc.org/ooxml/")) throw new UntranslatableStrictNamespaceError({
|
|
69
|
+
message: `Strict namespace ${uri} has no Transitional counterpart; folio will not replay it under a Transitional root.`,
|
|
70
|
+
uri
|
|
71
|
+
});
|
|
72
|
+
return TRANSITIONAL_URIS.has(uri) ? "transitional" : inherited;
|
|
73
|
+
};
|
|
74
|
+
const convertAttributes = (element, namespaceUri, localName) => {
|
|
75
|
+
const attributes = element.attributes ?? {};
|
|
76
|
+
let converted;
|
|
77
|
+
for (const [name, raw] of Object.entries(attributes)) {
|
|
78
|
+
if (typeof raw !== "string") continue;
|
|
79
|
+
const next = name === "xmlns" || name.startsWith("xmlns:") ? toTransitionalNamespaceUri(raw) : transitionalValue(raw, namespaceUri, transitionalSlotEncoding(element.namespaceUri, localName, getLocalName(name)));
|
|
80
|
+
if (next === raw) continue;
|
|
81
|
+
converted ??= { ...attributes };
|
|
82
|
+
converted[name] = next;
|
|
83
|
+
}
|
|
84
|
+
return converted;
|
|
85
|
+
};
|
|
86
|
+
const childWithValue = (child, text) => text === child.text ? child : {
|
|
87
|
+
...child,
|
|
88
|
+
text
|
|
89
|
+
};
|
|
90
|
+
const toTransitional = (element, inherited) => {
|
|
91
|
+
if (element.type === "text") return element;
|
|
92
|
+
const origin = originOf(element, inherited);
|
|
93
|
+
const namespaceUri = element.namespaceUri === void 0 ? "" : toTransitionalNamespaceUri(element.namespaceUri);
|
|
94
|
+
const localName = getLocalName(element.name);
|
|
95
|
+
const textEncoding = transitionalSlotEncoding(element.namespaceUri, localName);
|
|
96
|
+
const attributes = origin === "strict" && element.attributes ? convertAttributes(element, namespaceUri, localName) : void 0;
|
|
97
|
+
let elements;
|
|
98
|
+
for (const [index, child] of (element.elements ?? []).entries()) {
|
|
99
|
+
const next = origin === "strict" && child.type === "text" && typeof child.text === "string" ? childWithValue(child, transitionalValue(child.text, namespaceUri, textEncoding)) : toTransitional(child, origin);
|
|
100
|
+
if (next === child) continue;
|
|
101
|
+
elements ??= [...element.elements ?? []];
|
|
102
|
+
elements[index] = next;
|
|
103
|
+
}
|
|
104
|
+
if (attributes === void 0 && elements === void 0) return element;
|
|
105
|
+
return {
|
|
106
|
+
...element,
|
|
107
|
+
...attributes === void 0 ? {} : { attributes },
|
|
108
|
+
...elements === void 0 ? {} : { elements }
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/** True when any binding in scope, including inherited ones, is a Strict namespace. */
|
|
112
|
+
const scopeDeclaresStrict = (scope) => {
|
|
113
|
+
for (let current = scope; current; current = current.parent) for (const uri of current.bindings.values()) if (uri.startsWith("http://purl.oclc.org/ooxml/")) return true;
|
|
114
|
+
return false;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Serialize parsed markup for replay inside a rebuilt Transitional part.
|
|
118
|
+
*
|
|
119
|
+
* Every verbatim capture goes through here — a lint rule keeps
|
|
120
|
+
* {@link elementToXml} out of reach of the parsers — so a replay path added
|
|
121
|
+
* later cannot skip the conversion. Markup that binds no Strict namespace,
|
|
122
|
+
* anywhere in scope or in the fragment itself, is serialized once and returned
|
|
123
|
+
* unchanged.
|
|
124
|
+
*/
|
|
125
|
+
const captureVerbatimXml = (element) => {
|
|
126
|
+
const xml = elementToXml(element);
|
|
127
|
+
if (!xml.includes("http://purl.oclc.org/ooxml/") && !scopeDeclaresStrict(element.namespaceScope)) return xml;
|
|
128
|
+
return elementToXml(toTransitional(element, "transitional"));
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { UntranslatableStrictNamespaceError, captureVerbatimXml };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
2
2
|
import { pixelsToEmu } from "../utils/units.js";
|
|
3
3
|
import { resolveImageData } from "./imageParser.js";
|
|
4
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
4
5
|
import { isValidVmlPreviewDimension, parseVmlNumber, parseVmlStyle, renderStandaloneVmlPreview, renderVmlGroupPreview, vmlCssLengthToPx, vmlSvgDataUrl } from "./vmlPreview.js";
|
|
5
6
|
import { isWatermarkShape } from "./watermarkParser.js";
|
|
6
|
-
import { cloneWithXmlnsDeclarations,
|
|
7
|
+
import { cloneWithXmlnsDeclarations, findAllDeep, findChild, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
7
8
|
//#region src/docx/vmlImageParser.ts
|
|
8
9
|
const VML_POSITION_ABSOLUTE = "absolute";
|
|
9
10
|
const IMAGE_WRAP_INLINE = "inline";
|
|
@@ -90,7 +91,7 @@ const previewImage = (pictElement, svg, widthPx, heightPx, style, rootXmlns) =>
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
},
|
|
93
|
-
rawXml:
|
|
94
|
+
rawXml: captureVerbatimXml(cloneWithXmlnsDeclarations(pictElement, rootXmlns))
|
|
94
95
|
};
|
|
95
96
|
};
|
|
96
97
|
const previewDrawing = (pictElement, preview, rootXmlns) => {
|
|
@@ -154,7 +155,7 @@ function parseVmlImageContent(pictElement, rels, media, rootXmlns = {}) {
|
|
|
154
155
|
return {
|
|
155
156
|
type: "drawing",
|
|
156
157
|
image,
|
|
157
|
-
rawXml:
|
|
158
|
+
rawXml: captureVerbatimXml(cloneWithXmlnsDeclarations(pictElement, rootXmlns))
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
161
|
for (const child of getChildElements(pictElement)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
2
|
+
import { cloneWithXmlnsDeclarations, collectXmlnsDeclarations, findChild, findChildren, findDeep, getAttribute, getLocalName, getTextContent } from "./xmlParser.js";
|
|
2
3
|
//#region src/docx/watermarkParser.ts
|
|
3
4
|
const VML_TEXT_WATERMARK_SHAPETYPE = "#_x0000_t136";
|
|
4
5
|
/**
|
|
@@ -38,7 +39,7 @@ function parseWatermark(header) {
|
|
|
38
39
|
const hosting = findEnclosingParagraph(header, shape);
|
|
39
40
|
if (hosting) return {
|
|
40
41
|
watermark,
|
|
41
|
-
rawParagraphXml:
|
|
42
|
+
rawParagraphXml: captureVerbatimXml(cloneWithXmlnsDeclarations(hosting, headerXmlns)),
|
|
42
43
|
hostingParagraph: hosting,
|
|
43
44
|
blockIndex: blockIndexOf(header, hosting)
|
|
44
45
|
};
|
|
@@ -50,7 +51,7 @@ function parseWatermark(header) {
|
|
|
50
51
|
const hosting = findEnclosingParagraph(header, anchor);
|
|
51
52
|
if (hosting) return {
|
|
52
53
|
watermark,
|
|
53
|
-
rawParagraphXml:
|
|
54
|
+
rawParagraphXml: captureVerbatimXml(cloneWithXmlnsDeclarations(hosting, headerXmlns)),
|
|
54
55
|
hostingParagraph: hosting,
|
|
55
56
|
blockIndex: blockIndexOf(header, hosting)
|
|
56
57
|
};
|
package/dist/docx/xmlParser.d.ts
CHANGED
|
@@ -77,7 +77,18 @@ declare const NAMESPACES: {
|
|
|
77
77
|
* @param xml - XML string to parse
|
|
78
78
|
* @returns Parsed element tree
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
/**
|
|
81
|
+
* The prefix bindings a WordprocessingML part declares on its root.
|
|
82
|
+
*
|
|
83
|
+
* A property element captured out of a document carries no `xmlns` of its
|
|
84
|
+
* own, so parsing it on its own resolves no prefix and every lookup by
|
|
85
|
+
* namespace URI misses. Parsing it under this scope puts it back in the
|
|
86
|
+
* context it was written in. A part that binds `w` to something else — or
|
|
87
|
+
* binds it to a prefix this map does not know — simply fails to match, and
|
|
88
|
+
* the caller falls back to whatever it does without the capture.
|
|
89
|
+
*/
|
|
90
|
+
declare const OOXML_NAMESPACE_SCOPE: XmlNamespaceScope;
|
|
91
|
+
declare function parseXml(xml: string, inheritedNamespaceScope?: XmlNamespaceScope): XmlElement;
|
|
81
92
|
/**
|
|
82
93
|
* Serialize an XmlElement back to an XML string
|
|
83
94
|
*/
|
|
@@ -345,5 +356,15 @@ declare function mergeXmlnsDeclarations(inherited: Record<string, string>, eleme
|
|
|
345
356
|
* canonical binding so the detached subtree is valid on its first replay.
|
|
346
357
|
*/
|
|
347
358
|
declare function cloneWithXmlnsDeclarations(element: XmlElement, xmlnsDecls: Record<string, string>): XmlElement;
|
|
359
|
+
/**
|
|
360
|
+
* Shallow clone of an element that keeps its resolved namespace metadata.
|
|
361
|
+
*
|
|
362
|
+
* `namespaceUri` and `namespaceScope` are non-enumerable so structural
|
|
363
|
+
* comparisons stay stable, which also means a plain spread drops them and
|
|
364
|
+
* every namespace-URI lookup on the copy misses. Re-attaching over the
|
|
365
|
+
* original's scope leaves resolution unchanged whether or not the clone
|
|
366
|
+
* carries `xmlns` attributes of its own.
|
|
367
|
+
*/
|
|
368
|
+
declare function cloneElement(element: XmlElement, overrides: Partial<XmlElement>): XmlElement;
|
|
348
369
|
//#endregion
|
|
349
|
-
export { NAMESPACES, WORDPROCESSINGML_NAMESPACE_URIS, XmlAttributeMatch, XmlElement, XmlNamespaceScope, attachXmlNamespaceContext, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument };
|
|
370
|
+
export { NAMESPACES, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, XmlAttributeMatch, XmlElement, XmlNamespaceScope, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument };
|
package/dist/docx/xmlParser.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
2
|
+
import { universalMeasureAs } from "./universalMeasure.js";
|
|
1
3
|
import { XMLBuilder, XMLParser } from "fast-xml-parser";
|
|
2
4
|
import { OOXML_NS } from "@stll/docx-utils";
|
|
3
5
|
//#region src/docx/xmlParser.ts
|
|
@@ -130,8 +132,8 @@ function fxpNodeToElement(node, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE)
|
|
|
130
132
|
* XmlElement that matches xml-js's non-compact root structure:
|
|
131
133
|
* `{ elements: [...] }`.
|
|
132
134
|
*/
|
|
133
|
-
function fxpToRootElement(nodes) {
|
|
134
|
-
for (let index = 0; index < nodes.length; index += 1) nodes[index] = fxpNodeToElement(nodes[index]);
|
|
135
|
+
function fxpToRootElement(nodes, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) {
|
|
136
|
+
for (let index = 0; index < nodes.length; index += 1) nodes[index] = fxpNodeToElement(nodes[index], inheritedNamespaceScope);
|
|
135
137
|
return { elements: nodes };
|
|
136
138
|
}
|
|
137
139
|
/**
|
|
@@ -156,8 +158,19 @@ const NAMESPACES = OOXML_NS;
|
|
|
156
158
|
* @param xml - XML string to parse
|
|
157
159
|
* @returns Parsed element tree
|
|
158
160
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
/**
|
|
162
|
+
* The prefix bindings a WordprocessingML part declares on its root.
|
|
163
|
+
*
|
|
164
|
+
* A property element captured out of a document carries no `xmlns` of its
|
|
165
|
+
* own, so parsing it on its own resolves no prefix and every lookup by
|
|
166
|
+
* namespace URI misses. Parsing it under this scope puts it back in the
|
|
167
|
+
* context it was written in. A part that binds `w` to something else — or
|
|
168
|
+
* binds it to a prefix this map does not know — simply fails to match, and
|
|
169
|
+
* the caller falls back to whatever it does without the capture.
|
|
170
|
+
*/
|
|
171
|
+
const OOXML_NAMESPACE_SCOPE = { bindings: new Map(Object.entries(OOXML_NS)) };
|
|
172
|
+
function parseXml(xml, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) {
|
|
173
|
+
return fxpToRootElement((xml.includes("binData") ? fxpParserWithStopNodes : fxpParser).parse(xml), inheritedNamespaceScope);
|
|
161
174
|
}
|
|
162
175
|
/**
|
|
163
176
|
* Serialize an XmlElement back to an XML string
|
|
@@ -495,6 +508,9 @@ function parseColorElement(element) {
|
|
|
495
508
|
function parseNumericAttribute(element, namespace, name, scale = 1) {
|
|
496
509
|
const value = getAttribute(element, namespace, name);
|
|
497
510
|
if (value === null) return;
|
|
511
|
+
const unit = transitionalSlotEncoding(element?.namespaceUri, getLocalName(element?.name), name)?.measure;
|
|
512
|
+
const measure = unit === void 0 ? void 0 : universalMeasureAs(value, unit);
|
|
513
|
+
if (measure !== void 0) return measure * scale;
|
|
498
514
|
const num = Number.parseInt(value, 10);
|
|
499
515
|
if (Number.isNaN(num)) return;
|
|
500
516
|
return num * scale;
|
|
@@ -523,6 +539,8 @@ function parseTableMeasurementValue(element, widthType) {
|
|
|
523
539
|
const pct = Number.parseFloat(trimmed.slice(0, -1));
|
|
524
540
|
if (!Number.isNaN(pct)) return Math.round(pct * 50);
|
|
525
541
|
}
|
|
542
|
+
const measure = universalMeasureAs(trimmed, "twips");
|
|
543
|
+
if (measure !== void 0) return measure;
|
|
526
544
|
const num = Number.parseInt(trimmed, 10);
|
|
527
545
|
return Number.isNaN(num) ? void 0 : num;
|
|
528
546
|
}
|
|
@@ -741,14 +759,28 @@ function cloneWithXmlnsDeclarations(element, xmlnsDecls) {
|
|
|
741
759
|
if (!prefix || attributes[name] !== void 0 || additions[name] !== void 0 || !isCanonicalNamespacePrefix(prefix)) continue;
|
|
742
760
|
additions[name] = NAMESPACES[prefix];
|
|
743
761
|
}
|
|
744
|
-
for (const _key in additions) return {
|
|
762
|
+
for (const _key in additions) return cloneElement(element, { attributes: {
|
|
763
|
+
...attributes,
|
|
764
|
+
...additions
|
|
765
|
+
} });
|
|
766
|
+
return element;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Shallow clone of an element that keeps its resolved namespace metadata.
|
|
770
|
+
*
|
|
771
|
+
* `namespaceUri` and `namespaceScope` are non-enumerable so structural
|
|
772
|
+
* comparisons stay stable, which also means a plain spread drops them and
|
|
773
|
+
* every namespace-URI lookup on the copy misses. Re-attaching over the
|
|
774
|
+
* original's scope leaves resolution unchanged whether or not the clone
|
|
775
|
+
* carries `xmlns` attributes of its own.
|
|
776
|
+
*/
|
|
777
|
+
function cloneElement(element, overrides) {
|
|
778
|
+
const clone = {
|
|
745
779
|
...element,
|
|
746
|
-
|
|
747
|
-
...attributes,
|
|
748
|
-
...additions
|
|
749
|
-
}
|
|
780
|
+
...overrides
|
|
750
781
|
};
|
|
751
|
-
|
|
782
|
+
attachXmlNamespaceContext(clone, element.namespaceScope);
|
|
783
|
+
return clone;
|
|
752
784
|
}
|
|
753
785
|
//#endregion
|
|
754
|
-
export { NAMESPACES, WORDPROCESSINGML_NAMESPACE_URIS, attachXmlNamespaceContext, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument };
|
|
786
|
+
export { NAMESPACES, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, attachXmlNamespaceContext, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findDeep, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, hasFlag, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { document_d_exports } from "./types/document.js";
|
|
1
2
|
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAISignatureParty } from "./ai-edits/types.js";
|
|
2
3
|
import { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, diffWordSegments } from "./ai-edits/word-diff.js";
|
|
3
4
|
import { FolioAIEditApplyOutcome, FolioRevisionStamp, FolioWordDiffOptions, applyFolioAIEditOperations } from "./ai-edits/apply.js";
|
|
4
|
-
import { document_d_exports } from "./types/document.js";
|
|
5
5
|
import { ApplyFolioDocumentOperationsOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
|
|
6
6
|
import { createFolioAIEditSnapshot, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./ai-edits/snapshot.js";
|
|
7
|
-
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
7
|
+
import { DeriveBlockIdInput, FolioBlockId, currentFolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
8
8
|
import "./ai-edits/index.js";
|
|
9
9
|
import { AIBarStatus, AIChatMode, AICitation, AICitationSource, AIGenerateInput, AISuggestion, AISuggestionApplyMode, AISuggestionPreset, AISuggestionSeverity, AISuggestionStatus, DEFAULT_AI_SUGGESTION_PRESETS } from "./ai-suggestions/types.js";
|
|
10
10
|
import { ApplyResult, applySuggestions } from "./ai-suggestions/apply.js";
|
|
11
11
|
import { ResolvedAnchor, isSuggestionStale, resolveSuggestionAnchor } from "./ai-suggestions/conflict.js";
|
|
12
12
|
import { PositionalText, buildPositionalText } from "./ai-suggestions/text-positions.js";
|
|
13
|
-
import { COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareVerification, CompareVerificationCause, CompareVerificationFailure, CompareVerificationInvariant } from "./compare/verification.js";
|
|
14
|
-
import { COMPARE_UNSUPPORTED_REASONS, CompareChange, CompareChangeLocation, CompareDocxApplyError, CompareDocxError, CompareDocxOperationLimitError, CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, CompareFormatRange, CompareResult, CompareUnsupportedPart, CompareUnsupportedReason, InvalidCompareDocxOptionsError } from "./compare/types.js";
|
|
13
|
+
import { COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareVerification, CompareVerificationCause, CompareVerificationFailure, CompareVerificationInvariant, FinalParagraphMarkRevision } from "./compare/verification.js";
|
|
14
|
+
import { COMPARE_UNSUPPORTED_REASONS, CompareChange, CompareChangeLocation, CompareDocxApplyError, CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, CompareFormatRange, CompareResult, CompareUnsupportedPart, CompareUnsupportedReason, InvalidCompareDocxOptionsError } from "./compare/types.js";
|
|
15
15
|
import { MAX_COMPARE_OPERATIONS, compareDocx } from "./compare/compare.js";
|
|
16
16
|
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocumentPreset, DocumentStyleSet } from "./style-sets/types.js";
|
|
17
17
|
import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
|
|
@@ -38,4 +38,4 @@ import { getGoogleFontsEnabled, setEmbeddedFontFamilyMap, setGoogleFontsEnabled
|
|
|
38
38
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
39
39
|
type Document = document_d_exports.Document;
|
|
40
40
|
type DocxConformanceClass = document_d_exports.DocxConformanceClass;
|
|
41
|
-
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, CompareDocxApplyError, type CompareDocxError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFormatRange, type CompareResult, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAISignatureParty, type FolioBlockId, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
41
|
+
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFormatRange, type CompareResult, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAISignatureParty, type FolioBlockId, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { isSuggestionStale, resolveSuggestionAnchor } from "./ai-suggestions/con
|
|
|
6
6
|
import { buildPositionalText } from "./ai-suggestions/text-positions.js";
|
|
7
7
|
import { DEFAULT_AI_SUGGESTION_PRESETS } from "./ai-suggestions/types.js";
|
|
8
8
|
import { MAX_COMPARE_OPERATIONS, compareDocx } from "./compare/compare.js";
|
|
9
|
-
import { COMPARE_UNSUPPORTED_REASONS, CompareDocxApplyError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, InvalidCompareDocxOptionsError } from "./compare/types.js";
|
|
9
|
+
import { COMPARE_UNSUPPORTED_REASONS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, InvalidCompareDocxOptionsError } from "./compare/types.js";
|
|
10
10
|
import { COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS } from "./compare/verification.js";
|
|
11
11
|
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
|
|
12
12
|
import { inspectDocxCompatibility } from "./docx/compatibility.js";
|
|
@@ -26,9 +26,9 @@ import { clearTemplateSlashMenu, consumeTemplateSlashQuery, getTemplateSlashMenu
|
|
|
26
26
|
import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "./style-sets/extract.js";
|
|
27
27
|
import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "./style-sets/stellaStyle.js";
|
|
28
28
|
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "./style-sets/types.js";
|
|
29
|
-
import { deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
29
|
+
import { currentFolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
30
30
|
import { createEmptyDocument } from "./utils/createDocument.js";
|
|
31
31
|
import { getGoogleFontsEnabled, setEmbeddedFontFamilyMap, setGoogleFontsEnabled } from "./utils/fontResolver.js";
|
|
32
32
|
import { mergeDocumentContent } from "./utils/mergeDocumentContent.js";
|
|
33
33
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
34
|
-
export { COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidCompareDocxOptionsError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
34
|
+
export { COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidCompareDocxOptionsError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
package/dist/model.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { document_d_exports } from "./types/document.js";
|
|
2
|
-
import { DeriveBlockIdInput, FolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
2
|
+
import { DeriveBlockIdInput, FolioBlockId, currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
3
3
|
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, normalizeShapeTextAnchor } from "./types/documentEnumValues.js";
|
|
4
4
|
import { types_d_exports } from "./layout-engine/types.js";
|
|
5
5
|
import { measureTypes_d_exports } from "./layout-engine/measure/measureTypes.js";
|
|
6
6
|
export * from "@stll/docx-core/model";
|
|
7
7
|
declare namespace model_d_exports {
|
|
8
|
-
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
|
8
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
|
-
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, type measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
|
11
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, type measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
package/dist/model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { types_exports } from "./layout-engine/types.js";
|
|
2
|
-
import { deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
2
|
+
import { currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
3
3
|
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, normalizeShapeTextAnchor } from "./types/documentEnumValues.js";
|
|
4
|
-
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_exports as Layout, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
|
4
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_exports as Layout, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TEXT_ANCHOR_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId, normalizeShapeTextAnchor };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs } from "../attrs/index.js";
|
|
2
|
+
import { paragraphEndsItsContainer } from "../containerFinalParagraph.js";
|
|
2
3
|
import { textFormattingToMarks } from "../conversion/toProseDoc.js";
|
|
3
4
|
import { markStructuralChange } from "../extensions/features/ParagraphChangeTrackerExtension.js";
|
|
4
5
|
import { getFolioNodeRevisionCarriers } from "../revisionCarriers.js";
|
|
@@ -156,7 +157,10 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
156
157
|
if (!(nextNode?.type.name === paragraph.type.name && !(carriesSection(paragraph) && carriesSection(nextNode)))) {
|
|
157
158
|
const resolved = tr.doc.resolve(mappedPos);
|
|
158
159
|
const previous = resolved.nodeBefore;
|
|
159
|
-
|
|
160
|
+
const sectionCanMoveBack = !carriesSection(paragraph) || previous?.type.name === paragraph.type.name && !carriesSection(previous);
|
|
161
|
+
const endsItsContainer = paragraphEndsItsContainer(resolved, paragraph.type.name);
|
|
162
|
+
const canGo = op.markWasAdded || !endsItsContainer;
|
|
163
|
+
if (sectionCanMoveBack && holdsNoContent(paragraph) && canGo && resolved.parent.childCount > 1) {
|
|
160
164
|
if (carriesSection(paragraph) && previous) tr.setNodeMarkup(mappedPos - previous.nodeSize, void 0, {
|
|
161
165
|
...previous.attrs,
|
|
162
166
|
sectionBreakType: paragraph.attrs["sectionBreakType"],
|
|
@@ -386,9 +390,11 @@ function collectPPrMarkOp(node, pos, from, to, mode, revisionSet) {
|
|
|
386
390
|
const pPrMark = node.attrs["pPrMark"];
|
|
387
391
|
if (!isPPrMarkAttr(pPrMark)) return null;
|
|
388
392
|
if (revisionSet !== null && !revisionSet.has(pPrMark.info.id)) return null;
|
|
393
|
+
const markWasAdded = paragraphMarkWasAdded(pPrMark.kind);
|
|
389
394
|
return {
|
|
390
395
|
paragraphPos: pos,
|
|
391
|
-
action:
|
|
396
|
+
action: markWasAdded === (mode === "accept") ? "clear" : "join",
|
|
397
|
+
markWasAdded
|
|
392
398
|
};
|
|
393
399
|
}
|
|
394
400
|
function rangeCoversParagraphBoundary(from, to, pos, node) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Node, ResolvedPos } from "prosemirror-model";
|
|
2
|
+
//#region src/prosemirror/containerFinalParagraph.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Whether the paragraph starting at `at` is the one its container ENDS with,
|
|
5
|
+
* which is the one place a paragraph mark cannot carry a revision.
|
|
6
|
+
*
|
|
7
|
+
* A deleted mark asks a reader to join the paragraph it ends with the one
|
|
8
|
+
* after it, and an inserted mark says that break was added, so rejecting it
|
|
9
|
+
* closes the paragraph back over the next one. A body, a table cell, a header
|
|
10
|
+
* or footer, a note and a text box each end with a paragraph that nothing
|
|
11
|
+
* follows, so neither direction can be resolved there: a consumer is left with
|
|
12
|
+
* a revision it can only ignore, and the redline no longer resolves to the two
|
|
13
|
+
* documents it was written from.
|
|
14
|
+
*
|
|
15
|
+
* A paragraph before a TABLE is not one of those: the table is a following
|
|
16
|
+
* sibling, so the paragraph does not end anything and carries its own mark
|
|
17
|
+
* like any other.
|
|
18
|
+
*/
|
|
19
|
+
declare const paragraphEndsItsContainer: (at: ResolvedPos, paragraphTypeName: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Every paragraph a container ENDS with in `doc`, with its position.
|
|
22
|
+
*
|
|
23
|
+
* One walk for the whole document: asking the question of each paragraph in
|
|
24
|
+
* turn costs a scan of its siblings each time, which is quadratic in a body
|
|
25
|
+
* whose paragraphs a batch has just filled.
|
|
26
|
+
*/
|
|
27
|
+
declare const finalParagraphsOf: (doc: Node, paragraphTypeName: string) => {
|
|
28
|
+
position: number;
|
|
29
|
+
node: Node;
|
|
30
|
+
}[];
|
|
31
|
+
/**
|
|
32
|
+
* The paragraph an added break can rotate BACK onto from the one at `at`: the
|
|
33
|
+
* paragraph the run of inserted ones was appended after.
|
|
34
|
+
*
|
|
35
|
+
* The walk crosses the inserted paragraphs — their own marks stay where they
|
|
36
|
+
* are, and only which paragraph is left markless changes — and stops at the
|
|
37
|
+
* first one whose mark is free. `null` when there is none: a table in between,
|
|
38
|
+
* which no mark joins across; a paragraph whose mark says something else,
|
|
39
|
+
* which the rotation must not overwrite; or a container whose every paragraph
|
|
40
|
+
* is new.
|
|
41
|
+
*/
|
|
42
|
+
declare const addedBreakCarrierBefore: (at: ResolvedPos, paragraphTypeName: string) => {
|
|
43
|
+
position: number;
|
|
44
|
+
node: Node;
|
|
45
|
+
} | null;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { addedBreakCarrierBefore, finalParagraphsOf, paragraphEndsItsContainer };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/prosemirror/containerFinalParagraph.ts
|
|
2
|
+
/**
|
|
3
|
+
* A node the FILE holds as a child of the container it appears in.
|
|
4
|
+
*
|
|
5
|
+
* The editor keeps a text box as a block-level sibling of the paragraph that
|
|
6
|
+
* anchors it; the file hangs it off that paragraph's own run, so it is not a
|
|
7
|
+
* child of the container at all. A paragraph and a table are children in both.
|
|
8
|
+
*/
|
|
9
|
+
const isAContainerChild = (node, paragraphTypeName) => node.type.name === paragraphTypeName || node.type.spec["tableRole"] === "table";
|
|
10
|
+
/** Whether every child from `fromIndex` on is one the file does not hold here. */
|
|
11
|
+
const nothingFollowsIn = (parent, fromIndex, paragraphTypeName) => {
|
|
12
|
+
for (let index = fromIndex; index < parent.childCount; index++) if (isAContainerChild(parent.child(index), paragraphTypeName)) return false;
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Whether the paragraph starting at `at` is the one its container ENDS with,
|
|
17
|
+
* which is the one place a paragraph mark cannot carry a revision.
|
|
18
|
+
*
|
|
19
|
+
* A deleted mark asks a reader to join the paragraph it ends with the one
|
|
20
|
+
* after it, and an inserted mark says that break was added, so rejecting it
|
|
21
|
+
* closes the paragraph back over the next one. A body, a table cell, a header
|
|
22
|
+
* or footer, a note and a text box each end with a paragraph that nothing
|
|
23
|
+
* follows, so neither direction can be resolved there: a consumer is left with
|
|
24
|
+
* a revision it can only ignore, and the redline no longer resolves to the two
|
|
25
|
+
* documents it was written from.
|
|
26
|
+
*
|
|
27
|
+
* A paragraph before a TABLE is not one of those: the table is a following
|
|
28
|
+
* sibling, so the paragraph does not end anything and carries its own mark
|
|
29
|
+
* like any other.
|
|
30
|
+
*/
|
|
31
|
+
const paragraphEndsItsContainer = (at, paragraphTypeName) => nothingFollowsIn(at.parent, at.index() + 1, paragraphTypeName);
|
|
32
|
+
/**
|
|
33
|
+
* Every paragraph a container ENDS with in `doc`, with its position.
|
|
34
|
+
*
|
|
35
|
+
* One walk for the whole document: asking the question of each paragraph in
|
|
36
|
+
* turn costs a scan of its siblings each time, which is quadratic in a body
|
|
37
|
+
* whose paragraphs a batch has just filled.
|
|
38
|
+
*/
|
|
39
|
+
const finalParagraphsOf = (doc, paragraphTypeName) => {
|
|
40
|
+
const found = [];
|
|
41
|
+
const collect = (node, contentStart) => {
|
|
42
|
+
let last = null;
|
|
43
|
+
node.forEach((child, offset) => {
|
|
44
|
+
const position = contentStart + offset;
|
|
45
|
+
if (child.type.name === paragraphTypeName) last = {
|
|
46
|
+
position,
|
|
47
|
+
node: child
|
|
48
|
+
};
|
|
49
|
+
else if (isAContainerChild(child, paragraphTypeName)) last = null;
|
|
50
|
+
if (!child.isTextblock && child.childCount > 0) collect(child, position + 1);
|
|
51
|
+
});
|
|
52
|
+
if (last !== null) found.push(last);
|
|
53
|
+
};
|
|
54
|
+
collect(doc, 0);
|
|
55
|
+
return found;
|
|
56
|
+
};
|
|
57
|
+
/** A paragraph's mark, when it says the break was ADDED. */
|
|
58
|
+
const marksAnAddedBreak = (node) => {
|
|
59
|
+
const mark = node.attrs["pPrMark"];
|
|
60
|
+
if (typeof mark !== "object" || mark === null || !("kind" in mark)) return false;
|
|
61
|
+
return mark.kind === "ins" || mark.kind === "moveTo";
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The paragraph an added break can rotate BACK onto from the one at `at`: the
|
|
65
|
+
* paragraph the run of inserted ones was appended after.
|
|
66
|
+
*
|
|
67
|
+
* The walk crosses the inserted paragraphs — their own marks stay where they
|
|
68
|
+
* are, and only which paragraph is left markless changes — and stops at the
|
|
69
|
+
* first one whose mark is free. `null` when there is none: a table in between,
|
|
70
|
+
* which no mark joins across; a paragraph whose mark says something else,
|
|
71
|
+
* which the rotation must not overwrite; or a container whose every paragraph
|
|
72
|
+
* is new.
|
|
73
|
+
*/
|
|
74
|
+
const addedBreakCarrierBefore = (at, paragraphTypeName) => {
|
|
75
|
+
let position = at.pos;
|
|
76
|
+
for (let index = at.index() - 1; index >= 0; index--) {
|
|
77
|
+
const sibling = at.parent.child(index);
|
|
78
|
+
position -= sibling.nodeSize;
|
|
79
|
+
if (sibling.type.name !== paragraphTypeName) {
|
|
80
|
+
if (isAContainerChild(sibling, paragraphTypeName)) return null;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (sibling.attrs["pPrMark"] == null) return {
|
|
84
|
+
position,
|
|
85
|
+
node: sibling
|
|
86
|
+
};
|
|
87
|
+
if (!marksAnAddedBreak(sibling)) return null;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { addedBreakCarrierBefore, finalParagraphsOf, paragraphEndsItsContainer };
|