@stll/folio-core 0.65.0 → 0.66.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/ai-edits/apply.js +31 -9
- package/dist/docx/attributeRemainder.js +1 -1
- package/dist/docx/documentSectionFacts.js +1 -1
- package/dist/docx/ensureParaIds.js +2 -2
- package/dist/docx/importedIdCollisions.js +1 -1
- package/dist/docx/mathToMathml.js +1 -1
- package/dist/docx/numericIdNormalization.js +2 -2
- package/dist/docx/parser.js +1 -1
- package/dist/docx/revisionIdNormalization.js +2 -2
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/sdtProperties.js +1 -2
- package/dist/docx/selectedXmlIdentityScan.d.ts +1 -1
- package/dist/docx/selectedXmlIdentityScan.js +1 -1
- package/dist/docx/selectiveXmlPatch.js +2 -2
- package/dist/docx/server/boundedArchive.d.ts +1 -1
- package/dist/docx/server/boundedArchive.js +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -1
- package/dist/docx/shapeAlternateContent.js +1 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/unzip.js +1 -1
- package/dist/docx/verbatimCapture.js +1 -1
- package/dist/docx/xmlParser.d.ts +5 -36
- package/dist/docx/xmlParser.js +14 -78
- package/dist/docx/xmlSafety.js +5 -5
- package/dist/layout-painter/renderPage.js +4 -2
- package/dist/markdown/countParagraphList.d.ts +18 -0
- package/dist/markdown/countParagraphList.js +90 -0
- package/dist/markdown/renderParagraph.js +2 -62
- package/dist/markdown/renderRuns.js +4 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +5 -3
- package/dist/prosemirror/conversion/toProseDoc.js +4 -1
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.js +4 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +6 -0
- package/dist/prosemirror/replacedAnnotations.js +30 -8
- package/dist/prosemirror/schema/nodes.d.ts +7 -0
- package/dist/prosemirror/textBoxAnchorAttrs.js +9 -1
- package/package.json +2 -3
- package/dist/docx/streamingXmlParser.d.ts +0 -60
- package/dist/docx/streamingXmlParser.js +0 -406
- package/dist/docx/xmlNamespaceContext.d.ts +0 -6
- package/dist/docx/xmlNamespaceContext.js +0 -53
- package/dist/docx/xmlResourceLimits.d.ts +0 -107
- package/dist/docx/xmlResourceLimits.js +0 -194
package/dist/ai-edits/apply.js
CHANGED
|
@@ -26,7 +26,7 @@ import { getDocumentNumbering, getDocumentNumberingInstanceIds } from "../prosem
|
|
|
26
26
|
import { getDocumentStyleDefinitions, getDocumentStyleResolver } from "../prosemirror/plugins/documentStyleState.js";
|
|
27
27
|
import { claimRevisionIds, nextRevisionId, nextRevisionIdRange, reserveRevisionIds, seedRevisionIdsFromDoc } from "../prosemirror/plugins/revisionIds.js";
|
|
28
28
|
import { rebaseParagraphRuns } from "../prosemirror/rebaseParagraphRuns.js";
|
|
29
|
-
import { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, hasReplacedAnnotations, inheritedReplacementMarks, joinCommentStretches, placeTrackedInsertion, surveyReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
|
|
29
|
+
import { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, hasReplacedAnnotations, inheritedReplacementMarks, joinCommentStretches, placeTrackedInsertion, surveyAcceptedReplacedAnnotations, surveyReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
|
|
30
30
|
import { applyMarksToRunFormattingRepresentation, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
31
31
|
import { RUN_FORMATTING_MARK_NAMES } from "../prosemirror/runFormattingMarkNames.js";
|
|
32
32
|
import { readAuthoredRunFormatting, readAuthoredRunPropertySnapshot, reconcileRunFormattingMarks } from "../prosemirror/runFormattingReconciliation.js";
|
|
@@ -1395,6 +1395,17 @@ const holdsOnlyInsertedContent = (paragraph, revisions) => {
|
|
|
1395
1395
|
});
|
|
1396
1396
|
return whollyInserted;
|
|
1397
1397
|
};
|
|
1398
|
+
/** Whether every inline of `paragraph` is an ordinary insertion one of `revisionIds` made. */
|
|
1399
|
+
const holdsOnlyContentInsertedBy = (paragraph, revisionIds) => {
|
|
1400
|
+
let whollyInserted = true;
|
|
1401
|
+
paragraph.descendants((node) => {
|
|
1402
|
+
if (!whollyInserted) return false;
|
|
1403
|
+
if (!node.isInline || isZeroWidthAnchor(node)) return true;
|
|
1404
|
+
whollyInserted = node.marks.some((mark) => mark.type.name === "insertion" && mark.attrs["moveKind"] !== "moveTo" && revisionIds.has(mark.attrs["revisionId"]));
|
|
1405
|
+
return false;
|
|
1406
|
+
});
|
|
1407
|
+
return whollyInserted;
|
|
1408
|
+
};
|
|
1398
1409
|
/**
|
|
1399
1410
|
* Remove the paragraph between `from` and `to`, its content with it but not
|
|
1400
1411
|
* the range boundaries it holds: those stay where it was, as rejecting a
|
|
@@ -2072,7 +2083,7 @@ const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, autho
|
|
|
2072
2083
|
const trackedInsertion = insertedRevisionId !== null && batchRevisionIds.has(insertedRevisionId);
|
|
2073
2084
|
const suggestedInsertion = isSuggestedParagraphInsert(node);
|
|
2074
2085
|
const deletedBreakRevisionId = addedOrDeletedBreakRevisionId(deletedMark);
|
|
2075
|
-
if (isPlainDeletedPPrMark(deletedMark) && deletedBreakRevisionId !== null && !batchRevisionIds.has(deletedBreakRevisionId) && !holdsOnlyDeletedContent(previous.node) && (trackedInsertion || suggestedInsertion
|
|
2086
|
+
if (isPlainDeletedPPrMark(deletedMark) && deletedBreakRevisionId !== null && !batchRevisionIds.has(deletedBreakRevisionId) && !holdsOnlyDeletedContent(previous.node) && (trackedInsertion && holdsOnlyContentInsertedBy(node, batchRevisionIds) || suggestedInsertion && holdsOnlyInsertedContent(node, "ordinary"))) {
|
|
2076
2087
|
supersededDeletedBreaks.push({
|
|
2077
2088
|
preceding: previous.position,
|
|
2078
2089
|
inserted: position,
|
|
@@ -2094,6 +2105,7 @@ const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, autho
|
|
|
2094
2105
|
});
|
|
2095
2106
|
};
|
|
2096
2107
|
collectSupersededDeletedBreaks(tr.doc, 0);
|
|
2108
|
+
const passedThrough = new Set(supersededDeletedBreaks.map(({ preceding }) => preceding));
|
|
2097
2109
|
for (const { preceding, inserted, deletedMark, precedingMark, precedingFormatting } of supersededDeletedBreaks) {
|
|
2098
2110
|
const insertionRevisionId = addedBreakRevisionId(precedingMark);
|
|
2099
2111
|
if (insertionRevisionId !== null) {
|
|
@@ -2118,6 +2130,7 @@ const withRotatedAddedFinalBreaks = ({ tr, batchRevisionIds, revisionSeed, autho
|
|
|
2118
2130
|
tr.setNodeAttribute(preceding, "pPrMark", precedingMark);
|
|
2119
2131
|
tr.setNodeAttribute(inserted, "pPrMark", deletedMark);
|
|
2120
2132
|
if (insertionRevisionId === null) continue;
|
|
2133
|
+
if (passedThrough.has(inserted)) continue;
|
|
2121
2134
|
const source = tr.doc.nodeAt(inserted);
|
|
2122
2135
|
const survivor = paragraphLeftAfter({
|
|
2123
2136
|
doc: tr.doc,
|
|
@@ -2903,7 +2916,12 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
2903
2916
|
}
|
|
2904
2917
|
const nodes = [];
|
|
2905
2918
|
for (const group of nodeGroups.toReversed()) for (const node of group) nodes.push(node);
|
|
2906
|
-
tr =
|
|
2919
|
+
tr = insertBlocksInsideComments({
|
|
2920
|
+
tr,
|
|
2921
|
+
at: item.from,
|
|
2922
|
+
blocks: nodes,
|
|
2923
|
+
...item.boundaryComments !== void 0 && { carriedComments: item.boundaryComments }
|
|
2924
|
+
});
|
|
2907
2925
|
applied.push(...runApplied);
|
|
2908
2926
|
continue;
|
|
2909
2927
|
}
|
|
@@ -3288,7 +3306,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
3288
3306
|
tr = insertBlocksInsideComments({
|
|
3289
3307
|
tr,
|
|
3290
3308
|
at: item.from,
|
|
3291
|
-
blocks: built.nodes
|
|
3309
|
+
blocks: built.nodes,
|
|
3310
|
+
...item.boundaryComments !== void 0 && { carriedComments: item.boundaryComments }
|
|
3292
3311
|
});
|
|
3293
3312
|
break;
|
|
3294
3313
|
}
|
|
@@ -3713,7 +3732,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
3713
3732
|
const carriedComments = tableAfterDeletedSplit.get(item.blockFrom);
|
|
3714
3733
|
const usesRetractedSplit = carriedComments !== void 0 && item.from === item.blockTo;
|
|
3715
3734
|
let at = usesRetractedSplit ? tr.mapping.map(item.blockFrom, -1) : item.from;
|
|
3716
|
-
let insertionComments = carriedComments;
|
|
3735
|
+
let insertionComments = carriedComments ?? item.boundaryComments;
|
|
3717
3736
|
if (!usesRetractedSplit) {
|
|
3718
3737
|
const boundary = tr.doc.resolve(at);
|
|
3719
3738
|
const before = boundary.nodeBefore;
|
|
@@ -3903,6 +3922,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
3903
3922
|
if (mode === "direct") {
|
|
3904
3923
|
if (item.to > item.from) tr = tr.delete(item.from, item.to);
|
|
3905
3924
|
tr = tr.split(item.from);
|
|
3925
|
+
tr = tr.setNodeAttribute(item.blockFrom, "pPrMark", null);
|
|
3906
3926
|
if (splitsFromItsTextBoxes) gatherTextBoxesAfterParagraph(tr, item.blockFrom);
|
|
3907
3927
|
} else {
|
|
3908
3928
|
const revisionIdMark = operationRevisionSeed++;
|
|
@@ -4754,7 +4774,7 @@ const directReplacementMarks = ({ doc, plan, replacementBackground }) => {
|
|
|
4754
4774
|
const first = pieces.at(0);
|
|
4755
4775
|
const last = pieces.at(-1);
|
|
4756
4776
|
if (first === void 0 || last === void 0) panic("A planned replacement lost the characters it removes");
|
|
4757
|
-
marks = addCarriedMarks(inheritedReplacementMarks(doc, first.from, first.to),
|
|
4777
|
+
marks = addCarriedMarks(inheritedReplacementMarks(doc, first.from, first.to), surveyAcceptedReplacedAnnotations(doc, first.from, last.to).carried);
|
|
4758
4778
|
}
|
|
4759
4779
|
const written = clearsBackground ? withoutBackground(marks) : marks;
|
|
4760
4780
|
for (let offset = 0; offset < change.text.length; offset++) allocated.push(written);
|
|
@@ -5020,7 +5040,7 @@ const applyMinimalTrackedReplacement = ({ tr, item, noteReferences, replacement,
|
|
|
5020
5040
|
if (first === void 0 || last === void 0 || styleSource === null) panic("A planned replacement lost the characters it removes");
|
|
5021
5041
|
at = last.to;
|
|
5022
5042
|
removedFrom = first.from;
|
|
5023
|
-
marks = addCarriedMarks(inheritedReplacementMarks(doc, styleSource.from, styleSource.to),
|
|
5043
|
+
marks = addCarriedMarks(inheritedReplacementMarks(doc, styleSource.from, styleSource.to), surveyAcceptedReplacedAnnotations(doc, first.from, last.to).carried);
|
|
5024
5044
|
for (const piece of change.pieces) {
|
|
5025
5045
|
addTrackedDeletionMark({
|
|
5026
5046
|
insertionPolicy: "preserve-pending",
|
|
@@ -5285,7 +5305,8 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
|
|
|
5285
5305
|
blockFrom,
|
|
5286
5306
|
blockTo,
|
|
5287
5307
|
blockNode,
|
|
5288
|
-
insertTexts
|
|
5308
|
+
insertTexts,
|
|
5309
|
+
boundaryComments: commentsAcrossBlockBoundary(doc, insertFrom)
|
|
5289
5310
|
}
|
|
5290
5311
|
};
|
|
5291
5312
|
}
|
|
@@ -5541,7 +5562,8 @@ const resolveOperationTarget = ({ snapshot, operation, liveBlocks, liveBlocksByP
|
|
|
5541
5562
|
to: insertFrom,
|
|
5542
5563
|
blockFrom,
|
|
5543
5564
|
blockTo,
|
|
5544
|
-
blockNode
|
|
5565
|
+
blockNode,
|
|
5566
|
+
boundaryComments: commentsAcrossBlockBoundary(doc, insertFrom)
|
|
5545
5567
|
}
|
|
5546
5568
|
};
|
|
5547
5569
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { modelledAttributeNames } from "./propertyElementAttributes.js";
|
|
2
2
|
import { OOXML_NAMESPACES } from "./serializer/partNamespaces.js";
|
|
3
|
-
import { XML_NAMESPACE_URI } from "./xmlNamespaceContext.js";
|
|
4
3
|
import { getLocalName, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
5
4
|
import { TaggedError } from "better-result";
|
|
6
5
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
6
|
+
import { XML_NAMESPACE_URI } from "@stll/docx-core/xml/namespaces";
|
|
7
7
|
// src/docx/attributeRemainder.ts
|
|
8
8
|
/**
|
|
9
9
|
* The attribute remainder: what an element carried and its parser has no field for.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseHeaderFooterType } from "./headerFooterRefParser.js";
|
|
2
2
|
import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, WORDPROCESSINGML_NAMESPACE_URIS, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, parseXml } from "./xmlParser.js";
|
|
3
|
-
import { assertXmlResourceLimits } from "
|
|
3
|
+
import { assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
4
4
|
// src/docx/documentSectionFacts.ts
|
|
5
5
|
const isWordprocessingElement = (element, localName) => getLocalName(element.name) === localName && WORDPROCESSINGML_NAMESPACE_URIS.has(getNamespaceUri(element) ?? "");
|
|
6
6
|
/** Both facts from one walk of a parsed document tree. */
|
|
@@ -2,10 +2,10 @@ import { deterministicHexId } from "../utils/hexId.js";
|
|
|
2
2
|
import { resolvePackageRelationshipTarget } from "./packageParts.js";
|
|
3
3
|
import { spliceXml } from "./selectiveXmlPatch.js";
|
|
4
4
|
import { loadDocxArchive } from "./server/boundedArchive.js";
|
|
5
|
-
import { scanStreamingXmlElements } from "./streamingXmlParser.js";
|
|
6
|
-
import { resolveNamespaceUri } from "./xmlNamespaceContext.js";
|
|
7
5
|
import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, WORDPROCESSINGML_NAMESPACE_URIS, getAttribute, getChildElements, getLocalName, getNamespaceUri, parseXmlDocument, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
8
6
|
import { TaggedError } from "better-result";
|
|
7
|
+
import { scanStreamingXmlElements } from "@stll/docx-core/xml";
|
|
8
|
+
import { resolveNamespaceUri } from "@stll/docx-core/xml/namespaces";
|
|
9
9
|
import { ZipArchive } from "@stll/docx-core/zip";
|
|
10
10
|
// src/docx/ensureParaIds.ts
|
|
11
11
|
/**
|
|
@@ -3,10 +3,10 @@ import { REVISION_ELEMENT_NAMES } from "./revisionIdNormalization.js";
|
|
|
3
3
|
import { scanSelectedStreamingXmlElements } from "./selectedXmlIdentityScan.js";
|
|
4
4
|
import { OOXML_NAMESPACES } from "./serializer/partNamespaces.js";
|
|
5
5
|
import { toTransitionalNamespaceUri } from "./transitionalSpelling.js";
|
|
6
|
-
import { resolveNamespaceUri } from "./xmlNamespaceContext.js";
|
|
7
6
|
import { NAMESPACES, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
8
7
|
import { panic } from "better-result";
|
|
9
8
|
import { IMPORTED_ID_COLLISION_KINDS, PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
9
|
+
import { resolveNamespaceUri } from "@stll/docx-core/xml/namespaces";
|
|
10
10
|
// src/docx/importedIdCollisions.ts
|
|
11
11
|
const WORD_2010_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
12
12
|
const PACKAGE_RELATIONSHIP_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WORDPROCESSINGML_NAMESPACE_URIS, findChildByLocalName, findChildByNamespaceUri, getAttributeByNamespaceUri, getLocalName, getNamespaceUri, parseXmlDocument } from "./xmlParser.js";
|
|
2
|
-
import { assertXmlResourceLimits } from "./xmlResourceLimits.js";
|
|
3
2
|
import { escapeXmlText } from "@stll/docx-core";
|
|
3
|
+
import { assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
4
4
|
// src/docx/mathToMathml.ts
|
|
5
5
|
/**
|
|
6
6
|
* OMML → MathML conversion.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { REVISION_ELEMENT_NAMES } from "./revisionIdNormalization.js";
|
|
2
|
-
import { parseStreamingXmlWithIdentityVisitor, scanStreamingXmlNumericIdAttributes } from "./streamingXmlParser.js";
|
|
3
2
|
import { replaceRawDocxXmlParts } from "./unzip.js";
|
|
4
3
|
import { getLocalName, getNamespaceUri, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
5
|
-
import { XmlResourceLimitError } from "./xmlResourceLimits.js";
|
|
6
4
|
import { panic } from "better-result";
|
|
7
5
|
import { assertValidOoxmlNumericId, isOoxmlNumericIdAttributeName, isValidOoxmlNumericId, mayContainInvalidOoxmlNumericIds, mayContainOoxmlNumericIds, ooxmlNumericIdDomain } from "@stll/docx-core";
|
|
6
|
+
import { parseStreamingXmlWithIdentityVisitor, scanStreamingXmlNumericIdAttributes } from "@stll/docx-core/xml";
|
|
7
|
+
import { XmlResourceLimitError } from "@stll/docx-core/xml/limits";
|
|
8
8
|
// src/docx/numericIdNormalization.ts
|
|
9
9
|
const identityKey = (value) => {
|
|
10
10
|
const spelling = String(value).trim();
|
package/dist/docx/parser.js
CHANGED
|
@@ -40,10 +40,10 @@ import { UNBALANCED_MOVE_RANGE_WARNING, normalizeTrackedMoveRanges } from "./tra
|
|
|
40
40
|
import { getMediaMimeType, mediaToDataUrl, replaceRawDocxXmlParts, unzipDocx } from "./unzip.js";
|
|
41
41
|
import { renderWmfSvg } from "./wmfSvg.js";
|
|
42
42
|
import { getAttribute, getChildElements, getLocalName, parseXml, parseXmlDocument } from "./xmlParser.js";
|
|
43
|
-
import { FOLIO_XML_RESOURCE_LIMITS } from "./xmlResourceLimits.js";
|
|
44
43
|
import { TaggedError, panic } from "better-result";
|
|
45
44
|
import { PARSE_WARNING_CODES, setDocumentBodyComments } from "@stll/docx-core/model";
|
|
46
45
|
import { isCommentExhausted } from "@stll/docx-core/ops";
|
|
46
|
+
import { FOLIO_XML_RESOURCE_LIMITS } from "@stll/docx-core/xml/limits";
|
|
47
47
|
// src/docx/parser.ts
|
|
48
48
|
/**
|
|
49
49
|
* Main Parser Orchestrator - Unified parseDocx function
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { rewriteStreamingXmlDecimalAttributes } from "./streamingXmlParser.js";
|
|
2
1
|
import { WORDPROCESSINGML_NAMESPACE_URIS, findAttributeByNamespaceUri, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
3
|
-
import { XmlResourceLimitError, assertXmlResourceLimits } from "./xmlResourceLimits.js";
|
|
4
2
|
import { TaggedError } from "better-result";
|
|
3
|
+
import { rewriteStreamingXmlDecimalAttributes } from "@stll/docx-core/xml";
|
|
4
|
+
import { XmlResourceLimitError, assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
5
5
|
// src/docx/revisionIdNormalization.ts
|
|
6
6
|
const RevisionIdCollisionErrorBase = TaggedError("RevisionIdCollisionError");
|
|
7
7
|
/**
|
package/dist/docx/rezip.js
CHANGED
|
@@ -38,13 +38,13 @@ import { serializeStyle, serializeStylesXml } from "./serializer/stylesSerialize
|
|
|
38
38
|
import { serializeThemeXml } from "./serializer/themeSerializer.js";
|
|
39
39
|
import { updateEvenAndOddHeaders } from "./settingsHeaderFooterUpdate.js";
|
|
40
40
|
import { parseSettings } from "./settingsParser.js";
|
|
41
|
-
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "./streamingXmlParser.js";
|
|
42
41
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
43
42
|
import { hasCanonicalWordprocessingPrefixes } from "./wordprocessingPrefixes.js";
|
|
44
43
|
import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, findAttributeByNamespaceUri, findChild, findChildByNamespaceUri, findChildrenByNamespaceUri, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, matchesName, parseXml, parseXmlDocument } from "./xmlParser.js";
|
|
45
44
|
import { Result, TaggedError, panic } from "better-result";
|
|
46
45
|
import { assertValidOoxmlNumericIds, escapeXmlAttribute, escapeXmlText, validateDocxPackage } from "@stll/docx-core";
|
|
47
46
|
import { mintRelationshipId, numberingInstanceResolves } from "@stll/docx-core/model";
|
|
47
|
+
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
|
|
48
48
|
import { ZipArchive } from "@stll/docx-core/zip";
|
|
49
49
|
// src/docx/rezip.ts
|
|
50
50
|
const DocxPackageFidelityErrorBase = TaggedError("DocxPackageFidelityError");
|
|
@@ -69,8 +69,7 @@ const W15_LOCAL_NAMES = /* @__PURE__ */ new Set(["repeatingSection", "repeatingS
|
|
|
69
69
|
* would produce invalid XML in the saved DOCX — Word refuses files
|
|
70
70
|
* with unresolved namespace prefixes.
|
|
71
71
|
*
|
|
72
|
-
* Heuristics,
|
|
73
|
-
* preserveOrder mode:
|
|
72
|
+
* Heuristics, from when the XML reader did not surface namespace URIs:
|
|
74
73
|
*
|
|
75
74
|
* 1. If the captured wrapper element itself uses a non-`w` prefix, that
|
|
76
75
|
* prefix is taken to be bound to the WP URI (the source DOCX would
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { scanStreamingXmlElements } from "
|
|
1
|
+
import { scanStreamingXmlElements } from "@stll/docx-core/xml";
|
|
2
2
|
/** Identity census follows the parser's first-Choice, otherwise-Fallback policy. */
|
|
3
3
|
export declare const scanSelectedStreamingXmlElements: (xml: string, visitor: Parameters<typeof scanStreamingXmlElements>[1]) => {
|
|
4
4
|
status: "unsupported";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { scanStreamingXmlElements } from "./streamingXmlParser.js";
|
|
2
1
|
import { NAMESPACES, getLocalName, getNamespaceUri, selectAlternateContentBranch } from "./xmlParser.js";
|
|
2
|
+
import { scanStreamingXmlElements } from "@stll/docx-core/xml";
|
|
3
3
|
// src/docx/selectedXmlIdentityScan.ts
|
|
4
4
|
const isCompatibilityElement = (element, name) => getNamespaceUri(element) === NAMESPACES.mc && getLocalName(element.name) === name;
|
|
5
5
|
/** Identity census follows the parser's first-Choice, otherwise-Fallback policy. */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { patchBreaksCommentRangeBalance } from "./commentRangeIntegrity.js";
|
|
2
2
|
import { resolveParagraphIdentities } from "./paraIdAttribute.js";
|
|
3
3
|
import { readRootNamespaceBindings } from "./serializer/partNamespaces.js";
|
|
4
|
-
import { scanStreamingXmlElements } from "./streamingXmlParser.js";
|
|
5
4
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
6
5
|
import { PARAGRAPH_SCAN_NAMES, hasCanonicalWordprocessingPrefixes, matchCloseTag, matchOpenTag, resolveSelectiveScanPrefixes, splicesAsCanonical } from "./wordprocessingPrefixes.js";
|
|
7
|
-
import { resolveNamespaceUri } from "./xmlNamespaceContext.js";
|
|
8
6
|
import { NAMESPACES, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, findAttributeByNamespaceUri, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, parseXmlDocument } from "./xmlParser.js";
|
|
7
|
+
import { scanStreamingXmlElements } from "@stll/docx-core/xml";
|
|
8
|
+
import { resolveNamespaceUri } from "@stll/docx-core/xml/namespaces";
|
|
9
9
|
// src/docx/selectiveXmlPatch.ts
|
|
10
10
|
/**
|
|
11
11
|
* Selective XML Patch Module
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { XmlResourceLimits } from "../xmlResourceLimits.js";
|
|
2
1
|
import { TaggedErrorClass } from "better-result";
|
|
2
|
+
import { XmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
3
3
|
export declare const DOCX_MAX_ENTRY_BYTES: number;
|
|
4
4
|
export declare const DOCX_MAX_TOTAL_BYTES: number;
|
|
5
5
|
export declare const DOCX_MAX_ENTRIES = 4096;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decodeText } from "../../utils/textEncoding.js";
|
|
2
2
|
import { DOCX_COMPRESSION_RATIO_GRACE_BYTES, isRatioBoundedPart } from "../archiveInflation.js";
|
|
3
|
-
import { FOLIO_XML_RESOURCE_LIMITS, assertXmlResourceLimits, createXmlPackageBudget } from "../xmlResourceLimits.js";
|
|
4
3
|
import { Result, TaggedError } from "better-result";
|
|
4
|
+
import { FOLIO_XML_RESOURCE_LIMITS, assertXmlResourceLimits, createXmlPackageBudget } from "@stll/docx-core/xml/limits";
|
|
5
5
|
import { ZipArchive, ZipError } from "@stll/docx-core/zip";
|
|
6
6
|
// src/docx/server/boundedArchive.ts
|
|
7
7
|
const DOCX_MAX_ENTRY_BYTES = 134217728;
|
|
@@ -4,10 +4,10 @@ import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "../encryption/con
|
|
|
4
4
|
import { DocxModelValidationError, validateFolioDocumentModel } from "../modelValidation.js";
|
|
5
5
|
import { DocxParseError, parseDocx } from "../parser.js";
|
|
6
6
|
import { findChildByLocalName, getAttributeAnyPrefix, getLocalName, getNamespacePrefix, parseXmlDocument } from "../xmlParser.js";
|
|
7
|
-
import { XmlResourceLimitError } from "../xmlResourceLimits.js";
|
|
8
7
|
import { getDocxXmlSafetyIssue } from "../xmlSafety.js";
|
|
9
8
|
import { DocxArchiveError, loadDocxArchive } from "./boundedArchive.js";
|
|
10
9
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
10
|
+
import { XmlResourceLimitError } from "@stll/docx-core/xml/limits";
|
|
11
11
|
// src/docx/server/validateDocxConformance.ts
|
|
12
12
|
const FOLIO_DOCX_CONFORMANCE_REPORT_VERSION = 1;
|
|
13
13
|
const FOLIO_DOCX_CONFORMANCE_PROFILE = "folio-supported-v1";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
2
2
|
import { captureVerbatimXml, isSafeCapturedXmlDocument } from "./verbatimCapture.js";
|
|
3
3
|
import { NAMESPACES, WORDPROCESSINGML_NAMESPACE_URIS, cloneWithXmlnsDeclarations, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, parseXmlDocument } from "./xmlParser.js";
|
|
4
|
-
import { assertXmlResourceLimits } from "./xmlResourceLimits.js";
|
|
5
4
|
import { panic } from "better-result";
|
|
5
|
+
import { assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
6
6
|
// src/docx/shapeAlternateContent.ts
|
|
7
7
|
/**
|
|
8
8
|
* Every modeled field, text body included: the Fallback repeats the shape's
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
2
2
|
import { spliceXml } from "./selectiveXmlPatch.js";
|
|
3
|
-
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "./streamingXmlParser.js";
|
|
4
3
|
import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen.js";
|
|
5
4
|
import { captureSourceProfileXml, isSafeCapturedXmlDocument } from "./verbatimCapture.js";
|
|
6
5
|
import { WORDPROCESSINGML_NAMESPACE_URIS, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
7
6
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
8
7
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
8
|
+
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
|
|
9
9
|
// src/docx/storyBlockReplay.ts
|
|
10
10
|
const BLOCK_ELEMENT_NAMES = {
|
|
11
11
|
paragraph: "p",
|
package/dist/docx/unzip.js
CHANGED
|
@@ -4,8 +4,8 @@ import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "./encryption/cont
|
|
|
4
4
|
import { openDocxBuffer } from "./encryption/openEncryptedDocx.js";
|
|
5
5
|
import { RASTER_MIME_TYPES, detectRasterMimeType } from "./rasterMime.js";
|
|
6
6
|
import { decodeXmlBytes } from "./xmlEncoding.js";
|
|
7
|
-
import { FOLIO_XML_RESOURCE_LIMITS, assertXmlResourceLimits, createXmlPackageBudget } from "./xmlResourceLimits.js";
|
|
8
7
|
import { Result } from "better-result";
|
|
8
|
+
import { FOLIO_XML_RESOURCE_LIMITS, assertXmlResourceLimits, createXmlPackageBudget } from "@stll/docx-core/xml/limits";
|
|
9
9
|
import { ZipArchive, ZipError } from "@stll/docx-core/zip";
|
|
10
10
|
// src/docx/unzip.ts
|
|
11
11
|
/**
|
|
@@ -2,10 +2,10 @@ import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen
|
|
|
2
2
|
import { NUMBERS_PER_PERCENT, isStrictNamespaceUri, percentageSpelling, toTransitionalNamespaceUri, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
3
3
|
import { roundHalfAwayFromZero, universalMeasureAs } from "./universalMeasure.js";
|
|
4
4
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, elementToXml, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespacePrefix, parseXml, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
5
|
-
import { assertXmlResourceLimits } from "./xmlResourceLimits.js";
|
|
6
5
|
import { getDocxXmlSafetyIssue } from "./xmlSafety.js";
|
|
7
6
|
import { TaggedError, panic } from "better-result";
|
|
8
7
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
8
|
+
import { assertXmlResourceLimits } from "@stll/docx-core/xml/limits";
|
|
9
9
|
// src/docx/verbatimCapture.ts
|
|
10
10
|
/**
|
|
11
11
|
* The one way to turn parsed markup into a string a rebuilt part replays.
|
package/dist/docx/xmlParser.d.ts
CHANGED
|
@@ -1,32 +1,5 @@
|
|
|
1
1
|
import { ParseContext } from "./parseContext.js";
|
|
2
|
-
|
|
3
|
-
* XML element tree node — drop-in replacement for the `Element` type
|
|
4
|
-
* previously imported from `xml-js`. Every consumer imports this from
|
|
5
|
-
* `xmlParser.ts`, so the shape must stay identical.
|
|
6
|
-
*/
|
|
7
|
-
export type XmlElement = {
|
|
8
|
-
declaration?: {
|
|
9
|
-
attributes?: Record<string, string | number>;
|
|
10
|
-
};
|
|
11
|
-
instruction?: string;
|
|
12
|
-
attributes?: Record<string, string | number | undefined>;
|
|
13
|
-
cdata?: string;
|
|
14
|
-
doctype?: string;
|
|
15
|
-
comment?: string;
|
|
16
|
-
text?: string | number | boolean;
|
|
17
|
-
type?: string;
|
|
18
|
-
name?: string;
|
|
19
|
-
/** Resolved namespace URI; non-enumerable so legacy structural comparisons stay stable. */
|
|
20
|
-
namespaceUri?: string;
|
|
21
|
-
/** In-scope namespace declarations; non-enumerable so legacy comparisons stay stable. */
|
|
22
|
-
namespaceScope?: XmlNamespaceScope;
|
|
23
|
-
elements?: XmlElement[];
|
|
24
|
-
};
|
|
25
|
-
/** Parent-linked XML namespace declarations; each scope stores only local overrides. */
|
|
26
|
-
export type XmlNamespaceScope = {
|
|
27
|
-
bindings: ReadonlyMap<string, string>;
|
|
28
|
-
parent?: XmlNamespaceScope;
|
|
29
|
-
};
|
|
2
|
+
import { XmlElement, XmlNamespaceScope } from "@stll/docx-core/xml";
|
|
30
3
|
/**
|
|
31
4
|
* Common OOXML namespace URIs — re-exported from @stll/docx-utils.
|
|
32
5
|
*/
|
|
@@ -67,16 +40,11 @@ export declare const NAMESPACES: {
|
|
|
67
40
|
*/
|
|
68
41
|
export declare const OOXML_NAMESPACE_SCOPE: XmlNamespaceScope;
|
|
69
42
|
export declare function parseXml(xml: string, inheritedNamespaceScope?: XmlNamespaceScope): XmlElement;
|
|
70
|
-
/**
|
|
71
|
-
* The general-purpose reader {@link parseXml} falls back to, and the reference
|
|
72
|
-
* the streaming reader's equivalence tests compare against.
|
|
73
|
-
*/
|
|
74
|
-
export declare function parseXmlWithFastXmlParser(xml: string, inheritedNamespaceScope?: XmlNamespaceScope): XmlElement;
|
|
75
43
|
/**
|
|
76
44
|
* Serialize an XmlElement back to an XML string.
|
|
77
45
|
*
|
|
78
|
-
* Written here rather than handed to
|
|
79
|
-
* reasons. The builder writes a tab or a newline inside an attribute value
|
|
46
|
+
* Written here rather than handed to a general-purpose XML builder (the one
|
|
47
|
+
* folio used before) for two reasons. The builder writes a tab or a newline inside an attribute value
|
|
80
48
|
* literally, and XML 1.0 §3.3.3 has every conformant reader normalise those to
|
|
81
49
|
* a space: a `descr="two lines
"` a source file wrote came back as
|
|
82
50
|
* `descr="two lines "`. `escapeXmlAttribute` writes the character references
|
|
@@ -405,4 +373,5 @@ export declare function cloneWithXmlnsDeclarations(element: XmlElement, xmlnsDec
|
|
|
405
373
|
* original's scope leaves resolution unchanged whether or not the clone
|
|
406
374
|
* carries `xmlns` attributes of its own.
|
|
407
375
|
*/
|
|
408
|
-
export declare function cloneElement(element: XmlElement, overrides: Partial<XmlElement>): XmlElement;
|
|
376
|
+
export declare function cloneElement(element: XmlElement, overrides: Partial<XmlElement>): XmlElement;
|
|
377
|
+
export type { XmlElement, XmlNamespaceScope };
|
package/dist/docx/xmlParser.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { parseStreamingXml } from "./streamingXmlParser.js";
|
|
2
1
|
import { NUMBERS_PER_PERCENT, percentageSpelling, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
3
2
|
import { universalMeasureAs } from "./universalMeasure.js";
|
|
4
|
-
import { EMPTY_NAMESPACE_SCOPE, attachXmlNamespaceContext, resolveNamespaceUri } from "./xmlNamespaceContext.js";
|
|
5
3
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
6
4
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
7
|
-
import {
|
|
5
|
+
import { XmlReadError, readXml } from "@stll/docx-core/xml";
|
|
6
|
+
import { EMPTY_NAMESPACE_SCOPE, attachXmlNamespaceContext, resolveNamespaceUri } from "@stll/docx-core/xml/namespaces";
|
|
8
7
|
import { OOXML_NS } from "@stll/docx-utils";
|
|
9
8
|
// src/docx/xmlParser.ts
|
|
10
9
|
/**
|
|
@@ -27,69 +26,6 @@ import { OOXML_NS } from "@stll/docx-utils";
|
|
|
27
26
|
* - o: Office (extensions)
|
|
28
27
|
* - pic: Pictures
|
|
29
28
|
*/
|
|
30
|
-
const fxpParserOptions = {
|
|
31
|
-
preserveOrder: true,
|
|
32
|
-
ignoreAttributes: false,
|
|
33
|
-
attributeNamePrefix: "",
|
|
34
|
-
trimValues: false,
|
|
35
|
-
textNodeName: "#text",
|
|
36
|
-
parseTagValue: false,
|
|
37
|
-
parseAttributeValue: false,
|
|
38
|
-
ignoreDeclaration: true,
|
|
39
|
-
ignorePiTags: true,
|
|
40
|
-
jPath: false,
|
|
41
|
-
processEntities: true,
|
|
42
|
-
htmlEntities: true
|
|
43
|
-
};
|
|
44
|
-
const fxpParserOptionsWithStopNodes = {
|
|
45
|
-
...fxpParserOptions,
|
|
46
|
-
stopNodes: ["*.w:binData"]
|
|
47
|
-
};
|
|
48
|
-
const fxpParser = new XMLParser(fxpParserOptions);
|
|
49
|
-
const fxpParserWithStopNodes = new XMLParser(fxpParserOptionsWithStopNodes);
|
|
50
|
-
/** Text node key used by fast-xml-parser in preserveOrder mode. */
|
|
51
|
-
const TEXT_KEY = "#text";
|
|
52
|
-
/** Attribute group key used by fast-xml-parser in preserveOrder mode. */
|
|
53
|
-
const ATTR_KEY = ":@";
|
|
54
|
-
/**
|
|
55
|
-
* Convert a fast-xml-parser preserveOrder node into an XmlElement.
|
|
56
|
-
*
|
|
57
|
-
* In preserveOrder mode every node is an object with exactly one "real" key
|
|
58
|
-
* (the tag name or `#text`) whose value is the children array, plus an
|
|
59
|
-
* optional `:@` key holding the attributes object.
|
|
60
|
-
*/
|
|
61
|
-
function fxpNodeToElement(node, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) {
|
|
62
|
-
if (TEXT_KEY in node) return {
|
|
63
|
-
type: "text",
|
|
64
|
-
text: node[TEXT_KEY]
|
|
65
|
-
};
|
|
66
|
-
const attrs = node[ATTR_KEY];
|
|
67
|
-
for (const key in node) {
|
|
68
|
-
if (key === ATTR_KEY) continue;
|
|
69
|
-
const children = node[key];
|
|
70
|
-
const element = {
|
|
71
|
-
type: "element",
|
|
72
|
-
name: key
|
|
73
|
-
};
|
|
74
|
-
if (attrs) element.attributes = attrs;
|
|
75
|
-
const namespaceScope = attachXmlNamespaceContext(element, inheritedNamespaceScope);
|
|
76
|
-
if (children.length > 0) {
|
|
77
|
-
for (let index = 0; index < children.length; index += 1) children[index] = fxpNodeToElement(children[index], namespaceScope);
|
|
78
|
-
element.elements = children;
|
|
79
|
-
}
|
|
80
|
-
return element;
|
|
81
|
-
}
|
|
82
|
-
return { type: "element" };
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Convert the top-level fast-xml-parser preserveOrder array into an
|
|
86
|
-
* XmlElement that matches xml-js's non-compact root structure:
|
|
87
|
-
* `{ elements: [...] }`.
|
|
88
|
-
*/
|
|
89
|
-
function fxpToRootElement(nodes, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) {
|
|
90
|
-
for (let index = 0; index < nodes.length; index += 1) nodes[index] = fxpNodeToElement(nodes[index], inheritedNamespaceScope);
|
|
91
|
-
return { elements: nodes };
|
|
92
|
-
}
|
|
93
29
|
/**
|
|
94
30
|
* Common OOXML namespace URIs — re-exported from @stll/docx-utils.
|
|
95
31
|
*/
|
|
@@ -112,21 +48,21 @@ const NAMESPACES = OOXML_NS;
|
|
|
112
48
|
*/
|
|
113
49
|
const OOXML_NAMESPACE_SCOPE = { bindings: new Map(Object.entries(OOXML_NS)) };
|
|
114
50
|
function parseXml(xml, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return
|
|
51
|
+
const read = readXml(xml, {
|
|
52
|
+
conformance: "tolerant",
|
|
53
|
+
inheritedNamespaceScope
|
|
54
|
+
});
|
|
55
|
+
if (read.status === "rejected") throw new XmlReadError({
|
|
56
|
+
message: `XML part could not be read: ${read.reason}`,
|
|
57
|
+
reason: read.reason
|
|
58
|
+
});
|
|
59
|
+
return read.value;
|
|
124
60
|
}
|
|
125
61
|
/**
|
|
126
62
|
* Serialize an XmlElement back to an XML string.
|
|
127
63
|
*
|
|
128
|
-
* Written here rather than handed to
|
|
129
|
-
* reasons. The builder writes a tab or a newline inside an attribute value
|
|
64
|
+
* Written here rather than handed to a general-purpose XML builder (the one
|
|
65
|
+
* folio used before) for two reasons. The builder writes a tab or a newline inside an attribute value
|
|
130
66
|
* literally, and XML 1.0 §3.3.3 has every conformant reader normalise those to
|
|
131
67
|
* a space: a `descr="two lines
"` a source file wrote came back as
|
|
132
68
|
* `descr="two lines "`. `escapeXmlAttribute` writes the character references
|
|
@@ -853,4 +789,4 @@ function cloneElement(element, overrides) {
|
|
|
853
789
|
attachXmlNamespaceContext(clone, element.namespaceScope);
|
|
854
790
|
return clone;
|
|
855
791
|
}
|
|
856
|
-
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, findWordprocessingChild, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument,
|
|
792
|
+
export { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, cloneWithXmlnsDeclarations, collectXmlnsDeclarations, elementToXml, findAllDeep, findAttributeByNamespaceUri, findByFullName, findChild, findChildByLocalName, findChildByNamespaceUri, findChildren, findChildrenByLocalName, findChildrenByNamespaceUri, findDeep, findWordprocessingChild, getAttribute, getAttributeAny, getAttributeAnyPrefix, getAttributeByNamespaceUri, getAttributes, getChildElements, getLocalName, getNamespacePrefix, getNamespaceUri, getTextContent, hasChild, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseColorElement, parseNumberingLevelAttribute, parseNumericAttribute, parseOnOffAttribute, parseOnOffChild, parseOnOffValue, parseTableMeasurementValue, parseXml, parseXmlDocument, resolveAttributeNamespaceUri, selectAlternateContentBranch };
|
package/dist/docx/xmlSafety.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { wellFormedXmlIssue } from "@stll/docx-core/xml";
|
|
2
2
|
// src/docx/xmlSafety.ts
|
|
3
3
|
const DOCTYPE_PATTERN = /<!DOCTYPE(?:\s|>)/iu;
|
|
4
4
|
const BUILT_IN_ENTITIES = /* @__PURE__ */ new Set([
|
|
@@ -75,9 +75,9 @@ const scanName = (xml, start) => {
|
|
|
75
75
|
} : null;
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
|
-
* Reject lexical forms
|
|
79
|
-
* This is deliberately a small XML lexer, not a second
|
|
80
|
-
* nesting remains
|
|
78
|
+
* Reject lexical forms with a DOCX-specific verdict before the reader's
|
|
79
|
+
* well-formedness check. This is deliberately a small XML lexer, not a second
|
|
80
|
+
* tree parser: structural nesting remains the reader's job.
|
|
81
81
|
*/
|
|
82
82
|
const hasInvalidXmlLexicalForm = (xml) => {
|
|
83
83
|
if (!containsOnlyXmlCharacters(xml)) return true;
|
|
@@ -160,6 +160,6 @@ const getDocxXmlSafetyIssue = (xml) => {
|
|
|
160
160
|
if (DOCTYPE_PATTERN.test(xml)) return "doctype-forbidden";
|
|
161
161
|
if (hasForbiddenEntity(xml)) return "entity-forbidden";
|
|
162
162
|
if (hasInvalidXmlLexicalForm(xml)) return "not-well-formed";
|
|
163
|
-
return
|
|
163
|
+
return wellFormedXmlIssue(xml) === null ? null : "not-well-formed";
|
|
164
164
|
};
|
|
165
165
|
export { getDocxXmlSafetyIssue };
|
|
@@ -1124,7 +1124,8 @@ function renderPage(page, context, options = {}) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
if (shouldClipHeader) {
|
|
1126
1126
|
headerEl.style.maxHeight = `${availableHeaderHeight}px`;
|
|
1127
|
-
headerEl.style.
|
|
1127
|
+
headerEl.style.overflowX = "visible";
|
|
1128
|
+
headerEl.style.overflowY = "clip";
|
|
1128
1129
|
headerEl.style.overflowClipMargin = `${HEADER_FOOTER_RULE_CLIP_MARGIN}px`;
|
|
1129
1130
|
}
|
|
1130
1131
|
pageEl.append(headerEl);
|
|
@@ -1177,7 +1178,8 @@ function renderPage(page, context, options = {}) {
|
|
|
1177
1178
|
}
|
|
1178
1179
|
if (shouldClipFooter) {
|
|
1179
1180
|
footerEl.style.maxHeight = `${availableFooterHeight}px`;
|
|
1180
|
-
footerEl.style.
|
|
1181
|
+
footerEl.style.overflowX = "visible";
|
|
1182
|
+
footerEl.style.overflowY = "clip";
|
|
1181
1183
|
footerEl.style.overflowClipMargin = `${HEADER_FOOTER_RULE_CLIP_MARGIN}px`;
|
|
1182
1184
|
}
|
|
1183
1185
|
pageEl.append(footerEl);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { RenderContext } from "./types.js";
|
|
3
|
+
export type CountedParagraphList = {
|
|
4
|
+
/**
|
|
5
|
+
* The list the paragraph shows: its own numbering's, or, while a pending
|
|
6
|
+
* property change removed it, the one that numbering showed.
|
|
7
|
+
*/
|
|
8
|
+
visibleList: document_d_exports.ListRendering | undefined;
|
|
9
|
+
/** The label the counter gave the paragraph; absent when it shows none. */
|
|
10
|
+
label: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare function countParagraphList(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, para: document_d_exports.Paragraph): CountedParagraphList;
|
|
13
|
+
/**
|
|
14
|
+
* Count the paragraphs of a text box Markdown does not write, cells
|
|
15
|
+
* included, in document order. A text box holds no text box, so the walk
|
|
16
|
+
* stops at each paragraph.
|
|
17
|
+
*/
|
|
18
|
+
export declare function countTextBoxLists(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, shape: document_d_exports.Shape): void;
|