@stll/folio-core 0.44.0 → 0.46.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/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/apply.js +59 -19
- package/dist/ai-edits/headless.js +2 -1
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +78 -53
- package/dist/compare/inline-atoms.js +34 -20
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +11 -0
- package/dist/content-controls/checkboxDisplay.js +40 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +21 -4
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +1 -1
- package/dist/display-list/build/imagePrimitives.js +3 -1
- package/dist/display-list/build/paragraphPrimitives.js +21 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +18 -10
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +14 -3
- package/dist/docx/attributeRemainder.d.ts +43 -0
- package/dist/docx/attributeRemainder.js +65 -0
- package/dist/docx/blockContentParser.d.ts +1 -1
- package/dist/docx/blockContentParser.js +87 -63
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +1 -0
- package/dist/docx/bookmarkPlacement.js +2 -0
- package/dist/docx/borderParser.js +5 -5
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +78 -50
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +1 -0
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- package/dist/docx/compatibility.js +1 -0
- package/dist/docx/containerChildren.d.ts +111 -0
- package/dist/docx/containerChildren.gen.d.ts +28 -0
- package/dist/docx/containerChildren.gen.js +246 -0
- package/dist/docx/containerChildren.js +103 -0
- package/dist/docx/diagramPreview.js +87 -27
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +3 -3
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +3 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +27 -8
- package/dist/docx/hyperlinkParser.js +78 -20
- package/dist/docx/imageParser.d.ts +9 -1
- package/dist/docx/imageParser.js +91 -20
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +30 -6
- package/dist/docx/inlineWrapperContent.d.ts +85 -0
- package/dist/docx/inlineWrapperContent.js +84 -0
- package/dist/docx/mathToMathml.js +12 -14
- package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
- package/dist/docx/nonVisualDrawingProps.js +46 -0
- package/dist/docx/normalizeBaseDirection.js +10 -1
- package/dist/docx/paraIdAttribute.d.ts +21 -0
- package/dist/docx/paraIdAttribute.js +64 -0
- package/dist/docx/paragraphParser.d.ts +1 -1
- package/dist/docx/paragraphParser.js +277 -168
- package/dist/docx/paragraphPropertySource.js +5 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +9 -52
- package/dist/docx/paragraphTraversal.js +7 -4
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +2 -2
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +86 -0
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -4
- package/dist/docx/revisionIdNormalization.js +17 -5
- package/dist/docx/rezip.js +91 -36
- package/dist/docx/runParser.d.ts +1 -1
- package/dist/docx/runParser.js +16 -12
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.js +8 -1
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/selectiveXmlPatch.d.ts +46 -2
- package/dist/docx/selectiveXmlPatch.js +86 -39
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +1 -1
- package/dist/docx/serializer/borderSerializer.js +15 -14
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +87 -92
- package/dist/docx/serializer/documentSerializer.js +8 -11
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +12 -14
- package/dist/docx/serializer/markupRangeAttributes.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +8 -8
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.js +93 -72
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +73 -44
- package/dist/docx/serializer/sectionPropertiesSerializer.js +19 -14
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +28 -17
- package/dist/docx/serializer/textFormattingSerializer.js +29 -28
- package/dist/docx/serializer/themeSerializer.js +6 -6
- package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
- package/dist/docx/serializer/xmlUtils.d.ts +1 -2
- package/dist/docx/serializer/xmlUtils.js +1 -13
- package/dist/docx/server/boundedArchive.d.ts +12 -0
- package/dist/docx/server/boundedArchive.js +20 -1
- package/dist/docx/server/createBilingualDocument.js +3 -1
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/server/validateDocxConformance.js +22 -1
- package/dist/docx/shapeParser.js +12 -10
- package/dist/docx/tableParser.d.ts +1 -1
- package/dist/docx/tableParser.js +206 -85
- package/dist/docx/textBoxParser.d.ts +25 -2
- package/dist/docx/textBoxParser.js +59 -4
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +37 -26
- package/dist/docx/verbatimCapture.js +1 -1
- package/dist/docx/vmlImageParser.d.ts +17 -1
- package/dist/docx/vmlImageParser.js +20 -3
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +26 -2
- package/dist/docx/xmlParser.js +70 -27
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- package/dist/headless-layout.js +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
- package/dist/internal/paragraphFormattingSerialization.js +3 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/types.d.ts +23 -1
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +14 -6
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +4 -0
- package/dist/layout-painter/renderParagraph.d.ts +13 -1
- package/dist/layout-painter/renderParagraph.js +26 -6
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +14 -12
- package/dist/markdown/images.js +1 -4
- package/dist/markdown/renderBlock.js +1 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +28 -5
- package/dist/markdown/renderTable.js +22 -5
- package/dist/markdown/trailers.js +4 -1
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +14 -3
- package/dist/prosemirror/attrs/index.js +224 -2
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/commands/contentControls.js +10 -2
- package/dist/prosemirror/commands/image.d.ts +9 -2
- package/dist/prosemirror/commands/image.js +43 -28
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +338 -99
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +551 -327
- package/dist/prosemirror/extensions/StarterKit.js +8 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
- package/dist/prosemirror/extensions/markRegistry.js +75 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +10 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +13 -5
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +75 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +6 -3
- package/dist/prosemirror/paragraphFormattingProvenance.js +12 -3
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +165 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +25 -1
- package/dist/prosemirror/schema/nodes.d.ts +139 -3
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/validation.js +16 -2
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
- package/dist/prosemirror/zeroWidthAnchors.js +2 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +29 -2
- package/dist/utils/findReplace.js +1 -1
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +7 -17
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/units.d.ts +10 -1
- package/dist/utils/units.js +12 -1
- package/dist/utils/urlSecurity.d.ts +8 -2
- package/dist/utils/urlSecurity.js +21 -3
- package/package.json +2 -2
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -68,6 +68,8 @@ function getTableCellFloatingImages(cell, cellMeasure, contentWidth, resolvePosi
|
|
|
68
68
|
...run.alt !== void 0 ? { alt: run.alt } : {},
|
|
69
69
|
...run.transform !== void 0 ? { transform: run.transform } : {},
|
|
70
70
|
...run.opacity != null ? { opacity: run.opacity } : {},
|
|
71
|
+
...run.brightness != null ? { brightness: run.brightness } : {},
|
|
72
|
+
...run.contrast != null ? { contrast: run.contrast } : {},
|
|
71
73
|
...run.cropTop != null ? { cropTop: run.cropTop } : {},
|
|
72
74
|
...run.cropRight != null ? { cropRight: run.cropRight } : {},
|
|
73
75
|
...run.cropBottom != null ? { cropBottom: run.cropBottom } : {},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OutlineStyleAttr } from "../types/documentEnumValues.js";
|
|
2
|
-
import { ImagePosition, ImageWrap, NumberFormat, SdtProperties, SdtType, ShapeTextBody, TableCellFormatting, TableWidthType, VerticalAlign } from "@stll/docx-core/model";
|
|
2
|
+
import { ImagePosition, ImageWrap, InlineWrapper, NumberFormat, SdtProperties, SdtType, ShapeTextBody, TableCellFormatting, TableWidthType, VerticalAlign } from "@stll/docx-core/model";
|
|
3
3
|
declare namespace types_d_exports {
|
|
4
4
|
export { BlockId, BorderStyle, CellBorderSpec, CellBorders, ColumnBreakBlock, ColumnBreakMeasure, ColumnLayout, DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, DocumentPosition, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, FieldRun, FloatingTablePosition, FlowBlock, FootnoteContent, Fragment, FragmentBase, HeaderFooterContent, HeaderFooterContentHeights, HeaderFooterLayout, HitTestResult, HyperlinkInfo, ImageBlock, ImageFragment, ImageMeasure, ImageRun, ImageRunPosition, Layout, LayoutOptions, LineBreakRun, ListMarkerFormatting, ListNumPr, MathRun, Measure, MeasuredLine, Page, PageBreakBlock, PageBreakMeasure, PageHeaderFooterRefs, PageMargins, ParagraphAttrs, ParagraphBlock, ParagraphBorders, ParagraphFragment, ParagraphIndent, ParagraphMeasure, ParagraphSpacing, RenderedPageBreakRun, Run, RunFormatting, SdtGroup, SectionBreakBlock, SectionBreakMeasure, SectionPageNumbering, TabAlignment, TabRun, TabStop, TableBlock, TableCell, TableCellMeasure, TableFragment, TableMeasure, TableRow, TableRowMeasure, TextBoxBlock, TextBoxFlowAttrs, TextBoxFragment, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, tableColumnsArePinned };
|
|
5
5
|
}
|
|
@@ -99,6 +99,20 @@ type RunFormatting = {
|
|
|
99
99
|
* RTL; the painter sets `dir="ltr"` so style/paragraph RTL does not leak in.
|
|
100
100
|
*/
|
|
101
101
|
rtl?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The bidirectional wrapper (`w:bdo` / `w:dir`) the run was authored inside,
|
|
104
|
+
* when it was inside one. An override switches the bidirectional algorithm
|
|
105
|
+
* off for its content, which is what makes a Latin word inside an `rtl`
|
|
106
|
+
* override read backwards; an embedding opens a level and leaves the
|
|
107
|
+
* algorithm on. `direction` is the wrapper's own `w:val`, absent when the
|
|
108
|
+
* wrapper states none.
|
|
109
|
+
*
|
|
110
|
+
* Distinct from `rtl`, which is the run's own `w:rtl` property: the wrapper
|
|
111
|
+
* is a container the author wrote around the run, not a property of it.
|
|
112
|
+
*/
|
|
113
|
+
bidiWrapper?: Omit<Extract<InlineWrapper, {
|
|
114
|
+
kind: "bidi";
|
|
115
|
+
}>, "type" | "kind" | "content">;
|
|
102
116
|
/**
|
|
103
117
|
* Text effect animation hint (w:effect). Word 2013+ no longer animates,
|
|
104
118
|
* but the painter emits `docx-text-effect-<name>` plus `data-effect` so
|
|
@@ -212,6 +226,10 @@ type ImageRun = {
|
|
|
212
226
|
* eigenpal #424 (opacity render pipeline).
|
|
213
227
|
*/
|
|
214
228
|
opacity?: number;
|
|
229
|
+
/** DrawingML picture brightness as a signed percentage. */
|
|
230
|
+
brightness?: number;
|
|
231
|
+
/** DrawingML picture contrast as a signed percentage. */
|
|
232
|
+
contrast?: number;
|
|
215
233
|
/** Position for floating/anchored images */
|
|
216
234
|
position?: ImageRunPosition;
|
|
217
235
|
/** Whether a table-cell anchor uses the cell as its positioning scope. Undefined defaults true. */
|
|
@@ -681,6 +699,10 @@ type ImageBlock = {
|
|
|
681
699
|
* eigenpal #424 (opacity render pipeline).
|
|
682
700
|
*/
|
|
683
701
|
opacity?: number;
|
|
702
|
+
/** DrawingML picture brightness as a signed percentage. */
|
|
703
|
+
brightness?: number;
|
|
704
|
+
/** DrawingML picture contrast as a signed percentage. */
|
|
705
|
+
contrast?: number;
|
|
684
706
|
anchor?: {
|
|
685
707
|
isAnchored?: boolean;
|
|
686
708
|
offsetH?: number;
|
|
@@ -15,6 +15,8 @@ declare const IMAGE_CLASS_NAMES: {
|
|
|
15
15
|
*/
|
|
16
16
|
type ImageVisualAttrs = {
|
|
17
17
|
opacity?: number;
|
|
18
|
+
brightness?: number;
|
|
19
|
+
contrast?: number;
|
|
18
20
|
cropTop?: number;
|
|
19
21
|
cropRight?: number;
|
|
20
22
|
cropBottom?: number;
|
|
@@ -43,6 +45,8 @@ declare function applyImageBorder(element: HTMLElement, border: ImageBorderAttrs
|
|
|
43
45
|
*/
|
|
44
46
|
declare function hasImageVisualAttrs(v: ImageVisualAttrs): boolean;
|
|
45
47
|
declare function hasImageCrop(v: ImageVisualAttrs): boolean;
|
|
48
|
+
/** Apply non-geometric opacity and luminance effects to an image element. */
|
|
49
|
+
declare function applyImageColorAttrs(img: HTMLImageElement, v: ImageVisualAttrs): void;
|
|
46
50
|
/**
|
|
47
51
|
* Apply an OOXML `<a:srcRect>` crop to an `<img>` whose parent already has
|
|
48
52
|
* `overflow: hidden` and is sized to the *visible* (cropped) dimensions
|
|
@@ -96,4 +100,4 @@ type RenderImageFragmentOptions = {
|
|
|
96
100
|
*/
|
|
97
101
|
declare function renderImageFragment(fragment: ImageFragment, block: ImageBlock, _measure: ImageMeasure, _context: RenderContext, options?: RenderImageFragmentOptions): HTMLElement;
|
|
98
102
|
//#endregion
|
|
99
|
-
export { IMAGE_CLASS_NAMES, ImageBorderAttrs, ImageVisualAttrs, RenderImageFragmentOptions, applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
|
|
103
|
+
export { IMAGE_CLASS_NAMES, ImageBorderAttrs, ImageVisualAttrs, RenderImageFragmentOptions, applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { imageLuminanceFilter } from "../utils/imageLuminance.js";
|
|
1
2
|
import { applySanitizedImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
2
|
-
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
3
|
+
import { anchorTargetAttrs, sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
3
4
|
//#region src/layout-painter/renderImage.ts
|
|
4
5
|
/**
|
|
5
6
|
* CSS class names for image elements
|
|
@@ -32,11 +33,17 @@ function applyImageBorder(element, border) {
|
|
|
32
33
|
*/
|
|
33
34
|
function hasImageVisualAttrs(v) {
|
|
34
35
|
if (v.opacity != null && v.opacity < 1) return true;
|
|
35
|
-
return hasImageCrop(v);
|
|
36
|
+
return imageLuminanceFilter(v) !== void 0 || hasImageCrop(v);
|
|
36
37
|
}
|
|
37
38
|
function hasImageCrop(v) {
|
|
38
39
|
return Boolean(v.cropTop || v.cropRight || v.cropBottom || v.cropLeft);
|
|
39
40
|
}
|
|
41
|
+
/** Apply non-geometric opacity and luminance effects to an image element. */
|
|
42
|
+
function applyImageColorAttrs(img, v) {
|
|
43
|
+
if (v.opacity != null && v.opacity < 1) img.style.opacity = String(Math.max(0, v.opacity));
|
|
44
|
+
const filter = imageLuminanceFilter(v);
|
|
45
|
+
if (filter !== void 0) img.style.filter = filter;
|
|
46
|
+
}
|
|
40
47
|
/**
|
|
41
48
|
* Apply an OOXML `<a:srcRect>` crop to an `<img>` whose parent already has
|
|
42
49
|
* `overflow: hidden` and is sized to the *visible* (cropped) dimensions
|
|
@@ -58,7 +65,7 @@ function hasImageCrop(v) {
|
|
|
58
65
|
* call for plain images.
|
|
59
66
|
*/
|
|
60
67
|
function applyImageVisualAttrs(img, v) {
|
|
61
|
-
|
|
68
|
+
applyImageColorAttrs(img, v);
|
|
62
69
|
const top = v.cropTop ?? 0;
|
|
63
70
|
const right = v.cropRight ?? 0;
|
|
64
71
|
const bottom = v.cropBottom ?? 0;
|
|
@@ -145,8 +152,9 @@ function renderImageFragment(fragment, block, _measure, _context, options = {})
|
|
|
145
152
|
if (hlinkHref) {
|
|
146
153
|
const linkEl = doc.createElement("a");
|
|
147
154
|
linkEl.href = hlinkHref;
|
|
148
|
-
|
|
149
|
-
linkEl.
|
|
155
|
+
const { target, rel } = anchorTargetAttrs(void 0);
|
|
156
|
+
linkEl.target = target;
|
|
157
|
+
linkEl.rel = rel;
|
|
150
158
|
linkEl.style.display = "block";
|
|
151
159
|
linkEl.style.width = "100%";
|
|
152
160
|
linkEl.style.height = "100%";
|
|
@@ -158,4 +166,4 @@ function renderImageFragment(fragment, block, _measure, _context, options = {})
|
|
|
158
166
|
return containerEl;
|
|
159
167
|
}
|
|
160
168
|
//#endregion
|
|
161
|
-
export { IMAGE_CLASS_NAMES, applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
|
|
169
|
+
export { IMAGE_CLASS_NAMES, applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, renderImageFragment, wrapImageWithCrop };
|
|
@@ -19,6 +19,8 @@ type PageFloatingImage = {
|
|
|
19
19
|
* opaque. eigenpal #424 (opacity render pipeline).
|
|
20
20
|
*/
|
|
21
21
|
opacity?: number;
|
|
22
|
+
brightness?: number;
|
|
23
|
+
contrast?: number;
|
|
22
24
|
/** Which side: 'left' for left margin, 'right' for right margin */
|
|
23
25
|
side: "left" | "right";
|
|
24
26
|
/** X position relative to content area (0 = left edge of content) */
|
|
@@ -371,6 +371,8 @@ function extractFloatingImagesFromParagraph(block, fragmentY, geometry) {
|
|
|
371
371
|
...imgRun.alt !== void 0 ? { alt: imgRun.alt } : {},
|
|
372
372
|
...imgRun.transform !== void 0 ? { transform: imgRun.transform } : {},
|
|
373
373
|
...imgRun.opacity != null ? { opacity: imgRun.opacity } : {},
|
|
374
|
+
...imgRun.brightness != null ? { brightness: imgRun.brightness } : {},
|
|
375
|
+
...imgRun.contrast != null ? { contrast: imgRun.contrast } : {},
|
|
374
376
|
side,
|
|
375
377
|
x,
|
|
376
378
|
y,
|
|
@@ -460,6 +462,8 @@ function renderHeaderFooterContent(content, context, options, layout) {
|
|
|
460
462
|
height: run.height,
|
|
461
463
|
...run.alt !== void 0 ? { alt: run.alt } : {},
|
|
462
464
|
...run.opacity != null ? { opacity: run.opacity } : {},
|
|
465
|
+
...run.brightness != null ? { brightness: run.brightness } : {},
|
|
466
|
+
...run.contrast != null ? { contrast: run.contrast } : {},
|
|
463
467
|
...run.pmStart !== void 0 ? { pmStart: run.pmStart } : {},
|
|
464
468
|
...run.pmEnd !== void 0 ? { pmEnd: run.pmEnd } : {},
|
|
465
469
|
paragraphY: paragraphStartY,
|
|
@@ -30,6 +30,18 @@ type RenderParagraphOptions = {
|
|
|
30
30
|
renderedInlineImageKeys?: Set<string>;
|
|
31
31
|
};
|
|
32
32
|
declare function getRenderableTextColor(run: TextRun | TabRun): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* How CSS spells each bidirectional wrapper: an override switches the
|
|
35
|
+
* bidirectional algorithm off for its content, an embedding opens a level and
|
|
36
|
+
* leaves it on.
|
|
37
|
+
*
|
|
38
|
+
* Both painters write the keyword from here, so the DOM painter and the
|
|
39
|
+
* display list cannot spell the pair differently.
|
|
40
|
+
*/
|
|
41
|
+
declare const UNICODE_BIDI_BY_WRAPPER_CONTROL: {
|
|
42
|
+
readonly override: "bidi-override";
|
|
43
|
+
readonly embedding: "embed";
|
|
44
|
+
};
|
|
33
45
|
/**
|
|
34
46
|
* Get leader character for tab
|
|
35
47
|
*/
|
|
@@ -134,4 +146,4 @@ declare function renderLine(block: ParagraphBlock, line: MeasuredLine, alignment
|
|
|
134
146
|
*/
|
|
135
147
|
declare function renderParagraphFragment(fragment: ParagraphFragment, block: ParagraphBlock, measure: ParagraphMeasure, context: RenderContext, options?: RenderParagraphOptions): HTMLElement;
|
|
136
148
|
//#endregion
|
|
137
|
-
export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|
|
149
|
+
export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|
|
@@ -8,6 +8,7 @@ import { DOCX_SCRIPT_FONT_SCALE } from "../layout-engine/measure/measureHelpers.
|
|
|
8
8
|
import { calculateTabWidth } from "../layout-engine/measure/tabCalculator.js";
|
|
9
9
|
import { FONT_KERNING_MODE, countCompressibleSpaces, getFontKerningMode, getRunFontKerningMode, toPaintedText } from "../layout-engine/measure/textMeasurementPolicy.js";
|
|
10
10
|
import { isFloatingImageRun } from "../layout-engine/types.js";
|
|
11
|
+
import { writeCommentAnchorIds } from "../render-dom/commentAnchorAttributes.js";
|
|
11
12
|
import { AUTHOR_COLORS, getAuthorColorIdx } from "../utils/authorColors.js";
|
|
12
13
|
import { resolveFontFamily } from "../utils/fontResolver.js";
|
|
13
14
|
import "../utils/fontWeights.js";
|
|
@@ -16,11 +17,11 @@ import { resolvePhysicalParagraphInlineLayout } from "../utils/paragraphInlineLa
|
|
|
16
17
|
import { inlineImageBoundingBox, parseRotationDegrees, rotatedBoundingBox } from "../utils/rotationBoundingBox.js";
|
|
17
18
|
import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
|
|
18
19
|
import { SCRIPT_CLASS, hasCjk, hasComplexScript, segmentByScript } from "../utils/scriptSegments.js";
|
|
19
|
-
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
20
|
+
import { anchorTargetAttrs, sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
20
21
|
import { borderStrokeToCss, resolveParagraphBorderHorizontalOutsets } from "./borderStroke.js";
|
|
21
22
|
import { planCursiveJoiners, withCursiveJoiners } from "./cursiveJoiners.js";
|
|
22
23
|
import { getAutomaticTextColorForBackground, setAuthoredBackgroundColor, setAuthoredTextColor } from "./documentColors.js";
|
|
23
|
-
import { applyImageBorder, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, wrapImageWithCrop } from "./renderImage.js";
|
|
24
|
+
import { applyImageBorder, applyImageColorAttrs, applyImageVisualAttrs, hasImageCrop, hasImageVisualAttrs, wrapImageWithCrop } from "./renderImage.js";
|
|
24
25
|
import { resolveImageLineAlign } from "./renderUtils.js";
|
|
25
26
|
import { applySdtDataAttrs } from "./sdtBoundary.js";
|
|
26
27
|
//#region src/layout-painter/renderParagraph.ts
|
|
@@ -164,6 +165,18 @@ function applyHorizontalScaleTransform(element, horizontalScale) {
|
|
|
164
165
|
element.style.transformOrigin = "left center";
|
|
165
166
|
}
|
|
166
167
|
/**
|
|
168
|
+
* How CSS spells each bidirectional wrapper: an override switches the
|
|
169
|
+
* bidirectional algorithm off for its content, an embedding opens a level and
|
|
170
|
+
* leaves it on.
|
|
171
|
+
*
|
|
172
|
+
* Both painters write the keyword from here, so the DOM painter and the
|
|
173
|
+
* display list cannot spell the pair differently.
|
|
174
|
+
*/
|
|
175
|
+
const UNICODE_BIDI_BY_WRAPPER_CONTROL = {
|
|
176
|
+
override: "bidi-override",
|
|
177
|
+
embedding: "embed"
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
167
180
|
* Apply text run styles to an element
|
|
168
181
|
*/
|
|
169
182
|
function applyRunStyles(element, run) {
|
|
@@ -192,6 +205,10 @@ function applyRunStyles(element, run) {
|
|
|
192
205
|
}
|
|
193
206
|
if (run.rtl === true) element.dir = RIGHT_TO_LEFT_DIRECTION;
|
|
194
207
|
else if (run.rtl === false) element.dir = LEFT_TO_RIGHT_DIRECTION;
|
|
208
|
+
if (run.bidiWrapper) {
|
|
209
|
+
element.style.unicodeBidi = UNICODE_BIDI_BY_WRAPPER_CONTROL[run.bidiWrapper.control];
|
|
210
|
+
if (run.bidiWrapper.direction !== void 0 && run.rtl === void 0) element.dir = run.bidiWrapper.direction === "rtl" ? RIGHT_TO_LEFT_DIRECTION : LEFT_TO_RIGHT_DIRECTION;
|
|
211
|
+
}
|
|
195
212
|
if (run.textEffect) {
|
|
196
213
|
element.classList.add("docx-text-effect", `docx-text-effect-${run.textEffect}`);
|
|
197
214
|
element.dataset["effect"] = run.textEffect;
|
|
@@ -238,7 +255,7 @@ function applyRunStyles(element, run) {
|
|
|
238
255
|
if (run.commentIds && run.commentIds.length > 0) {
|
|
239
256
|
element.style.backgroundColor = "rgba(255, 212, 0, 0.08)";
|
|
240
257
|
element.style.borderBottom = "1px solid rgba(180, 130, 0, 0.24)";
|
|
241
|
-
element
|
|
258
|
+
writeCommentAnchorIds(element, run.commentIds);
|
|
242
259
|
}
|
|
243
260
|
if (run.isInsertion) {
|
|
244
261
|
const authorIdx = getAuthorColorIdx(run.changeAuthor ?? "");
|
|
@@ -357,8 +374,9 @@ function renderTextRun(run, doc, options) {
|
|
|
357
374
|
anchor.href = hyperlinkHref;
|
|
358
375
|
if (options?.hyperlinkDirection || DISPLAYED_URL_PATTERN.test(paintedText.trim())) anchor.dir = LEFT_TO_RIGHT_DIRECTION;
|
|
359
376
|
if (!isBookmarkTarget) {
|
|
360
|
-
|
|
361
|
-
anchor.
|
|
377
|
+
const { target, rel } = anchorTargetAttrs(void 0);
|
|
378
|
+
anchor.target = target;
|
|
379
|
+
anchor.rel = rel;
|
|
362
380
|
}
|
|
363
381
|
if (run.hyperlink.tooltip) anchor.title = run.hyperlink.tooltip;
|
|
364
382
|
appendPaintedText({
|
|
@@ -491,6 +509,7 @@ function renderInlineImageRun(run, doc) {
|
|
|
491
509
|
img.style.transform = run.transform;
|
|
492
510
|
img.style.transformOrigin = "center center";
|
|
493
511
|
}
|
|
512
|
+
applyImageColorAttrs(img, run);
|
|
494
513
|
if (!hasImageCrop(run)) applyImageBorder(img, run);
|
|
495
514
|
const rotation = parseRotationDegrees(run.transform);
|
|
496
515
|
if (rotation !== 0) {
|
|
@@ -557,6 +576,7 @@ function renderBlockImage(run, doc) {
|
|
|
557
576
|
img.style.transform = run.transform;
|
|
558
577
|
img.style.transformOrigin = "center center";
|
|
559
578
|
}
|
|
579
|
+
applyImageColorAttrs(img, run);
|
|
560
580
|
if (!hasImageCrop(run)) applyImageBorder(img, run);
|
|
561
581
|
const rotation = parseRotationDegrees(run.transform);
|
|
562
582
|
if (rotation !== 0) {
|
|
@@ -1666,4 +1686,4 @@ function renderListMarker({ marker, inlineWidth, visualOffset, doc, formatting,
|
|
|
1666
1686
|
return span;
|
|
1667
1687
|
}
|
|
1668
1688
|
//#endregion
|
|
1669
|
-
export { PARAGRAPH_CLASS_NAMES, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|
|
1689
|
+
export { PARAGRAPH_CLASS_NAMES, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
//#region src/managers/autoSaveCodec.d.ts
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Version 3 renamed the model's `bidiWrapper` to `inlineWrapper` and gave it a
|
|
5
|
+
* `kind`. The codec serialises the model itself, so a version-2 envelope holds
|
|
6
|
+
* paragraph content under the old discriminator: the model validator would
|
|
7
|
+
* reject it, and a reader that did not validate would drop the wrapper. The
|
|
8
|
+
* envelope is a local draft of one editing session, so it is refused and
|
|
9
|
+
* re-taken rather than migrated.
|
|
10
|
+
*/
|
|
11
|
+
declare const AUTOSAVE_FORMAT_VERSION = 3;
|
|
4
12
|
type DecodedAutoSave = {
|
|
5
13
|
document: document_d_exports.Document;
|
|
6
14
|
savedAt: string;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { validateFolioDocumentModel } from "../docx/modelValidation.js";
|
|
2
|
+
import { bytesToBase64 } from "../utils/base64.js";
|
|
2
3
|
//#region src/managers/autoSaveCodec.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Version 3 renamed the model's `bidiWrapper` to `inlineWrapper` and gave it a
|
|
6
|
+
* `kind`. The codec serialises the model itself, so a version-2 envelope holds
|
|
7
|
+
* paragraph content under the old discriminator: the model validator would
|
|
8
|
+
* reject it, and a reader that did not validate would drop the wrapper. The
|
|
9
|
+
* envelope is a local draft of one editing session, so it is refused and
|
|
10
|
+
* re-taken rather than migrated.
|
|
11
|
+
*/
|
|
12
|
+
const AUTOSAVE_FORMAT_VERSION = 3;
|
|
11
13
|
const decodeBase64 = (value) => {
|
|
12
14
|
const binary = atob(value);
|
|
13
15
|
const bytes = new Uint8Array(binary.length);
|
|
@@ -23,7 +25,7 @@ const encodeValue = (value) => {
|
|
|
23
25
|
};
|
|
24
26
|
if (value instanceof ArrayBuffer) return {
|
|
25
27
|
type: "arrayBuffer",
|
|
26
|
-
value:
|
|
28
|
+
value: bytesToBase64(new Uint8Array(value))
|
|
27
29
|
};
|
|
28
30
|
if (value instanceof Map) return {
|
|
29
31
|
type: "map",
|
|
@@ -86,20 +88,20 @@ const encodeAutoSaveDocument = (document) => {
|
|
|
86
88
|
};
|
|
87
89
|
return { json: JSON.stringify(encodeValue(snapshot)) };
|
|
88
90
|
};
|
|
89
|
-
const encodeAutoSaveEnvelopeFromDocument = (document, savedAt) => `{"document":${document.json},"savedAt":${JSON.stringify(savedAt)},"version":
|
|
91
|
+
const encodeAutoSaveEnvelopeFromDocument = (document, savedAt) => `{"document":${document.json},"savedAt":${JSON.stringify(savedAt)},"version":3}`;
|
|
90
92
|
const encodeAutoSaveEnvelope = (document, savedAt) => encodeAutoSaveEnvelopeFromDocument(encodeAutoSaveDocument(document), savedAt);
|
|
91
93
|
const decodeAutoSaveEnvelope = (json) => {
|
|
92
94
|
try {
|
|
93
95
|
const parsed = JSON.parse(json);
|
|
94
96
|
if (typeof parsed !== "object" || !parsed || !("document" in parsed) || !("savedAt" in parsed) || !("version" in parsed)) return null;
|
|
95
|
-
if (parsed.version !==
|
|
97
|
+
if (parsed.version !== 3 || typeof parsed.savedAt !== "string" || !Number.isFinite(Date.parse(parsed.savedAt))) return null;
|
|
96
98
|
const document = decodeValue(parsed.document);
|
|
97
99
|
if (typeof document !== "object" || !document) return null;
|
|
98
100
|
if (!validateFolioDocumentModel(document).valid) return null;
|
|
99
101
|
return {
|
|
100
102
|
document,
|
|
101
103
|
savedAt: parsed.savedAt,
|
|
102
|
-
version:
|
|
104
|
+
version: 3
|
|
103
105
|
};
|
|
104
106
|
} catch {
|
|
105
107
|
return null;
|
package/dist/markdown/images.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bytesToBase64 } from "../utils/base64.js";
|
|
1
2
|
//#region src/markdown/images.ts
|
|
2
3
|
const MIME_TO_EXT = {
|
|
3
4
|
"image/png": "png",
|
|
@@ -14,10 +15,6 @@ const MIME_TO_EXT = {
|
|
|
14
15
|
function extFor(mimeType, fallback) {
|
|
15
16
|
return MIME_TO_EXT[mimeType] ?? fallback;
|
|
16
17
|
}
|
|
17
|
-
function bytesToBase64(bytes) {
|
|
18
|
-
if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
|
|
19
|
-
return btoa(new TextDecoder("latin1").decode(bytes));
|
|
20
|
-
}
|
|
21
18
|
function toUint8(data) {
|
|
22
19
|
if (data instanceof Uint8Array) return data;
|
|
23
20
|
return new Uint8Array(data);
|
|
@@ -5,6 +5,6 @@ import { RenderContext } from "./types.js";
|
|
|
5
5
|
* Render the full inline content of a paragraph, tracking comment-range
|
|
6
6
|
* boundaries to apply the configured wrapper.
|
|
7
7
|
*/
|
|
8
|
-
declare function renderParagraphInline(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, content: document_d_exports.ParagraphContent[], paraId: string | undefined): string;
|
|
8
|
+
declare function renderParagraphInline(ctx: RenderContext, pkg: document_d_exports.DocxPackage | undefined, content: readonly document_d_exports.ParagraphContent[], paraId: string | undefined): string;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { renderParagraphInline };
|
|
@@ -76,6 +76,9 @@ function renderRunContent(ctx, pkg, content, paraId) {
|
|
|
76
76
|
case "noBreakHyphen":
|
|
77
77
|
out += "‑";
|
|
78
78
|
break;
|
|
79
|
+
case "preservedXml":
|
|
80
|
+
out += escapeInline(item.text);
|
|
81
|
+
break;
|
|
79
82
|
case "footnoteRef":
|
|
80
83
|
case "endnoteRef": {
|
|
81
84
|
if (ctx.opts.footnotes === "strip") break;
|
|
@@ -147,10 +150,23 @@ function renderHyperlink(ctx, pkg, link, paraId) {
|
|
|
147
150
|
}
|
|
148
151
|
function renderTrackedWrapper(ctx, pkg, wrapper, paraId) {
|
|
149
152
|
const renderChild = (child) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
switch (child.type) {
|
|
154
|
+
case "run": return renderRun(ctx, pkg, child, paraId);
|
|
155
|
+
case "hyperlink": return renderHyperlink(ctx, pkg, child, paraId);
|
|
156
|
+
case "mathEquation": return child.plainText ? escapeInline(child.plainText) : "";
|
|
157
|
+
case "inlineWrapper":
|
|
158
|
+
case "inlineSdt": return renderParagraphInline(ctx, pkg, child.content, paraId);
|
|
159
|
+
case "insertion":
|
|
160
|
+
case "deletion":
|
|
161
|
+
case "moveFrom":
|
|
162
|
+
case "moveTo": return renderTrackedWrapper(ctx, pkg, child, paraId);
|
|
163
|
+
case "simpleField":
|
|
164
|
+
case "complexField": return renderParagraphInline(ctx, pkg, [child], paraId);
|
|
165
|
+
case "bookmarkStart":
|
|
166
|
+
case "bookmarkEnd":
|
|
167
|
+
case "preservedInline": return "";
|
|
168
|
+
default: return child;
|
|
169
|
+
}
|
|
154
170
|
};
|
|
155
171
|
if (ctx.opts.trackedChanges === "clean") {
|
|
156
172
|
if (wrapper.type === "insertion" || wrapper.type === "moveTo") return wrapper.content.map(renderChild).join("");
|
|
@@ -196,10 +212,17 @@ function renderParagraphInline(ctx, pkg, content, paraId) {
|
|
|
196
212
|
case "simpleField":
|
|
197
213
|
case "complexField": {
|
|
198
214
|
const runs = item.type === "simpleField" ? item.content : item.fieldResult;
|
|
199
|
-
for (const child of runs)
|
|
215
|
+
for (const child of runs) {
|
|
216
|
+
if (child.type === "run") {
|
|
217
|
+
out += renderRun(ctx, pkg, child, paraId);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
out += child.type === "hyperlink" ? renderHyperlink(ctx, pkg, child, paraId) : child.text;
|
|
221
|
+
}
|
|
200
222
|
break;
|
|
201
223
|
}
|
|
202
224
|
case "inlineSdt":
|
|
225
|
+
case "inlineWrapper":
|
|
203
226
|
out += renderParagraphInline(ctx, pkg, item.content, paraId);
|
|
204
227
|
break;
|
|
205
228
|
case "mathEquation":
|
|
@@ -113,7 +113,7 @@ function renderHtmlCell(ctx, pkg, cell) {
|
|
|
113
113
|
for (const item of cell.content) if (item.type === "paragraph") {
|
|
114
114
|
const inner = renderHtmlInline(ctx, pkg, item.content, item.paraId);
|
|
115
115
|
if (inner) parts.push(inner);
|
|
116
|
-
} else {
|
|
116
|
+
} else if (item.type === "table") {
|
|
117
117
|
const nested = renderHtmlTable(ctx, pkg, item.rows, true);
|
|
118
118
|
if (nested) parts.push(nested);
|
|
119
119
|
}
|
|
@@ -148,6 +148,7 @@ function renderHtmlInline(ctx, pkg, content, paraId) {
|
|
|
148
148
|
break;
|
|
149
149
|
}
|
|
150
150
|
case "inlineSdt":
|
|
151
|
+
case "inlineWrapper":
|
|
151
152
|
out += renderHtmlInline(ctx, pkg, item.content, paraId);
|
|
152
153
|
break;
|
|
153
154
|
case "mathEquation":
|
|
@@ -159,10 +160,23 @@ function renderHtmlInline(ctx, pkg, content, paraId) {
|
|
|
159
160
|
}
|
|
160
161
|
function renderHtmlChildren(ctx, pkg, children, paraId) {
|
|
161
162
|
return children.map((child) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
switch (child.type) {
|
|
164
|
+
case "run": return renderHtmlRun(ctx, pkg, child, paraId);
|
|
165
|
+
case "hyperlink": return renderHtmlHyperlink(ctx, pkg, child, paraId);
|
|
166
|
+
case "mathEquation": return child.plainText ? escapeHtml(child.plainText) : "";
|
|
167
|
+
case "inlineWrapper":
|
|
168
|
+
case "inlineSdt":
|
|
169
|
+
case "simpleField":
|
|
170
|
+
case "complexField":
|
|
171
|
+
case "insertion":
|
|
172
|
+
case "deletion":
|
|
173
|
+
case "moveFrom":
|
|
174
|
+
case "moveTo": return renderHtmlInline(ctx, pkg, [child], paraId);
|
|
175
|
+
case "bookmarkStart":
|
|
176
|
+
case "bookmarkEnd":
|
|
177
|
+
case "preservedInline": return "";
|
|
178
|
+
default: return child;
|
|
179
|
+
}
|
|
166
180
|
}).join("");
|
|
167
181
|
}
|
|
168
182
|
function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
@@ -184,6 +198,9 @@ function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
|
184
198
|
case "noBreakHyphen":
|
|
185
199
|
text += "‑";
|
|
186
200
|
break;
|
|
201
|
+
case "preservedXml":
|
|
202
|
+
text += escapeHtml(item.text);
|
|
203
|
+
break;
|
|
187
204
|
case "softHyphen": break;
|
|
188
205
|
case "drawing": {
|
|
189
206
|
const ref = resolveRelationshipIdOfType(pkg?.relationships, item.image.rId, RELATIONSHIP_TYPES.image);
|
|
@@ -65,12 +65,15 @@ function inlineText(content) {
|
|
|
65
65
|
case "moveFrom":
|
|
66
66
|
case "moveTo":
|
|
67
67
|
case "inlineSdt":
|
|
68
|
-
case "
|
|
68
|
+
case "inlineWrapper":
|
|
69
69
|
out += inlineText(item.content);
|
|
70
70
|
break;
|
|
71
71
|
case "mathEquation":
|
|
72
72
|
out += item.plainText ?? "";
|
|
73
73
|
break;
|
|
74
|
+
case "preservedInline":
|
|
75
|
+
out += item.text;
|
|
76
|
+
break;
|
|
74
77
|
case "bookmarkStart":
|
|
75
78
|
case "bookmarkEnd":
|
|
76
79
|
case "commentRangeStart":
|