@univerjs/engine-render 1.0.0-alpha.1 → 1.0.0-alpha.2
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
CHANGED
|
@@ -114,6 +114,10 @@ let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
|
|
|
114
114
|
CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
|
|
115
115
|
CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
|
|
116
116
|
CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
|
|
117
|
+
CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
|
|
118
|
+
CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
|
|
119
|
+
CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
|
|
120
|
+
CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
|
|
117
121
|
CURSOR_TYPE["TEXT"] = "text";
|
|
118
122
|
CURSOR_TYPE["WAIT"] = "wait";
|
|
119
123
|
CURSOR_TYPE["HELP"] = "help";
|
|
@@ -228,6 +232,7 @@ const cancelRequestFrame = (requestID, requester) => {
|
|
|
228
232
|
};
|
|
229
233
|
const createCanvasElement = () => {
|
|
230
234
|
const canvas = document.createElement("canvas");
|
|
235
|
+
canvas.dir = "ltr";
|
|
231
236
|
try {
|
|
232
237
|
canvas.style = canvas.style || {};
|
|
233
238
|
} catch (e) {
|
|
@@ -12471,8 +12476,9 @@ function parseDataStreamToTree(dataStream, tables) {
|
|
|
12471
12476
|
};
|
|
12472
12477
|
}
|
|
12473
12478
|
var DocumentViewModel = class DocumentViewModel {
|
|
12474
|
-
constructor(_documentDataModel) {
|
|
12479
|
+
constructor(_documentDataModel, _tableSource) {
|
|
12475
12480
|
this._documentDataModel = _documentDataModel;
|
|
12481
|
+
this._tableSource = _tableSource;
|
|
12476
12482
|
_defineProperty(this, "_interceptor", null);
|
|
12477
12483
|
_defineProperty(this, "_cacheSize", 1e3);
|
|
12478
12484
|
_defineProperty(this, "_textRunsCache", /* @__PURE__ */ new Map());
|
|
@@ -12650,10 +12656,10 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12650
12656
|
}
|
|
12651
12657
|
}
|
|
12652
12658
|
_buildTableCache() {
|
|
12653
|
-
var _this$getBody4;
|
|
12659
|
+
var _this$getBody4, _this$_tableSource;
|
|
12654
12660
|
this._tableCache.clear();
|
|
12655
12661
|
const tables = (_this$getBody4 = this.getBody()) === null || _this$getBody4 === void 0 ? void 0 : _this$getBody4.tables;
|
|
12656
|
-
const tableConfig = this.getSnapshot().tableSource;
|
|
12662
|
+
const tableConfig = (_this$_tableSource = this._tableSource) !== null && _this$_tableSource !== void 0 ? _this$_tableSource : this.getSnapshot().tableSource;
|
|
12657
12663
|
if (tables == null || tableConfig == null) return;
|
|
12658
12664
|
for (const table of tables) {
|
|
12659
12665
|
const { startIndex, tableId } = table;
|
|
@@ -12695,12 +12701,13 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12695
12701
|
_buildHeaderFooterViewModel() {
|
|
12696
12702
|
const { headerModelMap, footerModelMap } = this._documentDataModel;
|
|
12697
12703
|
const viewModels = [];
|
|
12704
|
+
const tableSource = this.getSnapshot().tableSource;
|
|
12698
12705
|
for (const [headerId, headerModel] of headerModelMap) {
|
|
12699
|
-
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel));
|
|
12706
|
+
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel, tableSource));
|
|
12700
12707
|
viewModels.push(this._headerTreeMap.get(headerId));
|
|
12701
12708
|
}
|
|
12702
12709
|
for (const [footerId, footerModel] of footerModelMap) {
|
|
12703
|
-
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel));
|
|
12710
|
+
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel, tableSource));
|
|
12704
12711
|
viewModels.push(this._footerTreeMap.get(footerId));
|
|
12705
12712
|
}
|
|
12706
12713
|
this._segmentViewModels$.next(viewModels);
|
|
@@ -14884,10 +14891,10 @@ function lineIterator(pagesOrCells, cb) {
|
|
|
14884
14891
|
}
|
|
14885
14892
|
}
|
|
14886
14893
|
function documentSkeletonTableIterator(pages, options = {}) {
|
|
14887
|
-
const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, tableCellInsetX = 0, unitId = "" } = options;
|
|
14894
|
+
const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
|
|
14888
14895
|
const contexts = [];
|
|
14889
14896
|
pages.forEach((rootPage, pageIndex) => {
|
|
14890
|
-
var _rootPage$skeColumnGr;
|
|
14897
|
+
var _skeHeaders$get, _skeFooters$get, _rootPage$skeColumnGr;
|
|
14891
14898
|
const rootPageTop = ((rootPage.pageHeight === Infinity ? 0 : rootPage.pageHeight) + pageMarginTop) * pageIndex + rootPage.marginTop + docsTop;
|
|
14892
14899
|
const rootPageLeft = rootPage.marginLeft + docsLeft;
|
|
14893
14900
|
collectPageTables({
|
|
@@ -14903,6 +14910,36 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
14903
14910
|
tableCellInsetX,
|
|
14904
14911
|
unitId
|
|
14905
14912
|
});
|
|
14913
|
+
const rootPageDocumentTop = rootPageTop - rootPage.marginTop;
|
|
14914
|
+
const rootPageDocumentLeft = docsLeft + rootPage.marginLeft;
|
|
14915
|
+
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);
|
|
14916
|
+
if (headerPage != null) collectPageTables({
|
|
14917
|
+
contexts,
|
|
14918
|
+
docsLeft,
|
|
14919
|
+
page: headerPage,
|
|
14920
|
+
pageIndex,
|
|
14921
|
+
pageLeft: rootPageDocumentLeft,
|
|
14922
|
+
pageTop: rootPageDocumentTop + headerPage.marginTop,
|
|
14923
|
+
rootPage,
|
|
14924
|
+
source: "header",
|
|
14925
|
+
resolveViewport,
|
|
14926
|
+
tableCellInsetX,
|
|
14927
|
+
unitId
|
|
14928
|
+
});
|
|
14929
|
+
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);
|
|
14930
|
+
if (footerPage != null) collectPageTables({
|
|
14931
|
+
contexts,
|
|
14932
|
+
docsLeft,
|
|
14933
|
+
page: footerPage,
|
|
14934
|
+
pageIndex,
|
|
14935
|
+
pageLeft: rootPageDocumentLeft,
|
|
14936
|
+
pageTop: rootPageDocumentTop + rootPage.pageHeight - footerPage.height - footerPage.marginBottom,
|
|
14937
|
+
rootPage,
|
|
14938
|
+
source: "footer",
|
|
14939
|
+
resolveViewport,
|
|
14940
|
+
tableCellInsetX,
|
|
14941
|
+
unitId
|
|
14942
|
+
});
|
|
14906
14943
|
(_rootPage$skeColumnGr = rootPage.skeColumnGroups) === null || _rootPage$skeColumnGr === void 0 || _rootPage$skeColumnGr.forEach((columnGroup) => {
|
|
14907
14944
|
columnGroup.columns.forEach((columnGroupColumn) => {
|
|
14908
14945
|
const nestedPage = columnGroupColumn.page;
|
|
@@ -15444,20 +15481,22 @@ function getPageFromPath(skeletonData, path) {
|
|
|
15444
15481
|
const pageIndex = pathCopy.shift();
|
|
15445
15482
|
page = skeletonData.pages[pageIndex];
|
|
15446
15483
|
} else if (field === "skeTables") {
|
|
15447
|
-
var
|
|
15484
|
+
var _page$skeTables3;
|
|
15485
|
+
if (page == null) return null;
|
|
15448
15486
|
const tableId = pathCopy.shift();
|
|
15449
15487
|
pathCopy.shift();
|
|
15450
15488
|
const rowIndex = pathCopy.shift();
|
|
15451
15489
|
pathCopy.shift();
|
|
15452
15490
|
const cellIndex = pathCopy.shift();
|
|
15453
|
-
page = (
|
|
15491
|
+
page = (_page$skeTables3 = page.skeTables) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.get(tableId)) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.rows[rowIndex]) === null || _page$skeTables3 === void 0 ? void 0 : _page$skeTables3.cells[cellIndex];
|
|
15454
15492
|
} else if (field === "skeColumnGroups") {
|
|
15455
|
-
var
|
|
15493
|
+
var _page$skeColumnGroups2;
|
|
15494
|
+
if (page == null) return null;
|
|
15456
15495
|
const columnGroupId = pathCopy.shift();
|
|
15457
15496
|
pathCopy.shift();
|
|
15458
15497
|
const columnIndex = pathCopy.shift();
|
|
15459
15498
|
pathCopy.shift();
|
|
15460
|
-
page = (
|
|
15499
|
+
page = (_page$skeColumnGroups2 = page.skeColumnGroups) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.get(columnGroupId)) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.columns[columnIndex]) === null || _page$skeColumnGroups2 === void 0 ? void 0 : _page$skeColumnGroups2.page;
|
|
15461
15500
|
}
|
|
15462
15501
|
}
|
|
15463
15502
|
return page;
|
|
@@ -15524,8 +15563,8 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
15524
15563
|
}
|
|
15525
15564
|
page.originMarginTop = marginTop;
|
|
15526
15565
|
page.originMarginBottom = marginBottom;
|
|
15527
|
-
page.marginTop = _getVerticalMargin(marginTop, header
|
|
15528
|
-
page.marginBottom = _getVerticalMargin(marginBottom, footer
|
|
15566
|
+
page.marginTop = _getVerticalMargin(marginTop, header);
|
|
15567
|
+
page.marginBottom = _getVerticalMargin(marginBottom, footer);
|
|
15529
15568
|
const sections = page.sections;
|
|
15530
15569
|
const lastSection = sections[sections.length - 1];
|
|
15531
15570
|
const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
|
|
@@ -15698,8 +15737,10 @@ function applyTrailingBlockRangeSpaceBelow(pages, body, containerEndIndex) {
|
|
|
15698
15737
|
page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
|
|
15699
15738
|
}
|
|
15700
15739
|
}
|
|
15701
|
-
function _getVerticalMargin(marginTB,
|
|
15702
|
-
return marginTB;
|
|
15740
|
+
function _getVerticalMargin(marginTB, headerOrFooter) {
|
|
15741
|
+
if (headerOrFooter == null) return marginTB;
|
|
15742
|
+
const { marginTop = 0, height = 0, marginBottom = 0 } = headerOrFooter;
|
|
15743
|
+
return Math.max(marginTB, marginTop + height + marginBottom);
|
|
15703
15744
|
}
|
|
15704
15745
|
|
|
15705
15746
|
//#endregion
|
|
@@ -17871,6 +17912,26 @@ function resolveMostSpecificPageByCharIndex(page, charIndex) {
|
|
|
17871
17912
|
}
|
|
17872
17913
|
return page;
|
|
17873
17914
|
}
|
|
17915
|
+
function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
|
|
17916
|
+
var _skeletonData$skeHead, _skeletonData$skeFoot;
|
|
17917
|
+
const rootPage = skeletonData.pages[segmentPageIndex];
|
|
17918
|
+
if (rootPage == null) return null;
|
|
17919
|
+
const { headerId, footerId, pageWidth } = rootPage;
|
|
17920
|
+
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)];
|
|
17921
|
+
for (const segmentPage of segmentPages) {
|
|
17922
|
+
if (segmentPage == null) continue;
|
|
17923
|
+
const page = getPageFromPath({
|
|
17924
|
+
...skeletonData,
|
|
17925
|
+
pages: [segmentPage]
|
|
17926
|
+
}, [
|
|
17927
|
+
"pages",
|
|
17928
|
+
0,
|
|
17929
|
+
...path
|
|
17930
|
+
]);
|
|
17931
|
+
if (page != null) return page;
|
|
17932
|
+
}
|
|
17933
|
+
return null;
|
|
17934
|
+
}
|
|
17874
17935
|
var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
17875
17936
|
constructor(_docViewModel, localeService) {
|
|
17876
17937
|
super(localeService);
|
|
@@ -17965,7 +18026,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
17965
18026
|
pageIndex = skeletonData.pages.indexOf(page);
|
|
17966
18027
|
break;
|
|
17967
18028
|
case 3:
|
|
17968
|
-
pageIndex = path[1];
|
|
18029
|
+
pageIndex = typeof path[1] === "number" ? path[1] : segmentPage;
|
|
17969
18030
|
break;
|
|
17970
18031
|
default: throw new Error("Invalid page type");
|
|
17971
18032
|
}
|
|
@@ -18011,7 +18072,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
18011
18072
|
pageIndex = pages.indexOf(page);
|
|
18012
18073
|
break;
|
|
18013
18074
|
case 3:
|
|
18014
|
-
pageIndex = path[1];
|
|
18075
|
+
pageIndex = typeof path[1] === "number" ? path[1] : segmentPageIndex;
|
|
18015
18076
|
break;
|
|
18016
18077
|
default: throw new Error("Invalid page type");
|
|
18017
18078
|
}
|
|
@@ -18054,7 +18115,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
18054
18115
|
if (skeFooter == null) return;
|
|
18055
18116
|
else skePage = skeFooter;
|
|
18056
18117
|
}
|
|
18057
|
-
} else skePage =
|
|
18118
|
+
} else if (pageType === 3 && path[0] !== "pages") skePage = getSegmentPageFromRelativePath(skeletonData, segmentPage, path);
|
|
18119
|
+
else skePage = getPageFromPath(skeletonData, path);
|
|
18058
18120
|
if (skePage == null) return;
|
|
18059
18121
|
const glyphGroup = skePage.sections[section].columns[column].lines[line].divides[divide].glyphGroup;
|
|
18060
18122
|
glyph = Math.min(glyph, glyphGroup.length - 1);
|
|
@@ -18562,8 +18624,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
18562
18624
|
if (maybeHeaderSke) segmentPage = maybeHeaderSke;
|
|
18563
18625
|
else if (maybeFooterSke) segmentPage = maybeFooterSke;
|
|
18564
18626
|
else continue;
|
|
18565
|
-
|
|
18566
|
-
|
|
18627
|
+
segmentPage = resolveMostSpecificPageByCharIndex(segmentPage, charIndex);
|
|
18628
|
+
} else segmentPage = resolveMostSpecificPageByCharIndex(page, charIndex);
|
|
18567
18629
|
const { sections, st, ed } = segmentPage;
|
|
18568
18630
|
const segmentPageParent = segmentPage.parent;
|
|
18569
18631
|
const isColumnSegmentPage = segmentId === "" && (segmentPageParent === null || segmentPageParent === void 0 ? void 0 : segmentPageParent.page) === segmentPage && ((_segmentPageParent$pa = segmentPageParent.parent) === null || _segmentPageParent$pa === void 0 ? void 0 : _segmentPageParent$pa.columnGroupId);
|
|
@@ -23834,7 +23896,15 @@ var Documents = class Documents extends DocComponent {
|
|
|
23834
23896
|
if (this._drawLiquid == null) return;
|
|
23835
23897
|
const { sections, skeTables } = page;
|
|
23836
23898
|
const { y: originY } = this._drawLiquid;
|
|
23837
|
-
if (skeTables.size > 0)
|
|
23899
|
+
if (skeTables.size > 0) {
|
|
23900
|
+
const tablePage = {
|
|
23901
|
+
...page,
|
|
23902
|
+
marginLeft: parentPage.marginLeft,
|
|
23903
|
+
marginRight: parentPage.marginRight,
|
|
23904
|
+
marginTop: isHeader ? page.marginTop : page.marginTop + alignOffsetNoAngle.y
|
|
23905
|
+
};
|
|
23906
|
+
this._drawTable(ctx, tablePage, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
23907
|
+
}
|
|
23838
23908
|
for (const section of sections) {
|
|
23839
23909
|
const { columns } = section;
|
|
23840
23910
|
this._drawLiquid.translateSave();
|
|
@@ -26555,7 +26625,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
26555
26625
|
//#endregion
|
|
26556
26626
|
//#region package.json
|
|
26557
26627
|
var name = "@univerjs/engine-render";
|
|
26558
|
-
var version = "1.0.0-alpha.
|
|
26628
|
+
var version = "1.0.0-alpha.2";
|
|
26559
26629
|
|
|
26560
26630
|
//#endregion
|
|
26561
26631
|
//#region src/config/config.ts
|
package/lib/es/index.js
CHANGED
|
@@ -89,6 +89,10 @@ let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
|
|
|
89
89
|
CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
|
|
90
90
|
CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
|
|
91
91
|
CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
|
|
92
|
+
CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
|
|
93
|
+
CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
|
|
94
|
+
CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
|
|
95
|
+
CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
|
|
92
96
|
CURSOR_TYPE["TEXT"] = "text";
|
|
93
97
|
CURSOR_TYPE["WAIT"] = "wait";
|
|
94
98
|
CURSOR_TYPE["HELP"] = "help";
|
|
@@ -203,6 +207,7 @@ const cancelRequestFrame = (requestID, requester) => {
|
|
|
203
207
|
};
|
|
204
208
|
const createCanvasElement = () => {
|
|
205
209
|
const canvas = document.createElement("canvas");
|
|
210
|
+
canvas.dir = "ltr";
|
|
206
211
|
try {
|
|
207
212
|
canvas.style = canvas.style || {};
|
|
208
213
|
} catch (e) {
|
|
@@ -12446,8 +12451,9 @@ function parseDataStreamToTree(dataStream, tables) {
|
|
|
12446
12451
|
};
|
|
12447
12452
|
}
|
|
12448
12453
|
var DocumentViewModel = class DocumentViewModel {
|
|
12449
|
-
constructor(_documentDataModel) {
|
|
12454
|
+
constructor(_documentDataModel, _tableSource) {
|
|
12450
12455
|
this._documentDataModel = _documentDataModel;
|
|
12456
|
+
this._tableSource = _tableSource;
|
|
12451
12457
|
_defineProperty(this, "_interceptor", null);
|
|
12452
12458
|
_defineProperty(this, "_cacheSize", 1e3);
|
|
12453
12459
|
_defineProperty(this, "_textRunsCache", /* @__PURE__ */ new Map());
|
|
@@ -12625,10 +12631,10 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12625
12631
|
}
|
|
12626
12632
|
}
|
|
12627
12633
|
_buildTableCache() {
|
|
12628
|
-
var _this$getBody4;
|
|
12634
|
+
var _this$getBody4, _this$_tableSource;
|
|
12629
12635
|
this._tableCache.clear();
|
|
12630
12636
|
const tables = (_this$getBody4 = this.getBody()) === null || _this$getBody4 === void 0 ? void 0 : _this$getBody4.tables;
|
|
12631
|
-
const tableConfig = this.getSnapshot().tableSource;
|
|
12637
|
+
const tableConfig = (_this$_tableSource = this._tableSource) !== null && _this$_tableSource !== void 0 ? _this$_tableSource : this.getSnapshot().tableSource;
|
|
12632
12638
|
if (tables == null || tableConfig == null) return;
|
|
12633
12639
|
for (const table of tables) {
|
|
12634
12640
|
const { startIndex, tableId } = table;
|
|
@@ -12670,12 +12676,13 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12670
12676
|
_buildHeaderFooterViewModel() {
|
|
12671
12677
|
const { headerModelMap, footerModelMap } = this._documentDataModel;
|
|
12672
12678
|
const viewModels = [];
|
|
12679
|
+
const tableSource = this.getSnapshot().tableSource;
|
|
12673
12680
|
for (const [headerId, headerModel] of headerModelMap) {
|
|
12674
|
-
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel));
|
|
12681
|
+
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel, tableSource));
|
|
12675
12682
|
viewModels.push(this._headerTreeMap.get(headerId));
|
|
12676
12683
|
}
|
|
12677
12684
|
for (const [footerId, footerModel] of footerModelMap) {
|
|
12678
|
-
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel));
|
|
12685
|
+
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel, tableSource));
|
|
12679
12686
|
viewModels.push(this._footerTreeMap.get(footerId));
|
|
12680
12687
|
}
|
|
12681
12688
|
this._segmentViewModels$.next(viewModels);
|
|
@@ -14859,10 +14866,10 @@ function lineIterator(pagesOrCells, cb) {
|
|
|
14859
14866
|
}
|
|
14860
14867
|
}
|
|
14861
14868
|
function documentSkeletonTableIterator(pages, options = {}) {
|
|
14862
|
-
const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, tableCellInsetX = 0, unitId = "" } = options;
|
|
14869
|
+
const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
|
|
14863
14870
|
const contexts = [];
|
|
14864
14871
|
pages.forEach((rootPage, pageIndex) => {
|
|
14865
|
-
var _rootPage$skeColumnGr;
|
|
14872
|
+
var _skeHeaders$get, _skeFooters$get, _rootPage$skeColumnGr;
|
|
14866
14873
|
const rootPageTop = ((rootPage.pageHeight === Infinity ? 0 : rootPage.pageHeight) + pageMarginTop) * pageIndex + rootPage.marginTop + docsTop;
|
|
14867
14874
|
const rootPageLeft = rootPage.marginLeft + docsLeft;
|
|
14868
14875
|
collectPageTables({
|
|
@@ -14878,6 +14885,36 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
14878
14885
|
tableCellInsetX,
|
|
14879
14886
|
unitId
|
|
14880
14887
|
});
|
|
14888
|
+
const rootPageDocumentTop = rootPageTop - rootPage.marginTop;
|
|
14889
|
+
const rootPageDocumentLeft = docsLeft + rootPage.marginLeft;
|
|
14890
|
+
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);
|
|
14891
|
+
if (headerPage != null) collectPageTables({
|
|
14892
|
+
contexts,
|
|
14893
|
+
docsLeft,
|
|
14894
|
+
page: headerPage,
|
|
14895
|
+
pageIndex,
|
|
14896
|
+
pageLeft: rootPageDocumentLeft,
|
|
14897
|
+
pageTop: rootPageDocumentTop + headerPage.marginTop,
|
|
14898
|
+
rootPage,
|
|
14899
|
+
source: "header",
|
|
14900
|
+
resolveViewport,
|
|
14901
|
+
tableCellInsetX,
|
|
14902
|
+
unitId
|
|
14903
|
+
});
|
|
14904
|
+
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);
|
|
14905
|
+
if (footerPage != null) collectPageTables({
|
|
14906
|
+
contexts,
|
|
14907
|
+
docsLeft,
|
|
14908
|
+
page: footerPage,
|
|
14909
|
+
pageIndex,
|
|
14910
|
+
pageLeft: rootPageDocumentLeft,
|
|
14911
|
+
pageTop: rootPageDocumentTop + rootPage.pageHeight - footerPage.height - footerPage.marginBottom,
|
|
14912
|
+
rootPage,
|
|
14913
|
+
source: "footer",
|
|
14914
|
+
resolveViewport,
|
|
14915
|
+
tableCellInsetX,
|
|
14916
|
+
unitId
|
|
14917
|
+
});
|
|
14881
14918
|
(_rootPage$skeColumnGr = rootPage.skeColumnGroups) === null || _rootPage$skeColumnGr === void 0 || _rootPage$skeColumnGr.forEach((columnGroup) => {
|
|
14882
14919
|
columnGroup.columns.forEach((columnGroupColumn) => {
|
|
14883
14920
|
const nestedPage = columnGroupColumn.page;
|
|
@@ -15419,20 +15456,22 @@ function getPageFromPath(skeletonData, path) {
|
|
|
15419
15456
|
const pageIndex = pathCopy.shift();
|
|
15420
15457
|
page = skeletonData.pages[pageIndex];
|
|
15421
15458
|
} else if (field === "skeTables") {
|
|
15422
|
-
var
|
|
15459
|
+
var _page$skeTables3;
|
|
15460
|
+
if (page == null) return null;
|
|
15423
15461
|
const tableId = pathCopy.shift();
|
|
15424
15462
|
pathCopy.shift();
|
|
15425
15463
|
const rowIndex = pathCopy.shift();
|
|
15426
15464
|
pathCopy.shift();
|
|
15427
15465
|
const cellIndex = pathCopy.shift();
|
|
15428
|
-
page = (
|
|
15466
|
+
page = (_page$skeTables3 = page.skeTables) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.get(tableId)) === null || _page$skeTables3 === void 0 || (_page$skeTables3 = _page$skeTables3.rows[rowIndex]) === null || _page$skeTables3 === void 0 ? void 0 : _page$skeTables3.cells[cellIndex];
|
|
15429
15467
|
} else if (field === "skeColumnGroups") {
|
|
15430
|
-
var
|
|
15468
|
+
var _page$skeColumnGroups2;
|
|
15469
|
+
if (page == null) return null;
|
|
15431
15470
|
const columnGroupId = pathCopy.shift();
|
|
15432
15471
|
pathCopy.shift();
|
|
15433
15472
|
const columnIndex = pathCopy.shift();
|
|
15434
15473
|
pathCopy.shift();
|
|
15435
|
-
page = (
|
|
15474
|
+
page = (_page$skeColumnGroups2 = page.skeColumnGroups) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.get(columnGroupId)) === null || _page$skeColumnGroups2 === void 0 || (_page$skeColumnGroups2 = _page$skeColumnGroups2.columns[columnIndex]) === null || _page$skeColumnGroups2 === void 0 ? void 0 : _page$skeColumnGroups2.page;
|
|
15436
15475
|
}
|
|
15437
15476
|
}
|
|
15438
15477
|
return page;
|
|
@@ -15499,8 +15538,8 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
15499
15538
|
}
|
|
15500
15539
|
page.originMarginTop = marginTop;
|
|
15501
15540
|
page.originMarginBottom = marginBottom;
|
|
15502
|
-
page.marginTop = _getVerticalMargin(marginTop, header
|
|
15503
|
-
page.marginBottom = _getVerticalMargin(marginBottom, footer
|
|
15541
|
+
page.marginTop = _getVerticalMargin(marginTop, header);
|
|
15542
|
+
page.marginBottom = _getVerticalMargin(marginBottom, footer);
|
|
15504
15543
|
const sections = page.sections;
|
|
15505
15544
|
const lastSection = sections[sections.length - 1];
|
|
15506
15545
|
const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
|
|
@@ -15673,8 +15712,10 @@ function applyTrailingBlockRangeSpaceBelow(pages, body, containerEndIndex) {
|
|
|
15673
15712
|
page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
|
|
15674
15713
|
}
|
|
15675
15714
|
}
|
|
15676
|
-
function _getVerticalMargin(marginTB,
|
|
15677
|
-
return marginTB;
|
|
15715
|
+
function _getVerticalMargin(marginTB, headerOrFooter) {
|
|
15716
|
+
if (headerOrFooter == null) return marginTB;
|
|
15717
|
+
const { marginTop = 0, height = 0, marginBottom = 0 } = headerOrFooter;
|
|
15718
|
+
return Math.max(marginTB, marginTop + height + marginBottom);
|
|
15678
15719
|
}
|
|
15679
15720
|
|
|
15680
15721
|
//#endregion
|
|
@@ -17846,6 +17887,26 @@ function resolveMostSpecificPageByCharIndex(page, charIndex) {
|
|
|
17846
17887
|
}
|
|
17847
17888
|
return page;
|
|
17848
17889
|
}
|
|
17890
|
+
function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
|
|
17891
|
+
var _skeletonData$skeHead, _skeletonData$skeFoot;
|
|
17892
|
+
const rootPage = skeletonData.pages[segmentPageIndex];
|
|
17893
|
+
if (rootPage == null) return null;
|
|
17894
|
+
const { headerId, footerId, pageWidth } = rootPage;
|
|
17895
|
+
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)];
|
|
17896
|
+
for (const segmentPage of segmentPages) {
|
|
17897
|
+
if (segmentPage == null) continue;
|
|
17898
|
+
const page = getPageFromPath({
|
|
17899
|
+
...skeletonData,
|
|
17900
|
+
pages: [segmentPage]
|
|
17901
|
+
}, [
|
|
17902
|
+
"pages",
|
|
17903
|
+
0,
|
|
17904
|
+
...path
|
|
17905
|
+
]);
|
|
17906
|
+
if (page != null) return page;
|
|
17907
|
+
}
|
|
17908
|
+
return null;
|
|
17909
|
+
}
|
|
17849
17910
|
var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
17850
17911
|
constructor(_docViewModel, localeService) {
|
|
17851
17912
|
super(localeService);
|
|
@@ -17940,7 +18001,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
17940
18001
|
pageIndex = skeletonData.pages.indexOf(page);
|
|
17941
18002
|
break;
|
|
17942
18003
|
case 3:
|
|
17943
|
-
pageIndex = path[1];
|
|
18004
|
+
pageIndex = typeof path[1] === "number" ? path[1] : segmentPage;
|
|
17944
18005
|
break;
|
|
17945
18006
|
default: throw new Error("Invalid page type");
|
|
17946
18007
|
}
|
|
@@ -17986,7 +18047,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
17986
18047
|
pageIndex = pages.indexOf(page);
|
|
17987
18048
|
break;
|
|
17988
18049
|
case 3:
|
|
17989
|
-
pageIndex = path[1];
|
|
18050
|
+
pageIndex = typeof path[1] === "number" ? path[1] : segmentPageIndex;
|
|
17990
18051
|
break;
|
|
17991
18052
|
default: throw new Error("Invalid page type");
|
|
17992
18053
|
}
|
|
@@ -18029,7 +18090,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
18029
18090
|
if (skeFooter == null) return;
|
|
18030
18091
|
else skePage = skeFooter;
|
|
18031
18092
|
}
|
|
18032
|
-
} else skePage =
|
|
18093
|
+
} else if (pageType === 3 && path[0] !== "pages") skePage = getSegmentPageFromRelativePath(skeletonData, segmentPage, path);
|
|
18094
|
+
else skePage = getPageFromPath(skeletonData, path);
|
|
18033
18095
|
if (skePage == null) return;
|
|
18034
18096
|
const glyphGroup = skePage.sections[section].columns[column].lines[line].divides[divide].glyphGroup;
|
|
18035
18097
|
glyph = Math.min(glyph, glyphGroup.length - 1);
|
|
@@ -18537,8 +18599,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
18537
18599
|
if (maybeHeaderSke) segmentPage = maybeHeaderSke;
|
|
18538
18600
|
else if (maybeFooterSke) segmentPage = maybeFooterSke;
|
|
18539
18601
|
else continue;
|
|
18540
|
-
|
|
18541
|
-
|
|
18602
|
+
segmentPage = resolveMostSpecificPageByCharIndex(segmentPage, charIndex);
|
|
18603
|
+
} else segmentPage = resolveMostSpecificPageByCharIndex(page, charIndex);
|
|
18542
18604
|
const { sections, st, ed } = segmentPage;
|
|
18543
18605
|
const segmentPageParent = segmentPage.parent;
|
|
18544
18606
|
const isColumnSegmentPage = segmentId === "" && (segmentPageParent === null || segmentPageParent === void 0 ? void 0 : segmentPageParent.page) === segmentPage && ((_segmentPageParent$pa = segmentPageParent.parent) === null || _segmentPageParent$pa === void 0 ? void 0 : _segmentPageParent$pa.columnGroupId);
|
|
@@ -23809,7 +23871,15 @@ var Documents = class Documents extends DocComponent {
|
|
|
23809
23871
|
if (this._drawLiquid == null) return;
|
|
23810
23872
|
const { sections, skeTables } = page;
|
|
23811
23873
|
const { y: originY } = this._drawLiquid;
|
|
23812
|
-
if (skeTables.size > 0)
|
|
23874
|
+
if (skeTables.size > 0) {
|
|
23875
|
+
const tablePage = {
|
|
23876
|
+
...page,
|
|
23877
|
+
marginLeft: parentPage.marginLeft,
|
|
23878
|
+
marginRight: parentPage.marginRight,
|
|
23879
|
+
marginTop: isHeader ? page.marginTop : page.marginTop + alignOffsetNoAngle.y
|
|
23880
|
+
};
|
|
23881
|
+
this._drawTable(ctx, tablePage, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
23882
|
+
}
|
|
23813
23883
|
for (const section of sections) {
|
|
23814
23884
|
const { columns } = section;
|
|
23815
23885
|
this._drawLiquid.translateSave();
|
|
@@ -26530,7 +26600,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
26530
26600
|
//#endregion
|
|
26531
26601
|
//#region package.json
|
|
26532
26602
|
var name = "@univerjs/engine-render";
|
|
26533
|
-
var version = "1.0.0-alpha.
|
|
26603
|
+
var version = "1.0.0-alpha.2";
|
|
26534
26604
|
|
|
26535
26605
|
//#endregion
|
|
26536
26606
|
//#region src/config/config.ts
|
|
@@ -62,6 +62,10 @@ export declare enum CURSOR_TYPE {
|
|
|
62
62
|
SOUTH_WEST_RESIZE = "sw-resize",
|
|
63
63
|
SOUTH_RESIZE = "s-resize",
|
|
64
64
|
WEST_RESIZE = "w-resize",
|
|
65
|
+
EAST_WEST_RESIZE = "ew-resize",
|
|
66
|
+
NORTH_SOUTH_RESIZE = "ns-resize",
|
|
67
|
+
NORTH_EAST_SOUTH_WEST_RESIZE = "nesw-resize",
|
|
68
|
+
NORTH_WEST_SOUTH_EAST_RESIZE = "nwse-resize",
|
|
65
69
|
TEXT = "text",
|
|
66
70
|
WAIT = "wait",
|
|
67
71
|
HELP = "help",
|
|
@@ -92,7 +92,8 @@ export interface IDocumentSkeletonLineContext {
|
|
|
92
92
|
visualLeft?: number;
|
|
93
93
|
visualWidth?: number;
|
|
94
94
|
}
|
|
95
|
-
export type DocumentSkeletonTableSource = 'page' | 'column';
|
|
95
|
+
export type DocumentSkeletonTableSource = 'page' | 'column' | 'header' | 'footer';
|
|
96
|
+
type HeaderFooterSkeletonMap = Map<string, Map<number, IDocumentSkeletonPage>>;
|
|
96
97
|
export interface IDocumentSkeletonTableCellGeometry {
|
|
97
98
|
cell: IDocumentSkeletonPage;
|
|
98
99
|
cellRect: IBoundRectNoAngle;
|
|
@@ -123,6 +124,8 @@ export interface IDocumentSkeletonTableIteratorOptions {
|
|
|
123
124
|
docsTop?: number;
|
|
124
125
|
pageMarginTop?: number;
|
|
125
126
|
resolveViewport?: boolean;
|
|
127
|
+
skeFooters?: HeaderFooterSkeletonMap;
|
|
128
|
+
skeHeaders?: HeaderFooterSkeletonMap;
|
|
126
129
|
tableCellInsetX?: number;
|
|
127
130
|
unitId?: string;
|
|
128
131
|
}
|
|
@@ -41,6 +41,7 @@ interface IColumnGroupCoupleCache {
|
|
|
41
41
|
}
|
|
42
42
|
export declare class DocumentViewModel implements IDisposable {
|
|
43
43
|
private _documentDataModel;
|
|
44
|
+
private _tableSource?;
|
|
44
45
|
private _interceptor;
|
|
45
46
|
private _cacheSize;
|
|
46
47
|
private _textRunsCache;
|
|
@@ -58,7 +59,7 @@ export declare class DocumentViewModel implements IDisposable {
|
|
|
58
59
|
private _footerTreeMap;
|
|
59
60
|
private readonly _segmentViewModels$;
|
|
60
61
|
readonly segmentViewModels$: import("rxjs").Observable<DocumentViewModel[]>;
|
|
61
|
-
constructor(_documentDataModel: DocumentDataModel);
|
|
62
|
+
constructor(_documentDataModel: DocumentDataModel, _tableSource?: Record<string, ITable> | undefined);
|
|
62
63
|
registerCustomRangeInterceptor(interceptor: ICustomRangeInterceptor): IDisposable;
|
|
63
64
|
dispose(): void;
|
|
64
65
|
getHeaderFooterTreeMap(): {
|