oasis-editor 0.0.106 → 0.0.108
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/{OasisEditorApp-CwVZxG1m.js → OasisEditorApp-DkiTrFZ6.js} +1945 -489
- package/dist/app/controllers/tableResize/tableResizeGeometry.d.ts +3 -2
- package/dist/app/controllers/tableResize/tableResizeHitTest.d.ts +3 -2
- package/dist/app/controllers/useEditorLayout.d.ts +2 -0
- package/dist/app/controllers/useEditorNavigation.d.ts +4 -1
- package/dist/app/controllers/useEditorTableResize.d.ts +5 -1
- package/dist/export/pdf/OasisPdfWriter.d.ts +23 -2
- package/dist/export/pdf/draw/drawBlockList.d.ts +1 -1
- package/dist/export/pdf/writer/PdfDocumentSerializer.d.ts +2 -2
- package/dist/export/pdf/writer/pdfTypes.d.ts +55 -3
- package/dist/{index-DdcPkCmB.js → index-DzBLUs91.js} +13707 -14175
- package/dist/layoutProjection/index.d.ts +1 -0
- package/dist/layoutProjection/layoutMetricsEpoch.d.ts +2 -0
- package/dist/oasis-editor.js +55 -55
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ui/OasisEditorEditor.d.ts +3 -2
- package/dist/ui/app/EditorDragLayers.d.ts +5 -1
- package/dist/ui/app/EditorWorkspace.d.ts +2 -1
- package/dist/ui/app/buildEditorViewProps.d.ts +2 -0
- package/dist/ui/app/createEditorDocumentRuntime.d.ts +2 -0
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +2 -0
- package/dist/ui/app/useCanvasSurfaceHitResolver.d.ts +4 -3
- package/dist/ui/app/useEditorInteractionWiring.d.ts +2 -0
- package/dist/ui/canvas/canvasLayoutSnapshotProvider.d.ts +14 -0
- package/dist/ui/canvas/canvasSnapshotTypes.d.ts +2 -3
- package/dist/ui/canvas/canvasTextMeasurer.d.ts +3 -0
- package/dist/ui/components/DropCaret.d.ts +5 -1
- package/dist/ui/components/Outline/OutlinePanel.d.ts +5 -1
- package/dist/ui/editorUiTypes.d.ts +2 -1
- package/dist/ui/shells/DocumentShell.d.ts +3 -2
- package/package.json +2 -1
|
@@ -1,7 +1,458 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import {
|
|
4
|
+
import { d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageContentWidth, b as getPageBodyTop, c as getPageBodyBottom, l as listReferencedEndnotes, f as getFootnoteDisplayMarker, s as setActiveHyphenation, h as getDocumentSections, i as buildFootnoteReservations, M as MAX_FOOTNOTE_LAYOUT_ITERATIONS, r as reservationSignature, j as applyFootnotesToPages, k as getRunField, m as projectBlocksLayout, v as visitRun, n as assertNever, o as createSignal, q as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getParagraphText, C as getActiveZone, D as getActiveSectionIndex, E as getParagraphs, F as normalizeSelection, G as positionToParagraphOffset, H as paragraphOffsetToPosition, I as clampPosition, J as findParagraphIndex, K as createCollapsedSelection, L as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as getBlockParagraphs, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as underlineStyleToCssDecorationStyle, Z as resolveImageSrc, _ as listKindForTag, $ as isParagraphTag, a0 as collectInlineRuns, a1 as parseParagraphStyle, a2 as getRunImage, a3 as InlineShell, a4 as BalloonShell, a5 as DocumentShell, a6 as createMemo, a7 as getCaretRectFromSnapshot, a8 as getParagraphRectFromSnapshot, a9 as createComponent, aa as CaretOverlay, ab as Show, ac as createRenderEffect, ad as style, ae as setAttribute, af as setStyleProperty, ag as memo, ah as template, ai as useI18n, aj as createEffect, ak as insert, al as use, am as addEventListener, an as Dialog, ao as delegateEvents, ap as className, aq as For, ar as UNDERLINE_STYLE_OPTIONS, as as Tabs, at as onMount, au as onCleanup, av as PluginUiHost, aw as OasisEditorEditor, ax as OasisBrandMark, ay as setPreciseFontPreference, az as setWelcomeSeen, aA as enablePreciseFontMode, aB as TWIPS_PER_POINT, aC as PX_PER_INCH, aD as TWIPS_PER_INCH, aE as resolveEffectiveParagraphStyle, aF as resolveEffectiveTextStyleForParagraph, aG as EMU_PER_PX, aH as EMU_PER_PT, aI as getRunFootnoteReference, aJ as getRunEndnoteReference, aK as iterateFootnoteReferenceRuns, aL as iterateEndnoteReferenceRuns, aM as imageContentTypeDefaults, aN as getRunFieldChar, aO as getRunFieldInstruction, aP as createEditorRun, aQ as JSZip, aR as imageExtensionFromMime, aS as pxToPt$1, aT as resolveFloatingObjectRect, aU as getTextBoxFloatingGeometry, aV as getPresetPathSegments, aW as buildListLabels, aX as getImageFloatingGeometry, aY as textStyleToFontSizePt, aZ as PX_PER_POINT, a_ as DEFAULT_FONT_SIZE_PX, a$ as resolveOpenTypeFeatureTags, b0 as isDoubleUnderlineStyle, b1 as isWavyUnderlineStyle, b2 as underlineStyleLineWidthPx, b3 as underlineStyleDashArray, b4 as resolveListLabel, b5 as getListLabelInset, b6 as getAlignedListLabelInset, b7 as getParagraphBorderInsets, b8 as buildSegmentTable, b9 as buildCanvasTableLayout, ba as resolveCanvasTableWidth, bb as resolveFloatingTableRect, bc as normalizeFamily, bd as ROBOTO_FONT_FILES, be as loadFontAsset, bf as OFFICE_COMPAT_FONT_FAMILIES, bg as BinaryReader, bh as buildSfnt, bi as defaultFontDecoderRegistry, bj as SfntFontProgram, bk as collectPdfFontFamilies, bl as outlineFrom, bm as getPageHeaderZoneTop, bn as getPageColumnRects, bo as findFootnoteReference, bp as FOOTNOTE_MARKER_GUTTER_PX, bq as resolveImporterForFile, br as getDocumentSectionsCanonical, bs as getDocumentParagraphsCanonical, bt as getDocumentParagraphs, bu as getDocumentPageSettings, bv as getTableCellContentWidthForParagraph, bw as layoutMetricsEpoch, bx as bumpLayoutMetricsEpoch, by as createCanvasLayoutSnapshotProvider, bz as on, bA as debounce, bB as unwrap, bC as perfTimer, bD as getRunTextBox, bE as createEditorDocument, bF as resolveResizedDimensions, bG as resolveTextBoxRenderHeight, bH as getToolbarStyleState, bI as getCachedCanvasImage, bJ as measureParagraphMinContentWidthPx, bK as getEditableBlocksForZone, bL as findParagraphLocation, bM as createSectionBoundaryParagraph, bN as normalizePageSettings, bO as DEFAULT_EDITOR_PAGE_SETTINGS, bP as markStart, bQ as markEnd, bR as getParagraphEntries, bS as getParagraphById, bT as createEditorFootnote, bU as createFootnoteReferenceRun, bV as renumberFootnotes, bW as getHeadingLevel, bX as preciseFontModeVersion, bY as isPreciseFontModeEnabled, bZ as resolveNamedTextStyle, b_ as togglePreciseFontMode, b$ as nextFontSizePt, c0 as previousFontSizePt, c1 as fontSizePtToPx, c2 as createDefaultToolbarPreset, c3 as MenuRegistry, c4 as createToolbarRegistry, c5 as Editor, c6 as resolveCommandRef, c7 as commandRefName, c8 as createOasisEditorClient, c9 as createEditorZoom, ca as startLongTaskObserver, cb as installGlobalReport, cc as applyStoredPreciseFontPreference, cd as getWelcomeSeen, ce as isLocalFontAccessSupported, cf as EDITOR_SCROLL_PADDING_PX, cg as Toolbar, ch as OasisEditorLoading, ci as I18nProvider, cj as createTranslator, ck as createEditorLogger, cl as registerDomStatsSurface } from "./index-DzBLUs91.js";
|
|
5
|
+
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
6
|
+
const {
|
|
7
|
+
pageIndex,
|
|
8
|
+
totalPages,
|
|
9
|
+
measuredHeights,
|
|
10
|
+
styles,
|
|
11
|
+
contentWidth,
|
|
12
|
+
measurer,
|
|
13
|
+
defaultTabStop
|
|
14
|
+
} = context;
|
|
15
|
+
return blocks.map((block, index) => {
|
|
16
|
+
var _a2, _b2;
|
|
17
|
+
if (block.type === "paragraph") {
|
|
18
|
+
const layout = deps.projectParagraphLayout(
|
|
19
|
+
block,
|
|
20
|
+
pageIndex,
|
|
21
|
+
totalPages,
|
|
22
|
+
styles,
|
|
23
|
+
contentWidth,
|
|
24
|
+
measurer,
|
|
25
|
+
defaultTabStop
|
|
26
|
+
);
|
|
27
|
+
return {
|
|
28
|
+
blockId: block.id,
|
|
29
|
+
sourceBlockId: block.id,
|
|
30
|
+
blockType: block.type,
|
|
31
|
+
paragraphId: block.id,
|
|
32
|
+
globalIndex: index,
|
|
33
|
+
estimatedHeight: (measuredHeights == null ? void 0 : measuredHeights[block.id]) ?? deps.getProjectedParagraphBlockHeight(block, layout, styles),
|
|
34
|
+
layout,
|
|
35
|
+
sourceBlock: block
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const tableHeight = (measuredHeights == null ? void 0 : measuredHeights[block.id]) ?? deps.estimateTableBlockHeight(
|
|
39
|
+
block,
|
|
40
|
+
styles,
|
|
41
|
+
contentWidth,
|
|
42
|
+
measurer,
|
|
43
|
+
defaultTabStop
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
blockId: block.id,
|
|
47
|
+
sourceBlockId: block.id,
|
|
48
|
+
blockType: block.type,
|
|
49
|
+
globalIndex: index,
|
|
50
|
+
estimatedHeight: ((_a2 = block.style) == null ? void 0 : _a2.floating) ? 0 : tableHeight,
|
|
51
|
+
floatingTableHeight: ((_b2 = block.style) == null ? void 0 : _b2.floating) ? tableHeight : void 0,
|
|
52
|
+
sourceBlock: block
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function projectHeaderFooterBlocks(blocks, context = {}) {
|
|
57
|
+
return projectHeaderFooterBlocksWithDependencies(
|
|
58
|
+
blocks,
|
|
59
|
+
{
|
|
60
|
+
projectParagraphLayout,
|
|
61
|
+
estimateTableBlockHeight,
|
|
62
|
+
getProjectedParagraphBlockHeight
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
...context,
|
|
66
|
+
measurer: context.measurer ?? domTextMeasurer
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function getProjectedBlocksHeight(blocks) {
|
|
71
|
+
if (!blocks || blocks.length === 0) {
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
return blocks.reduce((sum, block) => sum + block.estimatedHeight, 0);
|
|
75
|
+
}
|
|
76
|
+
function selectSectionHeaderBlocks(section, pageIndexInSection, globalPageIndex) {
|
|
77
|
+
const isFirstPageOfSection = pageIndexInSection === 0;
|
|
78
|
+
const isEvenPageNumber = (globalPageIndex + 1) % 2 === 0;
|
|
79
|
+
if (isFirstPageOfSection && section.firstPageHeader) {
|
|
80
|
+
return section.firstPageHeader;
|
|
81
|
+
}
|
|
82
|
+
if (isEvenPageNumber && section.evenPageHeader) {
|
|
83
|
+
return section.evenPageHeader;
|
|
84
|
+
}
|
|
85
|
+
return section.header;
|
|
86
|
+
}
|
|
87
|
+
function selectSectionFooterBlocks(section, pageIndexInSection, globalPageIndex) {
|
|
88
|
+
const isFirstPageOfSection = pageIndexInSection === 0;
|
|
89
|
+
const isEvenPageNumber = (globalPageIndex + 1) % 2 === 0;
|
|
90
|
+
if (isFirstPageOfSection && section.firstPageFooter) {
|
|
91
|
+
return section.firstPageFooter;
|
|
92
|
+
}
|
|
93
|
+
if (isEvenPageNumber && section.evenPageFooter) {
|
|
94
|
+
return section.evenPageFooter;
|
|
95
|
+
}
|
|
96
|
+
return section.footer;
|
|
97
|
+
}
|
|
98
|
+
function resolveEffectiveVerticalMetrics(pageSettings, headerBlocks, footerBlocks) {
|
|
99
|
+
const staticBodyTop = getPageBodyTop(pageSettings);
|
|
100
|
+
const staticBodyBottom = getPageBodyBottom(pageSettings);
|
|
101
|
+
const headerHeight = getProjectedBlocksHeight(headerBlocks);
|
|
102
|
+
const footerHeight = getProjectedBlocksHeight(footerBlocks);
|
|
103
|
+
const headerTop = pageSettings.margins.header;
|
|
104
|
+
const footerTop = pageSettings.height - pageSettings.margins.footer - footerHeight;
|
|
105
|
+
const headerOccupiedBottom = headerHeight > 0 ? Math.min(pageSettings.height, headerTop + headerHeight) : 0;
|
|
106
|
+
const footerOccupiedTop = footerHeight > 0 ? Math.max(0, footerTop) : pageSettings.height;
|
|
107
|
+
const bodyTop = Math.max(staticBodyTop, headerOccupiedBottom);
|
|
108
|
+
const bodyBottom = Math.max(
|
|
109
|
+
bodyTop,
|
|
110
|
+
Math.min(staticBodyBottom, footerOccupiedTop)
|
|
111
|
+
);
|
|
112
|
+
return {
|
|
113
|
+
bodyTop,
|
|
114
|
+
bodyBottom,
|
|
115
|
+
headerTop,
|
|
116
|
+
footerTop,
|
|
117
|
+
contentHeight: Math.max(24, Math.floor(bodyBottom - bodyTop))
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function createHeaderFooterVariantProjector(context) {
|
|
121
|
+
return (blocks, contentWidth, pageIndex, totalPageCount) => blocks ? context.projectHeaderFooterBlocks(blocks, {
|
|
122
|
+
pageIndex,
|
|
123
|
+
totalPages: totalPageCount,
|
|
124
|
+
measuredHeights: context.measuredHeights,
|
|
125
|
+
measuredParagraphLayouts: context.measuredParagraphLayouts,
|
|
126
|
+
styles: context.documentStyles,
|
|
127
|
+
contentWidth,
|
|
128
|
+
measurer: context.measurer,
|
|
129
|
+
defaultTabStop: context.defaultTabStop
|
|
130
|
+
}) : void 0;
|
|
131
|
+
}
|
|
132
|
+
function projectTallestHeaderVariant(section, contentWidth, projectHeaderFooterVariant) {
|
|
133
|
+
const variants = [
|
|
134
|
+
section.header,
|
|
135
|
+
section.firstPageHeader,
|
|
136
|
+
section.evenPageHeader
|
|
137
|
+
].map((blocks) => projectHeaderFooterVariant(blocks, contentWidth)).filter((blocks) => !!blocks);
|
|
138
|
+
return variants.sort(
|
|
139
|
+
(a, b) => getProjectedBlocksHeight(b) - getProjectedBlocksHeight(a)
|
|
140
|
+
)[0];
|
|
141
|
+
}
|
|
142
|
+
function projectTallestFooterVariant(section, contentWidth, projectHeaderFooterVariant) {
|
|
143
|
+
const variants = [
|
|
144
|
+
section.footer,
|
|
145
|
+
section.firstPageFooter,
|
|
146
|
+
section.evenPageFooter
|
|
147
|
+
].map((blocks) => projectHeaderFooterVariant(blocks, contentWidth)).filter((blocks) => !!blocks);
|
|
148
|
+
return variants.sort(
|
|
149
|
+
(a, b) => getProjectedBlocksHeight(b) - getProjectedBlocksHeight(a)
|
|
150
|
+
)[0];
|
|
151
|
+
}
|
|
152
|
+
function calculateTotalPages(context, projectHeaderFooterVariant) {
|
|
153
|
+
let currentTotal = 0;
|
|
154
|
+
const activePages = [];
|
|
155
|
+
for (const section of context.sections) {
|
|
156
|
+
const contentWidth = getPageContentWidth(section.pageSettings);
|
|
157
|
+
const headerBlocks = projectTallestHeaderVariant(
|
|
158
|
+
section,
|
|
159
|
+
contentWidth,
|
|
160
|
+
projectHeaderFooterVariant
|
|
161
|
+
);
|
|
162
|
+
const footerBlocks = projectTallestFooterVariant(
|
|
163
|
+
section,
|
|
164
|
+
contentWidth,
|
|
165
|
+
projectHeaderFooterVariant
|
|
166
|
+
);
|
|
167
|
+
const metrics = resolveEffectiveVerticalMetrics(
|
|
168
|
+
section.pageSettings,
|
|
169
|
+
headerBlocks,
|
|
170
|
+
footerBlocks
|
|
171
|
+
);
|
|
172
|
+
const pageHeight = context.maxPageHeightOverride ?? metrics.contentHeight;
|
|
173
|
+
const isContinuous = section.breakType === "continuous" && activePages.length > 0;
|
|
174
|
+
const sectionPages = context.projectBlocks({
|
|
175
|
+
blocks: section.blocks,
|
|
176
|
+
pageSettings: section.pageSettings,
|
|
177
|
+
maxPageHeight: pageHeight,
|
|
178
|
+
measuredHeights: context.measuredHeights,
|
|
179
|
+
measuredParagraphLayouts: context.measuredParagraphLayouts,
|
|
180
|
+
pageOffset: isContinuous ? currentTotal - 1 : currentTotal,
|
|
181
|
+
existingPages: isContinuous ? [activePages[activePages.length - 1]] : [],
|
|
182
|
+
measurer: context.measurer,
|
|
183
|
+
defaultTabStop: context.defaultTabStop
|
|
184
|
+
});
|
|
185
|
+
if (isContinuous) {
|
|
186
|
+
activePages.pop();
|
|
187
|
+
activePages.push(...sectionPages);
|
|
188
|
+
currentTotal = activePages.length;
|
|
189
|
+
} else {
|
|
190
|
+
activePages.push(...sectionPages);
|
|
191
|
+
currentTotal = activePages.length;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return currentTotal;
|
|
195
|
+
}
|
|
196
|
+
function projectAllPages(context, totalPages, projectHeaderFooterVariant, reservedHeightByPageIndex) {
|
|
197
|
+
const allPages = [];
|
|
198
|
+
for (const section of context.sections) {
|
|
199
|
+
const contentWidth = getPageContentWidth(section.pageSettings);
|
|
200
|
+
const sectionHeaderBlocks = projectTallestHeaderVariant(
|
|
201
|
+
section,
|
|
202
|
+
contentWidth,
|
|
203
|
+
projectHeaderFooterVariant
|
|
204
|
+
);
|
|
205
|
+
const sectionFooterBlocks = projectTallestFooterVariant(
|
|
206
|
+
section,
|
|
207
|
+
contentWidth,
|
|
208
|
+
projectHeaderFooterVariant
|
|
209
|
+
);
|
|
210
|
+
const sectionMetrics = resolveEffectiveVerticalMetrics(
|
|
211
|
+
section.pageSettings,
|
|
212
|
+
sectionHeaderBlocks,
|
|
213
|
+
sectionFooterBlocks
|
|
214
|
+
);
|
|
215
|
+
const pageHeight = context.maxPageHeightOverride ?? sectionMetrics.contentHeight;
|
|
216
|
+
const isContinuous = section.breakType === "continuous" && allPages.length > 0;
|
|
217
|
+
const sectionPageOffset = isContinuous ? allPages.length - 1 : allPages.length;
|
|
218
|
+
const sectionPages = context.projectBlocks({
|
|
219
|
+
blocks: section.blocks,
|
|
220
|
+
pageSettings: section.pageSettings,
|
|
221
|
+
maxPageHeight: pageHeight,
|
|
222
|
+
measuredHeights: context.measuredHeights,
|
|
223
|
+
measuredParagraphLayouts: context.measuredParagraphLayouts,
|
|
224
|
+
styles: context.documentStyles,
|
|
225
|
+
pageOffset: sectionPageOffset,
|
|
226
|
+
totalPages,
|
|
227
|
+
existingPages: isContinuous ? [allPages[allPages.length - 1]] : [],
|
|
228
|
+
measurer: context.measurer,
|
|
229
|
+
reservedHeightByPageIndex,
|
|
230
|
+
defaultTabStop: context.defaultTabStop
|
|
231
|
+
});
|
|
232
|
+
if (isContinuous) {
|
|
233
|
+
allPages.pop();
|
|
234
|
+
}
|
|
235
|
+
for (const page of sectionPages) {
|
|
236
|
+
const pageIndexInSection = page.index - sectionPageOffset;
|
|
237
|
+
const pageContentWidth = getPageContentWidth(page.pageSettings);
|
|
238
|
+
const headerBlocks = projectHeaderFooterVariant(
|
|
239
|
+
selectSectionHeaderBlocks(
|
|
240
|
+
section,
|
|
241
|
+
Math.max(0, pageIndexInSection),
|
|
242
|
+
page.index
|
|
243
|
+
),
|
|
244
|
+
pageContentWidth,
|
|
245
|
+
page.index,
|
|
246
|
+
totalPages
|
|
247
|
+
) ?? page.headerBlocks;
|
|
248
|
+
const footerBlocks = projectHeaderFooterVariant(
|
|
249
|
+
selectSectionFooterBlocks(
|
|
250
|
+
section,
|
|
251
|
+
Math.max(0, pageIndexInSection),
|
|
252
|
+
page.index
|
|
253
|
+
),
|
|
254
|
+
pageContentWidth,
|
|
255
|
+
page.index,
|
|
256
|
+
totalPages
|
|
257
|
+
) ?? page.footerBlocks;
|
|
258
|
+
const pageMetrics = resolveEffectiveVerticalMetrics(
|
|
259
|
+
page.pageSettings,
|
|
260
|
+
headerBlocks,
|
|
261
|
+
footerBlocks
|
|
262
|
+
);
|
|
263
|
+
const reservedHeight = (reservedHeightByPageIndex == null ? void 0 : reservedHeightByPageIndex.get(page.index)) ?? 0;
|
|
264
|
+
page.headerBlocks = headerBlocks;
|
|
265
|
+
page.footerBlocks = footerBlocks;
|
|
266
|
+
page.bodyTop = pageMetrics.bodyTop;
|
|
267
|
+
page.bodyBottom = Math.max(
|
|
268
|
+
pageMetrics.bodyTop,
|
|
269
|
+
pageMetrics.bodyBottom - reservedHeight
|
|
270
|
+
);
|
|
271
|
+
page.headerTop = pageMetrics.headerTop;
|
|
272
|
+
page.footerTop = pageMetrics.footerTop;
|
|
273
|
+
page.maxHeight = Math.max(
|
|
274
|
+
24,
|
|
275
|
+
(context.maxPageHeightOverride ?? pageMetrics.contentHeight) - reservedHeight
|
|
276
|
+
);
|
|
277
|
+
allPages.push(page);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return allPages;
|
|
281
|
+
}
|
|
282
|
+
function projectDocumentSections(context, reservedHeightByPageIndex) {
|
|
283
|
+
const projectHeaderFooterVariant = createHeaderFooterVariantProjector(context);
|
|
284
|
+
const totalPages = context.needsTotalPages ? calculateTotalPages(context, projectHeaderFooterVariant) : void 0;
|
|
285
|
+
return {
|
|
286
|
+
totalPages,
|
|
287
|
+
pages: projectAllPages(
|
|
288
|
+
context,
|
|
289
|
+
totalPages,
|
|
290
|
+
projectHeaderFooterVariant,
|
|
291
|
+
reservedHeightByPageIndex
|
|
292
|
+
)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const FLOW_ID_PREFIX = "endnote-flow";
|
|
296
|
+
function makeMarkerRun(endnoteId, marker) {
|
|
297
|
+
return {
|
|
298
|
+
id: `${FLOW_ID_PREFIX}:marker:${endnoteId}`,
|
|
299
|
+
text: `${marker}. `,
|
|
300
|
+
styles: { superscript: true },
|
|
301
|
+
kind: "text"
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function prependMarker(paragraph, endnoteId, marker) {
|
|
305
|
+
return {
|
|
306
|
+
...paragraph,
|
|
307
|
+
id: `${FLOW_ID_PREFIX}:p:${endnoteId}:${paragraph.id}`,
|
|
308
|
+
runs: [makeMarkerRun(endnoteId, marker), ...paragraph.runs]
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function emptyMarkerParagraph(endnoteId, marker) {
|
|
312
|
+
return {
|
|
313
|
+
id: `${FLOW_ID_PREFIX}:p:${endnoteId}:empty`,
|
|
314
|
+
type: "paragraph",
|
|
315
|
+
runs: [
|
|
316
|
+
makeMarkerRun(endnoteId, marker),
|
|
317
|
+
{ id: `${FLOW_ID_PREFIX}:text:${endnoteId}`, text: "", kind: "text" }
|
|
318
|
+
]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function spacerParagraph() {
|
|
322
|
+
return {
|
|
323
|
+
id: `${FLOW_ID_PREFIX}:spacer`,
|
|
324
|
+
type: "paragraph",
|
|
325
|
+
runs: [{ id: `${FLOW_ID_PREFIX}:spacer:text`, text: "", kind: "text" }]
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function buildEndnoteFlowBlocks(document2) {
|
|
329
|
+
var _a2, _b2, _c;
|
|
330
|
+
const referenced = listReferencedEndnotes(document2);
|
|
331
|
+
const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
|
|
332
|
+
if (!items || referenced.length === 0) {
|
|
333
|
+
return [];
|
|
334
|
+
}
|
|
335
|
+
const format = ((_c = (_b2 = document2.endnotes) == null ? void 0 : _b2.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
|
|
336
|
+
const out = [spacerParagraph()];
|
|
337
|
+
for (const ref of referenced) {
|
|
338
|
+
const endnote = items[ref.endnoteId];
|
|
339
|
+
if (!endnote) continue;
|
|
340
|
+
const marker = ref.customMark ?? getFootnoteDisplayMarker(ref.index, format);
|
|
341
|
+
const blocks = endnote.blocks;
|
|
342
|
+
if (blocks.length === 0) {
|
|
343
|
+
out.push(emptyMarkerParagraph(ref.endnoteId, marker));
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
blocks.forEach((block, index) => {
|
|
347
|
+
if (index === 0 && block.type === "paragraph") {
|
|
348
|
+
out.push(prependMarker(block, ref.endnoteId, marker));
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (index === 0) {
|
|
352
|
+
out.push(emptyMarkerParagraph(ref.endnoteId, marker));
|
|
353
|
+
}
|
|
354
|
+
out.push(block);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return out;
|
|
358
|
+
}
|
|
359
|
+
function injectEndnotesIntoDocument(document2) {
|
|
360
|
+
const flowBlocks = buildEndnoteFlowBlocks(document2);
|
|
361
|
+
if (flowBlocks.length === 0) {
|
|
362
|
+
return document2;
|
|
363
|
+
}
|
|
364
|
+
const sections = document2.sections;
|
|
365
|
+
if (!sections || sections.length === 0) {
|
|
366
|
+
return document2;
|
|
367
|
+
}
|
|
368
|
+
const lastIndex = sections.length - 1;
|
|
369
|
+
const nextSections = sections.map(
|
|
370
|
+
(section, index) => index === lastIndex ? { ...section, blocks: [...section.blocks, ...flowBlocks] } : section
|
|
371
|
+
);
|
|
372
|
+
return { ...document2, sections: nextSections };
|
|
373
|
+
}
|
|
374
|
+
function blockContainsNumPagesField(block) {
|
|
375
|
+
if (block.type === "paragraph") {
|
|
376
|
+
return block.runs.some((run) => {
|
|
377
|
+
var _a2;
|
|
378
|
+
return ((_a2 = getRunField(run)) == null ? void 0 : _a2.type) === "NUMPAGES";
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return block.rows.some(
|
|
382
|
+
(row) => row.cells.some((cell) => cell.blocks.some(blockContainsNumPagesField))
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
function documentContainsNumPagesField(document2) {
|
|
386
|
+
return getDocumentSections(document2).some(
|
|
387
|
+
(section) => [
|
|
388
|
+
...section.header ?? [],
|
|
389
|
+
...section.firstPageHeader ?? [],
|
|
390
|
+
...section.evenPageHeader ?? [],
|
|
391
|
+
...section.blocks,
|
|
392
|
+
...section.footer ?? [],
|
|
393
|
+
...section.firstPageFooter ?? [],
|
|
394
|
+
...section.evenPageFooter ?? []
|
|
395
|
+
].some(blockContainsNumPagesField)
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights, measuredParagraphLayouts, options = {}) {
|
|
399
|
+
var _a2, _b2;
|
|
400
|
+
const measurer = options.measurer ?? domTextMeasurer;
|
|
401
|
+
setActiveHyphenation(
|
|
402
|
+
((_a2 = document2.settings) == null ? void 0 : _a2.autoHyphenation) ? {
|
|
403
|
+
enabled: true,
|
|
404
|
+
zone: document2.settings.hyphenationZone,
|
|
405
|
+
consecutiveLimit: document2.settings.consecutiveHyphenLimit,
|
|
406
|
+
doNotHyphenateCaps: document2.settings.doNotHyphenateCaps
|
|
407
|
+
} : void 0
|
|
408
|
+
);
|
|
409
|
+
const layoutDocument = injectEndnotesIntoDocument(document2);
|
|
410
|
+
const sections = getDocumentSections(layoutDocument);
|
|
411
|
+
const needsTotalPages = documentContainsNumPagesField(layoutDocument);
|
|
412
|
+
const sectionContext = {
|
|
413
|
+
sections,
|
|
414
|
+
documentStyles: document2.styles,
|
|
415
|
+
maxPageHeightOverride,
|
|
416
|
+
measuredHeights,
|
|
417
|
+
measuredParagraphLayouts,
|
|
418
|
+
measurer,
|
|
419
|
+
defaultTabStop: (_b2 = document2.settings) == null ? void 0 : _b2.defaultTabStop,
|
|
420
|
+
needsTotalPages,
|
|
421
|
+
projectBlocks: projectBlocksLayout,
|
|
422
|
+
projectHeaderFooterBlocks
|
|
423
|
+
};
|
|
424
|
+
const projectedSections = projectDocumentSections(sectionContext);
|
|
425
|
+
let pages = projectedSections.pages;
|
|
426
|
+
const totalPages = projectedSections.totalPages;
|
|
427
|
+
if (!document2.footnotes || Object.keys(document2.footnotes.items).length === 0) {
|
|
428
|
+
setActiveHyphenation(void 0);
|
|
429
|
+
return { pages };
|
|
430
|
+
}
|
|
431
|
+
const footnoteContext = {
|
|
432
|
+
document: document2,
|
|
433
|
+
totalPages,
|
|
434
|
+
measuredHeights,
|
|
435
|
+
measuredParagraphLayouts,
|
|
436
|
+
measurer,
|
|
437
|
+
projectBlocks: projectHeaderFooterBlocks
|
|
438
|
+
};
|
|
439
|
+
let reservations = buildFootnoteReservations(pages, footnoteContext);
|
|
440
|
+
let previousSignature = "";
|
|
441
|
+
for (let iteration = 0; iteration < MAX_FOOTNOTE_LAYOUT_ITERATIONS; iteration += 1) {
|
|
442
|
+
const signature = reservationSignature(reservations);
|
|
443
|
+
if (signature === previousSignature) {
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
previousSignature = signature;
|
|
447
|
+
pages = projectDocumentSections(sectionContext, reservations).pages;
|
|
448
|
+
reservations = buildFootnoteReservations(pages, footnoteContext);
|
|
449
|
+
}
|
|
450
|
+
const result = {
|
|
451
|
+
pages: applyFootnotesToPages(pages, footnoteContext)
|
|
452
|
+
};
|
|
453
|
+
setActiveHyphenation(void 0);
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
5
456
|
function cloneStyle(style2) {
|
|
6
457
|
return style2 ? { ...style2 } : void 0;
|
|
7
458
|
}
|
|
@@ -245,12 +696,12 @@ function cloneBlock(block) {
|
|
|
245
696
|
}
|
|
246
697
|
}
|
|
247
698
|
function cloneSection(section) {
|
|
248
|
-
var
|
|
699
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
249
700
|
return {
|
|
250
701
|
...section,
|
|
251
702
|
blocks: section.blocks.map(cloneBlock),
|
|
252
|
-
header: (
|
|
253
|
-
firstPageHeader: (
|
|
703
|
+
header: (_a2 = section.header) == null ? void 0 : _a2.map(cloneBlock),
|
|
704
|
+
firstPageHeader: (_b2 = section.firstPageHeader) == null ? void 0 : _b2.map(cloneBlock),
|
|
254
705
|
evenPageHeader: (_c = section.evenPageHeader) == null ? void 0 : _c.map(cloneBlock),
|
|
255
706
|
footer: (_d = section.footer) == null ? void 0 : _d.map(cloneBlock),
|
|
256
707
|
firstPageFooter: (_e = section.firstPageFooter) == null ? void 0 : _e.map(cloneBlock),
|
|
@@ -264,7 +715,7 @@ function cloneFootnote(footnote) {
|
|
|
264
715
|
};
|
|
265
716
|
}
|
|
266
717
|
function cloneFootnotes(footnotes) {
|
|
267
|
-
var
|
|
718
|
+
var _a2, _b2;
|
|
268
719
|
if (!footnotes) return void 0;
|
|
269
720
|
const nextItems = {};
|
|
270
721
|
for (const [id, footnote] of Object.entries(footnotes.items)) {
|
|
@@ -273,8 +724,8 @@ function cloneFootnotes(footnotes) {
|
|
|
273
724
|
return {
|
|
274
725
|
items: nextItems,
|
|
275
726
|
settings: footnotes.settings ? { ...footnotes.settings } : void 0,
|
|
276
|
-
separator: (
|
|
277
|
-
continuationSeparator: (
|
|
727
|
+
separator: (_a2 = footnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
|
|
728
|
+
continuationSeparator: (_b2 = footnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
|
|
278
729
|
};
|
|
279
730
|
}
|
|
280
731
|
function cloneEndnote(endnote) {
|
|
@@ -284,7 +735,7 @@ function cloneEndnote(endnote) {
|
|
|
284
735
|
};
|
|
285
736
|
}
|
|
286
737
|
function cloneEndnotes(endnotes) {
|
|
287
|
-
var
|
|
738
|
+
var _a2, _b2;
|
|
288
739
|
if (!endnotes) return void 0;
|
|
289
740
|
const nextItems = {};
|
|
290
741
|
for (const [id, endnote] of Object.entries(endnotes.items)) {
|
|
@@ -293,17 +744,17 @@ function cloneEndnotes(endnotes) {
|
|
|
293
744
|
return {
|
|
294
745
|
items: nextItems,
|
|
295
746
|
settings: endnotes.settings ? { ...endnotes.settings } : void 0,
|
|
296
|
-
separator: (
|
|
297
|
-
continuationSeparator: (
|
|
747
|
+
separator: (_a2 = endnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
|
|
748
|
+
continuationSeparator: (_b2 = endnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
|
|
298
749
|
};
|
|
299
750
|
}
|
|
300
751
|
function cloneEditorState(source) {
|
|
301
|
-
var
|
|
752
|
+
var _a2;
|
|
302
753
|
return {
|
|
303
754
|
...source,
|
|
304
755
|
document: {
|
|
305
756
|
...source.document,
|
|
306
|
-
sections: (
|
|
757
|
+
sections: (_a2 = source.document.sections) == null ? void 0 : _a2.map(cloneSection),
|
|
307
758
|
footnotes: cloneFootnotes(source.document.footnotes),
|
|
308
759
|
endnotes: cloneEndnotes(source.document.endnotes)
|
|
309
760
|
},
|
|
@@ -425,7 +876,7 @@ const getClassNames = (attrs) => {
|
|
|
425
876
|
return "";
|
|
426
877
|
};
|
|
427
878
|
const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
|
|
428
|
-
var
|
|
879
|
+
var _a2;
|
|
429
880
|
const iconName = element.getAttribute(nameAttr);
|
|
430
881
|
if (iconName == null) return;
|
|
431
882
|
const ComponentName = toPascalCase(iconName);
|
|
@@ -458,7 +909,7 @@ const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
|
|
|
458
909
|
});
|
|
459
910
|
}
|
|
460
911
|
const svgElement = createElement(iconNode, iconAttrs);
|
|
461
|
-
return (
|
|
912
|
+
return (_a2 = element.parentNode) == null ? void 0 : _a2.replaceChild(svgElement, element);
|
|
462
913
|
};
|
|
463
914
|
/**
|
|
464
915
|
* @license lucide v1.11.0 - ISC
|
|
@@ -26384,9 +26835,9 @@ function cloneLayoutSnapshot(snapshot) {
|
|
|
26384
26835
|
};
|
|
26385
26836
|
}
|
|
26386
26837
|
function isCanvasDebugEnabled() {
|
|
26387
|
-
var
|
|
26838
|
+
var _a2;
|
|
26388
26839
|
const viteEnv = __vite_import_meta_env__ ?? {};
|
|
26389
|
-
const processEnv = ((
|
|
26840
|
+
const processEnv = ((_a2 = globalThis.process) == null ? void 0 : _a2.env) ?? {};
|
|
26390
26841
|
return viteEnv.DEV === true || viteEnv.MODE === "test" || processEnv.NODE_ENV === "test" || viteEnv.VITE_OASIS_CANVAS_DEBUG === "1";
|
|
26391
26842
|
}
|
|
26392
26843
|
function buildApi() {
|
|
@@ -26782,12 +27233,12 @@ function addFontFamily(target, seen, value) {
|
|
|
26782
27233
|
target.push(family);
|
|
26783
27234
|
}
|
|
26784
27235
|
function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilies = []) {
|
|
26785
|
-
var
|
|
27236
|
+
var _a2;
|
|
26786
27237
|
const seen = /* @__PURE__ */ new Set();
|
|
26787
27238
|
const documentFonts = [];
|
|
26788
27239
|
const fallbackFonts = [];
|
|
26789
27240
|
for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
|
|
26790
|
-
addFontFamily(documentFonts, seen, (
|
|
27241
|
+
addFontFamily(documentFonts, seen, (_a2 = style2.textStyle) == null ? void 0 : _a2.fontFamily);
|
|
26791
27242
|
}
|
|
26792
27243
|
addFontFamily(documentFonts, seen, toolbarStyleState.fontFamily);
|
|
26793
27244
|
for (const family of localFontFamilies) {
|
|
@@ -26802,10 +27253,10 @@ function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilie
|
|
|
26802
27253
|
];
|
|
26803
27254
|
}
|
|
26804
27255
|
function computeFontSizeOptions(document2, toolbarStyleState) {
|
|
26805
|
-
var
|
|
27256
|
+
var _a2;
|
|
26806
27257
|
const values = new Set(STANDARD_FONT_SIZES_PT);
|
|
26807
27258
|
for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
|
|
26808
|
-
const fontSize = (
|
|
27259
|
+
const fontSize = (_a2 = style2.textStyle) == null ? void 0 : _a2.fontSize;
|
|
26809
27260
|
if (typeof fontSize === "number" && Number.isFinite(fontSize)) {
|
|
26810
27261
|
values.add(fontSizePxToPt(fontSize));
|
|
26811
27262
|
}
|
|
@@ -26925,7 +27376,7 @@ function clearParagraphList(paragraph) {
|
|
|
26925
27376
|
return nextParagraph;
|
|
26926
27377
|
}
|
|
26927
27378
|
function getStyleAtOffset(paragraph, offset) {
|
|
26928
|
-
var
|
|
27379
|
+
var _a2;
|
|
26929
27380
|
if (paragraph.runs.length === 0) {
|
|
26930
27381
|
return void 0;
|
|
26931
27382
|
}
|
|
@@ -26945,7 +27396,7 @@ function getStyleAtOffset(paragraph, offset) {
|
|
|
26945
27396
|
}
|
|
26946
27397
|
consumed = nextConsumed;
|
|
26947
27398
|
}
|
|
26948
|
-
return cloneStyle((
|
|
27399
|
+
return cloneStyle((_a2 = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a2.styles);
|
|
26949
27400
|
}
|
|
26950
27401
|
function getRunAtOffset(paragraph, offset) {
|
|
26951
27402
|
let consumed = 0;
|
|
@@ -26975,9 +27426,9 @@ function getRunAtOffset(paragraph, offset) {
|
|
|
26975
27426
|
return null;
|
|
26976
27427
|
}
|
|
26977
27428
|
function expandLinkRangeInParagraph(paragraph, offset) {
|
|
26978
|
-
var
|
|
27429
|
+
var _a2, _b2, _c;
|
|
26979
27430
|
const resolved = getRunAtOffset(paragraph, offset);
|
|
26980
|
-
const href = (
|
|
27431
|
+
const href = (_a2 = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a2.link;
|
|
26981
27432
|
if (!resolved || !href || resolved.run.kind === "image") {
|
|
26982
27433
|
return null;
|
|
26983
27434
|
}
|
|
@@ -26996,7 +27447,7 @@ function expandLinkRangeInParagraph(paragraph, offset) {
|
|
|
26996
27447
|
endOffset = consumed + resolved.run.text.length;
|
|
26997
27448
|
for (let index = runIndex - 1; index >= 0; index -= 1) {
|
|
26998
27449
|
const run = runs[index];
|
|
26999
|
-
if (run.kind === "image" || ((
|
|
27450
|
+
if (run.kind === "image" || ((_b2 = run.styles) == null ? void 0 : _b2.link) !== href) {
|
|
27000
27451
|
break;
|
|
27001
27452
|
}
|
|
27002
27453
|
startOffset -= run.text.length;
|
|
@@ -27350,8 +27801,8 @@ function deleteSelectionRange(state) {
|
|
|
27350
27801
|
const startOffset2 = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
27351
27802
|
const endOffset2 = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
27352
27803
|
return mapRunsInRange(paragraph, startOffset2, endOffset2, (run) => {
|
|
27353
|
-
var
|
|
27354
|
-
if (((
|
|
27804
|
+
var _a2;
|
|
27805
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
27355
27806
|
return { ...run, text: "" };
|
|
27356
27807
|
}
|
|
27357
27808
|
return {
|
|
@@ -27671,7 +28122,7 @@ function insertPlainTextAtSelection(state, text, styleOverride) {
|
|
|
27671
28122
|
);
|
|
27672
28123
|
}
|
|
27673
28124
|
function deleteBackward(state) {
|
|
27674
|
-
var
|
|
28125
|
+
var _a2;
|
|
27675
28126
|
if (!isSelectionCollapsed(state.selection)) {
|
|
27676
28127
|
return deleteSelectionRange(state);
|
|
27677
28128
|
}
|
|
@@ -27694,7 +28145,7 @@ function deleteBackward(state) {
|
|
|
27694
28145
|
}
|
|
27695
28146
|
if (targetRunIndex !== -1) {
|
|
27696
28147
|
const targetRun = runs[targetRunIndex];
|
|
27697
|
-
if (((
|
|
28148
|
+
if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
27698
28149
|
const nextRuns2 = [
|
|
27699
28150
|
...sliceRuns(paragraph, 0, offset - 1),
|
|
27700
28151
|
...sliceRuns(paragraph, offset, getParagraphLength(paragraph))
|
|
@@ -27780,7 +28231,7 @@ function deleteBackward(state) {
|
|
|
27780
28231
|
);
|
|
27781
28232
|
}
|
|
27782
28233
|
function deleteForward(state) {
|
|
27783
|
-
var
|
|
28234
|
+
var _a2;
|
|
27784
28235
|
if (!isSelectionCollapsed(state.selection)) {
|
|
27785
28236
|
return deleteSelectionRange(state);
|
|
27786
28237
|
}
|
|
@@ -27803,7 +28254,7 @@ function deleteForward(state) {
|
|
|
27803
28254
|
}
|
|
27804
28255
|
if (targetRunIndex !== -1) {
|
|
27805
28256
|
const targetRun = runs[targetRunIndex];
|
|
27806
|
-
if (((
|
|
28257
|
+
if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
27807
28258
|
const nextRuns2 = [
|
|
27808
28259
|
...sliceRuns(paragraph, 0, offset),
|
|
27809
28260
|
...sliceRuns(paragraph, offset + 1, getParagraphLength(paragraph))
|
|
@@ -27903,8 +28354,8 @@ function toggleTextStyle(state, key) {
|
|
|
27903
28354
|
return state;
|
|
27904
28355
|
}
|
|
27905
28356
|
const shouldEnable = !touchedRuns.every((run) => {
|
|
27906
|
-
var
|
|
27907
|
-
return Boolean((
|
|
28357
|
+
var _a2;
|
|
28358
|
+
return Boolean((_a2 = run.styles) == null ? void 0 : _a2[key]);
|
|
27908
28359
|
});
|
|
27909
28360
|
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
27910
28361
|
if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
|
|
@@ -27936,8 +28387,8 @@ function clearSelectedTextFormatting(state) {
|
|
|
27936
28387
|
const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
27937
28388
|
const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
27938
28389
|
return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
|
|
27939
|
-
var
|
|
27940
|
-
const link = (
|
|
28390
|
+
var _a2;
|
|
28391
|
+
const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
27941
28392
|
const styles = link != null && link !== "" ? { link } : {};
|
|
27942
28393
|
return { ...run, styles };
|
|
27943
28394
|
});
|
|
@@ -28240,7 +28691,7 @@ function createFontDialogBridge(deps) {
|
|
|
28240
28691
|
};
|
|
28241
28692
|
}
|
|
28242
28693
|
function moveBlockToPosition(state, blockId, targetPosition) {
|
|
28243
|
-
var
|
|
28694
|
+
var _a2;
|
|
28244
28695
|
let movedBlock;
|
|
28245
28696
|
const removeFromBlocks = (blocks) => {
|
|
28246
28697
|
const idx = blocks.findIndex((b) => b.id === blockId);
|
|
@@ -28290,7 +28741,7 @@ function moveBlockToPosition(state, blockId, targetPosition) {
|
|
|
28290
28741
|
};
|
|
28291
28742
|
const activeIdx = getActiveSectionIndex(state);
|
|
28292
28743
|
const zone = getActiveZone(state);
|
|
28293
|
-
const activeSection = (
|
|
28744
|
+
const activeSection = (_a2 = nextDocument.sections) == null ? void 0 : _a2[activeIdx];
|
|
28294
28745
|
const section = { ...activeSection };
|
|
28295
28746
|
let found = false;
|
|
28296
28747
|
if (zone === "header") {
|
|
@@ -28463,7 +28914,7 @@ function insertSectionBreakAtSelection(state, breakType) {
|
|
|
28463
28914
|
};
|
|
28464
28915
|
}
|
|
28465
28916
|
function updateSectionSettings(state, sectionIndex, settings) {
|
|
28466
|
-
var
|
|
28917
|
+
var _a2;
|
|
28467
28918
|
const sections = getDocumentSections(state.document);
|
|
28468
28919
|
if (sectionIndex < 0 || sectionIndex >= sections.length) {
|
|
28469
28920
|
return state;
|
|
@@ -28477,7 +28928,7 @@ function updateSectionSettings(state, sectionIndex, settings) {
|
|
|
28477
28928
|
...settings.pageSettings ?? {},
|
|
28478
28929
|
margins: {
|
|
28479
28930
|
...nextSections[sectionIndex].pageSettings.margins,
|
|
28480
|
-
...((
|
|
28931
|
+
...((_a2 = settings.pageSettings) == null ? void 0 : _a2.margins) ?? {}
|
|
28481
28932
|
}
|
|
28482
28933
|
}
|
|
28483
28934
|
};
|
|
@@ -29029,7 +29480,7 @@ function parseWidthToPt(value) {
|
|
|
29029
29480
|
}
|
|
29030
29481
|
function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
|
|
29031
29482
|
const updateTable = (table) => {
|
|
29032
|
-
var
|
|
29483
|
+
var _a2;
|
|
29033
29484
|
if (table.id !== tableId) return table;
|
|
29034
29485
|
const tableLayout = buildTableCellLayout(table);
|
|
29035
29486
|
const visualColumnCount = Math.max(
|
|
@@ -29048,7 +29499,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29048
29499
|
hasGridOverride = true;
|
|
29049
29500
|
continue;
|
|
29050
29501
|
}
|
|
29051
|
-
const existing = (
|
|
29502
|
+
const existing = (_a2 = table.gridCols) == null ? void 0 : _a2[columnIndex];
|
|
29052
29503
|
if (typeof existing === "number" && Number.isFinite(existing) && existing > 0) {
|
|
29053
29504
|
nextGridCols[columnIndex] = existing;
|
|
29054
29505
|
continue;
|
|
@@ -29058,7 +29509,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29058
29509
|
}
|
|
29059
29510
|
const nextRows = table.rows.map((row, rowIndex) => {
|
|
29060
29511
|
const nextCells = row.cells.map((cell, cellIndex) => {
|
|
29061
|
-
var
|
|
29512
|
+
var _a3, _b2;
|
|
29062
29513
|
const entry = tableLayout.find(
|
|
29063
29514
|
(item) => item.rowIndex === rowIndex && item.cellIndex === cellIndex
|
|
29064
29515
|
);
|
|
@@ -29066,11 +29517,11 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29066
29517
|
const rightVisualColumnIndex = entry.visualColumnIndex + entry.colSpan - 1;
|
|
29067
29518
|
const newWidth = columnWidths[rightVisualColumnIndex];
|
|
29068
29519
|
if (newWidth !== void 0 && entry.colSpan === 1) {
|
|
29069
|
-
const propertyRevision = state.trackChangesEnabled && !((
|
|
29520
|
+
const propertyRevision = state.trackChangesEnabled && !((_a3 = cell.style) == null ? void 0 : _a3.propertyRevision) ? {
|
|
29070
29521
|
...createTableRevisionMetadata(),
|
|
29071
29522
|
type: "property",
|
|
29072
29523
|
previous: { ...cell.style ?? {} }
|
|
29073
|
-
} : (
|
|
29524
|
+
} : (_b2 = cell.style) == null ? void 0 : _b2.propertyRevision;
|
|
29074
29525
|
return {
|
|
29075
29526
|
...cell,
|
|
29076
29527
|
style: {
|
|
@@ -29294,17 +29745,17 @@ function isVisibleBorder(border) {
|
|
|
29294
29745
|
return !!border && border.type !== "none" && border.width > 0;
|
|
29295
29746
|
}
|
|
29296
29747
|
function buildFloatingSummary(table) {
|
|
29297
|
-
var
|
|
29298
|
-
const floating = (
|
|
29748
|
+
var _a2;
|
|
29749
|
+
const floating = (_a2 = table.style) == null ? void 0 : _a2.floating;
|
|
29299
29750
|
if (!floating || Object.keys(floating).length === 0) return "";
|
|
29300
29751
|
return Object.entries(floating).map(([key, value]) => `${key}=${value}`).join(", ");
|
|
29301
29752
|
}
|
|
29302
29753
|
function buildInitialValues(ctx, activeTab = "table") {
|
|
29303
|
-
var
|
|
29304
|
-
const tableWidth = serializeWidth((
|
|
29754
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
29755
|
+
const tableWidth = serializeWidth((_a2 = ctx.table.style) == null ? void 0 : _a2.width);
|
|
29305
29756
|
const row = ctx.table.rows[ctx.rowIndex];
|
|
29306
29757
|
const cell = row == null ? void 0 : row.cells[ctx.cellIndex];
|
|
29307
|
-
const rowHeight = serializeWidth((
|
|
29758
|
+
const rowHeight = serializeWidth((_b2 = row == null ? void 0 : row.style) == null ? void 0 : _b2.height);
|
|
29308
29759
|
const cellWidth = serializeWidth((_c = cell == null ? void 0 : cell.style) == null ? void 0 : _c.width);
|
|
29309
29760
|
const gridWidth = (_d = ctx.table.gridCols) == null ? void 0 : _d[ctx.visualColumnIndex];
|
|
29310
29761
|
const columnWidth = serializeWidth(gridWidth);
|
|
@@ -29732,14 +30183,14 @@ function textLanguageToHtmlAttributes(language) {
|
|
|
29732
30183
|
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
29733
30184
|
}
|
|
29734
30185
|
function serializeImageRunToHtml(run, document2) {
|
|
29735
|
-
var
|
|
30186
|
+
var _a2;
|
|
29736
30187
|
if (run.kind !== "image") {
|
|
29737
30188
|
return "";
|
|
29738
30189
|
}
|
|
29739
30190
|
const resolvedSrc = resolveImageSrc(document2, run.image.src);
|
|
29740
30191
|
const altAttr = run.image.alt !== void 0 ? ` alt="${escapeHtml(run.image.alt)}"` : "";
|
|
29741
30192
|
const img = `<img src="${escapeHtml(resolvedSrc)}" width="${Math.max(1, Math.round(run.image.width))}" height="${Math.max(1, Math.round(run.image.height))}"${altAttr}>`;
|
|
29742
|
-
if ((
|
|
30193
|
+
if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
|
|
29743
30194
|
return `<a href="${escapeHtml(run.styles.link)}">${img}</a>`;
|
|
29744
30195
|
}
|
|
29745
30196
|
return img;
|
|
@@ -29783,7 +30234,7 @@ function serializeParagraphRunsToHtml(runs, document2) {
|
|
|
29783
30234
|
return runs.map((run) => serializeTextRunToHtml(run, document2)).join("") || "<br>";
|
|
29784
30235
|
}
|
|
29785
30236
|
function serializeEditorSelectionToHtml(state) {
|
|
29786
|
-
var
|
|
30237
|
+
var _a2;
|
|
29787
30238
|
const normalized = normalizeSelection(state);
|
|
29788
30239
|
if (normalized.isCollapsed) {
|
|
29789
30240
|
return "";
|
|
@@ -29808,7 +30259,7 @@ function serializeEditorSelectionToHtml(state) {
|
|
|
29808
30259
|
const css = paragraphStyleToCssText(paragraph.style);
|
|
29809
30260
|
const attrs = css.length > 0 ? ` style="${css}"` : "";
|
|
29810
30261
|
const paragraphHtml = serializeParagraphRunsToHtml(runs, state.document);
|
|
29811
|
-
if ((
|
|
30262
|
+
if ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) {
|
|
29812
30263
|
const wrapperTag = paragraph.list.kind === "bullet" ? "ul" : "ol";
|
|
29813
30264
|
if (activeListKind !== paragraph.list.kind) {
|
|
29814
30265
|
closeList();
|
|
@@ -30171,13 +30622,13 @@ function parseEditorClipboardHtmlWithDom(html) {
|
|
|
30171
30622
|
function createEditorContextMenuClipboard(deps) {
|
|
30172
30623
|
const t = deps.t;
|
|
30173
30624
|
const programmaticCopy = async () => {
|
|
30174
|
-
var
|
|
30625
|
+
var _a2;
|
|
30175
30626
|
const state = deps.state();
|
|
30176
30627
|
const text = getSelectedText(state);
|
|
30177
30628
|
if (!text) return;
|
|
30178
30629
|
const html = serializeEditorSelectionToHtml(state);
|
|
30179
30630
|
try {
|
|
30180
|
-
if (typeof ClipboardItem !== "undefined" && ((
|
|
30631
|
+
if (typeof ClipboardItem !== "undefined" && ((_a2 = navigator.clipboard) == null ? void 0 : _a2.write)) {
|
|
30181
30632
|
await navigator.clipboard.write([
|
|
30182
30633
|
new ClipboardItem({
|
|
30183
30634
|
"text/plain": new Blob([text], { type: "text/plain" }),
|
|
@@ -30211,12 +30662,12 @@ function createEditorContextMenuClipboard(deps) {
|
|
|
30211
30662
|
deps.focusInput();
|
|
30212
30663
|
};
|
|
30213
30664
|
const programmaticPaste = async () => {
|
|
30214
|
-
var
|
|
30665
|
+
var _a2, _b2;
|
|
30215
30666
|
if (deps.isReadOnly()) return;
|
|
30216
30667
|
let html = "";
|
|
30217
30668
|
let text = "";
|
|
30218
30669
|
try {
|
|
30219
|
-
if ((
|
|
30670
|
+
if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.read) {
|
|
30220
30671
|
const items = await navigator.clipboard.read();
|
|
30221
30672
|
for (const item of items) {
|
|
30222
30673
|
if (item.types.includes("text/html")) {
|
|
@@ -30228,7 +30679,7 @@ function createEditorContextMenuClipboard(deps) {
|
|
|
30228
30679
|
text = await blob.text();
|
|
30229
30680
|
}
|
|
30230
30681
|
}
|
|
30231
|
-
} else if ((
|
|
30682
|
+
} else if ((_b2 = navigator.clipboard) == null ? void 0 : _b2.readText) {
|
|
30232
30683
|
text = await navigator.clipboard.readText();
|
|
30233
30684
|
}
|
|
30234
30685
|
} catch (err) {
|
|
@@ -30569,19 +31020,19 @@ function createEditorUiOptions(ctx) {
|
|
|
30569
31020
|
showToolbar: () => ui().showToolbar ?? true,
|
|
30570
31021
|
showOutline: () => ui().showOutline ?? true,
|
|
30571
31022
|
toolbarView: () => {
|
|
30572
|
-
var
|
|
30573
|
-
return ((
|
|
31023
|
+
var _a2;
|
|
31024
|
+
return ((_a2 = ui().toolbar) == null ? void 0 : _a2.view) ?? "ribbon";
|
|
30574
31025
|
},
|
|
30575
31026
|
toolbarLayout: () => {
|
|
30576
|
-
var
|
|
30577
|
-
return ((
|
|
31027
|
+
var _a2;
|
|
31028
|
+
return ((_a2 = ui().toolbar) == null ? void 0 : _a2.layout) ?? "overflow";
|
|
30578
31029
|
},
|
|
30579
31030
|
isReadOnly: () => documentOptions().readOnly ?? false,
|
|
30580
31031
|
useComposedShell: () => ui().uiVariant === "docs" || (ui().shell ?? "document") !== "document",
|
|
30581
31032
|
loadingOptions,
|
|
30582
31033
|
loadingLabel: () => {
|
|
30583
|
-
var
|
|
30584
|
-
return ((
|
|
31034
|
+
var _a2;
|
|
31035
|
+
return ((_a2 = loadingOptions()) == null ? void 0 : _a2.label) ?? "Loading oasis-editor...";
|
|
30585
31036
|
},
|
|
30586
31037
|
shellComponent: () => {
|
|
30587
31038
|
const s = ui().shell ?? "document";
|
|
@@ -30611,13 +31062,15 @@ function computeShouldShowCaret(state, caretBox) {
|
|
|
30611
31062
|
}
|
|
30612
31063
|
function DropCaret(props) {
|
|
30613
31064
|
const layout = createMemo(() => {
|
|
30614
|
-
var
|
|
31065
|
+
var _a2, _b2, _c;
|
|
30615
31066
|
const pos = props.targetPos();
|
|
30616
31067
|
const surfaceRef = props.surfaceRef;
|
|
30617
31068
|
if (!surfaceRef) return null;
|
|
30618
|
-
const snapshot =
|
|
31069
|
+
const snapshot = props.snapshotProvider.getCanvasLayoutSnapshot({
|
|
30619
31070
|
surface: surfaceRef,
|
|
30620
|
-
state: props.state
|
|
31071
|
+
state: props.state,
|
|
31072
|
+
documentLayout: props.documentLayout(),
|
|
31073
|
+
zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
|
|
30621
31074
|
});
|
|
30622
31075
|
let viewportLeft = 0;
|
|
30623
31076
|
let viewportTop = 0;
|
|
@@ -30642,7 +31095,7 @@ function DropCaret(props) {
|
|
|
30642
31095
|
};
|
|
30643
31096
|
}
|
|
30644
31097
|
}
|
|
30645
|
-
const caret = ((
|
|
31098
|
+
const caret = ((_b2 = props.caretViewport) == null ? void 0 : _b2.call(props)) ?? null;
|
|
30646
31099
|
if (caret) {
|
|
30647
31100
|
viewportLeft = caret.left;
|
|
30648
31101
|
viewportTop = caret.top;
|
|
@@ -30653,7 +31106,7 @@ function DropCaret(props) {
|
|
|
30653
31106
|
height
|
|
30654
31107
|
};
|
|
30655
31108
|
}
|
|
30656
|
-
const pointer = ((
|
|
31109
|
+
const pointer = ((_c = props.pointerPos) == null ? void 0 : _c.call(props)) ?? null;
|
|
30657
31110
|
if (pointer) {
|
|
30658
31111
|
viewportLeft = pointer.x;
|
|
30659
31112
|
viewportTop = pointer.y - 12;
|
|
@@ -30777,6 +31230,15 @@ function EditorDragLayers(props) {
|
|
|
30777
31230
|
get state() {
|
|
30778
31231
|
return props.state;
|
|
30779
31232
|
},
|
|
31233
|
+
get documentLayout() {
|
|
31234
|
+
return props.documentLayout;
|
|
31235
|
+
},
|
|
31236
|
+
get snapshotProvider() {
|
|
31237
|
+
return props.snapshotProvider;
|
|
31238
|
+
},
|
|
31239
|
+
get zoomFactor() {
|
|
31240
|
+
return props.zoomFactor;
|
|
31241
|
+
},
|
|
30780
31242
|
targetPos: pos
|
|
30781
31243
|
})
|
|
30782
31244
|
}), createComponent(Show, {
|
|
@@ -30790,6 +31252,15 @@ function EditorDragLayers(props) {
|
|
|
30790
31252
|
get state() {
|
|
30791
31253
|
return props.state;
|
|
30792
31254
|
},
|
|
31255
|
+
get documentLayout() {
|
|
31256
|
+
return props.documentLayout;
|
|
31257
|
+
},
|
|
31258
|
+
get snapshotProvider() {
|
|
31259
|
+
return props.snapshotProvider;
|
|
31260
|
+
},
|
|
31261
|
+
get zoomFactor() {
|
|
31262
|
+
return props.zoomFactor;
|
|
31263
|
+
},
|
|
30793
31264
|
targetPos: pos
|
|
30794
31265
|
})
|
|
30795
31266
|
}), createComponent(Show, {
|
|
@@ -30803,6 +31274,15 @@ function EditorDragLayers(props) {
|
|
|
30803
31274
|
get state() {
|
|
30804
31275
|
return props.state;
|
|
30805
31276
|
},
|
|
31277
|
+
get documentLayout() {
|
|
31278
|
+
return props.documentLayout;
|
|
31279
|
+
},
|
|
31280
|
+
get snapshotProvider() {
|
|
31281
|
+
return props.snapshotProvider;
|
|
31282
|
+
},
|
|
31283
|
+
get zoomFactor() {
|
|
31284
|
+
return props.zoomFactor;
|
|
31285
|
+
},
|
|
30806
31286
|
targetPos: pos,
|
|
30807
31287
|
get pointerPos() {
|
|
30808
31288
|
return props.textDrag.pointerPos;
|
|
@@ -32533,9 +33013,9 @@ function ContextMenu(props) {
|
|
|
32533
33013
|
get children() {
|
|
32534
33014
|
var _el$2 = _tmpl$4(), _el$4 = _el$2.firstChild;
|
|
32535
33015
|
_el$2.$$click = () => {
|
|
32536
|
-
var
|
|
33016
|
+
var _a2;
|
|
32537
33017
|
if (item.disabled) return;
|
|
32538
|
-
(
|
|
33018
|
+
(_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
|
|
32539
33019
|
props.onClose();
|
|
32540
33020
|
};
|
|
32541
33021
|
insert(_el$2, createComponent(Show, {
|
|
@@ -32739,6 +33219,7 @@ function buildEditorViewProps(ctx) {
|
|
|
32739
33219
|
files
|
|
32740
33220
|
} = ctx;
|
|
32741
33221
|
const layout = {
|
|
33222
|
+
documentLayout: layoutInput.documentLayout,
|
|
32742
33223
|
viewportHeight: layoutInput.viewportHeight,
|
|
32743
33224
|
class: layoutInput.className,
|
|
32744
33225
|
style: layoutInput.style,
|
|
@@ -32778,12 +33259,12 @@ function buildEditorViewProps(ctx) {
|
|
|
32778
33259
|
};
|
|
32779
33260
|
const fileHandlers = {
|
|
32780
33261
|
onImportInputChange: (e) => {
|
|
32781
|
-
var
|
|
32782
|
-
return files.handleImportFile(((
|
|
33262
|
+
var _a2;
|
|
33263
|
+
return files.handleImportFile(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
|
|
32783
33264
|
},
|
|
32784
33265
|
onImageInputChange: (e) => {
|
|
32785
|
-
var
|
|
32786
|
-
return files.handleInsertImage(((
|
|
33266
|
+
var _a2;
|
|
33267
|
+
return files.handleInsertImage(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
|
|
32787
33268
|
}
|
|
32788
33269
|
};
|
|
32789
33270
|
const surfaceHandlers = {
|
|
@@ -32883,6 +33364,9 @@ function EditorWorkspace(props) {
|
|
|
32883
33364
|
get measuredParagraphLayouts() {
|
|
32884
33365
|
return view2.measuredParagraphLayouts;
|
|
32885
33366
|
},
|
|
33367
|
+
get documentLayout() {
|
|
33368
|
+
return view2.documentLayout;
|
|
33369
|
+
},
|
|
32886
33370
|
get viewportHeight() {
|
|
32887
33371
|
return view2.viewportHeight;
|
|
32888
33372
|
},
|
|
@@ -32934,6 +33418,7 @@ function EditorWorkspace(props) {
|
|
|
32934
33418
|
get layout() {
|
|
32935
33419
|
return {
|
|
32936
33420
|
...props.view.layout,
|
|
33421
|
+
documentLayout: props.view.documentLayout,
|
|
32937
33422
|
measuredBlockHeights: props.view.measuredBlockHeights,
|
|
32938
33423
|
measuredParagraphLayouts: props.view.measuredParagraphLayouts,
|
|
32939
33424
|
readOnly: props.view.isReadOnly()
|
|
@@ -33305,10 +33790,10 @@ function serializeBorder(border) {
|
|
|
33305
33790
|
return serializeDocxBorderAttrs(resolved, DEFAULT_TABLE_BORDER_COLOR);
|
|
33306
33791
|
}
|
|
33307
33792
|
function serializeTableCellBorders(cell) {
|
|
33308
|
-
var
|
|
33793
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
33309
33794
|
const borders = [
|
|
33310
|
-
`<w:top ${serializeBorder((
|
|
33311
|
-
`<w:left ${serializeBorder((
|
|
33795
|
+
`<w:top ${serializeBorder((_a2 = cell.style) == null ? void 0 : _a2.borderTop)}`,
|
|
33796
|
+
`<w:left ${serializeBorder((_b2 = cell.style) == null ? void 0 : _b2.borderLeft)}`,
|
|
33312
33797
|
`<w:bottom ${serializeBorder((_c = cell.style) == null ? void 0 : _c.borderBottom)}`,
|
|
33313
33798
|
`<w:right ${serializeBorder((_d = cell.style) == null ? void 0 : _d.borderRight)}`
|
|
33314
33799
|
];
|
|
@@ -33366,12 +33851,12 @@ function serializeTableDefaultCellMargins(margins) {
|
|
|
33366
33851
|
return parts.length > 0 ? `<w:tblCellMar>${parts.join("")}</w:tblCellMar>` : "";
|
|
33367
33852
|
}
|
|
33368
33853
|
function serializeTableCellProperties(cell, fallbackWidthPt) {
|
|
33369
|
-
var
|
|
33854
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
33370
33855
|
const colSpan = Math.max(1, Math.floor(cell.colSpan ?? 1));
|
|
33371
33856
|
const parts = [];
|
|
33372
33857
|
const conditional = serializeConditionalFlags(cell.conditionalStyle);
|
|
33373
33858
|
if (conditional) parts.push(conditional);
|
|
33374
|
-
const widthXml = serializeCellWidth(((
|
|
33859
|
+
const widthXml = serializeCellWidth(((_a2 = cell.style) == null ? void 0 : _a2.width) ?? fallbackWidthPt);
|
|
33375
33860
|
if (widthXml) {
|
|
33376
33861
|
parts.push(widthXml);
|
|
33377
33862
|
}
|
|
@@ -33383,7 +33868,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
|
|
|
33383
33868
|
} else if (cell.vMerge === "continue") {
|
|
33384
33869
|
parts.push("<w:vMerge/>");
|
|
33385
33870
|
}
|
|
33386
|
-
if ((
|
|
33871
|
+
if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
|
|
33387
33872
|
parts.push(
|
|
33388
33873
|
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(cell.style.shading, "FFFFFF")}"/>`
|
|
33389
33874
|
);
|
|
@@ -33460,10 +33945,10 @@ function serializeTableRowHeightFromStyle(heightValue, heightRule) {
|
|
|
33460
33945
|
return `<w:trHeight ${attrs.join(" ")}/>`;
|
|
33461
33946
|
}
|
|
33462
33947
|
function serializeTableRowHeight(row) {
|
|
33463
|
-
var
|
|
33948
|
+
var _a2, _b2;
|
|
33464
33949
|
return serializeTableRowHeightFromStyle(
|
|
33465
|
-
(
|
|
33466
|
-
(
|
|
33950
|
+
(_a2 = row.style) == null ? void 0 : _a2.height,
|
|
33951
|
+
(_b2 = row.style) == null ? void 0 : _b2.heightRule
|
|
33467
33952
|
);
|
|
33468
33953
|
}
|
|
33469
33954
|
function serializeTableRowStyleXml(style2) {
|
|
@@ -33497,13 +33982,13 @@ function serializeTableRowStyleXml(style2) {
|
|
|
33497
33982
|
return parts.length > 0 ? `<w:trPr>${parts.join("")}</w:trPr>` : "";
|
|
33498
33983
|
}
|
|
33499
33984
|
function serializeTableRowProperties(row) {
|
|
33500
|
-
var
|
|
33985
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
33501
33986
|
const parts = [];
|
|
33502
33987
|
const conditional = serializeConditionalFlags(row.conditionalStyle);
|
|
33503
33988
|
if (conditional) parts.push(conditional);
|
|
33504
|
-
const gridBefore = serializeGridSkip("gridBefore", (
|
|
33989
|
+
const gridBefore = serializeGridSkip("gridBefore", (_a2 = row.style) == null ? void 0 : _a2.gridBefore);
|
|
33505
33990
|
if (gridBefore) parts.push(gridBefore);
|
|
33506
|
-
const gridAfter = serializeGridSkip("gridAfter", (
|
|
33991
|
+
const gridAfter = serializeGridSkip("gridAfter", (_b2 = row.style) == null ? void 0 : _b2.gridAfter);
|
|
33507
33992
|
if (gridAfter) parts.push(gridAfter);
|
|
33508
33993
|
const widthBefore = serializeDocxWidthElement(
|
|
33509
33994
|
"wBefore",
|
|
@@ -33576,12 +34061,12 @@ function serializeTableBorders(style2) {
|
|
|
33576
34061
|
return xml ? `<w:tblBorders>${xml}</w:tblBorders>` : "";
|
|
33577
34062
|
}
|
|
33578
34063
|
function serializeTableProperties(table) {
|
|
33579
|
-
var
|
|
34064
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
33580
34065
|
const parts = [];
|
|
33581
|
-
if ((
|
|
34066
|
+
if ((_a2 = table.style) == null ? void 0 : _a2.styleId) {
|
|
33582
34067
|
parts.push(`<w:tblStyle w:val="${escapeXml(table.style.styleId)}"/>`);
|
|
33583
34068
|
}
|
|
33584
|
-
if ((
|
|
34069
|
+
if ((_b2 = table.style) == null ? void 0 : _b2.tblLook) {
|
|
33585
34070
|
const l = table.style.tblLook;
|
|
33586
34071
|
parts.push(
|
|
33587
34072
|
`<w:tblLook w:firstRow="${l.firstRow ? "1" : "0"}" w:lastRow="${l.lastRow ? "1" : "0"}" w:firstColumn="${l.firstCol ? "1" : "0"}" w:lastColumn="${l.lastCol ? "1" : "0"}" w:noHBand="${l.noHBand ? "1" : "0"}" w:noVBand="${l.noVBand ? "1" : "0"}"/>`
|
|
@@ -33747,7 +34232,7 @@ function materializeParagraphStyle(paragraph, styles) {
|
|
|
33747
34232
|
};
|
|
33748
34233
|
}
|
|
33749
34234
|
function materializeRunStyle(run, paragraphStyleId, styles) {
|
|
33750
|
-
var
|
|
34235
|
+
var _a2;
|
|
33751
34236
|
const effective = resolveEffectiveTextStyleForParagraph(
|
|
33752
34237
|
run.styles,
|
|
33753
34238
|
paragraphStyleId,
|
|
@@ -33803,7 +34288,7 @@ function materializeRunStyle(run, paragraphStyleId, styles) {
|
|
|
33803
34288
|
shading: effective.shading,
|
|
33804
34289
|
language: effective.language
|
|
33805
34290
|
};
|
|
33806
|
-
if ((
|
|
34291
|
+
if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
|
|
33807
34292
|
materialized.link = run.styles.link;
|
|
33808
34293
|
}
|
|
33809
34294
|
return materialized;
|
|
@@ -33886,11 +34371,11 @@ function serializeParagraphStyleXml(style2) {
|
|
|
33886
34371
|
return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
|
|
33887
34372
|
}
|
|
33888
34373
|
function serializeParagraphProperties(paragraph, numberingInfo, styles, overrides) {
|
|
33889
|
-
var
|
|
34374
|
+
var _a2, _b2;
|
|
33890
34375
|
const parts = [];
|
|
33891
34376
|
const style2 = materializeParagraphStyle(paragraph, styles);
|
|
33892
|
-
const align = ((
|
|
33893
|
-
if ((
|
|
34377
|
+
const align = ((_a2 = paragraph.style) == null ? void 0 : _a2.align) ?? (overrides == null ? void 0 : overrides.align) ?? style2.align;
|
|
34378
|
+
if ((_b2 = paragraph.style) == null ? void 0 : _b2.styleId) {
|
|
33894
34379
|
parts.push(`<w:pStyle w:val="${escapeXml(paragraph.style.styleId)}"/>`);
|
|
33895
34380
|
}
|
|
33896
34381
|
if (align) {
|
|
@@ -34625,7 +35110,7 @@ function serializeRun(run, context, paragraphStyleId, styles, serializeBlocksXml
|
|
|
34625
35110
|
});
|
|
34626
35111
|
}
|
|
34627
35112
|
function serializeRunWithRelationships(run, context, paragraphStyleId, styles, serializeBlocksXml2) {
|
|
34628
|
-
var
|
|
35113
|
+
var _a2;
|
|
34629
35114
|
const runXml = serializeRun(
|
|
34630
35115
|
run,
|
|
34631
35116
|
context,
|
|
@@ -34633,7 +35118,7 @@ function serializeRunWithRelationships(run, context, paragraphStyleId, styles, s
|
|
|
34633
35118
|
styles,
|
|
34634
35119
|
serializeBlocksXml2
|
|
34635
35120
|
);
|
|
34636
|
-
const href = (
|
|
35121
|
+
const href = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
34637
35122
|
if (!href) {
|
|
34638
35123
|
return runXml;
|
|
34639
35124
|
}
|
|
@@ -34712,18 +35197,18 @@ function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, st
|
|
|
34712
35197
|
return out;
|
|
34713
35198
|
}
|
|
34714
35199
|
function serializeSingleBlockXml(block, context, styles) {
|
|
34715
|
-
var
|
|
35200
|
+
var _a2;
|
|
34716
35201
|
switch (block.type) {
|
|
34717
35202
|
case "paragraph":
|
|
34718
35203
|
return serializeParagraphXml(block, context, styles);
|
|
34719
35204
|
case "table": {
|
|
34720
|
-
const pageBreakXml = ((
|
|
35205
|
+
const pageBreakXml = ((_a2 = block.style) == null ? void 0 : _a2.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
|
|
34721
35206
|
return pageBreakXml + serializeTableXml(
|
|
34722
35207
|
block,
|
|
34723
35208
|
(paragraph, cell) => {
|
|
34724
|
-
var
|
|
35209
|
+
var _a3;
|
|
34725
35210
|
return serializeParagraphXml(paragraph, context, styles, {
|
|
34726
|
-
align: (
|
|
35211
|
+
align: (_a3 = cell.style) == null ? void 0 : _a3.horizontalAlign
|
|
34727
35212
|
});
|
|
34728
35213
|
}
|
|
34729
35214
|
);
|
|
@@ -34733,12 +35218,12 @@ function serializeSingleBlockXml(block, context, styles) {
|
|
|
34733
35218
|
}
|
|
34734
35219
|
}
|
|
34735
35220
|
function serializeBlocksXml(blocks, context, styles) {
|
|
34736
|
-
var
|
|
35221
|
+
var _a2, _b2, _c;
|
|
34737
35222
|
let out = "";
|
|
34738
35223
|
let i = 0;
|
|
34739
35224
|
while (i < blocks.length) {
|
|
34740
35225
|
const block = blocks[i];
|
|
34741
|
-
const wrapper = (
|
|
35226
|
+
const wrapper = (_a2 = block.sdtWrappers) == null ? void 0 : _a2[0];
|
|
34742
35227
|
if (!wrapper) {
|
|
34743
35228
|
out += serializeSingleBlockXml(block, context, styles);
|
|
34744
35229
|
i += 1;
|
|
@@ -34746,7 +35231,7 @@ function serializeBlocksXml(blocks, context, styles) {
|
|
|
34746
35231
|
}
|
|
34747
35232
|
const group = [];
|
|
34748
35233
|
let j = i;
|
|
34749
|
-
while (j < blocks.length && ((_c = (
|
|
35234
|
+
while (j < blocks.length && ((_c = (_b2 = blocks[j].sdtWrappers) == null ? void 0 : _b2[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
|
|
34750
35235
|
const rest = blocks[j].sdtWrappers.slice(1);
|
|
34751
35236
|
group.push({
|
|
34752
35237
|
...blocks[j],
|
|
@@ -34761,11 +35246,11 @@ function serializeBlocksXml(blocks, context, styles) {
|
|
|
34761
35246
|
return out;
|
|
34762
35247
|
}
|
|
34763
35248
|
function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
34764
|
-
var
|
|
35249
|
+
var _a2, _b2, _c;
|
|
34765
35250
|
const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "", kind: "text" }];
|
|
34766
35251
|
const dropCapFrame = paragraph.dropCap ? serializeDropCapFrameParagraph(paragraph.dropCap) : "";
|
|
34767
|
-
const bookmarkEvents = (
|
|
34768
|
-
const commentEvents = (
|
|
35252
|
+
const bookmarkEvents = (_a2 = context.bookmarkEventsByParagraph) == null ? void 0 : _a2.get(paragraph.id);
|
|
35253
|
+
const commentEvents = (_b2 = context.commentEventsByParagraph) == null ? void 0 : _b2.get(paragraph.id);
|
|
34769
35254
|
const boundaryTokens = [
|
|
34770
35255
|
...(bookmarkEvents ?? []).map((e) => ({
|
|
34771
35256
|
offset: e.offset,
|
|
@@ -34786,11 +35271,11 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
|
34786
35271
|
styles
|
|
34787
35272
|
) : runs.map(
|
|
34788
35273
|
(run) => {
|
|
34789
|
-
var
|
|
35274
|
+
var _a3;
|
|
34790
35275
|
return serializeRunWithRelationships(
|
|
34791
35276
|
run,
|
|
34792
35277
|
context,
|
|
34793
|
-
(
|
|
35278
|
+
(_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
|
|
34794
35279
|
styles,
|
|
34795
35280
|
serializeBlocksXml
|
|
34796
35281
|
);
|
|
@@ -34805,8 +35290,8 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
|
34805
35290
|
}
|
|
34806
35291
|
const FIRST_FOOTNOTE_DOCX_ID = 1;
|
|
34807
35292
|
function collectReferencedFootnotesForExport(document2) {
|
|
34808
|
-
var
|
|
34809
|
-
const items = (
|
|
35293
|
+
var _a2;
|
|
35294
|
+
const items = (_a2 = document2.footnotes) == null ? void 0 : _a2.items;
|
|
34810
35295
|
if (!items) return [];
|
|
34811
35296
|
const seen = /* @__PURE__ */ new Map();
|
|
34812
35297
|
let nextDocxId = FIRST_FOOTNOTE_DOCX_ID;
|
|
@@ -34854,11 +35339,11 @@ function createEmptyFootnoteBodyParagraph(withMarker = true) {
|
|
|
34854
35339
|
};
|
|
34855
35340
|
}
|
|
34856
35341
|
function prependFootnoteRefMarker(paragraph) {
|
|
34857
|
-
var
|
|
35342
|
+
var _a2;
|
|
34858
35343
|
return {
|
|
34859
35344
|
...paragraph,
|
|
34860
35345
|
runs: [makeFootnoteRefMarkerRun(), ...paragraph.runs],
|
|
34861
|
-
style: ((
|
|
35346
|
+
style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
|
|
34862
35347
|
};
|
|
34863
35348
|
}
|
|
34864
35349
|
function makeFootnoteRefMarkerRun() {
|
|
@@ -34887,9 +35372,9 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
|
|
|
34887
35372
|
return serializeTableXml(
|
|
34888
35373
|
block,
|
|
34889
35374
|
(paragraph, cell) => {
|
|
34890
|
-
var
|
|
35375
|
+
var _a2;
|
|
34891
35376
|
return serializeParagraphXml(paragraph, partContext, styles, {
|
|
34892
|
-
align: (
|
|
35377
|
+
align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
|
|
34893
35378
|
});
|
|
34894
35379
|
}
|
|
34895
35380
|
);
|
|
@@ -34901,8 +35386,8 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
|
|
|
34901
35386
|
}
|
|
34902
35387
|
const FIRST_ENDNOTE_DOCX_ID = 1;
|
|
34903
35388
|
function collectReferencedEndnotesForExport(document2) {
|
|
34904
|
-
var
|
|
34905
|
-
const items = (
|
|
35389
|
+
var _a2;
|
|
35390
|
+
const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
|
|
34906
35391
|
if (!items) return [];
|
|
34907
35392
|
const seen = /* @__PURE__ */ new Map();
|
|
34908
35393
|
let nextDocxId = FIRST_ENDNOTE_DOCX_ID;
|
|
@@ -34950,11 +35435,11 @@ function createEmptyEndnoteBodyParagraph(withMarker = true) {
|
|
|
34950
35435
|
};
|
|
34951
35436
|
}
|
|
34952
35437
|
function prependEndnoteRefMarker(paragraph) {
|
|
34953
|
-
var
|
|
35438
|
+
var _a2;
|
|
34954
35439
|
return {
|
|
34955
35440
|
...paragraph,
|
|
34956
35441
|
runs: [makeEndnoteRefMarkerRun(), ...paragraph.runs],
|
|
34957
|
-
style: ((
|
|
35442
|
+
style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
|
|
34958
35443
|
};
|
|
34959
35444
|
}
|
|
34960
35445
|
function makeEndnoteRefMarkerRun() {
|
|
@@ -34982,9 +35467,9 @@ function buildEndnotesXml(_document, referenced, _numberingContext, _state, buil
|
|
|
34982
35467
|
return serializeTableXml(
|
|
34983
35468
|
block,
|
|
34984
35469
|
(paragraph, cell) => {
|
|
34985
|
-
var
|
|
35470
|
+
var _a2;
|
|
34986
35471
|
return serializeParagraphXml(paragraph, partContext, styles, {
|
|
34987
|
-
align: (
|
|
35472
|
+
align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
|
|
34988
35473
|
});
|
|
34989
35474
|
}
|
|
34990
35475
|
);
|
|
@@ -35416,14 +35901,14 @@ function buildNumberingXml(definitions) {
|
|
|
35416
35901
|
}
|
|
35417
35902
|
const DOCUMENT_XMLNS = `xmlns:w="${WORD_NS$1}" xmlns:w14="${WORD14_NS}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${OFFICE_REL_NS}"`;
|
|
35418
35903
|
function serializeSectionPropertiesWithReferences(pageSettings, references) {
|
|
35419
|
-
var
|
|
35904
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
35420
35905
|
const width = pxToTwips(pageSettings.width, 12240);
|
|
35421
35906
|
const height = pxToTwips(pageSettings.height, 15840);
|
|
35422
35907
|
const margins = pageSettings.margins;
|
|
35423
35908
|
const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
|
|
35424
35909
|
const referencesXml = [
|
|
35425
|
-
((
|
|
35426
|
-
((
|
|
35910
|
+
((_a2 = references == null ? void 0 : references.header) == null ? void 0 : _a2.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
|
|
35911
|
+
((_b2 = references == null ? void 0 : references.header) == null ? void 0 : _b2.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
|
|
35427
35912
|
((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
|
|
35428
35913
|
((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
|
|
35429
35914
|
((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
|
|
@@ -35504,11 +35989,11 @@ function createImageCaptionParagraph(captionText, label, sequenceNumber) {
|
|
|
35504
35989
|
return paragraph;
|
|
35505
35990
|
}
|
|
35506
35991
|
function isImageCaptionParagraph(paragraph) {
|
|
35507
|
-
var
|
|
35992
|
+
var _a2, _b2;
|
|
35508
35993
|
if (!paragraph) {
|
|
35509
35994
|
return false;
|
|
35510
35995
|
}
|
|
35511
|
-
const styleId = (
|
|
35996
|
+
const styleId = (_b2 = (_a2 = paragraph.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.toLowerCase();
|
|
35512
35997
|
if (styleId !== "caption") {
|
|
35513
35998
|
return false;
|
|
35514
35999
|
}
|
|
@@ -35520,7 +36005,7 @@ function isImageCaptionParagraph(paragraph) {
|
|
|
35520
36005
|
});
|
|
35521
36006
|
}
|
|
35522
36007
|
function getImageCaptionText(paragraph) {
|
|
35523
|
-
var
|
|
36008
|
+
var _a2;
|
|
35524
36009
|
if (!isImageCaptionParagraph(paragraph)) {
|
|
35525
36010
|
return "";
|
|
35526
36011
|
}
|
|
@@ -35531,15 +36016,15 @@ function getImageCaptionText(paragraph) {
|
|
|
35531
36016
|
value += run.text;
|
|
35532
36017
|
continue;
|
|
35533
36018
|
}
|
|
35534
|
-
if (((
|
|
36019
|
+
if (((_a2 = getRunFieldChar(run)) == null ? void 0 : _a2.kind) === "end") {
|
|
35535
36020
|
afterField = true;
|
|
35536
36021
|
}
|
|
35537
36022
|
}
|
|
35538
36023
|
return value.replace(/^[:\-\s]+/, "");
|
|
35539
36024
|
}
|
|
35540
36025
|
function updateImageCaptionParagraph(paragraph, captionText, label) {
|
|
35541
|
-
var
|
|
35542
|
-
const currentNumber = ((
|
|
36026
|
+
var _a2;
|
|
36027
|
+
const currentNumber = ((_a2 = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a2.text) ?? "1";
|
|
35543
36028
|
const next = createImageCaptionParagraph(
|
|
35544
36029
|
captionText,
|
|
35545
36030
|
label,
|
|
@@ -35638,9 +36123,9 @@ function buildPartContext(blocks, numberingContext, state, document2) {
|
|
|
35638
36123
|
const hyperlinks = [];
|
|
35639
36124
|
const hyperlinkMap = /* @__PURE__ */ new Map();
|
|
35640
36125
|
visitBlocks(blocks, (paragraph) => {
|
|
35641
|
-
var
|
|
36126
|
+
var _a2;
|
|
35642
36127
|
for (const run of paragraph.runs) {
|
|
35643
|
-
const link = (
|
|
36128
|
+
const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
35644
36129
|
if (link && !link.startsWith("#") && !hyperlinkMap.has(link)) {
|
|
35645
36130
|
const rId2 = `rIdLink${hyperlinks.length + 1}`;
|
|
35646
36131
|
hyperlinkMap.set(link, rId2);
|
|
@@ -35711,7 +36196,7 @@ function buildPartContext(blocks, numberingContext, state, document2) {
|
|
|
35711
36196
|
};
|
|
35712
36197
|
}
|
|
35713
36198
|
async function exportEditorDocumentToDocx(document2) {
|
|
35714
|
-
var
|
|
36199
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
35715
36200
|
document2 = renumberImageCaptionsInDocument(document2);
|
|
35716
36201
|
const zip = new JSZip();
|
|
35717
36202
|
const numberingContext = buildNumberingContext(document2);
|
|
@@ -35748,7 +36233,7 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
35748
36233
|
let nextFooterIndex = 1;
|
|
35749
36234
|
sections.forEach((section, sectionIndex) => {
|
|
35750
36235
|
const addPart = (kind, type, blocks) => {
|
|
35751
|
-
var
|
|
36236
|
+
var _a3;
|
|
35752
36237
|
if (!blocks || blocks.length === 0) {
|
|
35753
36238
|
return;
|
|
35754
36239
|
}
|
|
@@ -35775,7 +36260,7 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
35775
36260
|
context
|
|
35776
36261
|
});
|
|
35777
36262
|
const referenceKey = kind === "header" ? "header" : "footer";
|
|
35778
|
-
((
|
|
36263
|
+
((_a3 = sectionReferences[sectionIndex])[referenceKey] ?? (_a3[referenceKey] = {}))[type] = { relId };
|
|
35779
36264
|
if (kind === "header") {
|
|
35780
36265
|
nextHeaderIndex += 1;
|
|
35781
36266
|
} else {
|
|
@@ -35792,11 +36277,11 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
35792
36277
|
const hasNumbering = numberingContext.definitions.length > 0;
|
|
35793
36278
|
const hasEvenAndOddHeaders = sections.some(
|
|
35794
36279
|
(section) => {
|
|
35795
|
-
var
|
|
35796
|
-
return (((
|
|
36280
|
+
var _a3, _b3;
|
|
36281
|
+
return (((_a3 = section.evenPageHeader) == null ? void 0 : _a3.length) ?? 0) > 0 || (((_b3 = section.evenPageFooter) == null ? void 0 : _b3.length) ?? 0) > 0;
|
|
35797
36282
|
}
|
|
35798
36283
|
);
|
|
35799
|
-
const hasDocumentSettings = hasEvenAndOddHeaders || ((
|
|
36284
|
+
const hasDocumentSettings = hasEvenAndOddHeaders || ((_a2 = document2.settings) == null ? void 0 : _a2.defaultTabStop) !== void 0 || ((_b2 = document2.settings) == null ? void 0 : _b2.allowSpaceOfSameStyleInTable) !== void 0 || ((_c = document2.settings) == null ? void 0 : _c.autoHyphenation) !== void 0 || ((_d = document2.settings) == null ? void 0 : _d.consecutiveHyphenLimit) !== void 0 || ((_e = document2.settings) == null ? void 0 : _e.hyphenationZone) !== void 0 || ((_f = document2.settings) == null ? void 0 : _f.doNotHyphenateCaps) !== void 0 || ((_g = document2.footnotes) == null ? void 0 : _g.settings) !== void 0 || ((_h = document2.endnotes) == null ? void 0 : _h.settings) !== void 0;
|
|
35800
36285
|
const allImages = [
|
|
35801
36286
|
...bodyContext.images,
|
|
35802
36287
|
...parts.flatMap((part) => part.context.images)
|
|
@@ -35826,8 +36311,8 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
35826
36311
|
allImages.push(...endnotesPart.partContext.images);
|
|
35827
36312
|
}
|
|
35828
36313
|
const imageExtensions = allImages.filter((img) => img.kind === "embedded").map((img) => {
|
|
35829
|
-
var
|
|
35830
|
-
return (
|
|
36314
|
+
var _a3;
|
|
36315
|
+
return (_a3 = img.target.split(".").pop()) == null ? void 0 : _a3.toLowerCase();
|
|
35831
36316
|
}).filter((ext) => Boolean(ext));
|
|
35832
36317
|
const hasStyles = document2.styles != null && Object.keys(document2.styles).length > 0;
|
|
35833
36318
|
const hasFontTable = (((_i = document2.fontTable) == null ? void 0 : _i.length) ?? 0) > 0;
|
|
@@ -35969,24 +36454,24 @@ function borderDashArray(type) {
|
|
|
35969
36454
|
}
|
|
35970
36455
|
}
|
|
35971
36456
|
function getPadding(textBox) {
|
|
35972
|
-
var
|
|
36457
|
+
var _a2, _b2, _c, _d;
|
|
35973
36458
|
return {
|
|
35974
|
-
left: ((
|
|
35975
|
-
top: ((
|
|
36459
|
+
left: ((_a2 = textBox.body) == null ? void 0 : _a2.paddingLeft) ?? 0,
|
|
36460
|
+
top: ((_b2 = textBox.body) == null ? void 0 : _b2.paddingTop) ?? 0,
|
|
35976
36461
|
right: ((_c = textBox.body) == null ? void 0 : _c.paddingRight) ?? 0,
|
|
35977
36462
|
bottom: ((_d = textBox.body) == null ? void 0 : _d.paddingBottom) ?? 0
|
|
35978
36463
|
};
|
|
35979
36464
|
}
|
|
35980
36465
|
function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, heightPx) {
|
|
35981
|
-
var
|
|
36466
|
+
var _a2, _b2, _c, _d;
|
|
35982
36467
|
const segments = getPresetPathSegments(
|
|
35983
|
-
(
|
|
36468
|
+
(_a2 = textBox.shape) == null ? void 0 : _a2.preset,
|
|
35984
36469
|
pxToPt$1(xPx),
|
|
35985
36470
|
pxToPt$1(yPx),
|
|
35986
36471
|
pxToPt$1(widthPx),
|
|
35987
36472
|
pxToPt$1(heightPx)
|
|
35988
36473
|
);
|
|
35989
|
-
const fill = (
|
|
36474
|
+
const fill = (_b2 = textBox.shape) == null ? void 0 : _b2.fill;
|
|
35990
36475
|
const borderColor = (_c = textBox.shape) == null ? void 0 : _c.borderColor;
|
|
35991
36476
|
const borderWidthPt = ((_d = textBox.shape) == null ? void 0 : _d.borderWidthPt) ?? (borderColor ? 0.75 : 0);
|
|
35992
36477
|
writer.drawPath(pageIndex, {
|
|
@@ -35997,7 +36482,7 @@ function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, height
|
|
|
35997
36482
|
});
|
|
35998
36483
|
}
|
|
35999
36484
|
async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heightPx, drawers) {
|
|
36000
|
-
var
|
|
36485
|
+
var _a2;
|
|
36001
36486
|
if (textBox.blocks.length === 0) {
|
|
36002
36487
|
return;
|
|
36003
36488
|
}
|
|
@@ -36026,7 +36511,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
|
|
|
36026
36511
|
styles: ctx.document.styles,
|
|
36027
36512
|
pageOffset: ctx.pageIndex
|
|
36028
36513
|
});
|
|
36029
|
-
const blocks = ((
|
|
36514
|
+
const blocks = ((_a2 = pages[0]) == null ? void 0 : _a2.blocks) ?? [];
|
|
36030
36515
|
if (blocks.length === 0) {
|
|
36031
36516
|
return;
|
|
36032
36517
|
}
|
|
@@ -36635,7 +37120,7 @@ function groupSlotChunksByOffsetGaps(chars) {
|
|
|
36635
37120
|
return chunks;
|
|
36636
37121
|
}
|
|
36637
37122
|
function resolveTabLeader(paragraph, line, tabLeft, document2) {
|
|
36638
|
-
var
|
|
37123
|
+
var _a2;
|
|
36639
37124
|
const paragraphStyle = resolveEffectiveParagraphStyle(
|
|
36640
37125
|
paragraph.style,
|
|
36641
37126
|
document2.styles
|
|
@@ -36644,7 +37129,7 @@ function resolveTabLeader(paragraph, line, tabLeft, document2) {
|
|
|
36644
37129
|
if (tabs.length === 0) {
|
|
36645
37130
|
return void 0;
|
|
36646
37131
|
}
|
|
36647
|
-
const lineStart = ((
|
|
37132
|
+
const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
|
|
36648
37133
|
const relativeLeft = tabLeft - lineStart;
|
|
36649
37134
|
const stop = tabs.filter((tab) => tab.type !== "clear").map((tab) => ({ ...tab, positionPx: tab.position * PX_PER_POINT })).filter((tab) => tab.positionPx > relativeLeft + 0.01).sort((a, b) => a.positionPx - b.positionPx)[0];
|
|
36650
37135
|
return (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
|
|
@@ -36699,7 +37184,7 @@ async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, docu
|
|
|
36699
37184
|
);
|
|
36700
37185
|
}
|
|
36701
37186
|
async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
|
|
36702
|
-
var
|
|
37187
|
+
var _a2, _b2, _c;
|
|
36703
37188
|
if (fragment.image) {
|
|
36704
37189
|
if (fragment.image.floating) {
|
|
36705
37190
|
return;
|
|
@@ -36744,7 +37229,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
36744
37229
|
}
|
|
36745
37230
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
36746
37231
|
fragment.styles,
|
|
36747
|
-
(
|
|
37232
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
36748
37233
|
document2.styles
|
|
36749
37234
|
);
|
|
36750
37235
|
if (styles.hidden) {
|
|
@@ -36764,6 +37249,23 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
36764
37249
|
if (!firstChar || text.length === 0) {
|
|
36765
37250
|
return;
|
|
36766
37251
|
}
|
|
37252
|
+
if (styles.link) {
|
|
37253
|
+
const linkBounds = resolveFragmentBounds(
|
|
37254
|
+
line,
|
|
37255
|
+
fragment,
|
|
37256
|
+
styles.fontSize ?? DEFAULT_FONT_SIZE_PX
|
|
37257
|
+
);
|
|
37258
|
+
if (linkBounds && linkBounds.right > linkBounds.left) {
|
|
37259
|
+
const isInternal = styles.link.startsWith("#");
|
|
37260
|
+
writer.addLinkAnnotation(pageIndex, {
|
|
37261
|
+
x: pxToPt$1(originX + linkBounds.left),
|
|
37262
|
+
y: pxToPt$1(originY + line.top),
|
|
37263
|
+
width: pxToPt$1(linkBounds.right - linkBounds.left),
|
|
37264
|
+
height: pxToPt$1(line.height),
|
|
37265
|
+
...isInternal ? { destName: styles.link.slice(1) } : { uri: styles.link }
|
|
37266
|
+
});
|
|
37267
|
+
}
|
|
37268
|
+
}
|
|
36767
37269
|
drawFragmentShading(
|
|
36768
37270
|
writer,
|
|
36769
37271
|
pageIndex,
|
|
@@ -36816,7 +37318,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
36816
37318
|
horizontalScale: styles.characterScale ?? 100,
|
|
36817
37319
|
fontFeatures
|
|
36818
37320
|
};
|
|
36819
|
-
const mainColor = ((
|
|
37321
|
+
const mainColor = ((_b2 = styles.textFill) == null ? void 0 : _b2.type) === "solid" ? styles.textFill.color : ((_c = styles.textFill) == null ? void 0 : _c.type) === "gradient" && styles.textFill.stops[0] ? styles.textFill.stops[0].color : styles.color ?? "#000000";
|
|
36820
37322
|
const gradientShadingName = resolveGradientShadingName(
|
|
36821
37323
|
writer,
|
|
36822
37324
|
pageIndex,
|
|
@@ -36974,7 +37476,7 @@ function getListOrdinals(document2) {
|
|
|
36974
37476
|
return buildListLabels(document2);
|
|
36975
37477
|
}
|
|
36976
37478
|
function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
|
|
36977
|
-
var
|
|
37479
|
+
var _a2;
|
|
36978
37480
|
if (line.index !== 0) {
|
|
36979
37481
|
return;
|
|
36980
37482
|
}
|
|
@@ -36988,7 +37490,7 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
|
|
|
36988
37490
|
}
|
|
36989
37491
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
36990
37492
|
void 0,
|
|
36991
|
-
(
|
|
37493
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
36992
37494
|
document2.styles
|
|
36993
37495
|
);
|
|
36994
37496
|
const fontFace = fontRegistry.resolveFontFace({
|
|
@@ -37218,8 +37720,8 @@ async function drawTableBlock(writer, pageIndex, block, document2, originX, orig
|
|
|
37218
37720
|
}
|
|
37219
37721
|
}
|
|
37220
37722
|
const blockDrawers = { drawParagraph, drawTableBlock };
|
|
37221
|
-
async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings) {
|
|
37222
|
-
var
|
|
37723
|
+
async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings, onParagraphDrawn) {
|
|
37724
|
+
var _a2;
|
|
37223
37725
|
if (!blocks || blocks.length === 0) {
|
|
37224
37726
|
return;
|
|
37225
37727
|
}
|
|
@@ -37237,6 +37739,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
|
|
|
37237
37739
|
);
|
|
37238
37740
|
const spacingBefore = block.layout.startOffset === 0 && cursorY > originY ? paragraphStyle.spacingBefore ?? 0 : 0;
|
|
37239
37741
|
const boxTop = cursorY + spacingBefore;
|
|
37742
|
+
onParagraphDrawn == null ? void 0 : onParagraphDrawn(block.sourceBlock.id, boxTop);
|
|
37240
37743
|
const textTop = boxTop + getParagraphBorderInsets(paragraphStyle).top;
|
|
37241
37744
|
drawParagraphDecorations(
|
|
37242
37745
|
writer,
|
|
@@ -37318,7 +37821,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
|
|
|
37318
37821
|
break;
|
|
37319
37822
|
}
|
|
37320
37823
|
case "table":
|
|
37321
|
-
if (((
|
|
37824
|
+
if (((_a2 = block.sourceBlock.style) == null ? void 0 : _a2.floating) && pageSettings) {
|
|
37322
37825
|
const width = resolveCanvasTableWidth(
|
|
37323
37826
|
block.sourceBlock,
|
|
37324
37827
|
contentWidth
|
|
@@ -38970,7 +39473,7 @@ class SimpleTextLayouter {
|
|
|
38970
39473
|
function view(bytes) {
|
|
38971
39474
|
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
38972
39475
|
}
|
|
38973
|
-
function u16(bytes, offset) {
|
|
39476
|
+
function u16$1(bytes, offset) {
|
|
38974
39477
|
return view(bytes).getUint16(offset);
|
|
38975
39478
|
}
|
|
38976
39479
|
function i16(bytes, offset) {
|
|
@@ -39022,8 +39525,8 @@ function collectCompositeGlyphs(glyph, addGlyph) {
|
|
|
39022
39525
|
let flags = 0;
|
|
39023
39526
|
do {
|
|
39024
39527
|
if (offset + 4 > glyph.byteLength) return;
|
|
39025
|
-
flags = u16(glyph, offset);
|
|
39026
|
-
addGlyph(u16(glyph, offset + 2));
|
|
39528
|
+
flags = u16$1(glyph, offset);
|
|
39529
|
+
addGlyph(u16$1(glyph, offset + 2));
|
|
39027
39530
|
offset += 4;
|
|
39028
39531
|
offset += flags & 1 ? 4 : 2;
|
|
39029
39532
|
if (flags & 8) offset += 2;
|
|
@@ -39038,7 +39541,7 @@ function subsetClosure(font, initialGlyphs) {
|
|
|
39038
39541
|
if (!glyf || !loca || !head) {
|
|
39039
39542
|
return Array.from(/* @__PURE__ */ new Set([0, ...initialGlyphs])).sort((a, b) => a - b);
|
|
39040
39543
|
}
|
|
39041
|
-
const offsets = readLoca(loca, u16(head, 50));
|
|
39544
|
+
const offsets = readLoca(loca, u16$1(head, 50));
|
|
39042
39545
|
const used = /* @__PURE__ */ new Set([0, ...initialGlyphs]);
|
|
39043
39546
|
const stack = Array.from(used);
|
|
39044
39547
|
while (stack.length > 0) {
|
|
@@ -39082,7 +39585,7 @@ function buildSubsetTables(font, glyphIds) {
|
|
|
39082
39585
|
}
|
|
39083
39586
|
const maxGlyphId = Math.max(0, ...glyphIds);
|
|
39084
39587
|
const used = new Set(glyphIds);
|
|
39085
|
-
const sourceOffsets = readLoca(loca, u16(head, 50));
|
|
39588
|
+
const sourceOffsets = readLoca(loca, u16$1(head, 50));
|
|
39086
39589
|
const locaOffsets = [];
|
|
39087
39590
|
const glyfChunks = [];
|
|
39088
39591
|
let glyfOffset = 0;
|
|
@@ -39477,11 +39980,608 @@ function buildFunctionObject(stops) {
|
|
|
39477
39980
|
">>"
|
|
39478
39981
|
].join("\n");
|
|
39479
39982
|
}
|
|
39480
|
-
|
|
39983
|
+
var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
|
|
39984
|
+
var fleb = new u8([
|
|
39985
|
+
0,
|
|
39986
|
+
0,
|
|
39987
|
+
0,
|
|
39988
|
+
0,
|
|
39989
|
+
0,
|
|
39990
|
+
0,
|
|
39991
|
+
0,
|
|
39992
|
+
0,
|
|
39993
|
+
1,
|
|
39994
|
+
1,
|
|
39995
|
+
1,
|
|
39996
|
+
1,
|
|
39997
|
+
2,
|
|
39998
|
+
2,
|
|
39999
|
+
2,
|
|
40000
|
+
2,
|
|
40001
|
+
3,
|
|
40002
|
+
3,
|
|
40003
|
+
3,
|
|
40004
|
+
3,
|
|
40005
|
+
4,
|
|
40006
|
+
4,
|
|
40007
|
+
4,
|
|
40008
|
+
4,
|
|
40009
|
+
5,
|
|
40010
|
+
5,
|
|
40011
|
+
5,
|
|
40012
|
+
5,
|
|
40013
|
+
0,
|
|
40014
|
+
/* unused */
|
|
40015
|
+
0,
|
|
40016
|
+
0,
|
|
40017
|
+
/* impossible */
|
|
40018
|
+
0
|
|
40019
|
+
]);
|
|
40020
|
+
var fdeb = new u8([
|
|
40021
|
+
0,
|
|
40022
|
+
0,
|
|
40023
|
+
0,
|
|
40024
|
+
0,
|
|
40025
|
+
1,
|
|
40026
|
+
1,
|
|
40027
|
+
2,
|
|
40028
|
+
2,
|
|
40029
|
+
3,
|
|
40030
|
+
3,
|
|
40031
|
+
4,
|
|
40032
|
+
4,
|
|
40033
|
+
5,
|
|
40034
|
+
5,
|
|
40035
|
+
6,
|
|
40036
|
+
6,
|
|
40037
|
+
7,
|
|
40038
|
+
7,
|
|
40039
|
+
8,
|
|
40040
|
+
8,
|
|
40041
|
+
9,
|
|
40042
|
+
9,
|
|
40043
|
+
10,
|
|
40044
|
+
10,
|
|
40045
|
+
11,
|
|
40046
|
+
11,
|
|
40047
|
+
12,
|
|
40048
|
+
12,
|
|
40049
|
+
13,
|
|
40050
|
+
13,
|
|
40051
|
+
/* unused */
|
|
40052
|
+
0,
|
|
40053
|
+
0
|
|
40054
|
+
]);
|
|
40055
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
40056
|
+
var freb = function(eb, start) {
|
|
40057
|
+
var b = new u16(31);
|
|
40058
|
+
for (var i = 0; i < 31; ++i) {
|
|
40059
|
+
b[i] = start += 1 << eb[i - 1];
|
|
40060
|
+
}
|
|
40061
|
+
var r = new i32(b[30]);
|
|
40062
|
+
for (var i = 1; i < 30; ++i) {
|
|
40063
|
+
for (var j = b[i]; j < b[i + 1]; ++j) {
|
|
40064
|
+
r[j] = j - b[i] << 5 | i;
|
|
40065
|
+
}
|
|
40066
|
+
}
|
|
40067
|
+
return { b, r };
|
|
40068
|
+
};
|
|
40069
|
+
var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
|
|
40070
|
+
fl[28] = 258, revfl[258] = 28;
|
|
40071
|
+
var _b = freb(fdeb, 0), revfd = _b.r;
|
|
40072
|
+
var rev = new u16(32768);
|
|
40073
|
+
for (var i = 0; i < 32768; ++i) {
|
|
40074
|
+
var x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
40075
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
40076
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
40077
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
40078
|
+
}
|
|
40079
|
+
var hMap = function(cd, mb, r) {
|
|
40080
|
+
var s = cd.length;
|
|
40081
|
+
var i = 0;
|
|
40082
|
+
var l = new u16(mb);
|
|
40083
|
+
for (; i < s; ++i) {
|
|
40084
|
+
if (cd[i])
|
|
40085
|
+
++l[cd[i] - 1];
|
|
40086
|
+
}
|
|
40087
|
+
var le = new u16(mb);
|
|
40088
|
+
for (i = 1; i < mb; ++i) {
|
|
40089
|
+
le[i] = le[i - 1] + l[i - 1] << 1;
|
|
40090
|
+
}
|
|
40091
|
+
var co;
|
|
40092
|
+
if (r) {
|
|
40093
|
+
co = new u16(1 << mb);
|
|
40094
|
+
var rvb = 15 - mb;
|
|
40095
|
+
for (i = 0; i < s; ++i) {
|
|
40096
|
+
if (cd[i]) {
|
|
40097
|
+
var sv = i << 4 | cd[i];
|
|
40098
|
+
var r_1 = mb - cd[i];
|
|
40099
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
40100
|
+
for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
|
|
40101
|
+
co[rev[v] >> rvb] = sv;
|
|
40102
|
+
}
|
|
40103
|
+
}
|
|
40104
|
+
}
|
|
40105
|
+
} else {
|
|
40106
|
+
co = new u16(s);
|
|
40107
|
+
for (i = 0; i < s; ++i) {
|
|
40108
|
+
if (cd[i]) {
|
|
40109
|
+
co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
|
|
40110
|
+
}
|
|
40111
|
+
}
|
|
40112
|
+
}
|
|
40113
|
+
return co;
|
|
40114
|
+
};
|
|
40115
|
+
var flt = new u8(288);
|
|
40116
|
+
for (var i = 0; i < 144; ++i)
|
|
40117
|
+
flt[i] = 8;
|
|
40118
|
+
for (var i = 144; i < 256; ++i)
|
|
40119
|
+
flt[i] = 9;
|
|
40120
|
+
for (var i = 256; i < 280; ++i)
|
|
40121
|
+
flt[i] = 7;
|
|
40122
|
+
for (var i = 280; i < 288; ++i)
|
|
40123
|
+
flt[i] = 8;
|
|
40124
|
+
var fdt = new u8(32);
|
|
40125
|
+
for (var i = 0; i < 32; ++i)
|
|
40126
|
+
fdt[i] = 5;
|
|
40127
|
+
var flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
40128
|
+
var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
40129
|
+
var shft = function(p) {
|
|
40130
|
+
return (p + 7) / 8 | 0;
|
|
40131
|
+
};
|
|
40132
|
+
var slc = function(v, s, e) {
|
|
40133
|
+
if (e == null || e > v.length)
|
|
40134
|
+
e = v.length;
|
|
40135
|
+
return new u8(v.subarray(s, e));
|
|
40136
|
+
};
|
|
40137
|
+
var wbits = function(d, p, v) {
|
|
40138
|
+
v <<= p & 7;
|
|
40139
|
+
var o = p / 8 | 0;
|
|
40140
|
+
d[o] |= v;
|
|
40141
|
+
d[o + 1] |= v >> 8;
|
|
40142
|
+
};
|
|
40143
|
+
var wbits16 = function(d, p, v) {
|
|
40144
|
+
v <<= p & 7;
|
|
40145
|
+
var o = p / 8 | 0;
|
|
40146
|
+
d[o] |= v;
|
|
40147
|
+
d[o + 1] |= v >> 8;
|
|
40148
|
+
d[o + 2] |= v >> 16;
|
|
40149
|
+
};
|
|
40150
|
+
var hTree = function(d, mb) {
|
|
40151
|
+
var t = [];
|
|
40152
|
+
for (var i = 0; i < d.length; ++i) {
|
|
40153
|
+
if (d[i])
|
|
40154
|
+
t.push({ s: i, f: d[i] });
|
|
40155
|
+
}
|
|
40156
|
+
var s = t.length;
|
|
40157
|
+
var t2 = t.slice();
|
|
40158
|
+
if (!s)
|
|
40159
|
+
return { t: et, l: 0 };
|
|
40160
|
+
if (s == 1) {
|
|
40161
|
+
var v = new u8(t[0].s + 1);
|
|
40162
|
+
v[t[0].s] = 1;
|
|
40163
|
+
return { t: v, l: 1 };
|
|
40164
|
+
}
|
|
40165
|
+
t.sort(function(a, b) {
|
|
40166
|
+
return a.f - b.f;
|
|
40167
|
+
});
|
|
40168
|
+
t.push({ s: -1, f: 25001 });
|
|
40169
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
|
|
40170
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
40171
|
+
while (i1 != s - 1) {
|
|
40172
|
+
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
|
|
40173
|
+
r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
|
|
40174
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
40175
|
+
}
|
|
40176
|
+
var maxSym = t2[0].s;
|
|
40177
|
+
for (var i = 1; i < s; ++i) {
|
|
40178
|
+
if (t2[i].s > maxSym)
|
|
40179
|
+
maxSym = t2[i].s;
|
|
40180
|
+
}
|
|
40181
|
+
var tr = new u16(maxSym + 1);
|
|
40182
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
40183
|
+
if (mbt > mb) {
|
|
40184
|
+
var i = 0, dt = 0;
|
|
40185
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
40186
|
+
t2.sort(function(a, b) {
|
|
40187
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
40188
|
+
});
|
|
40189
|
+
for (; i < s; ++i) {
|
|
40190
|
+
var i2_1 = t2[i].s;
|
|
40191
|
+
if (tr[i2_1] > mb) {
|
|
40192
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
40193
|
+
tr[i2_1] = mb;
|
|
40194
|
+
} else
|
|
40195
|
+
break;
|
|
40196
|
+
}
|
|
40197
|
+
dt >>= lft;
|
|
40198
|
+
while (dt > 0) {
|
|
40199
|
+
var i2_2 = t2[i].s;
|
|
40200
|
+
if (tr[i2_2] < mb)
|
|
40201
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
40202
|
+
else
|
|
40203
|
+
++i;
|
|
40204
|
+
}
|
|
40205
|
+
for (; i >= 0 && dt; --i) {
|
|
40206
|
+
var i2_3 = t2[i].s;
|
|
40207
|
+
if (tr[i2_3] == mb) {
|
|
40208
|
+
--tr[i2_3];
|
|
40209
|
+
++dt;
|
|
40210
|
+
}
|
|
40211
|
+
}
|
|
40212
|
+
mbt = mb;
|
|
40213
|
+
}
|
|
40214
|
+
return { t: new u8(tr), l: mbt };
|
|
40215
|
+
};
|
|
40216
|
+
var ln = function(n, l, d) {
|
|
40217
|
+
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
40218
|
+
};
|
|
40219
|
+
var lc = function(c) {
|
|
40220
|
+
var s = c.length;
|
|
40221
|
+
while (s && !c[--s])
|
|
40222
|
+
;
|
|
40223
|
+
var cl = new u16(++s);
|
|
40224
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
40225
|
+
var w = function(v) {
|
|
40226
|
+
cl[cli++] = v;
|
|
40227
|
+
};
|
|
40228
|
+
for (var i = 1; i <= s; ++i) {
|
|
40229
|
+
if (c[i] == cln && i != s)
|
|
40230
|
+
++cls;
|
|
40231
|
+
else {
|
|
40232
|
+
if (!cln && cls > 2) {
|
|
40233
|
+
for (; cls > 138; cls -= 138)
|
|
40234
|
+
w(32754);
|
|
40235
|
+
if (cls > 2) {
|
|
40236
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
40237
|
+
cls = 0;
|
|
40238
|
+
}
|
|
40239
|
+
} else if (cls > 3) {
|
|
40240
|
+
w(cln), --cls;
|
|
40241
|
+
for (; cls > 6; cls -= 6)
|
|
40242
|
+
w(8304);
|
|
40243
|
+
if (cls > 2)
|
|
40244
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
40245
|
+
}
|
|
40246
|
+
while (cls--)
|
|
40247
|
+
w(cln);
|
|
40248
|
+
cls = 1;
|
|
40249
|
+
cln = c[i];
|
|
40250
|
+
}
|
|
40251
|
+
}
|
|
40252
|
+
return { c: cl.subarray(0, cli), n: s };
|
|
40253
|
+
};
|
|
40254
|
+
var clen = function(cf, cl) {
|
|
40255
|
+
var l = 0;
|
|
40256
|
+
for (var i = 0; i < cl.length; ++i)
|
|
40257
|
+
l += cf[i] * cl[i];
|
|
40258
|
+
return l;
|
|
40259
|
+
};
|
|
40260
|
+
var wfblk = function(out, pos, dat) {
|
|
40261
|
+
var s = dat.length;
|
|
40262
|
+
var o = shft(pos + 2);
|
|
40263
|
+
out[o] = s & 255;
|
|
40264
|
+
out[o + 1] = s >> 8;
|
|
40265
|
+
out[o + 2] = out[o] ^ 255;
|
|
40266
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
40267
|
+
for (var i = 0; i < s; ++i)
|
|
40268
|
+
out[o + i + 4] = dat[i];
|
|
40269
|
+
return (o + 4 + s) * 8;
|
|
40270
|
+
};
|
|
40271
|
+
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
40272
|
+
wbits(out, p++, final);
|
|
40273
|
+
++lf[256];
|
|
40274
|
+
var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
|
|
40275
|
+
var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
|
|
40276
|
+
var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
|
|
40277
|
+
var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
|
|
40278
|
+
var lcfreq = new u16(19);
|
|
40279
|
+
for (var i = 0; i < lclt.length; ++i)
|
|
40280
|
+
++lcfreq[lclt[i] & 31];
|
|
40281
|
+
for (var i = 0; i < lcdt.length; ++i)
|
|
40282
|
+
++lcfreq[lcdt[i] & 31];
|
|
40283
|
+
var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
|
|
40284
|
+
var nlcc = 19;
|
|
40285
|
+
for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
40286
|
+
;
|
|
40287
|
+
var flen = bl + 5 << 3;
|
|
40288
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
40289
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
40290
|
+
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
|
|
40291
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
40292
|
+
var lm, ll, dm, dl;
|
|
40293
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
40294
|
+
if (dtlen < ftlen) {
|
|
40295
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
40296
|
+
var llm = hMap(lct, mlcb, 0);
|
|
40297
|
+
wbits(out, p, nlc - 257);
|
|
40298
|
+
wbits(out, p + 5, ndc - 1);
|
|
40299
|
+
wbits(out, p + 10, nlcc - 4);
|
|
40300
|
+
p += 14;
|
|
40301
|
+
for (var i = 0; i < nlcc; ++i)
|
|
40302
|
+
wbits(out, p + 3 * i, lct[clim[i]]);
|
|
40303
|
+
p += 3 * nlcc;
|
|
40304
|
+
var lcts = [lclt, lcdt];
|
|
40305
|
+
for (var it = 0; it < 2; ++it) {
|
|
40306
|
+
var clct = lcts[it];
|
|
40307
|
+
for (var i = 0; i < clct.length; ++i) {
|
|
40308
|
+
var len = clct[i] & 31;
|
|
40309
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
40310
|
+
if (len > 15)
|
|
40311
|
+
wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
|
|
40312
|
+
}
|
|
40313
|
+
}
|
|
40314
|
+
} else {
|
|
40315
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
40316
|
+
}
|
|
40317
|
+
for (var i = 0; i < li; ++i) {
|
|
40318
|
+
var sym = syms[i];
|
|
40319
|
+
if (sym > 255) {
|
|
40320
|
+
var len = sym >> 18 & 31;
|
|
40321
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
40322
|
+
if (len > 7)
|
|
40323
|
+
wbits(out, p, sym >> 23 & 31), p += fleb[len];
|
|
40324
|
+
var dst = sym & 31;
|
|
40325
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
40326
|
+
if (dst > 3)
|
|
40327
|
+
wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
|
|
40328
|
+
} else {
|
|
40329
|
+
wbits16(out, p, lm[sym]), p += ll[sym];
|
|
40330
|
+
}
|
|
40331
|
+
}
|
|
40332
|
+
wbits16(out, p, lm[256]);
|
|
40333
|
+
return p + ll[256];
|
|
40334
|
+
};
|
|
40335
|
+
var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
40336
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
40337
|
+
var dflt = function(dat, lvl, plvl, pre, post, st) {
|
|
40338
|
+
var s = st.z || dat.length;
|
|
40339
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
|
|
40340
|
+
var w = o.subarray(pre, o.length - post);
|
|
40341
|
+
var lst = st.l;
|
|
40342
|
+
var pos = (st.r || 0) & 7;
|
|
40343
|
+
if (lvl) {
|
|
40344
|
+
if (pos)
|
|
40345
|
+
w[0] = st.r >> 3;
|
|
40346
|
+
var opt = deo[lvl - 1];
|
|
40347
|
+
var n = opt >> 13, c = opt & 8191;
|
|
40348
|
+
var msk_1 = (1 << plvl) - 1;
|
|
40349
|
+
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
|
|
40350
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
40351
|
+
var hsh = function(i2) {
|
|
40352
|
+
return (dat[i2] ^ dat[i2 + 1] << bs1_1 ^ dat[i2 + 2] << bs2_1) & msk_1;
|
|
40353
|
+
};
|
|
40354
|
+
var syms = new i32(25e3);
|
|
40355
|
+
var lf = new u16(288), df = new u16(32);
|
|
40356
|
+
var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
|
|
40357
|
+
for (; i + 2 < s; ++i) {
|
|
40358
|
+
var hv = hsh(i);
|
|
40359
|
+
var imod = i & 32767, pimod = head[hv];
|
|
40360
|
+
prev[imod] = pimod;
|
|
40361
|
+
head[hv] = imod;
|
|
40362
|
+
if (wi <= i) {
|
|
40363
|
+
var rem = s - i;
|
|
40364
|
+
if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
|
|
40365
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
40366
|
+
li = lc_1 = eb = 0, bs = i;
|
|
40367
|
+
for (var j = 0; j < 286; ++j)
|
|
40368
|
+
lf[j] = 0;
|
|
40369
|
+
for (var j = 0; j < 30; ++j)
|
|
40370
|
+
df[j] = 0;
|
|
40371
|
+
}
|
|
40372
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
40373
|
+
if (rem > 2 && hv == hsh(i - dif)) {
|
|
40374
|
+
var maxn = Math.min(n, rem) - 1;
|
|
40375
|
+
var maxd = Math.min(32767, i);
|
|
40376
|
+
var ml = Math.min(258, rem);
|
|
40377
|
+
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
40378
|
+
if (dat[i + l] == dat[i + l - dif]) {
|
|
40379
|
+
var nl = 0;
|
|
40380
|
+
for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)
|
|
40381
|
+
;
|
|
40382
|
+
if (nl > l) {
|
|
40383
|
+
l = nl, d = dif;
|
|
40384
|
+
if (nl > maxn)
|
|
40385
|
+
break;
|
|
40386
|
+
var mmd = Math.min(dif, nl - 2);
|
|
40387
|
+
var md = 0;
|
|
40388
|
+
for (var j = 0; j < mmd; ++j) {
|
|
40389
|
+
var ti = i - dif + j & 32767;
|
|
40390
|
+
var pti = prev[ti];
|
|
40391
|
+
var cd = ti - pti & 32767;
|
|
40392
|
+
if (cd > md)
|
|
40393
|
+
md = cd, pimod = ti;
|
|
40394
|
+
}
|
|
40395
|
+
}
|
|
40396
|
+
}
|
|
40397
|
+
imod = pimod, pimod = prev[imod];
|
|
40398
|
+
dif += imod - pimod & 32767;
|
|
40399
|
+
}
|
|
40400
|
+
}
|
|
40401
|
+
if (d) {
|
|
40402
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
40403
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
40404
|
+
eb += fleb[lin] + fdeb[din];
|
|
40405
|
+
++lf[257 + lin];
|
|
40406
|
+
++df[din];
|
|
40407
|
+
wi = i + l;
|
|
40408
|
+
++lc_1;
|
|
40409
|
+
} else {
|
|
40410
|
+
syms[li++] = dat[i];
|
|
40411
|
+
++lf[dat[i]];
|
|
40412
|
+
}
|
|
40413
|
+
}
|
|
40414
|
+
}
|
|
40415
|
+
for (i = Math.max(i, wi); i < s; ++i) {
|
|
40416
|
+
syms[li++] = dat[i];
|
|
40417
|
+
++lf[dat[i]];
|
|
40418
|
+
}
|
|
40419
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
40420
|
+
if (!lst) {
|
|
40421
|
+
st.r = pos & 7 | w[pos / 8 | 0] << 3;
|
|
40422
|
+
pos -= 7;
|
|
40423
|
+
st.h = head, st.p = prev, st.i = i, st.w = wi;
|
|
40424
|
+
}
|
|
40425
|
+
} else {
|
|
40426
|
+
for (var i = st.w || 0; i < s + lst; i += 65535) {
|
|
40427
|
+
var e = i + 65535;
|
|
40428
|
+
if (e >= s) {
|
|
40429
|
+
w[pos / 8 | 0] = lst;
|
|
40430
|
+
e = s;
|
|
40431
|
+
}
|
|
40432
|
+
pos = wfblk(w, pos + 1, dat.subarray(i, e));
|
|
40433
|
+
}
|
|
40434
|
+
st.i = s;
|
|
40435
|
+
}
|
|
40436
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
40437
|
+
};
|
|
40438
|
+
var adler = function() {
|
|
40439
|
+
var a = 1, b = 0;
|
|
40440
|
+
return {
|
|
40441
|
+
p: function(d) {
|
|
40442
|
+
var n = a, m = b;
|
|
40443
|
+
var l = d.length | 0;
|
|
40444
|
+
for (var i = 0; i != l; ) {
|
|
40445
|
+
var e = Math.min(i + 2655, l);
|
|
40446
|
+
for (; i < e; ++i)
|
|
40447
|
+
m += n += d[i];
|
|
40448
|
+
n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
|
|
40449
|
+
}
|
|
40450
|
+
a = n, b = m;
|
|
40451
|
+
},
|
|
40452
|
+
d: function() {
|
|
40453
|
+
a %= 65521, b %= 65521;
|
|
40454
|
+
return (a & 255) << 24 | (a & 65280) << 8 | (b & 255) << 8 | b >> 8;
|
|
40455
|
+
}
|
|
40456
|
+
};
|
|
40457
|
+
};
|
|
40458
|
+
var dopt = function(dat, opt, pre, post, st) {
|
|
40459
|
+
if (!st) {
|
|
40460
|
+
st = { l: 1 };
|
|
40461
|
+
if (opt.dictionary) {
|
|
40462
|
+
var dict = opt.dictionary.subarray(-32768);
|
|
40463
|
+
var newDat = new u8(dict.length + dat.length);
|
|
40464
|
+
newDat.set(dict);
|
|
40465
|
+
newDat.set(dat, dict.length);
|
|
40466
|
+
dat = newDat;
|
|
40467
|
+
st.w = dict.length;
|
|
40468
|
+
}
|
|
40469
|
+
}
|
|
40470
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
|
|
40471
|
+
};
|
|
40472
|
+
var wbytes = function(d, b, v) {
|
|
40473
|
+
for (; v; ++b)
|
|
40474
|
+
d[b] = v, v >>>= 8;
|
|
40475
|
+
};
|
|
40476
|
+
var zlh = function(c, o) {
|
|
40477
|
+
var lv = o.level, fl2 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
|
|
40478
|
+
c[0] = 120, c[1] = fl2 << 6 | (o.dictionary && 32);
|
|
40479
|
+
c[1] |= 31 - (c[0] << 8 | c[1]) % 31;
|
|
40480
|
+
if (o.dictionary) {
|
|
40481
|
+
var h = adler();
|
|
40482
|
+
h.p(o.dictionary);
|
|
40483
|
+
wbytes(c, 2, h.d());
|
|
40484
|
+
}
|
|
40485
|
+
};
|
|
40486
|
+
function zlibSync(data, opts) {
|
|
40487
|
+
if (!opts)
|
|
40488
|
+
opts = {};
|
|
40489
|
+
var a = adler();
|
|
40490
|
+
a.p(data);
|
|
40491
|
+
var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);
|
|
40492
|
+
return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
|
|
40493
|
+
}
|
|
40494
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
|
|
40495
|
+
var tds = 0;
|
|
40496
|
+
try {
|
|
40497
|
+
td.decode(et, { stream: true });
|
|
40498
|
+
tds = 1;
|
|
40499
|
+
} catch (e) {
|
|
40500
|
+
}
|
|
40501
|
+
const utf8 = new TextEncoder();
|
|
40502
|
+
function chunkByteLength(chunk) {
|
|
40503
|
+
return typeof chunk === "string" ? byteLength(chunk) : chunk.length;
|
|
40504
|
+
}
|
|
40505
|
+
function concatChunks(chunks) {
|
|
40506
|
+
const total = chunks.reduce((sum, chunk) => sum + chunkByteLength(chunk), 0);
|
|
40507
|
+
const out = new Uint8Array(total);
|
|
40508
|
+
let offset = 0;
|
|
40509
|
+
for (const chunk of chunks) {
|
|
40510
|
+
const bytes = typeof chunk === "string" ? utf8.encode(chunk) : chunk;
|
|
40511
|
+
out.set(bytes, offset);
|
|
40512
|
+
offset += bytes.length;
|
|
40513
|
+
}
|
|
40514
|
+
return out;
|
|
40515
|
+
}
|
|
40516
|
+
function buildContentStreamObject(streamText) {
|
|
40517
|
+
const compressed = zlibSync(utf8.encode(streamText));
|
|
40518
|
+
return concatChunks([
|
|
40519
|
+
`<< /Length ${compressed.length} /Filter /FlateDecode >>
|
|
40520
|
+
stream
|
|
40521
|
+
`,
|
|
40522
|
+
compressed,
|
|
40523
|
+
"\nendstream"
|
|
40524
|
+
]);
|
|
40525
|
+
}
|
|
40526
|
+
function encodePdfLiteralString(value) {
|
|
40527
|
+
return value.replace(/[\\()]/g, (char) => `\\${char}`);
|
|
40528
|
+
}
|
|
40529
|
+
function encodePdfTextString(value) {
|
|
40530
|
+
const codePoints = Array.from(value).map((ch) => ch.codePointAt(0) ?? 63);
|
|
40531
|
+
return `<FEFF${encodePdfUtf16Hex(codePoints)}>`;
|
|
40532
|
+
}
|
|
40533
|
+
function formatPdfDate(date) {
|
|
40534
|
+
const pad = (n, width = 2) => String(n).padStart(width, "0");
|
|
40535
|
+
return `D:${date.getUTCFullYear()}${pad(date.getUTCMonth() + 1)}${pad(date.getUTCDate())}${pad(date.getUTCHours())}${pad(date.getUTCMinutes())}${pad(date.getUTCSeconds())}+00'00'`;
|
|
40536
|
+
}
|
|
40537
|
+
function buildDocumentInfoBody(info) {
|
|
40538
|
+
const entries = [];
|
|
40539
|
+
if (info.title) entries.push(`/Title ${encodePdfTextString(info.title)}`);
|
|
40540
|
+
if (info.author) entries.push(`/Author ${encodePdfTextString(info.author)}`);
|
|
40541
|
+
if (info.subject) entries.push(`/Subject ${encodePdfTextString(info.subject)}`);
|
|
40542
|
+
if (info.keywords)
|
|
40543
|
+
entries.push(`/Keywords ${encodePdfTextString(info.keywords)}`);
|
|
40544
|
+
if (info.producer)
|
|
40545
|
+
entries.push(`/Producer (${encodePdfLiteralString(info.producer)})`);
|
|
40546
|
+
if (info.creationDate)
|
|
40547
|
+
entries.push(`/CreationDate (${formatPdfDate(info.creationDate)})`);
|
|
40548
|
+
if (entries.length === 0) {
|
|
40549
|
+
return void 0;
|
|
40550
|
+
}
|
|
40551
|
+
return `<< ${entries.join(" ")} >>`;
|
|
40552
|
+
}
|
|
40553
|
+
function buildOutlineTree(items) {
|
|
40554
|
+
const roots = [];
|
|
40555
|
+
const stack = [];
|
|
40556
|
+
for (const item of items) {
|
|
40557
|
+
const node = {
|
|
40558
|
+
title: item.title,
|
|
40559
|
+
destName: item.destName,
|
|
40560
|
+
children: []
|
|
40561
|
+
};
|
|
40562
|
+
while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
|
|
40563
|
+
stack.pop();
|
|
40564
|
+
}
|
|
40565
|
+
if (stack.length === 0) {
|
|
40566
|
+
roots.push(node);
|
|
40567
|
+
} else {
|
|
40568
|
+
stack[stack.length - 1].node.children.push(node);
|
|
40569
|
+
}
|
|
40570
|
+
stack.push({ node, level: item.level });
|
|
40571
|
+
}
|
|
40572
|
+
return roots;
|
|
40573
|
+
}
|
|
40574
|
+
function countOutlineDescendants(node) {
|
|
40575
|
+
return node.children.reduce(
|
|
40576
|
+
(total, child) => total + 1 + countOutlineDescendants(child),
|
|
40577
|
+
0
|
|
40578
|
+
);
|
|
40579
|
+
}
|
|
40580
|
+
function serializePdfDocument(pages, fonts, images, shadings, namedDestinations = [], outlineItems = [], documentInfo) {
|
|
39481
40581
|
const objects = [];
|
|
39482
|
-
const addObject = (
|
|
40582
|
+
const addObject = (body) => {
|
|
39483
40583
|
const id = objects.length + 1;
|
|
39484
|
-
objects.push({ id, body
|
|
40584
|
+
objects.push({ id, body });
|
|
39485
40585
|
return id;
|
|
39486
40586
|
};
|
|
39487
40587
|
const catalogObjectId = addObject("");
|
|
@@ -39493,11 +40593,7 @@ function serializePdfDocument(pages, fonts, images, shadings) {
|
|
|
39493
40593
|
for (const page of pages) {
|
|
39494
40594
|
const stream = `${page.commands.join("\n")}
|
|
39495
40595
|
`;
|
|
39496
|
-
const contentObjectId = addObject(
|
|
39497
|
-
`<< /Length ${byteLength(stream)} >>
|
|
39498
|
-
stream
|
|
39499
|
-
${stream}endstream`
|
|
39500
|
-
);
|
|
40596
|
+
const contentObjectId = addObject(buildContentStreamObject(stream));
|
|
39501
40597
|
const imageResourceXml = Array.from(page.imageResourceNames).map((resourceName) => {
|
|
39502
40598
|
const objectId = imageObjectIds.get(resourceName);
|
|
39503
40599
|
return objectId ? `/${resourceName} ${objectId} 0 R` : "";
|
|
@@ -39508,52 +40604,153 @@ ${stream}endstream`
|
|
|
39508
40604
|
return objectId ? `/${resourceName} ${objectId} 0 R` : "";
|
|
39509
40605
|
}).filter(Boolean).join(" ");
|
|
39510
40606
|
const shadingResourceDictXml = shadingResourceXml ? ` /Shading << ${shadingResourceXml} >>` : "";
|
|
40607
|
+
const annotationObjectIds = page.annotations.map((annotation) => {
|
|
40608
|
+
const x1 = annotation.x;
|
|
40609
|
+
const x2 = annotation.x + annotation.width;
|
|
40610
|
+
const y1 = page.height - annotation.y - annotation.height;
|
|
40611
|
+
const y2 = page.height - annotation.y;
|
|
40612
|
+
const action = annotation.destName !== void 0 ? `/A << /Type /Action /S /GoTo /D (${encodePdfLiteralString(annotation.destName)}) >>` : `/A << /Type /Action /S /URI /URI (${encodePdfLiteralString(annotation.uri ?? "")}) >>`;
|
|
40613
|
+
return addObject(
|
|
40614
|
+
[
|
|
40615
|
+
"<< /Type /Annot /Subtype /Link",
|
|
40616
|
+
`/Rect [${formatNumber(x1)} ${formatNumber(y1)} ${formatNumber(x2)} ${formatNumber(y2)}]`,
|
|
40617
|
+
"/Border [0 0 0]",
|
|
40618
|
+
action,
|
|
40619
|
+
">>"
|
|
40620
|
+
].join("\n")
|
|
40621
|
+
);
|
|
40622
|
+
});
|
|
40623
|
+
const annotsXml = annotationObjectIds.length > 0 ? `
|
|
40624
|
+
/Annots [${annotationObjectIds.map((id) => `${id} 0 R`).join(" ")}]` : "";
|
|
39511
40625
|
const pageObjectId = addObject(
|
|
39512
40626
|
[
|
|
39513
40627
|
"<< /Type /Page",
|
|
39514
40628
|
`/Parent ${pagesObjectId} 0 R`,
|
|
39515
40629
|
`/MediaBox [0 0 ${formatNumber(page.width)} ${formatNumber(page.height)}]`,
|
|
39516
40630
|
`/Resources << /Font << ${fontResourceXml} >>${xObjectResourceXml}${shadingResourceDictXml} >>`,
|
|
39517
|
-
`/Contents ${contentObjectId} 0 R`,
|
|
40631
|
+
`/Contents ${contentObjectId} 0 R${annotsXml}`,
|
|
39518
40632
|
">>"
|
|
39519
40633
|
].join("\n")
|
|
39520
40634
|
);
|
|
39521
40635
|
pageObjectIds.push(pageObjectId);
|
|
39522
40636
|
}
|
|
39523
|
-
|
|
40637
|
+
let namesObjectId;
|
|
40638
|
+
const resolvedDestinations = namedDestinations.filter((dest) => pageObjectIds[dest.pageIndex] !== void 0).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
40639
|
+
if (resolvedDestinations.length > 0) {
|
|
40640
|
+
const namesArray = resolvedDestinations.map((dest) => {
|
|
40641
|
+
const pageObjectId = pageObjectIds[dest.pageIndex];
|
|
40642
|
+
const pageHeight = pages[dest.pageIndex].height;
|
|
40643
|
+
const top = pageHeight - dest.y;
|
|
40644
|
+
return `(${encodePdfLiteralString(dest.name)}) [${pageObjectId} 0 R /XYZ ${formatNumber(dest.x)} ${formatNumber(top)} null]`;
|
|
40645
|
+
}).join(" ");
|
|
40646
|
+
const destsObjectId = addObject(`<< /Names [${namesArray}] >>`);
|
|
40647
|
+
namesObjectId = addObject(`<< /Dests ${destsObjectId} 0 R >>`);
|
|
40648
|
+
}
|
|
40649
|
+
let outlineRootId;
|
|
40650
|
+
const resolvedNames = new Set(resolvedDestinations.map((dest) => dest.name));
|
|
40651
|
+
const outlineRoots = buildOutlineTree(
|
|
40652
|
+
outlineItems.filter((item) => resolvedNames.has(item.destName))
|
|
40653
|
+
);
|
|
40654
|
+
if (outlineRoots.length > 0) {
|
|
40655
|
+
outlineRootId = addObject("");
|
|
40656
|
+
const assignIds = (nodes) => nodes.map((node) => {
|
|
40657
|
+
const id = addObject("");
|
|
40658
|
+
node.id = id;
|
|
40659
|
+
node.childIds = assignIds(node.children);
|
|
40660
|
+
return id;
|
|
40661
|
+
});
|
|
40662
|
+
const rootIds = assignIds(outlineRoots);
|
|
40663
|
+
const emit = (nodes, parentId) => {
|
|
40664
|
+
nodes.forEach((node, index) => {
|
|
40665
|
+
const self = node;
|
|
40666
|
+
const prev = index > 0 ? nodes[index - 1] : void 0;
|
|
40667
|
+
const next = index < nodes.length - 1 ? nodes[index + 1] : void 0;
|
|
40668
|
+
const lines = [
|
|
40669
|
+
"<< /Title " + encodePdfTextString(node.title),
|
|
40670
|
+
`/Parent ${parentId} 0 R`,
|
|
40671
|
+
prev ? `/Prev ${prev.id} 0 R` : "",
|
|
40672
|
+
next ? `/Next ${next.id} 0 R` : "",
|
|
40673
|
+
`/Dest (${encodePdfLiteralString(node.destName)})`
|
|
40674
|
+
];
|
|
40675
|
+
if (self.childIds.length > 0) {
|
|
40676
|
+
lines.push(`/First ${self.childIds[0]} 0 R`);
|
|
40677
|
+
lines.push(`/Last ${self.childIds[self.childIds.length - 1]} 0 R`);
|
|
40678
|
+
lines.push(`/Count ${countOutlineDescendants(node)}`);
|
|
40679
|
+
}
|
|
40680
|
+
lines.push(">>");
|
|
40681
|
+
objects[self.id - 1].body = lines.filter(Boolean).join("\n");
|
|
40682
|
+
emit(node.children, self.id);
|
|
40683
|
+
});
|
|
40684
|
+
};
|
|
40685
|
+
emit(outlineRoots, outlineRootId);
|
|
40686
|
+
const totalItems = outlineItems.filter(
|
|
40687
|
+
(item) => resolvedNames.has(item.destName)
|
|
40688
|
+
).length;
|
|
40689
|
+
objects[outlineRootId - 1].body = [
|
|
40690
|
+
"<< /Type /Outlines",
|
|
40691
|
+
`/First ${rootIds[0]} 0 R`,
|
|
40692
|
+
`/Last ${rootIds[rootIds.length - 1]} 0 R`,
|
|
40693
|
+
`/Count ${totalItems}`,
|
|
40694
|
+
">>"
|
|
40695
|
+
].join("\n");
|
|
40696
|
+
}
|
|
40697
|
+
objects[catalogObjectId - 1].body = [
|
|
40698
|
+
"<< /Type /Catalog",
|
|
40699
|
+
`/Pages ${pagesObjectId} 0 R`,
|
|
40700
|
+
namesObjectId !== void 0 ? `/Names ${namesObjectId} 0 R` : "",
|
|
40701
|
+
outlineRootId !== void 0 ? `/Outlines ${outlineRootId} 0 R` : "",
|
|
40702
|
+
outlineRootId !== void 0 ? "/PageMode /UseOutlines" : "",
|
|
40703
|
+
">>"
|
|
40704
|
+
].filter(Boolean).join("\n");
|
|
39524
40705
|
objects[pagesObjectId - 1].body = [
|
|
39525
40706
|
"<< /Type /Pages",
|
|
39526
40707
|
`/Kids [${pageObjectIds.map((id) => `${id} 0 R`).join(" ")}]`,
|
|
39527
40708
|
`/Count ${pageObjectIds.length}`,
|
|
39528
40709
|
">>"
|
|
39529
40710
|
].join("\n");
|
|
39530
|
-
let
|
|
40711
|
+
let infoObjectId;
|
|
40712
|
+
if (documentInfo) {
|
|
40713
|
+
const infoBody = buildDocumentInfoBody(documentInfo);
|
|
40714
|
+
if (infoBody) {
|
|
40715
|
+
infoObjectId = addObject(infoBody);
|
|
40716
|
+
}
|
|
40717
|
+
}
|
|
40718
|
+
const chunks = [PDF_HEADER];
|
|
40719
|
+
let offset = chunkByteLength(PDF_HEADER);
|
|
39531
40720
|
const offsets = [0];
|
|
40721
|
+
const push = (chunk) => {
|
|
40722
|
+
chunks.push(chunk);
|
|
40723
|
+
offset += chunkByteLength(chunk);
|
|
40724
|
+
};
|
|
39532
40725
|
for (const object of objects) {
|
|
39533
|
-
offsets[object.id] =
|
|
39534
|
-
|
|
39535
|
-
|
|
39536
|
-
|
|
39537
|
-
|
|
39538
|
-
}
|
|
39539
|
-
const xrefOffset =
|
|
39540
|
-
|
|
40726
|
+
offsets[object.id] = offset;
|
|
40727
|
+
push(`${object.id} 0 obj
|
|
40728
|
+
`);
|
|
40729
|
+
push(object.body);
|
|
40730
|
+
push("\nendobj\n");
|
|
40731
|
+
}
|
|
40732
|
+
const xrefOffset = offset;
|
|
40733
|
+
let xref = `xref
|
|
39541
40734
|
0 ${objects.length + 1}
|
|
39542
40735
|
`;
|
|
39543
|
-
|
|
40736
|
+
xref += "0000000000 65535 f \n";
|
|
39544
40737
|
for (const object of objects) {
|
|
39545
|
-
|
|
40738
|
+
xref += `${String(offsets[object.id] ?? 0).padStart(10, "0")} 00000 n
|
|
39546
40739
|
`;
|
|
39547
40740
|
}
|
|
39548
|
-
|
|
39549
|
-
|
|
39550
|
-
|
|
39551
|
-
|
|
39552
|
-
|
|
39553
|
-
|
|
39554
|
-
|
|
39555
|
-
|
|
39556
|
-
|
|
40741
|
+
push(xref);
|
|
40742
|
+
const infoTrailerXml = infoObjectId !== void 0 ? ` /Info ${infoObjectId} 0 R` : "";
|
|
40743
|
+
push(
|
|
40744
|
+
[
|
|
40745
|
+
"trailer",
|
|
40746
|
+
`<< /Size ${objects.length + 1} /Root ${catalogObjectId} 0 R${infoTrailerXml} >>`,
|
|
40747
|
+
"startxref",
|
|
40748
|
+
String(xrefOffset),
|
|
40749
|
+
"%%EOF",
|
|
40750
|
+
""
|
|
40751
|
+
].join("\n")
|
|
40752
|
+
);
|
|
40753
|
+
return concatChunks(chunks);
|
|
39557
40754
|
}
|
|
39558
40755
|
class OasisPdfWriter {
|
|
39559
40756
|
constructor(fontResources = DEFAULT_PDF_FONT_RESOURCES) {
|
|
@@ -39562,6 +40759,9 @@ class OasisPdfWriter {
|
|
|
39562
40759
|
__publicField(this, "fonts");
|
|
39563
40760
|
__publicField(this, "images", new PdfImageTable());
|
|
39564
40761
|
__publicField(this, "shadings", new PdfShadingTable());
|
|
40762
|
+
__publicField(this, "namedDestinations", []);
|
|
40763
|
+
__publicField(this, "outlineItems", []);
|
|
40764
|
+
__publicField(this, "documentInfo");
|
|
39565
40765
|
this.fonts = new PdfFontTable(fontResources);
|
|
39566
40766
|
}
|
|
39567
40767
|
registerFontResource(resource) {
|
|
@@ -39573,7 +40773,8 @@ class OasisPdfWriter {
|
|
|
39573
40773
|
height: Math.max(1, size.height),
|
|
39574
40774
|
commands: [],
|
|
39575
40775
|
imageResourceNames: /* @__PURE__ */ new Set(),
|
|
39576
|
-
shadingResourceNames: /* @__PURE__ */ new Set()
|
|
40776
|
+
shadingResourceNames: /* @__PURE__ */ new Set(),
|
|
40777
|
+
annotations: []
|
|
39577
40778
|
};
|
|
39578
40779
|
this.pages.push(page);
|
|
39579
40780
|
this.streams.push(
|
|
@@ -39585,36 +40786,36 @@ class OasisPdfWriter {
|
|
|
39585
40786
|
return this.pages.length;
|
|
39586
40787
|
}
|
|
39587
40788
|
drawRect(pageIndex, options) {
|
|
39588
|
-
var
|
|
39589
|
-
(
|
|
40789
|
+
var _a2;
|
|
40790
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawRect(options);
|
|
39590
40791
|
}
|
|
39591
40792
|
drawLine(pageIndex, options) {
|
|
39592
|
-
var
|
|
39593
|
-
(
|
|
40793
|
+
var _a2;
|
|
40794
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawLine(options);
|
|
39594
40795
|
}
|
|
39595
40796
|
drawPath(pageIndex, options) {
|
|
39596
|
-
var
|
|
39597
|
-
(
|
|
40797
|
+
var _a2;
|
|
40798
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawPath(options);
|
|
39598
40799
|
}
|
|
39599
40800
|
saveGraphicsState(pageIndex) {
|
|
39600
|
-
var
|
|
39601
|
-
(
|
|
40801
|
+
var _a2;
|
|
40802
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.saveGraphicsState();
|
|
39602
40803
|
}
|
|
39603
40804
|
restoreGraphicsState(pageIndex) {
|
|
39604
|
-
var
|
|
39605
|
-
(
|
|
40805
|
+
var _a2;
|
|
40806
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.restoreGraphicsState();
|
|
39606
40807
|
}
|
|
39607
40808
|
rotateAbout(pageIndex, centerX, centerY, degrees) {
|
|
39608
|
-
var
|
|
39609
|
-
(
|
|
40809
|
+
var _a2;
|
|
40810
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.rotateAbout(centerX, centerY, degrees);
|
|
39610
40811
|
}
|
|
39611
40812
|
clipRect(pageIndex, x, y, width, height) {
|
|
39612
|
-
var
|
|
39613
|
-
(
|
|
40813
|
+
var _a2;
|
|
40814
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.clipRect(x, y, width, height);
|
|
39614
40815
|
}
|
|
39615
40816
|
drawText(pageIndex, options) {
|
|
39616
|
-
var
|
|
39617
|
-
(
|
|
40817
|
+
var _a2;
|
|
40818
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawText(options);
|
|
39618
40819
|
}
|
|
39619
40820
|
/**
|
|
39620
40821
|
* Registers an axial (linear) gradient on a page for use as a glyph fill, and
|
|
@@ -39622,15 +40823,45 @@ class OasisPdfWriter {
|
|
|
39622
40823
|
* subsequent `drawText`. Coordinates are in the writer's top-left point space.
|
|
39623
40824
|
*/
|
|
39624
40825
|
registerAxialGradient(pageIndex, gradient) {
|
|
39625
|
-
var
|
|
39626
|
-
return ((
|
|
40826
|
+
var _a2;
|
|
40827
|
+
return ((_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.registerAxialGradient(gradient)) ?? null;
|
|
39627
40828
|
}
|
|
39628
40829
|
registerImageResource(resource) {
|
|
39629
40830
|
return this.images.registerImageResource(resource);
|
|
39630
40831
|
}
|
|
39631
40832
|
drawImage(pageIndex, options) {
|
|
39632
|
-
var
|
|
39633
|
-
(
|
|
40833
|
+
var _a2;
|
|
40834
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawImage(options);
|
|
40835
|
+
}
|
|
40836
|
+
/**
|
|
40837
|
+
* Attaches a clickable external link annotation to a page. The rect is in the
|
|
40838
|
+
* writer's top-left point space; the serializer flips it to PDF space.
|
|
40839
|
+
*/
|
|
40840
|
+
addLinkAnnotation(pageIndex, annotation) {
|
|
40841
|
+
var _a2;
|
|
40842
|
+
(_a2 = this.pages[pageIndex]) == null ? void 0 : _a2.annotations.push(annotation);
|
|
40843
|
+
}
|
|
40844
|
+
/**
|
|
40845
|
+
* Registers a named destination (jump target). Position is in the writer's
|
|
40846
|
+
* top-left point space. The first registration of a given name wins; later
|
|
40847
|
+
* duplicates are ignored so destinations stay unique in the names tree.
|
|
40848
|
+
*/
|
|
40849
|
+
addNamedDestination(destination) {
|
|
40850
|
+
if (this.namedDestinations.some((d) => d.name === destination.name)) {
|
|
40851
|
+
return;
|
|
40852
|
+
}
|
|
40853
|
+
this.namedDestinations.push(destination);
|
|
40854
|
+
}
|
|
40855
|
+
/**
|
|
40856
|
+
* Appends an outline (bookmarks-panel) entry. Call in document order; the
|
|
40857
|
+
* serializer nests entries by `level`.
|
|
40858
|
+
*/
|
|
40859
|
+
addOutlineItem(item) {
|
|
40860
|
+
this.outlineItems.push(item);
|
|
40861
|
+
}
|
|
40862
|
+
/** Sets the document information dictionary (`/Info`). */
|
|
40863
|
+
setDocumentInfo(info) {
|
|
40864
|
+
this.documentInfo = info;
|
|
39634
40865
|
}
|
|
39635
40866
|
toArrayBuffer() {
|
|
39636
40867
|
const bytes = this.toUint8Array();
|
|
@@ -39647,11 +40878,69 @@ class OasisPdfWriter {
|
|
|
39647
40878
|
this.pages,
|
|
39648
40879
|
this.fonts,
|
|
39649
40880
|
this.images,
|
|
39650
|
-
this.shadings
|
|
40881
|
+
this.shadings,
|
|
40882
|
+
this.namedDestinations,
|
|
40883
|
+
this.outlineItems,
|
|
40884
|
+
this.documentInfo
|
|
39651
40885
|
);
|
|
39652
40886
|
}
|
|
39653
40887
|
}
|
|
39654
40888
|
const FOOTNOTE_BLOCK_GAP_PX = 2;
|
|
40889
|
+
const PDF_PRODUCER = "Oasis Editor";
|
|
40890
|
+
function resolveDocumentInfo(document2) {
|
|
40891
|
+
const metadata = document2.metadata ?? {};
|
|
40892
|
+
const asString = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
40893
|
+
return {
|
|
40894
|
+
title: asString(metadata.title),
|
|
40895
|
+
author: asString(metadata.author),
|
|
40896
|
+
subject: asString(metadata.subject),
|
|
40897
|
+
keywords: asString(metadata.keywords),
|
|
40898
|
+
producer: PDF_PRODUCER,
|
|
40899
|
+
creationDate: /* @__PURE__ */ new Date()
|
|
40900
|
+
};
|
|
40901
|
+
}
|
|
40902
|
+
function collectBookmarkNamesByParagraph(document2) {
|
|
40903
|
+
var _a2;
|
|
40904
|
+
const byParagraph = /* @__PURE__ */ new Map();
|
|
40905
|
+
const bookmarks = document2.bookmarks;
|
|
40906
|
+
if (!bookmarks) {
|
|
40907
|
+
return byParagraph;
|
|
40908
|
+
}
|
|
40909
|
+
for (const id of bookmarks.order) {
|
|
40910
|
+
const bookmark = bookmarks.items[id];
|
|
40911
|
+
const paragraphId = (_a2 = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _a2.paragraphId;
|
|
40912
|
+
if (!bookmark || !paragraphId) {
|
|
40913
|
+
continue;
|
|
40914
|
+
}
|
|
40915
|
+
const names = byParagraph.get(paragraphId) ?? [];
|
|
40916
|
+
names.push(bookmark.name);
|
|
40917
|
+
byParagraph.set(paragraphId, names);
|
|
40918
|
+
}
|
|
40919
|
+
return byParagraph;
|
|
40920
|
+
}
|
|
40921
|
+
const HEADING_DEST_PREFIX = "__oasis_heading_";
|
|
40922
|
+
function registerBookmarkDestinations(writer, pageIndex, originX, bookmarkNamesByParagraph, headingByParagraph) {
|
|
40923
|
+
if (bookmarkNamesByParagraph.size === 0 && headingByParagraph.size === 0) {
|
|
40924
|
+
return void 0;
|
|
40925
|
+
}
|
|
40926
|
+
return (paragraphId, topPx) => {
|
|
40927
|
+
const y = pxToPt$1(topPx);
|
|
40928
|
+
const x = pxToPt$1(originX);
|
|
40929
|
+
for (const name of bookmarkNamesByParagraph.get(paragraphId) ?? []) {
|
|
40930
|
+
writer.addNamedDestination({ name, pageIndex, x, y });
|
|
40931
|
+
}
|
|
40932
|
+
const heading = headingByParagraph.get(paragraphId);
|
|
40933
|
+
if (heading) {
|
|
40934
|
+
const destName = `${HEADING_DEST_PREFIX}${paragraphId}`;
|
|
40935
|
+
writer.addNamedDestination({ name: destName, pageIndex, x, y });
|
|
40936
|
+
writer.addOutlineItem({
|
|
40937
|
+
title: heading.title,
|
|
40938
|
+
level: heading.level,
|
|
40939
|
+
destName
|
|
40940
|
+
});
|
|
40941
|
+
}
|
|
40942
|
+
};
|
|
40943
|
+
}
|
|
39655
40944
|
async function exportEditorDocumentToPdf(document2) {
|
|
39656
40945
|
document2 = renumberImageCaptionsInDocument(document2);
|
|
39657
40946
|
const fontRegistry = new PdfFontRegistry();
|
|
@@ -39659,8 +40948,16 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
39659
40948
|
families: collectPdfFontFamilies(document2)
|
|
39660
40949
|
});
|
|
39661
40950
|
const writer = new OasisPdfWriter(fontRegistry.getPdfFontResources());
|
|
40951
|
+
writer.setDocumentInfo(resolveDocumentInfo(document2));
|
|
39662
40952
|
const layout = projectDocumentLayout(document2);
|
|
39663
40953
|
const listOrdinals = getListOrdinals(document2);
|
|
40954
|
+
const bookmarkNamesByParagraph = collectBookmarkNamesByParagraph(document2);
|
|
40955
|
+
const headingByParagraph = new Map(
|
|
40956
|
+
outlineFrom(document2).map((item) => [
|
|
40957
|
+
item.id,
|
|
40958
|
+
{ level: item.level, title: item.text }
|
|
40959
|
+
])
|
|
40960
|
+
);
|
|
39664
40961
|
for (const page of layout.pages) {
|
|
39665
40962
|
const width = Math.max(1, pxToPt$1(page.pageSettings.width));
|
|
39666
40963
|
const height = Math.max(1, pxToPt$1(page.pageSettings.height));
|
|
@@ -39705,7 +41002,14 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
39705
41002
|
rect.width,
|
|
39706
41003
|
fontRegistry,
|
|
39707
41004
|
listOrdinals,
|
|
39708
|
-
page.pageSettings
|
|
41005
|
+
page.pageSettings,
|
|
41006
|
+
registerBookmarkDestinations(
|
|
41007
|
+
writer,
|
|
41008
|
+
pageIndex,
|
|
41009
|
+
rect.left,
|
|
41010
|
+
bookmarkNamesByParagraph,
|
|
41011
|
+
headingByParagraph
|
|
41012
|
+
)
|
|
39709
41013
|
);
|
|
39710
41014
|
}
|
|
39711
41015
|
} else {
|
|
@@ -39719,7 +41023,14 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
39719
41023
|
contentWidth,
|
|
39720
41024
|
fontRegistry,
|
|
39721
41025
|
listOrdinals,
|
|
39722
|
-
page.pageSettings
|
|
41026
|
+
page.pageSettings,
|
|
41027
|
+
registerBookmarkDestinations(
|
|
41028
|
+
writer,
|
|
41029
|
+
pageIndex,
|
|
41030
|
+
originX,
|
|
41031
|
+
bookmarkNamesByParagraph,
|
|
41032
|
+
headingByParagraph
|
|
41033
|
+
)
|
|
39723
41034
|
);
|
|
39724
41035
|
}
|
|
39725
41036
|
await drawBlockList(
|
|
@@ -39770,15 +41081,15 @@ async function exportEditorDocumentToPdfBlob(document2) {
|
|
|
39770
41081
|
return new Blob([buffer], { type: "application/pdf" });
|
|
39771
41082
|
}
|
|
39772
41083
|
async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenceIds, document2, originX, originY, contentWidth, fontRegistry, listOrdinals) {
|
|
39773
|
-
var
|
|
41084
|
+
var _a2;
|
|
39774
41085
|
let cursorY = originY;
|
|
39775
41086
|
const markerDrawn = /* @__PURE__ */ new Set();
|
|
39776
41087
|
const markerByFootnoteId = new Map(
|
|
39777
41088
|
footnoteReferenceIds.map((footnoteId) => {
|
|
39778
|
-
var
|
|
41089
|
+
var _a3;
|
|
39779
41090
|
return [
|
|
39780
41091
|
footnoteId,
|
|
39781
|
-
((
|
|
41092
|
+
((_a3 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a3.run.text) ?? ""
|
|
39782
41093
|
];
|
|
39783
41094
|
})
|
|
39784
41095
|
);
|
|
@@ -39792,7 +41103,7 @@ async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenc
|
|
|
39792
41103
|
const firstParagraph = block.sourceBlock.type === "paragraph" ? block.sourceBlock : void 0;
|
|
39793
41104
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
39794
41105
|
void 0,
|
|
39795
|
-
(
|
|
41106
|
+
(_a2 = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a2.styleId,
|
|
39796
41107
|
document2.styles
|
|
39797
41108
|
);
|
|
39798
41109
|
const fontFace = fontRegistry.resolveFontFace({
|
|
@@ -39891,7 +41202,7 @@ function findImageFileFromTransfer(transfer) {
|
|
|
39891
41202
|
return null;
|
|
39892
41203
|
}
|
|
39893
41204
|
function buildImportedDocumentDiagnostics(document2) {
|
|
39894
|
-
var
|
|
41205
|
+
var _a2;
|
|
39895
41206
|
const paragraphs = getDocumentParagraphs(document2);
|
|
39896
41207
|
const fontCounts = /* @__PURE__ */ new Map();
|
|
39897
41208
|
const alignCounts = /* @__PURE__ */ new Map();
|
|
@@ -39909,7 +41220,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
39909
41220
|
for (const run of paragraph.runs) {
|
|
39910
41221
|
const textStyle = resolveEffectiveTextStyleForParagraph(
|
|
39911
41222
|
run.styles,
|
|
39912
|
-
(
|
|
41223
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
39913
41224
|
document2.styles
|
|
39914
41225
|
);
|
|
39915
41226
|
const fontFamily = textStyle.fontFamily ?? "<null>";
|
|
@@ -39929,7 +41240,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
39929
41240
|
characterSpacingRuns,
|
|
39930
41241
|
characterScaleRuns,
|
|
39931
41242
|
firstParagraphs: paragraphs.slice(0, 30).map((paragraph, index) => {
|
|
39932
|
-
var
|
|
41243
|
+
var _a3;
|
|
39933
41244
|
const paragraphStyle = resolveEffectiveParagraphStyle(
|
|
39934
41245
|
paragraph.style,
|
|
39935
41246
|
document2.styles
|
|
@@ -39937,7 +41248,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
39937
41248
|
const firstRun = paragraph.runs[0];
|
|
39938
41249
|
const textStyle = resolveEffectiveTextStyleForParagraph(
|
|
39939
41250
|
firstRun == null ? void 0 : firstRun.styles,
|
|
39940
|
-
(
|
|
41251
|
+
(_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
|
|
39941
41252
|
document2.styles
|
|
39942
41253
|
);
|
|
39943
41254
|
return {
|
|
@@ -40028,8 +41339,8 @@ function createDocumentImporter(deps) {
|
|
|
40028
41339
|
const sections = getDocumentSectionsCanonical(document2);
|
|
40029
41340
|
const canonicalBlocks = sections.reduce(
|
|
40030
41341
|
(total, section) => {
|
|
40031
|
-
var
|
|
40032
|
-
return total + (((
|
|
41342
|
+
var _a2, _b2;
|
|
41343
|
+
return total + (((_a2 = section.header) == null ? void 0 : _a2.length) ?? 0) + section.blocks.length + (((_b2 = section.footer) == null ? void 0 : _b2.length) ?? 0);
|
|
40033
41344
|
},
|
|
40034
41345
|
0
|
|
40035
41346
|
);
|
|
@@ -40130,8 +41441,8 @@ function applyMoveWithText(floating, fixed) {
|
|
|
40130
41441
|
};
|
|
40131
41442
|
}
|
|
40132
41443
|
function isFloatingFixedPosition(floating) {
|
|
40133
|
-
var
|
|
40134
|
-
return ((
|
|
41444
|
+
var _a2;
|
|
41445
|
+
return ((_a2 = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a2.relativeFrom) === "page";
|
|
40135
41446
|
}
|
|
40136
41447
|
function getSelectedImageRun(state) {
|
|
40137
41448
|
return getSelectedObjectRun(state, (run) => run.kind === "image");
|
|
@@ -40697,7 +42008,7 @@ function resolveCaretSlot(paragraphs, focusOffset) {
|
|
|
40697
42008
|
};
|
|
40698
42009
|
}
|
|
40699
42010
|
function computeCanvasSelectionGeometry(snapshot, state) {
|
|
40700
|
-
var
|
|
42011
|
+
var _a2, _b2, _c, _d;
|
|
40701
42012
|
const normalized = normalizeSelection(state);
|
|
40702
42013
|
const selectionBoxes = [];
|
|
40703
42014
|
const surfaceRect = snapshot.surfaceRect;
|
|
@@ -40760,9 +42071,9 @@ function computeCanvasSelectionGeometry(snapshot, state) {
|
|
|
40760
42071
|
const section = sections[activeSectionIndex];
|
|
40761
42072
|
let tableBlock;
|
|
40762
42073
|
if (anchorLoc.zone === "header") {
|
|
40763
|
-
tableBlock = (
|
|
42074
|
+
tableBlock = (_a2 = section == null ? void 0 : section.header) == null ? void 0 : _a2[anchorLoc.blockIndex];
|
|
40764
42075
|
} else if (anchorLoc.zone === "footer") {
|
|
40765
|
-
tableBlock = (
|
|
42076
|
+
tableBlock = (_b2 = section == null ? void 0 : section.footer) == null ? void 0 : _b2[anchorLoc.blockIndex];
|
|
40766
42077
|
} else {
|
|
40767
42078
|
tableBlock = (_c = section == null ? void 0 : section.blocks) == null ? void 0 : _c[anchorLoc.blockIndex];
|
|
40768
42079
|
}
|
|
@@ -40947,6 +42258,110 @@ function computeCommentHighlights(snapshot, state) {
|
|
|
40947
42258
|
}
|
|
40948
42259
|
return boxes;
|
|
40949
42260
|
}
|
|
42261
|
+
const canvasTextMeasurer = {
|
|
42262
|
+
composeMeasuredParagraphLines: (options) => domTextMeasurer.composeMeasuredParagraphLines(options),
|
|
42263
|
+
resolveRenderedLineHeightPx: (styles, lineHeightMultiple) => domTextMeasurer.resolveRenderedLineHeightPx(styles, lineHeightMultiple)
|
|
42264
|
+
};
|
|
42265
|
+
function areLayoutParagraphsEquivalentForRender(previous, next) {
|
|
42266
|
+
if (previous === next) {
|
|
42267
|
+
return true;
|
|
42268
|
+
}
|
|
42269
|
+
if (!previous || !next) {
|
|
42270
|
+
return false;
|
|
42271
|
+
}
|
|
42272
|
+
if (previous.text !== next.text || previous.startOffset !== next.startOffset || previous.endOffset !== next.endOffset || previous.lines.length !== next.lines.length) {
|
|
42273
|
+
return false;
|
|
42274
|
+
}
|
|
42275
|
+
return next.lines.every((line, index) => {
|
|
42276
|
+
const previousLine = previous.lines[index];
|
|
42277
|
+
return previousLine !== void 0 && previousLine.startOffset === line.startOffset && previousLine.endOffset === line.endOffset && previousLine.top === line.top && previousLine.height === line.height;
|
|
42278
|
+
});
|
|
42279
|
+
}
|
|
42280
|
+
function canReuseLayoutBlock(previous, next) {
|
|
42281
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
42282
|
+
return Boolean(
|
|
42283
|
+
previous && previous.blockId === next.blockId && previous.sourceBlock === next.sourceBlock && previous.estimatedHeight === next.estimatedHeight && ((_a2 = previous.tableSegment) == null ? void 0 : _a2.startRowIndex) === ((_b2 = next.tableSegment) == null ? void 0 : _b2.startRowIndex) && ((_c = previous.tableSegment) == null ? void 0 : _c.endRowIndex) === ((_d = next.tableSegment) == null ? void 0 : _d.endRowIndex) && ((_e = previous.tableSegment) == null ? void 0 : _e.repeatedHeaderRowCount) === ((_f = next.tableSegment) == null ? void 0 : _f.repeatedHeaderRowCount) && sameNumberArray(
|
|
42284
|
+
(_g = previous.tableSegment) == null ? void 0 : _g.startRowCellBlockStarts,
|
|
42285
|
+
(_h = next.tableSegment) == null ? void 0 : _h.startRowCellBlockStarts
|
|
42286
|
+
) && sameNumberArray(
|
|
42287
|
+
(_i = previous.tableSegment) == null ? void 0 : _i.endRowCellBlockEnds,
|
|
42288
|
+
(_j = next.tableSegment) == null ? void 0 : _j.endRowCellBlockEnds
|
|
42289
|
+
) && sameTableCellBlockPositions(
|
|
42290
|
+
(_k = previous.tableSegment) == null ? void 0 : _k.startRowCellBlockPositions,
|
|
42291
|
+
(_l = next.tableSegment) == null ? void 0 : _l.startRowCellBlockPositions
|
|
42292
|
+
) && sameTableCellBlockPositions(
|
|
42293
|
+
(_m = previous.tableSegment) == null ? void 0 : _m.endRowCellBlockPositions,
|
|
42294
|
+
(_n = next.tableSegment) == null ? void 0 : _n.endRowCellBlockPositions
|
|
42295
|
+
) && areLayoutParagraphsEquivalentForRender(previous.layout, next.layout)
|
|
42296
|
+
);
|
|
42297
|
+
}
|
|
42298
|
+
function sameNumberArray(left, right) {
|
|
42299
|
+
if (((left == null ? void 0 : left.length) ?? 0) !== ((right == null ? void 0 : right.length) ?? 0)) return false;
|
|
42300
|
+
return (right ?? []).every((value, index) => (left == null ? void 0 : left[index]) === value);
|
|
42301
|
+
}
|
|
42302
|
+
function sameTableCellBlockPositions(left, right) {
|
|
42303
|
+
if (((left == null ? void 0 : left.length) ?? 0) !== ((right == null ? void 0 : right.length) ?? 0)) return false;
|
|
42304
|
+
return (right ?? []).every((value, index) => {
|
|
42305
|
+
const previous = left == null ? void 0 : left[index];
|
|
42306
|
+
return (previous == null ? void 0 : previous.blockIndex) === value.blockIndex && (previous == null ? void 0 : previous.offset) === value.offset;
|
|
42307
|
+
});
|
|
42308
|
+
}
|
|
42309
|
+
function canReuseLayoutPage(previous, next) {
|
|
42310
|
+
const samePageSettings = Boolean(
|
|
42311
|
+
previous && previous.pageSettings.width === next.pageSettings.width && previous.pageSettings.height === next.pageSettings.height && previous.pageSettings.orientation === next.pageSettings.orientation && previous.pageSettings.margins.top === next.pageSettings.margins.top && previous.pageSettings.margins.right === next.pageSettings.margins.right && previous.pageSettings.margins.bottom === next.pageSettings.margins.bottom && previous.pageSettings.margins.left === next.pageSettings.margins.left && previous.pageSettings.margins.header === next.pageSettings.margins.header && previous.pageSettings.margins.footer === next.pageSettings.margins.footer && previous.pageSettings.margins.gutter === next.pageSettings.margins.gutter
|
|
42312
|
+
);
|
|
42313
|
+
if (!previous || previous.id !== next.id || previous.index !== next.index || previous.height !== next.height || previous.maxHeight !== next.maxHeight || !samePageSettings || previous.bodyTop !== next.bodyTop || previous.bodyBottom !== next.bodyBottom || previous.headerTop !== next.headerTop || previous.footerTop !== next.footerTop || previous.footnoteTop !== next.footnoteTop || previous.footnoteSeparatorTop !== next.footnoteSeparatorTop) {
|
|
42314
|
+
return false;
|
|
42315
|
+
}
|
|
42316
|
+
const sameBlocks = (left, right) => {
|
|
42317
|
+
if (((left == null ? void 0 : left.length) ?? 0) !== ((right == null ? void 0 : right.length) ?? 0)) {
|
|
42318
|
+
return false;
|
|
42319
|
+
}
|
|
42320
|
+
return (right ?? []).every((block, index) => (left == null ? void 0 : left[index]) === block);
|
|
42321
|
+
};
|
|
42322
|
+
const sameFootnoteReferences = (left, right) => {
|
|
42323
|
+
if (((left == null ? void 0 : left.length) ?? 0) !== ((right == null ? void 0 : right.length) ?? 0)) {
|
|
42324
|
+
return false;
|
|
42325
|
+
}
|
|
42326
|
+
return (right ?? []).every(
|
|
42327
|
+
(footnoteId, index) => (left == null ? void 0 : left[index]) === footnoteId
|
|
42328
|
+
);
|
|
42329
|
+
};
|
|
42330
|
+
return sameBlocks(previous.blocks, next.blocks) && sameBlocks(previous.headerBlocks, next.headerBlocks) && sameBlocks(previous.footerBlocks, next.footerBlocks) && sameBlocks(previous.footnoteBlocks, next.footnoteBlocks) && sameFootnoteReferences(
|
|
42331
|
+
previous.footnoteReferenceIds,
|
|
42332
|
+
next.footnoteReferenceIds
|
|
42333
|
+
);
|
|
42334
|
+
}
|
|
42335
|
+
function createLayoutIdentityStabilizer() {
|
|
42336
|
+
let reusableLayoutBlocks = /* @__PURE__ */ new Map();
|
|
42337
|
+
let reusableLayoutPages = /* @__PURE__ */ new Map();
|
|
42338
|
+
return function stabilize(layout) {
|
|
42339
|
+
const nextBlockCache = /* @__PURE__ */ new Map();
|
|
42340
|
+
const stabilizeBlocks = (blocks) => blocks == null ? void 0 : blocks.map((block) => {
|
|
42341
|
+
const previous = reusableLayoutBlocks.get(block.blockId);
|
|
42342
|
+
const stable = canReuseLayoutBlock(previous, block) ? previous : block;
|
|
42343
|
+
nextBlockCache.set(stable.blockId, stable);
|
|
42344
|
+
return stable;
|
|
42345
|
+
});
|
|
42346
|
+
const pages = layout.pages.map((page) => {
|
|
42347
|
+
const nextPage = {
|
|
42348
|
+
...page,
|
|
42349
|
+
blocks: stabilizeBlocks(page.blocks) ?? [],
|
|
42350
|
+
headerBlocks: stabilizeBlocks(page.headerBlocks),
|
|
42351
|
+
footerBlocks: stabilizeBlocks(page.footerBlocks),
|
|
42352
|
+
footnoteBlocks: stabilizeBlocks(page.footnoteBlocks)
|
|
42353
|
+
};
|
|
42354
|
+
const previous = reusableLayoutPages.get(nextPage.id);
|
|
42355
|
+
if (canReuseLayoutPage(previous, nextPage)) {
|
|
42356
|
+
return previous;
|
|
42357
|
+
}
|
|
42358
|
+
return nextPage;
|
|
42359
|
+
});
|
|
42360
|
+
reusableLayoutBlocks = nextBlockCache;
|
|
42361
|
+
reusableLayoutPages = new Map(pages.map((page) => [page.id, page]));
|
|
42362
|
+
return { pages };
|
|
42363
|
+
};
|
|
42364
|
+
}
|
|
40950
42365
|
function scheduleFrame(callback) {
|
|
40951
42366
|
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
40952
42367
|
return window.requestAnimationFrame(() => callback());
|
|
@@ -40987,9 +42402,25 @@ function useEditorLayout(props) {
|
|
|
40987
42402
|
const [preferredColumnX, setPreferredColumnX] = createSignal(
|
|
40988
42403
|
null
|
|
40989
42404
|
);
|
|
42405
|
+
const stabilize = createLayoutIdentityStabilizer();
|
|
42406
|
+
const documentLayout = createMemo(() => {
|
|
42407
|
+
layoutMetricsEpoch();
|
|
42408
|
+
return stabilize(
|
|
42409
|
+
projectDocumentLayout(
|
|
42410
|
+
props.state.document,
|
|
42411
|
+
void 0,
|
|
42412
|
+
measuredBlockHeights(),
|
|
42413
|
+
measuredParagraphLayouts(),
|
|
42414
|
+
{
|
|
42415
|
+
measurer: canvasTextMeasurer
|
|
42416
|
+
}
|
|
42417
|
+
)
|
|
42418
|
+
);
|
|
42419
|
+
});
|
|
42420
|
+
const canvasSnapshotProvider = createCanvasLayoutSnapshotProvider();
|
|
40990
42421
|
let syncRequestId = 0;
|
|
40991
42422
|
const syncInputBox = (_reason = "selection") => {
|
|
40992
|
-
var
|
|
42423
|
+
var _a2;
|
|
40993
42424
|
const surface = props.surfaceRef();
|
|
40994
42425
|
if (!surface) {
|
|
40995
42426
|
setSelectionBoxes([]);
|
|
@@ -40999,12 +42430,11 @@ function useEditorLayout(props) {
|
|
|
40999
42430
|
setCaretBox((current) => ({ ...current, visible: false }));
|
|
41000
42431
|
return;
|
|
41001
42432
|
}
|
|
41002
|
-
const snapshot =
|
|
42433
|
+
const snapshot = canvasSnapshotProvider.getCanvasLayoutSnapshot({
|
|
41003
42434
|
surface,
|
|
41004
42435
|
state: props.state,
|
|
41005
|
-
|
|
41006
|
-
|
|
41007
|
-
zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
|
|
42436
|
+
documentLayout: documentLayout(),
|
|
42437
|
+
zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
|
|
41008
42438
|
});
|
|
41009
42439
|
if (!snapshot) {
|
|
41010
42440
|
setSelectionBoxes([]);
|
|
@@ -41040,29 +42470,33 @@ function useEditorLayout(props) {
|
|
|
41040
42470
|
setMeasuredParagraphLayouts(
|
|
41041
42471
|
(current) => normalizeParagraphLayouts(current, options.paragraphIds ?? [])
|
|
41042
42472
|
);
|
|
42473
|
+
bumpLayoutMetricsEpoch();
|
|
41043
42474
|
}
|
|
41044
42475
|
requestInputBoxSync(reason);
|
|
41045
42476
|
return options.resolveWhenDone ? Promise.resolve() : null;
|
|
41046
42477
|
};
|
|
41047
42478
|
const applyInvalidation = (invalidation) => {
|
|
41048
|
-
var
|
|
41049
|
-
if ((
|
|
42479
|
+
var _a2, _b2;
|
|
42480
|
+
if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
|
|
41050
42481
|
return;
|
|
41051
42482
|
}
|
|
41052
42483
|
if (invalidation.dirtyAll || invalidation.structureChanged) {
|
|
41053
42484
|
setMeasuredBlockHeights({});
|
|
41054
42485
|
setMeasuredParagraphLayouts({});
|
|
41055
|
-
|
|
42486
|
+
bumpLayoutMetricsEpoch();
|
|
42487
|
+
} else if ((((_b2 = invalidation.dirtyParagraphIds) == null ? void 0 : _b2.length) ?? 0) > 0) {
|
|
41056
42488
|
const dirtyIds = invalidation.dirtyParagraphIds ?? [];
|
|
41057
42489
|
setMeasuredParagraphLayouts(
|
|
41058
42490
|
(current) => normalizeParagraphLayouts(current, dirtyIds)
|
|
41059
42491
|
);
|
|
42492
|
+
bumpLayoutMetricsEpoch();
|
|
41060
42493
|
}
|
|
41061
42494
|
requestInputBoxSync("content-change");
|
|
41062
42495
|
};
|
|
41063
42496
|
const stabilizeLayoutAfterImport = async () => {
|
|
41064
42497
|
setMeasuredBlockHeights({});
|
|
41065
42498
|
setMeasuredParagraphLayouts({});
|
|
42499
|
+
bumpLayoutMetricsEpoch();
|
|
41066
42500
|
await new Promise((resolve) => {
|
|
41067
42501
|
scheduleFrame(() => resolve());
|
|
41068
42502
|
});
|
|
@@ -41078,11 +42512,11 @@ function useEditorLayout(props) {
|
|
|
41078
42512
|
requestInputBoxSync("selection");
|
|
41079
42513
|
});
|
|
41080
42514
|
createEffect(() => {
|
|
41081
|
-
var
|
|
42515
|
+
var _a2;
|
|
41082
42516
|
props.state.document;
|
|
41083
42517
|
props.state.activeSectionIndex;
|
|
41084
42518
|
props.state.activeZone;
|
|
41085
|
-
if ((
|
|
42519
|
+
if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
|
|
41086
42520
|
return;
|
|
41087
42521
|
}
|
|
41088
42522
|
requestInputBoxSync("content-change");
|
|
@@ -41110,10 +42544,13 @@ function useEditorLayout(props) {
|
|
|
41110
42544
|
const clearPreferredColumn = () => setPreferredColumnX(null);
|
|
41111
42545
|
const onCleanupHook = () => {
|
|
41112
42546
|
syncRequestId += 1;
|
|
42547
|
+
canvasSnapshotProvider.clear();
|
|
41113
42548
|
};
|
|
41114
42549
|
return {
|
|
41115
42550
|
measuredBlockHeights,
|
|
41116
42551
|
measuredParagraphLayouts,
|
|
42552
|
+
documentLayout,
|
|
42553
|
+
canvasSnapshotProvider,
|
|
41117
42554
|
inputBox,
|
|
41118
42555
|
selectionBoxes,
|
|
41119
42556
|
commentHighlights,
|
|
@@ -41140,7 +42577,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41140
42577
|
const isEnabled = () => options.enabled ?? false;
|
|
41141
42578
|
const persistence = options.persistence;
|
|
41142
42579
|
const debouncedSave = debounce(async (doc) => {
|
|
41143
|
-
var
|
|
42580
|
+
var _a2;
|
|
41144
42581
|
if (!isEnabled() || !isInitialized()) return;
|
|
41145
42582
|
setStatus("Saving...");
|
|
41146
42583
|
try {
|
|
@@ -41148,7 +42585,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41148
42585
|
await persistence.saveDocument(rawDoc);
|
|
41149
42586
|
setStatus("Saved");
|
|
41150
42587
|
} catch (err) {
|
|
41151
|
-
(
|
|
42588
|
+
(_a2 = options.logger) == null ? void 0 : _a2.error("persistence:autosave failed", err);
|
|
41152
42589
|
setStatus("Error");
|
|
41153
42590
|
}
|
|
41154
42591
|
}, 1e3);
|
|
@@ -41164,7 +42601,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41164
42601
|
)
|
|
41165
42602
|
);
|
|
41166
42603
|
onMount(async () => {
|
|
41167
|
-
var
|
|
42604
|
+
var _a2;
|
|
41168
42605
|
if (!isEnabled()) {
|
|
41169
42606
|
setIsInitialized(true);
|
|
41170
42607
|
setStatus("Saved");
|
|
@@ -41176,7 +42613,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41176
42613
|
onLoaded(loadedDoc);
|
|
41177
42614
|
}
|
|
41178
42615
|
} catch (err) {
|
|
41179
|
-
(
|
|
42616
|
+
(_a2 = options.logger) == null ? void 0 : _a2.error("persistence:load failed", err);
|
|
41180
42617
|
} finally {
|
|
41181
42618
|
setIsInitialized(true);
|
|
41182
42619
|
setStatus("Saved");
|
|
@@ -41192,8 +42629,8 @@ function createEmptyEditorHistoryState() {
|
|
|
41192
42629
|
};
|
|
41193
42630
|
}
|
|
41194
42631
|
function applyEditorHistoryTransaction(history, previous, next, options, now = Date.now()) {
|
|
41195
|
-
var
|
|
41196
|
-
const canMerge = (options == null ? void 0 : options.mergeKey) !== void 0 && ((
|
|
42632
|
+
var _a2;
|
|
42633
|
+
const canMerge = (options == null ? void 0 : options.mergeKey) !== void 0 && ((_a2 = history.lastTransactionMeta) == null ? void 0 : _a2.mergeKey) === options.mergeKey && now - history.lastTransactionMeta.timestamp < 1e3;
|
|
41197
42634
|
return {
|
|
41198
42635
|
undoStack: canMerge ? history.undoStack : [...history.undoStack, previous],
|
|
41199
42636
|
redoStack: [],
|
|
@@ -41354,13 +42791,13 @@ function createEditorHistoryActions(deps) {
|
|
|
41354
42791
|
return true;
|
|
41355
42792
|
};
|
|
41356
42793
|
const applySelectionPreservingStructure = (nextSelection) => {
|
|
41357
|
-
var
|
|
42794
|
+
var _a2;
|
|
41358
42795
|
const snapshot = deps.stateSnapshot();
|
|
41359
42796
|
deps.applyHistoryState({
|
|
41360
42797
|
...snapshot,
|
|
41361
42798
|
document: {
|
|
41362
42799
|
...snapshot.document,
|
|
41363
|
-
sections: (
|
|
42800
|
+
sections: (_a2 = snapshot.document.sections) == null ? void 0 : _a2.map(cloneSection)
|
|
41364
42801
|
},
|
|
41365
42802
|
selection: {
|
|
41366
42803
|
anchor: { ...nextSelection.anchor },
|
|
@@ -41379,8 +42816,8 @@ function openDB(options) {
|
|
|
41379
42816
|
return new Promise((resolve, reject) => {
|
|
41380
42817
|
const request = indexedDB.open(options.name, options.version);
|
|
41381
42818
|
request.onerror = () => {
|
|
41382
|
-
var
|
|
41383
|
-
reject(new Error(`Failed to open IndexedDB: ${(
|
|
42819
|
+
var _a2;
|
|
42820
|
+
reject(new Error(`Failed to open IndexedDB: ${(_a2 = request.error) == null ? void 0 : _a2.message}`));
|
|
41384
42821
|
};
|
|
41385
42822
|
request.onsuccess = () => {
|
|
41386
42823
|
resolve(request.result);
|
|
@@ -41398,10 +42835,10 @@ function putItem(db, storeName, key, value) {
|
|
|
41398
42835
|
const store = transaction.objectStore(storeName);
|
|
41399
42836
|
const request = store.put(value, key);
|
|
41400
42837
|
request.onerror = () => {
|
|
41401
|
-
var
|
|
42838
|
+
var _a2;
|
|
41402
42839
|
reject(
|
|
41403
42840
|
new Error(
|
|
41404
|
-
`Failed to put item in ${storeName}: ${(
|
|
42841
|
+
`Failed to put item in ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
41405
42842
|
)
|
|
41406
42843
|
);
|
|
41407
42844
|
};
|
|
@@ -41420,10 +42857,10 @@ function getItem(db, storeName, key) {
|
|
|
41420
42857
|
const store = transaction.objectStore(storeName);
|
|
41421
42858
|
const request = store.get(key);
|
|
41422
42859
|
request.onerror = () => {
|
|
41423
|
-
var
|
|
42860
|
+
var _a2;
|
|
41424
42861
|
reject(
|
|
41425
42862
|
new Error(
|
|
41426
|
-
`Failed to get item from ${storeName}: ${(
|
|
42863
|
+
`Failed to get item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
41427
42864
|
)
|
|
41428
42865
|
);
|
|
41429
42866
|
};
|
|
@@ -41442,10 +42879,10 @@ function deleteItem(db, storeName, key) {
|
|
|
41442
42879
|
const store = transaction.objectStore(storeName);
|
|
41443
42880
|
const request = store.delete(key);
|
|
41444
42881
|
request.onerror = () => {
|
|
41445
|
-
var
|
|
42882
|
+
var _a2;
|
|
41446
42883
|
reject(
|
|
41447
42884
|
new Error(
|
|
41448
|
-
`Failed to delete item from ${storeName}: ${(
|
|
42885
|
+
`Failed to delete item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
41449
42886
|
)
|
|
41450
42887
|
);
|
|
41451
42888
|
};
|
|
@@ -41500,7 +42937,7 @@ function createIndexedDbPersistence(options = {}) {
|
|
|
41500
42937
|
};
|
|
41501
42938
|
}
|
|
41502
42939
|
function computeLayoutInvalidationFromTransaction(prev, next) {
|
|
41503
|
-
var
|
|
42940
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
41504
42941
|
if (prev === next || prev.document === next.document) {
|
|
41505
42942
|
return {};
|
|
41506
42943
|
}
|
|
@@ -41544,7 +42981,7 @@ function computeLayoutInvalidationFromTransaction(prev, next) {
|
|
|
41544
42981
|
}
|
|
41545
42982
|
const aImage = getRunImage(a);
|
|
41546
42983
|
const bImage = getRunImage(b);
|
|
41547
|
-
if (Boolean(aImage) !== Boolean(bImage) || ((aImage == null ? void 0 : aImage.width) ?? -1) !== ((bImage == null ? void 0 : bImage.width) ?? -1) || ((aImage == null ? void 0 : aImage.height) ?? -1) !== ((bImage == null ? void 0 : bImage.height) ?? -1) || (((
|
|
42984
|
+
if (Boolean(aImage) !== Boolean(bImage) || ((aImage == null ? void 0 : aImage.width) ?? -1) !== ((bImage == null ? void 0 : bImage.width) ?? -1) || ((aImage == null ? void 0 : aImage.height) ?? -1) !== ((bImage == null ? void 0 : bImage.height) ?? -1) || (((_a2 = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _a2.wrap) ?? "") !== (((_b2 = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _b2.wrap) ?? "") || Boolean((_c = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _c.behindDoc) !== Boolean((_d = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _d.behindDoc) || (((_e = aImage == null ? void 0 : aImage.wrapPolygon) == null ? void 0 : _e.length) ?? -1) !== (((_f = bImage == null ? void 0 : bImage.wrapPolygon) == null ? void 0 : _f.length) ?? -1)) {
|
|
41548
42985
|
changed = true;
|
|
41549
42986
|
break;
|
|
41550
42987
|
}
|
|
@@ -41611,7 +43048,7 @@ function useEditorTransactions(ctx) {
|
|
|
41611
43048
|
}
|
|
41612
43049
|
function createEditorChangeBroadcast(deps) {
|
|
41613
43050
|
createEffect(() => {
|
|
41614
|
-
var
|
|
43051
|
+
var _a2;
|
|
41615
43052
|
deps.state.document;
|
|
41616
43053
|
deps.state.selection;
|
|
41617
43054
|
deps.state.activeSectionIndex;
|
|
@@ -41621,7 +43058,7 @@ function createEditorChangeBroadcast(deps) {
|
|
|
41621
43058
|
return;
|
|
41622
43059
|
}
|
|
41623
43060
|
const snapshot = deps.cloneState(deps.getStateSnapshot());
|
|
41624
|
-
(
|
|
43061
|
+
(_a2 = deps.getOnStateChange()) == null ? void 0 : _a2(snapshot);
|
|
41625
43062
|
deps.emit("change", snapshot);
|
|
41626
43063
|
deps.emit("documentChange", snapshot.document);
|
|
41627
43064
|
deps.emit("selectionChange", snapshot.selection);
|
|
@@ -41658,12 +43095,14 @@ function createEditorDocumentRuntime(deps) {
|
|
|
41658
43095
|
logger
|
|
41659
43096
|
});
|
|
41660
43097
|
const isImportInProgress = () => {
|
|
41661
|
-
var
|
|
41662
|
-
return ((
|
|
43098
|
+
var _a2, _b2;
|
|
43099
|
+
return ((_a2 = docIO.importProgress()) == null ? void 0 : _a2.phase) !== "done" && ((_b2 = docIO.importProgress()) == null ? void 0 : _b2.phase) !== "error" && docIO.importProgress() !== null;
|
|
41663
43100
|
};
|
|
41664
43101
|
const {
|
|
41665
43102
|
measuredBlockHeights,
|
|
41666
43103
|
measuredParagraphLayouts,
|
|
43104
|
+
documentLayout,
|
|
43105
|
+
canvasSnapshotProvider,
|
|
41667
43106
|
inputBox,
|
|
41668
43107
|
selectionBoxes,
|
|
41669
43108
|
commentHighlights,
|
|
@@ -41733,6 +43172,8 @@ function createEditorDocumentRuntime(deps) {
|
|
|
41733
43172
|
clearPreferredColumn();
|
|
41734
43173
|
setMeasuredBlockHeights({});
|
|
41735
43174
|
setMeasuredParagraphLayouts({});
|
|
43175
|
+
bumpLayoutMetricsEpoch();
|
|
43176
|
+
canvasSnapshotProvider.clear();
|
|
41736
43177
|
clearHistory();
|
|
41737
43178
|
};
|
|
41738
43179
|
createEditorChangeBroadcast({
|
|
@@ -41748,6 +43189,8 @@ function createEditorDocumentRuntime(deps) {
|
|
|
41748
43189
|
isImportInProgress,
|
|
41749
43190
|
measuredBlockHeights,
|
|
41750
43191
|
measuredParagraphLayouts,
|
|
43192
|
+
documentLayout,
|
|
43193
|
+
canvasSnapshotProvider,
|
|
41751
43194
|
inputBox,
|
|
41752
43195
|
selectionBoxes,
|
|
41753
43196
|
commentHighlights,
|
|
@@ -41931,7 +43374,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
|
|
|
41931
43374
|
return {
|
|
41932
43375
|
...cloneParagraph(candidate),
|
|
41933
43376
|
runs: candidate.runs.map((run) => {
|
|
41934
|
-
var
|
|
43377
|
+
var _a2;
|
|
41935
43378
|
if (run.id !== targetRun.id || run.kind !== "textBox") {
|
|
41936
43379
|
return cloneRun(run);
|
|
41937
43380
|
}
|
|
@@ -41941,7 +43384,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
|
|
|
41941
43384
|
width: nextWidth,
|
|
41942
43385
|
height: nextHeight
|
|
41943
43386
|
};
|
|
41944
|
-
if (changesHeight && ((
|
|
43387
|
+
if (changesHeight && ((_a2 = textBox.body) == null ? void 0 : _a2.autoFit)) {
|
|
41945
43388
|
nextTextBox.body = { ...textBox.body, autoFit: false };
|
|
41946
43389
|
}
|
|
41947
43390
|
if (textBox.floating) {
|
|
@@ -42039,7 +43482,7 @@ const updateBlocksInCurrentSection = (current, blocks, zone = "main") => {
|
|
|
42039
43482
|
};
|
|
42040
43483
|
};
|
|
42041
43484
|
const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
|
|
42042
|
-
var
|
|
43485
|
+
var _a2;
|
|
42043
43486
|
const location = findParagraphTableLocation(
|
|
42044
43487
|
current.document,
|
|
42045
43488
|
current.selection.focus.paragraphId,
|
|
@@ -42060,7 +43503,7 @@ const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
|
|
|
42060
43503
|
(block, i) => i === location.blockIndex ? clonedTable : block
|
|
42061
43504
|
);
|
|
42062
43505
|
const tableBlock = clonedTable;
|
|
42063
|
-
const targetCell = (
|
|
43506
|
+
const targetCell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42064
43507
|
if (!targetCell) {
|
|
42065
43508
|
return edit(current);
|
|
42066
43509
|
}
|
|
@@ -42100,7 +43543,7 @@ function createTableOpsGuards(deps) {
|
|
|
42100
43543
|
return Boolean(range && range.endCellIndex > range.startCellIndex);
|
|
42101
43544
|
};
|
|
42102
43545
|
const canSplitSelectedTableCell = (current) => {
|
|
42103
|
-
var
|
|
43546
|
+
var _a2;
|
|
42104
43547
|
const location = findParagraphTableLocation(
|
|
42105
43548
|
current.document,
|
|
42106
43549
|
current.selection.focus.paragraphId,
|
|
@@ -42114,11 +43557,11 @@ function createTableOpsGuards(deps) {
|
|
|
42114
43557
|
if (!block || block.type !== "table") {
|
|
42115
43558
|
return false;
|
|
42116
43559
|
}
|
|
42117
|
-
const cell = (
|
|
43560
|
+
const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42118
43561
|
return Boolean(((cell == null ? void 0 : cell.colSpan) ?? 1) > 1);
|
|
42119
43562
|
};
|
|
42120
43563
|
const canMergeSelectedTableRows = (current) => {
|
|
42121
|
-
var
|
|
43564
|
+
var _a2;
|
|
42122
43565
|
const range = deps.resolveVerticalTableCellRange(current);
|
|
42123
43566
|
if (!range) {
|
|
42124
43567
|
return false;
|
|
@@ -42129,7 +43572,7 @@ function createTableOpsGuards(deps) {
|
|
|
42129
43572
|
return false;
|
|
42130
43573
|
}
|
|
42131
43574
|
for (let rowIndex = range.startRowIndex; rowIndex <= range.endRowIndex; rowIndex += 1) {
|
|
42132
|
-
const cell = (
|
|
43575
|
+
const cell = (_a2 = tableBlock.rows[rowIndex]) == null ? void 0 : _a2.cells[range.cellIndex];
|
|
42133
43576
|
if (!cell || cell.vMerge === "continue" || cell.blocks.length !== 1) {
|
|
42134
43577
|
return false;
|
|
42135
43578
|
}
|
|
@@ -42140,7 +43583,7 @@ function createTableOpsGuards(deps) {
|
|
|
42140
43583
|
return canMergeSelectedTableCells(current) || canMergeSelectedTableRows(current);
|
|
42141
43584
|
};
|
|
42142
43585
|
const canSplitSelectedTableCellVertically = (current) => {
|
|
42143
|
-
var
|
|
43586
|
+
var _a2;
|
|
42144
43587
|
const location = findParagraphTableLocation(
|
|
42145
43588
|
current.document,
|
|
42146
43589
|
current.selection.focus.paragraphId,
|
|
@@ -42154,7 +43597,7 @@ function createTableOpsGuards(deps) {
|
|
|
42154
43597
|
if (!block || block.type !== "table") {
|
|
42155
43598
|
return false;
|
|
42156
43599
|
}
|
|
42157
|
-
const cell = (
|
|
43600
|
+
const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42158
43601
|
return Boolean(((cell == null ? void 0 : cell.rowSpan) ?? 1) > 1 && (cell == null ? void 0 : cell.vMerge) === "restart");
|
|
42159
43602
|
};
|
|
42160
43603
|
const canSplitSelectedTable = (current) => {
|
|
@@ -42251,11 +43694,11 @@ function getSelectionTableContext(current, deps) {
|
|
|
42251
43694
|
}
|
|
42252
43695
|
function createTableSelectionResolvers(deps) {
|
|
42253
43696
|
const resolveTableCellRangeSelection = (current) => {
|
|
42254
|
-
var
|
|
43697
|
+
var _a2, _b2, _c, _d, _e;
|
|
42255
43698
|
const selection = current.selection;
|
|
42256
43699
|
const context = getSelectionTableContext(current, deps);
|
|
42257
43700
|
if (!context || context.anchorLocation.rowIndex === context.focusLocation.rowIndex && context.anchorLocation.cellIndex === context.focusLocation.cellIndex) {
|
|
42258
|
-
(
|
|
43701
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.debug(
|
|
42259
43702
|
`resolveTableCellRangeSelection: no expansion (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId})`
|
|
42260
43703
|
);
|
|
42261
43704
|
return null;
|
|
@@ -42276,7 +43719,7 @@ function createTableSelectionResolvers(deps) {
|
|
|
42276
43719
|
context.anchorLocation.cellIndex,
|
|
42277
43720
|
context.focusLocation.cellIndex
|
|
42278
43721
|
);
|
|
42279
|
-
(
|
|
43722
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info(
|
|
42280
43723
|
`resolveTableCellRangeSelection: expanding r${context.anchorLocation.rowIndex}:c${context.anchorLocation.cellIndex}->r${context.focusLocation.rowIndex}:c${context.focusLocation.cellIndex} (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId}) range=[rows ${rangeStartRow}..${rangeEndRow}, cells ${rangeStartCell}..${rangeEndCell}]`
|
|
42281
43724
|
);
|
|
42282
43725
|
const startLocation = compareCellLocations(context.anchorCell, context.focusCell) <= 0 ? context.anchorLocation : context.focusLocation;
|
|
@@ -42552,7 +43995,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
42552
43995
|
return current;
|
|
42553
43996
|
};
|
|
42554
43997
|
const splitSelectedTableCellVertically = (current) => {
|
|
42555
|
-
var
|
|
43998
|
+
var _a2;
|
|
42556
43999
|
const location = findParagraphTableLocation(
|
|
42557
44000
|
current.document,
|
|
42558
44001
|
current.selection.focus.paragraphId,
|
|
@@ -42566,7 +44009,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
42566
44009
|
if (!tableBlock || tableBlock.type !== "table") {
|
|
42567
44010
|
return current;
|
|
42568
44011
|
}
|
|
42569
|
-
const cell = (
|
|
44012
|
+
const cell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42570
44013
|
const span = Math.max(1, (cell == null ? void 0 : cell.rowSpan) ?? 1);
|
|
42571
44014
|
if (!cell || span <= 1 || cell.vMerge !== "restart") {
|
|
42572
44015
|
return current;
|
|
@@ -42596,8 +44039,8 @@ function createTableCellSpanOperations(deps) {
|
|
|
42596
44039
|
previousCells: [
|
|
42597
44040
|
previousCell,
|
|
42598
44041
|
...Array.from({ length: span - 1 }, (_, offset) => {
|
|
42599
|
-
var
|
|
42600
|
-
const prior = (
|
|
44042
|
+
var _a3;
|
|
44043
|
+
const prior = (_a3 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a3.cells[location.cellIndex];
|
|
42601
44044
|
return prior ? cloneCellSnapshot(prior) : createEditorTableCell([], preservedColSpan);
|
|
42602
44045
|
})
|
|
42603
44046
|
]
|
|
@@ -42632,7 +44075,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
42632
44075
|
};
|
|
42633
44076
|
};
|
|
42634
44077
|
const splitSelectedTableCell = (current) => {
|
|
42635
|
-
var
|
|
44078
|
+
var _a2;
|
|
42636
44079
|
const location = findParagraphTableLocation(
|
|
42637
44080
|
current.document,
|
|
42638
44081
|
current.selection.focus.paragraphId,
|
|
@@ -42688,7 +44131,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
42688
44131
|
)
|
|
42689
44132
|
];
|
|
42690
44133
|
row.cells.splice(location.cellIndex, 1, ...nextCells);
|
|
42691
|
-
const nextParagraph = (
|
|
44134
|
+
const nextParagraph = (_a2 = nextCells[0]) == null ? void 0 : _a2.blocks[0];
|
|
42692
44135
|
if (!nextParagraph) {
|
|
42693
44136
|
return current;
|
|
42694
44137
|
}
|
|
@@ -42725,7 +44168,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
42725
44168
|
}
|
|
42726
44169
|
function createTableRowColumnOperations(deps) {
|
|
42727
44170
|
const insertSelectedTableRow = (current, direction) => {
|
|
42728
|
-
var
|
|
44171
|
+
var _a2, _b2;
|
|
42729
44172
|
const location = findParagraphTableLocation(
|
|
42730
44173
|
current.document,
|
|
42731
44174
|
current.selection.focus.paragraphId,
|
|
@@ -42801,9 +44244,9 @@ function createTableRowColumnOperations(deps) {
|
|
|
42801
44244
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
42802
44245
|
const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
|
|
42803
44246
|
const targetCell2 = findCellAtVisualColumn(blankRow, targetVisualColumn);
|
|
42804
|
-
const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((
|
|
44247
|
+
const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a2 = blankRow.cells.find(
|
|
42805
44248
|
(cell) => cell.vMerge !== "continue" && cell.blocks[0]
|
|
42806
|
-
)) == null ? void 0 :
|
|
44249
|
+
)) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
|
|
42807
44250
|
if (!nextParagraph2) {
|
|
42808
44251
|
return updateBlocksInCurrentSection(
|
|
42809
44252
|
current,
|
|
@@ -42843,9 +44286,9 @@ function createTableRowColumnOperations(deps) {
|
|
|
42843
44286
|
}
|
|
42844
44287
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
42845
44288
|
const targetCell = blankRow.cells[Math.min(location.cellIndex, blankRow.cells.length - 1)];
|
|
42846
|
-
const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((
|
|
44289
|
+
const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b2 = blankRow.cells.find(
|
|
42847
44290
|
(cell) => cell.vMerge !== "continue" && cell.blocks[0]
|
|
42848
|
-
)) == null ? void 0 :
|
|
44291
|
+
)) == null ? void 0 : _b2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
|
|
42849
44292
|
if (!nextParagraph) {
|
|
42850
44293
|
return updateBlocksInCurrentSection(current, targetBlocks, location.zone);
|
|
42851
44294
|
}
|
|
@@ -42948,7 +44391,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
42948
44391
|
};
|
|
42949
44392
|
};
|
|
42950
44393
|
const insertSelectedTableColumn = (current, direction) => {
|
|
42951
|
-
var
|
|
44394
|
+
var _a2;
|
|
42952
44395
|
const location = findParagraphTableLocation(
|
|
42953
44396
|
current.document,
|
|
42954
44397
|
current.selection.focus.paragraphId,
|
|
@@ -43055,7 +44498,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43055
44498
|
const insertIndex = Math.max(
|
|
43056
44499
|
0,
|
|
43057
44500
|
Math.min(
|
|
43058
|
-
((
|
|
44501
|
+
((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) ?? 0,
|
|
43059
44502
|
location.cellIndex + (direction > 0 ? 1 : 0)
|
|
43060
44503
|
)
|
|
43061
44504
|
);
|
|
@@ -43091,7 +44534,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43091
44534
|
};
|
|
43092
44535
|
};
|
|
43093
44536
|
const deleteSelectedTableColumn = (current) => {
|
|
43094
|
-
var
|
|
44537
|
+
var _a2;
|
|
43095
44538
|
const location = findParagraphTableLocation(
|
|
43096
44539
|
current.document,
|
|
43097
44540
|
current.selection.focus.paragraphId,
|
|
@@ -43185,7 +44628,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43185
44628
|
}
|
|
43186
44629
|
};
|
|
43187
44630
|
}
|
|
43188
|
-
if (((
|
|
44631
|
+
if (((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) <= 1) {
|
|
43189
44632
|
return current;
|
|
43190
44633
|
}
|
|
43191
44634
|
for (const row of tableBlock.rows) {
|
|
@@ -43230,19 +44673,19 @@ function createTableSelectionAwareCommands(deps) {
|
|
|
43230
44673
|
};
|
|
43231
44674
|
const applySelectionAwareCommand = (command, logPrefix) => {
|
|
43232
44675
|
deps.applyTransactionalState((current) => {
|
|
43233
|
-
var
|
|
44676
|
+
var _a2, _b2, _c;
|
|
43234
44677
|
const selection = deps.resolveSelectedTableCells(current);
|
|
43235
44678
|
if (!selection || selection.cells.length <= 1) {
|
|
43236
44679
|
const expanded = withExpandedTableCellSelection(current);
|
|
43237
44680
|
if (expanded !== current) {
|
|
43238
|
-
(
|
|
44681
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info(
|
|
43239
44682
|
`${logPrefix}: expanded selection to ${expanded.selection.anchor.paragraphId}[${expanded.selection.anchor.offset}]..${expanded.selection.focus.paragraphId}[${expanded.selection.focus.offset}]`
|
|
43240
44683
|
);
|
|
43241
44684
|
}
|
|
43242
44685
|
return command(expanded);
|
|
43243
44686
|
}
|
|
43244
44687
|
const { blockIndex, cells, zone } = selection;
|
|
43245
|
-
(
|
|
44688
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info(
|
|
43246
44689
|
`${logPrefix}: multi-cell selection in table block ${blockIndex} (${cells.length} cells) in zone ${zone}`
|
|
43247
44690
|
);
|
|
43248
44691
|
const allParagraphs = [];
|
|
@@ -43387,8 +44830,8 @@ function createEditorTableOperations(deps) {
|
|
|
43387
44830
|
logger: deps.logger
|
|
43388
44831
|
});
|
|
43389
44832
|
const insertTableCommand = (rows, cols) => {
|
|
43390
|
-
var
|
|
43391
|
-
(
|
|
44833
|
+
var _a2;
|
|
44834
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info(`insertTableCommand: ${rows}x${cols}`);
|
|
43392
44835
|
deps.applyTransactionalState(
|
|
43393
44836
|
(current) => insertTableAtSelection(current, rows, cols),
|
|
43394
44837
|
{
|
|
@@ -43452,12 +44895,12 @@ function createResizeSession(adapter, deps) {
|
|
|
43452
44895
|
}
|
|
43453
44896
|
});
|
|
43454
44897
|
const handleMouseMove = (event) => {
|
|
43455
|
-
var
|
|
44898
|
+
var _a2;
|
|
43456
44899
|
const resize = active;
|
|
43457
44900
|
if (!resize) {
|
|
43458
44901
|
return;
|
|
43459
44902
|
}
|
|
43460
|
-
const z = ((
|
|
44903
|
+
const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
|
|
43461
44904
|
const deltaX = (event.clientX - resize.startClientX) / z;
|
|
43462
44905
|
const deltaY = (event.clientY - resize.startClientY) / z;
|
|
43463
44906
|
const maxWidth = adapter.getMaxWidth(deps.state, resize.paragraphId);
|
|
@@ -44356,7 +45799,7 @@ function resolveImageAtPoint(snapshot, pageIndex, zone, clientX, clientY, pierce
|
|
|
44356
45799
|
return null;
|
|
44357
45800
|
}
|
|
44358
45801
|
function resolveCanvasSurfaceHitAtPoint(options) {
|
|
44359
|
-
var
|
|
45802
|
+
var _a2, _b2, _c;
|
|
44360
45803
|
const { snapshot, state } = options;
|
|
44361
45804
|
const pierce = options.pierce ?? false;
|
|
44362
45805
|
const zoomFactor = options.zoomFactor && options.zoomFactor > 0 ? options.zoomFactor : 1;
|
|
@@ -44398,7 +45841,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
|
|
|
44398
45841
|
position: position2,
|
|
44399
45842
|
source: "canvas-layout",
|
|
44400
45843
|
resolvedFromParagraph: true,
|
|
44401
|
-
tableCellAnchorPosition: (
|
|
45844
|
+
tableCellAnchorPosition: (_a2 = paragraphSegment.tableCell) == null ? void 0 : _a2.anchorPosition,
|
|
44402
45845
|
caretViewport: {
|
|
44403
45846
|
left: textBoxHit.left,
|
|
44404
45847
|
top: textBoxHit.top,
|
|
@@ -44447,7 +45890,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
|
|
|
44447
45890
|
position: position2,
|
|
44448
45891
|
source: "canvas-layout",
|
|
44449
45892
|
resolvedFromParagraph: true,
|
|
44450
|
-
tableCellAnchorPosition: (
|
|
45893
|
+
tableCellAnchorPosition: (_b2 = paragraphSegment.tableCell) == null ? void 0 : _b2.anchorPosition,
|
|
44451
45894
|
caretViewport: {
|
|
44452
45895
|
left: imageHit.left,
|
|
44453
45896
|
top: imageHit.top,
|
|
@@ -44509,43 +45952,17 @@ function resolveCanvasSurfaceHitAtPoint(options) {
|
|
|
44509
45952
|
};
|
|
44510
45953
|
}
|
|
44511
45954
|
function createCanvasSurfaceHitResolver(deps) {
|
|
44512
|
-
let canvasSnapshotCache = null;
|
|
44513
45955
|
const resolveSurfaceHitAtPoint = (clientX, clientY, context = {}) => {
|
|
44514
45956
|
const currentSurfaceRef = deps.surfaceRef();
|
|
44515
|
-
const currentViewportRef = deps.viewportRef();
|
|
44516
45957
|
if (!currentSurfaceRef) return null;
|
|
44517
|
-
const currentMeasuredBlockHeights = deps.measuredBlockHeights();
|
|
44518
|
-
const currentMeasuredParagraphLayouts = deps.measuredParagraphLayouts();
|
|
44519
45958
|
const currentState = deps.state();
|
|
44520
|
-
const viewportScrollTop = (currentViewportRef == null ? void 0 : currentViewportRef.scrollTop) ?? 0;
|
|
44521
|
-
const viewportScrollLeft = (currentViewportRef == null ? void 0 : currentViewportRef.scrollLeft) ?? 0;
|
|
44522
|
-
const windowWidth = window.innerWidth;
|
|
44523
|
-
const windowHeight = window.innerHeight;
|
|
44524
45959
|
const zoomFactor = deps.zoomFactor();
|
|
44525
|
-
const
|
|
44526
|
-
const snapshot = shouldReuseSnapshot ? canvasSnapshotCache.snapshot : buildCanvasLayoutSnapshot({
|
|
45960
|
+
const snapshot = deps.canvasSnapshotProvider.getCanvasLayoutSnapshot({
|
|
44527
45961
|
surface: currentSurfaceRef,
|
|
44528
45962
|
state: currentState,
|
|
44529
|
-
|
|
44530
|
-
measuredParagraphLayouts: currentMeasuredParagraphLayouts,
|
|
45963
|
+
documentLayout: deps.documentLayout(),
|
|
44531
45964
|
zoomFactor
|
|
44532
45965
|
});
|
|
44533
|
-
if (!shouldReuseSnapshot) {
|
|
44534
|
-
canvasSnapshotCache = {
|
|
44535
|
-
snapshot,
|
|
44536
|
-
documentRef: currentState.document,
|
|
44537
|
-
measuredBlockHeightsRef: currentMeasuredBlockHeights,
|
|
44538
|
-
measuredParagraphLayoutsRef: currentMeasuredParagraphLayouts,
|
|
44539
|
-
surfaceRef: currentSurfaceRef,
|
|
44540
|
-
viewportScrollTop,
|
|
44541
|
-
viewportScrollLeft,
|
|
44542
|
-
surfaceClientWidth: currentSurfaceRef.clientWidth,
|
|
44543
|
-
surfaceClientHeight: currentSurfaceRef.clientHeight,
|
|
44544
|
-
windowWidth,
|
|
44545
|
-
windowHeight,
|
|
44546
|
-
zoomFactor
|
|
44547
|
-
};
|
|
44548
|
-
}
|
|
44549
45966
|
recordCanvasDebugLayoutSnapshot(snapshot);
|
|
44550
45967
|
if (!snapshot) {
|
|
44551
45968
|
recordCanvasDebugHit(null);
|
|
@@ -44816,20 +46233,20 @@ function createEditorLayoutOptionsController(deps) {
|
|
|
44816
46233
|
}
|
|
44817
46234
|
function createEditorClipboardController(deps) {
|
|
44818
46235
|
const handleCopy = (event) => {
|
|
44819
|
-
var
|
|
46236
|
+
var _a2, _b2;
|
|
44820
46237
|
const text = getSelectedText(deps.state());
|
|
44821
46238
|
if (text.length === 0) {
|
|
44822
46239
|
return;
|
|
44823
46240
|
}
|
|
44824
46241
|
event.preventDefault();
|
|
44825
|
-
(
|
|
44826
|
-
(
|
|
46242
|
+
(_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
|
|
46243
|
+
(_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
|
|
44827
46244
|
"text/html",
|
|
44828
46245
|
serializeEditorSelectionToHtml(deps.state())
|
|
44829
46246
|
);
|
|
44830
46247
|
};
|
|
44831
46248
|
const handleCut = (event) => {
|
|
44832
|
-
var
|
|
46249
|
+
var _a2, _b2;
|
|
44833
46250
|
if (deps.isReadOnly()) {
|
|
44834
46251
|
event.preventDefault();
|
|
44835
46252
|
return;
|
|
@@ -44839,8 +46256,8 @@ function createEditorClipboardController(deps) {
|
|
|
44839
46256
|
return;
|
|
44840
46257
|
}
|
|
44841
46258
|
event.preventDefault();
|
|
44842
|
-
(
|
|
44843
|
-
(
|
|
46259
|
+
(_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
|
|
46260
|
+
(_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
|
|
44844
46261
|
"text/html",
|
|
44845
46262
|
serializeEditorSelectionToHtml(deps.state())
|
|
44846
46263
|
);
|
|
@@ -44855,14 +46272,14 @@ function createEditorClipboardController(deps) {
|
|
|
44855
46272
|
deps.focusInput();
|
|
44856
46273
|
};
|
|
44857
46274
|
const handlePaste = (event) => {
|
|
44858
|
-
var
|
|
46275
|
+
var _a2, _b2, _c;
|
|
44859
46276
|
if (deps.isReadOnly()) {
|
|
44860
46277
|
event.preventDefault();
|
|
44861
46278
|
return;
|
|
44862
46279
|
}
|
|
44863
46280
|
if (deps.forcePlainTextPaste()) {
|
|
44864
46281
|
deps.setForcePlainTextPaste(false);
|
|
44865
|
-
const text2 = ((
|
|
46282
|
+
const text2 = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
|
|
44866
46283
|
if (text2.length === 0) {
|
|
44867
46284
|
event.preventDefault();
|
|
44868
46285
|
return;
|
|
@@ -44890,7 +46307,7 @@ function createEditorClipboardController(deps) {
|
|
|
44890
46307
|
deps.focusInput();
|
|
44891
46308
|
return;
|
|
44892
46309
|
}
|
|
44893
|
-
const html = ((
|
|
46310
|
+
const html = ((_b2 = event.clipboardData) == null ? void 0 : _b2.getData("text/html")) ?? "";
|
|
44894
46311
|
const paragraphs = parseEditorClipboardHtmlWithDom(html);
|
|
44895
46312
|
if (paragraphs.length > 0) {
|
|
44896
46313
|
event.preventDefault();
|
|
@@ -44958,10 +46375,12 @@ function getTableById(state, tableId) {
|
|
|
44958
46375
|
);
|
|
44959
46376
|
return table ?? null;
|
|
44960
46377
|
}
|
|
44961
|
-
function buildTableGeometries(surface, state) {
|
|
44962
|
-
const snapshot =
|
|
46378
|
+
function buildTableGeometries(surface, state, documentLayout, canvasSnapshotProvider, zoomFactor) {
|
|
46379
|
+
const snapshot = canvasSnapshotProvider.getCanvasLayoutSnapshot({
|
|
44963
46380
|
surface,
|
|
44964
|
-
state
|
|
46381
|
+
state,
|
|
46382
|
+
documentLayout,
|
|
46383
|
+
zoomFactor
|
|
44965
46384
|
});
|
|
44966
46385
|
if (!snapshot) {
|
|
44967
46386
|
return [];
|
|
@@ -45057,8 +46476,14 @@ function buildTableGeometries(surface, state) {
|
|
|
45057
46476
|
}
|
|
45058
46477
|
const EDGE_THRESHOLD_COLUMN_PX = 4;
|
|
45059
46478
|
const EDGE_THRESHOLD_ROW_PX = 4;
|
|
45060
|
-
function findTableResizeHoverInfo(event, surface, state) {
|
|
45061
|
-
const geometries = buildTableGeometries(
|
|
46479
|
+
function findTableResizeHoverInfo(event, surface, state, documentLayout, canvasSnapshotProvider, zoomFactor) {
|
|
46480
|
+
const geometries = buildTableGeometries(
|
|
46481
|
+
surface,
|
|
46482
|
+
state,
|
|
46483
|
+
documentLayout,
|
|
46484
|
+
canvasSnapshotProvider,
|
|
46485
|
+
zoomFactor
|
|
46486
|
+
);
|
|
45062
46487
|
if (geometries.length === 0) {
|
|
45063
46488
|
return null;
|
|
45064
46489
|
}
|
|
@@ -45155,17 +46580,17 @@ const CONTENT_MIN_WIDTH_GUARD_PX = 12;
|
|
|
45155
46580
|
const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
|
|
45156
46581
|
const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
|
|
45157
46582
|
function resolveHorizontalCellChromePx(cell) {
|
|
45158
|
-
var
|
|
45159
|
-
const padding = typeof ((
|
|
46583
|
+
var _a2, _b2, _c, _d, _e;
|
|
46584
|
+
const padding = typeof ((_a2 = cell.style) == null ? void 0 : _a2.padding) === "number" && Number.isFinite(cell.style.padding) ? Math.max(0, ptToPx(cell.style.padding)) * 2 : Math.max(
|
|
45160
46585
|
0,
|
|
45161
|
-
(((
|
|
46586
|
+
(((_b2 = cell.style) == null ? void 0 : _b2.paddingLeft) !== void 0 ? ptToPx(cell.style.paddingLeft) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX) + (((_c = cell.style) == null ? void 0 : _c.paddingRight) !== void 0 ? ptToPx(cell.style.paddingRight) : DEFAULT_CELL_PADDING_LEFT_RIGHT_PX)
|
|
45162
46587
|
);
|
|
45163
46588
|
const borderLeft = ((_d = cell.style) == null ? void 0 : _d.borderLeft) ? Math.max(0, ptToPx(cell.style.borderLeft.width)) : 1;
|
|
45164
46589
|
const borderRight = ((_e = cell.style) == null ? void 0 : _e.borderRight) ? Math.max(0, ptToPx(cell.style.borderRight.width)) : 1;
|
|
45165
46590
|
return padding + borderLeft + borderRight;
|
|
45166
46591
|
}
|
|
45167
46592
|
function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
|
|
45168
|
-
var
|
|
46593
|
+
var _a2, _b2;
|
|
45169
46594
|
const rowCount = Math.max(1, tableNode.rows.length);
|
|
45170
46595
|
const baseRowHeight = geometry.bounds.height / rowCount;
|
|
45171
46596
|
const rowHeights = Array(rowCount).fill(baseRowHeight);
|
|
@@ -45175,7 +46600,7 @@ function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
|
|
|
45175
46600
|
)
|
|
45176
46601
|
);
|
|
45177
46602
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
|
|
45178
|
-
const explicitPt = parseSizeToPt((
|
|
46603
|
+
const explicitPt = parseSizeToPt((_b2 = (_a2 = tableNode.rows[rowIndex]) == null ? void 0 : _a2.style) == null ? void 0 : _b2.height);
|
|
45179
46604
|
if (explicitPt !== null) {
|
|
45180
46605
|
rowHeights[rowIndex] = Math.max(1, ptToPx(explicitPt));
|
|
45181
46606
|
continue;
|
|
@@ -45265,7 +46690,7 @@ function resolveMinRowHeightPx(tableNode, tableLayout, geometry, targetRowIndex)
|
|
|
45265
46690
|
return Math.max(minFloor, minHeight);
|
|
45266
46691
|
}
|
|
45267
46692
|
function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
|
|
45268
|
-
var
|
|
46693
|
+
var _a2;
|
|
45269
46694
|
const minFloor = ptToPx(MIN_TABLE_SIZE_PT);
|
|
45270
46695
|
const result = {};
|
|
45271
46696
|
const geometryByKey = new Map(
|
|
@@ -45279,7 +46704,7 @@ function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
|
|
|
45279
46704
|
`${entry.rowIndex}:${entry.cellIndex}`
|
|
45280
46705
|
);
|
|
45281
46706
|
if (!geometryCell) continue;
|
|
45282
|
-
const cell = (
|
|
46707
|
+
const cell = (_a2 = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a2.cells[entry.cellIndex];
|
|
45283
46708
|
if (!cell) continue;
|
|
45284
46709
|
const visualCol = entry.visualColumnIndex;
|
|
45285
46710
|
const currentMin = result[visualCol] ?? minFloor;
|
|
@@ -45311,7 +46736,7 @@ function applyRowResize(state, resize, delta) {
|
|
|
45311
46736
|
return setTableRowHeight(state, resize.tableId, resize.index, newSizePt);
|
|
45312
46737
|
}
|
|
45313
46738
|
function applyColumnResize(state, resize, delta) {
|
|
45314
|
-
var
|
|
46739
|
+
var _a2;
|
|
45315
46740
|
if (resize.type !== "column") return state;
|
|
45316
46741
|
const deltaPt = pxToPt(delta);
|
|
45317
46742
|
const maxColumnIndex = resize.maxColumnIndex ?? resize.index;
|
|
@@ -45377,7 +46802,7 @@ function applyColumnResize(state, resize, delta) {
|
|
|
45377
46802
|
0
|
|
45378
46803
|
);
|
|
45379
46804
|
const tableNode = getTableById(state, resize.tableId);
|
|
45380
|
-
const currentTableWidthPt = parseSizeToPt((
|
|
46805
|
+
const currentTableWidthPt = parseSizeToPt((_a2 = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a2.width);
|
|
45381
46806
|
const tableWidthToPersist = isLastColumn ? tableWidthPt : currentTableWidthPt !== null ? currentTableWidthPt : void 0;
|
|
45382
46807
|
return setTableColumnWidths(
|
|
45383
46808
|
state,
|
|
@@ -45427,6 +46852,7 @@ const DRAG_THRESHOLD_PX = 2;
|
|
|
45427
46852
|
function createEditorTableResize(deps) {
|
|
45428
46853
|
const [resizing, setResizing] = createSignal(null);
|
|
45429
46854
|
const handleMouseMove = (event) => {
|
|
46855
|
+
var _a2;
|
|
45430
46856
|
if (resizing()) {
|
|
45431
46857
|
setActiveCursorClass(resizing().type === "column");
|
|
45432
46858
|
return;
|
|
@@ -45436,7 +46862,14 @@ function createEditorTableResize(deps) {
|
|
|
45436
46862
|
clearResizeCursorClasses();
|
|
45437
46863
|
return;
|
|
45438
46864
|
}
|
|
45439
|
-
const info = findTableResizeHoverInfo(
|
|
46865
|
+
const info = findTableResizeHoverInfo(
|
|
46866
|
+
event,
|
|
46867
|
+
surface,
|
|
46868
|
+
deps.state(),
|
|
46869
|
+
deps.documentLayout(),
|
|
46870
|
+
deps.canvasSnapshotProvider,
|
|
46871
|
+
(_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
46872
|
+
);
|
|
45440
46873
|
if (!info) {
|
|
45441
46874
|
clearResizeCursorClasses();
|
|
45442
46875
|
return;
|
|
@@ -45444,10 +46877,17 @@ function createEditorTableResize(deps) {
|
|
|
45444
46877
|
setHoverCursorClass(info.side === "left" || info.side === "right");
|
|
45445
46878
|
};
|
|
45446
46879
|
const handleMouseDown = (event) => {
|
|
45447
|
-
var
|
|
46880
|
+
var _a2, _b2;
|
|
45448
46881
|
const surface = deps.surfaceRef();
|
|
45449
46882
|
if (!surface) return false;
|
|
45450
|
-
const info = findTableResizeHoverInfo(
|
|
46883
|
+
const info = findTableResizeHoverInfo(
|
|
46884
|
+
event,
|
|
46885
|
+
surface,
|
|
46886
|
+
deps.state(),
|
|
46887
|
+
deps.documentLayout(),
|
|
46888
|
+
deps.canvasSnapshotProvider,
|
|
46889
|
+
(_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
46890
|
+
);
|
|
45451
46891
|
if (!info) return false;
|
|
45452
46892
|
const state = deps.state();
|
|
45453
46893
|
const tableLayout = buildTableCellLayout(info.tableNode);
|
|
@@ -45478,7 +46918,7 @@ function createEditorTableResize(deps) {
|
|
|
45478
46918
|
maxColumnIndex,
|
|
45479
46919
|
minColumnWidthsPx,
|
|
45480
46920
|
resizeFromLeftEdge: isLeftTableEdge,
|
|
45481
|
-
initialTableIndentLeftPt: parseSizeToPt((
|
|
46921
|
+
initialTableIndentLeftPt: parseSizeToPt((_b2 = info.tableNode.style) == null ? void 0 : _b2.indentLeft) ?? 0,
|
|
45482
46922
|
guideBounds: getGuideBounds(deps.viewportRef)
|
|
45483
46923
|
});
|
|
45484
46924
|
setActiveCursorClass(true);
|
|
@@ -45532,10 +46972,10 @@ function createEditorTableResize(deps) {
|
|
|
45532
46972
|
setActiveCursorClass(currentResizing.type === "column");
|
|
45533
46973
|
};
|
|
45534
46974
|
const handleWindowMouseUp = (event) => {
|
|
45535
|
-
var
|
|
46975
|
+
var _a2;
|
|
45536
46976
|
const currentResizing = resizing();
|
|
45537
46977
|
if (!currentResizing) return;
|
|
45538
|
-
const z = ((
|
|
46978
|
+
const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
|
|
45539
46979
|
const delta = ((currentResizing.type === "column" ? event.clientX : event.clientY) - currentResizing.initialPos) / z;
|
|
45540
46980
|
if (Math.abs(delta) >= DRAG_THRESHOLD_PX) {
|
|
45541
46981
|
deps.applyTransactionalState((current) => {
|
|
@@ -45574,7 +47014,7 @@ function createEditorTableDrag(deps) {
|
|
|
45574
47014
|
document.body.style.cursor = "";
|
|
45575
47015
|
};
|
|
45576
47016
|
const handleMouseMove = (event) => {
|
|
45577
|
-
var
|
|
47017
|
+
var _a2;
|
|
45578
47018
|
setMousePos({ x: event.clientX, y: event.clientY });
|
|
45579
47019
|
if (!dragging()) {
|
|
45580
47020
|
const delta = Math.abs(event.clientY - startClientY());
|
|
@@ -45590,7 +47030,7 @@ function createEditorTableDrag(deps) {
|
|
|
45590
47030
|
event.clientX,
|
|
45591
47031
|
event.clientY
|
|
45592
47032
|
);
|
|
45593
|
-
const tableId = (
|
|
47033
|
+
const tableId = (_a2 = draggedTableInfo()) == null ? void 0 : _a2.tableId;
|
|
45594
47034
|
if (pos && tableId) {
|
|
45595
47035
|
const state = deps.state();
|
|
45596
47036
|
const location = findParagraphTableLocation(
|
|
@@ -45619,7 +47059,7 @@ function createEditorTableDrag(deps) {
|
|
|
45619
47059
|
const tableId = info == null ? void 0 : info.tableId;
|
|
45620
47060
|
if (tableId) {
|
|
45621
47061
|
deps.applyTransactionalState((current) => {
|
|
45622
|
-
var
|
|
47062
|
+
var _a2;
|
|
45623
47063
|
const findTable = () => {
|
|
45624
47064
|
for (const zone of ["main", "header", "footer"]) {
|
|
45625
47065
|
const blocks = getEditableBlocksForZone(current, zone);
|
|
@@ -45631,7 +47071,7 @@ function createEditorTableDrag(deps) {
|
|
|
45631
47071
|
return void 0;
|
|
45632
47072
|
};
|
|
45633
47073
|
const table = findTable();
|
|
45634
|
-
if ((table == null ? void 0 : table.type) === "table" && ((
|
|
47074
|
+
if ((table == null ? void 0 : table.type) === "table" && ((_a2 = table.style) == null ? void 0 : _a2.floating)) {
|
|
45635
47075
|
const floating = table.style.floating;
|
|
45636
47076
|
const pointsPerPixel = 72 / 96;
|
|
45637
47077
|
return setActiveTableStyleValue(current, tableId, "floating", {
|
|
@@ -45790,9 +47230,9 @@ function createEditorSurfaceEvents(deps) {
|
|
|
45790
47230
|
globalThis.clearTimeout(handle);
|
|
45791
47231
|
};
|
|
45792
47232
|
const applyWithZone = (state, targetZone, newState, targetPosition) => {
|
|
45793
|
-
var
|
|
47233
|
+
var _a2;
|
|
45794
47234
|
const isZoneTransition = targetZone !== (state.activeZone ?? "main");
|
|
45795
|
-
const targetFootnoteId = targetZone === "footnote" && targetPosition ? (
|
|
47235
|
+
const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a2 = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a2.footnoteId : void 0;
|
|
45796
47236
|
const isFootnoteTransition = targetZone === "footnote" && targetFootnoteId !== state.activeFootnoteId;
|
|
45797
47237
|
if (!isZoneTransition && !isFootnoteTransition) {
|
|
45798
47238
|
deps.applyState(newState);
|
|
@@ -45927,7 +47367,7 @@ function createEditorSurfaceEvents(deps) {
|
|
|
45927
47367
|
deps.focusInputAfterPointerSelection();
|
|
45928
47368
|
};
|
|
45929
47369
|
const handleSurfaceMouseDown = (event) => {
|
|
45930
|
-
var
|
|
47370
|
+
var _a2;
|
|
45931
47371
|
if (event.button !== 0) {
|
|
45932
47372
|
return;
|
|
45933
47373
|
}
|
|
@@ -45962,7 +47402,7 @@ function createEditorSurfaceEvents(deps) {
|
|
|
45962
47402
|
deps.focusInputAfterPointerSelection();
|
|
45963
47403
|
return;
|
|
45964
47404
|
}
|
|
45965
|
-
if ((
|
|
47405
|
+
if ((_a2 = deps.textDrag) == null ? void 0 : _a2.tryStartTextDrag(event, hit)) {
|
|
45966
47406
|
dragAnchor = null;
|
|
45967
47407
|
stopDragging();
|
|
45968
47408
|
deps.focusInputAfterPointerSelection();
|
|
@@ -46197,7 +47637,7 @@ function createEditorTextInput(deps) {
|
|
|
46197
47637
|
const [composing, setComposing] = createSignal(false);
|
|
46198
47638
|
let suppressedInputText = null;
|
|
46199
47639
|
const handleTextInput = (event) => {
|
|
46200
|
-
var
|
|
47640
|
+
var _a2, _b2, _c, _d;
|
|
46201
47641
|
markStart("input:text");
|
|
46202
47642
|
if (deps.isReadOnly()) {
|
|
46203
47643
|
deps.logger.debug(
|
|
@@ -46222,9 +47662,9 @@ function createEditorTextInput(deps) {
|
|
|
46222
47662
|
}
|
|
46223
47663
|
const state = deps.state();
|
|
46224
47664
|
const sel = state.selection;
|
|
46225
|
-
const currentRun = (
|
|
47665
|
+
const currentRun = (_a2 = getParagraphs(state).find((p) => p.id === sel.anchor.paragraphId)) == null ? void 0 : _a2.runs.find((r) => r.id === sel.anchor.runId);
|
|
46226
47666
|
const runStyle = currentRun ? {
|
|
46227
|
-
bold: (
|
|
47667
|
+
bold: (_b2 = currentRun.styles) == null ? void 0 : _b2.bold,
|
|
46228
47668
|
italic: (_c = currentRun.styles) == null ? void 0 : _c.italic,
|
|
46229
47669
|
underline: (_d = currentRun.styles) == null ? void 0 : _d.underline
|
|
46230
47670
|
} : null;
|
|
@@ -46340,8 +47780,8 @@ function createEditorTextDrag(deps) {
|
|
|
46340
47780
|
document.head.appendChild(cursorStyleEl);
|
|
46341
47781
|
};
|
|
46342
47782
|
const stopDrag = () => {
|
|
46343
|
-
var
|
|
46344
|
-
(
|
|
47783
|
+
var _a2;
|
|
47784
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:stop", {
|
|
46345
47785
|
dragging: dragging(),
|
|
46346
47786
|
dropTarget: dropTargetPos() ? `${dropTargetPos().paragraphId}:${dropTargetPos().runId}[${dropTargetPos().offset}]` : null,
|
|
46347
47787
|
copyMode: copyMode()
|
|
@@ -46358,7 +47798,7 @@ function createEditorTextDrag(deps) {
|
|
|
46358
47798
|
window.removeEventListener("mouseup", handleWindowMouseUp);
|
|
46359
47799
|
};
|
|
46360
47800
|
const handleWindowMouseMove = (event) => {
|
|
46361
|
-
var
|
|
47801
|
+
var _a2, _b2, _c;
|
|
46362
47802
|
if (!pendingStart) {
|
|
46363
47803
|
return;
|
|
46364
47804
|
}
|
|
@@ -46370,7 +47810,7 @@ function createEditorTextDrag(deps) {
|
|
|
46370
47810
|
if (deltaX + deltaY < 4) {
|
|
46371
47811
|
return;
|
|
46372
47812
|
}
|
|
46373
|
-
(
|
|
47813
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:activate", {
|
|
46374
47814
|
start: pendingStart,
|
|
46375
47815
|
at: { x: event.clientX, y: event.clientY },
|
|
46376
47816
|
deltaX,
|
|
@@ -46382,7 +47822,7 @@ function createEditorTextDrag(deps) {
|
|
|
46382
47822
|
setPointerPos({ x: event.clientX, y: event.clientY });
|
|
46383
47823
|
const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY);
|
|
46384
47824
|
if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) {
|
|
46385
|
-
(
|
|
47825
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:hit-miss", {
|
|
46386
47826
|
x: event.clientX,
|
|
46387
47827
|
y: event.clientY
|
|
46388
47828
|
});
|
|
@@ -46410,8 +47850,8 @@ function createEditorTextDrag(deps) {
|
|
|
46410
47850
|
setCaretViewport(hit.caretViewport ?? null);
|
|
46411
47851
|
};
|
|
46412
47852
|
const handleWindowMouseUp = (event) => {
|
|
46413
|
-
var
|
|
46414
|
-
(
|
|
47853
|
+
var _a2, _b2, _c;
|
|
47854
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:mouseup", {
|
|
46415
47855
|
x: event.clientX,
|
|
46416
47856
|
y: event.clientY,
|
|
46417
47857
|
dragging: dragging(),
|
|
@@ -46432,7 +47872,7 @@ function createEditorTextDrag(deps) {
|
|
|
46432
47872
|
mergeKey: copy ? MERGE_KEYS.copyTextByDrag : MERGE_KEYS.moveTextByDrag
|
|
46433
47873
|
}
|
|
46434
47874
|
);
|
|
46435
|
-
(
|
|
47875
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info("text-drag:apply", {
|
|
46436
47876
|
mode: copy ? "copy" : "move",
|
|
46437
47877
|
destination: `${destination.paragraphId}:${destination.runId}[${destination.offset}]`
|
|
46438
47878
|
});
|
|
@@ -46458,9 +47898,9 @@ function createEditorTextDrag(deps) {
|
|
|
46458
47898
|
deps.focusInputAfterPointerSelection();
|
|
46459
47899
|
};
|
|
46460
47900
|
const tryStartTextDrag = (event, hit) => {
|
|
46461
|
-
var
|
|
47901
|
+
var _a2, _b2, _c;
|
|
46462
47902
|
if (deps.isReadOnly() || !(hit == null ? void 0 : hit.resolvedFromParagraph)) {
|
|
46463
|
-
(
|
|
47903
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.debug("text-drag:skip-start", {
|
|
46464
47904
|
reason: deps.isReadOnly() ? "readonly" : "no-hit",
|
|
46465
47905
|
x: event.clientX,
|
|
46466
47906
|
y: event.clientY
|
|
@@ -46469,7 +47909,7 @@ function createEditorTextDrag(deps) {
|
|
|
46469
47909
|
}
|
|
46470
47910
|
const current = deps.state();
|
|
46471
47911
|
if (!isPositionInsideSelection(current, hit.position)) {
|
|
46472
|
-
(
|
|
47912
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:skip-start", {
|
|
46473
47913
|
reason: "outside-selection",
|
|
46474
47914
|
x: event.clientX,
|
|
46475
47915
|
y: event.clientY,
|
|
@@ -46605,7 +48045,7 @@ function createEditorNavigation(deps) {
|
|
|
46605
48045
|
return moveVerticalSelection(direction, false);
|
|
46606
48046
|
};
|
|
46607
48047
|
const moveVerticalSelection = (direction, extend) => {
|
|
46608
|
-
var
|
|
48048
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
46609
48049
|
const state = deps.state();
|
|
46610
48050
|
const paragraphs = getParagraphs(state);
|
|
46611
48051
|
const currentIndex = paragraphs.findIndex(
|
|
@@ -46618,10 +48058,11 @@ function createEditorNavigation(deps) {
|
|
|
46618
48058
|
const surfaceRect = (surfaceRef == null ? void 0 : surfaceRef.getBoundingClientRect()) ?? null;
|
|
46619
48059
|
const preferredX = deps.preferredColumnX();
|
|
46620
48060
|
const desiredX = preferredX === null ? deps.caretBox().left + ((surfaceRect == null ? void 0 : surfaceRect.left) ?? 0) : preferredX;
|
|
46621
|
-
const snapshot = surfaceRef ?
|
|
48061
|
+
const snapshot = surfaceRef ? deps.canvasSnapshotProvider.getCanvasLayoutSnapshot({
|
|
46622
48062
|
surface: surfaceRef,
|
|
46623
48063
|
state,
|
|
46624
|
-
|
|
48064
|
+
documentLayout: deps.documentLayout(),
|
|
48065
|
+
zoomFactor: (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
46625
48066
|
}) : null;
|
|
46626
48067
|
let targetIndex = currentIndex + direction;
|
|
46627
48068
|
const tableLocation = findParagraphTableLocation(
|
|
@@ -46653,17 +48094,17 @@ function createEditorNavigation(deps) {
|
|
|
46653
48094
|
continue;
|
|
46654
48095
|
}
|
|
46655
48096
|
const scoredCandidates = rowCandidates.map((entry) => {
|
|
46656
|
-
var
|
|
46657
|
-
const paragraphId = (
|
|
46658
|
-
const cellRect = paragraphId ? (
|
|
48097
|
+
var _a3, _b3;
|
|
48098
|
+
const paragraphId = (_a3 = entry.cell.blocks[0]) == null ? void 0 : _a3.id;
|
|
48099
|
+
const cellRect = paragraphId ? (_b3 = snapshot == null ? void 0 : snapshot.paragraphs.find(
|
|
46659
48100
|
(paragraph) => paragraph.paragraphId === paragraphId && paragraph.tableCell && paragraph.tableCell.tableId === block.id
|
|
46660
|
-
)) == null ? void 0 :
|
|
48101
|
+
)) == null ? void 0 : _b3.tableCell : null;
|
|
46661
48102
|
const left = (cellRect == null ? void 0 : cellRect.left) ?? desiredX;
|
|
46662
48103
|
const right = cellRect ? cellRect.left + cellRect.width : desiredX;
|
|
46663
48104
|
const distance = desiredX < left ? left - desiredX : desiredX > right ? desiredX - right : 0;
|
|
46664
48105
|
return { entry, distance };
|
|
46665
48106
|
}).sort((left, right) => left.distance - right.distance);
|
|
46666
|
-
const candidate = (
|
|
48107
|
+
const candidate = (_b2 = scoredCandidates[0]) == null ? void 0 : _b2.entry;
|
|
46667
48108
|
if (!candidate) {
|
|
46668
48109
|
continue;
|
|
46669
48110
|
}
|
|
@@ -46730,12 +48171,12 @@ function createEditorNavigation(deps) {
|
|
|
46730
48171
|
function createEditorRevisionController(deps) {
|
|
46731
48172
|
const [hoveredRevision, setHoveredRevision] = createSignal(null);
|
|
46732
48173
|
const handleRevisionMouseEnter = (revisionId, event) => {
|
|
46733
|
-
var
|
|
48174
|
+
var _a2, _b2, _c;
|
|
46734
48175
|
const paragraphs = getParagraphs(deps.state());
|
|
46735
48176
|
let foundRevision;
|
|
46736
48177
|
for (const p of paragraphs) {
|
|
46737
48178
|
for (const run of p.runs) {
|
|
46738
|
-
if (((
|
|
48179
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId) {
|
|
46739
48180
|
foundRevision = run.revision;
|
|
46740
48181
|
break;
|
|
46741
48182
|
}
|
|
@@ -46743,10 +48184,10 @@ function createEditorRevisionController(deps) {
|
|
|
46743
48184
|
if (foundRevision) break;
|
|
46744
48185
|
}
|
|
46745
48186
|
const findInBlocks = (blocks) => {
|
|
46746
|
-
var
|
|
48187
|
+
var _a3, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
46747
48188
|
for (const block of blocks) {
|
|
46748
48189
|
if (block.type === "paragraph") continue;
|
|
46749
|
-
if (((
|
|
48190
|
+
if (((_b3 = (_a3 = block.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b3.id) === revisionId) {
|
|
46750
48191
|
return block.style.revision;
|
|
46751
48192
|
}
|
|
46752
48193
|
if (((_c2 = block.gridRevision) == null ? void 0 : _c2.id) === revisionId) return block.gridRevision;
|
|
@@ -46789,7 +48230,7 @@ function createEditorRevisionController(deps) {
|
|
|
46789
48230
|
}
|
|
46790
48231
|
if (!foundRevision) return;
|
|
46791
48232
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
46792
|
-
const surfaceRect = (
|
|
48233
|
+
const surfaceRect = (_b2 = deps.surfaceRef()) == null ? void 0 : _b2.getBoundingClientRect();
|
|
46793
48234
|
if (!surfaceRect) return;
|
|
46794
48235
|
const z = ((_c = deps.zoomFactor) == null ? void 0 : _c.call(deps)) ?? 1;
|
|
46795
48236
|
setHoveredRevision({
|
|
@@ -46817,7 +48258,9 @@ function useEditorInteractionWiring(ctx) {
|
|
|
46817
48258
|
applyTransactionalState: ctx.applyTransactionalState,
|
|
46818
48259
|
surfaceRef: ctx.surfaceRef,
|
|
46819
48260
|
viewportRef: ctx.viewportRef,
|
|
46820
|
-
zoomFactor: ctx.zoomFactor
|
|
48261
|
+
zoomFactor: ctx.zoomFactor,
|
|
48262
|
+
documentLayout: ctx.documentLayout,
|
|
48263
|
+
canvasSnapshotProvider: ctx.canvasSnapshotProvider
|
|
46821
48264
|
});
|
|
46822
48265
|
const tableDrag = createEditorTableDrag({
|
|
46823
48266
|
state,
|
|
@@ -46878,7 +48321,9 @@ function useEditorInteractionWiring(ctx) {
|
|
|
46878
48321
|
clearPreferredColumn: ctx.clearPreferredColumn,
|
|
46879
48322
|
resetTransactionGrouping: ctx.resetTransactionGrouping,
|
|
46880
48323
|
focusInput: ctx.focusInput,
|
|
46881
|
-
zoomFactor: ctx.zoomFactor
|
|
48324
|
+
zoomFactor: ctx.zoomFactor,
|
|
48325
|
+
documentLayout: ctx.documentLayout,
|
|
48326
|
+
canvasSnapshotProvider: ctx.canvasSnapshotProvider
|
|
46882
48327
|
});
|
|
46883
48328
|
const { handleCopy, handleCut, handlePaste, handleDrop } = createEditorClipboardController({
|
|
46884
48329
|
state,
|
|
@@ -46930,8 +48375,8 @@ function createEditorInteractionRuntime(deps) {
|
|
|
46930
48375
|
caretBox,
|
|
46931
48376
|
preferredColumnX,
|
|
46932
48377
|
setPreferredColumnX,
|
|
46933
|
-
|
|
46934
|
-
|
|
48378
|
+
documentLayout,
|
|
48379
|
+
canvasSnapshotProvider
|
|
46935
48380
|
} = deps;
|
|
46936
48381
|
const selectedImageRun = () => getSelectedImageRun(state);
|
|
46937
48382
|
const selectedTextBoxRun = () => getSelectedTextBoxRun(state);
|
|
@@ -46945,8 +48390,8 @@ function createEditorInteractionRuntime(deps) {
|
|
|
46945
48390
|
state: () => state,
|
|
46946
48391
|
surfaceRef: () => surfaceRef() ?? null,
|
|
46947
48392
|
viewportRef: () => viewportRef() ?? null,
|
|
46948
|
-
|
|
46949
|
-
|
|
48393
|
+
documentLayout,
|
|
48394
|
+
canvasSnapshotProvider,
|
|
46950
48395
|
zoomFactor
|
|
46951
48396
|
});
|
|
46952
48397
|
const resolveSurfaceHitAtPoint = canvasHitResolver.resolveSurfaceHitAtPoint;
|
|
@@ -46967,8 +48412,8 @@ function createEditorInteractionRuntime(deps) {
|
|
|
46967
48412
|
logger
|
|
46968
48413
|
});
|
|
46969
48414
|
const resolvePositionAtSurfacePoint = (clientX, clientY) => {
|
|
46970
|
-
var
|
|
46971
|
-
return ((
|
|
48415
|
+
var _a2;
|
|
48416
|
+
return ((_a2 = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a2.position) ?? null;
|
|
46972
48417
|
};
|
|
46973
48418
|
const imageOps = createEditorImageOperations({
|
|
46974
48419
|
state,
|
|
@@ -47017,6 +48462,8 @@ function createEditorInteractionRuntime(deps) {
|
|
|
47017
48462
|
preferredColumnX: () => preferredColumnX(),
|
|
47018
48463
|
setPreferredColumnX,
|
|
47019
48464
|
zoomFactor,
|
|
48465
|
+
documentLayout,
|
|
48466
|
+
canvasSnapshotProvider,
|
|
47020
48467
|
resolveSurfaceHitAtPoint,
|
|
47021
48468
|
resolvePositionAtSurfacePoint,
|
|
47022
48469
|
tableOps,
|
|
@@ -47064,10 +48511,10 @@ function ensureFootnotes(footnotes) {
|
|
|
47064
48511
|
return { items: {} };
|
|
47065
48512
|
}
|
|
47066
48513
|
function nextAutoMarker(document2) {
|
|
47067
|
-
var
|
|
48514
|
+
var _a2, _b2;
|
|
47068
48515
|
const footnotes = document2.footnotes;
|
|
47069
|
-
const format = ((
|
|
47070
|
-
const startAt = ((
|
|
48516
|
+
const format = ((_a2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _a2.numberFormat) ?? "decimal";
|
|
48517
|
+
const startAt = ((_b2 = footnotes == null ? void 0 : footnotes.settings) == null ? void 0 : _b2.startAt) ?? 1;
|
|
47071
48518
|
let autoCount = startAt - 1;
|
|
47072
48519
|
const seen = /* @__PURE__ */ new Set();
|
|
47073
48520
|
for (const { run } of iterateFootnoteReferenceRuns(document2)) {
|
|
@@ -47142,10 +48589,10 @@ function toggleTrackChanges(state) {
|
|
|
47142
48589
|
}
|
|
47143
48590
|
function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
47144
48591
|
return blocks.flatMap((block) => {
|
|
47145
|
-
var
|
|
48592
|
+
var _a2;
|
|
47146
48593
|
if (block.type === "paragraph") return [block];
|
|
47147
48594
|
let style2 = block.style;
|
|
47148
|
-
if (((
|
|
48595
|
+
if (((_a2 = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a2.id) === revisionId) {
|
|
47149
48596
|
if (accept) {
|
|
47150
48597
|
const { revision: _revision, ...current } = style2;
|
|
47151
48598
|
style2 = current;
|
|
@@ -47189,8 +48636,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
|
47189
48636
|
}
|
|
47190
48637
|
}
|
|
47191
48638
|
const rows = sourceRows.flatMap((row) => {
|
|
47192
|
-
var
|
|
47193
|
-
if (((
|
|
48639
|
+
var _a3, _b2, _c, _d;
|
|
48640
|
+
if (((_b2 = (_a3 = row.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
|
|
47194
48641
|
const remove = accept && row.style.revision.type === "delete" || !accept && row.style.revision.type === "insert";
|
|
47195
48642
|
if (remove) return [];
|
|
47196
48643
|
}
|
|
@@ -47211,8 +48658,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
|
47211
48658
|
rowStyle = current;
|
|
47212
48659
|
}
|
|
47213
48660
|
const cells = row.cells.flatMap((cell) => {
|
|
47214
|
-
var
|
|
47215
|
-
if (((
|
|
48661
|
+
var _a4, _b3, _c2, _d2, _e;
|
|
48662
|
+
if (((_b3 = (_a4 = cell.style) == null ? void 0 : _a4.revision) == null ? void 0 : _b3.id) === revisionId) {
|
|
47216
48663
|
const remove = accept && cell.style.revision.type === "delete" || !accept && cell.style.revision.type === "insert";
|
|
47217
48664
|
if (remove) return [];
|
|
47218
48665
|
}
|
|
@@ -47287,12 +48734,12 @@ function acceptRevision(state, revisionId) {
|
|
|
47287
48734
|
const nextParagraphs = paragraphs.map((paragraph) => {
|
|
47288
48735
|
const nextRuns = paragraph.runs.filter(
|
|
47289
48736
|
(run) => {
|
|
47290
|
-
var
|
|
47291
|
-
return !(((
|
|
48737
|
+
var _a2;
|
|
48738
|
+
return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete");
|
|
47292
48739
|
}
|
|
47293
48740
|
).map((run) => {
|
|
47294
|
-
var
|
|
47295
|
-
if (((
|
|
48741
|
+
var _a2;
|
|
48742
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert") {
|
|
47296
48743
|
const nextRun = { ...run };
|
|
47297
48744
|
delete nextRun.revision;
|
|
47298
48745
|
return nextRun;
|
|
@@ -47319,12 +48766,12 @@ function rejectRevision(state, revisionId) {
|
|
|
47319
48766
|
const nextParagraphs = paragraphs.map((paragraph) => {
|
|
47320
48767
|
const nextRuns = paragraph.runs.filter(
|
|
47321
48768
|
(run) => {
|
|
47322
|
-
var
|
|
47323
|
-
return !(((
|
|
48769
|
+
var _a2;
|
|
48770
|
+
return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert");
|
|
47324
48771
|
}
|
|
47325
48772
|
).map((run) => {
|
|
47326
|
-
var
|
|
47327
|
-
if (((
|
|
48773
|
+
var _a2;
|
|
48774
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete") {
|
|
47328
48775
|
const nextRun = { ...run };
|
|
47329
48776
|
delete nextRun.revision;
|
|
47330
48777
|
return nextRun;
|
|
@@ -47347,7 +48794,7 @@ function rejectRevision(state, revisionId) {
|
|
|
47347
48794
|
return transformTableRevision(textState, revisionId, false);
|
|
47348
48795
|
}
|
|
47349
48796
|
function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
47350
|
-
var
|
|
48797
|
+
var _a2, _b2, _c, _d, _e;
|
|
47351
48798
|
for (const block of blocks) {
|
|
47352
48799
|
if (block.type === "paragraph") continue;
|
|
47353
48800
|
const tableSelected = block.rows.some(
|
|
@@ -47356,7 +48803,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
47356
48803
|
)
|
|
47357
48804
|
);
|
|
47358
48805
|
if (tableSelected) {
|
|
47359
|
-
if ((
|
|
48806
|
+
if ((_a2 = block.style) == null ? void 0 : _a2.revision) revisionIds.add(block.style.revision.id);
|
|
47360
48807
|
if (block.gridRevision) revisionIds.add(block.gridRevision.id);
|
|
47361
48808
|
}
|
|
47362
48809
|
for (const row of block.rows) {
|
|
@@ -47364,7 +48811,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
47364
48811
|
(cell) => cell.blocks.some((paragraph) => selectedParagraphIds.has(paragraph.id))
|
|
47365
48812
|
);
|
|
47366
48813
|
if (selectedCells.length > 0) {
|
|
47367
|
-
if ((
|
|
48814
|
+
if ((_b2 = row.style) == null ? void 0 : _b2.revision) revisionIds.add(row.style.revision.id);
|
|
47368
48815
|
if ((_c = row.style) == null ? void 0 : _c.propertyRevision) {
|
|
47369
48816
|
revisionIds.add(row.style.propertyRevision.id);
|
|
47370
48817
|
}
|
|
@@ -47380,7 +48827,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
47380
48827
|
}
|
|
47381
48828
|
}
|
|
47382
48829
|
function acceptRevisionsInSelection(state) {
|
|
47383
|
-
var
|
|
48830
|
+
var _a2;
|
|
47384
48831
|
const normalized = normalizeSelection(state);
|
|
47385
48832
|
const paragraphs = getParagraphs(state);
|
|
47386
48833
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
@@ -47390,7 +48837,7 @@ function acceptRevisionsInSelection(state) {
|
|
|
47390
48837
|
const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
47391
48838
|
const runs = sliceRuns(paragraph, startOffset, endOffset);
|
|
47392
48839
|
for (const run of runs) {
|
|
47393
|
-
if ((
|
|
48840
|
+
if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
|
|
47394
48841
|
revisionIds.add(run.revision.id);
|
|
47395
48842
|
}
|
|
47396
48843
|
}
|
|
@@ -47420,7 +48867,7 @@ function acceptRevisionsInSelection(state) {
|
|
|
47420
48867
|
return nextState;
|
|
47421
48868
|
}
|
|
47422
48869
|
function rejectRevisionsInSelection(state) {
|
|
47423
|
-
var
|
|
48870
|
+
var _a2;
|
|
47424
48871
|
const normalized = normalizeSelection(state);
|
|
47425
48872
|
const paragraphs = getParagraphs(state);
|
|
47426
48873
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
@@ -47430,7 +48877,7 @@ function rejectRevisionsInSelection(state) {
|
|
|
47430
48877
|
const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
47431
48878
|
const runs = sliceRuns(paragraph, startOffset, endOffset);
|
|
47432
48879
|
for (const run of runs) {
|
|
47433
|
-
if ((
|
|
48880
|
+
if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
|
|
47434
48881
|
revisionIds.add(run.revision.id);
|
|
47435
48882
|
}
|
|
47436
48883
|
}
|
|
@@ -47460,7 +48907,7 @@ function rejectRevisionsInSelection(state) {
|
|
|
47460
48907
|
return nextState;
|
|
47461
48908
|
}
|
|
47462
48909
|
function getLinkAtSelection(state) {
|
|
47463
|
-
var
|
|
48910
|
+
var _a2, _b2, _c;
|
|
47464
48911
|
const normalized = normalizeSelection(state);
|
|
47465
48912
|
const paragraphs = getParagraphs(state);
|
|
47466
48913
|
if (normalized.isCollapsed) {
|
|
@@ -47468,7 +48915,7 @@ function getLinkAtSelection(state) {
|
|
|
47468
48915
|
if (!paragraph) {
|
|
47469
48916
|
return null;
|
|
47470
48917
|
}
|
|
47471
|
-
return ((
|
|
48918
|
+
return ((_a2 = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a2.href) ?? null;
|
|
47472
48919
|
}
|
|
47473
48920
|
const touchedRuns = paragraphs.slice(normalized.startIndex, normalized.endIndex + 1).flatMap((paragraph, relativeIndex) => {
|
|
47474
48921
|
const paragraphIndex = normalized.startIndex + relativeIndex;
|
|
@@ -47479,13 +48926,13 @@ function getLinkAtSelection(state) {
|
|
|
47479
48926
|
if (touchedRuns.length === 0) {
|
|
47480
48927
|
return null;
|
|
47481
48928
|
}
|
|
47482
|
-
const href = (_c = (
|
|
48929
|
+
const href = (_c = (_b2 = touchedRuns[0]) == null ? void 0 : _b2.styles) == null ? void 0 : _c.link;
|
|
47483
48930
|
if (!href) {
|
|
47484
48931
|
return null;
|
|
47485
48932
|
}
|
|
47486
48933
|
return touchedRuns.every((run) => {
|
|
47487
|
-
var
|
|
47488
|
-
return ((
|
|
48934
|
+
var _a3;
|
|
48935
|
+
return ((_a3 = run.styles) == null ? void 0 : _a3.link) === href;
|
|
47489
48936
|
}) ? href : null;
|
|
47490
48937
|
}
|
|
47491
48938
|
function setLinkAtSelection(state, href) {
|
|
@@ -47623,11 +49070,11 @@ function toggleParagraphList(state, kind) {
|
|
|
47623
49070
|
const endIndex = normalized.endIndex;
|
|
47624
49071
|
const targetedParagraphs = paragraphs.slice(startIndex, endIndex + 1);
|
|
47625
49072
|
const shouldClear = targetedParagraphs.length > 0 && targetedParagraphs.every((paragraph) => {
|
|
47626
|
-
var
|
|
47627
|
-
return ((
|
|
49073
|
+
var _a2;
|
|
49074
|
+
return ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) === kind;
|
|
47628
49075
|
});
|
|
47629
49076
|
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
47630
|
-
var
|
|
49077
|
+
var _a2, _b2, _c;
|
|
47631
49078
|
if (paragraphIndex < startIndex || paragraphIndex > endIndex) {
|
|
47632
49079
|
return cloneParagraph(paragraph);
|
|
47633
49080
|
}
|
|
@@ -47638,8 +49085,8 @@ function toggleParagraphList(state, kind) {
|
|
|
47638
49085
|
}
|
|
47639
49086
|
nextParagraph.list = {
|
|
47640
49087
|
kind,
|
|
47641
|
-
level: ((
|
|
47642
|
-
format: (
|
|
49088
|
+
level: ((_a2 = paragraph.list) == null ? void 0 : _a2.level) ?? 0,
|
|
49089
|
+
format: (_b2 = paragraph.list) == null ? void 0 : _b2.format,
|
|
47643
49090
|
startAt: (_c = paragraph.list) == null ? void 0 : _c.startAt
|
|
47644
49091
|
};
|
|
47645
49092
|
return nextParagraph;
|
|
@@ -47997,12 +49444,12 @@ function createEditorCommandsController(deps) {
|
|
|
47997
49444
|
focusInput();
|
|
47998
49445
|
};
|
|
47999
49446
|
const promptForImageAlt = () => {
|
|
48000
|
-
var
|
|
49447
|
+
var _a2;
|
|
48001
49448
|
const run = selectedImageRun();
|
|
48002
49449
|
if (!run) {
|
|
48003
49450
|
return;
|
|
48004
49451
|
}
|
|
48005
|
-
const currentAlt = ((
|
|
49452
|
+
const currentAlt = ((_a2 = getRunImage(run.run)) == null ? void 0 : _a2.alt) ?? "";
|
|
48006
49453
|
deps.openImageAltDialog(currentAlt);
|
|
48007
49454
|
};
|
|
48008
49455
|
const applyImageCaptionCommand = (caption) => {
|
|
@@ -48098,13 +49545,13 @@ class EditorCommandRegistry {
|
|
|
48098
49545
|
return Array.from(this.bindings.values());
|
|
48099
49546
|
}
|
|
48100
49547
|
execute(event, deps, commandExecutor) {
|
|
48101
|
-
var
|
|
49548
|
+
var _a2;
|
|
48102
49549
|
const isCtrlOrMeta = event.ctrlKey || event.metaKey;
|
|
48103
49550
|
const lowerKey = event.key.toLowerCase();
|
|
48104
49551
|
for (const binding of this.bindings.values()) {
|
|
48105
49552
|
if (binding.key.toLowerCase() === lowerKey && Boolean(binding.ctrlOrMeta) === isCtrlOrMeta && Boolean(binding.shift) === event.shiftKey && Boolean(binding.alt) === event.altKey) {
|
|
48106
49553
|
if (binding.command && commandExecutor) {
|
|
48107
|
-
const canExecute = ((
|
|
49554
|
+
const canExecute = ((_a2 = commandExecutor.canExecuteCommand) == null ? void 0 : _a2.call(commandExecutor, binding.command)) ?? true;
|
|
48108
49555
|
if (canExecute) {
|
|
48109
49556
|
commandExecutor.executeCommand(binding.command);
|
|
48110
49557
|
event.preventDefault();
|
|
@@ -48373,12 +49820,12 @@ function createEditorKeyboardController(deps) {
|
|
|
48373
49820
|
}
|
|
48374
49821
|
const commandExecutor = deps.executeCommand ? {
|
|
48375
49822
|
executeCommand: (commandName, payload) => {
|
|
48376
|
-
var
|
|
48377
|
-
return (
|
|
49823
|
+
var _a2;
|
|
49824
|
+
return (_a2 = deps.executeCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
|
|
48378
49825
|
},
|
|
48379
49826
|
canExecuteCommand: (commandName, payload) => {
|
|
48380
|
-
var
|
|
48381
|
-
return (
|
|
49827
|
+
var _a2;
|
|
49828
|
+
return (_a2 = deps.canExecuteCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
|
|
48382
49829
|
}
|
|
48383
49830
|
} : void 0;
|
|
48384
49831
|
if (registry.execute(event, deps, commandExecutor)) {
|
|
@@ -48790,10 +50237,10 @@ const DEFAULT_TOC_MAX_LEVEL = 3;
|
|
|
48790
50237
|
const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
|
|
48791
50238
|
const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
|
|
48792
50239
|
function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
48793
|
-
var
|
|
50240
|
+
var _a2;
|
|
48794
50241
|
const headings = [];
|
|
48795
50242
|
for (const paragraph of getDocumentParagraphs(state.document)) {
|
|
48796
|
-
const level = getHeadingLevel((
|
|
50243
|
+
const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
|
|
48797
50244
|
if (level === null || level > maxLevel) continue;
|
|
48798
50245
|
const text = getParagraphText(paragraph).trim();
|
|
48799
50246
|
if (!text) continue;
|
|
@@ -49645,18 +51092,18 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49645
51092
|
};
|
|
49646
51093
|
const essentialsDocument = {
|
|
49647
51094
|
documentStyles: () => {
|
|
49648
|
-
var
|
|
51095
|
+
var _a2, _b2;
|
|
49649
51096
|
const document2 = options.state().document;
|
|
49650
51097
|
const styles = (document2 == null ? void 0 : document2.styles) ?? {};
|
|
49651
51098
|
const usedStyleIds = /* @__PURE__ */ new Set();
|
|
49652
51099
|
for (const paragraph of getDocumentParagraphs(document2)) {
|
|
49653
|
-
if ((
|
|
51100
|
+
if ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) usedStyleIds.add(paragraph.style.styleId);
|
|
49654
51101
|
for (const run of paragraph.runs) {
|
|
49655
|
-
if ((
|
|
51102
|
+
if ((_b2 = run.styles) == null ? void 0 : _b2.styleId) usedStyleIds.add(run.styles.styleId);
|
|
49656
51103
|
}
|
|
49657
51104
|
}
|
|
49658
51105
|
return Object.values(styles).map((style2) => {
|
|
49659
|
-
var
|
|
51106
|
+
var _a3;
|
|
49660
51107
|
const preview = resolveNamedTextStyle(style2.id, styles);
|
|
49661
51108
|
return {
|
|
49662
51109
|
id: style2.id,
|
|
@@ -49667,7 +51114,7 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49667
51114
|
semiHidden: style2.semiHidden,
|
|
49668
51115
|
unhideWhenUsed: style2.unhideWhenUsed,
|
|
49669
51116
|
isUsed: usedStyleIds.has(style2.id),
|
|
49670
|
-
fontFamily: ((
|
|
51117
|
+
fontFamily: ((_a3 = preview.fontFamily) == null ? void 0 : _a3.trim()) || void 0,
|
|
49671
51118
|
fontSize: typeof preview.fontSize === "number" ? preview.fontSize : void 0,
|
|
49672
51119
|
color: preview.color ?? void 0,
|
|
49673
51120
|
bold: preview.bold ?? void 0,
|
|
@@ -49678,12 +51125,12 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49678
51125
|
exportDocx: () => void options.docIO.handleExportDocx(),
|
|
49679
51126
|
exportPdf: () => void options.docIO.handleExportPdf(),
|
|
49680
51127
|
importDocument: () => {
|
|
49681
|
-
var
|
|
49682
|
-
return (
|
|
51128
|
+
var _a2;
|
|
51129
|
+
return (_a2 = options.importInputRef()) == null ? void 0 : _a2.click();
|
|
49683
51130
|
},
|
|
49684
51131
|
insertImage: () => {
|
|
49685
|
-
var
|
|
49686
|
-
return (
|
|
51132
|
+
var _a2;
|
|
51133
|
+
return (_a2 = options.imageInputRef()) == null ? void 0 : _a2.click();
|
|
49687
51134
|
},
|
|
49688
51135
|
insertShape: (preset) => options.applyTransactionalState(
|
|
49689
51136
|
(current) => insertShapeAtSelection(current, preset)
|
|
@@ -49781,15 +51228,15 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49781
51228
|
};
|
|
49782
51229
|
const essentialsSection = {
|
|
49783
51230
|
isLandscape: () => {
|
|
49784
|
-
var
|
|
51231
|
+
var _a2, _b2;
|
|
49785
51232
|
const idx = getActiveSectionIndex(options.state());
|
|
49786
|
-
const section = ((
|
|
49787
|
-
return ((
|
|
51233
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
51234
|
+
return ((_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
|
|
49788
51235
|
},
|
|
49789
51236
|
setOrientation: (orientation) => {
|
|
49790
|
-
var
|
|
51237
|
+
var _a2;
|
|
49791
51238
|
const idx = getActiveSectionIndex(options.state());
|
|
49792
|
-
const section = ((
|
|
51239
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
49793
51240
|
if (!section) return;
|
|
49794
51241
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
49795
51242
|
pageSettings: {
|
|
@@ -49799,11 +51246,11 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49799
51246
|
});
|
|
49800
51247
|
},
|
|
49801
51248
|
toggleOrientation: () => {
|
|
49802
|
-
var
|
|
51249
|
+
var _a2, _b2;
|
|
49803
51250
|
const idx = getActiveSectionIndex(options.state());
|
|
49804
|
-
const section = ((
|
|
51251
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
49805
51252
|
if (!section) return;
|
|
49806
|
-
const current = ((
|
|
51253
|
+
const current = ((_b2 = section.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
|
|
49807
51254
|
essentialsSection.setOrientation(
|
|
49808
51255
|
current === "portrait" ? "landscape" : "portrait"
|
|
49809
51256
|
);
|
|
@@ -49811,15 +51258,15 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
49811
51258
|
breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
|
|
49812
51259
|
breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
|
|
49813
51260
|
getMargins: () => {
|
|
49814
|
-
var
|
|
51261
|
+
var _a2, _b2;
|
|
49815
51262
|
const idx = getActiveSectionIndex(options.state());
|
|
49816
|
-
const section = ((
|
|
49817
|
-
return (
|
|
51263
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
51264
|
+
return (_b2 = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b2.margins;
|
|
49818
51265
|
},
|
|
49819
51266
|
setPageMargins: (margins) => {
|
|
49820
|
-
var
|
|
51267
|
+
var _a2;
|
|
49821
51268
|
const idx = getActiveSectionIndex(options.state());
|
|
49822
|
-
const section = ((
|
|
51269
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
49823
51270
|
if (!(section == null ? void 0 : section.pageSettings)) return;
|
|
49824
51271
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
49825
51272
|
pageSettings: {
|
|
@@ -50318,7 +51765,7 @@ const defaultMenuItems = [
|
|
|
50318
51765
|
}
|
|
50319
51766
|
];
|
|
50320
51767
|
function useEditorRuntimePlugins(options) {
|
|
50321
|
-
var
|
|
51768
|
+
var _a2, _b2;
|
|
50322
51769
|
const runtimePlugins = [
|
|
50323
51770
|
options.essentialsPlugin,
|
|
50324
51771
|
...options.externalPlugins ?? []
|
|
@@ -50362,8 +51809,8 @@ function useEditorRuntimePlugins(options) {
|
|
|
50362
51809
|
contributedMenuIds.push(item.id);
|
|
50363
51810
|
}
|
|
50364
51811
|
}
|
|
50365
|
-
(
|
|
50366
|
-
(
|
|
51812
|
+
(_a2 = options.customizeToolbar) == null ? void 0 : _a2.call(options, toolbarRegistry);
|
|
51813
|
+
(_b2 = options.customizeMenubar) == null ? void 0 : _b2.call(options, menuRegistry);
|
|
50367
51814
|
return {
|
|
50368
51815
|
runtimePlugins,
|
|
50369
51816
|
toolbarRegistry,
|
|
@@ -50387,13 +51834,13 @@ function createRuntimeCommandHost(options) {
|
|
|
50387
51834
|
);
|
|
50388
51835
|
let disposed = false;
|
|
50389
51836
|
const commandStateOf = (commandRef) => {
|
|
50390
|
-
var
|
|
51837
|
+
var _a2;
|
|
50391
51838
|
const commandName = commandRefName(commandRef);
|
|
50392
51839
|
const cmd = runtimeEditor().commands.get(commandName);
|
|
50393
51840
|
if (!cmd) {
|
|
50394
51841
|
return { isEnabled: false, isActive: false, value: void 0 };
|
|
50395
51842
|
}
|
|
50396
|
-
const refreshed = ((
|
|
51843
|
+
const refreshed = ((_a2 = cmd.refresh) == null ? void 0 : _a2.call(cmd)) ?? { isEnabled: true };
|
|
50397
51844
|
return {
|
|
50398
51845
|
isEnabled: refreshed.isEnabled !== false,
|
|
50399
51846
|
isActive: Boolean(refreshed.isActive),
|
|
@@ -50421,7 +51868,7 @@ function createRuntimeCommandHost(options) {
|
|
|
50421
51868
|
focusEditor: options.focusEditor
|
|
50422
51869
|
});
|
|
50423
51870
|
const initialize = async () => {
|
|
50424
|
-
var
|
|
51871
|
+
var _a2, _b2;
|
|
50425
51872
|
try {
|
|
50426
51873
|
const initializedRuntimeEditor = await Editor.create({
|
|
50427
51874
|
doc: options.initialDocument,
|
|
@@ -50436,14 +51883,14 @@ function createRuntimeCommandHost(options) {
|
|
|
50436
51883
|
await previousRuntimeEditor.destroy();
|
|
50437
51884
|
setRuntimeReady(true);
|
|
50438
51885
|
requestAnimationFrame(() => {
|
|
50439
|
-
var
|
|
50440
|
-
(
|
|
50441
|
-
(
|
|
51886
|
+
var _a3, _b3;
|
|
51887
|
+
(_a3 = options.onSettled) == null ? void 0 : _a3.call(options);
|
|
51888
|
+
(_b3 = options.onReady) == null ? void 0 : _b3.call(options, initializedRuntimeEditor);
|
|
50442
51889
|
});
|
|
50443
51890
|
} catch (error) {
|
|
50444
51891
|
options.logger.error("runtime:init failed", error);
|
|
50445
|
-
(
|
|
50446
|
-
(
|
|
51892
|
+
(_a2 = options.onError) == null ? void 0 : _a2.call(options, error);
|
|
51893
|
+
(_b2 = options.onSettled) == null ? void 0 : _b2.call(options);
|
|
50447
51894
|
}
|
|
50448
51895
|
};
|
|
50449
51896
|
const dispose = async () => {
|
|
@@ -50559,9 +52006,9 @@ function createEditorCommandRuntime(deps) {
|
|
|
50559
52006
|
focusEditor: deps.focusInput,
|
|
50560
52007
|
logger: deps.logger,
|
|
50561
52008
|
onReady: (editor) => {
|
|
50562
|
-
var
|
|
52009
|
+
var _a2, _b2;
|
|
50563
52010
|
runtimeClient.resolveReady(editor);
|
|
50564
|
-
(
|
|
52011
|
+
(_b2 = (_a2 = deps.runtimeOptions()).onReady) == null ? void 0 : _b2.call(_a2, runtimeClient);
|
|
50565
52012
|
},
|
|
50566
52013
|
onSettled: () => {
|
|
50567
52014
|
deps.setInitialLoading(false);
|
|
@@ -50622,8 +52069,8 @@ function createEditorCommandRuntime(deps) {
|
|
|
50622
52069
|
}
|
|
50623
52070
|
var _tmpl$ = /* @__PURE__ */ template(`<div class="oasis-editor-shell oasis-editor-app">`);
|
|
50624
52071
|
function OasisEditorApp(props = {}) {
|
|
50625
|
-
var
|
|
50626
|
-
const runtimeClient = ((
|
|
52072
|
+
var _a2;
|
|
52073
|
+
const runtimeClient = ((_a2 = props.runtime) == null ? void 0 : _a2.client) ?? createOasisEditorClient();
|
|
50627
52074
|
const ui = () => props.ui ?? {};
|
|
50628
52075
|
const documentOptions = () => props.document ?? {};
|
|
50629
52076
|
const runtimeOptions = () => props.runtime ?? {};
|
|
@@ -50708,6 +52155,8 @@ function OasisEditorApp(props = {}) {
|
|
|
50708
52155
|
docIO,
|
|
50709
52156
|
measuredBlockHeights,
|
|
50710
52157
|
measuredParagraphLayouts,
|
|
52158
|
+
documentLayout,
|
|
52159
|
+
canvasSnapshotProvider,
|
|
50711
52160
|
inputBox,
|
|
50712
52161
|
selectionBoxes,
|
|
50713
52162
|
commentHighlights,
|
|
@@ -50747,8 +52196,8 @@ function OasisEditorApp(props = {}) {
|
|
|
50747
52196
|
caretBox,
|
|
50748
52197
|
preferredColumnX,
|
|
50749
52198
|
setPreferredColumnX,
|
|
50750
|
-
|
|
50751
|
-
|
|
52199
|
+
documentLayout,
|
|
52200
|
+
canvasSnapshotProvider
|
|
50752
52201
|
});
|
|
50753
52202
|
const {
|
|
50754
52203
|
selectedImageRun,
|
|
@@ -50848,6 +52297,7 @@ function OasisEditorApp(props = {}) {
|
|
|
50848
52297
|
fileHandlers: editorFileHandlers
|
|
50849
52298
|
} = buildEditorViewProps({
|
|
50850
52299
|
layout: {
|
|
52300
|
+
documentLayout,
|
|
50851
52301
|
viewportHeight: ui().viewportHeight,
|
|
50852
52302
|
className: ui().class,
|
|
50853
52303
|
style: ui().style,
|
|
@@ -51001,6 +52451,7 @@ function OasisEditorApp(props = {}) {
|
|
|
51001
52451
|
viewportHeight: () => ui().viewportHeight,
|
|
51002
52452
|
measuredBlockHeights,
|
|
51003
52453
|
measuredParagraphLayouts,
|
|
52454
|
+
documentLayout,
|
|
51004
52455
|
layout: editorLayoutProps,
|
|
51005
52456
|
overlays: editorOverlayProps,
|
|
51006
52457
|
refs: editorRefs,
|
|
@@ -51014,6 +52465,11 @@ function OasisEditorApp(props = {}) {
|
|
|
51014
52465
|
get surfaceRef() {
|
|
51015
52466
|
return surfaceRef();
|
|
51016
52467
|
},
|
|
52468
|
+
documentLayout,
|
|
52469
|
+
snapshotProvider: canvasSnapshotProvider,
|
|
52470
|
+
get zoomFactor() {
|
|
52471
|
+
return zoom.zoomFactor;
|
|
52472
|
+
},
|
|
51017
52473
|
tableResize,
|
|
51018
52474
|
imageOps,
|
|
51019
52475
|
tableDrag,
|
|
@@ -51029,12 +52485,12 @@ function OasisEditorApp(props = {}) {
|
|
|
51029
52485
|
return loadingLabel();
|
|
51030
52486
|
},
|
|
51031
52487
|
get ["class"]() {
|
|
51032
|
-
var
|
|
51033
|
-
return (
|
|
52488
|
+
var _a3;
|
|
52489
|
+
return (_a3 = loadingOptions()) == null ? void 0 : _a3.class;
|
|
51034
52490
|
},
|
|
51035
52491
|
get style() {
|
|
51036
|
-
var
|
|
51037
|
-
return (
|
|
52492
|
+
var _a3;
|
|
52493
|
+
return (_a3 = loadingOptions()) == null ? void 0 : _a3.style;
|
|
51038
52494
|
}
|
|
51039
52495
|
});
|
|
51040
52496
|
}
|