@stll/folio-core 0.15.1 → 0.15.3
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 +2 -2
- package/dist/ai-edits/blockRange.js +1 -1
- package/dist/ai-edits/headless.js +9 -9
- package/dist/ai-edits/index.js +5 -5
- package/dist/ai-edits/read.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +2 -2
- package/dist/compat/eigenpal.js +19 -19
- package/dist/content-controls/mutateContentControls.js +1 -1
- package/dist/controller/contentControlWidgetController.js +1 -1
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorManager.js +5 -5
- package/dist/controller/layoutPipeline.js +10 -10
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/docx/blockContentParser.js +4 -4
- package/dist/docx/commentParser.js +30 -2
- package/dist/docx/documentParser.js +27 -3
- package/dist/docx/drawingIdNormalization.d.ts +5 -0
- package/dist/docx/drawingIdNormalization.js +35 -0
- package/dist/docx/drawingUtils.d.ts +1 -1
- package/dist/docx/drawingUtils.js +111 -27
- package/dist/docx/encryption/agileDecryption.js +1 -1
- package/dist/docx/encryption/encryptionInfo.js +1 -1
- package/dist/docx/encryption/index.js +1 -1
- package/dist/docx/encryption/openEncryptedDocx.js +3 -3
- package/dist/docx/fieldParser.js +1 -1
- package/dist/docx/footnoteParser.js +2 -2
- package/dist/docx/groupDrawingParser.js +1 -1
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterVerbatim.d.ts +2 -1
- package/dist/docx/headerFooterVerbatim.js +6 -1
- package/dist/docx/hyperlinkParser.js +1 -1
- package/dist/docx/imageParser.js +3 -3
- package/dist/docx/index.js +1 -1
- package/dist/docx/paragraphParser.js +8 -5
- package/dist/docx/paragraphTextBoxEnrichment.js +4 -4
- package/dist/docx/paragraphTraversal.d.ts +5 -3
- package/dist/docx/paragraphTraversal.js +20 -13
- package/dist/docx/parser.js +17 -7
- package/dist/docx/parserEnums.d.ts +4 -1
- package/dist/docx/parserEnums.js +5 -2
- package/dist/docx/rezip.js +9 -9
- package/dist/docx/runConsolidator.js +0 -1
- package/dist/docx/runParser.js +22 -6
- package/dist/docx/sectionParser.js +2 -2
- package/dist/docx/selectiveSave.js +7 -7
- package/dist/docx/serializer/commentSerializer.js +13 -8
- package/dist/docx/serializer/documentSerializer.js +7 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -3
- package/dist/docx/serializer/noteSerializer.js +2 -2
- package/dist/docx/serializer/numberingSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +2 -2
- package/dist/docx/serializer/runSerializer.js +19 -13
- package/dist/docx/serializer/sectionPropertiesSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +3 -3
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/server/docxToMarkdown.js +1 -1
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +1 -1
- package/dist/docx/server/extractDocxText.js +1 -1
- package/dist/docx/server/validateDocxConformance.js +3 -3
- package/dist/docx/shapeParser.js +5 -113
- package/dist/docx/styleParser.js +3 -3
- package/dist/docx/tableParser.js +11 -9
- package/dist/docx/textBoxParser.js +2 -2
- package/dist/docx/vmlImageParser.js +2 -2
- package/dist/fonts/embeddedFonts.js +2 -2
- package/dist/index.js +18 -18
- package/dist/layout-bridge/convert/footnoteLayout.js +2 -2
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -2
- package/dist/layout-bridge/convert/paragraphFrames.js +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -10
- package/dist/layout-bridge/engine/clickToPosition.js +2 -2
- package/dist/layout-bridge/engine/hitTest.js +1 -1
- package/dist/layout-bridge/engine/measuring/index.js +6 -6
- package/dist/layout-bridge/engine/selectionRects.js +5 -5
- package/dist/layout-engine/index.js +6 -6
- package/dist/layout-engine/measure/cache.js +2 -2
- package/dist/layout-engine/measure/index.js +6 -6
- package/dist/layout-engine/measure/lineBreaks.js +1 -1
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -1
- package/dist/layout-engine/measure/measureBlocks.js +7 -7
- package/dist/layout-engine/measure/measureContainer.js +3 -3
- package/dist/layout-engine/measure/measureHelpers.js +1 -1
- package/dist/layout-engine/measure/measureParagraph.js +7 -7
- package/dist/layout-engine/measure/tableCellFlow.js +1 -1
- package/dist/layout-engine/paginator.js +1 -1
- package/dist/layout-engine/tableRowBreak.js +2 -2
- package/dist/layout-painter/index.js +5 -5
- package/dist/layout-painter/registry/modules/textBox.js +1 -1
- package/dist/layout-painter/renderImage.js +1 -1
- package/dist/layout-painter/renderPage.js +7 -7
- package/dist/layout-painter/renderParagraph.js +13 -13
- package/dist/layout-painter/renderTable.js +6 -6
- package/dist/layout-painter/renderTextBox.js +1 -1
- package/dist/managers/DocumentLoaderManager.js +3 -3
- package/dist/managers/TableSelectionManager.js +1 -1
- package/dist/managers/editorShortcuts.js +1 -1
- package/dist/markdown/fromMarkdown.js +1 -1
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/renderRuns.js +1 -1
- package/dist/markdown/renderTable.js +1 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +3 -3
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +17 -2
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/contentControlsBlockFill.js +1 -1
- package/dist/prosemirror/commands/formatting.js +1 -1
- package/dist/prosemirror/commands/hyperlink.js +1 -1
- package/dist/prosemirror/commands/image.js +2 -2
- package/dist/prosemirror/commands/index.js +6 -6
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
- package/dist/prosemirror/commentOps.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +13 -9
- package/dist/prosemirror/conversion/index.js +1 -1
- package/dist/prosemirror/conversion/toProseDoc.js +9 -9
- package/dist/prosemirror/extensions/StarterKit.js +4 -4
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +4 -4
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -3
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -2
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +2 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +3 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +2 -2
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +1 -1
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/TabExtension.js +32 -9
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1 -1
- package/dist/prosemirror/index.js +15 -15
- package/dist/prosemirror/insertOperations.js +3 -3
- package/dist/prosemirror/plugins/templateDirectives.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/nodes.d.ts +4 -1
- package/dist/prosemirror/styles/styleResolver.js +1 -1
- package/dist/prosemirror/validation.js +5 -3
- package/dist/redline.js +1 -1
- package/dist/render-dom/BodySelectionOverlay.js +2 -2
- package/dist/server.js +15 -15
- package/dist/style-sets/extract.js +1 -1
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +4 -1
- package/dist/types/documentEnumValues.js +14 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/version-comparison.js +2 -2
- package/package.json +2 -2
package/dist/docx/runParser.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, ShadingPatternSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
-
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getLocalName, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
3
|
-
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
4
|
-
import { parseImage } from "./imageParser.js";
|
|
5
1
|
import { parseGroupDrawing } from "./groupDrawingParser.js";
|
|
2
|
+
import { parseImage } from "./imageParser.js";
|
|
3
|
+
import { EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, PositionalTabAlignmentSchema, PositionalTabLeaderSchema, PositionalTabRelativeToSchema, ShadingPatternSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
6
4
|
import { parseShapeFromDrawing, shouldPreserveRawShapeDrawing } from "./shapeParser.js";
|
|
7
|
-
import {
|
|
8
|
-
import { resolveThemeFontRef } from "./themeParser.js";
|
|
5
|
+
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
9
6
|
import { requiresXmlSpacePreserve } from "./textWhitespace.js";
|
|
7
|
+
import { resolveThemeFontRef } from "./themeParser.js";
|
|
8
|
+
import { parseVmlImageContent } from "./vmlImageParser.js";
|
|
9
|
+
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getLocalName, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
10
10
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
11
11
|
//#region src/docx/runParser.ts
|
|
12
12
|
/**
|
|
@@ -386,6 +386,19 @@ function parseTextContent(element) {
|
|
|
386
386
|
function parseTabContent() {
|
|
387
387
|
return { type: "tab" };
|
|
388
388
|
}
|
|
389
|
+
function parsePositionalTabContent(element) {
|
|
390
|
+
const positional = {};
|
|
391
|
+
const relativeTo = narrowEnum(getAttribute(element, "w", "relativeTo"), PositionalTabRelativeToSchema);
|
|
392
|
+
const alignment = narrowEnum(getAttribute(element, "w", "alignment"), PositionalTabAlignmentSchema);
|
|
393
|
+
const leader = narrowEnum(getAttribute(element, "w", "leader"), PositionalTabLeaderSchema);
|
|
394
|
+
if (relativeTo !== void 0) positional.relativeTo = relativeTo;
|
|
395
|
+
if (alignment !== void 0) positional.alignment = alignment;
|
|
396
|
+
if (leader !== void 0) positional.leader = leader;
|
|
397
|
+
return {
|
|
398
|
+
type: "tab",
|
|
399
|
+
positional
|
|
400
|
+
};
|
|
401
|
+
}
|
|
389
402
|
/**
|
|
390
403
|
* Parse break element (w:br)
|
|
391
404
|
*/
|
|
@@ -516,6 +529,9 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
516
529
|
case "tab":
|
|
517
530
|
contents.push(parseTabContent());
|
|
518
531
|
break;
|
|
532
|
+
case "ptab":
|
|
533
|
+
contents.push(parsePositionalTabContent(child));
|
|
534
|
+
break;
|
|
519
535
|
case "br":
|
|
520
536
|
contents.push(parseBreakContent(child));
|
|
521
537
|
break;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BorderStyleSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
-
import { findChild, findChildren, getAttribute, getChildElements, getLocalName, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
3
1
|
import { parseFooterReference, parseHeaderReference } from "./headerFooterRefParser.js";
|
|
4
2
|
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
3
|
+
import { BorderStyleSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
4
|
+
import { findChild, findChildren, getAttribute, getChildElements, getLocalName, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
5
5
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
6
6
|
//#region src/docx/sectionParser.ts
|
|
7
7
|
/**
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { parseNumbering } from "./numberingParser.js";
|
|
2
|
-
import { RELATIONSHIP_TYPES } from "./relsParser.js";
|
|
3
1
|
import { parseCommentsExtended } from "./commentParser.js";
|
|
4
|
-
import { validateFolioDocumentModel } from "./modelValidation.js";
|
|
5
|
-
import { isPreservableDocxEntry } from "./unzip.js";
|
|
6
|
-
import { hasUnsynthesizedReplyRanges } from "./commentReplyMarkers.js";
|
|
7
2
|
import { withoutOrphanCommentRanges } from "./commentRangeIntegrity.js";
|
|
3
|
+
import { hasUnsynthesizedReplyRanges } from "./commentReplyMarkers.js";
|
|
4
|
+
import { validateFolioDocumentModel } from "./modelValidation.js";
|
|
8
5
|
import { isNewDataUrlDrawing } from "./newImage.js";
|
|
6
|
+
import { parseNumbering } from "./numberingParser.js";
|
|
7
|
+
import { RELATIONSHIP_TYPES } from "./relsParser.js";
|
|
8
|
+
import { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_PART_LOWER, addCommentsExtendedOverride, addCommentsExtendedRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, updateCoreProperties } from "./rezip.js";
|
|
9
|
+
import "./selectiveSaveFlags.js";
|
|
9
10
|
import { buildPatchedDocumentXml, buildPatchedNoteXml, buildPatchedNumberingXml, collectChangedNumberingDefs, collectParaIds } from "./selectiveXmlPatch.js";
|
|
10
11
|
import { ensureThreadedCommentParaIds, serializeComments, serializeCommentsExtended } from "./serializer/commentSerializer.js";
|
|
11
12
|
import { serializeDocument } from "./serializer/documentSerializer.js";
|
|
12
13
|
import { serializeEndnotes, serializeFootnotes } from "./serializer/noteSerializer.js";
|
|
13
14
|
import { serializeNumberingXml } from "./serializer/numberingSerializer.js";
|
|
14
|
-
import {
|
|
15
|
-
import "./selectiveSaveFlags.js";
|
|
15
|
+
import { isPreservableDocxEntry } from "./unzip.js";
|
|
16
16
|
//#region src/docx/selectiveSave.ts
|
|
17
17
|
/**
|
|
18
18
|
* Check if document content has new images (data: URL without rId) or
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
import { deterministicHexId } from "../../utils/hexId.js";
|
|
2
|
-
import { escapeXml } from "./xmlUtils.js";
|
|
3
2
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
3
|
+
import { serializeTextFormatting } from "./runSerializer.js";
|
|
4
|
+
import { escapeXml } from "./xmlUtils.js";
|
|
4
5
|
//#region src/docx/serializer/commentSerializer.ts
|
|
5
6
|
/**
|
|
6
7
|
* Comment Serializer
|
|
7
8
|
*
|
|
8
9
|
* Serializes Comment[] to OOXML comments.xml format.
|
|
9
10
|
*/
|
|
10
|
-
const
|
|
11
|
+
const DEFAULT_ANNOTATION_REFERENCE_PROPERTIES = "<w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr>";
|
|
11
12
|
const PARAGRAPH_PROPERTIES_END = "</w:pPr>";
|
|
13
|
+
const serializeAnnotationReference = (formatting) => {
|
|
14
|
+
return `<w:r>${formatting ? serializeTextFormatting(formatting) : DEFAULT_ANNOTATION_REFERENCE_PROPERTIES}<w:annotationRef/></w:r>`;
|
|
15
|
+
};
|
|
12
16
|
/** Serialize a paragraph, prepending an annotationRef run (required by Word in first paragraph of a comment) */
|
|
13
|
-
function serializeParagraphWithAnnotationRef(paragraph) {
|
|
17
|
+
function serializeParagraphWithAnnotationRef(paragraph, formatting) {
|
|
14
18
|
const xml = serializeParagraph(paragraph);
|
|
19
|
+
const annotationReference = serializeAnnotationReference(formatting);
|
|
15
20
|
const propertiesEnd = xml.indexOf(PARAGRAPH_PROPERTIES_END);
|
|
16
21
|
if (propertiesEnd !== -1) {
|
|
17
22
|
const contentStart = propertiesEnd + 8;
|
|
18
|
-
return `${xml.slice(0, contentStart)}${
|
|
23
|
+
return `${xml.slice(0, contentStart)}${annotationReference}${xml.slice(contentStart)}`;
|
|
19
24
|
}
|
|
20
|
-
return xml.replace(/^<w:p(?=[\s>])[^>]*>/u, (openingTag) => `${openingTag}${
|
|
25
|
+
return xml.replace(/^<w:p(?=[\s>])[^>]*>/u, (openingTag) => `${openingTag}${annotationReference}`);
|
|
21
26
|
}
|
|
22
27
|
function serializeComment(comment) {
|
|
23
28
|
const attrs = [`w:id="${comment.id}"`, `w:author="${escapeXml(comment.author)}"`];
|
|
24
|
-
if (comment.initials) attrs.push(`w:initials="${escapeXml(comment.initials)}"`);
|
|
29
|
+
if (comment.initials !== void 0) attrs.push(`w:initials="${escapeXml(comment.initials)}"`);
|
|
25
30
|
if (comment.date) attrs.push(`w:date="${escapeXml(comment.date)}"`);
|
|
26
31
|
let xml = `<w:comment ${attrs.join(" ")}>`;
|
|
27
32
|
if (comment.content.length > 0) {
|
|
28
|
-
xml += serializeParagraphWithAnnotationRef(comment.content[0]);
|
|
33
|
+
xml += serializeParagraphWithAnnotationRef(comment.content[0], comment.annotationReferenceFormatting);
|
|
29
34
|
for (let i = 1; i < comment.content.length; i++) xml += serializeParagraph(comment.content[i]);
|
|
30
|
-
} else xml +=
|
|
35
|
+
} else xml += `<w:p>${serializeAnnotationReference(comment.annotationReferenceFormatting)}</w:p>`;
|
|
31
36
|
xml += "</w:comment>";
|
|
32
37
|
return xml;
|
|
33
38
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
2
|
+
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
2
3
|
import { resetAutoIdCounter } from "./runSerializer.js";
|
|
3
4
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
4
|
-
import {
|
|
5
|
-
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
5
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
6
6
|
//#region src/docx/serializer/documentSerializer.ts
|
|
7
7
|
/**
|
|
8
8
|
* Standard OOXML namespaces for document.xml
|
|
9
9
|
*/
|
|
10
10
|
const NAMESPACES = {
|
|
11
|
+
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
11
12
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
12
13
|
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
13
14
|
cx1: "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",
|
|
@@ -23,6 +24,7 @@ const NAMESPACES = {
|
|
|
23
24
|
am3d: "http://schemas.microsoft.com/office/drawing/2017/model3d",
|
|
24
25
|
o: "urn:schemas-microsoft-com:office:office",
|
|
25
26
|
oel: "http://schemas.microsoft.com/office/2019/extlst",
|
|
27
|
+
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
26
28
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
27
29
|
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
28
30
|
v: "urn:schemas-microsoft-com:vml",
|
|
@@ -47,9 +49,11 @@ const NAMESPACES = {
|
|
|
47
49
|
*/
|
|
48
50
|
function buildNamespaceDeclarations() {
|
|
49
51
|
const declared = {
|
|
52
|
+
a: NAMESPACES.a,
|
|
50
53
|
wpc: NAMESPACES.wpc,
|
|
51
54
|
mc: NAMESPACES.mc,
|
|
52
55
|
o: NAMESPACES.o,
|
|
56
|
+
pic: NAMESPACES.pic,
|
|
53
57
|
r: NAMESPACES.r,
|
|
54
58
|
m: NAMESPACES.m,
|
|
55
59
|
v: NAMESPACES.v,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { canReplayHeaderFooterVerbatim, getHeaderFooterVerbatimXml } from "../headerFooterVerbatim.js";
|
|
2
|
-
import { escapeXml } from "./xmlUtils.js";
|
|
3
|
-
import { serializeTable } from "./tableSerializer.js";
|
|
4
|
-
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
5
2
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
3
|
+
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
4
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
5
|
+
import { escapeXml } from "./xmlUtils.js";
|
|
6
6
|
//#region src/docx/serializer/headerFooterSerializer.ts
|
|
7
7
|
const NAMESPACES = {
|
|
8
8
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { serializeTable } from "./tableSerializer.js";
|
|
2
|
-
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
3
1
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
2
|
+
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
3
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
4
4
|
//#region src/docx/serializer/noteSerializer.ts
|
|
5
5
|
const NAMESPACES = {
|
|
6
6
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
2
1
|
import { serializeTextFormatting } from "./runSerializer.js";
|
|
2
|
+
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
3
3
|
//#region src/docx/serializer/numberingSerializer.ts
|
|
4
4
|
const W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
5
5
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { numPrEqual } from "../numberingParser.js";
|
|
2
1
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
2
|
+
import { numPrEqual } from "../numberingParser.js";
|
|
3
3
|
import { reconcileRawSdtPr } from "../sdtPropertiesPatch.js";
|
|
4
|
-
import { escapeXml, intAttr, isSingleWellFormedElement } from "./xmlUtils.js";
|
|
5
4
|
import { serializeBorder } from "./borderSerializer.js";
|
|
6
5
|
import { serializeRun, serializeTextFormatting } from "./runSerializer.js";
|
|
7
6
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
7
|
+
import { escapeXml, intAttr, isSingleWellFormedElement } from "./xmlUtils.js";
|
|
8
8
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
9
9
|
//#region src/docx/serializer/paragraphSerializer.ts
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HIGHLIGHT_COLOR_VALUES } from "../../types/documentEnumValues.js";
|
|
2
|
-
import { THEME_COLOR_TO_DRAWING_SCHEME } from "../drawingUtils.js";
|
|
3
2
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
3
|
+
import { THEME_COLOR_TO_DRAWING_SCHEME } from "../drawingUtils.js";
|
|
4
4
|
import { requiresXmlSpacePreserve } from "../textWhitespace.js";
|
|
5
|
-
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
6
|
-
import { serializeTable } from "./tableSerializer.js";
|
|
7
5
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
6
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
7
|
+
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
8
8
|
import { panic } from "better-result";
|
|
9
9
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
10
10
|
//#region src/docx/serializer/runSerializer.ts
|
|
@@ -38,7 +38,7 @@ function getUniqueId(id) {
|
|
|
38
38
|
return String(nextAutoId++);
|
|
39
39
|
}
|
|
40
40
|
/** Valid OOXML highlight color names (ECMA-376 §17.18.40) */
|
|
41
|
-
const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES
|
|
41
|
+
const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
|
|
42
42
|
/**
|
|
43
43
|
* Serialize a color element (w:color)
|
|
44
44
|
*/
|
|
@@ -132,7 +132,7 @@ function serializeTextFormatting(formatting) {
|
|
|
132
132
|
if (formatting.position !== void 0) parts.push(`<w:position w:val="${intAttr(formatting.position)}"/>`);
|
|
133
133
|
if (formatting.fontSize !== void 0) parts.push(`<w:sz w:val="${intAttr(formatting.fontSize)}"/>`);
|
|
134
134
|
if (formatting.fontSizeCs !== void 0) parts.push(`<w:szCs w:val="${intAttr(formatting.fontSizeCs)}"/>`);
|
|
135
|
-
if (formatting.highlight
|
|
135
|
+
if (formatting.highlight) {
|
|
136
136
|
if (VALID_HIGHLIGHT_COLORS.has(formatting.highlight)) parts.push(`<w:highlight w:val="${formatting.highlight}"/>`);
|
|
137
137
|
else if (!formatting.shading) {
|
|
138
138
|
const hex = formatting.highlight.replace(/^#/u, "");
|
|
@@ -150,13 +150,14 @@ function serializeTextFormatting(formatting) {
|
|
|
150
150
|
parts.push(`<w:u ${uAttrs.join(" ")}/>`);
|
|
151
151
|
}
|
|
152
152
|
if (formatting.effect && formatting.effect !== "none") parts.push(`<w:effect w:val="${formatting.effect}"/>`);
|
|
153
|
-
if (formatting.emphasisMark
|
|
153
|
+
if (formatting.emphasisMark) parts.push(`<w:em w:val="${formatting.emphasisMark}"/>`);
|
|
154
154
|
const shadingXml = serializeShading(formatting.shading);
|
|
155
155
|
if (shadingXml) parts.push(shadingXml);
|
|
156
156
|
if (formatting.vertAlign) parts.push(`<w:vertAlign w:val="${formatting.vertAlign}"/>`);
|
|
157
157
|
if (formatting.rtl === true) parts.push("<w:rtl/>");
|
|
158
158
|
else if (formatting.rtl === false) parts.push("<w:rtl w:val=\"0\"/>");
|
|
159
|
-
if (formatting.cs) parts.push("<w:cs/>");
|
|
159
|
+
if (formatting.cs === true) parts.push("<w:cs/>");
|
|
160
|
+
else if (formatting.cs === false) parts.push("<w:cs w:val=\"0\"/>");
|
|
160
161
|
if (parts.length === 0) return "";
|
|
161
162
|
return `<w:rPr>${parts.join("")}</w:rPr>`;
|
|
162
163
|
}
|
|
@@ -191,8 +192,13 @@ function serializeTextContent(content) {
|
|
|
191
192
|
/**
|
|
192
193
|
* Serialize tab content (w:tab)
|
|
193
194
|
*/
|
|
194
|
-
function serializeTabContent(
|
|
195
|
-
return "<w:tab/>";
|
|
195
|
+
function serializeTabContent(content) {
|
|
196
|
+
if (!content.positional) return "<w:tab/>";
|
|
197
|
+
return `<w:ptab${[
|
|
198
|
+
content.positional.relativeTo ? ` w:relativeTo="${escapeXml(content.positional.relativeTo)}"` : "",
|
|
199
|
+
content.positional.alignment ? ` w:alignment="${escapeXml(content.positional.alignment)}"` : "",
|
|
200
|
+
content.positional.leader ? ` w:leader="${escapeXml(content.positional.leader)}"` : ""
|
|
201
|
+
].join("")}/>`;
|
|
196
202
|
}
|
|
197
203
|
/**
|
|
198
204
|
* Serialize break content (w:br)
|
|
@@ -201,10 +207,8 @@ function serializeBreakContent(content) {
|
|
|
201
207
|
const attrs = [];
|
|
202
208
|
if (content.breakType === "page") attrs.push("w:type=\"page\"");
|
|
203
209
|
else if (content.breakType === "column") attrs.push("w:type=\"column\"");
|
|
204
|
-
else if (content.breakType === "textWrapping")
|
|
205
|
-
|
|
206
|
-
if (content.clear && content.clear !== "none") attrs.push(`w:clear="${content.clear}"`);
|
|
207
|
-
}
|
|
210
|
+
else if (content.breakType === "textWrapping") attrs.push("w:type=\"textWrapping\"");
|
|
211
|
+
if (content.clear !== void 0) attrs.push(`w:clear="${content.clear}"`);
|
|
208
212
|
if (attrs.length === 0) return "<w:br/>";
|
|
209
213
|
return `<w:br ${attrs.join(" ")}/>`;
|
|
210
214
|
}
|
|
@@ -264,6 +268,7 @@ function serializeDrawingColor(color) {
|
|
|
264
268
|
/** Serialize shape fill to DrawingML */
|
|
265
269
|
function serializeFill(fill) {
|
|
266
270
|
if (!fill) return "";
|
|
271
|
+
if (fill.rawXml) return fill.rawXml;
|
|
267
272
|
if (fill.type === "none") return "<a:noFill/>";
|
|
268
273
|
if (fill.type === "solid" && fill.color) return `<a:solidFill>${serializeDrawingColor(fill.color)}</a:solidFill>`;
|
|
269
274
|
if (fill.type === "gradient" && fill.gradient) {
|
|
@@ -286,6 +291,7 @@ function serializeLineCap(cap) {
|
|
|
286
291
|
}
|
|
287
292
|
function serializeOutline(outline) {
|
|
288
293
|
if (!outline) return "";
|
|
294
|
+
if (outline.rawXml) return outline.rawXml;
|
|
289
295
|
const attrs = [];
|
|
290
296
|
if (typeof outline.width === "number") attrs.push(`w="${outline.width}"`);
|
|
291
297
|
if (outline.cap) attrs.push(`cap="${serializeLineCap(outline.cap)}"`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getUnserializedSectionPropertyChildNames } from "../sectionParser.js";
|
|
2
|
-
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
3
2
|
import { serializeBorder } from "./borderSerializer.js";
|
|
3
|
+
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
4
4
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
5
5
|
//#region src/docx/serializer/sectionPropertiesSerializer.ts
|
|
6
6
|
const serializeHeaderReference = (ref) => `<w:headerReference w:type="${ref.type}" r:id="${ref.rId}"/>`;
|
|
@@ -51,7 +51,7 @@ function serializePaperSource(props) {
|
|
|
51
51
|
return attrs.length > 0 ? `<w:paperSrc ${attrs.join(" ")}/>` : "";
|
|
52
52
|
}
|
|
53
53
|
function serializeColumns(props) {
|
|
54
|
-
if (props.columnCount === void 0 && !props.columns?.length && props.columnSpace === void 0) return "";
|
|
54
|
+
if (props.columnCount === void 0 && !props.columns?.length && props.columnSpace === void 0 && props.equalWidth === void 0) return "";
|
|
55
55
|
const attrs = [];
|
|
56
56
|
if (props.columnCount !== void 0 && props.columnCount >= 1) attrs.push(`w:num="${intAttr(props.columnCount)}"`);
|
|
57
57
|
if (props.columnSpace !== void 0) attrs.push(`w:space="${intAttr(props.columnSpace)}"`);
|
|
@@ -169,7 +169,8 @@ function serializeSectionProperties(props) {
|
|
|
169
169
|
]) if (xml) parts.push(xml);
|
|
170
170
|
if (props.verticalAlign) parts.push(`<w:vAlign w:val="${props.verticalAlign}"/>`);
|
|
171
171
|
if (props.textDirection) parts.push(`<w:textDirection w:val="${props.textDirection}"/>`);
|
|
172
|
-
|
|
172
|
+
const titlePgXml = serializeOnOffElement(props.titlePg, "titlePg");
|
|
173
|
+
if (titlePgXml) parts.push(titlePgXml);
|
|
173
174
|
const bidiXml = serializeOnOffElement(props.bidi, "bidi");
|
|
174
175
|
if (bidiXml) parts.push(bidiXml);
|
|
175
176
|
for (const xml of [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { escapeXml } from "./xmlUtils.js";
|
|
2
|
-
import { serializeTableCellFormatting, serializeTableFormatting, serializeTableRowFormatting } from "./tableSerializer.js";
|
|
3
|
-
import { serializeTextFormatting } from "./runSerializer.js";
|
|
4
1
|
import { serializeParagraphFormatting } from "./paragraphSerializer.js";
|
|
2
|
+
import { serializeTextFormatting } from "./runSerializer.js";
|
|
3
|
+
import { serializeTableCellFormatting, serializeTableFormatting, serializeTableRowFormatting } from "./tableSerializer.js";
|
|
4
|
+
import { escapeXml } from "./xmlUtils.js";
|
|
5
5
|
//#region src/docx/serializer/stylesSerializer.ts
|
|
6
6
|
const W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
7
7
|
const serializeStylesXml = (definitions) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
2
|
-
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
3
2
|
import { serializeBorder } from "./borderSerializer.js";
|
|
3
|
+
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
4
4
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
5
5
|
//#region src/docx/serializer/tableSerializer.ts
|
|
6
6
|
function normalizeTrackedChangeInfo(info) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DocxArchiveError } from "./boundedArchive.js";
|
|
2
1
|
import { getDocxXmlSafetyIssue } from "../xmlSafety.js";
|
|
2
|
+
import { DocxArchiveError } from "./boundedArchive.js";
|
|
3
3
|
import { FolioDocxPackageInspectionError, inspectDocxPackage } from "./inspectDocxPackage.js";
|
|
4
4
|
import { TaggedError, panic } from "better-result";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { findAllDeep, findChild, findDeep, getAttribute, getAttributeAnyPrefix, getLocalName, getTextContent, parseXml } from "../xmlParser.js";
|
|
2
1
|
import { RELATIONSHIP_TYPES, parseRelationships } from "../relsParser.js";
|
|
2
|
+
import { findAllDeep, findChild, findDeep, getAttribute, getAttributeAnyPrefix, getLocalName, getTextContent, parseXml } from "../xmlParser.js";
|
|
3
3
|
import { loadDocxArchive } from "./boundedArchive.js";
|
|
4
4
|
//#region src/docx/server/extractDocxText.ts
|
|
5
5
|
const DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { findChildByLocalName, getAttributeAnyPrefix, getLocalName, getNamespacePrefix, parseXmlDocument } from "../xmlParser.js";
|
|
2
1
|
import { detectDocxConformanceClass } from "../conformance.js";
|
|
3
|
-
import { DocxModelValidationError, validateFolioDocumentModel } from "../modelValidation.js";
|
|
4
2
|
import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "../encryption/containerFormat.js";
|
|
3
|
+
import { DocxModelValidationError, validateFolioDocumentModel } from "../modelValidation.js";
|
|
5
4
|
import { DocxParseError, parseDocx } from "../parser.js";
|
|
6
|
-
import {
|
|
5
|
+
import { findChildByLocalName, getAttributeAnyPrefix, getLocalName, getNamespacePrefix, parseXmlDocument } from "../xmlParser.js";
|
|
7
6
|
import { getDocxXmlSafetyIssue } from "../xmlSafety.js";
|
|
7
|
+
import { DocxArchiveError, loadDocxArchive } from "./boundedArchive.js";
|
|
8
8
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
9
9
|
//#region src/docx/server/validateDocxConformance.ts
|
|
10
10
|
const FOLIO_DOCX_CONFORMANCE_REPORT_VERSION = 1;
|
package/dist/docx/shapeParser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { parseAnchorPosition, parseAnchorWrap, parseFill, parseOutline } from "./drawingUtils.js";
|
|
2
|
+
import { ShapeTypeSchema, narrowEnum } from "./parserEnums.js";
|
|
3
|
+
import { findAllDeep, findChildByLocalName, getAttribute, parseNumericAttribute } from "./xmlParser.js";
|
|
4
4
|
//#region src/docx/shapeParser.ts
|
|
5
5
|
/** Convert OOXML rotation (1/60000ths of a degree) to degrees. */
|
|
6
6
|
function rotToDegrees(rot) {
|
|
@@ -13,115 +13,7 @@ function rotToDegrees(rot) {
|
|
|
13
13
|
* Falls through to `drawingUtils.parseFill` for solid / none cases.
|
|
14
14
|
*/
|
|
15
15
|
function parseShapeFill(spPr) {
|
|
16
|
-
|
|
17
|
-
if (base?.type !== "gradient" || !spPr) return base;
|
|
18
|
-
const gradFill = findChildByLocalName(spPr, "gradFill");
|
|
19
|
-
if (!gradFill) return base;
|
|
20
|
-
return parseGradientFill(gradFill);
|
|
21
|
-
}
|
|
22
|
-
function parseGradientFill(gradFill) {
|
|
23
|
-
let gradientType = "linear";
|
|
24
|
-
let angle;
|
|
25
|
-
const lin = findChildByLocalName(gradFill, "lin");
|
|
26
|
-
if (lin) {
|
|
27
|
-
gradientType = "linear";
|
|
28
|
-
const ang = getAttribute(lin, null, "ang");
|
|
29
|
-
if (ang) {
|
|
30
|
-
const parsed = Number.parseInt(ang, 10);
|
|
31
|
-
angle = Number.isNaN(parsed) ? void 0 : parsed / 6e4;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const path = findChildByLocalName(gradFill, "path");
|
|
35
|
-
if (path) {
|
|
36
|
-
const pathType = getAttribute(path, null, "path");
|
|
37
|
-
if (pathType === "circle") gradientType = "radial";
|
|
38
|
-
else if (pathType === "rect") gradientType = "rectangular";
|
|
39
|
-
else gradientType = "path";
|
|
40
|
-
}
|
|
41
|
-
const stops = [];
|
|
42
|
-
const gsLst = findChildByLocalName(gradFill, "gsLst");
|
|
43
|
-
if (gsLst) for (const gs of findChildrenByLocalName(gsLst, "gs")) {
|
|
44
|
-
const pos = getAttribute(gs, null, "pos");
|
|
45
|
-
const position = pos ? Number.parseInt(pos, 10) : 0;
|
|
46
|
-
const color = parseColorElement(gs);
|
|
47
|
-
if (color) stops.push({
|
|
48
|
-
position: Number.isNaN(position) ? 0 : position,
|
|
49
|
-
color
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
type: "gradient",
|
|
54
|
-
gradient: {
|
|
55
|
-
type: gradientType,
|
|
56
|
-
...angle !== void 0 ? { angle } : {},
|
|
57
|
-
stops
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const LINE_END_TYPES = /* @__PURE__ */ new Set([
|
|
62
|
-
"none",
|
|
63
|
-
"triangle",
|
|
64
|
-
"stealth",
|
|
65
|
-
"diamond",
|
|
66
|
-
"oval",
|
|
67
|
-
"arrow"
|
|
68
|
-
]);
|
|
69
|
-
function narrowLineEndType(value) {
|
|
70
|
-
if (value === null || value === void 0) return "none";
|
|
71
|
-
for (const allowed of LINE_END_TYPES) if (allowed === value) return allowed;
|
|
72
|
-
return "none";
|
|
73
|
-
}
|
|
74
|
-
function narrowLineEndSize(value) {
|
|
75
|
-
if (value === "sm" || value === "med" || value === "lg") return value;
|
|
76
|
-
}
|
|
77
|
-
function parseLineEnd(element) {
|
|
78
|
-
const type = narrowLineEndType(getAttribute(element, null, "type"));
|
|
79
|
-
const width = narrowLineEndSize(getAttribute(element, null, "w"));
|
|
80
|
-
const length = narrowLineEndSize(getAttribute(element, null, "len"));
|
|
81
|
-
return {
|
|
82
|
-
type,
|
|
83
|
-
...width !== void 0 ? { width } : {},
|
|
84
|
-
...length !== void 0 ? { length } : {}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Parse a shape outline with cap, join, and arrow end fidelity. Returns
|
|
89
|
-
* `undefined` when the spPr has no `<a:ln>`, an explicit `<a:noFill/>`,
|
|
90
|
-
* or no usable attributes.
|
|
91
|
-
*/
|
|
92
|
-
function parseShapeOutline(spPr) {
|
|
93
|
-
const ln = findChildByLocalName(spPr, "ln");
|
|
94
|
-
if (!ln) return;
|
|
95
|
-
if (findChildByLocalName(ln, "noFill")) return;
|
|
96
|
-
const outline = {};
|
|
97
|
-
const w = getAttribute(ln, null, "w");
|
|
98
|
-
if (w) {
|
|
99
|
-
const parsed = Number.parseInt(w, 10);
|
|
100
|
-
if (!Number.isNaN(parsed)) outline.width = parsed;
|
|
101
|
-
}
|
|
102
|
-
const cap = getAttribute(ln, null, "cap");
|
|
103
|
-
if (cap === "flat") outline.cap = "flat";
|
|
104
|
-
else if (cap === "rnd") outline.cap = "round";
|
|
105
|
-
else if (cap === "sq") outline.cap = "square";
|
|
106
|
-
if (findChildByLocalName(ln, "bevel")) outline.join = "bevel";
|
|
107
|
-
else if (findChildByLocalName(ln, "round")) outline.join = "round";
|
|
108
|
-
else if (findChildByLocalName(ln, "miter")) outline.join = "miter";
|
|
109
|
-
const solidFill = findChildByLocalName(ln, "solidFill");
|
|
110
|
-
if (solidFill) {
|
|
111
|
-
const color = parseColorElement(solidFill);
|
|
112
|
-
if (color) outline.color = color;
|
|
113
|
-
}
|
|
114
|
-
const prstDash = findChildByLocalName(ln, "prstDash");
|
|
115
|
-
if (prstDash) {
|
|
116
|
-
const narrowed = narrowEnum(getAttribute(prstDash, null, "val"), ShapeOutlineStyleSchema);
|
|
117
|
-
if (narrowed !== void 0) outline.style = narrowed;
|
|
118
|
-
}
|
|
119
|
-
const headEnd = findChildByLocalName(ln, "headEnd");
|
|
120
|
-
if (headEnd) outline.headEnd = parseLineEnd(headEnd);
|
|
121
|
-
const tailEnd = findChildByLocalName(ln, "tailEnd");
|
|
122
|
-
if (tailEnd) outline.tailEnd = parseLineEnd(tailEnd);
|
|
123
|
-
if (outline.width === void 0 && outline.color === void 0 && outline.cap === void 0 && outline.join === void 0 && outline.style === void 0 && outline.headEnd === void 0 && outline.tailEnd === void 0) return;
|
|
124
|
-
return outline;
|
|
16
|
+
return parseFill(spPr);
|
|
125
17
|
}
|
|
126
18
|
function parseTransform(xfrm) {
|
|
127
19
|
if (!xfrm) return { size: {
|
|
@@ -194,7 +86,7 @@ function parseShape(node) {
|
|
|
194
86
|
const shapeType = parseShapeType(spPr);
|
|
195
87
|
const { size, transform } = parseTransform(findChildByLocalName(spPr, "xfrm"));
|
|
196
88
|
const fill = parseShapeFill(spPr);
|
|
197
|
-
const outline =
|
|
89
|
+
const outline = parseOutline(spPr);
|
|
198
90
|
const id = cNvPr ? getAttribute(cNvPr, null, "id") ?? void 0 : void 0;
|
|
199
91
|
const name = cNvPr ? getAttribute(cNvPr, null, "name") ?? void 0 : void 0;
|
|
200
92
|
const shape = {
|
package/dist/docx/styleParser.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
-
import { findChild, findChildren, getAttribute, getLocalName, parseBooleanElement, parseNumberingLevelAttribute, parseNumericAttribute, parseTableMeasurementValue, parseXmlDocument } from "./xmlParser.js";
|
|
3
|
-
import { mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
4
1
|
import { mergeParagraphFormatting } from "../utils/paragraphFormattingMerge.js";
|
|
2
|
+
import { mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
3
|
+
import { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
5
4
|
import { resolveThemeFontRef } from "./themeParser.js";
|
|
5
|
+
import { findChild, findChildren, getAttribute, getLocalName, parseBooleanElement, parseNumberingLevelAttribute, parseNumericAttribute, parseTableMeasurementValue, parseXmlDocument } from "./xmlParser.js";
|
|
6
6
|
//#region src/docx/styleParser.ts
|
|
7
7
|
/**
|
|
8
8
|
* Parse text formatting properties (w:rPr)
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BorderStyleSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, ShadingPatternSchema, TableCellTextDirectionSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
-
import { findChild, findChildByLocalName, findChildren, getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, parseTableMeasurementValue } from "./xmlParser.js";
|
|
3
1
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
4
|
-
import { parseParagraph } from "./paragraphParser.js";
|
|
5
2
|
import { appendBookmarkMarkerToLastParagraphInBlocks, appendBookmarkMarkerToLastParagraphInCells, prependBookmarkMarkersToFirstParagraphInBlocks, prependBookmarkMarkersToFirstParagraphInCell } from "./bookmarkPlacement.js";
|
|
3
|
+
import { parseParagraph } from "./paragraphParser.js";
|
|
6
4
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
5
|
+
import { BorderStyleSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, ShadingPatternSchema, TableCellTextDirectionSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
6
|
+
import { findChild, findChildByLocalName, findChildren, getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, parseTableMeasurementValue } from "./xmlParser.js";
|
|
7
7
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
8
8
|
//#region src/docx/tableParser.ts
|
|
9
9
|
/**
|
|
@@ -394,12 +394,14 @@ function parseTableRowProperties(trPrElement) {
|
|
|
394
394
|
const heightElement = findChild(trPrElement, "w", "trHeight");
|
|
395
395
|
if (heightElement) {
|
|
396
396
|
const heightVal = parseNumericAttribute(heightElement, "w", "val");
|
|
397
|
-
if (heightVal !== void 0 && heightVal > 0)
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
397
|
+
if (heightVal !== void 0 && heightVal > 0) {
|
|
398
|
+
formatting.height = {
|
|
399
|
+
value: heightVal,
|
|
400
|
+
type: "dxa"
|
|
401
|
+
};
|
|
402
|
+
const hRule = getAttribute(heightElement, "w", "hRule");
|
|
403
|
+
if (hRule === "auto" || hRule === "atLeast" || hRule === "exact") formatting.heightRule = hRule;
|
|
404
|
+
}
|
|
403
405
|
}
|
|
404
406
|
if (parseBooleanElement(findChild(trPrElement, "w", "tblHeader"))) formatting.header = true;
|
|
405
407
|
if (parseBooleanElement(findChild(trPrElement, "w", "cantSplit"))) formatting.cantSplit = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { findByFullName, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, parseNumericAttribute } from "./xmlParser.js";
|
|
2
1
|
import { emuToPixels } from "../utils/units.js";
|
|
3
2
|
import { parseAnchorPosition, parseAnchorWrap, parseFill, parseOutline, resolveColorValueToHex } from "./drawingUtils.js";
|
|
3
|
+
import { findByFullName, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, parseNumericAttribute } from "./xmlParser.js";
|
|
4
4
|
//#region src/docx/textBoxParser.ts
|
|
5
5
|
/** Default text box margins in EMUs (0.1 inch) */
|
|
6
6
|
const DEFAULT_MARGIN_EMU = 91440;
|
|
@@ -133,7 +133,7 @@ function parseTextBox(drawingEl) {
|
|
|
133
133
|
if (position) textBox.position = position;
|
|
134
134
|
const wrap = parseAnchorWrap(container);
|
|
135
135
|
if (wrap) textBox.wrap = wrap;
|
|
136
|
-
}
|
|
136
|
+
} else textBox.wrap = { type: "inline" };
|
|
137
137
|
return textBox;
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
2
|
-
import { pixelsToEmu } from "../utils/units.js";
|
|
3
1
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
2
|
+
import { pixelsToEmu } from "../utils/units.js";
|
|
4
3
|
import { resolveImageData } from "./imageParser.js";
|
|
5
4
|
import { isWatermarkShape } from "./watermarkParser.js";
|
|
5
|
+
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
|
|
6
6
|
//#region src/docx/vmlImageParser.ts
|
|
7
7
|
const MAX_VML_PREVIEW_SHAPES = 256;
|
|
8
8
|
const MAX_VML_PREVIEW_DIMENSION_PX = 2e4;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseRelationships, resolveRelativePath } from "../docx/relsParser.js";
|
|
2
|
-
import { generateHexId } from "../utils/hexId.js";
|
|
3
2
|
import { unzipDocx } from "../docx/unzip.js";
|
|
4
|
-
import {
|
|
3
|
+
import { generateHexId } from "../utils/hexId.js";
|
|
5
4
|
import { parseEmbeddedFontTable } from "./embeddedFontTable.js";
|
|
5
|
+
import { deobfuscateFont, isValidFontKey } from "./fontDeobfuscation.js";
|
|
6
6
|
//#region src/fonts/embeddedFonts.ts
|
|
7
7
|
/**
|
|
8
8
|
* Embedded-font extraction.
|