@univerjs/engine-render 1.0.2 → 1.0.4
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/lib/cjs/index.js +224 -53
- package/lib/es/index.js +224 -53
- package/lib/index.js +224 -53
- package/lib/types/basics/i-document-skeleton-cached.d.ts +6 -2
- package/lib/types/basics/interfaces.d.ts +2 -2
- package/lib/types/components/docs/document.d.ts +2 -3
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +3 -0
- package/lib/types/components/docs/layout/document-layout-publication.d.ts +2 -2
- package/lib/types/components/docs/layout/document-layout-types.d.ts +2 -0
- package/lib/types/components/docs/layout/header-footer-field.d.ts +18 -0
- package/lib/types/components/docs/layout/tools.d.ts +10 -1
- package/lib/types/worker-layout.d.ts +1 -0
- package/lib/umd/index.js +4 -4
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -5696,7 +5696,7 @@ var Border = class extends SheetExtension {
|
|
|
5696
5696
|
let startX = cellStartX;
|
|
5697
5697
|
let endX = cellEndX;
|
|
5698
5698
|
if (type !== "t" && type !== "b" && type !== "l" && type !== "r") {
|
|
5699
|
-
if (isMerged)
|
|
5699
|
+
if (isMerged) continue;
|
|
5700
5700
|
if (isMergedMainCell) {
|
|
5701
5701
|
startY = mergeInfo.startY;
|
|
5702
5702
|
endY = mergeInfo.endY;
|
|
@@ -13912,6 +13912,26 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13912
13912
|
}
|
|
13913
13913
|
};
|
|
13914
13914
|
|
|
13915
|
+
//#endregion
|
|
13916
|
+
//#region src/components/docs/layout/header-footer-field.ts
|
|
13917
|
+
function resolveHeaderFooterFieldGlyph(glyph, startIndex, endIndex, customRanges, pageNumber, pageCount) {
|
|
13918
|
+
var _fieldRange$propertie, _fieldRange$propertie2;
|
|
13919
|
+
if (!glyph.content || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END) return glyph;
|
|
13920
|
+
const fieldRange = customRanges.find((customRange) => {
|
|
13921
|
+
var _customRange$properti;
|
|
13922
|
+
return customRange.rangeType === _univerjs_core.CustomRangeType.FIELD && customRange.startIndex <= startIndex && customRange.endIndex >= endIndex && typeof ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.fieldType) === "string";
|
|
13923
|
+
});
|
|
13924
|
+
const fieldType = fieldRange === null || fieldRange === void 0 || (_fieldRange$propertie = fieldRange.properties) === null || _fieldRange$propertie === void 0 || (_fieldRange$propertie = _fieldRange$propertie.fieldType) === null || _fieldRange$propertie === void 0 ? void 0 : _fieldRange$propertie.toUpperCase();
|
|
13925
|
+
if (!fieldRange || ((_fieldRange$propertie2 = fieldRange.properties) === null || _fieldRange$propertie2 === void 0 ? void 0 : _fieldRange$propertie2.locked) === _univerjs_core.BooleanNumber.TRUE || fieldType !== "PAGE" && fieldType !== "NUMPAGES") return glyph;
|
|
13926
|
+
if (fieldType === "NUMPAGES" && pageCount == null) return glyph;
|
|
13927
|
+
let content = "";
|
|
13928
|
+
if (startIndex === fieldRange.startIndex + 1) content = String(fieldType === "PAGE" ? pageNumber : pageCount);
|
|
13929
|
+
return content === glyph.content ? glyph : {
|
|
13930
|
+
...glyph,
|
|
13931
|
+
content
|
|
13932
|
+
};
|
|
13933
|
+
}
|
|
13934
|
+
|
|
13915
13935
|
//#endregion
|
|
13916
13936
|
//#region src/components/docs/layout/line-breaker/enhancers/utils.ts
|
|
13917
13937
|
/**
|
|
@@ -17050,27 +17070,75 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
17050
17070
|
let header;
|
|
17051
17071
|
let footer;
|
|
17052
17072
|
if (headerId) {
|
|
17053
|
-
var _skeHeaders$get;
|
|
17054
|
-
|
|
17073
|
+
var _headerTreeMap$get, _skeHeaders$get;
|
|
17074
|
+
const fieldRanges = headerTreeMap === null || headerTreeMap === void 0 || (_headerTreeMap$get = headerTreeMap.get(headerId)) === null || _headerTreeMap$get === void 0 || (_headerTreeMap$get = _headerTreeMap$get.getBody()) === null || _headerTreeMap$get === void 0 ? void 0 : _headerTreeMap$get.customRanges;
|
|
17075
|
+
const dynamic = fieldRanges === null || fieldRanges === void 0 ? void 0 : fieldRanges.some((range) => {
|
|
17076
|
+
var _range$properties, _range$properties2, _range$properties3;
|
|
17077
|
+
return range.rangeType === _univerjs_core.CustomRangeType.FIELD && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.locked) !== _univerjs_core.BooleanNumber.TRUE && (((_range$properties2 = range.properties) === null || _range$properties2 === void 0 ? void 0 : _range$properties2.fieldType) === "PAGE" || ((_range$properties3 = range.properties) === null || _range$properties3 === void 0 ? void 0 : _range$properties3.fieldType) === "NUMPAGES");
|
|
17078
|
+
});
|
|
17079
|
+
const key = dynamic ? JSON.stringify([
|
|
17080
|
+
sectionId,
|
|
17081
|
+
pageNumber,
|
|
17082
|
+
pageWidth,
|
|
17083
|
+
marginLeft,
|
|
17084
|
+
marginRight,
|
|
17085
|
+
ctx.hasNumPagesFields ? ctx.fieldPageCount : void 0
|
|
17086
|
+
]) : pageWidth;
|
|
17087
|
+
if (typeof key === "string") page.headerLayoutKey = key;
|
|
17088
|
+
if ((_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.has(key)) {
|
|
17055
17089
|
var _skeHeaders$get2;
|
|
17056
|
-
header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(
|
|
17090
|
+
header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(key);
|
|
17057
17091
|
} else if (headerTreeMap && headerTreeMap.has(headerId)) {
|
|
17058
|
-
|
|
17092
|
+
const previousFieldContext = ctx.headerFooterFieldContext;
|
|
17093
|
+
ctx.headerFooterFieldContext = dynamic ? {
|
|
17094
|
+
pageNumber,
|
|
17095
|
+
pageCount: ctx.fieldPageCount
|
|
17096
|
+
} : void 0;
|
|
17097
|
+
try {
|
|
17098
|
+
header = _createSkeletonHeaderFooter(ctx, headerTreeMap.get(headerId), sectionBreakConfig, skeletonResourceReference, headerId, true);
|
|
17099
|
+
header.fieldsResolved = Boolean(dynamic);
|
|
17100
|
+
} finally {
|
|
17101
|
+
ctx.headerFooterFieldContext = previousFieldContext;
|
|
17102
|
+
}
|
|
17059
17103
|
const widths = skeHeaders.get(headerId) ?? /* @__PURE__ */ new Map();
|
|
17060
|
-
widths.set(
|
|
17104
|
+
widths.set(key, header);
|
|
17061
17105
|
skeHeaders.set(headerId, widths);
|
|
17062
17106
|
}
|
|
17063
17107
|
page.headerId = headerId;
|
|
17064
17108
|
}
|
|
17065
17109
|
if (footerId) {
|
|
17066
|
-
var _skeFooters$get;
|
|
17067
|
-
|
|
17110
|
+
var _footerTreeMap$get, _skeFooters$get;
|
|
17111
|
+
const fieldRanges = footerTreeMap === null || footerTreeMap === void 0 || (_footerTreeMap$get = footerTreeMap.get(footerId)) === null || _footerTreeMap$get === void 0 || (_footerTreeMap$get = _footerTreeMap$get.getBody()) === null || _footerTreeMap$get === void 0 ? void 0 : _footerTreeMap$get.customRanges;
|
|
17112
|
+
const dynamic = fieldRanges === null || fieldRanges === void 0 ? void 0 : fieldRanges.some((range) => {
|
|
17113
|
+
var _range$properties4, _range$properties5, _range$properties6;
|
|
17114
|
+
return range.rangeType === _univerjs_core.CustomRangeType.FIELD && ((_range$properties4 = range.properties) === null || _range$properties4 === void 0 ? void 0 : _range$properties4.locked) !== _univerjs_core.BooleanNumber.TRUE && (((_range$properties5 = range.properties) === null || _range$properties5 === void 0 ? void 0 : _range$properties5.fieldType) === "PAGE" || ((_range$properties6 = range.properties) === null || _range$properties6 === void 0 ? void 0 : _range$properties6.fieldType) === "NUMPAGES");
|
|
17115
|
+
});
|
|
17116
|
+
const key = dynamic ? JSON.stringify([
|
|
17117
|
+
sectionId,
|
|
17118
|
+
pageNumber,
|
|
17119
|
+
pageWidth,
|
|
17120
|
+
marginLeft,
|
|
17121
|
+
marginRight,
|
|
17122
|
+
ctx.hasNumPagesFields ? ctx.fieldPageCount : void 0
|
|
17123
|
+
]) : pageWidth;
|
|
17124
|
+
if (typeof key === "string") page.footerLayoutKey = key;
|
|
17125
|
+
if ((_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.has(key)) {
|
|
17068
17126
|
var _skeFooters$get2;
|
|
17069
|
-
footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(
|
|
17127
|
+
footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(key);
|
|
17070
17128
|
} else if (footerTreeMap && footerTreeMap.has(footerId)) {
|
|
17071
|
-
|
|
17129
|
+
const previousFieldContext = ctx.headerFooterFieldContext;
|
|
17130
|
+
ctx.headerFooterFieldContext = dynamic ? {
|
|
17131
|
+
pageNumber,
|
|
17132
|
+
pageCount: ctx.fieldPageCount
|
|
17133
|
+
} : void 0;
|
|
17134
|
+
try {
|
|
17135
|
+
footer = _createSkeletonHeaderFooter(ctx, footerTreeMap.get(footerId), sectionBreakConfig, skeletonResourceReference, footerId, false);
|
|
17136
|
+
footer.fieldsResolved = Boolean(dynamic);
|
|
17137
|
+
} finally {
|
|
17138
|
+
ctx.headerFooterFieldContext = previousFieldContext;
|
|
17139
|
+
}
|
|
17072
17140
|
const widths = skeFooters.get(footerId) ?? /* @__PURE__ */ new Map();
|
|
17073
|
-
widths.set(
|
|
17141
|
+
widths.set(key, footer);
|
|
17074
17142
|
skeFooters.set(footerId, widths);
|
|
17075
17143
|
}
|
|
17076
17144
|
page.footerId = footerId;
|
|
@@ -17079,6 +17147,29 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
17079
17147
|
page.originMarginBottom = marginBottom;
|
|
17080
17148
|
page.marginTop = _getVerticalMargin(marginTop, header);
|
|
17081
17149
|
page.marginBottom = _getVerticalMargin(marginBottom, footer);
|
|
17150
|
+
if (ctx.headerFooterMinimumMargins) for (const [id, layoutKey, margin] of [[
|
|
17151
|
+
headerId,
|
|
17152
|
+
page.headerLayoutKey,
|
|
17153
|
+
"marginTop"
|
|
17154
|
+
], [
|
|
17155
|
+
footerId,
|
|
17156
|
+
page.footerLayoutKey,
|
|
17157
|
+
"marginBottom"
|
|
17158
|
+
]]) {
|
|
17159
|
+
if (layoutKey == null) continue;
|
|
17160
|
+
const key = JSON.stringify([
|
|
17161
|
+
id,
|
|
17162
|
+
sectionId,
|
|
17163
|
+
pageNumber,
|
|
17164
|
+
pageWidth,
|
|
17165
|
+
marginLeft,
|
|
17166
|
+
marginRight,
|
|
17167
|
+
margin
|
|
17168
|
+
]);
|
|
17169
|
+
const maximum = Math.max(page[margin], ctx.headerFooterMinimumMargins.get(key) ?? 0);
|
|
17170
|
+
ctx.headerFooterMinimumMargins.set(key, maximum);
|
|
17171
|
+
if (ctx.fieldCountCycle) page[margin] = maximum;
|
|
17172
|
+
}
|
|
17082
17173
|
const sections = page.sections;
|
|
17083
17174
|
const lastSection = sections[sections.length - 1];
|
|
17084
17175
|
const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
|
|
@@ -18278,8 +18369,8 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18278
18369
|
const initialFootnoteTop = lastPage.type === 4 && lastPage.pageNumber === 1 && columnInfo.index === ((_ctx$footnoteFirstCol = ctx.footnoteFirstColumn) === null || _ctx$footnoteFirstCol === void 0 ? void 0 : _ctx$footnoteFirstCol.index) ? ctx.footnoteFirstColumn.top : 0;
|
|
18279
18370
|
const lineTop = preLineHeight + ((preLine === null || preLine === void 0 ? void 0 : preLine.top) ?? initialFootnoteTop);
|
|
18280
18371
|
const { pageWidth, headerId, footerId } = lastPage;
|
|
18281
|
-
const headerPage = skeHeaders === null || skeHeaders === void 0 || (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
18282
|
-
const footerPage = skeFooters === null || skeFooters === void 0 || (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
18372
|
+
const headerPage = skeHeaders === null || skeHeaders === void 0 || (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(lastPage.headerLayoutKey ?? pageWidth);
|
|
18373
|
+
const footerPage = skeFooters === null || skeFooters === void 0 || (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(lastPage.footerLayoutKey ?? pageWidth);
|
|
18283
18374
|
let needOpenNewPageByTableLayout = false;
|
|
18284
18375
|
const { deferredInlineGroupAnchorDrawings, deferredTopBottomAnchorDrawings } = _positionLineDrawings(ctx, glyphGroup, column, lastPage, paragraphConfig, lineTop, lineHeight, paragraphAnchorLeft, hasInlineCustomBlock, isParagraphFirstShapedText);
|
|
18285
18376
|
if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
|
|
@@ -19485,7 +19576,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
19485
19576
|
unitId
|
|
19486
19577
|
});
|
|
19487
19578
|
const rootPageDocumentLeft = docsLeft + rootPage.marginLeft;
|
|
19488
|
-
const headerPage = rootPage.headerId == null ? void 0 : skeHeaders === null || skeHeaders === void 0 || (_skeHeaders$get = skeHeaders.get(rootPage.headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(rootPage.pageWidth);
|
|
19579
|
+
const headerPage = rootPage.headerId == null ? void 0 : skeHeaders === null || skeHeaders === void 0 || (_skeHeaders$get = skeHeaders.get(rootPage.headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(rootPage.headerLayoutKey ?? rootPage.pageWidth);
|
|
19489
19580
|
if (headerPage != null) collectPageTables({
|
|
19490
19581
|
contexts,
|
|
19491
19582
|
docsLeft,
|
|
@@ -19500,7 +19591,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
19500
19591
|
tableCellInsetX,
|
|
19501
19592
|
unitId
|
|
19502
19593
|
});
|
|
19503
|
-
const footerPage = rootPage.footerId == null ? void 0 : skeFooters === null || skeFooters === void 0 || (_skeFooters$get = skeFooters.get(rootPage.footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(rootPage.pageWidth);
|
|
19594
|
+
const footerPage = rootPage.footerId == null ? void 0 : skeFooters === null || skeFooters === void 0 || (_skeFooters$get = skeFooters.get(rootPage.footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(rootPage.footerLayoutKey ?? rootPage.pageWidth);
|
|
19504
19595
|
if (footerPage != null) collectPageTables({
|
|
19505
19596
|
contexts,
|
|
19506
19597
|
docsLeft,
|
|
@@ -21096,6 +21187,26 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
21096
21187
|
for (const glyph of shapedGlyphs) if (isCjkLeftAlignedPunctuation(glyph.content) || isCjkRightAlignedPunctuation(glyph.content) || isCjkCenterAlignedPunctuation(glyph.content)) glyph.adjustability.shrinkability = [0, 0];
|
|
21097
21188
|
}
|
|
21098
21189
|
if (((_sectionBreakConfig$r5 = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r5 === void 0 ? void 0 : _sectionBreakConfig$r5.preservePunctuationSpacing) !== _univerjs_core.BooleanNumber.TRUE && (!traditionalLayout || fixedPunctuationPairs)) punctuationSpaceAdjustment(shapedGlyphs, fixedPunctuationPairs);
|
|
21190
|
+
if (ctx.headerFooterFieldContext) {
|
|
21191
|
+
let index = paragraphNode.contentStartIndex + last;
|
|
21192
|
+
for (let glyphIndex = 0; glyphIndex < shapedGlyphs.length; glyphIndex++) {
|
|
21193
|
+
var _viewModel$getBody3, _glyph$fontStyle, _glyph$ts2;
|
|
21194
|
+
const glyph = shapedGlyphs[glyphIndex];
|
|
21195
|
+
const resolved = resolveHeaderFooterFieldGlyph(glyph, index, index + glyph.count - 1, ((_viewModel$getBody3 = viewModel.getBody()) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.customRanges) ?? [], ctx.headerFooterFieldContext.pageNumber, ctx.headerFooterFieldContext.pageCount);
|
|
21196
|
+
index += glyph.count;
|
|
21197
|
+
if (resolved === glyph) continue;
|
|
21198
|
+
const font = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.fontString;
|
|
21199
|
+
const widthDelta = resolved.content && font ? (FontCache.getMeasureText(resolved.content, font).width - FontCache.getMeasureText(glyph.content, font).width) * getTextHorizontalScale((_glyph$ts2 = glyph.ts) === null || _glyph$ts2 === void 0 ? void 0 : _glyph$ts2.sa) : -glyph.width;
|
|
21200
|
+
shapedGlyphs[glyphIndex] = {
|
|
21201
|
+
...resolved,
|
|
21202
|
+
width: Math.max(0, glyph.width + widthDelta),
|
|
21203
|
+
bBox: {
|
|
21204
|
+
...glyph.bBox,
|
|
21205
|
+
width: Math.max(0, glyph.bBox.width + widthDelta)
|
|
21206
|
+
}
|
|
21207
|
+
};
|
|
21208
|
+
}
|
|
21209
|
+
}
|
|
21099
21210
|
appendShapedText(shapedTextList, shapedGlyphs, bk.type, paragraphStyle.fixedTabStops === _univerjs_core.BooleanNumber.TRUE);
|
|
21100
21211
|
last = bk.position;
|
|
21101
21212
|
}
|
|
@@ -23203,6 +23314,8 @@ function serializePaginatedContinuationCheckpoint(page) {
|
|
|
23203
23314
|
sectionId: page.sectionId,
|
|
23204
23315
|
headerId: page.headerId,
|
|
23205
23316
|
footerId: page.footerId,
|
|
23317
|
+
headerLayoutKey: page.headerLayoutKey,
|
|
23318
|
+
footerLayoutKey: page.footerLayoutKey,
|
|
23206
23319
|
pageWidth: page.pageWidth,
|
|
23207
23320
|
pageHeight: page.pageHeight,
|
|
23208
23321
|
pageOrient: page.pageOrient,
|
|
@@ -23279,7 +23392,7 @@ function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
|
|
|
23279
23392
|
const rootPage = skeletonData.pages[segmentPageIndex];
|
|
23280
23393
|
if (rootPage == null) return null;
|
|
23281
23394
|
const { headerId, footerId, pageWidth } = rootPage;
|
|
23282
|
-
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(pageWidth)];
|
|
23395
|
+
const segmentPages = [headerId == null ? null : (_skeletonData$skeHead = skeletonData.skeHeaders.get(headerId)) === null || _skeletonData$skeHead === void 0 ? void 0 : _skeletonData$skeHead.get(rootPage.headerLayoutKey ?? pageWidth), footerId == null ? null : (_skeletonData$skeFoot = skeletonData.skeFooters.get(footerId)) === null || _skeletonData$skeFoot === void 0 ? void 0 : _skeletonData$skeFoot.get(rootPage.footerLayoutKey ?? pageWidth)];
|
|
23283
23396
|
for (const segmentPage of segmentPages) {
|
|
23284
23397
|
if (segmentPage == null) continue;
|
|
23285
23398
|
const page = getPageFromPath({
|
|
@@ -23310,6 +23423,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23310
23423
|
_defineProperty(this, "_languageDetector", LanguageDetector.getInstance());
|
|
23311
23424
|
_defineProperty(this, "_initialWidth", 0);
|
|
23312
23425
|
_defineProperty(this, "_paginationMetrics", null);
|
|
23426
|
+
_defineProperty(this, "_completedPageCount", void 0);
|
|
23313
23427
|
_defineProperty(this, "_lastCompleteSkeletonData", null);
|
|
23314
23428
|
_defineProperty(this, "_pendingInvalidationAnchor", null);
|
|
23315
23429
|
_defineProperty(this, "_layoutGeneration", 0);
|
|
@@ -23334,6 +23448,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23334
23448
|
this._layoutPageMaterialized$.complete();
|
|
23335
23449
|
this._skeletonData = null;
|
|
23336
23450
|
this._lastCompleteSkeletonData = null;
|
|
23451
|
+
this._completedPageCount = void 0;
|
|
23337
23452
|
this._pendingInvalidationAnchor = null;
|
|
23338
23453
|
this._externalLayoutProgress = null;
|
|
23339
23454
|
this._externalProtectedPages = null;
|
|
@@ -23351,14 +23466,21 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23351
23466
|
* PS: This method has significant impact on performance.
|
|
23352
23467
|
*/
|
|
23353
23468
|
calculate(bounds) {
|
|
23469
|
+
var _this$_skeletonData;
|
|
23354
23470
|
if (!this.dirty) return;
|
|
23355
23471
|
this.cancelIncrementalLayout();
|
|
23356
23472
|
this._externalLayoutProgress = null;
|
|
23357
23473
|
this._externalProtectedPages = null;
|
|
23358
23474
|
this._externalProtectedContinuousLayout = null;
|
|
23359
|
-
|
|
23360
|
-
|
|
23475
|
+
let ctx = this._prepareLayoutContext();
|
|
23476
|
+
while (true) {
|
|
23477
|
+
this._skeletonData = this._createSkeleton(ctx, bounds);
|
|
23478
|
+
const retry = this._prepareFieldCountRetry(ctx);
|
|
23479
|
+
if (retry == null) break;
|
|
23480
|
+
ctx = retry;
|
|
23481
|
+
}
|
|
23361
23482
|
this._lastCompleteSkeletonData = this._skeletonData;
|
|
23483
|
+
this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
|
|
23362
23484
|
this._pendingInvalidationAnchor = null;
|
|
23363
23485
|
this._paginationMetrics = ctx.paginationMetrics ?? null;
|
|
23364
23486
|
this._dirty$.next(true);
|
|
@@ -23432,6 +23554,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23432
23554
|
lastPublishedBlockCount: incrementalStart.processedBlockCount,
|
|
23433
23555
|
publicationRevision: 0,
|
|
23434
23556
|
reuseUnaffectedTail: (options === null || options === void 0 ? void 0 : options.reuseUnaffectedTail) !== false,
|
|
23557
|
+
paginationRevision: 0,
|
|
23435
23558
|
allowMetadataOnlyStructuralTailReuse: (options === null || options === void 0 ? void 0 : options.allowMetadataOnlyStructuralTailReuse) === true,
|
|
23436
23559
|
reusedTail: false,
|
|
23437
23560
|
tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
|
|
@@ -23478,7 +23601,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23478
23601
|
const hasEarlierOverlappingRange = anchorPageIndex > 0 && previousSkeleton.pages.slice(0, anchorPageIndex).some((page) => previousAnchor >= page.st && previousAnchor <= page.ed);
|
|
23479
23602
|
const anchorBlockOwnsTable = blocks[anchorBlockIndex].block.children.some((child) => child.nodeType === _univerjs_core.DataStreamTreeNodeType.TABLE && anchor >= child.startIndex && anchor <= child.endIndex);
|
|
23480
23603
|
const canResumePlainParagraph = blocks[anchorBlockIndex].block.nodeType === _univerjs_core.DataStreamTreeNodeType.PARAGRAPH && blocks[anchorBlockIndex].block.children.length === 0;
|
|
23481
|
-
if (mode === "paginated" && reuseInteractionPagePrefix && canResumePlainParagraph && !((_previousSkeleton$pag = previousSkeleton.pages[anchorPageIndex]) === null || _previousSkeleton$pag === void 0 || (_previousSkeleton$pag = _previousSkeleton$pag.notes) === null || _previousSkeleton$pag === void 0 ? void 0 : _previousSkeleton$pag.length)) {
|
|
23604
|
+
if (mode === "paginated" && reuseInteractionPagePrefix && invalidation != null && canResumePlainParagraph && !((_previousSkeleton$pag = previousSkeleton.pages[anchorPageIndex]) === null || _previousSkeleton$pag === void 0 || (_previousSkeleton$pag = _previousSkeleton$pag.notes) === null || _previousSkeleton$pag === void 0 ? void 0 : _previousSkeleton$pag.length)) {
|
|
23482
23605
|
const interactionPreviousAnchor = mapCurrentOffsetToPrevious(anchor, invalidation);
|
|
23483
23606
|
const interactionPageIndex = interactionSkeleton == null ? -1 : this._findBodyPageIndex(interactionSkeleton.pages, interactionPreviousAnchor);
|
|
23484
23607
|
const paginatedPrefix = this._preparePaginatedParagraphPrefix(ctx, interactionSkeleton ?? previousSkeleton, blocks[anchorBlockIndex], anchorBlockIndex, interactionPageIndex, invalidation);
|
|
@@ -23808,11 +23931,13 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23808
23931
|
const publishedPageCount = state.mode === "continuous" ? pageCount : state.complete ? state.reusedTail ? pageCount : shouldPublishPriority ? Math.max(state.lastPublishedPageCount, priorityPublishedPageCount) : Math.min(pageCount, state.lastPublishedPageCount + 1) : shouldPublishPriority ? Math.max(state.lastPublishedPageCount, priorityPublishedPageCount) : Math.min(stableComputedPageCount, state.lastPublishedPageCount + 1);
|
|
23809
23932
|
let didPublish = false;
|
|
23810
23933
|
let didPublishAnchor = false;
|
|
23811
|
-
if (!state.cancelled && canPublish && (!suppressPreAnchorPublication || shouldPublishPriority || state.complete)) {
|
|
23934
|
+
if (!state.cancelled && canPublish && (state.ctx.fieldCountCandidates == null || state.complete) && (!suppressPreAnchorPublication || shouldPublishPriority || state.complete)) {
|
|
23812
23935
|
if (state.mode === "paginated") this._finalizePaginatedPagesForPublication(state, publishedPageCount);
|
|
23813
23936
|
const isFinalPublication = state.complete && publishedPageCount >= pageCount;
|
|
23814
23937
|
if (isFinalPublication) {
|
|
23938
|
+
var _state$ctx$skeleton;
|
|
23815
23939
|
this._lastCompleteSkeletonData = state.ctx.skeleton;
|
|
23940
|
+
this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
|
|
23816
23941
|
this._pendingInvalidationAnchor = null;
|
|
23817
23942
|
}
|
|
23818
23943
|
this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
|
|
@@ -23954,9 +24079,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23954
24079
|
* page or block range while the external executor publishes a newer tail.
|
|
23955
24080
|
*/
|
|
23956
24081
|
beginExternalLayout(options) {
|
|
23957
|
-
var _this$
|
|
24082
|
+
var _this$_skeletonData2;
|
|
23958
24083
|
this.cancelIncrementalLayout();
|
|
23959
|
-
const pages = ((_this$
|
|
24084
|
+
const pages = ((_this$_skeletonData2 = this._skeletonData) === null || _this$_skeletonData2 === void 0 ? void 0 : _this$_skeletonData2.pages) ?? [];
|
|
23960
24085
|
const protectedRange = options.protectedRange;
|
|
23961
24086
|
const protectedPageRange = (protectedRange === null || protectedRange === void 0 ? void 0 : protectedRange.mode) === "paginated" ? protectedRange : void 0;
|
|
23962
24087
|
if (protectedPageRange == null) this._externalProtectedPages = null;
|
|
@@ -24113,6 +24238,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24113
24238
|
if (progress.complete) {
|
|
24114
24239
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24115
24240
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24241
|
+
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24116
24242
|
this._pendingInvalidationAnchor = null;
|
|
24117
24243
|
this._externalProtectedContinuousLayout = null;
|
|
24118
24244
|
}
|
|
@@ -24182,6 +24308,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24182
24308
|
if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
|
|
24183
24309
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24184
24310
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24311
|
+
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24185
24312
|
this._pendingInvalidationAnchor = null;
|
|
24186
24313
|
this._externalProtectedPages = null;
|
|
24187
24314
|
this._externalProtectedContinuousLayout = null;
|
|
@@ -24391,8 +24518,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24391
24518
|
};
|
|
24392
24519
|
}
|
|
24393
24520
|
findBodyPageIndexByCharIndex(charIndex) {
|
|
24394
|
-
var _this$
|
|
24395
|
-
return this._findBodyPageIndex(((_this$
|
|
24521
|
+
var _this$_skeletonData3;
|
|
24522
|
+
return this._findBodyPageIndex(((_this$_skeletonData3 = this._skeletonData) === null || _this$_skeletonData3 === void 0 ? void 0 : _this$_skeletonData3.pages) ?? [], charIndex);
|
|
24396
24523
|
}
|
|
24397
24524
|
findNodeByCharIndex(charIndex, segmentId = "", segmentPageIndex = -1) {
|
|
24398
24525
|
const nodes = this._findNodeByIndex(charIndex, segmentId, segmentPageIndex);
|
|
@@ -24411,12 +24538,12 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24411
24538
|
const { headerId, footerId, pageWidth } = skePage;
|
|
24412
24539
|
if (pageType === 1) {
|
|
24413
24540
|
var _skeHeaders$get;
|
|
24414
|
-
const skeHeader = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
24541
|
+
const skeHeader = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(skePage.headerLayoutKey ?? pageWidth);
|
|
24415
24542
|
if (skeHeader == null) return;
|
|
24416
24543
|
else skePage = skeHeader;
|
|
24417
24544
|
} else if (pageType === 2) {
|
|
24418
24545
|
var _skeFooters$get;
|
|
24419
|
-
const skeFooter = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
24546
|
+
const skeFooter = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(skePage.footerLayoutKey ?? pageWidth);
|
|
24420
24547
|
if (skeFooter == null) return;
|
|
24421
24548
|
else skePage = skeFooter;
|
|
24422
24549
|
}
|
|
@@ -24524,9 +24651,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24524
24651
|
let exactMatch = null;
|
|
24525
24652
|
if (editArea === "HEADER" || editArea === "FOOTER") {
|
|
24526
24653
|
var _skeHeaders$get2, _skeFooters$get2;
|
|
24527
|
-
const headerSke = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(pageWidth);
|
|
24654
|
+
const headerSke = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(page.headerLayoutKey ?? pageWidth);
|
|
24528
24655
|
if (headerSke) exactMatch = this._collectNearestNode(headerSke, 1, page, headerId, pi, cache, x, y, pageLength);
|
|
24529
|
-
const footerSke = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(pageWidth);
|
|
24656
|
+
const footerSke = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(page.footerLayoutKey ?? pageWidth);
|
|
24530
24657
|
if (footerSke) exactMatch = exactMatch ?? this._collectNearestNode(footerSke, 2, page, footerId, pi, cache, x, y, pageLength);
|
|
24531
24658
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24532
24659
|
if (exactMatch) return exactMatch;
|
|
@@ -24548,9 +24675,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24548
24675
|
const { headerId, footerId, pageWidth } = page;
|
|
24549
24676
|
if (segmentId !== "" && !this._docViewModel.getNoteTreeMap().has(segmentId)) {
|
|
24550
24677
|
var _skeHeaders$get3, _skeFooters$get3;
|
|
24551
|
-
const headerSke = (_skeHeaders$get3 = skeHeaders.get(headerId)) === null || _skeHeaders$get3 === void 0 ? void 0 : _skeHeaders$get3.get(pageWidth);
|
|
24678
|
+
const headerSke = (_skeHeaders$get3 = skeHeaders.get(headerId)) === null || _skeHeaders$get3 === void 0 ? void 0 : _skeHeaders$get3.get(page.headerLayoutKey ?? pageWidth);
|
|
24552
24679
|
if (headerSke) exactMatch = this._collectNearestNode(headerSke, 1, page, headerId, pi, cache, x, y, pageLength);
|
|
24553
|
-
const footerSke = (_skeFooters$get3 = skeFooters.get(footerId)) === null || _skeFooters$get3 === void 0 ? void 0 : _skeFooters$get3.get(pageWidth);
|
|
24680
|
+
const footerSke = (_skeFooters$get3 = skeFooters.get(footerId)) === null || _skeFooters$get3 === void 0 ? void 0 : _skeFooters$get3.get(page.footerLayoutKey ?? pageWidth);
|
|
24554
24681
|
if (footerSke) exactMatch = exactMatch ?? this._collectNearestNode(footerSke, 2, page, footerId, pi, cache, x, y, pageLength);
|
|
24555
24682
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24556
24683
|
if (exactMatch) return exactMatch;
|
|
@@ -24565,7 +24692,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24565
24692
|
continue;
|
|
24566
24693
|
}
|
|
24567
24694
|
const { headerId, pageWidth } = page;
|
|
24568
|
-
const segmentSke = segmentId === headerId ? (_skeHeaders$get4 = skeHeaders.get(segmentId)) === null || _skeHeaders$get4 === void 0 ? void 0 : _skeHeaders$get4.get(pageWidth) : (_skeFooters$get4 = skeFooters.get(segmentId)) === null || _skeFooters$get4 === void 0 ? void 0 : _skeFooters$get4.get(pageWidth);
|
|
24695
|
+
const segmentSke = segmentId === headerId ? (_skeHeaders$get4 = skeHeaders.get(segmentId)) === null || _skeHeaders$get4 === void 0 ? void 0 : _skeHeaders$get4.get(page.headerLayoutKey ?? pageWidth) : (_skeFooters$get4 = skeFooters.get(segmentId)) === null || _skeFooters$get4 === void 0 ? void 0 : _skeFooters$get4.get(page.footerLayoutKey ?? pageWidth);
|
|
24569
24696
|
if (segmentSke) exactMatch = this._collectNearestNode(segmentSke, segmentId === headerId ? 1 : 2, page, segmentId, segmentPage, cache, x, y, pageLength);
|
|
24570
24697
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24571
24698
|
if (exactMatch) return exactMatch;
|
|
@@ -24892,6 +25019,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24892
25019
|
return {
|
|
24893
25020
|
generation: state.generation,
|
|
24894
25021
|
publicationRevision: state.publicationRevision,
|
|
25022
|
+
paginationRevision: state.paginationRevision,
|
|
24895
25023
|
didPublish,
|
|
24896
25024
|
didPublishAnchor,
|
|
24897
25025
|
publishedPageCount: state.lastPublishedPageCount,
|
|
@@ -25411,10 +25539,52 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25411
25539
|
}
|
|
25412
25540
|
for (const hSkeMap of skeleton.skeHeaders.values()) for (const page of hSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
|
|
25413
25541
|
for (const fSkeMap of skeleton.skeFooters.values()) for (const page of fSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
|
|
25542
|
+
const retry = this._prepareFieldCountRetry(ctx);
|
|
25543
|
+
if (retry != null) {
|
|
25544
|
+
state.paginationRevision++;
|
|
25545
|
+
state.ctx = retry;
|
|
25546
|
+
state.sectionIndex = 0;
|
|
25547
|
+
state.paragraphIndex = 0;
|
|
25548
|
+
state.sectionInitialized = false;
|
|
25549
|
+
state.sectionBreakConfig = null;
|
|
25550
|
+
state.layoutAnchor = null;
|
|
25551
|
+
state.laidOutThrough = -1;
|
|
25552
|
+
state.stableLaidOutThrough = -1;
|
|
25553
|
+
state.processedBlockCount = 0;
|
|
25554
|
+
state.pendingTableBuild = null;
|
|
25555
|
+
state.pendingSlicedTableBuild = null;
|
|
25556
|
+
state.pendingParagraphCheckpoint = null;
|
|
25557
|
+
state.stablePageCount = 0;
|
|
25558
|
+
state.finalizedPageCount = 0;
|
|
25559
|
+
state.lastPublishedPageCount = 0;
|
|
25560
|
+
state.lastPublishedBlockCount = 0;
|
|
25561
|
+
state.anchorPublished = false;
|
|
25562
|
+
state.reuseUnaffectedTail = false;
|
|
25563
|
+
state.reusedTail = false;
|
|
25564
|
+
state.tailConvergencePageCount = 0;
|
|
25565
|
+
state.interactionPageTail = null;
|
|
25566
|
+
state.interactionPageComplete = false;
|
|
25567
|
+
state.interactionWindowComplete = false;
|
|
25568
|
+
state.interactionWindowResume = null;
|
|
25569
|
+
return;
|
|
25570
|
+
}
|
|
25414
25571
|
setPageParent(skeleton.pages, skeleton);
|
|
25415
25572
|
state.complete = true;
|
|
25416
25573
|
state.stableLaidOutThrough = state.laidOutThrough;
|
|
25417
25574
|
}
|
|
25575
|
+
getCompletedPageCount() {
|
|
25576
|
+
return this._completedPageCount;
|
|
25577
|
+
}
|
|
25578
|
+
_prepareFieldCountRetry(ctx) {
|
|
25579
|
+
if (!ctx.hasNumPagesFields || ctx.fieldPageCount === ctx.skeleton.pages.length) return null;
|
|
25580
|
+
const retry = this._prepareLayoutContext();
|
|
25581
|
+
retry.fieldPageCount = ctx.skeleton.pages.length;
|
|
25582
|
+
retry.headerFooterMinimumMargins = ctx.headerFooterMinimumMargins;
|
|
25583
|
+
retry.fieldCountCandidates = ctx.fieldCountCandidates ?? /* @__PURE__ */ new Set();
|
|
25584
|
+
if (ctx.fieldPageCount != null) retry.fieldCountCandidates.add(ctx.fieldPageCount);
|
|
25585
|
+
retry.fieldCountCycle = ctx.fieldCountCycle || retry.fieldCountCandidates.has(retry.fieldPageCount);
|
|
25586
|
+
return retry;
|
|
25587
|
+
}
|
|
25418
25588
|
_prepareLayoutContext() {
|
|
25419
25589
|
var _ctx$noteReferences;
|
|
25420
25590
|
const viewModel = this.getViewModel();
|
|
@@ -25446,7 +25616,17 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25446
25616
|
skeListLevel,
|
|
25447
25617
|
drawingAnchor
|
|
25448
25618
|
};
|
|
25619
|
+
const hasNumPagesFields = [...headerTreeMap.values(), ...footerTreeMap.values()].some((story) => {
|
|
25620
|
+
var _story$getBody;
|
|
25621
|
+
return (_story$getBody = story.getBody()) === null || _story$getBody === void 0 || (_story$getBody = _story$getBody.customRanges) === null || _story$getBody === void 0 ? void 0 : _story$getBody.some((range) => {
|
|
25622
|
+
var _range$properties;
|
|
25623
|
+
return range.rangeType === _univerjs_core.CustomRangeType.FIELD && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.fieldType) === "NUMPAGES" && range.properties.locked !== _univerjs_core.BooleanNumber.TRUE;
|
|
25624
|
+
});
|
|
25625
|
+
});
|
|
25449
25626
|
const ctx = {
|
|
25627
|
+
fieldPageCount: this.getCompletedPageCount(),
|
|
25628
|
+
hasNumPagesFields,
|
|
25629
|
+
headerFooterMinimumMargins: hasNumPagesFields ? /* @__PURE__ */ new Map() : void 0,
|
|
25450
25630
|
viewModel,
|
|
25451
25631
|
dataModel,
|
|
25452
25632
|
noteReferences: documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL ? resolveNoteReferences(dataModel.getSnapshot()) : void 0,
|
|
@@ -25642,8 +25822,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25642
25822
|
let segmentPage = page;
|
|
25643
25823
|
if (segmentId) {
|
|
25644
25824
|
var _skeHeaders$get5, _skeFooters$get5, _page$notes3;
|
|
25645
|
-
const maybeHeaderSke = (_skeHeaders$get5 = skeHeaders.get(segmentId)) === null || _skeHeaders$get5 === void 0 ? void 0 : _skeHeaders$get5.get(pageWidth);
|
|
25646
|
-
const maybeFooterSke = (_skeFooters$get5 = skeFooters.get(segmentId)) === null || _skeFooters$get5 === void 0 ? void 0 : _skeFooters$get5.get(pageWidth);
|
|
25825
|
+
const maybeHeaderSke = (_skeHeaders$get5 = skeHeaders.get(segmentId)) === null || _skeHeaders$get5 === void 0 ? void 0 : _skeHeaders$get5.get(page.headerLayoutKey ?? pageWidth);
|
|
25826
|
+
const maybeFooterSke = (_skeFooters$get5 = skeFooters.get(segmentId)) === null || _skeFooters$get5 === void 0 ? void 0 : _skeFooters$get5.get(page.footerLayoutKey ?? pageWidth);
|
|
25647
25827
|
const note = (_page$notes3 = page.notes) === null || _page$notes3 === void 0 ? void 0 : _page$notes3.find((fragment) => fragment.noteId === segmentId && fragment.page.st <= charIndex && charIndex <= fragment.page.ed);
|
|
25648
25828
|
if (note) segmentPage = note.page;
|
|
25649
25829
|
else if (maybeHeaderSke) segmentPage = maybeHeaderSke;
|
|
@@ -28781,22 +28961,6 @@ function getVisibleContinuousLineRange(lines, viewportTop, viewportBottom, flowT
|
|
|
28781
28961
|
end: low
|
|
28782
28962
|
};
|
|
28783
28963
|
}
|
|
28784
|
-
function resolveHeaderFooterFieldGlyph(glyph, startIndex, endIndex, customRanges, pageNumber, pageCount) {
|
|
28785
|
-
var _fieldRange$propertie;
|
|
28786
|
-
if (!glyph.content || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END) return glyph;
|
|
28787
|
-
const fieldRange = customRanges.find((customRange) => {
|
|
28788
|
-
var _customRange$properti;
|
|
28789
|
-
return customRange.startIndex <= startIndex && customRange.endIndex >= endIndex && typeof ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.fieldType) === "string";
|
|
28790
|
-
});
|
|
28791
|
-
const fieldType = fieldRange === null || fieldRange === void 0 || (_fieldRange$propertie = fieldRange.properties) === null || _fieldRange$propertie === void 0 || (_fieldRange$propertie = _fieldRange$propertie.fieldType) === null || _fieldRange$propertie === void 0 ? void 0 : _fieldRange$propertie.toUpperCase();
|
|
28792
|
-
if (!fieldRange || fieldType !== "PAGE" && fieldType !== "NUMPAGES") return glyph;
|
|
28793
|
-
let content = "";
|
|
28794
|
-
if (startIndex === fieldRange.startIndex + 1) content = String(fieldType === "PAGE" ? pageNumber : pageCount);
|
|
28795
|
-
return content === glyph.content ? glyph : {
|
|
28796
|
-
...glyph,
|
|
28797
|
-
content
|
|
28798
|
-
};
|
|
28799
|
-
}
|
|
28800
28964
|
function resolveHeaderFooterFieldGlyphGroup(divide, context) {
|
|
28801
28965
|
var _context$viewModel;
|
|
28802
28966
|
const { glyphGroup } = divide;
|
|
@@ -29024,7 +29188,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29024
29188
|
this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
29025
29189
|
ctx.restore();
|
|
29026
29190
|
}
|
|
29027
|
-
const headerSkeletonPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
29191
|
+
const headerSkeletonPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(page.headerLayoutKey ?? pageWidth);
|
|
29028
29192
|
const headerAlignOffsetNoAngle = Vector2.create(horizontalOffsetNoAngle, (headerSkeletonPage === null || headerSkeletonPage === void 0 ? void 0 : headerSkeletonPage.marginTop) ?? 0);
|
|
29029
29193
|
if (headerSkeletonPage) this._drawHeaderFooter(headerSkeletonPage, ctx, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, headerAlignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, page, true, pages.length, void 0, headerFooterOpacity);
|
|
29030
29194
|
ctx.save();
|
|
@@ -29038,7 +29202,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29038
29202
|
var _this$getSkeleton6;
|
|
29039
29203
|
this._drawHeaderFooter(note.page, ctx, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, Vector2.create(horizontalOffsetNoAngle + note.left - page.marginLeft, note.top), centerAngle, vertexAngle, renderConfig, parentScale, page, false, pages.length, "kind" in note ? ((_this$getSkeleton6 = this.getSkeleton()) === null || _this$getSkeleton6 === void 0 || (_this$getSkeleton6 = _this$getSkeleton6.getViewModel().getSnapshot().noteSettings) === null || _this$getSkeleton6 === void 0 || (_this$getSkeleton6 = _this$getSkeleton6[note.noteType ?? "footnote"]) === null || _this$getSkeleton6 === void 0 || (_this$getSkeleton6 = _this$getSkeleton6[note.kind]) === null || _this$getSkeleton6 === void 0 ? void 0 : _this$getSkeleton6.customRanges) ?? [] : void 0);
|
|
29040
29204
|
}
|
|
29041
|
-
const footerSkeletonPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
29205
|
+
const footerSkeletonPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(page.footerLayoutKey ?? pageWidth);
|
|
29042
29206
|
if (footerSkeletonPage) {
|
|
29043
29207
|
const footerAlignOffsetNoAngle = Vector2.create(horizontalOffsetNoAngle, page.pageHeight - (footerSkeletonPage === null || footerSkeletonPage === void 0 ? void 0 : footerSkeletonPage.height) - footerSkeletonPage.marginBottom);
|
|
29044
29208
|
this._drawHeaderFooter(footerSkeletonPage, ctx, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, footerAlignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, page, false, pages.length, void 0, headerFooterOpacity);
|
|
@@ -29642,7 +29806,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29642
29806
|
const skeleton = this.getSkeleton();
|
|
29643
29807
|
const viewModel = typeof (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getViewModel) === "function" ? skeleton.getViewModel().getSelfOrHeaderFooterViewModel(page.segmentId) : void 0;
|
|
29644
29808
|
const fieldContext = {
|
|
29645
|
-
customRanges: customRangesOverride ?? (viewModel === null || viewModel === void 0 || (_viewModel$getBody = viewModel.getBody()) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.customRanges) ?? [],
|
|
29809
|
+
customRanges: page.fieldsResolved ? [] : customRangesOverride ?? (viewModel === null || viewModel === void 0 || (_viewModel$getBody = viewModel.getBody()) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.customRanges) ?? [],
|
|
29646
29810
|
pageNumber: parentPage.pageNumber,
|
|
29647
29811
|
pageCount,
|
|
29648
29812
|
viewModel
|
|
@@ -35365,7 +35529,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
35365
35529
|
//#endregion
|
|
35366
35530
|
//#region package.json
|
|
35367
35531
|
var name = "@univerjs/engine-render";
|
|
35368
|
-
var version = "1.0.
|
|
35532
|
+
var version = "1.0.4";
|
|
35369
35533
|
|
|
35370
35534
|
//#endregion
|
|
35371
35535
|
//#region src/config/config.ts
|
|
@@ -40036,6 +40200,7 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40036
40200
|
_defineProperty(this, "_viewModel", void 0);
|
|
40037
40201
|
_defineProperty(this, "_skeleton", void 0);
|
|
40038
40202
|
_defineProperty(this, "_lastPublishedPageCount", 0);
|
|
40203
|
+
_defineProperty(this, "_paginationRevision", 0);
|
|
40039
40204
|
_defineProperty(this, "_layoutReason", "initial");
|
|
40040
40205
|
_defineProperty(this, "_didPublishEditAnchor", false);
|
|
40041
40206
|
_defineProperty(this, "_continuousPageSnapshot", null);
|
|
@@ -40051,6 +40216,7 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40051
40216
|
var _options$invalidation;
|
|
40052
40217
|
this._lastPublishedPageCount = 0;
|
|
40053
40218
|
this._layoutReason = (options === null || options === void 0 ? void 0 : options.reason) ?? "initial";
|
|
40219
|
+
this._paginationRevision = 0;
|
|
40054
40220
|
this._didPublishEditAnchor = false;
|
|
40055
40221
|
this._publishedHeaderPages.clear();
|
|
40056
40222
|
this._publishedFooterPages.clear();
|
|
@@ -40131,6 +40297,11 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40131
40297
|
}
|
|
40132
40298
|
_collectPublications(initialProgress) {
|
|
40133
40299
|
let progress = initialProgress;
|
|
40300
|
+
if ((progress.paginationRevision ?? 0) !== this._paginationRevision) {
|
|
40301
|
+
this._paginationRevision = progress.paginationRevision ?? 0;
|
|
40302
|
+
this._lastPublishedPageCount = 0;
|
|
40303
|
+
this._didPublishEditAnchor = false;
|
|
40304
|
+
}
|
|
40134
40305
|
if (!progress.didPublish) return {
|
|
40135
40306
|
progress,
|
|
40136
40307
|
publication: null
|