@stll/folio-core 0.47.7 → 0.49.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 +565 -121
- package/dist/ai-edits/minimal-replacement.d.ts +64 -0
- package/dist/ai-edits/minimal-replacement.js +282 -0
- package/dist/controller/fontReadiness.js +3 -3
- package/dist/controller/hyphenationReadiness.d.ts +19 -0
- package/dist/controller/hyphenationReadiness.js +47 -0
- package/dist/controller/layoutPipeline.d.ts +3 -0
- package/dist/controller/layoutPipeline.js +70 -18
- package/dist/display-list/build/buildDisplayList.js +39 -12
- package/dist/display-list/build/pageFurniture.d.ts +7 -1
- package/dist/display-list/build/pageFurniture.js +21 -8
- package/dist/display-list/build/paragraphPrimitives.js +68 -11
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/display-list/build/textBoxPrimitives.js +1 -1
- package/dist/display-list/build/unsupported.d.ts +2 -2
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +79 -64
- package/dist/docx/bulletMarkers.d.ts +18 -2
- package/dist/docx/bulletMarkers.js +27 -2
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +57 -45
- package/dist/docx/containerChildren.d.ts +21 -8
- package/dist/docx/containerChildren.js +39 -9
- package/dist/docx/documentParser.d.ts +5 -1
- package/dist/docx/documentParser.js +8 -5
- package/dist/docx/documentSectionFacts.d.ts +22 -0
- package/dist/docx/documentSectionFacts.js +43 -0
- package/dist/docx/drawingGroupChildren.d.ts +60 -0
- package/dist/docx/drawingGroupChildren.js +176 -0
- package/dist/docx/drawingUtils.js +3 -0
- package/dist/docx/fieldParser.d.ts +8 -1
- package/dist/docx/fieldParser.js +47 -3
- package/dist/docx/fontTableParser.js +34 -27
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +15 -12
- package/dist/docx/groupDrawingParser.d.ts +9 -2
- package/dist/docx/groupDrawingParser.js +125 -37
- package/dist/docx/headerFooterParser.d.ts +7 -2
- package/dist/docx/headerFooterParser.js +15 -5
- package/dist/docx/hyperlinkParser.d.ts +48 -36
- package/dist/docx/hyperlinkParser.js +97 -82
- package/dist/docx/numberingParser.js +108 -84
- package/dist/docx/packageParts.d.ts +45 -1
- package/dist/docx/packageParts.js +93 -2
- package/dist/docx/paraIdAttribute.d.ts +3 -2
- package/dist/docx/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +468 -365
- package/dist/docx/paragraphProperties.js +123 -109
- package/dist/docx/paragraphPropertySource.d.ts +6 -1
- package/dist/docx/paragraphPropertySource.js +9 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
- package/dist/docx/parser.d.ts +7 -1
- package/dist/docx/parser.js +33 -16
- package/dist/docx/previewBudget.d.ts +55 -33
- package/dist/docx/previewBudget.js +59 -65
- package/dist/docx/rezip.js +41 -58
- package/dist/docx/runParser.d.ts +4 -1
- package/dist/docx/runParser.js +182 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/selectiveSaveFlags.d.ts +10 -3
- package/dist/docx/selectiveSaveFlags.js +1 -1
- package/dist/docx/selectiveXmlPatch.d.ts +56 -34
- package/dist/docx/selectiveXmlPatch.js +222 -115
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
- package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
- package/dist/docx/serializer/paragraphSerializer.js +47 -42
- package/dist/docx/serializer/runSerializer.d.ts +5 -1
- package/dist/docx/serializer/runSerializer.js +4 -3
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -0
- package/dist/docx/shapeAlternateContent.d.ts +25 -0
- package/dist/docx/shapeAlternateContent.js +52 -0
- package/dist/docx/streamingXmlParser.d.ts +6 -2
- package/dist/docx/streamingXmlParser.js +12 -7
- package/dist/docx/styleParser.js +34 -8
- package/dist/docx/tableParser.d.ts +21 -12
- package/dist/docx/tableParser.js +518 -441
- package/dist/docx/textBoxParser.d.ts +18 -5
- package/dist/docx/textBoxParser.js +12 -6
- package/dist/docx/verbatimCapture.d.ts +10 -8
- package/dist/docx/verbatimCapture.js +45 -2
- package/dist/docx/vmlImageParser.d.ts +15 -13
- package/dist/docx/vmlImageParser.js +75 -60
- package/dist/docx/vmlPreview.d.ts +3 -3
- package/dist/docx/vmlPreview.js +3 -4
- package/dist/docx/xmlNamespaceContext.d.ts +9 -0
- package/dist/docx/xmlNamespaceContext.js +54 -0
- package/dist/docx/xmlParser.d.ts +6 -3
- package/dist/docx/xmlParser.js +11 -41
- package/dist/docx/xmlResourceLimits.d.ts +2 -1
- package/dist/docx/xmlResourceLimits.js +4 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.d.ts +11 -2
- package/dist/headless-layout.js +153 -107
- package/dist/internal/headlessRevisionResolution.js +50 -13
- package/dist/internal/paragraphFormattingSerialization.js +3 -3
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
- package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
- package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
- package/dist/layout-bridge/engine/hitTest.js +5 -3
- package/dist/layout-bridge/engine/selectionRects.js +5 -3
- package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
- package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +102 -14
- package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
- package/dist/layout-engine/justificationCompatibility.js +9 -5
- package/dist/layout-engine/keep-together.d.ts +15 -6
- package/dist/layout-engine/keep-together.js +43 -16
- package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
- package/dist/layout-engine/layoutInstrumentation.js +8 -1
- package/dist/layout-engine/measure/advanceComposition.js +50 -7
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
- package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
- package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
- package/dist/layout-engine/measure/lineBreaks.js +10 -3
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
- package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
- package/dist/layout-engine/measure/measureBlocks.js +46 -10
- package/dist/layout-engine/measure/measureContainer.js +51 -8
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +34 -8
- package/dist/layout-engine/measure/measureParagraph.js +143 -101
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
- package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
- package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
- package/dist/layout-engine/measure/tabCalculator.js +2 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +51 -19
- package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
- package/dist/layout-engine/measure/tableCellGrid.js +45 -5
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
- package/dist/layout-engine/noteAreaFlow.js +83 -0
- package/dist/layout-engine/paginator.d.ts +12 -1
- package/dist/layout-engine/paginator.js +18 -2
- package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
- package/dist/layout-engine/paragraphSpacing.js +2 -1
- package/dist/layout-engine/tableRowBreak.d.ts +8 -1
- package/dist/layout-engine/tableRowBreak.js +25 -2
- package/dist/layout-engine/types.d.ts +108 -3
- package/dist/layout-engine/types.js +96 -1
- package/dist/layout-painter/index.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +32 -83
- package/dist/layout-painter/renderParagraph.d.ts +6 -1
- package/dist/layout-painter/renderParagraph.js +75 -26
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/layout-painter/renderTextBox.d.ts +12 -2
- package/dist/layout-painter/renderTextBox.js +26 -2
- package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
- package/dist/prosemirror/alternateContentAttrs.js +35 -0
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +133 -11
- package/dist/prosemirror/commands/comments.js +51 -41
- package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
- package/dist/prosemirror/contentControlRevisions.js +84 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +117 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +4 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/paragraphDirection.d.ts +29 -2
- package/dist/prosemirror/paragraphDirection.js +21 -2
- package/dist/prosemirror/plugins/suggestionMode.js +37 -8
- package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
- package/dist/prosemirror/rejoinRunCarriers.js +66 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
- package/dist/prosemirror/schema/nodes.d.ts +50 -6
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +10 -1
- package/dist/utils/scriptSegments.d.ts +33 -4
- package/dist/utils/scriptSegments.js +39 -6
- package/dist/utils/textFormattingMerge.d.ts +17 -3
- package/dist/utils/textFormattingMerge.js +18 -12
- package/dist/utils/trailingText.d.ts +22 -0
- package/dist/utils/trailingText.js +32 -0
- package/package.json +2 -2
- package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
- package/dist/layout-engine/justifiedLineFit.js +0 -6
|
@@ -2,7 +2,7 @@ import { OutlineStyleAttr } from "../types/documentEnumValues.js";
|
|
|
2
2
|
import { CssBorderStyle } from "../utils/borderCss.js";
|
|
3
3
|
import { ImagePosition, ImageWrap, InlineWrapper, NumberFormat, OutlineLevel, ParagraphNumberingOverride, PreviewDescriptor, SdtProperties, SdtType, SectionStart, ShapeTextBody, TableCellFormatting, TableWidthType, UnderlineStyle, VerticalAlign } from "@stll/docx-core/model";
|
|
4
4
|
declare namespace types_d_exports {
|
|
5
|
-
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, 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, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, tableColumnsArePinned };
|
|
5
|
+
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, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, 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, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned };
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Unique identifier for a block in the document.
|
|
@@ -47,6 +47,11 @@ type RunFormatting = {
|
|
|
47
47
|
eastAsiaFontFamily?: string;
|
|
48
48
|
/** OOXML alternate-name fallback for `eastAsiaFontFamily`. */
|
|
49
49
|
eastAsiaAlternateFontFamily?: string;
|
|
50
|
+
/**
|
|
51
|
+
* `w:rFonts/@w:hint="eastAsia"`: the symbols and punctuation shared with East
|
|
52
|
+
* Asian text also take `eastAsiaFontFamily` (see `isEastAsiaHintCodePoint`).
|
|
53
|
+
*/
|
|
54
|
+
eastAsiaHint?: boolean;
|
|
50
55
|
/**
|
|
51
56
|
* Resolved complex-script font (`w:cs` / `cstheme`). Arabic, Hebrew, Indic
|
|
52
57
|
* and South-East Asian code points in this run measure and paint with this
|
|
@@ -155,7 +160,7 @@ type RunFormatting = {
|
|
|
155
160
|
/** Groups a suggestion's runs for accept/reject and scroll-to. */
|
|
156
161
|
suggestionId?: string;
|
|
157
162
|
};
|
|
158
|
-
type ListMarkerFormatting = Pick<RunFormatting, "fontFamily" | "alternateFontFamily" | "eastAsiaFontFamily" | "eastAsiaAlternateFontFamily" | "complexScriptFontFamily" | "complexScriptAlternateFontFamily" | "fontSize" | "complexScriptFontSize" | "bold" | "complexScriptBold" | "italic" | "complexScriptItalic" | "rtl" | "forceComplexScript">;
|
|
163
|
+
type ListMarkerFormatting = Pick<RunFormatting, "fontFamily" | "alternateFontFamily" | "eastAsiaFontFamily" | "eastAsiaAlternateFontFamily" | "complexScriptFontFamily" | "complexScriptAlternateFontFamily" | "fontSize" | "complexScriptFontSize" | "bold" | "complexScriptBold" | "italic" | "complexScriptItalic" | "rtl" | "forceComplexScript" | "color">;
|
|
159
164
|
/**
|
|
160
165
|
* Hyperlink information for a run.
|
|
161
166
|
*/
|
|
@@ -519,6 +524,12 @@ type ParagraphAttrs = {
|
|
|
519
524
|
* one space glyph; `nothing` lets body text butt against the marker.
|
|
520
525
|
*/
|
|
521
526
|
listMarkerSuffix?: "tab" | "space" | "nothing";
|
|
527
|
+
/**
|
|
528
|
+
* `w:doNotUseIndentAsNumberingTabStop` (§17.15.3): the hanging indent is
|
|
529
|
+
* not an implicit stop for the tab after the number, so the first custom
|
|
530
|
+
* stop past the marker wins wherever it is.
|
|
531
|
+
*/
|
|
532
|
+
listNumberingTabIgnoresIndent?: boolean;
|
|
522
533
|
/**
|
|
523
534
|
* Tracked-change state of the list numbering itself. When a list is applied
|
|
524
535
|
* (or removed) under suggesting mode, the marker paints in the insertion /
|
|
@@ -681,6 +692,14 @@ type TableBlock = {
|
|
|
681
692
|
justification?: "left" | "center" | "right";
|
|
682
693
|
/** Table indent from the leading margin (in pixels, from w:tblInd). */
|
|
683
694
|
indent?: number;
|
|
695
|
+
/**
|
|
696
|
+
* Default cell spacing in pixels (`w:tblCellSpacing`, §17.4.43). Each cell
|
|
697
|
+
* box sits this far inside its grid slot on every side, so adjacent cells
|
|
698
|
+
* stand twice this apart, and the table edge adds one more unit around the
|
|
699
|
+
* outermost cells. Borders then follow the separated model: every cell
|
|
700
|
+
* paints its own four edges.
|
|
701
|
+
*/
|
|
702
|
+
cellSpacing?: number;
|
|
684
703
|
/**
|
|
685
704
|
* Pre-Word-2013 `w:tblInd` semantics: the indent measures to the leading
|
|
686
705
|
* cell's text edge instead of the table border. Derived from the document's
|
|
@@ -830,6 +849,21 @@ declare const DEFAULT_TEXTBOX_MARGINS: {
|
|
|
830
849
|
};
|
|
831
850
|
/** Default text box width in pixels when no width is specified */
|
|
832
851
|
declare const DEFAULT_TEXTBOX_WIDTH = 200;
|
|
852
|
+
/**
|
|
853
|
+
* A linear DrawingML gradient fill with its colors resolved (ECMA-376
|
|
854
|
+
* §20.1.8.33, §20.1.8.41). It runs along `angle`, in degrees clockwise from
|
|
855
|
+
* the positive x axis; when `scaled`, that angle is stated in the unit square
|
|
856
|
+
* and stretched with the box.
|
|
857
|
+
*/
|
|
858
|
+
type TextBoxGradientFill = {
|
|
859
|
+
angle: number;
|
|
860
|
+
scaled: boolean;
|
|
861
|
+
/** Stops in ascending order; `offset` runs 0 to 1. */
|
|
862
|
+
stops: {
|
|
863
|
+
offset: number;
|
|
864
|
+
color: string;
|
|
865
|
+
}[];
|
|
866
|
+
};
|
|
833
867
|
/**
|
|
834
868
|
* Text box block — positioned container with block content.
|
|
835
869
|
*/
|
|
@@ -850,6 +884,8 @@ type TextBoxBlock = {
|
|
|
850
884
|
verticalAlign?: ShapeTextBody["anchor"];
|
|
851
885
|
/** Fill/background color */
|
|
852
886
|
fillColor?: string;
|
|
887
|
+
/** Gradient fill, painted when no `fillColor` states a solid one. */
|
|
888
|
+
fillGradient?: TextBoxGradientFill;
|
|
853
889
|
/** Border width in pixels */
|
|
854
890
|
outlineWidth?: number;
|
|
855
891
|
/** Border color */
|
|
@@ -865,6 +901,23 @@ type TextBoxBlock = {
|
|
|
865
901
|
left: number;
|
|
866
902
|
right: number;
|
|
867
903
|
};
|
|
904
|
+
/**
|
|
905
|
+
* An inline box's `wp:effectExtent`, in pixels. The line reserves these
|
|
906
|
+
* beyond the box's own extent on each side, so the box sits `left`/`top`
|
|
907
|
+
* inside the space it occupies (ECMA-376 §20.4.2.6).
|
|
908
|
+
*/
|
|
909
|
+
effectExtent?: {
|
|
910
|
+
top: number;
|
|
911
|
+
bottom: number;
|
|
912
|
+
left: number;
|
|
913
|
+
right: number;
|
|
914
|
+
};
|
|
915
|
+
/**
|
|
916
|
+
* The paragraph an inline box is the only content of. The box is run
|
|
917
|
+
* content of that paragraph, so its spacing surrounds the box and its
|
|
918
|
+
* indentation and alignment place it on the line.
|
|
919
|
+
*/
|
|
920
|
+
hostParagraph?: ParagraphAttrs;
|
|
868
921
|
/** Flow blocks inside the text box */
|
|
869
922
|
content: (ParagraphBlock | TableBlock)[];
|
|
870
923
|
/** Display mode copied from the ProseMirror text box node. */
|
|
@@ -1208,9 +1261,23 @@ type Page = {
|
|
|
1208
1261
|
footnoteIds?: number[];
|
|
1209
1262
|
/** Height reserved for the footnote area at page bottom (pixels). */
|
|
1210
1263
|
footnoteReservedHeight?: number;
|
|
1264
|
+
/**
|
|
1265
|
+
* Rules drawn for the `w:separator` / `w:continuationSeparator` marks of a
|
|
1266
|
+
* note area that flows with the body (endnotes), in page coordinates.
|
|
1267
|
+
*/
|
|
1268
|
+
noteSeparators?: NoteSeparatorRule[];
|
|
1211
1269
|
/** Column layout for this page (if multi-column). */
|
|
1212
1270
|
columns?: ColumnLayout;
|
|
1213
1271
|
};
|
|
1272
|
+
/**
|
|
1273
|
+
* One separator rule of a flowed note area: the top-left corner of a
|
|
1274
|
+
* `NOTE_SEPARATOR_RULE_THICKNESS`-high rule and its width, in page pixels.
|
|
1275
|
+
*/
|
|
1276
|
+
type NoteSeparatorRule = {
|
|
1277
|
+
x: number;
|
|
1278
|
+
y: number;
|
|
1279
|
+
width: number;
|
|
1280
|
+
};
|
|
1214
1281
|
/**
|
|
1215
1282
|
* Column layout configuration.
|
|
1216
1283
|
*/
|
|
@@ -1291,6 +1358,8 @@ type LayoutOptions = {
|
|
|
1291
1358
|
firstPageMargins?: PageMargins;
|
|
1292
1359
|
/** Per-section body margins used on even authored page numbers. */
|
|
1293
1360
|
sectionEvenPageMargins?: (PageMargins | undefined)[];
|
|
1361
|
+
/** Per-section body margins used on the first page of a `w:titlePg` section. */
|
|
1362
|
+
sectionFirstPageMargins?: (PageMargins | undefined)[];
|
|
1294
1363
|
/** Page-number policy for the initial section. */
|
|
1295
1364
|
pageNumbering?: SectionPageNumbering;
|
|
1296
1365
|
/** Body-level final section page size. */
|
|
@@ -1341,6 +1410,32 @@ type LayoutOptions = {
|
|
|
1341
1410
|
footnoteHeightById?: Map<number, number>;
|
|
1342
1411
|
/** Header/footer references for each document section, by section index. */
|
|
1343
1412
|
sectionHeaderFooterRefs?: PageHeaderFooterRefs[];
|
|
1413
|
+
/** Note areas (endnotes) whose blocks flow with the body blocks. */
|
|
1414
|
+
noteAreas?: NoteAreaLayout;
|
|
1415
|
+
};
|
|
1416
|
+
/** Which separator story a flowed note-area block renders. */
|
|
1417
|
+
type NoteSeparatorKind = "separator" | "continuationSeparator";
|
|
1418
|
+
/**
|
|
1419
|
+
* Note areas laid out in the body flow (ECMA-376 §17.11): endnotes collected
|
|
1420
|
+
* at the end of the document or of a section. Their blocks sit in the body's
|
|
1421
|
+
* block list; this names the ones the paginator treats specially.
|
|
1422
|
+
*/
|
|
1423
|
+
type NoteAreaLayout = {
|
|
1424
|
+
/**
|
|
1425
|
+
* Separator-story paragraphs that carry a `w:separator` mark, keyed by block
|
|
1426
|
+
* id. A rule is drawn across the first line of each of their fragments.
|
|
1427
|
+
*/
|
|
1428
|
+
separatorBlockIds: ReadonlyMap<string, NoteSeparatorKind>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Note content blocks. A page opened while one of them is laid out
|
|
1431
|
+
* continues the area, so it starts with the continuation separator.
|
|
1432
|
+
*/
|
|
1433
|
+
contentBlockIds: ReadonlySet<string>;
|
|
1434
|
+
/** The `w:continuationSeparator` story's first paragraph, already measured. */
|
|
1435
|
+
continuationSeparator?: {
|
|
1436
|
+
block: ParagraphBlock;
|
|
1437
|
+
measure: ParagraphMeasure;
|
|
1438
|
+
};
|
|
1344
1439
|
};
|
|
1345
1440
|
/**
|
|
1346
1441
|
* Result of hit-testing a click position.
|
|
@@ -1383,6 +1478,10 @@ declare const FOOTNOTE_SEPARATOR_HEIGHT = 12;
|
|
|
1383
1478
|
* present in the source DOCX.
|
|
1384
1479
|
*/
|
|
1385
1480
|
declare const FOOTNOTE_ENTRY_MARGIN_BOTTOM = 0;
|
|
1481
|
+
/** Thickness of a note separator rule, in the footnote band and in flowed endnotes. */
|
|
1482
|
+
declare const NOTE_SEPARATOR_RULE_THICKNESS = 0.5;
|
|
1483
|
+
/** Width of a `w:separator` rule as a fraction of its column. */
|
|
1484
|
+
declare const NOTE_SEPARATOR_WIDTH_FRACTION = 0.33;
|
|
1386
1485
|
/**
|
|
1387
1486
|
* Line height used when a footnote entry has no measured line height yet.
|
|
1388
1487
|
* Conservative fallback so a missing measure does not collapse the entry.
|
|
@@ -1489,5 +1588,11 @@ declare function tableColumnsArePinned(table: TableBlock): boolean;
|
|
|
1489
1588
|
declare function resolveTableWidthPx(width: number | undefined, widthType: TableWidthType | undefined, containerWidth: number): number | undefined;
|
|
1490
1589
|
/** Return the leading visual offset for a row with omitted grid columns. */
|
|
1491
1590
|
declare const getTableRowLeadingWidth: (row: TableRow, columnWidths: readonly number[]) => number;
|
|
1591
|
+
/**
|
|
1592
|
+
* A copy of a block with every ProseMirror anchor removed. A note story's
|
|
1593
|
+
* blocks carry positions in the note's own document; painted beside the body
|
|
1594
|
+
* they must not resolve a click, a selection or a caret into the body.
|
|
1595
|
+
*/
|
|
1596
|
+
declare function stripFlowBlockPmAnchors(block: FlowBlock): FlowBlock;
|
|
1492
1597
|
//#endregion
|
|
1493
|
-
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, 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, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, tableColumnsArePinned, types_d_exports };
|
|
1598
|
+
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, MathRun, Measure, MeasuredLine, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, NoteAreaLayout, NoteSeparatorKind, NoteSeparatorRule, 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, TextBoxGradientFill, TextBoxMeasure, TextRun, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned, types_d_exports };
|
|
@@ -7,6 +7,8 @@ var types_exports = /* @__PURE__ */ __exportAll({
|
|
|
7
7
|
FOOTNOTE_ENTRY_MARGIN_BOTTOM: () => 0,
|
|
8
8
|
FOOTNOTE_FALLBACK_LINE_HEIGHT: () => 13,
|
|
9
9
|
FOOTNOTE_SEPARATOR_HEIGHT: () => 12,
|
|
10
|
+
NOTE_SEPARATOR_RULE_THICKNESS: () => NOTE_SEPARATOR_RULE_THICKNESS,
|
|
11
|
+
NOTE_SEPARATOR_WIDTH_FRACTION: () => NOTE_SEPARATOR_WIDTH_FRACTION,
|
|
10
12
|
floatingTextBoxReservesBand: () => floatingTextBoxReservesBand,
|
|
11
13
|
floatingTextBoxWrapsText: () => floatingTextBoxWrapsText,
|
|
12
14
|
getTableRowLeadingWidth: () => getTableRowLeadingWidth,
|
|
@@ -16,6 +18,7 @@ var types_exports = /* @__PURE__ */ __exportAll({
|
|
|
16
18
|
isTextWrappingFloatingImageRun: () => isTextWrappingFloatingImageRun,
|
|
17
19
|
resolveTableCellPadding: () => resolveTableCellPadding,
|
|
18
20
|
resolveTableWidthPx: () => resolveTableWidthPx,
|
|
21
|
+
stripFlowBlockPmAnchors: () => stripFlowBlockPmAnchors,
|
|
19
22
|
tableColumnsArePinned: () => tableColumnsArePinned
|
|
20
23
|
});
|
|
21
24
|
/**
|
|
@@ -69,6 +72,10 @@ const FOOTNOTE_SEPARATOR_HEIGHT = 12;
|
|
|
69
72
|
* present in the source DOCX.
|
|
70
73
|
*/
|
|
71
74
|
const FOOTNOTE_ENTRY_MARGIN_BOTTOM = 0;
|
|
75
|
+
/** Thickness of a note separator rule, in the footnote band and in flowed endnotes. */
|
|
76
|
+
const NOTE_SEPARATOR_RULE_THICKNESS = .5;
|
|
77
|
+
/** Width of a `w:separator` rule as a fraction of its column. */
|
|
78
|
+
const NOTE_SEPARATOR_WIDTH_FRACTION = .33;
|
|
72
79
|
/**
|
|
73
80
|
* Line height used when a footnote entry has no measured line height yet.
|
|
74
81
|
* Conservative fallback so a missing measure does not collapse the entry.
|
|
@@ -189,5 +196,93 @@ const getTableRowLeadingWidth = (row, columnWidths) => {
|
|
|
189
196
|
if (tableRowOwnsNestedGrid(row)) return 0;
|
|
190
197
|
return columnWidths.slice(0, row.gridBefore ?? 0).reduce((sum, columnWidth) => sum + columnWidth, 0);
|
|
191
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* A copy of a block with every ProseMirror anchor removed. A note story's
|
|
201
|
+
* blocks carry positions in the note's own document; painted beside the body
|
|
202
|
+
* they must not resolve a click, a selection or a caret into the body.
|
|
203
|
+
*/
|
|
204
|
+
function stripFlowBlockPmAnchors(block) {
|
|
205
|
+
switch (block.kind) {
|
|
206
|
+
case "paragraph": return stripParagraphPmAnchors(block);
|
|
207
|
+
case "table": return stripTablePmAnchors(block);
|
|
208
|
+
case "image": {
|
|
209
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...image } = block;
|
|
210
|
+
return image;
|
|
211
|
+
}
|
|
212
|
+
case "textBox": {
|
|
213
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...textBox } = block;
|
|
214
|
+
return {
|
|
215
|
+
...textBox,
|
|
216
|
+
content: textBox.content.map((contentBlock) => contentBlock.kind === "table" ? stripTablePmAnchors(contentBlock) : stripParagraphPmAnchors(contentBlock))
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
case "pageBreak":
|
|
220
|
+
case "columnBreak": {
|
|
221
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...breakBlock } = block;
|
|
222
|
+
return breakBlock;
|
|
223
|
+
}
|
|
224
|
+
case "sectionBreak": return block;
|
|
225
|
+
default: return block;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function stripTablePmAnchors(block) {
|
|
229
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...table } = block;
|
|
230
|
+
return {
|
|
231
|
+
...table,
|
|
232
|
+
rows: table.rows.map(stripTableRowPmAnchors)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function stripTableRowPmAnchors(row) {
|
|
236
|
+
return {
|
|
237
|
+
...row,
|
|
238
|
+
cells: row.cells.map(stripTableCellPmAnchors)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function stripTableCellPmAnchors(cell) {
|
|
242
|
+
return {
|
|
243
|
+
...cell,
|
|
244
|
+
blocks: cell.blocks.map(stripFlowBlockPmAnchors)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function stripParagraphPmAnchors(block) {
|
|
248
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...paragraph } = block;
|
|
249
|
+
return {
|
|
250
|
+
...paragraph,
|
|
251
|
+
runs: paragraph.runs.map(stripRunPmAnchors)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function stripRunPmAnchors(run) {
|
|
255
|
+
switch (run.kind) {
|
|
256
|
+
case "text": {
|
|
257
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...textRun } = run;
|
|
258
|
+
return textRun;
|
|
259
|
+
}
|
|
260
|
+
case "tab": {
|
|
261
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...tabRun } = run;
|
|
262
|
+
return tabRun;
|
|
263
|
+
}
|
|
264
|
+
case "image": {
|
|
265
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...imageRun } = run;
|
|
266
|
+
return imageRun;
|
|
267
|
+
}
|
|
268
|
+
case "lineBreak": {
|
|
269
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...lineBreakRun } = run;
|
|
270
|
+
return lineBreakRun;
|
|
271
|
+
}
|
|
272
|
+
case "field": {
|
|
273
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...fieldRun } = run;
|
|
274
|
+
return fieldRun;
|
|
275
|
+
}
|
|
276
|
+
case "math": {
|
|
277
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...mathRun } = run;
|
|
278
|
+
return mathRun;
|
|
279
|
+
}
|
|
280
|
+
case "renderedPageBreak": {
|
|
281
|
+
const { pmStart: _pmStart, pmEnd: _pmEnd, ...breakRun } = run;
|
|
282
|
+
return breakRun;
|
|
283
|
+
}
|
|
284
|
+
default: return run;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
192
287
|
//#endregion
|
|
193
|
-
export { DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, tableColumnsArePinned, types_exports };
|
|
288
|
+
export { DEFAULT_TEXTBOX_MARGINS, DEFAULT_TEXTBOX_WIDTH, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, floatingTextBoxReservesBand, floatingTextBoxWrapsText, getTableRowLeadingWidth, isFloatingImageRun, isFloatingTextBoxBlock, isListNumPr, isTextWrappingFloatingImageRun, resolveTableCellPadding, resolveTableWidthPx, stripFlowBlockPmAnchors, tableColumnsArePinned, types_exports };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FlowBlock, Layout, Measure } from "../layout-engine/types.js";
|
|
2
|
+
import { NoteStoryKey } from "../types/editor-story.js";
|
|
2
3
|
import { RenderContext } from "./renderUtils.js";
|
|
3
4
|
import { BlockFor, FeatureDispatchInput, FeatureFallback, FeatureModule, FeatureRenderInput, FragmentFor, MeasureFor } from "./registry/types.js";
|
|
4
5
|
import { FeatureRegistry, createFeatureRegistry } from "./registry/registry.js";
|
|
@@ -17,6 +18,8 @@ type BlockLookupEntry = {
|
|
|
17
18
|
block: FlowBlock;
|
|
18
19
|
measure: Measure;
|
|
19
20
|
version?: string;
|
|
21
|
+
/** The note story a block flowed with the body belongs to (endnote content). */
|
|
22
|
+
noteStory?: NoteStoryKey;
|
|
20
23
|
};
|
|
21
24
|
/**
|
|
22
25
|
* Block lookup map type
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { resolveFloatingTableX } from "../layout-engine/measure/floatingTablePosition.js";
|
|
2
2
|
import { rectsToFloatingZones } from "../layout-engine/measure/floatingZones.js";
|
|
3
|
+
import { DEFAULT_FONT_FAMILY } from "../layout-engine/measure/measureHelpers.js";
|
|
3
4
|
import { measureParagraph } from "../layout-engine/measure/measureParagraph.js";
|
|
4
5
|
import { resolveTableInlineOffset } from "../layout-engine/measure/tableInlinePlacement.js";
|
|
5
|
-
import { floatingTextBoxReservesBand, floatingTextBoxWrapsText, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun } from "../layout-engine/types.js";
|
|
6
|
+
import { NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION, floatingTextBoxReservesBand, floatingTextBoxWrapsText, isFloatingImageRun, isFloatingTextBoxBlock, isTextWrappingFloatingImageRun, stripFlowBlockPmAnchors } from "../layout-engine/types.js";
|
|
6
7
|
import { cssBorderStyle } from "../utils/borderCss.js";
|
|
7
8
|
import { resolveFontFamily } from "../utils/fontResolver.js";
|
|
8
9
|
import { borderToStyle } from "../utils/formatToStyle.js";
|
|
@@ -43,7 +44,7 @@ const PAGE_CLASS_NAMES = {
|
|
|
43
44
|
};
|
|
44
45
|
const HEADER_FOOTER_RULE_CLIP_MARGIN = pointsToPixels(1.5);
|
|
45
46
|
const DEFAULT_MARGIN_GUIDE_COLOR = "#c0c0c0";
|
|
46
|
-
const getDefaultPageFontFamily = () => resolveFontFamily(
|
|
47
|
+
const getDefaultPageFontFamily = () => resolveFontFamily(DEFAULT_FONT_FAMILY).cssFallback;
|
|
47
48
|
/**
|
|
48
49
|
* Apply page styles to an element
|
|
49
50
|
*/
|
|
@@ -603,6 +604,25 @@ function calculateFootnoteAreaRenderHeight(footnotes) {
|
|
|
603
604
|
}
|
|
604
605
|
return height;
|
|
605
606
|
}
|
|
607
|
+
/** A note separator rule: the canvas ink colour, `NOTE_SEPARATOR_RULE_THICKNESS` high. */
|
|
608
|
+
function applyNoteSeparatorRuleStyles(element, width) {
|
|
609
|
+
element.style.width = `${width}px`;
|
|
610
|
+
element.style.height = `${NOTE_SEPARATOR_RULE_THICKNESS}px`;
|
|
611
|
+
element.style.backgroundColor = "var(--doc-canvas-text, #000)";
|
|
612
|
+
}
|
|
613
|
+
/** The separator rules of a note area that flows with the body (endnotes). */
|
|
614
|
+
function renderFlowedNoteSeparators(page, contentEl, doc) {
|
|
615
|
+
for (const rule of page.noteSeparators ?? []) {
|
|
616
|
+
const ruleEl = doc.createElement("div");
|
|
617
|
+
ruleEl.className = "layout-note-separator";
|
|
618
|
+
applyNoteSeparatorRuleStyles(ruleEl, rule.width);
|
|
619
|
+
ruleEl.style.position = "absolute";
|
|
620
|
+
ruleEl.style.left = `${rule.x - page.margins.left}px`;
|
|
621
|
+
ruleEl.style.top = `${rule.y - page.margins.top}px`;
|
|
622
|
+
ruleEl.style.pointerEvents = "none";
|
|
623
|
+
contentEl.append(ruleEl);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
606
626
|
/**
|
|
607
627
|
* Render the footnote area at the bottom of a page.
|
|
608
628
|
* Includes a separator line (33% width) and footnote entries.
|
|
@@ -612,11 +632,8 @@ function renderFootnoteArea(footnotes, contentWidth, doc, context) {
|
|
|
612
632
|
container.className = "layout-footnote-area";
|
|
613
633
|
container.style.width = `${contentWidth}px`;
|
|
614
634
|
const separator = doc.createElement("div");
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
separator.style.width = "33%";
|
|
618
|
-
separator.style.height = `${separatorRuleHeight}px`;
|
|
619
|
-
separator.style.backgroundColor = "var(--doc-canvas-text, #000)";
|
|
635
|
+
const separatorMargin = (12 - NOTE_SEPARATOR_RULE_THICKNESS) / 2;
|
|
636
|
+
applyNoteSeparatorRuleStyles(separator, contentWidth * NOTE_SEPARATOR_WIDTH_FRACTION);
|
|
620
637
|
separator.style.marginTop = `${separatorMargin}px`;
|
|
621
638
|
separator.style.marginBottom = `${separatorMargin}px`;
|
|
622
639
|
container.append(separator);
|
|
@@ -674,7 +691,7 @@ function renderFootnoteContent(footnote, contentWidth, doc, context) {
|
|
|
674
691
|
return wrapper;
|
|
675
692
|
}
|
|
676
693
|
function renderFootnoteBlock(block, measure, contentWidth, y, context, doc) {
|
|
677
|
-
const renderBlock =
|
|
694
|
+
const renderBlock = stripFlowBlockPmAnchors(block);
|
|
678
695
|
if (renderBlock.kind === "paragraph" && measure.kind === "paragraph") {
|
|
679
696
|
const element = renderParagraphFragment({
|
|
680
697
|
kind: "paragraph",
|
|
@@ -732,81 +749,6 @@ function renderFootnoteBlock(block, measure, contentWidth, y, context, doc) {
|
|
|
732
749
|
}
|
|
733
750
|
return null;
|
|
734
751
|
}
|
|
735
|
-
function stripFootnotePmAnchors(block) {
|
|
736
|
-
switch (block.kind) {
|
|
737
|
-
case "paragraph": return stripFootnoteParagraphPmAnchors(block);
|
|
738
|
-
case "table": return stripFootnoteTablePmAnchors(block);
|
|
739
|
-
case "image": {
|
|
740
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...image } = block;
|
|
741
|
-
return image;
|
|
742
|
-
}
|
|
743
|
-
case "textBox": {
|
|
744
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...textBox } = block;
|
|
745
|
-
return {
|
|
746
|
-
...textBox,
|
|
747
|
-
content: textBox.content.map((contentBlock) => contentBlock.kind === "table" ? stripFootnoteTablePmAnchors(contentBlock) : stripFootnoteParagraphPmAnchors(contentBlock))
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
case "pageBreak":
|
|
751
|
-
case "columnBreak": {
|
|
752
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...breakBlock } = block;
|
|
753
|
-
return breakBlock;
|
|
754
|
-
}
|
|
755
|
-
case "sectionBreak": return block;
|
|
756
|
-
default: return block;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
function stripFootnoteTablePmAnchors(block) {
|
|
760
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...table } = block;
|
|
761
|
-
return {
|
|
762
|
-
...table,
|
|
763
|
-
rows: table.rows.map(stripFootnoteTableRowPmAnchors)
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
function stripFootnoteTableRowPmAnchors(row) {
|
|
767
|
-
return {
|
|
768
|
-
...row,
|
|
769
|
-
cells: row.cells.map(stripFootnoteTableCellPmAnchors)
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
function stripFootnoteTableCellPmAnchors(cell) {
|
|
773
|
-
return {
|
|
774
|
-
...cell,
|
|
775
|
-
blocks: cell.blocks.map(stripFootnotePmAnchors)
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
function stripFootnoteParagraphPmAnchors(block) {
|
|
779
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...paragraph } = block;
|
|
780
|
-
return {
|
|
781
|
-
...paragraph,
|
|
782
|
-
runs: paragraph.runs.map(stripFootnoteRunPmAnchors)
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
function stripFootnoteRunPmAnchors(run) {
|
|
786
|
-
switch (run.kind) {
|
|
787
|
-
case "text": {
|
|
788
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...textRun } = run;
|
|
789
|
-
return textRun;
|
|
790
|
-
}
|
|
791
|
-
case "tab": {
|
|
792
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...tabRun } = run;
|
|
793
|
-
return tabRun;
|
|
794
|
-
}
|
|
795
|
-
case "image": {
|
|
796
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...imageRun } = run;
|
|
797
|
-
return imageRun;
|
|
798
|
-
}
|
|
799
|
-
case "lineBreak": {
|
|
800
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...lineBreakRun } = run;
|
|
801
|
-
return lineBreakRun;
|
|
802
|
-
}
|
|
803
|
-
case "field": {
|
|
804
|
-
const { pmStart: _pmStart, pmEnd: _pmEnd, ...fieldRun } = run;
|
|
805
|
-
return fieldRun;
|
|
806
|
-
}
|
|
807
|
-
default: return run;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
752
|
function positionFootnoteBlock(element, top, width, height) {
|
|
811
753
|
element.style.position = "absolute";
|
|
812
754
|
element.style.left = "0";
|
|
@@ -1040,6 +982,11 @@ function renderPage(page, context, options = {}) {
|
|
|
1040
982
|
left: page.margins.left,
|
|
1041
983
|
top: page.margins.top
|
|
1042
984
|
});
|
|
985
|
+
const noteStory = options.blockLookup?.get(String(fragment.blockId))?.noteStory;
|
|
986
|
+
if (noteStory) {
|
|
987
|
+
fragmentEl.dataset["noteKind"] = noteStory.kind;
|
|
988
|
+
fragmentEl.dataset["noteId"] = String(noteStory.noteId);
|
|
989
|
+
}
|
|
1043
990
|
contentEl.append(fragmentEl);
|
|
1044
991
|
}
|
|
1045
992
|
if (frontFloatingImages.length > 0) {
|
|
@@ -1064,6 +1011,7 @@ function renderPage(page, context, options = {}) {
|
|
|
1064
1011
|
contentEl.append(line);
|
|
1065
1012
|
}
|
|
1066
1013
|
}
|
|
1014
|
+
renderFlowedNoteSeparators(page, contentEl, doc);
|
|
1067
1015
|
if (options.footnoteArea && options.footnoteArea.length > 0) {
|
|
1068
1016
|
const fnAreaEl = renderFootnoteArea(options.footnoteArea, contentWidth, doc, context);
|
|
1069
1017
|
fnAreaEl.style.position = "absolute";
|
|
@@ -1425,6 +1373,7 @@ function runContentKey(run) {
|
|
|
1425
1373
|
if (run.forceComplexScript !== void 0) parts.push(`cs-force:${run.forceComplexScript}`);
|
|
1426
1374
|
if (run.eastAsiaFontFamily) parts.push(`ea:${run.eastAsiaFontFamily}`);
|
|
1427
1375
|
if (run.eastAsiaAlternateFontFamily) parts.push(`ea-alt:${run.eastAsiaAlternateFontFamily}`);
|
|
1376
|
+
if (run.eastAsiaHint !== void 0) parts.push(`ea-hint:${run.eastAsiaHint}`);
|
|
1428
1377
|
if (run.fontSize !== void 0) parts.push(`fs:${run.fontSize}`);
|
|
1429
1378
|
if (run.letterSpacing !== void 0) parts.push(`ls:${run.letterSpacing}`);
|
|
1430
1379
|
if (run.superscript) parts.push("sup");
|
|
@@ -30,6 +30,11 @@ type RenderParagraphOptions = {
|
|
|
30
30
|
renderedInlineImageKeys?: Set<string>;
|
|
31
31
|
};
|
|
32
32
|
declare function getRenderableTextColor(run: TextRun | TabRun): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The colour a list marker paints in, or undefined for the canvas text colour.
|
|
35
|
+
* Black and `auto` fall back to the canvas colour, as they do for runs.
|
|
36
|
+
*/
|
|
37
|
+
declare function getRenderableListMarkerColor(color: string | undefined): string | undefined;
|
|
33
38
|
/**
|
|
34
39
|
* How CSS spells each bidirectional wrapper: an override switches the
|
|
35
40
|
* bidirectional algorithm off for its content, an embedding opens a level and
|
|
@@ -147,4 +152,4 @@ declare const paragraphHasTrackedChanges: (block: ParagraphBlock) => boolean;
|
|
|
147
152
|
*/
|
|
148
153
|
declare function renderParagraphFragment(fragment: ParagraphFragment, block: ParagraphBlock, measure: ParagraphMeasure, context: RenderContext, options?: RenderParagraphOptions): HTMLElement;
|
|
149
154
|
//#endregion
|
|
150
|
-
export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, paragraphHasTrackedChanges, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|
|
155
|
+
export { PARAGRAPH_CLASS_NAMES, RenderParagraphOptions, UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableListMarkerColor, getRenderableTextColor, paragraphHasTrackedChanges, renderLine, renderParagraphFragment, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap };
|