oasis-editor 0.0.107 → 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-BFNqDc07.js → OasisEditorApp-DkiTrFZ6.js} +1282 -456
- 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-4uLtMJwI.js → index-DzBLUs91.js} +103 -102
- package/dist/oasis-editor.js +50 -50
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
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 { 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
|
|
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
5
|
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
6
6
|
const {
|
|
7
7
|
pageIndex,
|
|
@@ -13,7 +13,7 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
|
13
13
|
defaultTabStop
|
|
14
14
|
} = context;
|
|
15
15
|
return blocks.map((block, index) => {
|
|
16
|
-
var
|
|
16
|
+
var _a2, _b2;
|
|
17
17
|
if (block.type === "paragraph") {
|
|
18
18
|
const layout = deps.projectParagraphLayout(
|
|
19
19
|
block,
|
|
@@ -47,8 +47,8 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
|
47
47
|
sourceBlockId: block.id,
|
|
48
48
|
blockType: block.type,
|
|
49
49
|
globalIndex: index,
|
|
50
|
-
estimatedHeight: ((
|
|
51
|
-
floatingTableHeight: ((
|
|
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
52
|
sourceBlock: block
|
|
53
53
|
};
|
|
54
54
|
});
|
|
@@ -326,13 +326,13 @@ function spacerParagraph() {
|
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
328
|
function buildEndnoteFlowBlocks(document2) {
|
|
329
|
-
var
|
|
329
|
+
var _a2, _b2, _c;
|
|
330
330
|
const referenced = listReferencedEndnotes(document2);
|
|
331
|
-
const items = (
|
|
331
|
+
const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
|
|
332
332
|
if (!items || referenced.length === 0) {
|
|
333
333
|
return [];
|
|
334
334
|
}
|
|
335
|
-
const format = ((_c = (
|
|
335
|
+
const format = ((_c = (_b2 = document2.endnotes) == null ? void 0 : _b2.settings) == null ? void 0 : _c.numberFormat) ?? "decimal";
|
|
336
336
|
const out = [spacerParagraph()];
|
|
337
337
|
for (const ref of referenced) {
|
|
338
338
|
const endnote = items[ref.endnoteId];
|
|
@@ -374,8 +374,8 @@ function injectEndnotesIntoDocument(document2) {
|
|
|
374
374
|
function blockContainsNumPagesField(block) {
|
|
375
375
|
if (block.type === "paragraph") {
|
|
376
376
|
return block.runs.some((run) => {
|
|
377
|
-
var
|
|
378
|
-
return ((
|
|
377
|
+
var _a2;
|
|
378
|
+
return ((_a2 = getRunField(run)) == null ? void 0 : _a2.type) === "NUMPAGES";
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
381
|
return block.rows.some(
|
|
@@ -396,10 +396,10 @@ function documentContainsNumPagesField(document2) {
|
|
|
396
396
|
);
|
|
397
397
|
}
|
|
398
398
|
function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights, measuredParagraphLayouts, options = {}) {
|
|
399
|
-
var
|
|
399
|
+
var _a2, _b2;
|
|
400
400
|
const measurer = options.measurer ?? domTextMeasurer;
|
|
401
401
|
setActiveHyphenation(
|
|
402
|
-
((
|
|
402
|
+
((_a2 = document2.settings) == null ? void 0 : _a2.autoHyphenation) ? {
|
|
403
403
|
enabled: true,
|
|
404
404
|
zone: document2.settings.hyphenationZone,
|
|
405
405
|
consecutiveLimit: document2.settings.consecutiveHyphenLimit,
|
|
@@ -416,7 +416,7 @@ function projectDocumentLayout(document2, maxPageHeightOverride, measuredHeights
|
|
|
416
416
|
measuredHeights,
|
|
417
417
|
measuredParagraphLayouts,
|
|
418
418
|
measurer,
|
|
419
|
-
defaultTabStop: (
|
|
419
|
+
defaultTabStop: (_b2 = document2.settings) == null ? void 0 : _b2.defaultTabStop,
|
|
420
420
|
needsTotalPages,
|
|
421
421
|
projectBlocks: projectBlocksLayout,
|
|
422
422
|
projectHeaderFooterBlocks
|
|
@@ -696,12 +696,12 @@ function cloneBlock(block) {
|
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
function cloneSection(section) {
|
|
699
|
-
var
|
|
699
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
700
700
|
return {
|
|
701
701
|
...section,
|
|
702
702
|
blocks: section.blocks.map(cloneBlock),
|
|
703
|
-
header: (
|
|
704
|
-
firstPageHeader: (
|
|
703
|
+
header: (_a2 = section.header) == null ? void 0 : _a2.map(cloneBlock),
|
|
704
|
+
firstPageHeader: (_b2 = section.firstPageHeader) == null ? void 0 : _b2.map(cloneBlock),
|
|
705
705
|
evenPageHeader: (_c = section.evenPageHeader) == null ? void 0 : _c.map(cloneBlock),
|
|
706
706
|
footer: (_d = section.footer) == null ? void 0 : _d.map(cloneBlock),
|
|
707
707
|
firstPageFooter: (_e = section.firstPageFooter) == null ? void 0 : _e.map(cloneBlock),
|
|
@@ -715,7 +715,7 @@ function cloneFootnote(footnote) {
|
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
717
|
function cloneFootnotes(footnotes) {
|
|
718
|
-
var
|
|
718
|
+
var _a2, _b2;
|
|
719
719
|
if (!footnotes) return void 0;
|
|
720
720
|
const nextItems = {};
|
|
721
721
|
for (const [id, footnote] of Object.entries(footnotes.items)) {
|
|
@@ -724,8 +724,8 @@ function cloneFootnotes(footnotes) {
|
|
|
724
724
|
return {
|
|
725
725
|
items: nextItems,
|
|
726
726
|
settings: footnotes.settings ? { ...footnotes.settings } : void 0,
|
|
727
|
-
separator: (
|
|
728
|
-
continuationSeparator: (
|
|
727
|
+
separator: (_a2 = footnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
|
|
728
|
+
continuationSeparator: (_b2 = footnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
|
|
729
729
|
};
|
|
730
730
|
}
|
|
731
731
|
function cloneEndnote(endnote) {
|
|
@@ -735,7 +735,7 @@ function cloneEndnote(endnote) {
|
|
|
735
735
|
};
|
|
736
736
|
}
|
|
737
737
|
function cloneEndnotes(endnotes) {
|
|
738
|
-
var
|
|
738
|
+
var _a2, _b2;
|
|
739
739
|
if (!endnotes) return void 0;
|
|
740
740
|
const nextItems = {};
|
|
741
741
|
for (const [id, endnote] of Object.entries(endnotes.items)) {
|
|
@@ -744,17 +744,17 @@ function cloneEndnotes(endnotes) {
|
|
|
744
744
|
return {
|
|
745
745
|
items: nextItems,
|
|
746
746
|
settings: endnotes.settings ? { ...endnotes.settings } : void 0,
|
|
747
|
-
separator: (
|
|
748
|
-
continuationSeparator: (
|
|
747
|
+
separator: (_a2 = endnotes.separator) == null ? void 0 : _a2.map(cloneBlock),
|
|
748
|
+
continuationSeparator: (_b2 = endnotes.continuationSeparator) == null ? void 0 : _b2.map(cloneBlock)
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
751
|
function cloneEditorState(source) {
|
|
752
|
-
var
|
|
752
|
+
var _a2;
|
|
753
753
|
return {
|
|
754
754
|
...source,
|
|
755
755
|
document: {
|
|
756
756
|
...source.document,
|
|
757
|
-
sections: (
|
|
757
|
+
sections: (_a2 = source.document.sections) == null ? void 0 : _a2.map(cloneSection),
|
|
758
758
|
footnotes: cloneFootnotes(source.document.footnotes),
|
|
759
759
|
endnotes: cloneEndnotes(source.document.endnotes)
|
|
760
760
|
},
|
|
@@ -876,7 +876,7 @@ const getClassNames = (attrs) => {
|
|
|
876
876
|
return "";
|
|
877
877
|
};
|
|
878
878
|
const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
|
|
879
|
-
var
|
|
879
|
+
var _a2;
|
|
880
880
|
const iconName = element.getAttribute(nameAttr);
|
|
881
881
|
if (iconName == null) return;
|
|
882
882
|
const ComponentName = toPascalCase(iconName);
|
|
@@ -909,7 +909,7 @@ const replaceElement = (element, { nameAttr, icons: icons2, attrs }) => {
|
|
|
909
909
|
});
|
|
910
910
|
}
|
|
911
911
|
const svgElement = createElement(iconNode, iconAttrs);
|
|
912
|
-
return (
|
|
912
|
+
return (_a2 = element.parentNode) == null ? void 0 : _a2.replaceChild(svgElement, element);
|
|
913
913
|
};
|
|
914
914
|
/**
|
|
915
915
|
* @license lucide v1.11.0 - ISC
|
|
@@ -26835,9 +26835,9 @@ function cloneLayoutSnapshot(snapshot) {
|
|
|
26835
26835
|
};
|
|
26836
26836
|
}
|
|
26837
26837
|
function isCanvasDebugEnabled() {
|
|
26838
|
-
var
|
|
26838
|
+
var _a2;
|
|
26839
26839
|
const viteEnv = __vite_import_meta_env__ ?? {};
|
|
26840
|
-
const processEnv = ((
|
|
26840
|
+
const processEnv = ((_a2 = globalThis.process) == null ? void 0 : _a2.env) ?? {};
|
|
26841
26841
|
return viteEnv.DEV === true || viteEnv.MODE === "test" || processEnv.NODE_ENV === "test" || viteEnv.VITE_OASIS_CANVAS_DEBUG === "1";
|
|
26842
26842
|
}
|
|
26843
26843
|
function buildApi() {
|
|
@@ -27233,12 +27233,12 @@ function addFontFamily(target, seen, value) {
|
|
|
27233
27233
|
target.push(family);
|
|
27234
27234
|
}
|
|
27235
27235
|
function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilies = []) {
|
|
27236
|
-
var
|
|
27236
|
+
var _a2;
|
|
27237
27237
|
const seen = /* @__PURE__ */ new Set();
|
|
27238
27238
|
const documentFonts = [];
|
|
27239
27239
|
const fallbackFonts = [];
|
|
27240
27240
|
for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
|
|
27241
|
-
addFontFamily(documentFonts, seen, (
|
|
27241
|
+
addFontFamily(documentFonts, seen, (_a2 = style2.textStyle) == null ? void 0 : _a2.fontFamily);
|
|
27242
27242
|
}
|
|
27243
27243
|
addFontFamily(documentFonts, seen, toolbarStyleState.fontFamily);
|
|
27244
27244
|
for (const family of localFontFamilies) {
|
|
@@ -27253,10 +27253,10 @@ function computeFontFamilyOptions(document2, toolbarStyleState, localFontFamilie
|
|
|
27253
27253
|
];
|
|
27254
27254
|
}
|
|
27255
27255
|
function computeFontSizeOptions(document2, toolbarStyleState) {
|
|
27256
|
-
var
|
|
27256
|
+
var _a2;
|
|
27257
27257
|
const values = new Set(STANDARD_FONT_SIZES_PT);
|
|
27258
27258
|
for (const style2 of Object.values((document2 == null ? void 0 : document2.styles) ?? {})) {
|
|
27259
|
-
const fontSize = (
|
|
27259
|
+
const fontSize = (_a2 = style2.textStyle) == null ? void 0 : _a2.fontSize;
|
|
27260
27260
|
if (typeof fontSize === "number" && Number.isFinite(fontSize)) {
|
|
27261
27261
|
values.add(fontSizePxToPt(fontSize));
|
|
27262
27262
|
}
|
|
@@ -27376,7 +27376,7 @@ function clearParagraphList(paragraph) {
|
|
|
27376
27376
|
return nextParagraph;
|
|
27377
27377
|
}
|
|
27378
27378
|
function getStyleAtOffset(paragraph, offset) {
|
|
27379
|
-
var
|
|
27379
|
+
var _a2;
|
|
27380
27380
|
if (paragraph.runs.length === 0) {
|
|
27381
27381
|
return void 0;
|
|
27382
27382
|
}
|
|
@@ -27396,7 +27396,7 @@ function getStyleAtOffset(paragraph, offset) {
|
|
|
27396
27396
|
}
|
|
27397
27397
|
consumed = nextConsumed;
|
|
27398
27398
|
}
|
|
27399
|
-
return cloneStyle((
|
|
27399
|
+
return cloneStyle((_a2 = paragraph.runs[paragraph.runs.length - 1]) == null ? void 0 : _a2.styles);
|
|
27400
27400
|
}
|
|
27401
27401
|
function getRunAtOffset(paragraph, offset) {
|
|
27402
27402
|
let consumed = 0;
|
|
@@ -27426,9 +27426,9 @@ function getRunAtOffset(paragraph, offset) {
|
|
|
27426
27426
|
return null;
|
|
27427
27427
|
}
|
|
27428
27428
|
function expandLinkRangeInParagraph(paragraph, offset) {
|
|
27429
|
-
var
|
|
27429
|
+
var _a2, _b2, _c;
|
|
27430
27430
|
const resolved = getRunAtOffset(paragraph, offset);
|
|
27431
|
-
const href = (
|
|
27431
|
+
const href = (_a2 = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a2.link;
|
|
27432
27432
|
if (!resolved || !href || resolved.run.kind === "image") {
|
|
27433
27433
|
return null;
|
|
27434
27434
|
}
|
|
@@ -27447,7 +27447,7 @@ function expandLinkRangeInParagraph(paragraph, offset) {
|
|
|
27447
27447
|
endOffset = consumed + resolved.run.text.length;
|
|
27448
27448
|
for (let index = runIndex - 1; index >= 0; index -= 1) {
|
|
27449
27449
|
const run = runs[index];
|
|
27450
|
-
if (run.kind === "image" || ((
|
|
27450
|
+
if (run.kind === "image" || ((_b2 = run.styles) == null ? void 0 : _b2.link) !== href) {
|
|
27451
27451
|
break;
|
|
27452
27452
|
}
|
|
27453
27453
|
startOffset -= run.text.length;
|
|
@@ -27801,8 +27801,8 @@ function deleteSelectionRange(state) {
|
|
|
27801
27801
|
const startOffset2 = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
27802
27802
|
const endOffset2 = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
27803
27803
|
return mapRunsInRange(paragraph, startOffset2, endOffset2, (run) => {
|
|
27804
|
-
var
|
|
27805
|
-
if (((
|
|
27804
|
+
var _a2;
|
|
27805
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
27806
27806
|
return { ...run, text: "" };
|
|
27807
27807
|
}
|
|
27808
27808
|
return {
|
|
@@ -28122,7 +28122,7 @@ function insertPlainTextAtSelection(state, text, styleOverride) {
|
|
|
28122
28122
|
);
|
|
28123
28123
|
}
|
|
28124
28124
|
function deleteBackward(state) {
|
|
28125
|
-
var
|
|
28125
|
+
var _a2;
|
|
28126
28126
|
if (!isSelectionCollapsed(state.selection)) {
|
|
28127
28127
|
return deleteSelectionRange(state);
|
|
28128
28128
|
}
|
|
@@ -28145,7 +28145,7 @@ function deleteBackward(state) {
|
|
|
28145
28145
|
}
|
|
28146
28146
|
if (targetRunIndex !== -1) {
|
|
28147
28147
|
const targetRun = runs[targetRunIndex];
|
|
28148
|
-
if (((
|
|
28148
|
+
if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
28149
28149
|
const nextRuns2 = [
|
|
28150
28150
|
...sliceRuns(paragraph, 0, offset - 1),
|
|
28151
28151
|
...sliceRuns(paragraph, offset, getParagraphLength(paragraph))
|
|
@@ -28231,7 +28231,7 @@ function deleteBackward(state) {
|
|
|
28231
28231
|
);
|
|
28232
28232
|
}
|
|
28233
28233
|
function deleteForward(state) {
|
|
28234
|
-
var
|
|
28234
|
+
var _a2;
|
|
28235
28235
|
if (!isSelectionCollapsed(state.selection)) {
|
|
28236
28236
|
return deleteSelectionRange(state);
|
|
28237
28237
|
}
|
|
@@ -28254,7 +28254,7 @@ function deleteForward(state) {
|
|
|
28254
28254
|
}
|
|
28255
28255
|
if (targetRunIndex !== -1) {
|
|
28256
28256
|
const targetRun = runs[targetRunIndex];
|
|
28257
|
-
if (((
|
|
28257
|
+
if (((_a2 = targetRun.revision) == null ? void 0 : _a2.type) === "insert") {
|
|
28258
28258
|
const nextRuns2 = [
|
|
28259
28259
|
...sliceRuns(paragraph, 0, offset),
|
|
28260
28260
|
...sliceRuns(paragraph, offset + 1, getParagraphLength(paragraph))
|
|
@@ -28354,8 +28354,8 @@ function toggleTextStyle(state, key) {
|
|
|
28354
28354
|
return state;
|
|
28355
28355
|
}
|
|
28356
28356
|
const shouldEnable = !touchedRuns.every((run) => {
|
|
28357
|
-
var
|
|
28358
|
-
return Boolean((
|
|
28357
|
+
var _a2;
|
|
28358
|
+
return Boolean((_a2 = run.styles) == null ? void 0 : _a2[key]);
|
|
28359
28359
|
});
|
|
28360
28360
|
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
28361
28361
|
if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
|
|
@@ -28387,8 +28387,8 @@ function clearSelectedTextFormatting(state) {
|
|
|
28387
28387
|
const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
28388
28388
|
const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
28389
28389
|
return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
|
|
28390
|
-
var
|
|
28391
|
-
const link = (
|
|
28390
|
+
var _a2;
|
|
28391
|
+
const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
28392
28392
|
const styles = link != null && link !== "" ? { link } : {};
|
|
28393
28393
|
return { ...run, styles };
|
|
28394
28394
|
});
|
|
@@ -28691,7 +28691,7 @@ function createFontDialogBridge(deps) {
|
|
|
28691
28691
|
};
|
|
28692
28692
|
}
|
|
28693
28693
|
function moveBlockToPosition(state, blockId, targetPosition) {
|
|
28694
|
-
var
|
|
28694
|
+
var _a2;
|
|
28695
28695
|
let movedBlock;
|
|
28696
28696
|
const removeFromBlocks = (blocks) => {
|
|
28697
28697
|
const idx = blocks.findIndex((b) => b.id === blockId);
|
|
@@ -28741,7 +28741,7 @@ function moveBlockToPosition(state, blockId, targetPosition) {
|
|
|
28741
28741
|
};
|
|
28742
28742
|
const activeIdx = getActiveSectionIndex(state);
|
|
28743
28743
|
const zone = getActiveZone(state);
|
|
28744
|
-
const activeSection = (
|
|
28744
|
+
const activeSection = (_a2 = nextDocument.sections) == null ? void 0 : _a2[activeIdx];
|
|
28745
28745
|
const section = { ...activeSection };
|
|
28746
28746
|
let found = false;
|
|
28747
28747
|
if (zone === "header") {
|
|
@@ -28914,7 +28914,7 @@ function insertSectionBreakAtSelection(state, breakType) {
|
|
|
28914
28914
|
};
|
|
28915
28915
|
}
|
|
28916
28916
|
function updateSectionSettings(state, sectionIndex, settings) {
|
|
28917
|
-
var
|
|
28917
|
+
var _a2;
|
|
28918
28918
|
const sections = getDocumentSections(state.document);
|
|
28919
28919
|
if (sectionIndex < 0 || sectionIndex >= sections.length) {
|
|
28920
28920
|
return state;
|
|
@@ -28928,7 +28928,7 @@ function updateSectionSettings(state, sectionIndex, settings) {
|
|
|
28928
28928
|
...settings.pageSettings ?? {},
|
|
28929
28929
|
margins: {
|
|
28930
28930
|
...nextSections[sectionIndex].pageSettings.margins,
|
|
28931
|
-
...((
|
|
28931
|
+
...((_a2 = settings.pageSettings) == null ? void 0 : _a2.margins) ?? {}
|
|
28932
28932
|
}
|
|
28933
28933
|
}
|
|
28934
28934
|
};
|
|
@@ -29480,7 +29480,7 @@ function parseWidthToPt(value) {
|
|
|
29480
29480
|
}
|
|
29481
29481
|
function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
|
|
29482
29482
|
const updateTable = (table) => {
|
|
29483
|
-
var
|
|
29483
|
+
var _a2;
|
|
29484
29484
|
if (table.id !== tableId) return table;
|
|
29485
29485
|
const tableLayout = buildTableCellLayout(table);
|
|
29486
29486
|
const visualColumnCount = Math.max(
|
|
@@ -29499,7 +29499,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29499
29499
|
hasGridOverride = true;
|
|
29500
29500
|
continue;
|
|
29501
29501
|
}
|
|
29502
|
-
const existing = (
|
|
29502
|
+
const existing = (_a2 = table.gridCols) == null ? void 0 : _a2[columnIndex];
|
|
29503
29503
|
if (typeof existing === "number" && Number.isFinite(existing) && existing > 0) {
|
|
29504
29504
|
nextGridCols[columnIndex] = existing;
|
|
29505
29505
|
continue;
|
|
@@ -29509,7 +29509,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29509
29509
|
}
|
|
29510
29510
|
const nextRows = table.rows.map((row, rowIndex) => {
|
|
29511
29511
|
const nextCells = row.cells.map((cell, cellIndex) => {
|
|
29512
|
-
var
|
|
29512
|
+
var _a3, _b2;
|
|
29513
29513
|
const entry = tableLayout.find(
|
|
29514
29514
|
(item) => item.rowIndex === rowIndex && item.cellIndex === cellIndex
|
|
29515
29515
|
);
|
|
@@ -29517,11 +29517,11 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29517
29517
|
const rightVisualColumnIndex = entry.visualColumnIndex + entry.colSpan - 1;
|
|
29518
29518
|
const newWidth = columnWidths[rightVisualColumnIndex];
|
|
29519
29519
|
if (newWidth !== void 0 && entry.colSpan === 1) {
|
|
29520
|
-
const propertyRevision = state.trackChangesEnabled && !((
|
|
29520
|
+
const propertyRevision = state.trackChangesEnabled && !((_a3 = cell.style) == null ? void 0 : _a3.propertyRevision) ? {
|
|
29521
29521
|
...createTableRevisionMetadata(),
|
|
29522
29522
|
type: "property",
|
|
29523
29523
|
previous: { ...cell.style ?? {} }
|
|
29524
|
-
} : (
|
|
29524
|
+
} : (_b2 = cell.style) == null ? void 0 : _b2.propertyRevision;
|
|
29525
29525
|
return {
|
|
29526
29526
|
...cell,
|
|
29527
29527
|
style: {
|
|
@@ -29745,17 +29745,17 @@ function isVisibleBorder(border) {
|
|
|
29745
29745
|
return !!border && border.type !== "none" && border.width > 0;
|
|
29746
29746
|
}
|
|
29747
29747
|
function buildFloatingSummary(table) {
|
|
29748
|
-
var
|
|
29749
|
-
const floating = (
|
|
29748
|
+
var _a2;
|
|
29749
|
+
const floating = (_a2 = table.style) == null ? void 0 : _a2.floating;
|
|
29750
29750
|
if (!floating || Object.keys(floating).length === 0) return "";
|
|
29751
29751
|
return Object.entries(floating).map(([key, value]) => `${key}=${value}`).join(", ");
|
|
29752
29752
|
}
|
|
29753
29753
|
function buildInitialValues(ctx, activeTab = "table") {
|
|
29754
|
-
var
|
|
29755
|
-
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);
|
|
29756
29756
|
const row = ctx.table.rows[ctx.rowIndex];
|
|
29757
29757
|
const cell = row == null ? void 0 : row.cells[ctx.cellIndex];
|
|
29758
|
-
const rowHeight = serializeWidth((
|
|
29758
|
+
const rowHeight = serializeWidth((_b2 = row == null ? void 0 : row.style) == null ? void 0 : _b2.height);
|
|
29759
29759
|
const cellWidth = serializeWidth((_c = cell == null ? void 0 : cell.style) == null ? void 0 : _c.width);
|
|
29760
29760
|
const gridWidth = (_d = ctx.table.gridCols) == null ? void 0 : _d[ctx.visualColumnIndex];
|
|
29761
29761
|
const columnWidth = serializeWidth(gridWidth);
|
|
@@ -30183,14 +30183,14 @@ function textLanguageToHtmlAttributes(language) {
|
|
|
30183
30183
|
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
30184
30184
|
}
|
|
30185
30185
|
function serializeImageRunToHtml(run, document2) {
|
|
30186
|
-
var
|
|
30186
|
+
var _a2;
|
|
30187
30187
|
if (run.kind !== "image") {
|
|
30188
30188
|
return "";
|
|
30189
30189
|
}
|
|
30190
30190
|
const resolvedSrc = resolveImageSrc(document2, run.image.src);
|
|
30191
30191
|
const altAttr = run.image.alt !== void 0 ? ` alt="${escapeHtml(run.image.alt)}"` : "";
|
|
30192
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}>`;
|
|
30193
|
-
if ((
|
|
30193
|
+
if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
|
|
30194
30194
|
return `<a href="${escapeHtml(run.styles.link)}">${img}</a>`;
|
|
30195
30195
|
}
|
|
30196
30196
|
return img;
|
|
@@ -30234,7 +30234,7 @@ function serializeParagraphRunsToHtml(runs, document2) {
|
|
|
30234
30234
|
return runs.map((run) => serializeTextRunToHtml(run, document2)).join("") || "<br>";
|
|
30235
30235
|
}
|
|
30236
30236
|
function serializeEditorSelectionToHtml(state) {
|
|
30237
|
-
var
|
|
30237
|
+
var _a2;
|
|
30238
30238
|
const normalized = normalizeSelection(state);
|
|
30239
30239
|
if (normalized.isCollapsed) {
|
|
30240
30240
|
return "";
|
|
@@ -30259,7 +30259,7 @@ function serializeEditorSelectionToHtml(state) {
|
|
|
30259
30259
|
const css = paragraphStyleToCssText(paragraph.style);
|
|
30260
30260
|
const attrs = css.length > 0 ? ` style="${css}"` : "";
|
|
30261
30261
|
const paragraphHtml = serializeParagraphRunsToHtml(runs, state.document);
|
|
30262
|
-
if ((
|
|
30262
|
+
if ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) {
|
|
30263
30263
|
const wrapperTag = paragraph.list.kind === "bullet" ? "ul" : "ol";
|
|
30264
30264
|
if (activeListKind !== paragraph.list.kind) {
|
|
30265
30265
|
closeList();
|
|
@@ -30622,13 +30622,13 @@ function parseEditorClipboardHtmlWithDom(html) {
|
|
|
30622
30622
|
function createEditorContextMenuClipboard(deps) {
|
|
30623
30623
|
const t = deps.t;
|
|
30624
30624
|
const programmaticCopy = async () => {
|
|
30625
|
-
var
|
|
30625
|
+
var _a2;
|
|
30626
30626
|
const state = deps.state();
|
|
30627
30627
|
const text = getSelectedText(state);
|
|
30628
30628
|
if (!text) return;
|
|
30629
30629
|
const html = serializeEditorSelectionToHtml(state);
|
|
30630
30630
|
try {
|
|
30631
|
-
if (typeof ClipboardItem !== "undefined" && ((
|
|
30631
|
+
if (typeof ClipboardItem !== "undefined" && ((_a2 = navigator.clipboard) == null ? void 0 : _a2.write)) {
|
|
30632
30632
|
await navigator.clipboard.write([
|
|
30633
30633
|
new ClipboardItem({
|
|
30634
30634
|
"text/plain": new Blob([text], { type: "text/plain" }),
|
|
@@ -30662,12 +30662,12 @@ function createEditorContextMenuClipboard(deps) {
|
|
|
30662
30662
|
deps.focusInput();
|
|
30663
30663
|
};
|
|
30664
30664
|
const programmaticPaste = async () => {
|
|
30665
|
-
var
|
|
30665
|
+
var _a2, _b2;
|
|
30666
30666
|
if (deps.isReadOnly()) return;
|
|
30667
30667
|
let html = "";
|
|
30668
30668
|
let text = "";
|
|
30669
30669
|
try {
|
|
30670
|
-
if ((
|
|
30670
|
+
if ((_a2 = navigator.clipboard) == null ? void 0 : _a2.read) {
|
|
30671
30671
|
const items = await navigator.clipboard.read();
|
|
30672
30672
|
for (const item of items) {
|
|
30673
30673
|
if (item.types.includes("text/html")) {
|
|
@@ -30679,7 +30679,7 @@ function createEditorContextMenuClipboard(deps) {
|
|
|
30679
30679
|
text = await blob.text();
|
|
30680
30680
|
}
|
|
30681
30681
|
}
|
|
30682
|
-
} else if ((
|
|
30682
|
+
} else if ((_b2 = navigator.clipboard) == null ? void 0 : _b2.readText) {
|
|
30683
30683
|
text = await navigator.clipboard.readText();
|
|
30684
30684
|
}
|
|
30685
30685
|
} catch (err) {
|
|
@@ -31020,19 +31020,19 @@ function createEditorUiOptions(ctx) {
|
|
|
31020
31020
|
showToolbar: () => ui().showToolbar ?? true,
|
|
31021
31021
|
showOutline: () => ui().showOutline ?? true,
|
|
31022
31022
|
toolbarView: () => {
|
|
31023
|
-
var
|
|
31024
|
-
return ((
|
|
31023
|
+
var _a2;
|
|
31024
|
+
return ((_a2 = ui().toolbar) == null ? void 0 : _a2.view) ?? "ribbon";
|
|
31025
31025
|
},
|
|
31026
31026
|
toolbarLayout: () => {
|
|
31027
|
-
var
|
|
31028
|
-
return ((
|
|
31027
|
+
var _a2;
|
|
31028
|
+
return ((_a2 = ui().toolbar) == null ? void 0 : _a2.layout) ?? "overflow";
|
|
31029
31029
|
},
|
|
31030
31030
|
isReadOnly: () => documentOptions().readOnly ?? false,
|
|
31031
31031
|
useComposedShell: () => ui().uiVariant === "docs" || (ui().shell ?? "document") !== "document",
|
|
31032
31032
|
loadingOptions,
|
|
31033
31033
|
loadingLabel: () => {
|
|
31034
|
-
var
|
|
31035
|
-
return ((
|
|
31034
|
+
var _a2;
|
|
31035
|
+
return ((_a2 = loadingOptions()) == null ? void 0 : _a2.label) ?? "Loading oasis-editor...";
|
|
31036
31036
|
},
|
|
31037
31037
|
shellComponent: () => {
|
|
31038
31038
|
const s = ui().shell ?? "document";
|
|
@@ -31062,7 +31062,7 @@ function computeShouldShowCaret(state, caretBox) {
|
|
|
31062
31062
|
}
|
|
31063
31063
|
function DropCaret(props) {
|
|
31064
31064
|
const layout = createMemo(() => {
|
|
31065
|
-
var
|
|
31065
|
+
var _a2, _b2, _c;
|
|
31066
31066
|
const pos = props.targetPos();
|
|
31067
31067
|
const surfaceRef = props.surfaceRef;
|
|
31068
31068
|
if (!surfaceRef) return null;
|
|
@@ -31070,7 +31070,7 @@ function DropCaret(props) {
|
|
|
31070
31070
|
surface: surfaceRef,
|
|
31071
31071
|
state: props.state,
|
|
31072
31072
|
documentLayout: props.documentLayout(),
|
|
31073
|
-
zoomFactor: (
|
|
31073
|
+
zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
|
|
31074
31074
|
});
|
|
31075
31075
|
let viewportLeft = 0;
|
|
31076
31076
|
let viewportTop = 0;
|
|
@@ -31095,7 +31095,7 @@ function DropCaret(props) {
|
|
|
31095
31095
|
};
|
|
31096
31096
|
}
|
|
31097
31097
|
}
|
|
31098
|
-
const caret = ((
|
|
31098
|
+
const caret = ((_b2 = props.caretViewport) == null ? void 0 : _b2.call(props)) ?? null;
|
|
31099
31099
|
if (caret) {
|
|
31100
31100
|
viewportLeft = caret.left;
|
|
31101
31101
|
viewportTop = caret.top;
|
|
@@ -33013,9 +33013,9 @@ function ContextMenu(props) {
|
|
|
33013
33013
|
get children() {
|
|
33014
33014
|
var _el$2 = _tmpl$4(), _el$4 = _el$2.firstChild;
|
|
33015
33015
|
_el$2.$$click = () => {
|
|
33016
|
-
var
|
|
33016
|
+
var _a2;
|
|
33017
33017
|
if (item.disabled) return;
|
|
33018
|
-
(
|
|
33018
|
+
(_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
|
|
33019
33019
|
props.onClose();
|
|
33020
33020
|
};
|
|
33021
33021
|
insert(_el$2, createComponent(Show, {
|
|
@@ -33259,12 +33259,12 @@ function buildEditorViewProps(ctx) {
|
|
|
33259
33259
|
};
|
|
33260
33260
|
const fileHandlers = {
|
|
33261
33261
|
onImportInputChange: (e) => {
|
|
33262
|
-
var
|
|
33263
|
-
return files.handleImportFile(((
|
|
33262
|
+
var _a2;
|
|
33263
|
+
return files.handleImportFile(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
|
|
33264
33264
|
},
|
|
33265
33265
|
onImageInputChange: (e) => {
|
|
33266
|
-
var
|
|
33267
|
-
return files.handleInsertImage(((
|
|
33266
|
+
var _a2;
|
|
33267
|
+
return files.handleInsertImage(((_a2 = e.currentTarget.files) == null ? void 0 : _a2[0]) ?? null);
|
|
33268
33268
|
}
|
|
33269
33269
|
};
|
|
33270
33270
|
const surfaceHandlers = {
|
|
@@ -33790,10 +33790,10 @@ function serializeBorder(border) {
|
|
|
33790
33790
|
return serializeDocxBorderAttrs(resolved, DEFAULT_TABLE_BORDER_COLOR);
|
|
33791
33791
|
}
|
|
33792
33792
|
function serializeTableCellBorders(cell) {
|
|
33793
|
-
var
|
|
33793
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
33794
33794
|
const borders = [
|
|
33795
|
-
`<w:top ${serializeBorder((
|
|
33796
|
-
`<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)}`,
|
|
33797
33797
|
`<w:bottom ${serializeBorder((_c = cell.style) == null ? void 0 : _c.borderBottom)}`,
|
|
33798
33798
|
`<w:right ${serializeBorder((_d = cell.style) == null ? void 0 : _d.borderRight)}`
|
|
33799
33799
|
];
|
|
@@ -33851,12 +33851,12 @@ function serializeTableDefaultCellMargins(margins) {
|
|
|
33851
33851
|
return parts.length > 0 ? `<w:tblCellMar>${parts.join("")}</w:tblCellMar>` : "";
|
|
33852
33852
|
}
|
|
33853
33853
|
function serializeTableCellProperties(cell, fallbackWidthPt) {
|
|
33854
|
-
var
|
|
33854
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
33855
33855
|
const colSpan = Math.max(1, Math.floor(cell.colSpan ?? 1));
|
|
33856
33856
|
const parts = [];
|
|
33857
33857
|
const conditional = serializeConditionalFlags(cell.conditionalStyle);
|
|
33858
33858
|
if (conditional) parts.push(conditional);
|
|
33859
|
-
const widthXml = serializeCellWidth(((
|
|
33859
|
+
const widthXml = serializeCellWidth(((_a2 = cell.style) == null ? void 0 : _a2.width) ?? fallbackWidthPt);
|
|
33860
33860
|
if (widthXml) {
|
|
33861
33861
|
parts.push(widthXml);
|
|
33862
33862
|
}
|
|
@@ -33868,7 +33868,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
|
|
|
33868
33868
|
} else if (cell.vMerge === "continue") {
|
|
33869
33869
|
parts.push("<w:vMerge/>");
|
|
33870
33870
|
}
|
|
33871
|
-
if ((
|
|
33871
|
+
if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
|
|
33872
33872
|
parts.push(
|
|
33873
33873
|
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(cell.style.shading, "FFFFFF")}"/>`
|
|
33874
33874
|
);
|
|
@@ -33945,10 +33945,10 @@ function serializeTableRowHeightFromStyle(heightValue, heightRule) {
|
|
|
33945
33945
|
return `<w:trHeight ${attrs.join(" ")}/>`;
|
|
33946
33946
|
}
|
|
33947
33947
|
function serializeTableRowHeight(row) {
|
|
33948
|
-
var
|
|
33948
|
+
var _a2, _b2;
|
|
33949
33949
|
return serializeTableRowHeightFromStyle(
|
|
33950
|
-
(
|
|
33951
|
-
(
|
|
33950
|
+
(_a2 = row.style) == null ? void 0 : _a2.height,
|
|
33951
|
+
(_b2 = row.style) == null ? void 0 : _b2.heightRule
|
|
33952
33952
|
);
|
|
33953
33953
|
}
|
|
33954
33954
|
function serializeTableRowStyleXml(style2) {
|
|
@@ -33982,13 +33982,13 @@ function serializeTableRowStyleXml(style2) {
|
|
|
33982
33982
|
return parts.length > 0 ? `<w:trPr>${parts.join("")}</w:trPr>` : "";
|
|
33983
33983
|
}
|
|
33984
33984
|
function serializeTableRowProperties(row) {
|
|
33985
|
-
var
|
|
33985
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
33986
33986
|
const parts = [];
|
|
33987
33987
|
const conditional = serializeConditionalFlags(row.conditionalStyle);
|
|
33988
33988
|
if (conditional) parts.push(conditional);
|
|
33989
|
-
const gridBefore = serializeGridSkip("gridBefore", (
|
|
33989
|
+
const gridBefore = serializeGridSkip("gridBefore", (_a2 = row.style) == null ? void 0 : _a2.gridBefore);
|
|
33990
33990
|
if (gridBefore) parts.push(gridBefore);
|
|
33991
|
-
const gridAfter = serializeGridSkip("gridAfter", (
|
|
33991
|
+
const gridAfter = serializeGridSkip("gridAfter", (_b2 = row.style) == null ? void 0 : _b2.gridAfter);
|
|
33992
33992
|
if (gridAfter) parts.push(gridAfter);
|
|
33993
33993
|
const widthBefore = serializeDocxWidthElement(
|
|
33994
33994
|
"wBefore",
|
|
@@ -34061,12 +34061,12 @@ function serializeTableBorders(style2) {
|
|
|
34061
34061
|
return xml ? `<w:tblBorders>${xml}</w:tblBorders>` : "";
|
|
34062
34062
|
}
|
|
34063
34063
|
function serializeTableProperties(table) {
|
|
34064
|
-
var
|
|
34064
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
34065
34065
|
const parts = [];
|
|
34066
|
-
if ((
|
|
34066
|
+
if ((_a2 = table.style) == null ? void 0 : _a2.styleId) {
|
|
34067
34067
|
parts.push(`<w:tblStyle w:val="${escapeXml(table.style.styleId)}"/>`);
|
|
34068
34068
|
}
|
|
34069
|
-
if ((
|
|
34069
|
+
if ((_b2 = table.style) == null ? void 0 : _b2.tblLook) {
|
|
34070
34070
|
const l = table.style.tblLook;
|
|
34071
34071
|
parts.push(
|
|
34072
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"}"/>`
|
|
@@ -34232,7 +34232,7 @@ function materializeParagraphStyle(paragraph, styles) {
|
|
|
34232
34232
|
};
|
|
34233
34233
|
}
|
|
34234
34234
|
function materializeRunStyle(run, paragraphStyleId, styles) {
|
|
34235
|
-
var
|
|
34235
|
+
var _a2;
|
|
34236
34236
|
const effective = resolveEffectiveTextStyleForParagraph(
|
|
34237
34237
|
run.styles,
|
|
34238
34238
|
paragraphStyleId,
|
|
@@ -34288,7 +34288,7 @@ function materializeRunStyle(run, paragraphStyleId, styles) {
|
|
|
34288
34288
|
shading: effective.shading,
|
|
34289
34289
|
language: effective.language
|
|
34290
34290
|
};
|
|
34291
|
-
if ((
|
|
34291
|
+
if ((_a2 = run.styles) == null ? void 0 : _a2.link) {
|
|
34292
34292
|
materialized.link = run.styles.link;
|
|
34293
34293
|
}
|
|
34294
34294
|
return materialized;
|
|
@@ -34371,11 +34371,11 @@ function serializeParagraphStyleXml(style2) {
|
|
|
34371
34371
|
return parts.length > 0 ? `<w:pPr>${parts.join("")}</w:pPr>` : "";
|
|
34372
34372
|
}
|
|
34373
34373
|
function serializeParagraphProperties(paragraph, numberingInfo, styles, overrides) {
|
|
34374
|
-
var
|
|
34374
|
+
var _a2, _b2;
|
|
34375
34375
|
const parts = [];
|
|
34376
34376
|
const style2 = materializeParagraphStyle(paragraph, styles);
|
|
34377
|
-
const align = ((
|
|
34378
|
-
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) {
|
|
34379
34379
|
parts.push(`<w:pStyle w:val="${escapeXml(paragraph.style.styleId)}"/>`);
|
|
34380
34380
|
}
|
|
34381
34381
|
if (align) {
|
|
@@ -35110,7 +35110,7 @@ function serializeRun(run, context, paragraphStyleId, styles, serializeBlocksXml
|
|
|
35110
35110
|
});
|
|
35111
35111
|
}
|
|
35112
35112
|
function serializeRunWithRelationships(run, context, paragraphStyleId, styles, serializeBlocksXml2) {
|
|
35113
|
-
var
|
|
35113
|
+
var _a2;
|
|
35114
35114
|
const runXml = serializeRun(
|
|
35115
35115
|
run,
|
|
35116
35116
|
context,
|
|
@@ -35118,7 +35118,7 @@ function serializeRunWithRelationships(run, context, paragraphStyleId, styles, s
|
|
|
35118
35118
|
styles,
|
|
35119
35119
|
serializeBlocksXml2
|
|
35120
35120
|
);
|
|
35121
|
-
const href = (
|
|
35121
|
+
const href = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
35122
35122
|
if (!href) {
|
|
35123
35123
|
return runXml;
|
|
35124
35124
|
}
|
|
@@ -35197,18 +35197,18 @@ function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, st
|
|
|
35197
35197
|
return out;
|
|
35198
35198
|
}
|
|
35199
35199
|
function serializeSingleBlockXml(block, context, styles) {
|
|
35200
|
-
var
|
|
35200
|
+
var _a2;
|
|
35201
35201
|
switch (block.type) {
|
|
35202
35202
|
case "paragraph":
|
|
35203
35203
|
return serializeParagraphXml(block, context, styles);
|
|
35204
35204
|
case "table": {
|
|
35205
|
-
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>' : "";
|
|
35206
35206
|
return pageBreakXml + serializeTableXml(
|
|
35207
35207
|
block,
|
|
35208
35208
|
(paragraph, cell) => {
|
|
35209
|
-
var
|
|
35209
|
+
var _a3;
|
|
35210
35210
|
return serializeParagraphXml(paragraph, context, styles, {
|
|
35211
|
-
align: (
|
|
35211
|
+
align: (_a3 = cell.style) == null ? void 0 : _a3.horizontalAlign
|
|
35212
35212
|
});
|
|
35213
35213
|
}
|
|
35214
35214
|
);
|
|
@@ -35218,12 +35218,12 @@ function serializeSingleBlockXml(block, context, styles) {
|
|
|
35218
35218
|
}
|
|
35219
35219
|
}
|
|
35220
35220
|
function serializeBlocksXml(blocks, context, styles) {
|
|
35221
|
-
var
|
|
35221
|
+
var _a2, _b2, _c;
|
|
35222
35222
|
let out = "";
|
|
35223
35223
|
let i = 0;
|
|
35224
35224
|
while (i < blocks.length) {
|
|
35225
35225
|
const block = blocks[i];
|
|
35226
|
-
const wrapper = (
|
|
35226
|
+
const wrapper = (_a2 = block.sdtWrappers) == null ? void 0 : _a2[0];
|
|
35227
35227
|
if (!wrapper) {
|
|
35228
35228
|
out += serializeSingleBlockXml(block, context, styles);
|
|
35229
35229
|
i += 1;
|
|
@@ -35231,7 +35231,7 @@ function serializeBlocksXml(blocks, context, styles) {
|
|
|
35231
35231
|
}
|
|
35232
35232
|
const group = [];
|
|
35233
35233
|
let j = i;
|
|
35234
|
-
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) {
|
|
35235
35235
|
const rest = blocks[j].sdtWrappers.slice(1);
|
|
35236
35236
|
group.push({
|
|
35237
35237
|
...blocks[j],
|
|
@@ -35246,11 +35246,11 @@ function serializeBlocksXml(blocks, context, styles) {
|
|
|
35246
35246
|
return out;
|
|
35247
35247
|
}
|
|
35248
35248
|
function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
35249
|
-
var
|
|
35249
|
+
var _a2, _b2, _c;
|
|
35250
35250
|
const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "", kind: "text" }];
|
|
35251
35251
|
const dropCapFrame = paragraph.dropCap ? serializeDropCapFrameParagraph(paragraph.dropCap) : "";
|
|
35252
|
-
const bookmarkEvents = (
|
|
35253
|
-
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);
|
|
35254
35254
|
const boundaryTokens = [
|
|
35255
35255
|
...(bookmarkEvents ?? []).map((e) => ({
|
|
35256
35256
|
offset: e.offset,
|
|
@@ -35271,11 +35271,11 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
|
35271
35271
|
styles
|
|
35272
35272
|
) : runs.map(
|
|
35273
35273
|
(run) => {
|
|
35274
|
-
var
|
|
35274
|
+
var _a3;
|
|
35275
35275
|
return serializeRunWithRelationships(
|
|
35276
35276
|
run,
|
|
35277
35277
|
context,
|
|
35278
|
-
(
|
|
35278
|
+
(_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
|
|
35279
35279
|
styles,
|
|
35280
35280
|
serializeBlocksXml
|
|
35281
35281
|
);
|
|
@@ -35290,8 +35290,8 @@ function serializeParagraphXml(paragraph, context, styles, overrides) {
|
|
|
35290
35290
|
}
|
|
35291
35291
|
const FIRST_FOOTNOTE_DOCX_ID = 1;
|
|
35292
35292
|
function collectReferencedFootnotesForExport(document2) {
|
|
35293
|
-
var
|
|
35294
|
-
const items = (
|
|
35293
|
+
var _a2;
|
|
35294
|
+
const items = (_a2 = document2.footnotes) == null ? void 0 : _a2.items;
|
|
35295
35295
|
if (!items) return [];
|
|
35296
35296
|
const seen = /* @__PURE__ */ new Map();
|
|
35297
35297
|
let nextDocxId = FIRST_FOOTNOTE_DOCX_ID;
|
|
@@ -35339,11 +35339,11 @@ function createEmptyFootnoteBodyParagraph(withMarker = true) {
|
|
|
35339
35339
|
};
|
|
35340
35340
|
}
|
|
35341
35341
|
function prependFootnoteRefMarker(paragraph) {
|
|
35342
|
-
var
|
|
35342
|
+
var _a2;
|
|
35343
35343
|
return {
|
|
35344
35344
|
...paragraph,
|
|
35345
35345
|
runs: [makeFootnoteRefMarkerRun(), ...paragraph.runs],
|
|
35346
|
-
style: ((
|
|
35346
|
+
style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "FootnoteText" }
|
|
35347
35347
|
};
|
|
35348
35348
|
}
|
|
35349
35349
|
function makeFootnoteRefMarkerRun() {
|
|
@@ -35372,9 +35372,9 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
|
|
|
35372
35372
|
return serializeTableXml(
|
|
35373
35373
|
block,
|
|
35374
35374
|
(paragraph, cell) => {
|
|
35375
|
-
var
|
|
35375
|
+
var _a2;
|
|
35376
35376
|
return serializeParagraphXml(paragraph, partContext, styles, {
|
|
35377
|
-
align: (
|
|
35377
|
+
align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
|
|
35378
35378
|
});
|
|
35379
35379
|
}
|
|
35380
35380
|
);
|
|
@@ -35386,8 +35386,8 @@ function buildFootnotesXml(document2, referenced, numberingContext, state, build
|
|
|
35386
35386
|
}
|
|
35387
35387
|
const FIRST_ENDNOTE_DOCX_ID = 1;
|
|
35388
35388
|
function collectReferencedEndnotesForExport(document2) {
|
|
35389
|
-
var
|
|
35390
|
-
const items = (
|
|
35389
|
+
var _a2;
|
|
35390
|
+
const items = (_a2 = document2.endnotes) == null ? void 0 : _a2.items;
|
|
35391
35391
|
if (!items) return [];
|
|
35392
35392
|
const seen = /* @__PURE__ */ new Map();
|
|
35393
35393
|
let nextDocxId = FIRST_ENDNOTE_DOCX_ID;
|
|
@@ -35435,11 +35435,11 @@ function createEmptyEndnoteBodyParagraph(withMarker = true) {
|
|
|
35435
35435
|
};
|
|
35436
35436
|
}
|
|
35437
35437
|
function prependEndnoteRefMarker(paragraph) {
|
|
35438
|
-
var
|
|
35438
|
+
var _a2;
|
|
35439
35439
|
return {
|
|
35440
35440
|
...paragraph,
|
|
35441
35441
|
runs: [makeEndnoteRefMarkerRun(), ...paragraph.runs],
|
|
35442
|
-
style: ((
|
|
35442
|
+
style: ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) ? paragraph.style : { ...paragraph.style ?? {}, styleId: "EndnoteText" }
|
|
35443
35443
|
};
|
|
35444
35444
|
}
|
|
35445
35445
|
function makeEndnoteRefMarkerRun() {
|
|
@@ -35467,9 +35467,9 @@ function buildEndnotesXml(_document, referenced, _numberingContext, _state, buil
|
|
|
35467
35467
|
return serializeTableXml(
|
|
35468
35468
|
block,
|
|
35469
35469
|
(paragraph, cell) => {
|
|
35470
|
-
var
|
|
35470
|
+
var _a2;
|
|
35471
35471
|
return serializeParagraphXml(paragraph, partContext, styles, {
|
|
35472
|
-
align: (
|
|
35472
|
+
align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
|
|
35473
35473
|
});
|
|
35474
35474
|
}
|
|
35475
35475
|
);
|
|
@@ -35901,14 +35901,14 @@ function buildNumberingXml(definitions) {
|
|
|
35901
35901
|
}
|
|
35902
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}"`;
|
|
35903
35903
|
function serializeSectionPropertiesWithReferences(pageSettings, references) {
|
|
35904
|
-
var
|
|
35904
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
35905
35905
|
const width = pxToTwips(pageSettings.width, 12240);
|
|
35906
35906
|
const height = pxToTwips(pageSettings.height, 15840);
|
|
35907
35907
|
const margins = pageSettings.margins;
|
|
35908
35908
|
const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
|
|
35909
35909
|
const referencesXml = [
|
|
35910
|
-
((
|
|
35911
|
-
((
|
|
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}"/>` : "",
|
|
35912
35912
|
((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
|
|
35913
35913
|
((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
|
|
35914
35914
|
((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
|
|
@@ -35989,11 +35989,11 @@ function createImageCaptionParagraph(captionText, label, sequenceNumber) {
|
|
|
35989
35989
|
return paragraph;
|
|
35990
35990
|
}
|
|
35991
35991
|
function isImageCaptionParagraph(paragraph) {
|
|
35992
|
-
var
|
|
35992
|
+
var _a2, _b2;
|
|
35993
35993
|
if (!paragraph) {
|
|
35994
35994
|
return false;
|
|
35995
35995
|
}
|
|
35996
|
-
const styleId = (
|
|
35996
|
+
const styleId = (_b2 = (_a2 = paragraph.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.toLowerCase();
|
|
35997
35997
|
if (styleId !== "caption") {
|
|
35998
35998
|
return false;
|
|
35999
35999
|
}
|
|
@@ -36005,7 +36005,7 @@ function isImageCaptionParagraph(paragraph) {
|
|
|
36005
36005
|
});
|
|
36006
36006
|
}
|
|
36007
36007
|
function getImageCaptionText(paragraph) {
|
|
36008
|
-
var
|
|
36008
|
+
var _a2;
|
|
36009
36009
|
if (!isImageCaptionParagraph(paragraph)) {
|
|
36010
36010
|
return "";
|
|
36011
36011
|
}
|
|
@@ -36016,15 +36016,15 @@ function getImageCaptionText(paragraph) {
|
|
|
36016
36016
|
value += run.text;
|
|
36017
36017
|
continue;
|
|
36018
36018
|
}
|
|
36019
|
-
if (((
|
|
36019
|
+
if (((_a2 = getRunFieldChar(run)) == null ? void 0 : _a2.kind) === "end") {
|
|
36020
36020
|
afterField = true;
|
|
36021
36021
|
}
|
|
36022
36022
|
}
|
|
36023
36023
|
return value.replace(/^[:\-\s]+/, "");
|
|
36024
36024
|
}
|
|
36025
36025
|
function updateImageCaptionParagraph(paragraph, captionText, label) {
|
|
36026
|
-
var
|
|
36027
|
-
const currentNumber = ((
|
|
36026
|
+
var _a2;
|
|
36027
|
+
const currentNumber = ((_a2 = paragraph.runs.find((run) => /^\d+$/.test(run.text))) == null ? void 0 : _a2.text) ?? "1";
|
|
36028
36028
|
const next = createImageCaptionParagraph(
|
|
36029
36029
|
captionText,
|
|
36030
36030
|
label,
|
|
@@ -36123,9 +36123,9 @@ function buildPartContext(blocks, numberingContext, state, document2) {
|
|
|
36123
36123
|
const hyperlinks = [];
|
|
36124
36124
|
const hyperlinkMap = /* @__PURE__ */ new Map();
|
|
36125
36125
|
visitBlocks(blocks, (paragraph) => {
|
|
36126
|
-
var
|
|
36126
|
+
var _a2;
|
|
36127
36127
|
for (const run of paragraph.runs) {
|
|
36128
|
-
const link = (
|
|
36128
|
+
const link = (_a2 = run.styles) == null ? void 0 : _a2.link;
|
|
36129
36129
|
if (link && !link.startsWith("#") && !hyperlinkMap.has(link)) {
|
|
36130
36130
|
const rId2 = `rIdLink${hyperlinks.length + 1}`;
|
|
36131
36131
|
hyperlinkMap.set(link, rId2);
|
|
@@ -36196,7 +36196,7 @@ function buildPartContext(blocks, numberingContext, state, document2) {
|
|
|
36196
36196
|
};
|
|
36197
36197
|
}
|
|
36198
36198
|
async function exportEditorDocumentToDocx(document2) {
|
|
36199
|
-
var
|
|
36199
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
36200
36200
|
document2 = renumberImageCaptionsInDocument(document2);
|
|
36201
36201
|
const zip = new JSZip();
|
|
36202
36202
|
const numberingContext = buildNumberingContext(document2);
|
|
@@ -36233,7 +36233,7 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
36233
36233
|
let nextFooterIndex = 1;
|
|
36234
36234
|
sections.forEach((section, sectionIndex) => {
|
|
36235
36235
|
const addPart = (kind, type, blocks) => {
|
|
36236
|
-
var
|
|
36236
|
+
var _a3;
|
|
36237
36237
|
if (!blocks || blocks.length === 0) {
|
|
36238
36238
|
return;
|
|
36239
36239
|
}
|
|
@@ -36260,7 +36260,7 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
36260
36260
|
context
|
|
36261
36261
|
});
|
|
36262
36262
|
const referenceKey = kind === "header" ? "header" : "footer";
|
|
36263
|
-
((
|
|
36263
|
+
((_a3 = sectionReferences[sectionIndex])[referenceKey] ?? (_a3[referenceKey] = {}))[type] = { relId };
|
|
36264
36264
|
if (kind === "header") {
|
|
36265
36265
|
nextHeaderIndex += 1;
|
|
36266
36266
|
} else {
|
|
@@ -36277,11 +36277,11 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
36277
36277
|
const hasNumbering = numberingContext.definitions.length > 0;
|
|
36278
36278
|
const hasEvenAndOddHeaders = sections.some(
|
|
36279
36279
|
(section) => {
|
|
36280
|
-
var
|
|
36281
|
-
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;
|
|
36282
36282
|
}
|
|
36283
36283
|
);
|
|
36284
|
-
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;
|
|
36285
36285
|
const allImages = [
|
|
36286
36286
|
...bodyContext.images,
|
|
36287
36287
|
...parts.flatMap((part) => part.context.images)
|
|
@@ -36311,8 +36311,8 @@ async function exportEditorDocumentToDocx(document2) {
|
|
|
36311
36311
|
allImages.push(...endnotesPart.partContext.images);
|
|
36312
36312
|
}
|
|
36313
36313
|
const imageExtensions = allImages.filter((img) => img.kind === "embedded").map((img) => {
|
|
36314
|
-
var
|
|
36315
|
-
return (
|
|
36314
|
+
var _a3;
|
|
36315
|
+
return (_a3 = img.target.split(".").pop()) == null ? void 0 : _a3.toLowerCase();
|
|
36316
36316
|
}).filter((ext) => Boolean(ext));
|
|
36317
36317
|
const hasStyles = document2.styles != null && Object.keys(document2.styles).length > 0;
|
|
36318
36318
|
const hasFontTable = (((_i = document2.fontTable) == null ? void 0 : _i.length) ?? 0) > 0;
|
|
@@ -36454,24 +36454,24 @@ function borderDashArray(type) {
|
|
|
36454
36454
|
}
|
|
36455
36455
|
}
|
|
36456
36456
|
function getPadding(textBox) {
|
|
36457
|
-
var
|
|
36457
|
+
var _a2, _b2, _c, _d;
|
|
36458
36458
|
return {
|
|
36459
|
-
left: ((
|
|
36460
|
-
top: ((
|
|
36459
|
+
left: ((_a2 = textBox.body) == null ? void 0 : _a2.paddingLeft) ?? 0,
|
|
36460
|
+
top: ((_b2 = textBox.body) == null ? void 0 : _b2.paddingTop) ?? 0,
|
|
36461
36461
|
right: ((_c = textBox.body) == null ? void 0 : _c.paddingRight) ?? 0,
|
|
36462
36462
|
bottom: ((_d = textBox.body) == null ? void 0 : _d.paddingBottom) ?? 0
|
|
36463
36463
|
};
|
|
36464
36464
|
}
|
|
36465
36465
|
function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, heightPx) {
|
|
36466
|
-
var
|
|
36466
|
+
var _a2, _b2, _c, _d;
|
|
36467
36467
|
const segments = getPresetPathSegments(
|
|
36468
|
-
(
|
|
36468
|
+
(_a2 = textBox.shape) == null ? void 0 : _a2.preset,
|
|
36469
36469
|
pxToPt$1(xPx),
|
|
36470
36470
|
pxToPt$1(yPx),
|
|
36471
36471
|
pxToPt$1(widthPx),
|
|
36472
36472
|
pxToPt$1(heightPx)
|
|
36473
36473
|
);
|
|
36474
|
-
const fill = (
|
|
36474
|
+
const fill = (_b2 = textBox.shape) == null ? void 0 : _b2.fill;
|
|
36475
36475
|
const borderColor = (_c = textBox.shape) == null ? void 0 : _c.borderColor;
|
|
36476
36476
|
const borderWidthPt = ((_d = textBox.shape) == null ? void 0 : _d.borderWidthPt) ?? (borderColor ? 0.75 : 0);
|
|
36477
36477
|
writer.drawPath(pageIndex, {
|
|
@@ -36482,7 +36482,7 @@ function drawShapeGeometry(writer, pageIndex, textBox, xPx, yPx, widthPx, height
|
|
|
36482
36482
|
});
|
|
36483
36483
|
}
|
|
36484
36484
|
async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heightPx, drawers) {
|
|
36485
|
-
var
|
|
36485
|
+
var _a2;
|
|
36486
36486
|
if (textBox.blocks.length === 0) {
|
|
36487
36487
|
return;
|
|
36488
36488
|
}
|
|
@@ -36511,7 +36511,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
|
|
|
36511
36511
|
styles: ctx.document.styles,
|
|
36512
36512
|
pageOffset: ctx.pageIndex
|
|
36513
36513
|
});
|
|
36514
|
-
const blocks = ((
|
|
36514
|
+
const blocks = ((_a2 = pages[0]) == null ? void 0 : _a2.blocks) ?? [];
|
|
36515
36515
|
if (blocks.length === 0) {
|
|
36516
36516
|
return;
|
|
36517
36517
|
}
|
|
@@ -37120,7 +37120,7 @@ function groupSlotChunksByOffsetGaps(chars) {
|
|
|
37120
37120
|
return chunks;
|
|
37121
37121
|
}
|
|
37122
37122
|
function resolveTabLeader(paragraph, line, tabLeft, document2) {
|
|
37123
|
-
var
|
|
37123
|
+
var _a2;
|
|
37124
37124
|
const paragraphStyle = resolveEffectiveParagraphStyle(
|
|
37125
37125
|
paragraph.style,
|
|
37126
37126
|
document2.styles
|
|
@@ -37129,7 +37129,7 @@ function resolveTabLeader(paragraph, line, tabLeft, document2) {
|
|
|
37129
37129
|
if (tabs.length === 0) {
|
|
37130
37130
|
return void 0;
|
|
37131
37131
|
}
|
|
37132
|
-
const lineStart = ((
|
|
37132
|
+
const lineStart = ((_a2 = line.slots[0]) == null ? void 0 : _a2.left) ?? 0;
|
|
37133
37133
|
const relativeLeft = tabLeft - lineStart;
|
|
37134
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];
|
|
37135
37135
|
return (stop == null ? void 0 : stop.leader) && stop.leader !== "none" ? stop.leader : void 0;
|
|
@@ -37184,7 +37184,7 @@ async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, docu
|
|
|
37184
37184
|
);
|
|
37185
37185
|
}
|
|
37186
37186
|
async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
|
|
37187
|
-
var
|
|
37187
|
+
var _a2, _b2, _c;
|
|
37188
37188
|
if (fragment.image) {
|
|
37189
37189
|
if (fragment.image.floating) {
|
|
37190
37190
|
return;
|
|
@@ -37229,7 +37229,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
37229
37229
|
}
|
|
37230
37230
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
37231
37231
|
fragment.styles,
|
|
37232
|
-
(
|
|
37232
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
37233
37233
|
document2.styles
|
|
37234
37234
|
);
|
|
37235
37235
|
if (styles.hidden) {
|
|
@@ -37249,6 +37249,23 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
37249
37249
|
if (!firstChar || text.length === 0) {
|
|
37250
37250
|
return;
|
|
37251
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
|
+
}
|
|
37252
37269
|
drawFragmentShading(
|
|
37253
37270
|
writer,
|
|
37254
37271
|
pageIndex,
|
|
@@ -37301,7 +37318,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
37301
37318
|
horizontalScale: styles.characterScale ?? 100,
|
|
37302
37319
|
fontFeatures
|
|
37303
37320
|
};
|
|
37304
|
-
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";
|
|
37305
37322
|
const gradientShadingName = resolveGradientShadingName(
|
|
37306
37323
|
writer,
|
|
37307
37324
|
pageIndex,
|
|
@@ -37459,7 +37476,7 @@ function getListOrdinals(document2) {
|
|
|
37459
37476
|
return buildListLabels(document2);
|
|
37460
37477
|
}
|
|
37461
37478
|
function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
|
|
37462
|
-
var
|
|
37479
|
+
var _a2;
|
|
37463
37480
|
if (line.index !== 0) {
|
|
37464
37481
|
return;
|
|
37465
37482
|
}
|
|
@@ -37473,7 +37490,7 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
|
|
|
37473
37490
|
}
|
|
37474
37491
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
37475
37492
|
void 0,
|
|
37476
|
-
(
|
|
37493
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
37477
37494
|
document2.styles
|
|
37478
37495
|
);
|
|
37479
37496
|
const fontFace = fontRegistry.resolveFontFace({
|
|
@@ -37703,8 +37720,8 @@ async function drawTableBlock(writer, pageIndex, block, document2, originX, orig
|
|
|
37703
37720
|
}
|
|
37704
37721
|
}
|
|
37705
37722
|
const blockDrawers = { drawParagraph, drawTableBlock };
|
|
37706
|
-
async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings) {
|
|
37707
|
-
var
|
|
37723
|
+
async function drawBlockList(writer, pageIndex, blocks, document2, originX, originY, contentWidth, fontRegistry, listOrdinals, pageSettings, onParagraphDrawn) {
|
|
37724
|
+
var _a2;
|
|
37708
37725
|
if (!blocks || blocks.length === 0) {
|
|
37709
37726
|
return;
|
|
37710
37727
|
}
|
|
@@ -37722,6 +37739,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
|
|
|
37722
37739
|
);
|
|
37723
37740
|
const spacingBefore = block.layout.startOffset === 0 && cursorY > originY ? paragraphStyle.spacingBefore ?? 0 : 0;
|
|
37724
37741
|
const boxTop = cursorY + spacingBefore;
|
|
37742
|
+
onParagraphDrawn == null ? void 0 : onParagraphDrawn(block.sourceBlock.id, boxTop);
|
|
37725
37743
|
const textTop = boxTop + getParagraphBorderInsets(paragraphStyle).top;
|
|
37726
37744
|
drawParagraphDecorations(
|
|
37727
37745
|
writer,
|
|
@@ -37803,7 +37821,7 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
|
|
|
37803
37821
|
break;
|
|
37804
37822
|
}
|
|
37805
37823
|
case "table":
|
|
37806
|
-
if (((
|
|
37824
|
+
if (((_a2 = block.sourceBlock.style) == null ? void 0 : _a2.floating) && pageSettings) {
|
|
37807
37825
|
const width = resolveCanvasTableWidth(
|
|
37808
37826
|
block.sourceBlock,
|
|
37809
37827
|
contentWidth
|
|
@@ -39455,7 +39473,7 @@ class SimpleTextLayouter {
|
|
|
39455
39473
|
function view(bytes) {
|
|
39456
39474
|
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
39457
39475
|
}
|
|
39458
|
-
function u16(bytes, offset) {
|
|
39476
|
+
function u16$1(bytes, offset) {
|
|
39459
39477
|
return view(bytes).getUint16(offset);
|
|
39460
39478
|
}
|
|
39461
39479
|
function i16(bytes, offset) {
|
|
@@ -39507,8 +39525,8 @@ function collectCompositeGlyphs(glyph, addGlyph) {
|
|
|
39507
39525
|
let flags = 0;
|
|
39508
39526
|
do {
|
|
39509
39527
|
if (offset + 4 > glyph.byteLength) return;
|
|
39510
|
-
flags = u16(glyph, offset);
|
|
39511
|
-
addGlyph(u16(glyph, offset + 2));
|
|
39528
|
+
flags = u16$1(glyph, offset);
|
|
39529
|
+
addGlyph(u16$1(glyph, offset + 2));
|
|
39512
39530
|
offset += 4;
|
|
39513
39531
|
offset += flags & 1 ? 4 : 2;
|
|
39514
39532
|
if (flags & 8) offset += 2;
|
|
@@ -39523,7 +39541,7 @@ function subsetClosure(font, initialGlyphs) {
|
|
|
39523
39541
|
if (!glyf || !loca || !head) {
|
|
39524
39542
|
return Array.from(/* @__PURE__ */ new Set([0, ...initialGlyphs])).sort((a, b) => a - b);
|
|
39525
39543
|
}
|
|
39526
|
-
const offsets = readLoca(loca, u16(head, 50));
|
|
39544
|
+
const offsets = readLoca(loca, u16$1(head, 50));
|
|
39527
39545
|
const used = /* @__PURE__ */ new Set([0, ...initialGlyphs]);
|
|
39528
39546
|
const stack = Array.from(used);
|
|
39529
39547
|
while (stack.length > 0) {
|
|
@@ -39567,7 +39585,7 @@ function buildSubsetTables(font, glyphIds) {
|
|
|
39567
39585
|
}
|
|
39568
39586
|
const maxGlyphId = Math.max(0, ...glyphIds);
|
|
39569
39587
|
const used = new Set(glyphIds);
|
|
39570
|
-
const sourceOffsets = readLoca(loca, u16(head, 50));
|
|
39588
|
+
const sourceOffsets = readLoca(loca, u16$1(head, 50));
|
|
39571
39589
|
const locaOffsets = [];
|
|
39572
39590
|
const glyfChunks = [];
|
|
39573
39591
|
let glyfOffset = 0;
|
|
@@ -39962,11 +39980,608 @@ function buildFunctionObject(stops) {
|
|
|
39962
39980
|
">>"
|
|
39963
39981
|
].join("\n");
|
|
39964
39982
|
}
|
|
39965
|
-
|
|
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) {
|
|
39966
40581
|
const objects = [];
|
|
39967
|
-
const addObject = (
|
|
40582
|
+
const addObject = (body) => {
|
|
39968
40583
|
const id = objects.length + 1;
|
|
39969
|
-
objects.push({ id, body
|
|
40584
|
+
objects.push({ id, body });
|
|
39970
40585
|
return id;
|
|
39971
40586
|
};
|
|
39972
40587
|
const catalogObjectId = addObject("");
|
|
@@ -39978,11 +40593,7 @@ function serializePdfDocument(pages, fonts, images, shadings) {
|
|
|
39978
40593
|
for (const page of pages) {
|
|
39979
40594
|
const stream = `${page.commands.join("\n")}
|
|
39980
40595
|
`;
|
|
39981
|
-
const contentObjectId = addObject(
|
|
39982
|
-
`<< /Length ${byteLength(stream)} >>
|
|
39983
|
-
stream
|
|
39984
|
-
${stream}endstream`
|
|
39985
|
-
);
|
|
40596
|
+
const contentObjectId = addObject(buildContentStreamObject(stream));
|
|
39986
40597
|
const imageResourceXml = Array.from(page.imageResourceNames).map((resourceName) => {
|
|
39987
40598
|
const objectId = imageObjectIds.get(resourceName);
|
|
39988
40599
|
return objectId ? `/${resourceName} ${objectId} 0 R` : "";
|
|
@@ -39993,52 +40604,153 @@ ${stream}endstream`
|
|
|
39993
40604
|
return objectId ? `/${resourceName} ${objectId} 0 R` : "";
|
|
39994
40605
|
}).filter(Boolean).join(" ");
|
|
39995
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(" ")}]` : "";
|
|
39996
40625
|
const pageObjectId = addObject(
|
|
39997
40626
|
[
|
|
39998
40627
|
"<< /Type /Page",
|
|
39999
40628
|
`/Parent ${pagesObjectId} 0 R`,
|
|
40000
40629
|
`/MediaBox [0 0 ${formatNumber(page.width)} ${formatNumber(page.height)}]`,
|
|
40001
40630
|
`/Resources << /Font << ${fontResourceXml} >>${xObjectResourceXml}${shadingResourceDictXml} >>`,
|
|
40002
|
-
`/Contents ${contentObjectId} 0 R`,
|
|
40631
|
+
`/Contents ${contentObjectId} 0 R${annotsXml}`,
|
|
40003
40632
|
">>"
|
|
40004
40633
|
].join("\n")
|
|
40005
40634
|
);
|
|
40006
40635
|
pageObjectIds.push(pageObjectId);
|
|
40007
40636
|
}
|
|
40008
|
-
|
|
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");
|
|
40009
40705
|
objects[pagesObjectId - 1].body = [
|
|
40010
40706
|
"<< /Type /Pages",
|
|
40011
40707
|
`/Kids [${pageObjectIds.map((id) => `${id} 0 R`).join(" ")}]`,
|
|
40012
40708
|
`/Count ${pageObjectIds.length}`,
|
|
40013
40709
|
">>"
|
|
40014
40710
|
].join("\n");
|
|
40015
|
-
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);
|
|
40016
40720
|
const offsets = [0];
|
|
40721
|
+
const push = (chunk) => {
|
|
40722
|
+
chunks.push(chunk);
|
|
40723
|
+
offset += chunkByteLength(chunk);
|
|
40724
|
+
};
|
|
40017
40725
|
for (const object of objects) {
|
|
40018
|
-
offsets[object.id] =
|
|
40019
|
-
|
|
40020
|
-
|
|
40021
|
-
|
|
40022
|
-
|
|
40023
|
-
}
|
|
40024
|
-
const xrefOffset =
|
|
40025
|
-
|
|
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
|
|
40026
40734
|
0 ${objects.length + 1}
|
|
40027
40735
|
`;
|
|
40028
|
-
|
|
40736
|
+
xref += "0000000000 65535 f \n";
|
|
40029
40737
|
for (const object of objects) {
|
|
40030
|
-
|
|
40738
|
+
xref += `${String(offsets[object.id] ?? 0).padStart(10, "0")} 00000 n
|
|
40031
40739
|
`;
|
|
40032
40740
|
}
|
|
40033
|
-
|
|
40034
|
-
|
|
40035
|
-
|
|
40036
|
-
|
|
40037
|
-
|
|
40038
|
-
|
|
40039
|
-
|
|
40040
|
-
|
|
40041
|
-
|
|
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);
|
|
40042
40754
|
}
|
|
40043
40755
|
class OasisPdfWriter {
|
|
40044
40756
|
constructor(fontResources = DEFAULT_PDF_FONT_RESOURCES) {
|
|
@@ -40047,6 +40759,9 @@ class OasisPdfWriter {
|
|
|
40047
40759
|
__publicField(this, "fonts");
|
|
40048
40760
|
__publicField(this, "images", new PdfImageTable());
|
|
40049
40761
|
__publicField(this, "shadings", new PdfShadingTable());
|
|
40762
|
+
__publicField(this, "namedDestinations", []);
|
|
40763
|
+
__publicField(this, "outlineItems", []);
|
|
40764
|
+
__publicField(this, "documentInfo");
|
|
40050
40765
|
this.fonts = new PdfFontTable(fontResources);
|
|
40051
40766
|
}
|
|
40052
40767
|
registerFontResource(resource) {
|
|
@@ -40058,7 +40773,8 @@ class OasisPdfWriter {
|
|
|
40058
40773
|
height: Math.max(1, size.height),
|
|
40059
40774
|
commands: [],
|
|
40060
40775
|
imageResourceNames: /* @__PURE__ */ new Set(),
|
|
40061
|
-
shadingResourceNames: /* @__PURE__ */ new Set()
|
|
40776
|
+
shadingResourceNames: /* @__PURE__ */ new Set(),
|
|
40777
|
+
annotations: []
|
|
40062
40778
|
};
|
|
40063
40779
|
this.pages.push(page);
|
|
40064
40780
|
this.streams.push(
|
|
@@ -40070,36 +40786,36 @@ class OasisPdfWriter {
|
|
|
40070
40786
|
return this.pages.length;
|
|
40071
40787
|
}
|
|
40072
40788
|
drawRect(pageIndex, options) {
|
|
40073
|
-
var
|
|
40074
|
-
(
|
|
40789
|
+
var _a2;
|
|
40790
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawRect(options);
|
|
40075
40791
|
}
|
|
40076
40792
|
drawLine(pageIndex, options) {
|
|
40077
|
-
var
|
|
40078
|
-
(
|
|
40793
|
+
var _a2;
|
|
40794
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawLine(options);
|
|
40079
40795
|
}
|
|
40080
40796
|
drawPath(pageIndex, options) {
|
|
40081
|
-
var
|
|
40082
|
-
(
|
|
40797
|
+
var _a2;
|
|
40798
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawPath(options);
|
|
40083
40799
|
}
|
|
40084
40800
|
saveGraphicsState(pageIndex) {
|
|
40085
|
-
var
|
|
40086
|
-
(
|
|
40801
|
+
var _a2;
|
|
40802
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.saveGraphicsState();
|
|
40087
40803
|
}
|
|
40088
40804
|
restoreGraphicsState(pageIndex) {
|
|
40089
|
-
var
|
|
40090
|
-
(
|
|
40805
|
+
var _a2;
|
|
40806
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.restoreGraphicsState();
|
|
40091
40807
|
}
|
|
40092
40808
|
rotateAbout(pageIndex, centerX, centerY, degrees) {
|
|
40093
|
-
var
|
|
40094
|
-
(
|
|
40809
|
+
var _a2;
|
|
40810
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.rotateAbout(centerX, centerY, degrees);
|
|
40095
40811
|
}
|
|
40096
40812
|
clipRect(pageIndex, x, y, width, height) {
|
|
40097
|
-
var
|
|
40098
|
-
(
|
|
40813
|
+
var _a2;
|
|
40814
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.clipRect(x, y, width, height);
|
|
40099
40815
|
}
|
|
40100
40816
|
drawText(pageIndex, options) {
|
|
40101
|
-
var
|
|
40102
|
-
(
|
|
40817
|
+
var _a2;
|
|
40818
|
+
(_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.drawText(options);
|
|
40103
40819
|
}
|
|
40104
40820
|
/**
|
|
40105
40821
|
* Registers an axial (linear) gradient on a page for use as a glyph fill, and
|
|
@@ -40107,15 +40823,45 @@ class OasisPdfWriter {
|
|
|
40107
40823
|
* subsequent `drawText`. Coordinates are in the writer's top-left point space.
|
|
40108
40824
|
*/
|
|
40109
40825
|
registerAxialGradient(pageIndex, gradient) {
|
|
40110
|
-
var
|
|
40111
|
-
return ((
|
|
40826
|
+
var _a2;
|
|
40827
|
+
return ((_a2 = this.streams[pageIndex]) == null ? void 0 : _a2.registerAxialGradient(gradient)) ?? null;
|
|
40112
40828
|
}
|
|
40113
40829
|
registerImageResource(resource) {
|
|
40114
40830
|
return this.images.registerImageResource(resource);
|
|
40115
40831
|
}
|
|
40116
40832
|
drawImage(pageIndex, options) {
|
|
40117
|
-
var
|
|
40118
|
-
(
|
|
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;
|
|
40119
40865
|
}
|
|
40120
40866
|
toArrayBuffer() {
|
|
40121
40867
|
const bytes = this.toUint8Array();
|
|
@@ -40132,11 +40878,69 @@ class OasisPdfWriter {
|
|
|
40132
40878
|
this.pages,
|
|
40133
40879
|
this.fonts,
|
|
40134
40880
|
this.images,
|
|
40135
|
-
this.shadings
|
|
40881
|
+
this.shadings,
|
|
40882
|
+
this.namedDestinations,
|
|
40883
|
+
this.outlineItems,
|
|
40884
|
+
this.documentInfo
|
|
40136
40885
|
);
|
|
40137
40886
|
}
|
|
40138
40887
|
}
|
|
40139
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
|
+
}
|
|
40140
40944
|
async function exportEditorDocumentToPdf(document2) {
|
|
40141
40945
|
document2 = renumberImageCaptionsInDocument(document2);
|
|
40142
40946
|
const fontRegistry = new PdfFontRegistry();
|
|
@@ -40144,8 +40948,16 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
40144
40948
|
families: collectPdfFontFamilies(document2)
|
|
40145
40949
|
});
|
|
40146
40950
|
const writer = new OasisPdfWriter(fontRegistry.getPdfFontResources());
|
|
40951
|
+
writer.setDocumentInfo(resolveDocumentInfo(document2));
|
|
40147
40952
|
const layout = projectDocumentLayout(document2);
|
|
40148
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
|
+
);
|
|
40149
40961
|
for (const page of layout.pages) {
|
|
40150
40962
|
const width = Math.max(1, pxToPt$1(page.pageSettings.width));
|
|
40151
40963
|
const height = Math.max(1, pxToPt$1(page.pageSettings.height));
|
|
@@ -40190,7 +41002,14 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
40190
41002
|
rect.width,
|
|
40191
41003
|
fontRegistry,
|
|
40192
41004
|
listOrdinals,
|
|
40193
|
-
page.pageSettings
|
|
41005
|
+
page.pageSettings,
|
|
41006
|
+
registerBookmarkDestinations(
|
|
41007
|
+
writer,
|
|
41008
|
+
pageIndex,
|
|
41009
|
+
rect.left,
|
|
41010
|
+
bookmarkNamesByParagraph,
|
|
41011
|
+
headingByParagraph
|
|
41012
|
+
)
|
|
40194
41013
|
);
|
|
40195
41014
|
}
|
|
40196
41015
|
} else {
|
|
@@ -40204,7 +41023,14 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
40204
41023
|
contentWidth,
|
|
40205
41024
|
fontRegistry,
|
|
40206
41025
|
listOrdinals,
|
|
40207
|
-
page.pageSettings
|
|
41026
|
+
page.pageSettings,
|
|
41027
|
+
registerBookmarkDestinations(
|
|
41028
|
+
writer,
|
|
41029
|
+
pageIndex,
|
|
41030
|
+
originX,
|
|
41031
|
+
bookmarkNamesByParagraph,
|
|
41032
|
+
headingByParagraph
|
|
41033
|
+
)
|
|
40208
41034
|
);
|
|
40209
41035
|
}
|
|
40210
41036
|
await drawBlockList(
|
|
@@ -40255,15 +41081,15 @@ async function exportEditorDocumentToPdfBlob(document2) {
|
|
|
40255
41081
|
return new Blob([buffer], { type: "application/pdf" });
|
|
40256
41082
|
}
|
|
40257
41083
|
async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenceIds, document2, originX, originY, contentWidth, fontRegistry, listOrdinals) {
|
|
40258
|
-
var
|
|
41084
|
+
var _a2;
|
|
40259
41085
|
let cursorY = originY;
|
|
40260
41086
|
const markerDrawn = /* @__PURE__ */ new Set();
|
|
40261
41087
|
const markerByFootnoteId = new Map(
|
|
40262
41088
|
footnoteReferenceIds.map((footnoteId) => {
|
|
40263
|
-
var
|
|
41089
|
+
var _a3;
|
|
40264
41090
|
return [
|
|
40265
41091
|
footnoteId,
|
|
40266
|
-
((
|
|
41092
|
+
((_a3 = findFootnoteReference(document2, footnoteId)) == null ? void 0 : _a3.run.text) ?? ""
|
|
40267
41093
|
];
|
|
40268
41094
|
})
|
|
40269
41095
|
);
|
|
@@ -40277,7 +41103,7 @@ async function drawFootnoteBlockList(writer, pageIndex, blocks, footnoteReferenc
|
|
|
40277
41103
|
const firstParagraph = block.sourceBlock.type === "paragraph" ? block.sourceBlock : void 0;
|
|
40278
41104
|
const styles = resolveEffectiveTextStyleForParagraph(
|
|
40279
41105
|
void 0,
|
|
40280
|
-
(
|
|
41106
|
+
(_a2 = firstParagraph == null ? void 0 : firstParagraph.style) == null ? void 0 : _a2.styleId,
|
|
40281
41107
|
document2.styles
|
|
40282
41108
|
);
|
|
40283
41109
|
const fontFace = fontRegistry.resolveFontFace({
|
|
@@ -40376,7 +41202,7 @@ function findImageFileFromTransfer(transfer) {
|
|
|
40376
41202
|
return null;
|
|
40377
41203
|
}
|
|
40378
41204
|
function buildImportedDocumentDiagnostics(document2) {
|
|
40379
|
-
var
|
|
41205
|
+
var _a2;
|
|
40380
41206
|
const paragraphs = getDocumentParagraphs(document2);
|
|
40381
41207
|
const fontCounts = /* @__PURE__ */ new Map();
|
|
40382
41208
|
const alignCounts = /* @__PURE__ */ new Map();
|
|
@@ -40394,7 +41220,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
40394
41220
|
for (const run of paragraph.runs) {
|
|
40395
41221
|
const textStyle = resolveEffectiveTextStyleForParagraph(
|
|
40396
41222
|
run.styles,
|
|
40397
|
-
(
|
|
41223
|
+
(_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
|
|
40398
41224
|
document2.styles
|
|
40399
41225
|
);
|
|
40400
41226
|
const fontFamily = textStyle.fontFamily ?? "<null>";
|
|
@@ -40414,7 +41240,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
40414
41240
|
characterSpacingRuns,
|
|
40415
41241
|
characterScaleRuns,
|
|
40416
41242
|
firstParagraphs: paragraphs.slice(0, 30).map((paragraph, index) => {
|
|
40417
|
-
var
|
|
41243
|
+
var _a3;
|
|
40418
41244
|
const paragraphStyle = resolveEffectiveParagraphStyle(
|
|
40419
41245
|
paragraph.style,
|
|
40420
41246
|
document2.styles
|
|
@@ -40422,7 +41248,7 @@ function buildImportedDocumentDiagnostics(document2) {
|
|
|
40422
41248
|
const firstRun = paragraph.runs[0];
|
|
40423
41249
|
const textStyle = resolveEffectiveTextStyleForParagraph(
|
|
40424
41250
|
firstRun == null ? void 0 : firstRun.styles,
|
|
40425
|
-
(
|
|
41251
|
+
(_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
|
|
40426
41252
|
document2.styles
|
|
40427
41253
|
);
|
|
40428
41254
|
return {
|
|
@@ -40513,8 +41339,8 @@ function createDocumentImporter(deps) {
|
|
|
40513
41339
|
const sections = getDocumentSectionsCanonical(document2);
|
|
40514
41340
|
const canonicalBlocks = sections.reduce(
|
|
40515
41341
|
(total, section) => {
|
|
40516
|
-
var
|
|
40517
|
-
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);
|
|
40518
41344
|
},
|
|
40519
41345
|
0
|
|
40520
41346
|
);
|
|
@@ -40615,8 +41441,8 @@ function applyMoveWithText(floating, fixed) {
|
|
|
40615
41441
|
};
|
|
40616
41442
|
}
|
|
40617
41443
|
function isFloatingFixedPosition(floating) {
|
|
40618
|
-
var
|
|
40619
|
-
return ((
|
|
41444
|
+
var _a2;
|
|
41445
|
+
return ((_a2 = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a2.relativeFrom) === "page";
|
|
40620
41446
|
}
|
|
40621
41447
|
function getSelectedImageRun(state) {
|
|
40622
41448
|
return getSelectedObjectRun(state, (run) => run.kind === "image");
|
|
@@ -41182,7 +42008,7 @@ function resolveCaretSlot(paragraphs, focusOffset) {
|
|
|
41182
42008
|
};
|
|
41183
42009
|
}
|
|
41184
42010
|
function computeCanvasSelectionGeometry(snapshot, state) {
|
|
41185
|
-
var
|
|
42011
|
+
var _a2, _b2, _c, _d;
|
|
41186
42012
|
const normalized = normalizeSelection(state);
|
|
41187
42013
|
const selectionBoxes = [];
|
|
41188
42014
|
const surfaceRect = snapshot.surfaceRect;
|
|
@@ -41245,9 +42071,9 @@ function computeCanvasSelectionGeometry(snapshot, state) {
|
|
|
41245
42071
|
const section = sections[activeSectionIndex];
|
|
41246
42072
|
let tableBlock;
|
|
41247
42073
|
if (anchorLoc.zone === "header") {
|
|
41248
|
-
tableBlock = (
|
|
42074
|
+
tableBlock = (_a2 = section == null ? void 0 : section.header) == null ? void 0 : _a2[anchorLoc.blockIndex];
|
|
41249
42075
|
} else if (anchorLoc.zone === "footer") {
|
|
41250
|
-
tableBlock = (
|
|
42076
|
+
tableBlock = (_b2 = section == null ? void 0 : section.footer) == null ? void 0 : _b2[anchorLoc.blockIndex];
|
|
41251
42077
|
} else {
|
|
41252
42078
|
tableBlock = (_c = section == null ? void 0 : section.blocks) == null ? void 0 : _c[anchorLoc.blockIndex];
|
|
41253
42079
|
}
|
|
@@ -41452,9 +42278,9 @@ function areLayoutParagraphsEquivalentForRender(previous, next) {
|
|
|
41452
42278
|
});
|
|
41453
42279
|
}
|
|
41454
42280
|
function canReuseLayoutBlock(previous, next) {
|
|
41455
|
-
var
|
|
42281
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
41456
42282
|
return Boolean(
|
|
41457
|
-
previous && previous.blockId === next.blockId && previous.sourceBlock === next.sourceBlock && previous.estimatedHeight === next.estimatedHeight && ((
|
|
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(
|
|
41458
42284
|
(_g = previous.tableSegment) == null ? void 0 : _g.startRowCellBlockStarts,
|
|
41459
42285
|
(_h = next.tableSegment) == null ? void 0 : _h.startRowCellBlockStarts
|
|
41460
42286
|
) && sameNumberArray(
|
|
@@ -41594,7 +42420,7 @@ function useEditorLayout(props) {
|
|
|
41594
42420
|
const canvasSnapshotProvider = createCanvasLayoutSnapshotProvider();
|
|
41595
42421
|
let syncRequestId = 0;
|
|
41596
42422
|
const syncInputBox = (_reason = "selection") => {
|
|
41597
|
-
var
|
|
42423
|
+
var _a2;
|
|
41598
42424
|
const surface = props.surfaceRef();
|
|
41599
42425
|
if (!surface) {
|
|
41600
42426
|
setSelectionBoxes([]);
|
|
@@ -41608,7 +42434,7 @@ function useEditorLayout(props) {
|
|
|
41608
42434
|
surface,
|
|
41609
42435
|
state: props.state,
|
|
41610
42436
|
documentLayout: documentLayout(),
|
|
41611
|
-
zoomFactor: (
|
|
42437
|
+
zoomFactor: (_a2 = props.zoomFactor) == null ? void 0 : _a2.call(props)
|
|
41612
42438
|
});
|
|
41613
42439
|
if (!snapshot) {
|
|
41614
42440
|
setSelectionBoxes([]);
|
|
@@ -41650,15 +42476,15 @@ function useEditorLayout(props) {
|
|
|
41650
42476
|
return options.resolveWhenDone ? Promise.resolve() : null;
|
|
41651
42477
|
};
|
|
41652
42478
|
const applyInvalidation = (invalidation) => {
|
|
41653
|
-
var
|
|
41654
|
-
if ((
|
|
42479
|
+
var _a2, _b2;
|
|
42480
|
+
if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
|
|
41655
42481
|
return;
|
|
41656
42482
|
}
|
|
41657
42483
|
if (invalidation.dirtyAll || invalidation.structureChanged) {
|
|
41658
42484
|
setMeasuredBlockHeights({});
|
|
41659
42485
|
setMeasuredParagraphLayouts({});
|
|
41660
42486
|
bumpLayoutMetricsEpoch();
|
|
41661
|
-
} else if ((((
|
|
42487
|
+
} else if ((((_b2 = invalidation.dirtyParagraphIds) == null ? void 0 : _b2.length) ?? 0) > 0) {
|
|
41662
42488
|
const dirtyIds = invalidation.dirtyParagraphIds ?? [];
|
|
41663
42489
|
setMeasuredParagraphLayouts(
|
|
41664
42490
|
(current) => normalizeParagraphLayouts(current, dirtyIds)
|
|
@@ -41686,11 +42512,11 @@ function useEditorLayout(props) {
|
|
|
41686
42512
|
requestInputBoxSync("selection");
|
|
41687
42513
|
});
|
|
41688
42514
|
createEffect(() => {
|
|
41689
|
-
var
|
|
42515
|
+
var _a2;
|
|
41690
42516
|
props.state.document;
|
|
41691
42517
|
props.state.activeSectionIndex;
|
|
41692
42518
|
props.state.activeZone;
|
|
41693
|
-
if ((
|
|
42519
|
+
if ((_a2 = props.isImporting) == null ? void 0 : _a2.call(props)) {
|
|
41694
42520
|
return;
|
|
41695
42521
|
}
|
|
41696
42522
|
requestInputBoxSync("content-change");
|
|
@@ -41751,7 +42577,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41751
42577
|
const isEnabled = () => options.enabled ?? false;
|
|
41752
42578
|
const persistence = options.persistence;
|
|
41753
42579
|
const debouncedSave = debounce(async (doc) => {
|
|
41754
|
-
var
|
|
42580
|
+
var _a2;
|
|
41755
42581
|
if (!isEnabled() || !isInitialized()) return;
|
|
41756
42582
|
setStatus("Saving...");
|
|
41757
42583
|
try {
|
|
@@ -41759,7 +42585,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41759
42585
|
await persistence.saveDocument(rawDoc);
|
|
41760
42586
|
setStatus("Saved");
|
|
41761
42587
|
} catch (err) {
|
|
41762
|
-
(
|
|
42588
|
+
(_a2 = options.logger) == null ? void 0 : _a2.error("persistence:autosave failed", err);
|
|
41763
42589
|
setStatus("Error");
|
|
41764
42590
|
}
|
|
41765
42591
|
}, 1e3);
|
|
@@ -41775,7 +42601,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41775
42601
|
)
|
|
41776
42602
|
);
|
|
41777
42603
|
onMount(async () => {
|
|
41778
|
-
var
|
|
42604
|
+
var _a2;
|
|
41779
42605
|
if (!isEnabled()) {
|
|
41780
42606
|
setIsInitialized(true);
|
|
41781
42607
|
setStatus("Saved");
|
|
@@ -41787,7 +42613,7 @@ function useEditorPersistence(state, onLoaded, options) {
|
|
|
41787
42613
|
onLoaded(loadedDoc);
|
|
41788
42614
|
}
|
|
41789
42615
|
} catch (err) {
|
|
41790
|
-
(
|
|
42616
|
+
(_a2 = options.logger) == null ? void 0 : _a2.error("persistence:load failed", err);
|
|
41791
42617
|
} finally {
|
|
41792
42618
|
setIsInitialized(true);
|
|
41793
42619
|
setStatus("Saved");
|
|
@@ -41803,8 +42629,8 @@ function createEmptyEditorHistoryState() {
|
|
|
41803
42629
|
};
|
|
41804
42630
|
}
|
|
41805
42631
|
function applyEditorHistoryTransaction(history, previous, next, options, now = Date.now()) {
|
|
41806
|
-
var
|
|
41807
|
-
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;
|
|
41808
42634
|
return {
|
|
41809
42635
|
undoStack: canMerge ? history.undoStack : [...history.undoStack, previous],
|
|
41810
42636
|
redoStack: [],
|
|
@@ -41965,13 +42791,13 @@ function createEditorHistoryActions(deps) {
|
|
|
41965
42791
|
return true;
|
|
41966
42792
|
};
|
|
41967
42793
|
const applySelectionPreservingStructure = (nextSelection) => {
|
|
41968
|
-
var
|
|
42794
|
+
var _a2;
|
|
41969
42795
|
const snapshot = deps.stateSnapshot();
|
|
41970
42796
|
deps.applyHistoryState({
|
|
41971
42797
|
...snapshot,
|
|
41972
42798
|
document: {
|
|
41973
42799
|
...snapshot.document,
|
|
41974
|
-
sections: (
|
|
42800
|
+
sections: (_a2 = snapshot.document.sections) == null ? void 0 : _a2.map(cloneSection)
|
|
41975
42801
|
},
|
|
41976
42802
|
selection: {
|
|
41977
42803
|
anchor: { ...nextSelection.anchor },
|
|
@@ -41990,8 +42816,8 @@ function openDB(options) {
|
|
|
41990
42816
|
return new Promise((resolve, reject) => {
|
|
41991
42817
|
const request = indexedDB.open(options.name, options.version);
|
|
41992
42818
|
request.onerror = () => {
|
|
41993
|
-
var
|
|
41994
|
-
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}`));
|
|
41995
42821
|
};
|
|
41996
42822
|
request.onsuccess = () => {
|
|
41997
42823
|
resolve(request.result);
|
|
@@ -42009,10 +42835,10 @@ function putItem(db, storeName, key, value) {
|
|
|
42009
42835
|
const store = transaction.objectStore(storeName);
|
|
42010
42836
|
const request = store.put(value, key);
|
|
42011
42837
|
request.onerror = () => {
|
|
42012
|
-
var
|
|
42838
|
+
var _a2;
|
|
42013
42839
|
reject(
|
|
42014
42840
|
new Error(
|
|
42015
|
-
`Failed to put item in ${storeName}: ${(
|
|
42841
|
+
`Failed to put item in ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
42016
42842
|
)
|
|
42017
42843
|
);
|
|
42018
42844
|
};
|
|
@@ -42031,10 +42857,10 @@ function getItem(db, storeName, key) {
|
|
|
42031
42857
|
const store = transaction.objectStore(storeName);
|
|
42032
42858
|
const request = store.get(key);
|
|
42033
42859
|
request.onerror = () => {
|
|
42034
|
-
var
|
|
42860
|
+
var _a2;
|
|
42035
42861
|
reject(
|
|
42036
42862
|
new Error(
|
|
42037
|
-
`Failed to get item from ${storeName}: ${(
|
|
42863
|
+
`Failed to get item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
42038
42864
|
)
|
|
42039
42865
|
);
|
|
42040
42866
|
};
|
|
@@ -42053,10 +42879,10 @@ function deleteItem(db, storeName, key) {
|
|
|
42053
42879
|
const store = transaction.objectStore(storeName);
|
|
42054
42880
|
const request = store.delete(key);
|
|
42055
42881
|
request.onerror = () => {
|
|
42056
|
-
var
|
|
42882
|
+
var _a2;
|
|
42057
42883
|
reject(
|
|
42058
42884
|
new Error(
|
|
42059
|
-
`Failed to delete item from ${storeName}: ${(
|
|
42885
|
+
`Failed to delete item from ${storeName}: ${(_a2 = request.error) == null ? void 0 : _a2.message}`
|
|
42060
42886
|
)
|
|
42061
42887
|
);
|
|
42062
42888
|
};
|
|
@@ -42111,7 +42937,7 @@ function createIndexedDbPersistence(options = {}) {
|
|
|
42111
42937
|
};
|
|
42112
42938
|
}
|
|
42113
42939
|
function computeLayoutInvalidationFromTransaction(prev, next) {
|
|
42114
|
-
var
|
|
42940
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
42115
42941
|
if (prev === next || prev.document === next.document) {
|
|
42116
42942
|
return {};
|
|
42117
42943
|
}
|
|
@@ -42155,7 +42981,7 @@ function computeLayoutInvalidationFromTransaction(prev, next) {
|
|
|
42155
42981
|
}
|
|
42156
42982
|
const aImage = getRunImage(a);
|
|
42157
42983
|
const bImage = getRunImage(b);
|
|
42158
|
-
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)) {
|
|
42159
42985
|
changed = true;
|
|
42160
42986
|
break;
|
|
42161
42987
|
}
|
|
@@ -42222,7 +43048,7 @@ function useEditorTransactions(ctx) {
|
|
|
42222
43048
|
}
|
|
42223
43049
|
function createEditorChangeBroadcast(deps) {
|
|
42224
43050
|
createEffect(() => {
|
|
42225
|
-
var
|
|
43051
|
+
var _a2;
|
|
42226
43052
|
deps.state.document;
|
|
42227
43053
|
deps.state.selection;
|
|
42228
43054
|
deps.state.activeSectionIndex;
|
|
@@ -42232,7 +43058,7 @@ function createEditorChangeBroadcast(deps) {
|
|
|
42232
43058
|
return;
|
|
42233
43059
|
}
|
|
42234
43060
|
const snapshot = deps.cloneState(deps.getStateSnapshot());
|
|
42235
|
-
(
|
|
43061
|
+
(_a2 = deps.getOnStateChange()) == null ? void 0 : _a2(snapshot);
|
|
42236
43062
|
deps.emit("change", snapshot);
|
|
42237
43063
|
deps.emit("documentChange", snapshot.document);
|
|
42238
43064
|
deps.emit("selectionChange", snapshot.selection);
|
|
@@ -42269,8 +43095,8 @@ function createEditorDocumentRuntime(deps) {
|
|
|
42269
43095
|
logger
|
|
42270
43096
|
});
|
|
42271
43097
|
const isImportInProgress = () => {
|
|
42272
|
-
var
|
|
42273
|
-
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;
|
|
42274
43100
|
};
|
|
42275
43101
|
const {
|
|
42276
43102
|
measuredBlockHeights,
|
|
@@ -42548,7 +43374,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
|
|
|
42548
43374
|
return {
|
|
42549
43375
|
...cloneParagraph(candidate),
|
|
42550
43376
|
runs: candidate.runs.map((run) => {
|
|
42551
|
-
var
|
|
43377
|
+
var _a2;
|
|
42552
43378
|
if (run.id !== targetRun.id || run.kind !== "textBox") {
|
|
42553
43379
|
return cloneRun(run);
|
|
42554
43380
|
}
|
|
@@ -42558,7 +43384,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
|
|
|
42558
43384
|
width: nextWidth,
|
|
42559
43385
|
height: nextHeight
|
|
42560
43386
|
};
|
|
42561
|
-
if (changesHeight && ((
|
|
43387
|
+
if (changesHeight && ((_a2 = textBox.body) == null ? void 0 : _a2.autoFit)) {
|
|
42562
43388
|
nextTextBox.body = { ...textBox.body, autoFit: false };
|
|
42563
43389
|
}
|
|
42564
43390
|
if (textBox.floating) {
|
|
@@ -42656,7 +43482,7 @@ const updateBlocksInCurrentSection = (current, blocks, zone = "main") => {
|
|
|
42656
43482
|
};
|
|
42657
43483
|
};
|
|
42658
43484
|
const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
|
|
42659
|
-
var
|
|
43485
|
+
var _a2;
|
|
42660
43486
|
const location = findParagraphTableLocation(
|
|
42661
43487
|
current.document,
|
|
42662
43488
|
current.selection.focus.paragraphId,
|
|
@@ -42677,7 +43503,7 @@ const applyTableAwareParagraphEdit = (current, getTargetBlocks, edit) => {
|
|
|
42677
43503
|
(block, i) => i === location.blockIndex ? clonedTable : block
|
|
42678
43504
|
);
|
|
42679
43505
|
const tableBlock = clonedTable;
|
|
42680
|
-
const targetCell = (
|
|
43506
|
+
const targetCell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42681
43507
|
if (!targetCell) {
|
|
42682
43508
|
return edit(current);
|
|
42683
43509
|
}
|
|
@@ -42717,7 +43543,7 @@ function createTableOpsGuards(deps) {
|
|
|
42717
43543
|
return Boolean(range && range.endCellIndex > range.startCellIndex);
|
|
42718
43544
|
};
|
|
42719
43545
|
const canSplitSelectedTableCell = (current) => {
|
|
42720
|
-
var
|
|
43546
|
+
var _a2;
|
|
42721
43547
|
const location = findParagraphTableLocation(
|
|
42722
43548
|
current.document,
|
|
42723
43549
|
current.selection.focus.paragraphId,
|
|
@@ -42731,11 +43557,11 @@ function createTableOpsGuards(deps) {
|
|
|
42731
43557
|
if (!block || block.type !== "table") {
|
|
42732
43558
|
return false;
|
|
42733
43559
|
}
|
|
42734
|
-
const cell = (
|
|
43560
|
+
const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42735
43561
|
return Boolean(((cell == null ? void 0 : cell.colSpan) ?? 1) > 1);
|
|
42736
43562
|
};
|
|
42737
43563
|
const canMergeSelectedTableRows = (current) => {
|
|
42738
|
-
var
|
|
43564
|
+
var _a2;
|
|
42739
43565
|
const range = deps.resolveVerticalTableCellRange(current);
|
|
42740
43566
|
if (!range) {
|
|
42741
43567
|
return false;
|
|
@@ -42746,7 +43572,7 @@ function createTableOpsGuards(deps) {
|
|
|
42746
43572
|
return false;
|
|
42747
43573
|
}
|
|
42748
43574
|
for (let rowIndex = range.startRowIndex; rowIndex <= range.endRowIndex; rowIndex += 1) {
|
|
42749
|
-
const cell = (
|
|
43575
|
+
const cell = (_a2 = tableBlock.rows[rowIndex]) == null ? void 0 : _a2.cells[range.cellIndex];
|
|
42750
43576
|
if (!cell || cell.vMerge === "continue" || cell.blocks.length !== 1) {
|
|
42751
43577
|
return false;
|
|
42752
43578
|
}
|
|
@@ -42757,7 +43583,7 @@ function createTableOpsGuards(deps) {
|
|
|
42757
43583
|
return canMergeSelectedTableCells(current) || canMergeSelectedTableRows(current);
|
|
42758
43584
|
};
|
|
42759
43585
|
const canSplitSelectedTableCellVertically = (current) => {
|
|
42760
|
-
var
|
|
43586
|
+
var _a2;
|
|
42761
43587
|
const location = findParagraphTableLocation(
|
|
42762
43588
|
current.document,
|
|
42763
43589
|
current.selection.focus.paragraphId,
|
|
@@ -42771,7 +43597,7 @@ function createTableOpsGuards(deps) {
|
|
|
42771
43597
|
if (!block || block.type !== "table") {
|
|
42772
43598
|
return false;
|
|
42773
43599
|
}
|
|
42774
|
-
const cell = (
|
|
43600
|
+
const cell = (_a2 = block.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
42775
43601
|
return Boolean(((cell == null ? void 0 : cell.rowSpan) ?? 1) > 1 && (cell == null ? void 0 : cell.vMerge) === "restart");
|
|
42776
43602
|
};
|
|
42777
43603
|
const canSplitSelectedTable = (current) => {
|
|
@@ -42868,11 +43694,11 @@ function getSelectionTableContext(current, deps) {
|
|
|
42868
43694
|
}
|
|
42869
43695
|
function createTableSelectionResolvers(deps) {
|
|
42870
43696
|
const resolveTableCellRangeSelection = (current) => {
|
|
42871
|
-
var
|
|
43697
|
+
var _a2, _b2, _c, _d, _e;
|
|
42872
43698
|
const selection = current.selection;
|
|
42873
43699
|
const context = getSelectionTableContext(current, deps);
|
|
42874
43700
|
if (!context || context.anchorLocation.rowIndex === context.focusLocation.rowIndex && context.anchorLocation.cellIndex === context.focusLocation.cellIndex) {
|
|
42875
|
-
(
|
|
43701
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.debug(
|
|
42876
43702
|
`resolveTableCellRangeSelection: no expansion (anchor=${selection.anchor.paragraphId} focus=${selection.focus.paragraphId})`
|
|
42877
43703
|
);
|
|
42878
43704
|
return null;
|
|
@@ -42893,7 +43719,7 @@ function createTableSelectionResolvers(deps) {
|
|
|
42893
43719
|
context.anchorLocation.cellIndex,
|
|
42894
43720
|
context.focusLocation.cellIndex
|
|
42895
43721
|
);
|
|
42896
|
-
(
|
|
43722
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info(
|
|
42897
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}]`
|
|
42898
43724
|
);
|
|
42899
43725
|
const startLocation = compareCellLocations(context.anchorCell, context.focusCell) <= 0 ? context.anchorLocation : context.focusLocation;
|
|
@@ -43169,7 +43995,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
43169
43995
|
return current;
|
|
43170
43996
|
};
|
|
43171
43997
|
const splitSelectedTableCellVertically = (current) => {
|
|
43172
|
-
var
|
|
43998
|
+
var _a2;
|
|
43173
43999
|
const location = findParagraphTableLocation(
|
|
43174
44000
|
current.document,
|
|
43175
44001
|
current.selection.focus.paragraphId,
|
|
@@ -43183,7 +44009,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
43183
44009
|
if (!tableBlock || tableBlock.type !== "table") {
|
|
43184
44010
|
return current;
|
|
43185
44011
|
}
|
|
43186
|
-
const cell = (
|
|
44012
|
+
const cell = (_a2 = tableBlock.rows[location.rowIndex]) == null ? void 0 : _a2.cells[location.cellIndex];
|
|
43187
44013
|
const span = Math.max(1, (cell == null ? void 0 : cell.rowSpan) ?? 1);
|
|
43188
44014
|
if (!cell || span <= 1 || cell.vMerge !== "restart") {
|
|
43189
44015
|
return current;
|
|
@@ -43213,8 +44039,8 @@ function createTableCellSpanOperations(deps) {
|
|
|
43213
44039
|
previousCells: [
|
|
43214
44040
|
previousCell,
|
|
43215
44041
|
...Array.from({ length: span - 1 }, (_, offset) => {
|
|
43216
|
-
var
|
|
43217
|
-
const prior = (
|
|
44042
|
+
var _a3;
|
|
44043
|
+
const prior = (_a3 = tableBlock.rows[location.rowIndex + offset + 1]) == null ? void 0 : _a3.cells[location.cellIndex];
|
|
43218
44044
|
return prior ? cloneCellSnapshot(prior) : createEditorTableCell([], preservedColSpan);
|
|
43219
44045
|
})
|
|
43220
44046
|
]
|
|
@@ -43249,7 +44075,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
43249
44075
|
};
|
|
43250
44076
|
};
|
|
43251
44077
|
const splitSelectedTableCell = (current) => {
|
|
43252
|
-
var
|
|
44078
|
+
var _a2;
|
|
43253
44079
|
const location = findParagraphTableLocation(
|
|
43254
44080
|
current.document,
|
|
43255
44081
|
current.selection.focus.paragraphId,
|
|
@@ -43305,7 +44131,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
43305
44131
|
)
|
|
43306
44132
|
];
|
|
43307
44133
|
row.cells.splice(location.cellIndex, 1, ...nextCells);
|
|
43308
|
-
const nextParagraph = (
|
|
44134
|
+
const nextParagraph = (_a2 = nextCells[0]) == null ? void 0 : _a2.blocks[0];
|
|
43309
44135
|
if (!nextParagraph) {
|
|
43310
44136
|
return current;
|
|
43311
44137
|
}
|
|
@@ -43342,7 +44168,7 @@ function createTableCellSpanOperations(deps) {
|
|
|
43342
44168
|
}
|
|
43343
44169
|
function createTableRowColumnOperations(deps) {
|
|
43344
44170
|
const insertSelectedTableRow = (current, direction) => {
|
|
43345
|
-
var
|
|
44171
|
+
var _a2, _b2;
|
|
43346
44172
|
const location = findParagraphTableLocation(
|
|
43347
44173
|
current.document,
|
|
43348
44174
|
current.selection.focus.paragraphId,
|
|
@@ -43418,9 +44244,9 @@ function createTableRowColumnOperations(deps) {
|
|
|
43418
44244
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
43419
44245
|
const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
|
|
43420
44246
|
const targetCell2 = findCellAtVisualColumn(blankRow, targetVisualColumn);
|
|
43421
|
-
const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((
|
|
44247
|
+
const nextParagraph2 = (targetCell2 == null ? void 0 : targetCell2.blocks[0]) ?? ((_a2 = blankRow.cells.find(
|
|
43422
44248
|
(cell) => cell.vMerge !== "continue" && cell.blocks[0]
|
|
43423
|
-
)) == null ? void 0 :
|
|
44249
|
+
)) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
|
|
43424
44250
|
if (!nextParagraph2) {
|
|
43425
44251
|
return updateBlocksInCurrentSection(
|
|
43426
44252
|
current,
|
|
@@ -43460,9 +44286,9 @@ function createTableRowColumnOperations(deps) {
|
|
|
43460
44286
|
}
|
|
43461
44287
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
43462
44288
|
const targetCell = blankRow.cells[Math.min(location.cellIndex, blankRow.cells.length - 1)];
|
|
43463
|
-
const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((
|
|
44289
|
+
const nextParagraph = (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_b2 = blankRow.cells.find(
|
|
43464
44290
|
(cell) => cell.vMerge !== "continue" && cell.blocks[0]
|
|
43465
|
-
)) == null ? void 0 :
|
|
44291
|
+
)) == null ? void 0 : _b2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
|
|
43466
44292
|
if (!nextParagraph) {
|
|
43467
44293
|
return updateBlocksInCurrentSection(current, targetBlocks, location.zone);
|
|
43468
44294
|
}
|
|
@@ -43565,7 +44391,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43565
44391
|
};
|
|
43566
44392
|
};
|
|
43567
44393
|
const insertSelectedTableColumn = (current, direction) => {
|
|
43568
|
-
var
|
|
44394
|
+
var _a2;
|
|
43569
44395
|
const location = findParagraphTableLocation(
|
|
43570
44396
|
current.document,
|
|
43571
44397
|
current.selection.focus.paragraphId,
|
|
@@ -43672,7 +44498,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43672
44498
|
const insertIndex = Math.max(
|
|
43673
44499
|
0,
|
|
43674
44500
|
Math.min(
|
|
43675
|
-
((
|
|
44501
|
+
((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) ?? 0,
|
|
43676
44502
|
location.cellIndex + (direction > 0 ? 1 : 0)
|
|
43677
44503
|
)
|
|
43678
44504
|
);
|
|
@@ -43708,7 +44534,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43708
44534
|
};
|
|
43709
44535
|
};
|
|
43710
44536
|
const deleteSelectedTableColumn = (current) => {
|
|
43711
|
-
var
|
|
44537
|
+
var _a2;
|
|
43712
44538
|
const location = findParagraphTableLocation(
|
|
43713
44539
|
current.document,
|
|
43714
44540
|
current.selection.focus.paragraphId,
|
|
@@ -43802,7 +44628,7 @@ function createTableRowColumnOperations(deps) {
|
|
|
43802
44628
|
}
|
|
43803
44629
|
};
|
|
43804
44630
|
}
|
|
43805
|
-
if (((
|
|
44631
|
+
if (((_a2 = tableBlock.rows[0]) == null ? void 0 : _a2.cells.length) <= 1) {
|
|
43806
44632
|
return current;
|
|
43807
44633
|
}
|
|
43808
44634
|
for (const row of tableBlock.rows) {
|
|
@@ -43847,19 +44673,19 @@ function createTableSelectionAwareCommands(deps) {
|
|
|
43847
44673
|
};
|
|
43848
44674
|
const applySelectionAwareCommand = (command, logPrefix) => {
|
|
43849
44675
|
deps.applyTransactionalState((current) => {
|
|
43850
|
-
var
|
|
44676
|
+
var _a2, _b2, _c;
|
|
43851
44677
|
const selection = deps.resolveSelectedTableCells(current);
|
|
43852
44678
|
if (!selection || selection.cells.length <= 1) {
|
|
43853
44679
|
const expanded = withExpandedTableCellSelection(current);
|
|
43854
44680
|
if (expanded !== current) {
|
|
43855
|
-
(
|
|
44681
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info(
|
|
43856
44682
|
`${logPrefix}: expanded selection to ${expanded.selection.anchor.paragraphId}[${expanded.selection.anchor.offset}]..${expanded.selection.focus.paragraphId}[${expanded.selection.focus.offset}]`
|
|
43857
44683
|
);
|
|
43858
44684
|
}
|
|
43859
44685
|
return command(expanded);
|
|
43860
44686
|
}
|
|
43861
44687
|
const { blockIndex, cells, zone } = selection;
|
|
43862
|
-
(
|
|
44688
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info(
|
|
43863
44689
|
`${logPrefix}: multi-cell selection in table block ${blockIndex} (${cells.length} cells) in zone ${zone}`
|
|
43864
44690
|
);
|
|
43865
44691
|
const allParagraphs = [];
|
|
@@ -44004,8 +44830,8 @@ function createEditorTableOperations(deps) {
|
|
|
44004
44830
|
logger: deps.logger
|
|
44005
44831
|
});
|
|
44006
44832
|
const insertTableCommand = (rows, cols) => {
|
|
44007
|
-
var
|
|
44008
|
-
(
|
|
44833
|
+
var _a2;
|
|
44834
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info(`insertTableCommand: ${rows}x${cols}`);
|
|
44009
44835
|
deps.applyTransactionalState(
|
|
44010
44836
|
(current) => insertTableAtSelection(current, rows, cols),
|
|
44011
44837
|
{
|
|
@@ -44069,12 +44895,12 @@ function createResizeSession(adapter, deps) {
|
|
|
44069
44895
|
}
|
|
44070
44896
|
});
|
|
44071
44897
|
const handleMouseMove = (event) => {
|
|
44072
|
-
var
|
|
44898
|
+
var _a2;
|
|
44073
44899
|
const resize = active;
|
|
44074
44900
|
if (!resize) {
|
|
44075
44901
|
return;
|
|
44076
44902
|
}
|
|
44077
|
-
const z = ((
|
|
44903
|
+
const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
|
|
44078
44904
|
const deltaX = (event.clientX - resize.startClientX) / z;
|
|
44079
44905
|
const deltaY = (event.clientY - resize.startClientY) / z;
|
|
44080
44906
|
const maxWidth = adapter.getMaxWidth(deps.state, resize.paragraphId);
|
|
@@ -44973,7 +45799,7 @@ function resolveImageAtPoint(snapshot, pageIndex, zone, clientX, clientY, pierce
|
|
|
44973
45799
|
return null;
|
|
44974
45800
|
}
|
|
44975
45801
|
function resolveCanvasSurfaceHitAtPoint(options) {
|
|
44976
|
-
var
|
|
45802
|
+
var _a2, _b2, _c;
|
|
44977
45803
|
const { snapshot, state } = options;
|
|
44978
45804
|
const pierce = options.pierce ?? false;
|
|
44979
45805
|
const zoomFactor = options.zoomFactor && options.zoomFactor > 0 ? options.zoomFactor : 1;
|
|
@@ -45015,7 +45841,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
|
|
|
45015
45841
|
position: position2,
|
|
45016
45842
|
source: "canvas-layout",
|
|
45017
45843
|
resolvedFromParagraph: true,
|
|
45018
|
-
tableCellAnchorPosition: (
|
|
45844
|
+
tableCellAnchorPosition: (_a2 = paragraphSegment.tableCell) == null ? void 0 : _a2.anchorPosition,
|
|
45019
45845
|
caretViewport: {
|
|
45020
45846
|
left: textBoxHit.left,
|
|
45021
45847
|
top: textBoxHit.top,
|
|
@@ -45064,7 +45890,7 @@ function resolveCanvasSurfaceHitAtPoint(options) {
|
|
|
45064
45890
|
position: position2,
|
|
45065
45891
|
source: "canvas-layout",
|
|
45066
45892
|
resolvedFromParagraph: true,
|
|
45067
|
-
tableCellAnchorPosition: (
|
|
45893
|
+
tableCellAnchorPosition: (_b2 = paragraphSegment.tableCell) == null ? void 0 : _b2.anchorPosition,
|
|
45068
45894
|
caretViewport: {
|
|
45069
45895
|
left: imageHit.left,
|
|
45070
45896
|
top: imageHit.top,
|
|
@@ -45407,20 +46233,20 @@ function createEditorLayoutOptionsController(deps) {
|
|
|
45407
46233
|
}
|
|
45408
46234
|
function createEditorClipboardController(deps) {
|
|
45409
46235
|
const handleCopy = (event) => {
|
|
45410
|
-
var
|
|
46236
|
+
var _a2, _b2;
|
|
45411
46237
|
const text = getSelectedText(deps.state());
|
|
45412
46238
|
if (text.length === 0) {
|
|
45413
46239
|
return;
|
|
45414
46240
|
}
|
|
45415
46241
|
event.preventDefault();
|
|
45416
|
-
(
|
|
45417
|
-
(
|
|
46242
|
+
(_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
|
|
46243
|
+
(_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
|
|
45418
46244
|
"text/html",
|
|
45419
46245
|
serializeEditorSelectionToHtml(deps.state())
|
|
45420
46246
|
);
|
|
45421
46247
|
};
|
|
45422
46248
|
const handleCut = (event) => {
|
|
45423
|
-
var
|
|
46249
|
+
var _a2, _b2;
|
|
45424
46250
|
if (deps.isReadOnly()) {
|
|
45425
46251
|
event.preventDefault();
|
|
45426
46252
|
return;
|
|
@@ -45430,8 +46256,8 @@ function createEditorClipboardController(deps) {
|
|
|
45430
46256
|
return;
|
|
45431
46257
|
}
|
|
45432
46258
|
event.preventDefault();
|
|
45433
|
-
(
|
|
45434
|
-
(
|
|
46259
|
+
(_a2 = event.clipboardData) == null ? void 0 : _a2.setData("text/plain", text);
|
|
46260
|
+
(_b2 = event.clipboardData) == null ? void 0 : _b2.setData(
|
|
45435
46261
|
"text/html",
|
|
45436
46262
|
serializeEditorSelectionToHtml(deps.state())
|
|
45437
46263
|
);
|
|
@@ -45446,14 +46272,14 @@ function createEditorClipboardController(deps) {
|
|
|
45446
46272
|
deps.focusInput();
|
|
45447
46273
|
};
|
|
45448
46274
|
const handlePaste = (event) => {
|
|
45449
|
-
var
|
|
46275
|
+
var _a2, _b2, _c;
|
|
45450
46276
|
if (deps.isReadOnly()) {
|
|
45451
46277
|
event.preventDefault();
|
|
45452
46278
|
return;
|
|
45453
46279
|
}
|
|
45454
46280
|
if (deps.forcePlainTextPaste()) {
|
|
45455
46281
|
deps.setForcePlainTextPaste(false);
|
|
45456
|
-
const text2 = ((
|
|
46282
|
+
const text2 = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
|
|
45457
46283
|
if (text2.length === 0) {
|
|
45458
46284
|
event.preventDefault();
|
|
45459
46285
|
return;
|
|
@@ -45481,7 +46307,7 @@ function createEditorClipboardController(deps) {
|
|
|
45481
46307
|
deps.focusInput();
|
|
45482
46308
|
return;
|
|
45483
46309
|
}
|
|
45484
|
-
const html = ((
|
|
46310
|
+
const html = ((_b2 = event.clipboardData) == null ? void 0 : _b2.getData("text/html")) ?? "";
|
|
45485
46311
|
const paragraphs = parseEditorClipboardHtmlWithDom(html);
|
|
45486
46312
|
if (paragraphs.length > 0) {
|
|
45487
46313
|
event.preventDefault();
|
|
@@ -45754,17 +46580,17 @@ const CONTENT_MIN_WIDTH_GUARD_PX = 12;
|
|
|
45754
46580
|
const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
|
|
45755
46581
|
const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
|
|
45756
46582
|
function resolveHorizontalCellChromePx(cell) {
|
|
45757
|
-
var
|
|
45758
|
-
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(
|
|
45759
46585
|
0,
|
|
45760
|
-
(((
|
|
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)
|
|
45761
46587
|
);
|
|
45762
46588
|
const borderLeft = ((_d = cell.style) == null ? void 0 : _d.borderLeft) ? Math.max(0, ptToPx(cell.style.borderLeft.width)) : 1;
|
|
45763
46589
|
const borderRight = ((_e = cell.style) == null ? void 0 : _e.borderRight) ? Math.max(0, ptToPx(cell.style.borderRight.width)) : 1;
|
|
45764
46590
|
return padding + borderLeft + borderRight;
|
|
45765
46591
|
}
|
|
45766
46592
|
function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
|
|
45767
|
-
var
|
|
46593
|
+
var _a2, _b2;
|
|
45768
46594
|
const rowCount = Math.max(1, tableNode.rows.length);
|
|
45769
46595
|
const baseRowHeight = geometry.bounds.height / rowCount;
|
|
45770
46596
|
const rowHeights = Array(rowCount).fill(baseRowHeight);
|
|
@@ -45774,7 +46600,7 @@ function resolveRowHeightsPx(tableNode, tableLayout, geometry) {
|
|
|
45774
46600
|
)
|
|
45775
46601
|
);
|
|
45776
46602
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
|
|
45777
|
-
const explicitPt = parseSizeToPt((
|
|
46603
|
+
const explicitPt = parseSizeToPt((_b2 = (_a2 = tableNode.rows[rowIndex]) == null ? void 0 : _a2.style) == null ? void 0 : _b2.height);
|
|
45778
46604
|
if (explicitPt !== null) {
|
|
45779
46605
|
rowHeights[rowIndex] = Math.max(1, ptToPx(explicitPt));
|
|
45780
46606
|
continue;
|
|
@@ -45864,7 +46690,7 @@ function resolveMinRowHeightPx(tableNode, tableLayout, geometry, targetRowIndex)
|
|
|
45864
46690
|
return Math.max(minFloor, minHeight);
|
|
45865
46691
|
}
|
|
45866
46692
|
function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
|
|
45867
|
-
var
|
|
46693
|
+
var _a2;
|
|
45868
46694
|
const minFloor = ptToPx(MIN_TABLE_SIZE_PT);
|
|
45869
46695
|
const result = {};
|
|
45870
46696
|
const geometryByKey = new Map(
|
|
@@ -45878,7 +46704,7 @@ function resolveMinColumnWidthsPx(state, tableNode, tableLayout, geometry) {
|
|
|
45878
46704
|
`${entry.rowIndex}:${entry.cellIndex}`
|
|
45879
46705
|
);
|
|
45880
46706
|
if (!geometryCell) continue;
|
|
45881
|
-
const cell = (
|
|
46707
|
+
const cell = (_a2 = tableNode.rows[entry.rowIndex]) == null ? void 0 : _a2.cells[entry.cellIndex];
|
|
45882
46708
|
if (!cell) continue;
|
|
45883
46709
|
const visualCol = entry.visualColumnIndex;
|
|
45884
46710
|
const currentMin = result[visualCol] ?? minFloor;
|
|
@@ -45910,7 +46736,7 @@ function applyRowResize(state, resize, delta) {
|
|
|
45910
46736
|
return setTableRowHeight(state, resize.tableId, resize.index, newSizePt);
|
|
45911
46737
|
}
|
|
45912
46738
|
function applyColumnResize(state, resize, delta) {
|
|
45913
|
-
var
|
|
46739
|
+
var _a2;
|
|
45914
46740
|
if (resize.type !== "column") return state;
|
|
45915
46741
|
const deltaPt = pxToPt(delta);
|
|
45916
46742
|
const maxColumnIndex = resize.maxColumnIndex ?? resize.index;
|
|
@@ -45976,7 +46802,7 @@ function applyColumnResize(state, resize, delta) {
|
|
|
45976
46802
|
0
|
|
45977
46803
|
);
|
|
45978
46804
|
const tableNode = getTableById(state, resize.tableId);
|
|
45979
|
-
const currentTableWidthPt = parseSizeToPt((
|
|
46805
|
+
const currentTableWidthPt = parseSizeToPt((_a2 = tableNode == null ? void 0 : tableNode.style) == null ? void 0 : _a2.width);
|
|
45980
46806
|
const tableWidthToPersist = isLastColumn ? tableWidthPt : currentTableWidthPt !== null ? currentTableWidthPt : void 0;
|
|
45981
46807
|
return setTableColumnWidths(
|
|
45982
46808
|
state,
|
|
@@ -46026,7 +46852,7 @@ const DRAG_THRESHOLD_PX = 2;
|
|
|
46026
46852
|
function createEditorTableResize(deps) {
|
|
46027
46853
|
const [resizing, setResizing] = createSignal(null);
|
|
46028
46854
|
const handleMouseMove = (event) => {
|
|
46029
|
-
var
|
|
46855
|
+
var _a2;
|
|
46030
46856
|
if (resizing()) {
|
|
46031
46857
|
setActiveCursorClass(resizing().type === "column");
|
|
46032
46858
|
return;
|
|
@@ -46042,7 +46868,7 @@ function createEditorTableResize(deps) {
|
|
|
46042
46868
|
deps.state(),
|
|
46043
46869
|
deps.documentLayout(),
|
|
46044
46870
|
deps.canvasSnapshotProvider,
|
|
46045
|
-
(
|
|
46871
|
+
(_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
46046
46872
|
);
|
|
46047
46873
|
if (!info) {
|
|
46048
46874
|
clearResizeCursorClasses();
|
|
@@ -46051,7 +46877,7 @@ function createEditorTableResize(deps) {
|
|
|
46051
46877
|
setHoverCursorClass(info.side === "left" || info.side === "right");
|
|
46052
46878
|
};
|
|
46053
46879
|
const handleMouseDown = (event) => {
|
|
46054
|
-
var
|
|
46880
|
+
var _a2, _b2;
|
|
46055
46881
|
const surface = deps.surfaceRef();
|
|
46056
46882
|
if (!surface) return false;
|
|
46057
46883
|
const info = findTableResizeHoverInfo(
|
|
@@ -46060,7 +46886,7 @@ function createEditorTableResize(deps) {
|
|
|
46060
46886
|
deps.state(),
|
|
46061
46887
|
deps.documentLayout(),
|
|
46062
46888
|
deps.canvasSnapshotProvider,
|
|
46063
|
-
(
|
|
46889
|
+
(_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
46064
46890
|
);
|
|
46065
46891
|
if (!info) return false;
|
|
46066
46892
|
const state = deps.state();
|
|
@@ -46092,7 +46918,7 @@ function createEditorTableResize(deps) {
|
|
|
46092
46918
|
maxColumnIndex,
|
|
46093
46919
|
minColumnWidthsPx,
|
|
46094
46920
|
resizeFromLeftEdge: isLeftTableEdge,
|
|
46095
|
-
initialTableIndentLeftPt: parseSizeToPt((
|
|
46921
|
+
initialTableIndentLeftPt: parseSizeToPt((_b2 = info.tableNode.style) == null ? void 0 : _b2.indentLeft) ?? 0,
|
|
46096
46922
|
guideBounds: getGuideBounds(deps.viewportRef)
|
|
46097
46923
|
});
|
|
46098
46924
|
setActiveCursorClass(true);
|
|
@@ -46146,10 +46972,10 @@ function createEditorTableResize(deps) {
|
|
|
46146
46972
|
setActiveCursorClass(currentResizing.type === "column");
|
|
46147
46973
|
};
|
|
46148
46974
|
const handleWindowMouseUp = (event) => {
|
|
46149
|
-
var
|
|
46975
|
+
var _a2;
|
|
46150
46976
|
const currentResizing = resizing();
|
|
46151
46977
|
if (!currentResizing) return;
|
|
46152
|
-
const z = ((
|
|
46978
|
+
const z = ((_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)) ?? 1;
|
|
46153
46979
|
const delta = ((currentResizing.type === "column" ? event.clientX : event.clientY) - currentResizing.initialPos) / z;
|
|
46154
46980
|
if (Math.abs(delta) >= DRAG_THRESHOLD_PX) {
|
|
46155
46981
|
deps.applyTransactionalState((current) => {
|
|
@@ -46188,7 +47014,7 @@ function createEditorTableDrag(deps) {
|
|
|
46188
47014
|
document.body.style.cursor = "";
|
|
46189
47015
|
};
|
|
46190
47016
|
const handleMouseMove = (event) => {
|
|
46191
|
-
var
|
|
47017
|
+
var _a2;
|
|
46192
47018
|
setMousePos({ x: event.clientX, y: event.clientY });
|
|
46193
47019
|
if (!dragging()) {
|
|
46194
47020
|
const delta = Math.abs(event.clientY - startClientY());
|
|
@@ -46204,7 +47030,7 @@ function createEditorTableDrag(deps) {
|
|
|
46204
47030
|
event.clientX,
|
|
46205
47031
|
event.clientY
|
|
46206
47032
|
);
|
|
46207
|
-
const tableId = (
|
|
47033
|
+
const tableId = (_a2 = draggedTableInfo()) == null ? void 0 : _a2.tableId;
|
|
46208
47034
|
if (pos && tableId) {
|
|
46209
47035
|
const state = deps.state();
|
|
46210
47036
|
const location = findParagraphTableLocation(
|
|
@@ -46233,7 +47059,7 @@ function createEditorTableDrag(deps) {
|
|
|
46233
47059
|
const tableId = info == null ? void 0 : info.tableId;
|
|
46234
47060
|
if (tableId) {
|
|
46235
47061
|
deps.applyTransactionalState((current) => {
|
|
46236
|
-
var
|
|
47062
|
+
var _a2;
|
|
46237
47063
|
const findTable = () => {
|
|
46238
47064
|
for (const zone of ["main", "header", "footer"]) {
|
|
46239
47065
|
const blocks = getEditableBlocksForZone(current, zone);
|
|
@@ -46245,7 +47071,7 @@ function createEditorTableDrag(deps) {
|
|
|
46245
47071
|
return void 0;
|
|
46246
47072
|
};
|
|
46247
47073
|
const table = findTable();
|
|
46248
|
-
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)) {
|
|
46249
47075
|
const floating = table.style.floating;
|
|
46250
47076
|
const pointsPerPixel = 72 / 96;
|
|
46251
47077
|
return setActiveTableStyleValue(current, tableId, "floating", {
|
|
@@ -46404,9 +47230,9 @@ function createEditorSurfaceEvents(deps) {
|
|
|
46404
47230
|
globalThis.clearTimeout(handle);
|
|
46405
47231
|
};
|
|
46406
47232
|
const applyWithZone = (state, targetZone, newState, targetPosition) => {
|
|
46407
|
-
var
|
|
47233
|
+
var _a2;
|
|
46408
47234
|
const isZoneTransition = targetZone !== (state.activeZone ?? "main");
|
|
46409
|
-
const targetFootnoteId = targetZone === "footnote" && targetPosition ? (
|
|
47235
|
+
const targetFootnoteId = targetZone === "footnote" && targetPosition ? (_a2 = findParagraphLocation(newState.document, targetPosition.paragraphId)) == null ? void 0 : _a2.footnoteId : void 0;
|
|
46410
47236
|
const isFootnoteTransition = targetZone === "footnote" && targetFootnoteId !== state.activeFootnoteId;
|
|
46411
47237
|
if (!isZoneTransition && !isFootnoteTransition) {
|
|
46412
47238
|
deps.applyState(newState);
|
|
@@ -46541,7 +47367,7 @@ function createEditorSurfaceEvents(deps) {
|
|
|
46541
47367
|
deps.focusInputAfterPointerSelection();
|
|
46542
47368
|
};
|
|
46543
47369
|
const handleSurfaceMouseDown = (event) => {
|
|
46544
|
-
var
|
|
47370
|
+
var _a2;
|
|
46545
47371
|
if (event.button !== 0) {
|
|
46546
47372
|
return;
|
|
46547
47373
|
}
|
|
@@ -46576,7 +47402,7 @@ function createEditorSurfaceEvents(deps) {
|
|
|
46576
47402
|
deps.focusInputAfterPointerSelection();
|
|
46577
47403
|
return;
|
|
46578
47404
|
}
|
|
46579
|
-
if ((
|
|
47405
|
+
if ((_a2 = deps.textDrag) == null ? void 0 : _a2.tryStartTextDrag(event, hit)) {
|
|
46580
47406
|
dragAnchor = null;
|
|
46581
47407
|
stopDragging();
|
|
46582
47408
|
deps.focusInputAfterPointerSelection();
|
|
@@ -46811,7 +47637,7 @@ function createEditorTextInput(deps) {
|
|
|
46811
47637
|
const [composing, setComposing] = createSignal(false);
|
|
46812
47638
|
let suppressedInputText = null;
|
|
46813
47639
|
const handleTextInput = (event) => {
|
|
46814
|
-
var
|
|
47640
|
+
var _a2, _b2, _c, _d;
|
|
46815
47641
|
markStart("input:text");
|
|
46816
47642
|
if (deps.isReadOnly()) {
|
|
46817
47643
|
deps.logger.debug(
|
|
@@ -46836,9 +47662,9 @@ function createEditorTextInput(deps) {
|
|
|
46836
47662
|
}
|
|
46837
47663
|
const state = deps.state();
|
|
46838
47664
|
const sel = state.selection;
|
|
46839
|
-
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);
|
|
46840
47666
|
const runStyle = currentRun ? {
|
|
46841
|
-
bold: (
|
|
47667
|
+
bold: (_b2 = currentRun.styles) == null ? void 0 : _b2.bold,
|
|
46842
47668
|
italic: (_c = currentRun.styles) == null ? void 0 : _c.italic,
|
|
46843
47669
|
underline: (_d = currentRun.styles) == null ? void 0 : _d.underline
|
|
46844
47670
|
} : null;
|
|
@@ -46954,8 +47780,8 @@ function createEditorTextDrag(deps) {
|
|
|
46954
47780
|
document.head.appendChild(cursorStyleEl);
|
|
46955
47781
|
};
|
|
46956
47782
|
const stopDrag = () => {
|
|
46957
|
-
var
|
|
46958
|
-
(
|
|
47783
|
+
var _a2;
|
|
47784
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:stop", {
|
|
46959
47785
|
dragging: dragging(),
|
|
46960
47786
|
dropTarget: dropTargetPos() ? `${dropTargetPos().paragraphId}:${dropTargetPos().runId}[${dropTargetPos().offset}]` : null,
|
|
46961
47787
|
copyMode: copyMode()
|
|
@@ -46972,7 +47798,7 @@ function createEditorTextDrag(deps) {
|
|
|
46972
47798
|
window.removeEventListener("mouseup", handleWindowMouseUp);
|
|
46973
47799
|
};
|
|
46974
47800
|
const handleWindowMouseMove = (event) => {
|
|
46975
|
-
var
|
|
47801
|
+
var _a2, _b2, _c;
|
|
46976
47802
|
if (!pendingStart) {
|
|
46977
47803
|
return;
|
|
46978
47804
|
}
|
|
@@ -46984,7 +47810,7 @@ function createEditorTextDrag(deps) {
|
|
|
46984
47810
|
if (deltaX + deltaY < 4) {
|
|
46985
47811
|
return;
|
|
46986
47812
|
}
|
|
46987
|
-
(
|
|
47813
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:activate", {
|
|
46988
47814
|
start: pendingStart,
|
|
46989
47815
|
at: { x: event.clientX, y: event.clientY },
|
|
46990
47816
|
deltaX,
|
|
@@ -46996,7 +47822,7 @@ function createEditorTextDrag(deps) {
|
|
|
46996
47822
|
setPointerPos({ x: event.clientX, y: event.clientY });
|
|
46997
47823
|
const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY);
|
|
46998
47824
|
if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) {
|
|
46999
|
-
(
|
|
47825
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:hit-miss", {
|
|
47000
47826
|
x: event.clientX,
|
|
47001
47827
|
y: event.clientY
|
|
47002
47828
|
});
|
|
@@ -47024,8 +47850,8 @@ function createEditorTextDrag(deps) {
|
|
|
47024
47850
|
setCaretViewport(hit.caretViewport ?? null);
|
|
47025
47851
|
};
|
|
47026
47852
|
const handleWindowMouseUp = (event) => {
|
|
47027
|
-
var
|
|
47028
|
-
(
|
|
47853
|
+
var _a2, _b2, _c;
|
|
47854
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.info("text-drag:mouseup", {
|
|
47029
47855
|
x: event.clientX,
|
|
47030
47856
|
y: event.clientY,
|
|
47031
47857
|
dragging: dragging(),
|
|
@@ -47046,7 +47872,7 @@ function createEditorTextDrag(deps) {
|
|
|
47046
47872
|
mergeKey: copy ? MERGE_KEYS.copyTextByDrag : MERGE_KEYS.moveTextByDrag
|
|
47047
47873
|
}
|
|
47048
47874
|
);
|
|
47049
|
-
(
|
|
47875
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.info("text-drag:apply", {
|
|
47050
47876
|
mode: copy ? "copy" : "move",
|
|
47051
47877
|
destination: `${destination.paragraphId}:${destination.runId}[${destination.offset}]`
|
|
47052
47878
|
});
|
|
@@ -47072,9 +47898,9 @@ function createEditorTextDrag(deps) {
|
|
|
47072
47898
|
deps.focusInputAfterPointerSelection();
|
|
47073
47899
|
};
|
|
47074
47900
|
const tryStartTextDrag = (event, hit) => {
|
|
47075
|
-
var
|
|
47901
|
+
var _a2, _b2, _c;
|
|
47076
47902
|
if (deps.isReadOnly() || !(hit == null ? void 0 : hit.resolvedFromParagraph)) {
|
|
47077
|
-
(
|
|
47903
|
+
(_a2 = deps.logger) == null ? void 0 : _a2.debug("text-drag:skip-start", {
|
|
47078
47904
|
reason: deps.isReadOnly() ? "readonly" : "no-hit",
|
|
47079
47905
|
x: event.clientX,
|
|
47080
47906
|
y: event.clientY
|
|
@@ -47083,7 +47909,7 @@ function createEditorTextDrag(deps) {
|
|
|
47083
47909
|
}
|
|
47084
47910
|
const current = deps.state();
|
|
47085
47911
|
if (!isPositionInsideSelection(current, hit.position)) {
|
|
47086
|
-
(
|
|
47912
|
+
(_b2 = deps.logger) == null ? void 0 : _b2.debug("text-drag:skip-start", {
|
|
47087
47913
|
reason: "outside-selection",
|
|
47088
47914
|
x: event.clientX,
|
|
47089
47915
|
y: event.clientY,
|
|
@@ -47219,7 +48045,7 @@ function createEditorNavigation(deps) {
|
|
|
47219
48045
|
return moveVerticalSelection(direction, false);
|
|
47220
48046
|
};
|
|
47221
48047
|
const moveVerticalSelection = (direction, extend) => {
|
|
47222
|
-
var
|
|
48048
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
47223
48049
|
const state = deps.state();
|
|
47224
48050
|
const paragraphs = getParagraphs(state);
|
|
47225
48051
|
const currentIndex = paragraphs.findIndex(
|
|
@@ -47236,7 +48062,7 @@ function createEditorNavigation(deps) {
|
|
|
47236
48062
|
surface: surfaceRef,
|
|
47237
48063
|
state,
|
|
47238
48064
|
documentLayout: deps.documentLayout(),
|
|
47239
|
-
zoomFactor: (
|
|
48065
|
+
zoomFactor: (_a2 = deps.zoomFactor) == null ? void 0 : _a2.call(deps)
|
|
47240
48066
|
}) : null;
|
|
47241
48067
|
let targetIndex = currentIndex + direction;
|
|
47242
48068
|
const tableLocation = findParagraphTableLocation(
|
|
@@ -47268,17 +48094,17 @@ function createEditorNavigation(deps) {
|
|
|
47268
48094
|
continue;
|
|
47269
48095
|
}
|
|
47270
48096
|
const scoredCandidates = rowCandidates.map((entry) => {
|
|
47271
|
-
var
|
|
47272
|
-
const paragraphId = (
|
|
47273
|
-
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(
|
|
47274
48100
|
(paragraph) => paragraph.paragraphId === paragraphId && paragraph.tableCell && paragraph.tableCell.tableId === block.id
|
|
47275
|
-
)) == null ? void 0 :
|
|
48101
|
+
)) == null ? void 0 : _b3.tableCell : null;
|
|
47276
48102
|
const left = (cellRect == null ? void 0 : cellRect.left) ?? desiredX;
|
|
47277
48103
|
const right = cellRect ? cellRect.left + cellRect.width : desiredX;
|
|
47278
48104
|
const distance = desiredX < left ? left - desiredX : desiredX > right ? desiredX - right : 0;
|
|
47279
48105
|
return { entry, distance };
|
|
47280
48106
|
}).sort((left, right) => left.distance - right.distance);
|
|
47281
|
-
const candidate = (
|
|
48107
|
+
const candidate = (_b2 = scoredCandidates[0]) == null ? void 0 : _b2.entry;
|
|
47282
48108
|
if (!candidate) {
|
|
47283
48109
|
continue;
|
|
47284
48110
|
}
|
|
@@ -47345,12 +48171,12 @@ function createEditorNavigation(deps) {
|
|
|
47345
48171
|
function createEditorRevisionController(deps) {
|
|
47346
48172
|
const [hoveredRevision, setHoveredRevision] = createSignal(null);
|
|
47347
48173
|
const handleRevisionMouseEnter = (revisionId, event) => {
|
|
47348
|
-
var
|
|
48174
|
+
var _a2, _b2, _c;
|
|
47349
48175
|
const paragraphs = getParagraphs(deps.state());
|
|
47350
48176
|
let foundRevision;
|
|
47351
48177
|
for (const p of paragraphs) {
|
|
47352
48178
|
for (const run of p.runs) {
|
|
47353
|
-
if (((
|
|
48179
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId) {
|
|
47354
48180
|
foundRevision = run.revision;
|
|
47355
48181
|
break;
|
|
47356
48182
|
}
|
|
@@ -47358,10 +48184,10 @@ function createEditorRevisionController(deps) {
|
|
|
47358
48184
|
if (foundRevision) break;
|
|
47359
48185
|
}
|
|
47360
48186
|
const findInBlocks = (blocks) => {
|
|
47361
|
-
var
|
|
48187
|
+
var _a3, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
47362
48188
|
for (const block of blocks) {
|
|
47363
48189
|
if (block.type === "paragraph") continue;
|
|
47364
|
-
if (((
|
|
48190
|
+
if (((_b3 = (_a3 = block.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b3.id) === revisionId) {
|
|
47365
48191
|
return block.style.revision;
|
|
47366
48192
|
}
|
|
47367
48193
|
if (((_c2 = block.gridRevision) == null ? void 0 : _c2.id) === revisionId) return block.gridRevision;
|
|
@@ -47404,7 +48230,7 @@ function createEditorRevisionController(deps) {
|
|
|
47404
48230
|
}
|
|
47405
48231
|
if (!foundRevision) return;
|
|
47406
48232
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
47407
|
-
const surfaceRect = (
|
|
48233
|
+
const surfaceRect = (_b2 = deps.surfaceRef()) == null ? void 0 : _b2.getBoundingClientRect();
|
|
47408
48234
|
if (!surfaceRect) return;
|
|
47409
48235
|
const z = ((_c = deps.zoomFactor) == null ? void 0 : _c.call(deps)) ?? 1;
|
|
47410
48236
|
setHoveredRevision({
|
|
@@ -47586,8 +48412,8 @@ function createEditorInteractionRuntime(deps) {
|
|
|
47586
48412
|
logger
|
|
47587
48413
|
});
|
|
47588
48414
|
const resolvePositionAtSurfacePoint = (clientX, clientY) => {
|
|
47589
|
-
var
|
|
47590
|
-
return ((
|
|
48415
|
+
var _a2;
|
|
48416
|
+
return ((_a2 = resolveSurfaceHitAtPoint(clientX, clientY)) == null ? void 0 : _a2.position) ?? null;
|
|
47591
48417
|
};
|
|
47592
48418
|
const imageOps = createEditorImageOperations({
|
|
47593
48419
|
state,
|
|
@@ -47685,10 +48511,10 @@ function ensureFootnotes(footnotes) {
|
|
|
47685
48511
|
return { items: {} };
|
|
47686
48512
|
}
|
|
47687
48513
|
function nextAutoMarker(document2) {
|
|
47688
|
-
var
|
|
48514
|
+
var _a2, _b2;
|
|
47689
48515
|
const footnotes = document2.footnotes;
|
|
47690
|
-
const format = ((
|
|
47691
|
-
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;
|
|
47692
48518
|
let autoCount = startAt - 1;
|
|
47693
48519
|
const seen = /* @__PURE__ */ new Set();
|
|
47694
48520
|
for (const { run } of iterateFootnoteReferenceRuns(document2)) {
|
|
@@ -47763,10 +48589,10 @@ function toggleTrackChanges(state) {
|
|
|
47763
48589
|
}
|
|
47764
48590
|
function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
47765
48591
|
return blocks.flatMap((block) => {
|
|
47766
|
-
var
|
|
48592
|
+
var _a2;
|
|
47767
48593
|
if (block.type === "paragraph") return [block];
|
|
47768
48594
|
let style2 = block.style;
|
|
47769
|
-
if (((
|
|
48595
|
+
if (((_a2 = style2 == null ? void 0 : style2.revision) == null ? void 0 : _a2.id) === revisionId) {
|
|
47770
48596
|
if (accept) {
|
|
47771
48597
|
const { revision: _revision, ...current } = style2;
|
|
47772
48598
|
style2 = current;
|
|
@@ -47810,8 +48636,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
|
47810
48636
|
}
|
|
47811
48637
|
}
|
|
47812
48638
|
const rows = sourceRows.flatMap((row) => {
|
|
47813
|
-
var
|
|
47814
|
-
if (((
|
|
48639
|
+
var _a3, _b2, _c, _d;
|
|
48640
|
+
if (((_b2 = (_a3 = row.style) == null ? void 0 : _a3.revision) == null ? void 0 : _b2.id) === revisionId) {
|
|
47815
48641
|
const remove = accept && row.style.revision.type === "delete" || !accept && row.style.revision.type === "insert";
|
|
47816
48642
|
if (remove) return [];
|
|
47817
48643
|
}
|
|
@@ -47832,8 +48658,8 @@ function transformTableRevisionBlocks(blocks, revisionId, accept) {
|
|
|
47832
48658
|
rowStyle = current;
|
|
47833
48659
|
}
|
|
47834
48660
|
const cells = row.cells.flatMap((cell) => {
|
|
47835
|
-
var
|
|
47836
|
-
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) {
|
|
47837
48663
|
const remove = accept && cell.style.revision.type === "delete" || !accept && cell.style.revision.type === "insert";
|
|
47838
48664
|
if (remove) return [];
|
|
47839
48665
|
}
|
|
@@ -47908,12 +48734,12 @@ function acceptRevision(state, revisionId) {
|
|
|
47908
48734
|
const nextParagraphs = paragraphs.map((paragraph) => {
|
|
47909
48735
|
const nextRuns = paragraph.runs.filter(
|
|
47910
48736
|
(run) => {
|
|
47911
|
-
var
|
|
47912
|
-
return !(((
|
|
48737
|
+
var _a2;
|
|
48738
|
+
return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete");
|
|
47913
48739
|
}
|
|
47914
48740
|
).map((run) => {
|
|
47915
|
-
var
|
|
47916
|
-
if (((
|
|
48741
|
+
var _a2;
|
|
48742
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert") {
|
|
47917
48743
|
const nextRun = { ...run };
|
|
47918
48744
|
delete nextRun.revision;
|
|
47919
48745
|
return nextRun;
|
|
@@ -47940,12 +48766,12 @@ function rejectRevision(state, revisionId) {
|
|
|
47940
48766
|
const nextParagraphs = paragraphs.map((paragraph) => {
|
|
47941
48767
|
const nextRuns = paragraph.runs.filter(
|
|
47942
48768
|
(run) => {
|
|
47943
|
-
var
|
|
47944
|
-
return !(((
|
|
48769
|
+
var _a2;
|
|
48770
|
+
return !(((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "insert");
|
|
47945
48771
|
}
|
|
47946
48772
|
).map((run) => {
|
|
47947
|
-
var
|
|
47948
|
-
if (((
|
|
48773
|
+
var _a2;
|
|
48774
|
+
if (((_a2 = run.revision) == null ? void 0 : _a2.id) === revisionId && run.revision.type === "delete") {
|
|
47949
48775
|
const nextRun = { ...run };
|
|
47950
48776
|
delete nextRun.revision;
|
|
47951
48777
|
return nextRun;
|
|
@@ -47968,7 +48794,7 @@ function rejectRevision(state, revisionId) {
|
|
|
47968
48794
|
return transformTableRevision(textState, revisionId, false);
|
|
47969
48795
|
}
|
|
47970
48796
|
function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
47971
|
-
var
|
|
48797
|
+
var _a2, _b2, _c, _d, _e;
|
|
47972
48798
|
for (const block of blocks) {
|
|
47973
48799
|
if (block.type === "paragraph") continue;
|
|
47974
48800
|
const tableSelected = block.rows.some(
|
|
@@ -47977,7 +48803,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
47977
48803
|
)
|
|
47978
48804
|
);
|
|
47979
48805
|
if (tableSelected) {
|
|
47980
|
-
if ((
|
|
48806
|
+
if ((_a2 = block.style) == null ? void 0 : _a2.revision) revisionIds.add(block.style.revision.id);
|
|
47981
48807
|
if (block.gridRevision) revisionIds.add(block.gridRevision.id);
|
|
47982
48808
|
}
|
|
47983
48809
|
for (const row of block.rows) {
|
|
@@ -47985,7 +48811,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
47985
48811
|
(cell) => cell.blocks.some((paragraph) => selectedParagraphIds.has(paragraph.id))
|
|
47986
48812
|
);
|
|
47987
48813
|
if (selectedCells.length > 0) {
|
|
47988
|
-
if ((
|
|
48814
|
+
if ((_b2 = row.style) == null ? void 0 : _b2.revision) revisionIds.add(row.style.revision.id);
|
|
47989
48815
|
if ((_c = row.style) == null ? void 0 : _c.propertyRevision) {
|
|
47990
48816
|
revisionIds.add(row.style.propertyRevision.id);
|
|
47991
48817
|
}
|
|
@@ -48001,7 +48827,7 @@ function collectTableRevisionIds(blocks, selectedParagraphIds, revisionIds) {
|
|
|
48001
48827
|
}
|
|
48002
48828
|
}
|
|
48003
48829
|
function acceptRevisionsInSelection(state) {
|
|
48004
|
-
var
|
|
48830
|
+
var _a2;
|
|
48005
48831
|
const normalized = normalizeSelection(state);
|
|
48006
48832
|
const paragraphs = getParagraphs(state);
|
|
48007
48833
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
@@ -48011,7 +48837,7 @@ function acceptRevisionsInSelection(state) {
|
|
|
48011
48837
|
const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
48012
48838
|
const runs = sliceRuns(paragraph, startOffset, endOffset);
|
|
48013
48839
|
for (const run of runs) {
|
|
48014
|
-
if ((
|
|
48840
|
+
if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
|
|
48015
48841
|
revisionIds.add(run.revision.id);
|
|
48016
48842
|
}
|
|
48017
48843
|
}
|
|
@@ -48041,7 +48867,7 @@ function acceptRevisionsInSelection(state) {
|
|
|
48041
48867
|
return nextState;
|
|
48042
48868
|
}
|
|
48043
48869
|
function rejectRevisionsInSelection(state) {
|
|
48044
|
-
var
|
|
48870
|
+
var _a2;
|
|
48045
48871
|
const normalized = normalizeSelection(state);
|
|
48046
48872
|
const paragraphs = getParagraphs(state);
|
|
48047
48873
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
@@ -48051,7 +48877,7 @@ function rejectRevisionsInSelection(state) {
|
|
|
48051
48877
|
const endOffset = i === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
48052
48878
|
const runs = sliceRuns(paragraph, startOffset, endOffset);
|
|
48053
48879
|
for (const run of runs) {
|
|
48054
|
-
if ((
|
|
48880
|
+
if ((_a2 = run.revision) == null ? void 0 : _a2.id) {
|
|
48055
48881
|
revisionIds.add(run.revision.id);
|
|
48056
48882
|
}
|
|
48057
48883
|
}
|
|
@@ -48081,7 +48907,7 @@ function rejectRevisionsInSelection(state) {
|
|
|
48081
48907
|
return nextState;
|
|
48082
48908
|
}
|
|
48083
48909
|
function getLinkAtSelection(state) {
|
|
48084
|
-
var
|
|
48910
|
+
var _a2, _b2, _c;
|
|
48085
48911
|
const normalized = normalizeSelection(state);
|
|
48086
48912
|
const paragraphs = getParagraphs(state);
|
|
48087
48913
|
if (normalized.isCollapsed) {
|
|
@@ -48089,7 +48915,7 @@ function getLinkAtSelection(state) {
|
|
|
48089
48915
|
if (!paragraph) {
|
|
48090
48916
|
return null;
|
|
48091
48917
|
}
|
|
48092
|
-
return ((
|
|
48918
|
+
return ((_a2 = expandLinkRangeInParagraph(paragraph, normalized.startParagraphOffset)) == null ? void 0 : _a2.href) ?? null;
|
|
48093
48919
|
}
|
|
48094
48920
|
const touchedRuns = paragraphs.slice(normalized.startIndex, normalized.endIndex + 1).flatMap((paragraph, relativeIndex) => {
|
|
48095
48921
|
const paragraphIndex = normalized.startIndex + relativeIndex;
|
|
@@ -48100,13 +48926,13 @@ function getLinkAtSelection(state) {
|
|
|
48100
48926
|
if (touchedRuns.length === 0) {
|
|
48101
48927
|
return null;
|
|
48102
48928
|
}
|
|
48103
|
-
const href = (_c = (
|
|
48929
|
+
const href = (_c = (_b2 = touchedRuns[0]) == null ? void 0 : _b2.styles) == null ? void 0 : _c.link;
|
|
48104
48930
|
if (!href) {
|
|
48105
48931
|
return null;
|
|
48106
48932
|
}
|
|
48107
48933
|
return touchedRuns.every((run) => {
|
|
48108
|
-
var
|
|
48109
|
-
return ((
|
|
48934
|
+
var _a3;
|
|
48935
|
+
return ((_a3 = run.styles) == null ? void 0 : _a3.link) === href;
|
|
48110
48936
|
}) ? href : null;
|
|
48111
48937
|
}
|
|
48112
48938
|
function setLinkAtSelection(state, href) {
|
|
@@ -48244,11 +49070,11 @@ function toggleParagraphList(state, kind) {
|
|
|
48244
49070
|
const endIndex = normalized.endIndex;
|
|
48245
49071
|
const targetedParagraphs = paragraphs.slice(startIndex, endIndex + 1);
|
|
48246
49072
|
const shouldClear = targetedParagraphs.length > 0 && targetedParagraphs.every((paragraph) => {
|
|
48247
|
-
var
|
|
48248
|
-
return ((
|
|
49073
|
+
var _a2;
|
|
49074
|
+
return ((_a2 = paragraph.list) == null ? void 0 : _a2.kind) === kind;
|
|
48249
49075
|
});
|
|
48250
49076
|
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
48251
|
-
var
|
|
49077
|
+
var _a2, _b2, _c;
|
|
48252
49078
|
if (paragraphIndex < startIndex || paragraphIndex > endIndex) {
|
|
48253
49079
|
return cloneParagraph(paragraph);
|
|
48254
49080
|
}
|
|
@@ -48259,8 +49085,8 @@ function toggleParagraphList(state, kind) {
|
|
|
48259
49085
|
}
|
|
48260
49086
|
nextParagraph.list = {
|
|
48261
49087
|
kind,
|
|
48262
|
-
level: ((
|
|
48263
|
-
format: (
|
|
49088
|
+
level: ((_a2 = paragraph.list) == null ? void 0 : _a2.level) ?? 0,
|
|
49089
|
+
format: (_b2 = paragraph.list) == null ? void 0 : _b2.format,
|
|
48264
49090
|
startAt: (_c = paragraph.list) == null ? void 0 : _c.startAt
|
|
48265
49091
|
};
|
|
48266
49092
|
return nextParagraph;
|
|
@@ -48618,12 +49444,12 @@ function createEditorCommandsController(deps) {
|
|
|
48618
49444
|
focusInput();
|
|
48619
49445
|
};
|
|
48620
49446
|
const promptForImageAlt = () => {
|
|
48621
|
-
var
|
|
49447
|
+
var _a2;
|
|
48622
49448
|
const run = selectedImageRun();
|
|
48623
49449
|
if (!run) {
|
|
48624
49450
|
return;
|
|
48625
49451
|
}
|
|
48626
|
-
const currentAlt = ((
|
|
49452
|
+
const currentAlt = ((_a2 = getRunImage(run.run)) == null ? void 0 : _a2.alt) ?? "";
|
|
48627
49453
|
deps.openImageAltDialog(currentAlt);
|
|
48628
49454
|
};
|
|
48629
49455
|
const applyImageCaptionCommand = (caption) => {
|
|
@@ -48719,13 +49545,13 @@ class EditorCommandRegistry {
|
|
|
48719
49545
|
return Array.from(this.bindings.values());
|
|
48720
49546
|
}
|
|
48721
49547
|
execute(event, deps, commandExecutor) {
|
|
48722
|
-
var
|
|
49548
|
+
var _a2;
|
|
48723
49549
|
const isCtrlOrMeta = event.ctrlKey || event.metaKey;
|
|
48724
49550
|
const lowerKey = event.key.toLowerCase();
|
|
48725
49551
|
for (const binding of this.bindings.values()) {
|
|
48726
49552
|
if (binding.key.toLowerCase() === lowerKey && Boolean(binding.ctrlOrMeta) === isCtrlOrMeta && Boolean(binding.shift) === event.shiftKey && Boolean(binding.alt) === event.altKey) {
|
|
48727
49553
|
if (binding.command && commandExecutor) {
|
|
48728
|
-
const canExecute = ((
|
|
49554
|
+
const canExecute = ((_a2 = commandExecutor.canExecuteCommand) == null ? void 0 : _a2.call(commandExecutor, binding.command)) ?? true;
|
|
48729
49555
|
if (canExecute) {
|
|
48730
49556
|
commandExecutor.executeCommand(binding.command);
|
|
48731
49557
|
event.preventDefault();
|
|
@@ -48994,12 +49820,12 @@ function createEditorKeyboardController(deps) {
|
|
|
48994
49820
|
}
|
|
48995
49821
|
const commandExecutor = deps.executeCommand ? {
|
|
48996
49822
|
executeCommand: (commandName, payload) => {
|
|
48997
|
-
var
|
|
48998
|
-
return (
|
|
49823
|
+
var _a2;
|
|
49824
|
+
return (_a2 = deps.executeCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
|
|
48999
49825
|
},
|
|
49000
49826
|
canExecuteCommand: (commandName, payload) => {
|
|
49001
|
-
var
|
|
49002
|
-
return (
|
|
49827
|
+
var _a2;
|
|
49828
|
+
return (_a2 = deps.canExecuteCommand) == null ? void 0 : _a2.call(deps, commandName, payload);
|
|
49003
49829
|
}
|
|
49004
49830
|
} : void 0;
|
|
49005
49831
|
if (registry.execute(event, deps, commandExecutor)) {
|
|
@@ -49411,10 +50237,10 @@ const DEFAULT_TOC_MAX_LEVEL = 3;
|
|
|
49411
50237
|
const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
|
|
49412
50238
|
const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
|
|
49413
50239
|
function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
49414
|
-
var
|
|
50240
|
+
var _a2;
|
|
49415
50241
|
const headings = [];
|
|
49416
50242
|
for (const paragraph of getDocumentParagraphs(state.document)) {
|
|
49417
|
-
const level = getHeadingLevel((
|
|
50243
|
+
const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
|
|
49418
50244
|
if (level === null || level > maxLevel) continue;
|
|
49419
50245
|
const text = getParagraphText(paragraph).trim();
|
|
49420
50246
|
if (!text) continue;
|
|
@@ -50266,18 +51092,18 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50266
51092
|
};
|
|
50267
51093
|
const essentialsDocument = {
|
|
50268
51094
|
documentStyles: () => {
|
|
50269
|
-
var
|
|
51095
|
+
var _a2, _b2;
|
|
50270
51096
|
const document2 = options.state().document;
|
|
50271
51097
|
const styles = (document2 == null ? void 0 : document2.styles) ?? {};
|
|
50272
51098
|
const usedStyleIds = /* @__PURE__ */ new Set();
|
|
50273
51099
|
for (const paragraph of getDocumentParagraphs(document2)) {
|
|
50274
|
-
if ((
|
|
51100
|
+
if ((_a2 = paragraph.style) == null ? void 0 : _a2.styleId) usedStyleIds.add(paragraph.style.styleId);
|
|
50275
51101
|
for (const run of paragraph.runs) {
|
|
50276
|
-
if ((
|
|
51102
|
+
if ((_b2 = run.styles) == null ? void 0 : _b2.styleId) usedStyleIds.add(run.styles.styleId);
|
|
50277
51103
|
}
|
|
50278
51104
|
}
|
|
50279
51105
|
return Object.values(styles).map((style2) => {
|
|
50280
|
-
var
|
|
51106
|
+
var _a3;
|
|
50281
51107
|
const preview = resolveNamedTextStyle(style2.id, styles);
|
|
50282
51108
|
return {
|
|
50283
51109
|
id: style2.id,
|
|
@@ -50288,7 +51114,7 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50288
51114
|
semiHidden: style2.semiHidden,
|
|
50289
51115
|
unhideWhenUsed: style2.unhideWhenUsed,
|
|
50290
51116
|
isUsed: usedStyleIds.has(style2.id),
|
|
50291
|
-
fontFamily: ((
|
|
51117
|
+
fontFamily: ((_a3 = preview.fontFamily) == null ? void 0 : _a3.trim()) || void 0,
|
|
50292
51118
|
fontSize: typeof preview.fontSize === "number" ? preview.fontSize : void 0,
|
|
50293
51119
|
color: preview.color ?? void 0,
|
|
50294
51120
|
bold: preview.bold ?? void 0,
|
|
@@ -50299,12 +51125,12 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50299
51125
|
exportDocx: () => void options.docIO.handleExportDocx(),
|
|
50300
51126
|
exportPdf: () => void options.docIO.handleExportPdf(),
|
|
50301
51127
|
importDocument: () => {
|
|
50302
|
-
var
|
|
50303
|
-
return (
|
|
51128
|
+
var _a2;
|
|
51129
|
+
return (_a2 = options.importInputRef()) == null ? void 0 : _a2.click();
|
|
50304
51130
|
},
|
|
50305
51131
|
insertImage: () => {
|
|
50306
|
-
var
|
|
50307
|
-
return (
|
|
51132
|
+
var _a2;
|
|
51133
|
+
return (_a2 = options.imageInputRef()) == null ? void 0 : _a2.click();
|
|
50308
51134
|
},
|
|
50309
51135
|
insertShape: (preset) => options.applyTransactionalState(
|
|
50310
51136
|
(current) => insertShapeAtSelection(current, preset)
|
|
@@ -50402,15 +51228,15 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50402
51228
|
};
|
|
50403
51229
|
const essentialsSection = {
|
|
50404
51230
|
isLandscape: () => {
|
|
50405
|
-
var
|
|
51231
|
+
var _a2, _b2;
|
|
50406
51232
|
const idx = getActiveSectionIndex(options.state());
|
|
50407
|
-
const section = ((
|
|
50408
|
-
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";
|
|
50409
51235
|
},
|
|
50410
51236
|
setOrientation: (orientation) => {
|
|
50411
|
-
var
|
|
51237
|
+
var _a2;
|
|
50412
51238
|
const idx = getActiveSectionIndex(options.state());
|
|
50413
|
-
const section = ((
|
|
51239
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
50414
51240
|
if (!section) return;
|
|
50415
51241
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
50416
51242
|
pageSettings: {
|
|
@@ -50420,11 +51246,11 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50420
51246
|
});
|
|
50421
51247
|
},
|
|
50422
51248
|
toggleOrientation: () => {
|
|
50423
|
-
var
|
|
51249
|
+
var _a2, _b2;
|
|
50424
51250
|
const idx = getActiveSectionIndex(options.state());
|
|
50425
|
-
const section = ((
|
|
51251
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
50426
51252
|
if (!section) return;
|
|
50427
|
-
const current = ((
|
|
51253
|
+
const current = ((_b2 = section.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
|
|
50428
51254
|
essentialsSection.setOrientation(
|
|
50429
51255
|
current === "portrait" ? "landscape" : "portrait"
|
|
50430
51256
|
);
|
|
@@ -50432,15 +51258,15 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
50432
51258
|
breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
|
|
50433
51259
|
breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
|
|
50434
51260
|
getMargins: () => {
|
|
50435
|
-
var
|
|
51261
|
+
var _a2, _b2;
|
|
50436
51262
|
const idx = getActiveSectionIndex(options.state());
|
|
50437
|
-
const section = ((
|
|
50438
|
-
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;
|
|
50439
51265
|
},
|
|
50440
51266
|
setPageMargins: (margins) => {
|
|
50441
|
-
var
|
|
51267
|
+
var _a2;
|
|
50442
51268
|
const idx = getActiveSectionIndex(options.state());
|
|
50443
|
-
const section = ((
|
|
51269
|
+
const section = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
50444
51270
|
if (!(section == null ? void 0 : section.pageSettings)) return;
|
|
50445
51271
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
50446
51272
|
pageSettings: {
|
|
@@ -50939,7 +51765,7 @@ const defaultMenuItems = [
|
|
|
50939
51765
|
}
|
|
50940
51766
|
];
|
|
50941
51767
|
function useEditorRuntimePlugins(options) {
|
|
50942
|
-
var
|
|
51768
|
+
var _a2, _b2;
|
|
50943
51769
|
const runtimePlugins = [
|
|
50944
51770
|
options.essentialsPlugin,
|
|
50945
51771
|
...options.externalPlugins ?? []
|
|
@@ -50983,8 +51809,8 @@ function useEditorRuntimePlugins(options) {
|
|
|
50983
51809
|
contributedMenuIds.push(item.id);
|
|
50984
51810
|
}
|
|
50985
51811
|
}
|
|
50986
|
-
(
|
|
50987
|
-
(
|
|
51812
|
+
(_a2 = options.customizeToolbar) == null ? void 0 : _a2.call(options, toolbarRegistry);
|
|
51813
|
+
(_b2 = options.customizeMenubar) == null ? void 0 : _b2.call(options, menuRegistry);
|
|
50988
51814
|
return {
|
|
50989
51815
|
runtimePlugins,
|
|
50990
51816
|
toolbarRegistry,
|
|
@@ -51008,13 +51834,13 @@ function createRuntimeCommandHost(options) {
|
|
|
51008
51834
|
);
|
|
51009
51835
|
let disposed = false;
|
|
51010
51836
|
const commandStateOf = (commandRef) => {
|
|
51011
|
-
var
|
|
51837
|
+
var _a2;
|
|
51012
51838
|
const commandName = commandRefName(commandRef);
|
|
51013
51839
|
const cmd = runtimeEditor().commands.get(commandName);
|
|
51014
51840
|
if (!cmd) {
|
|
51015
51841
|
return { isEnabled: false, isActive: false, value: void 0 };
|
|
51016
51842
|
}
|
|
51017
|
-
const refreshed = ((
|
|
51843
|
+
const refreshed = ((_a2 = cmd.refresh) == null ? void 0 : _a2.call(cmd)) ?? { isEnabled: true };
|
|
51018
51844
|
return {
|
|
51019
51845
|
isEnabled: refreshed.isEnabled !== false,
|
|
51020
51846
|
isActive: Boolean(refreshed.isActive),
|
|
@@ -51042,7 +51868,7 @@ function createRuntimeCommandHost(options) {
|
|
|
51042
51868
|
focusEditor: options.focusEditor
|
|
51043
51869
|
});
|
|
51044
51870
|
const initialize = async () => {
|
|
51045
|
-
var
|
|
51871
|
+
var _a2, _b2;
|
|
51046
51872
|
try {
|
|
51047
51873
|
const initializedRuntimeEditor = await Editor.create({
|
|
51048
51874
|
doc: options.initialDocument,
|
|
@@ -51057,14 +51883,14 @@ function createRuntimeCommandHost(options) {
|
|
|
51057
51883
|
await previousRuntimeEditor.destroy();
|
|
51058
51884
|
setRuntimeReady(true);
|
|
51059
51885
|
requestAnimationFrame(() => {
|
|
51060
|
-
var
|
|
51061
|
-
(
|
|
51062
|
-
(
|
|
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);
|
|
51063
51889
|
});
|
|
51064
51890
|
} catch (error) {
|
|
51065
51891
|
options.logger.error("runtime:init failed", error);
|
|
51066
|
-
(
|
|
51067
|
-
(
|
|
51892
|
+
(_a2 = options.onError) == null ? void 0 : _a2.call(options, error);
|
|
51893
|
+
(_b2 = options.onSettled) == null ? void 0 : _b2.call(options);
|
|
51068
51894
|
}
|
|
51069
51895
|
};
|
|
51070
51896
|
const dispose = async () => {
|
|
@@ -51180,9 +52006,9 @@ function createEditorCommandRuntime(deps) {
|
|
|
51180
52006
|
focusEditor: deps.focusInput,
|
|
51181
52007
|
logger: deps.logger,
|
|
51182
52008
|
onReady: (editor) => {
|
|
51183
|
-
var
|
|
52009
|
+
var _a2, _b2;
|
|
51184
52010
|
runtimeClient.resolveReady(editor);
|
|
51185
|
-
(
|
|
52011
|
+
(_b2 = (_a2 = deps.runtimeOptions()).onReady) == null ? void 0 : _b2.call(_a2, runtimeClient);
|
|
51186
52012
|
},
|
|
51187
52013
|
onSettled: () => {
|
|
51188
52014
|
deps.setInitialLoading(false);
|
|
@@ -51243,8 +52069,8 @@ function createEditorCommandRuntime(deps) {
|
|
|
51243
52069
|
}
|
|
51244
52070
|
var _tmpl$ = /* @__PURE__ */ template(`<div class="oasis-editor-shell oasis-editor-app">`);
|
|
51245
52071
|
function OasisEditorApp(props = {}) {
|
|
51246
|
-
var
|
|
51247
|
-
const runtimeClient = ((
|
|
52072
|
+
var _a2;
|
|
52073
|
+
const runtimeClient = ((_a2 = props.runtime) == null ? void 0 : _a2.client) ?? createOasisEditorClient();
|
|
51248
52074
|
const ui = () => props.ui ?? {};
|
|
51249
52075
|
const documentOptions = () => props.document ?? {};
|
|
51250
52076
|
const runtimeOptions = () => props.runtime ?? {};
|
|
@@ -51659,12 +52485,12 @@ function OasisEditorApp(props = {}) {
|
|
|
51659
52485
|
return loadingLabel();
|
|
51660
52486
|
},
|
|
51661
52487
|
get ["class"]() {
|
|
51662
|
-
var
|
|
51663
|
-
return (
|
|
52488
|
+
var _a3;
|
|
52489
|
+
return (_a3 = loadingOptions()) == null ? void 0 : _a3.class;
|
|
51664
52490
|
},
|
|
51665
52491
|
get style() {
|
|
51666
|
-
var
|
|
51667
|
-
return (
|
|
52492
|
+
var _a3;
|
|
52493
|
+
return (_a3 = loadingOptions()) == null ? void 0 : _a3.style;
|
|
51668
52494
|
}
|
|
51669
52495
|
});
|
|
51670
52496
|
}
|