@betteroffice/docx 0.0.1
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/LICENSE +201 -0
- package/README.md +41 -0
- package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
- package/dist/agent/index.d.mts +531 -0
- package/dist/agent/index.mjs +1 -0
- package/dist/chunk-34K66SY4.mjs +1 -0
- package/dist/chunk-3UBMCDME.mjs +1 -0
- package/dist/chunk-4RCISPPE.mjs +1 -0
- package/dist/chunk-4UD54UM5.mjs +1 -0
- package/dist/chunk-52GB3Y42.mjs +1 -0
- package/dist/chunk-6NEKRDXF.mjs +1 -0
- package/dist/chunk-6PW4CWUG.mjs +1 -0
- package/dist/chunk-7DEIW7FL.mjs +1 -0
- package/dist/chunk-7PCO5I2O.mjs +1 -0
- package/dist/chunk-BI3B33LI.mjs +1 -0
- package/dist/chunk-BIQWVK5P.mjs +2 -0
- package/dist/chunk-CIRN3LZA.mjs +1 -0
- package/dist/chunk-DXKG3HQ5.mjs +16 -0
- package/dist/chunk-EUUIJVM6.mjs +0 -0
- package/dist/chunk-FPZBTOD6.mjs +1 -0
- package/dist/chunk-FZIA7OFY.mjs +1 -0
- package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
- package/dist/chunk-H3JCIGWK.mjs +1 -0
- package/dist/chunk-HJGAQIU7.mjs +2 -0
- package/dist/chunk-I6KKMUUC.mjs +1 -0
- package/dist/chunk-IL5JZJT7.mjs +1 -0
- package/dist/chunk-JY6ILTNS.mjs +1 -0
- package/dist/chunk-KEE52TT5.mjs +1 -0
- package/dist/chunk-KVKLLTDP.mjs +58 -0
- package/dist/chunk-KXNZFTTK.mjs +1 -0
- package/dist/chunk-L5ISVQ3W.mjs +1 -0
- package/dist/chunk-LDUWIM7M.mjs +1 -0
- package/dist/chunk-N5Q3YN64.mjs +1 -0
- package/dist/chunk-NEWOMDTX.mjs +1 -0
- package/dist/chunk-O2QSE2I7.mjs +1 -0
- package/dist/chunk-OBQGPMPQ.mjs +1 -0
- package/dist/chunk-OJOHXQNQ.mjs +1 -0
- package/dist/chunk-OMR3TWCD.mjs +2 -0
- package/dist/chunk-P3KDV4M2.mjs +1 -0
- package/dist/chunk-Q7PO7V73.mjs +1 -0
- package/dist/chunk-QOUFE3VX.mjs +1 -0
- package/dist/chunk-SINEY6ZF.mjs +1 -0
- package/dist/chunk-T4EZMUXM.mjs +1 -0
- package/dist/chunk-TTRUPDAB.mjs +1 -0
- package/dist/chunk-TYHI7RAD.mjs +1 -0
- package/dist/chunk-UIEJWORW.mjs +1 -0
- package/dist/chunk-VAOUFAUH.mjs +1 -0
- package/dist/chunk-VBOTMRXV.mjs +1 -0
- package/dist/chunk-VCER63GQ.mjs +1 -0
- package/dist/chunk-WAUF2UC7.mjs +2 -0
- package/dist/chunk-WRWRCBLK.mjs +1 -0
- package/dist/chunk-X4XDO3LZ.mjs +1 -0
- package/dist/chunk-XQBCCJBO.mjs +9 -0
- package/dist/chunk-XWUOLYRQ.mjs +2 -0
- package/dist/chunk-XYH6XWP3.mjs +10 -0
- package/dist/chunk-YBIM6UJV.mjs +8 -0
- package/dist/chunk-YCIH2Q3E.mjs +1 -0
- package/dist/chunk-YUOKI2HB.mjs +1 -0
- package/dist/chunk-ZOV5KL7C.mjs +1 -0
- package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
- package/dist/content-sSHuWw49.d.mts +2202 -0
- package/dist/core-plugins.d.mts +37 -0
- package/dist/core-plugins.mjs +1 -0
- package/dist/core.d.mts +451 -0
- package/dist/core.mjs +1 -0
- package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
- package/dist/docx/index.d.mts +618 -0
- package/dist/docx/index.mjs +2 -0
- package/dist/docx/parser.d.mts +41 -0
- package/dist/docx/parser.mjs +1 -0
- package/dist/docx/rezip.d.mts +148 -0
- package/dist/docx/rezip.mjs +1 -0
- package/dist/docx/serializer/index.d.mts +42 -0
- package/dist/docx/serializer/index.mjs +1 -0
- package/dist/docx/wrapTypes.d.mts +19 -0
- package/dist/docx/wrapTypes.mjs +1 -0
- package/dist/docxInput-DTbCa48g.d.mts +21 -0
- package/dist/editor/index.d.mts +170 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/editorTree-DO5PyDK8.d.mts +37 -0
- package/dist/executor-7O2RBJ2B.mjs +1 -0
- package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
- package/dist/formatting-DoL7KBSL.d.mts +823 -0
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
- package/dist/headless.d.mts +69 -0
- package/dist/headless.mjs +1 -0
- package/dist/layout/flow/index.d.mts +149 -0
- package/dist/layout/flow/index.mjs +1 -0
- package/dist/layout/index.d.mts +307 -0
- package/dist/layout/index.mjs +1 -0
- package/dist/layout/measure/index.d.mts +324 -0
- package/dist/layout/measure/index.mjs +1 -0
- package/dist/layout/pagination/index.d.mts +60 -0
- package/dist/layout/pagination/index.mjs +1 -0
- package/dist/layout/pagination/types.d.mts +4 -0
- package/dist/layout/pagination/types.mjs +1 -0
- package/dist/layout/render/index.d.mts +733 -0
- package/dist/layout/render/index.mjs +1 -0
- package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
- package/dist/managers/AutoSaveManager.d.mts +81 -0
- package/dist/managers/AutoSaveManager.mjs +1 -0
- package/dist/managers/TableSelectionManager.d.mts +74 -0
- package/dist/managers/TableSelectionManager.mjs +1 -0
- package/dist/managers/types.d.mts +113 -0
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +142 -0
- package/dist/mcp.d.mts +162 -0
- package/dist/mcp.mjs +16 -0
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
- package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
- package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
- package/dist/plugin-api/RenderedDomContext.mjs +1 -0
- package/dist/plugin-api/index.d.mts +7 -0
- package/dist/plugin-api/index.mjs +0 -0
- package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
- package/dist/plugin-api/resolveItemPositions.mjs +1 -0
- package/dist/plugin-api/types.d.mts +193 -0
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
- package/dist/registry-DMM5VTdT.d.mts +165 -0
- package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
- package/dist/rustPagination-Bj2hq013.d.mts +106 -0
- package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
- package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
- package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
- package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
- package/dist/styles/index.d.mts +162 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/styles-VxNcXLdi.d.mts +189 -0
- package/dist/types/agentApi.d.mts +456 -0
- package/dist/types/agentApi.mjs +1 -0
- package/dist/types/content.d.mts +3 -0
- package/dist/types/content.mjs +1 -0
- package/dist/types/document.d.mts +117 -0
- package/dist/types/document.mjs +1 -0
- package/dist/types-DNrYr6yQ.d.mts +1754 -0
- package/dist/types-dYdjUZMo.d.mts +311 -0
- package/dist/units-O5Y02RKQ.d.mts +34 -0
- package/dist/utils/autoScroll.d.mts +24 -0
- package/dist/utils/autoScroll.mjs +1 -0
- package/dist/utils/cardStyles.d.mts +22 -0
- package/dist/utils/cardStyles.mjs +1 -0
- package/dist/utils/comments.d.mts +120 -0
- package/dist/utils/comments.mjs +4 -0
- package/dist/utils/findReplace.d.mts +114 -0
- package/dist/utils/findReplace.mjs +2 -0
- package/dist/utils/findVerticalScrollParent.d.mts +25 -0
- package/dist/utils/findVerticalScrollParent.mjs +1 -0
- package/dist/utils/fontOptions.d.mts +21 -0
- package/dist/utils/fontOptions.mjs +1 -0
- package/dist/utils/headingCollector.d.mts +28 -0
- package/dist/utils/headingCollector.mjs +1 -0
- package/dist/utils/highlightColors.d.mts +14 -0
- package/dist/utils/highlightColors.mjs +1 -0
- package/dist/utils/index.d.mts +956 -0
- package/dist/utils/index.mjs +84 -0
- package/dist/utils/listState.d.mts +27 -0
- package/dist/utils/listState.mjs +1 -0
- package/dist/utils/reportIssue.d.mts +23 -0
- package/dist/utils/reportIssue.mjs +2 -0
- package/dist/utils/sidebarConstants.d.mts +10 -0
- package/dist/utils/sidebarConstants.mjs +1 -0
- package/dist/utils/stylePreview.d.mts +70 -0
- package/dist/utils/stylePreview.mjs +1 -0
- package/dist/utils/textSelection.d.mts +92 -0
- package/dist/utils/textSelection.mjs +1 -0
- package/dist/utils/units.d.mts +78 -0
- package/dist/utils/units.mjs +1 -0
- package/dist/variableDetector-Borj29SF.d.mts +115 -0
- package/dist/wasm-FZQ5XB2Y.mjs +1 -0
- package/dist/wasm-SA237OSP.mjs +1 -0
- package/dist/wasm-edit.d.mts +473 -0
- package/dist/wasm-edit.mjs +1 -0
- package/dist/wasm-layout.d.mts +112 -0
- package/dist/wasm-layout.mjs +1 -0
- package/dist/wasm-opc.d.mts +16 -0
- package/dist/wasm-opc.mjs +1 -0
- package/dist/wasm-parse.d.mts +18 -0
- package/dist/wasm-parse.mjs +1 -0
- package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
- package/dist/yrs/index.d.mts +882 -0
- package/dist/yrs/index.mjs +1 -0
- package/dist/yrs/residentEngineWorker.d.mts +2 -0
- package/dist/yrs/residentEngineWorker.mjs +1 -0
- package/package.json +365 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { e as LayoutBlock, B as BlockExtent, f as BlockId, L as LayoutOptions, a as Layout, F as FootnoteContent, g as Page, h as FootnoteRenderItem, P as PageMargins, H as HeaderFooterContent, I as ImageRun } from './types-DNrYr6yQ.mjs';
|
|
2
|
+
import { a as Theme } from './formatting-DoL7KBSL.mjs';
|
|
3
|
+
import { ax as NoteKind, F as Footnote, E as Endnote, m as HeaderFooter } from './content-sSHuWw49.mjs';
|
|
4
|
+
import { a as StyleDefinitions } from './styles-VxNcXLdi.mjs';
|
|
5
|
+
import { M as MeasuredBlock } from './measuredBlock-DZwz8zhD.mjs';
|
|
6
|
+
import { Document } from './types/document.mjs';
|
|
7
|
+
import { a as DisplayListQueries, D as DisplayListRect } from './displayListQueries-p-ijSzdh.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Footnote Layout Utilities
|
|
11
|
+
*
|
|
12
|
+
* Footnote/endnote rendering pipeline plus page-mapping helpers:
|
|
13
|
+
* - scanning FlowBlocks for footnote references and their PM positions
|
|
14
|
+
* - mapping references to the page that ends up containing them
|
|
15
|
+
* - converting a Footnote → FootnoteContent via the body pipeline
|
|
16
|
+
* (footnoteToProseDoc → toLayoutBlocks → caller-supplied measureBlocks)
|
|
17
|
+
* - reserving per-page footnote area heights for layout
|
|
18
|
+
*
|
|
19
|
+
* Everything that's pure OOXML / LayoutBlock semantics lives here so the
|
|
20
|
+
* React, Vue, and any future adapters can share the conversion logic
|
|
21
|
+
* and just supply their own measurement function (which depends on
|
|
22
|
+
* platform-specific Canvas/font metrics).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Separator line height + vertical padding in pixels. */
|
|
26
|
+
declare const FOOTNOTE_SEPARATOR_HEIGHT = 12;
|
|
27
|
+
/**
|
|
28
|
+
* Gutter between footnote columns when `w15:footnoteColumns` > 1, in pixels
|
|
29
|
+
* (≈ 0.25in). Shared by the reserved-height/measurement path (core) and the
|
|
30
|
+
* footnote painter so a footnote measured at column width paints into a column
|
|
31
|
+
* of exactly that width. Single-column footnotes never consult it.
|
|
32
|
+
*/
|
|
33
|
+
declare const FOOTNOTE_COLUMN_GAP_PX = 24;
|
|
34
|
+
/**
|
|
35
|
+
* Hard cap on the multi-pass footnote layout loop. Reserving footnote
|
|
36
|
+
* space can move a reference to another page, so adapters keep remapping
|
|
37
|
+
* until the page→height contract is stable. Dense layouts converge in
|
|
38
|
+
* 2–3 passes in practice; 6 is a safe ceiling.
|
|
39
|
+
*/
|
|
40
|
+
declare const MAX_FOOTNOTE_LAYOUT_PASSES = 6;
|
|
41
|
+
/**
|
|
42
|
+
* Compare two per-page footnote reservation maps. Used by the React +
|
|
43
|
+
* Vue adapters to detect when the multi-pass loop has converged.
|
|
44
|
+
*/
|
|
45
|
+
declare function footnoteReservedHeightsEqual(a: Map<number, number>, b: Map<number, number>): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Where a footnote reference lives, as found by {@link collectFootnoteRefs}.
|
|
48
|
+
*
|
|
49
|
+
* `pmPos` alone is enough to attribute a reference to a page for ordinary
|
|
50
|
+
* (paragraph) content, whose fragments carry a per-page pm sub-range. A table
|
|
51
|
+
* is different: it splits across pages by ROW, but every `TableFragment` keeps
|
|
52
|
+
* the whole table's `pmStart`/`pmEnd` (those drive selection mapping and must
|
|
53
|
+
* not be narrowed). So for a reference authored inside a table cell we also
|
|
54
|
+
* record the OUTERMOST table's id and the index of the row that contains it,
|
|
55
|
+
* letting {@link mapFootnotesToPages} attribute the reference to the page that
|
|
56
|
+
* actually laid out that row.
|
|
57
|
+
*/
|
|
58
|
+
type FootnoteRefLocation = {
|
|
59
|
+
footnoteId: number;
|
|
60
|
+
pmPos: number;
|
|
61
|
+
/** Undefined preserves the legacy footnote-only shape. */
|
|
62
|
+
noteKind?: NoteKind;
|
|
63
|
+
/** Id of the outermost enclosing table block, when the ref is in a table cell. */
|
|
64
|
+
tableBlockId?: BlockId;
|
|
65
|
+
/** Index (into the outermost table's `rows`) of the row holding the ref. */
|
|
66
|
+
rowIndex?: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Scan FlowBlocks for runs with footnoteRefId set.
|
|
70
|
+
* Returns a list of {@link FootnoteRefLocation} in document order.
|
|
71
|
+
*
|
|
72
|
+
* Recurses into container blocks (table cells, text boxes) so footnote
|
|
73
|
+
* references authored anywhere in the body reach the page-reservation
|
|
74
|
+
* pass. Without this, a `footnoteRefId` nested inside a table cell never
|
|
75
|
+
* gets mapped to a page and the per-page `.layout-footnote-area` silently
|
|
76
|
+
* drops that entry even though the body still renders the in-line ref
|
|
77
|
+
* marker.
|
|
78
|
+
*
|
|
79
|
+
* For refs inside a table, the OUTERMOST table's id and row index are
|
|
80
|
+
* recorded (a nested table keeps the outer context, since the outer row is
|
|
81
|
+
* what the paginator splits into per-page fragments).
|
|
82
|
+
*/
|
|
83
|
+
declare function collectFootnoteRefs(blocks: LayoutBlock[]): FootnoteRefLocation[];
|
|
84
|
+
/**
|
|
85
|
+
* After layout, determine which footnotes appear on which pages.
|
|
86
|
+
* Checks each page's fragments to see if any footnoteRef PM positions fall within.
|
|
87
|
+
*
|
|
88
|
+
* Returns Map<pageNumber, footnoteId[]> in document order.
|
|
89
|
+
*/
|
|
90
|
+
declare function mapFootnotesToPages(pages: Page[], footnoteRefs: FootnoteRefLocation[]): Map<number, number[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Footnote-specific block normalization. Mirrors the spirit of
|
|
93
|
+
* `normalizeHeaderFooterMeasureBlocks`: post-process the body-pipeline
|
|
94
|
+
* output for a single footnote so it carries the correct visual prefix
|
|
95
|
+
* (its display number, rendered as a superscript) and a default 8pt font
|
|
96
|
+
* for any run that didn't specify a size.
|
|
97
|
+
*
|
|
98
|
+
* The displayNumber is prepended onto the FIRST paragraph as a fresh
|
|
99
|
+
* superscript text run — visually matches Word's footnote numbering
|
|
100
|
+
* without disturbing the authored runs.
|
|
101
|
+
*
|
|
102
|
+
* Exported for callers that want to compose their own conversion
|
|
103
|
+
* pipeline; `convertFootnoteToContent` calls it as part of its flow.
|
|
104
|
+
*/
|
|
105
|
+
declare function applyFootnotePresentation(blocks: LayoutBlock[], displayNumber: number, displayLabel?: string): LayoutBlock[];
|
|
106
|
+
/**
|
|
107
|
+
* Adapter-supplied block measurement function. The caller (React /
|
|
108
|
+
* Vue / etc.) supplies its platform's measure routine — at minimum
|
|
109
|
+
* paragraph + table + image + textBox — so this core helper stays
|
|
110
|
+
* Canvas-free.
|
|
111
|
+
*/
|
|
112
|
+
type MeasureBlocksFn = (blocks: LayoutBlock[], contentWidth: number) => BlockExtent[];
|
|
113
|
+
/**
|
|
114
|
+
* Options for {@link convertFootnoteToContent}.
|
|
115
|
+
*/
|
|
116
|
+
type ConvertFootnoteOptions = {
|
|
117
|
+
/** The document's parsed style definitions, threaded into the body pipeline. */
|
|
118
|
+
styles?: StyleDefinitions | null;
|
|
119
|
+
/** Theme for resolving themed fills / fonts inside the footnote. */
|
|
120
|
+
theme?: Theme | null;
|
|
121
|
+
/** Authoritative yrs story source. */
|
|
122
|
+
yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
|
|
123
|
+
/** BlockExtent callback supplied by the rendering adapter. */
|
|
124
|
+
measureBlocks: MeasureBlocksFn;
|
|
125
|
+
/**
|
|
126
|
+
* Doc-level `w:defaultTabStop` (twips) from the body so list markers
|
|
127
|
+
* inside footnotes honor the same tab grid.
|
|
128
|
+
*/
|
|
129
|
+
defaultTabStopTwips?: number | null;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Convert a Footnote to renderable FootnoteContent via the body pipeline:
|
|
133
|
+
* `footnoteToProseDoc → toLayoutBlocks → applyFootnotePresentation →
|
|
134
|
+
* measureBlocks`. Pre-PR (#378) this lived in a hand-rolled shadow stack
|
|
135
|
+
* that silently dropped non-paragraph content; routing through the body
|
|
136
|
+
* pipeline gives footnotes full block-kind support — paragraph + table
|
|
137
|
+
* + image + textBox + fields.
|
|
138
|
+
*/
|
|
139
|
+
declare function convertFootnoteToContent(footnote: Footnote | Endnote, displayNumber: number, contentWidth: number, options: ConvertFootnoteOptions, presentation?: {
|
|
140
|
+
noteKind?: NoteKind;
|
|
141
|
+
displayLabel?: string;
|
|
142
|
+
anchor?: FootnoteContent['anchor'];
|
|
143
|
+
}): FootnoteContent;
|
|
144
|
+
/**
|
|
145
|
+
* Build footnote content for all footnotes referenced in the document.
|
|
146
|
+
* Display numbers are assigned by first-appearance order (the same way
|
|
147
|
+
* Word renders them).
|
|
148
|
+
*/
|
|
149
|
+
declare function buildFootnoteContentMap(footnotes: Footnote[], footnoteRefs: Array<{
|
|
150
|
+
footnoteId: number;
|
|
151
|
+
}>, contentWidth: number | ((ref: {
|
|
152
|
+
footnoteId: number;
|
|
153
|
+
}) => number), options: ConvertFootnoteOptions): Map<number, FootnoteContent>;
|
|
154
|
+
/**
|
|
155
|
+
* Distribute footnote items across `columns` balanced columns, preserving
|
|
156
|
+
* document order (footnotes must still read in numeric sequence). Items fill
|
|
157
|
+
* the first column until it reaches the balanced target height (≈ total / N),
|
|
158
|
+
* then spill into the next column — the same order-preserving balance Word
|
|
159
|
+
* applies to its footnote columns, not a greedy shortest-column packing
|
|
160
|
+
* (which would scramble the reading order).
|
|
161
|
+
*
|
|
162
|
+
* `columns <= 1` (the default for ordinary single-column footnotes) returns a
|
|
163
|
+
* single column unchanged, so callers that never opt into multi-column
|
|
164
|
+
* footnotes are byte-for-byte unaffected.
|
|
165
|
+
*
|
|
166
|
+
* Pure and shared by the reserved-height calculation (core) and the
|
|
167
|
+
* display-list footnote emission so the reserved area and the rendered
|
|
168
|
+
* columns are computed from the same partition.
|
|
169
|
+
*/
|
|
170
|
+
declare function distributeFootnotesIntoColumns<T extends {
|
|
171
|
+
height: number;
|
|
172
|
+
}>(items: T[], columns: number): T[][];
|
|
173
|
+
/**
|
|
174
|
+
* Calculate per-page footnote reserved heights.
|
|
175
|
+
* Returns Map<pageNumber, reservedHeight>.
|
|
176
|
+
*
|
|
177
|
+
* With `columns > 1` the footnotes are balanced across that many columns and
|
|
178
|
+
* the reserved height is the tallest column (plus the separator), since the
|
|
179
|
+
* columns sit side by side — not the sum of every footnote height.
|
|
180
|
+
*/
|
|
181
|
+
declare function calculateFootnoteReservedHeights(pageFootnoteMap: Map<number, number[]>, footnoteContentMap: Map<number, {
|
|
182
|
+
height: number;
|
|
183
|
+
noteKind?: NoteKind;
|
|
184
|
+
}>, columns?: number | Map<number, number>): Map<number, number>;
|
|
185
|
+
interface StabilizeFootnoteLayoutArgs {
|
|
186
|
+
blocks: LayoutBlock[];
|
|
187
|
+
measures: BlockExtent[];
|
|
188
|
+
layoutOpts: LayoutOptions;
|
|
189
|
+
/**
|
|
190
|
+
* The pagination kernel each stabilization iteration re-enters — the
|
|
191
|
+
* caller binds this to the mandatory Rust pagination source
|
|
192
|
+
* (`LayoutPaginationSource.paginate`). Throws on engine failure; the
|
|
193
|
+
* pipeline surfaces the error.
|
|
194
|
+
*/
|
|
195
|
+
paginate: (measured: MeasuredBlock[], options: LayoutOptions) => Layout;
|
|
196
|
+
footnoteRefs: FootnoteRefLocation[];
|
|
197
|
+
footnoteContentMap: Map<number, FootnoteContent>;
|
|
198
|
+
/** First-pass layout already computed by the caller without reserved heights. */
|
|
199
|
+
initialLayout: Layout;
|
|
200
|
+
/**
|
|
201
|
+
* Number of columns the footnote area is laid out in (`w15:footnoteColumns`).
|
|
202
|
+
* Defaults to 1. When > 1, reserved heights are balanced across the columns
|
|
203
|
+
* (tallest column wins) instead of summing every footnote, and the value is
|
|
204
|
+
* written onto each footnote-bearing page as `page.footnoteColumns`.
|
|
205
|
+
*/
|
|
206
|
+
footnoteColumns?: number | Map<number, number>;
|
|
207
|
+
/** Placement-aware mapper; defaults to legacy reference-page mapping. */
|
|
208
|
+
mapReferencesToPages?: (pages: Page[], refs: FootnoteRefLocation[]) => Map<number, number[]>;
|
|
209
|
+
}
|
|
210
|
+
interface StabilizeFootnoteLayoutResult {
|
|
211
|
+
layout: Layout;
|
|
212
|
+
pageFootnoteMap: Map<number, number[]>;
|
|
213
|
+
/** True if the loop converged before hitting MAX_FOOTNOTE_LAYOUT_PASSES. */
|
|
214
|
+
converged: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Run the multi-pass footnote layout loop. Reserving footnote space on a
|
|
218
|
+
* page can move a reference to another page, which changes the reservation,
|
|
219
|
+
* which can move references again. Iterate until the page→height contract
|
|
220
|
+
* is the same one used by the latest layout, or `MAX_FOOTNOTE_LAYOUT_PASSES`
|
|
221
|
+
* passes have run.
|
|
222
|
+
*
|
|
223
|
+
* Lives in core so the React + Vue adapters call the same loop and stay in
|
|
224
|
+
* lockstep on convergence behaviour. Writes `page.footnoteIds` onto each
|
|
225
|
+
* page in the returned layout so renderers can paint footnote areas.
|
|
226
|
+
*/
|
|
227
|
+
declare function stabilizeFootnoteLayout(args: StabilizeFootnoteLayoutArgs): StabilizeFootnoteLayoutResult;
|
|
228
|
+
/**
|
|
229
|
+
* Turn the page→footnote-id map into the per-page render payload that
|
|
230
|
+
* `renderPages` consumes via `footnotesByPage`. Skips non-`normal` notes
|
|
231
|
+
* (separators, continuation notices), reads the display number out of the
|
|
232
|
+
* content map, and pulls plain text via `getFootnoteText`.
|
|
233
|
+
*
|
|
234
|
+
* Lives in core (not in either adapter) so React + Vue both call the
|
|
235
|
+
* same helper — same rule as the rest of this module.
|
|
236
|
+
*/
|
|
237
|
+
declare function buildFootnoteRenderItems(pageFootnoteMap: Map<number, number[]>, footnoteContentMap: Map<number, FootnoteContent>, doc: Document | null): Map<number, FootnoteRenderItem[]>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Header / Footer Layout Utilities
|
|
241
|
+
*
|
|
242
|
+
* The header/footer rendering pipeline lives here so any rendering adapter
|
|
243
|
+
* (React, Vue, etc.) can share the conversion logic and just supply its
|
|
244
|
+
* platform-specific {@link MeasureBlocksFn}. Mirrors the footnote pipeline
|
|
245
|
+
* in `footnoteLayout.ts`.
|
|
246
|
+
*
|
|
247
|
+
* Pipeline:
|
|
248
|
+
* HF.content → headerFooterToProseDoc → toLayoutBlocks
|
|
249
|
+
* → measureBlocks (caller-supplied, Canvas-aware)
|
|
250
|
+
* → HeaderFooterContent (blocks, measures, height, visualTop/Bottom)
|
|
251
|
+
*
|
|
252
|
+
* The render side uses the normalized block list so paint and measurement stay
|
|
253
|
+
* in lockstep. Visual-bounds calculation still inspects the original block
|
|
254
|
+
* list because floating images can paint above/below the nominal flow box even
|
|
255
|
+
* when they do not contribute to flow height.
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
type HeaderFooterMetrics = {
|
|
259
|
+
section: 'header' | 'footer';
|
|
260
|
+
pageSize: {
|
|
261
|
+
w: number;
|
|
262
|
+
h: number;
|
|
263
|
+
};
|
|
264
|
+
margins: PageMargins;
|
|
265
|
+
};
|
|
266
|
+
declare function normalizeHeaderFooterMeasureBlocks(blocks: LayoutBlock[]): LayoutBlock[];
|
|
267
|
+
declare function resolveHeaderFooterVisualTop(run: ImageRun, paragraphY: number, flowHeight: number, metrics: HeaderFooterMetrics): number;
|
|
268
|
+
/**
|
|
269
|
+
* Whether a header/footer block participates in the in-flow band height that
|
|
270
|
+
* pushes the body margin.
|
|
271
|
+
*
|
|
272
|
+
* OOXML semantics: Word grows the header/footer band — and shifts body text —
|
|
273
|
+
* based only on the story's in-flow content. A floating/anchored object
|
|
274
|
+
* (`wp:anchor` DrawingML or an absolutely-positioned VML shape, e.g. a
|
|
275
|
+
* full-page letterhead anchored to the page in a header) is removed from the
|
|
276
|
+
* text flow and positioned on the page; it does NOT grow the band or push the
|
|
277
|
+
* body. So only inline-flow blocks count here. Anchored image *runs* inside a
|
|
278
|
+
* paragraph are likewise out of flow, but they don't contribute to the
|
|
279
|
+
* paragraph's measured line height, so paragraphs need no special handling.
|
|
280
|
+
*
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
declare function contributesToHeaderFooterFlowHeight(block: LayoutBlock): boolean;
|
|
284
|
+
declare function calculateHeaderFooterVisualBounds(blocks: LayoutBlock[], measures: BlockExtent[], flowHeight: number, metrics: HeaderFooterMetrics): {
|
|
285
|
+
visualTop: number;
|
|
286
|
+
visualBottom: number;
|
|
287
|
+
};
|
|
288
|
+
type ConvertHeaderFooterOptions = {
|
|
289
|
+
styles?: StyleDefinitions | null;
|
|
290
|
+
theme?: Theme | null;
|
|
291
|
+
measureBlocks: MeasureBlocksFn;
|
|
292
|
+
/** Authoritative yrs story source. */
|
|
293
|
+
yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
|
|
294
|
+
/**
|
|
295
|
+
* `w:defaultTabStop` (twips) read from `state.doc.attrs.defaultTabStopTwips`
|
|
296
|
+
* on the body doc — HF content doesn't carry its own doc-level setting,
|
|
297
|
+
* so pass it through so list markers inside headers/footers honor the
|
|
298
|
+
* same tab grid as the body.
|
|
299
|
+
*/
|
|
300
|
+
defaultTabStopTwips?: number | null;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Convert HeaderFooter (document type) to HeaderFooterContent (render type).
|
|
304
|
+
*
|
|
305
|
+
* Routes through the same pipeline as the body: HF.content →
|
|
306
|
+
* headerFooterToProseDoc → toLayoutBlocks → measureBlocks. The inline editor
|
|
307
|
+
* uses the same conversion chain, so block support (paragraph, table, image,
|
|
308
|
+
* textBox, fields) and the inline editor's content stay in lockstep.
|
|
309
|
+
*/
|
|
310
|
+
declare function convertHeaderFooterToContent(headerFooter: HeaderFooter | null | undefined, contentWidth: number, metrics: HeaderFooterMetrics, options: ConvertHeaderFooterOptions, hfStoryId?: string): HeaderFooterContent | undefined;
|
|
311
|
+
/** Query-backed HF caret geometry, optionally narrowed to the edited page. */
|
|
312
|
+
declare function computeHfCaretRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, pos: number, pageIndex?: number): DisplayListRect[];
|
|
313
|
+
/** Query-backed HF selection geometry, optionally narrowed to the edited page. */
|
|
314
|
+
declare function computeHfSelectionRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, from: number, to: number, pageIndex?: number): DisplayListRect[];
|
|
315
|
+
|
|
316
|
+
export { type ConvertFootnoteOptions as C, FOOTNOTE_COLUMN_GAP_PX as F, type HeaderFooterMetrics as H, MAX_FOOTNOTE_LAYOUT_PASSES as M, type StabilizeFootnoteLayoutArgs as S, type ConvertHeaderFooterOptions as a, FOOTNOTE_SEPARATOR_HEIGHT as b, type FootnoteRefLocation as c, type MeasureBlocksFn as d, type StabilizeFootnoteLayoutResult as e, applyFootnotePresentation as f, buildFootnoteContentMap as g, buildFootnoteRenderItems as h, calculateFootnoteReservedHeights as i, calculateHeaderFooterVisualBounds as j, collectFootnoteRefs as k, computeHfCaretRectsFromDisplayList as l, computeHfSelectionRectsFromDisplayList as m, contributesToHeaderFooterFlowHeight as n, convertFootnoteToContent as o, convertHeaderFooterToContent as p, distributeFootnotesIntoColumns as q, footnoteReservedHeightsEqual as r, mapFootnotesToPages as s, normalizeHeaderFooterMeasureBlocks as t, resolveHeaderFooterVisualTop as u, stabilizeFootnoteLayout as v };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export { A as AgentContextOptions, S as ContextSelectionOptions, D as DocumentAgent, E as ExtendedSelectionContext, F as FormattedTextSegment, a as FormattingSummary, I as InsertHyperlinkOptions, b as InsertImageOptions, c as InsertTableOptions, d as InsertTextOptions, e as SelectionContextOptions, f as buildExtendedSelectionContext, g as buildSelectionContext, h as buildSelectionContextFromContext, i as createAgent, j as createAgentFromDocument, k as executeCommand, l as executeCommands, m as getAgentContext, n as getDocumentSummary, o as getSelectionFormattingSummary } from './selectionContext-Buc9BCU1.mjs';
|
|
2
|
+
export { ContentControlBoundError, ContentControlCreateError, ContentControlFilter, ContentControlInfo, ContentControlKindError, ContentControlLocation, ContentControlLockedError, ContentControlNotFoundError, ContentControlTypeError, ContentControlValue, ContentControlValueError, CreateContentControlTarget, FindContentControlsOptions, NewContentControlProps, RepeatingSectionError, addRepeatingSectionItem, countCharacters, countWords, createContentControl, findContentControl, findContentControls, formatSdtDate, getBlockIndexForParagraph, getBodyCharacterCount, getBodyText, getBodyWordCount, getContentControlText, getFormattingAtPosition, getHyperlinkAtPosition, getHyperlinkText, getParagraphAtIndex, getParagraphText, getParagraphs, getRunText, getTableText, getTextAfter, getTextBefore, hasHyperlinks, hasImages, hasTables, isHeadingStyle, isPositionInHyperlink, isRepeatingSection, isRepeatingSectionItem, parseHeadingLevel, removeContentControl, removeRepeatingSectionItem, setContentControlContent, setContentControlValue } from './agent/index.mjs';
|
|
3
|
+
export { parseDocx } from './docx/parser.mjs';
|
|
4
|
+
export { serializeDocumentBody, serializeDocument as serializeDocx, serializeSectionProperties } from './docx/serializer/index.mjs';
|
|
5
|
+
export { createDocx, default as repackDocx, updateMultipleFiles } from './docx/rezip.mjs';
|
|
6
|
+
export { g as getDocumentWatermark, s as setDocumentWatermark } from './watermarkApi-DCxjutkg.mjs';
|
|
7
|
+
export { a as attemptSelectiveSave } from './selectiveSave-oFBJ1n71.mjs';
|
|
8
|
+
export { b as buildPatchedDocumentXml, v as validatePatchSafety } from './selectiveXmlPatch-ypkxlTD_.mjs';
|
|
9
|
+
export { C as CreateEmptyDocumentOptions, P as ProcessTemplateOptions, a as ProcessTemplateResult, T as TemplateError, c as colorsEqual, b as createDocumentWithText, d as createEmptyDocument, e as createRgbColor, f as createTemplateProcessor, g as createThemeColor, h as getMissingVariables, i as getTemplateTags, j as isBlack, k as isWhite, p as parseColorString, l as previewTemplate, m as processTemplate, n as processTemplateAdvanced, o as processTemplateAsBlob, q as processTemplateDetailed, r as resolveHighlightColor, s as resolveShadingColor, v as validateTemplate } from './colorResolver-n0o7H7ep.mjs';
|
|
10
|
+
export { V as VariableDetectionResult, a as VariableOccurrence, d as detectVariables, b as detectVariablesDetailed, c as detectVariablesInBody, e as detectVariablesInParagraph, f as documentHasVariables, g as extractVariablesFromText, h as formatVariable, i as hasTemplateVariables, j as isValidVariableName, p as parseVariable, r as removeVariables, k as replaceVariables, s as sanitizeVariableName } from './variableDetector-Borj29SF.mjs';
|
|
11
|
+
export { emuToTwips, formatPx, halfPointsToPixels, pixelsToTwips, pointsToHalfPoints, twipsToEmu, twipsToPixels } from './utils/units.mjs';
|
|
12
|
+
export { mapHexToHighlightName } from './utils/highlightColors.mjs';
|
|
13
|
+
export { C as CommandHandler, a as CommandResult, b as CorePlugin, J as JsonSchema, L as LoadedDocument, M as McpSession, c as McpToolAnnotations, d as McpToolContent, e as McpToolContext, f as McpToolDefinition, g as McpToolHandler, h as McpToolResult, b as Plugin, P as PluginCommand, C as PluginCommandHandler, i as PluginEvent, j as PluginEventListener, k as PluginOptions, l as PluginRegistrationResult, f as ToolDefinition, g as ToolHandler, h as ToolResult, Z as ZodSchemaLike, m as isZodSchema } from './types-dYdjUZMo.mjs';
|
|
14
|
+
export { P as PluginRegistry, c as createPluginRegistrar, p as pluginRegistry, r as registerPlugins } from './registry-DMM5VTdT.mjs';
|
|
15
|
+
export { Document, DocxPackage } from './types/document.mjs';
|
|
16
|
+
export { AIAction, AIActionRequest, AgentCommand, AgentContext, AgentResponse, ApplyStyleCommand, ApplyVariablesCommand, DEFAULT_AI_ACTIONS, DeleteTextCommand, FormatParagraphCommand, FormatTextCommand, InsertHyperlinkCommand, InsertImageCommand, InsertTableCommand, InsertTextCommand, ParagraphContext, ParagraphOutline, Position, Range, ReplaceTextCommand, SectionInfo, SelectionContext, SetVariableCommand, StyleInfo, SuggestedAction, comparePositions, createCollapsedRange, createCommand, createRange, getActionDescription, getActionLabel, isPositionInRange } from './types/agentApi.mjs';
|
|
17
|
+
export { B as BlockContent, C as Comment, a as CommentRangeEnd, b as CommentRangeStart, D as Deletion, c as DocumentBody, E as Endnote, F as Footnote, H as Hyperlink, I as Image, d as Insertion, L as ListLevel, M as MoveFrom, e as MoveTo, N as NumberingDefinitions, P as Paragraph, f as ParagraphContent, R as Run, g as RunContent, S as SectionProperties, T as Table, h as TableCell, i as TableRow, j as TextContent, k as TrackedChangeInfo, l as TrackedRunChange } from './content-sSHuWw49.mjs';
|
|
18
|
+
export { P as ParagraphFormatting, T as TextFormatting, a as Theme, b as blendColors, d as darkenColor, g as getContrastingColor, l as lightenColor, r as resolveColor } from './formatting-DoL7KBSL.mjs';
|
|
19
|
+
export { R as Relationship, S as Style, a as StyleDefinitions } from './styles-VxNcXLdi.mjs';
|
|
20
|
+
export { e as emuToPixels, p as pixelsToEmu, a as pointsToPixels } from './units-O5Y02RKQ.mjs';
|
|
21
|
+
import './docxInput-DTbCa48g.mjs';
|
|
22
|
+
import './settingsParser-CcGvtmCK.mjs';
|
|
23
|
+
import './docx/wrapTypes.mjs';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @betteroffice/docx/headless
|
|
27
|
+
*
|
|
28
|
+
* Headless aggregate for Node.js scripts, CLI tools, and server-side
|
|
29
|
+
* processing. Same surface as the default `.` entry, named to make the
|
|
30
|
+
* "no DOM" intent explicit. Prefer the smaller subpaths (`./docx`,
|
|
31
|
+
* `./agent`, `./utils`, etc.) for new code — they tree-shake better.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { DocumentAgent, parseDocx, pluginRegistry } from '@betteroffice/docx/headless';
|
|
36
|
+
* import { docxtemplaterPlugin } from '@betteroffice/docx/core-plugins';
|
|
37
|
+
*
|
|
38
|
+
* // Register plugins
|
|
39
|
+
* pluginRegistry.register(docxtemplaterPlugin);
|
|
40
|
+
*
|
|
41
|
+
* // Load and manipulate document
|
|
42
|
+
* const buffer = fs.readFileSync('template.docx');
|
|
43
|
+
* const agent = await DocumentAgent.fromBuffer(buffer);
|
|
44
|
+
*
|
|
45
|
+
* // Get document info
|
|
46
|
+
* console.log('Word count:', agent.getWordCount());
|
|
47
|
+
* console.log('Variables:', agent.getVariables());
|
|
48
|
+
*
|
|
49
|
+
* // Edit document
|
|
50
|
+
* const newAgent = agent
|
|
51
|
+
* .insertText({ paragraphIndex: 0, offset: 0 }, 'Hello ')
|
|
52
|
+
* .applyStyle(0, 'Heading1');
|
|
53
|
+
*
|
|
54
|
+
* // Apply template variables
|
|
55
|
+
* const finalAgent = await newAgent.applyVariables({
|
|
56
|
+
* customer_name: 'Jane Doe',
|
|
57
|
+
* date: '2024-02-15',
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // Export
|
|
61
|
+
* const output = await finalAgent.toBuffer();
|
|
62
|
+
* fs.writeFileSync('output.docx', Buffer.from(output));
|
|
63
|
+
* ```
|
|
64
|
+
* @packageDocumentation
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
declare const VERSION = "0.0.2";
|
|
68
|
+
|
|
69
|
+
export { VERSION };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as mapHexToHighlightName}from'./chunk-YCIH2Q3E.mjs';export{b as createDocumentWithText,a as createEmptyDocument}from'./chunk-VAOUFAUH.mjs';export{j as colorsEqual,g as createRgbColor,f as createThemeColor,c as isBlack,d as isWhite,e as parseColorString,a as resolveHighlightColor,b as resolveShadingColor}from'./chunk-L5ISVQ3W.mjs';export{a as isZodSchema}from'./chunk-XYH6XWP3.mjs';export{j as createTemplateProcessor,g as getMissingVariables,e as getTemplateTags,h as previewTemplate,a as processTemplate,i as processTemplateAdvanced,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-O2QSE2I7.mjs';export{a as getDocumentWatermark,b as setDocumentWatermark}from'./chunk-WAUF2UC7.mjs';export{b as buildPatchedDocumentXml,a as validatePatchSafety}from'./chunk-KEE52TT5.mjs';export{i as blendColors,g as darkenColor,f as getContrastingColor,h as lightenColor,d as resolveColor}from'./chunk-FZIA7OFY.mjs';export{a as ContentControlCreateError,e as RepeatingSectionError,f as addRepeatingSectionItem,b as createContentControl,c as isRepeatingSection,d as isRepeatingSectionItem,g as removeRepeatingSectionItem}from'./chunk-QOUFE3VX.mjs';export{C as ContentControlBoundError,F as ContentControlKindError,A as ContentControlLockedError,z as ContentControlNotFoundError,B as ContentControlTypeError,J as ContentControlValueError,g as countCharacters,f as countWords,y as findContentControl,x as findContentControls,K as formatSdtDate,v as getBlockIndexForParagraph,i as getBodyCharacterCount,e as getBodyText,h as getBodyWordCount,w as getContentControlText,l as getFormattingAtPosition,n as getHyperlinkAtPosition,c as getHyperlinkText,u as getParagraphAtIndex,a as getParagraphText,t as getParagraphs,b as getRunText,d as getTableText,k as getTextAfter,j as getTextBefore,r as hasHyperlinks,q as hasImages,s as hasTables,o as isHeadingStyle,m as isPositionInHyperlink,p as parseHeadingLevel,I as removeContentControl,H as setContentControlContent,M as setContentControlValue}from'./chunk-YBIM6UJV.mjs';export{g as DEFAULT_AI_ACTIONS,d as comparePositions,a as createCollapsedRange,h as createCommand,b as createRange,f as getActionDescription,e as getActionLabel,c as isPositionInRange}from'./chunk-Q7PO7V73.mjs';export{a as DocumentAgent,h as buildExtendedSelectionContext,g as buildSelectionContext,e as buildSelectionContextFromContext,b as createAgent,c as createAgentFromDocument,d as getAgentContext,f as getDocumentSummary,i as getSelectionFormattingSummary}from'./chunk-XQBCCJBO.mjs';export{a as detectVariables,b as detectVariablesDetailed,c as detectVariablesInBody,d as detectVariablesInParagraph,m as documentHasVariables,e as extractVariablesFromText,i as formatVariable,f as hasTemplateVariables,g as isValidVariableName,j as parseVariable,l as removeVariables,k as replaceVariables,h as sanitizeVariableName}from'./chunk-UIEJWORW.mjs';export{a as executeCommand,b as executeCommands}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';export{a as PluginRegistry,d as createPluginRegistrar,b as pluginRegistry,c as registerPlugins}from'./chunk-VBOTMRXV.mjs';export{a as attemptSelectiveSave}from'./chunk-OJOHXQNQ.mjs';export{s as createDocx,h as repackDocx,l as updateMultipleFiles}from'./chunk-KVKLLTDP.mjs';import'./chunk-BIQWVK5P.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,m as pointsToHalfPoints,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-3UBMCDME.mjs';export{a as parseDocx}from'./chunk-LDUWIM7M.mjs';import'./chunk-DXKG3HQ5.mjs';import'./chunk-FPZBTOD6.mjs';import'./chunk-H3JCIGWK.mjs';export{c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties}from'./chunk-N5Q3YN64.mjs';import'./chunk-SINEY6ZF.mjs';import'./chunk-T4EZMUXM.mjs';import'./chunk-TTRUPDAB.mjs';var Pt="0.0.2";export{Pt as VERSION};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { E as EditorTreeNode } from '../../editorTree-DO5PyDK8.mjs';
|
|
2
|
+
import { j as BorderStyle, e as LayoutBlock, ao as TableBlock } from '../../types-DNrYr6yQ.mjs';
|
|
3
|
+
import { a as Theme } from '../../formatting-DoL7KBSL.mjs';
|
|
4
|
+
import { aC as NumberFormat } from '../../content-sSHuWw49.mjs';
|
|
5
|
+
import '../../docx/wrapTypes.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Shared types and primitive helpers used across toLayoutBlocks sub-modules.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for the conversion.
|
|
13
|
+
*/
|
|
14
|
+
type ToLayoutBlocksOptions = {
|
|
15
|
+
/** Default font family. */
|
|
16
|
+
defaultFont?: string;
|
|
17
|
+
/** Default font size in points. */
|
|
18
|
+
defaultSize?: number;
|
|
19
|
+
/** Theme for resolving theme colors. */
|
|
20
|
+
theme?: Theme | null;
|
|
21
|
+
/** Page content height in pixels (pageHeight - marginTop - marginBottom). Images taller than this are scaled down to fit. */
|
|
22
|
+
pageContentHeight?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Document-wide `w:defaultTabStop` (§17.6.13) in twips. Stamped onto each
|
|
25
|
+
* paragraph's attrs so the layout-time list-marker helper can snap body
|
|
26
|
+
* text to the default tab grid when no custom `w:tabs` are defined.
|
|
27
|
+
* Default 720 twips (Word's spec default).
|
|
28
|
+
*/
|
|
29
|
+
defaultTabStopTwips?: number;
|
|
30
|
+
/**
|
|
31
|
+
* @internal Allocated by toLayoutBlocks() and threaded through table /
|
|
32
|
+
* text-box conversion so list numbering stays continuous across containers.
|
|
33
|
+
* Keyed by abstractNumId when known (ECMA-376 §17.9.18: numIds sharing one
|
|
34
|
+
* abstractNum share counter state); falls back to numId.
|
|
35
|
+
*/
|
|
36
|
+
listCounters?: Map<number, number[]>;
|
|
37
|
+
/**
|
|
38
|
+
* @internal Tracks `${numId}:${ilvl}` pairs whose startOverride has already
|
|
39
|
+
* been applied. Per ECMA-376 §17.9.27 the override fires the first time
|
|
40
|
+
* each level of a numId is encountered, so a numId with overrides on
|
|
41
|
+
* multiple ilvls fires each one independently.
|
|
42
|
+
*/
|
|
43
|
+
listSeenNumIds?: Set<string>;
|
|
44
|
+
};
|
|
45
|
+
declare function resetBlockIdCounter(): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Border Conversion
|
|
49
|
+
*
|
|
50
|
+
* Shared OOXML BorderSpec → layout/pagination BorderStyle conversion, used by
|
|
51
|
+
* paragraph borders, table cell borders, and header/footer borders.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Convert an OOXML BorderSpec to a layout/pagination BorderStyle.
|
|
56
|
+
* Shared by paragraph borders, cell borders, and header/footer borders.
|
|
57
|
+
*/
|
|
58
|
+
declare function convertBorderSpecToLayout(border: {
|
|
59
|
+
style?: string;
|
|
60
|
+
size?: number;
|
|
61
|
+
space?: number;
|
|
62
|
+
color?: {
|
|
63
|
+
rgb?: string;
|
|
64
|
+
themeColor?: string;
|
|
65
|
+
themeTint?: string;
|
|
66
|
+
themeShade?: string;
|
|
67
|
+
};
|
|
68
|
+
}, theme?: Theme | null): BorderStyle | undefined;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* List Marker Resolution
|
|
72
|
+
*
|
|
73
|
+
* Helpers for rendering OOXML list markers from the counter stack:
|
|
74
|
+
* - format numbers as decimal/roman/letter per ECMA-376 §17.9.16 numFmt
|
|
75
|
+
* - resolve lvlText templates ("%1.%2.") against the counter stack
|
|
76
|
+
* - drive the per-paragraph counter increment, including startOverride.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Resolve an OOXML lvlText template like "%1.%2." against the counter stack
|
|
81
|
+
* and per-level numFmt list (ECMA-376 §17.9.11).
|
|
82
|
+
*
|
|
83
|
+
* When a referenced counter has no value yet (e.g. "%2" referenced from a
|
|
84
|
+
* level-0 paragraph), the placeholder AND the punctuation immediately
|
|
85
|
+
* following it are dropped — matches Word's behavior so "%1.%2." renders
|
|
86
|
+
* "1." rather than "1..".
|
|
87
|
+
*
|
|
88
|
+
* Exported for unit testing.
|
|
89
|
+
*/
|
|
90
|
+
declare function resolveListTemplate(template: string, counters: number[], levelNumFmts: NumberFormat[] | undefined): string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* ProseMirror to LayoutBlock Converter
|
|
94
|
+
*
|
|
95
|
+
* Converts a ProseMirror document into LayoutBlock[] for the layout engine.
|
|
96
|
+
* Tracks pmStart/pmEnd positions for click-to-position mapping.
|
|
97
|
+
*
|
|
98
|
+
* The deep import `@openooxml/.../layout/flow` is part of the
|
|
99
|
+
* public surface (Vue adapter + tests), so the per-domain helpers under
|
|
100
|
+
* ./toLayoutBlocks/ are re-exported from here to keep that path stable.
|
|
101
|
+
* @packageDocumentation
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Convert a ProseMirror document to LayoutBlock array.
|
|
107
|
+
*
|
|
108
|
+
* Walks the document tree, converting each node to the appropriate block type.
|
|
109
|
+
* Tracks pmStart/pmEnd positions for each block for click-to-position mapping.
|
|
110
|
+
*/
|
|
111
|
+
declare function toLayoutBlocks(doc: EditorTreeNode, options?: ToLayoutBlocksOptions): LayoutBlock[];
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Floating-table compatibility helpers.
|
|
115
|
+
*
|
|
116
|
+
* A DOCX table with `w:tblpPr` is a positioned ("floating") table — text wraps
|
|
117
|
+
* around it. But contract templates routinely make a full-width form table
|
|
118
|
+
* floating (often a paste artifact), leaving NO horizontal room for text on
|
|
119
|
+
* either side. Word and Google Docs treat such a table as a normal in-flow
|
|
120
|
+
* block: it paginates across pages and following content flows beneath it.
|
|
121
|
+
*
|
|
122
|
+
* The paginator now preserves authored floating status: block-like floats
|
|
123
|
+
* advance flow beneath their exclusion, and unavoidable tall floats fragment
|
|
124
|
+
* at safe row/line boundaries.
|
|
125
|
+
*
|
|
126
|
+
* The predicate mirrors the geometry in `layoutFloatingTable` (the existing
|
|
127
|
+
* block-like cursor-advance) and `extractFloatingTableZone`; keep the three in
|
|
128
|
+
* sync. Narrow floating tables — where text genuinely wraps beside them — fall
|
|
129
|
+
* below the threshold and stay floating.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* True when a floating table is effectively full-width — it leaves less than
|
|
134
|
+
* {@link MIN_WRAP_SEGMENT_WIDTH} of usable text room on BOTH sides, so no text
|
|
135
|
+
* can wrap beside it. Returns false for non-floating tables and for narrow
|
|
136
|
+
* floats that leave real wrap room.
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
declare function isBlockLikeFloatingTable(block: TableBlock, contentWidth: number): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Legacy no-op kept so external callers compiled against the old helper do not
|
|
143
|
+
* break. Authored `floating` is never cleared.
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
declare function demoteBlockLikeFloatingTables(_blocks: LayoutBlock[], _blockWidths: number[], _fallbackWidth: number): void;
|
|
148
|
+
|
|
149
|
+
export { type ToLayoutBlocksOptions, convertBorderSpecToLayout, demoteBlockLikeFloatingTables, isBlockLikeFloatingTable, resetBlockIdCounter, resolveListTemplate, toLayoutBlocks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as convertBorderSpecToLayout,e as demoteBlockLikeFloatingTables,d as isBlockLikeFloatingTable,b as resolveListTemplate,c as toLayoutBlocks}from'../../chunk-IL5JZJT7.mjs';export{d as resetBlockIdCounter}from'../../chunk-GWKJ2Y4Y.mjs';import'../../chunk-52GB3Y42.mjs';import'../../chunk-X4XDO3LZ.mjs';import'../../chunk-L5ISVQ3W.mjs';import'../../chunk-XWUOLYRQ.mjs';import'../../chunk-HJGAQIU7.mjs';import'../../chunk-FZIA7OFY.mjs';import'../../chunk-OBQGPMPQ.mjs';import'../../chunk-3UBMCDME.mjs';import'../../chunk-FPZBTOD6.mjs';import'../../chunk-H3JCIGWK.mjs';import'../../chunk-SINEY6ZF.mjs';import'../../chunk-T4EZMUXM.mjs';import'../../chunk-TTRUPDAB.mjs';
|