@univerjs/engine-render 1.0.3 → 1.1.0
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 +615 -390
- package/lib/es/index.js +610 -385
- package/lib/index.js +610 -385
- package/lib/types/basics/i-document-skeleton-cached.d.ts +10 -2
- package/lib/types/basics/interfaces.d.ts +5 -2
- package/lib/types/components/docs/document.d.ts +3 -3
- package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +1 -1
- package/lib/types/components/docs/layout/block/section.d.ts +1 -0
- package/lib/types/components/docs/layout/doc-simple-skeleton.d.ts +2 -1
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +6 -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/model/page.d.ts +2 -2
- package/lib/types/components/docs/layout/tools.d.ts +10 -1
- package/lib/types/components/sheets/extensions/font.d.ts +1 -1
- package/lib/types/components/sheets/sheet.render-skeleton.d.ts +1 -0
- package/lib/types/shape/text.d.ts +2 -0
- package/lib/types/worker-layout.d.ts +1 -0
- package/lib/umd/index.js +5 -5
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ let _floating_ui_dom = require("@floating-ui/dom");
|
|
|
23
23
|
let _floating_ui_utils = require("@floating-ui/utils");
|
|
24
24
|
let _floating_ui_utils_dom = require("@floating-ui/utils/dom");
|
|
25
25
|
|
|
26
|
-
//#region \0@oxc-project+runtime@0.
|
|
26
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
27
27
|
function _typeof(o) {
|
|
28
28
|
"@babel/helpers - typeof";
|
|
29
29
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -34,7 +34,7 @@ function _typeof(o) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
38
38
|
function toPrimitive(t, r) {
|
|
39
39
|
if ("object" != _typeof(t) || !t) return t;
|
|
40
40
|
var e = t[Symbol.toPrimitive];
|
|
@@ -47,14 +47,14 @@ function toPrimitive(t, r) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region \0@oxc-project+runtime@0.
|
|
50
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
51
51
|
function toPropertyKey(t) {
|
|
52
52
|
var i = toPrimitive(t, "string");
|
|
53
53
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
58
58
|
function _defineProperty(e, r, t) {
|
|
59
59
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
60
60
|
value: t,
|
|
@@ -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;
|
|
@@ -11920,12 +11920,13 @@ var LineBreaker = class {
|
|
|
11920
11920
|
* limitations under the License.
|
|
11921
11921
|
*/
|
|
11922
11922
|
var DocSimpleSkeleton = class {
|
|
11923
|
-
constructor(_text, _fontStyle, _warp, _width, _height) {
|
|
11923
|
+
constructor(_text, _fontStyle, _warp, _width, _height, _lineGap = 0) {
|
|
11924
11924
|
this._text = _text;
|
|
11925
11925
|
this._fontStyle = _fontStyle;
|
|
11926
11926
|
this._warp = _warp;
|
|
11927
11927
|
this._width = _width;
|
|
11928
11928
|
this._height = _height;
|
|
11929
|
+
this._lineGap = _lineGap;
|
|
11929
11930
|
_defineProperty(this, "_lineBreaker", void 0);
|
|
11930
11931
|
_defineProperty(this, "_lines", []);
|
|
11931
11932
|
_defineProperty(this, "_dirty", true);
|
|
@@ -11977,7 +11978,7 @@ var DocSimpleSkeleton = class {
|
|
|
11977
11978
|
if (textSize.width > this._width) {
|
|
11978
11979
|
if (currentLine.text.length > 0) {
|
|
11979
11980
|
this._lines.push(currentLine);
|
|
11980
|
-
totalHeight += currentLine.height;
|
|
11981
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
11981
11982
|
if (totalHeight > this._height) break;
|
|
11982
11983
|
currentLine = {
|
|
11983
11984
|
text: "",
|
|
@@ -12033,7 +12034,7 @@ var DocSimpleSkeleton = class {
|
|
|
12033
12034
|
remainingText = remainingText.slice(charCount);
|
|
12034
12035
|
if (remainingText.length > 0) {
|
|
12035
12036
|
this._lines.push(currentLine);
|
|
12036
|
-
totalHeight += currentLine.height;
|
|
12037
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12037
12038
|
if (totalHeight > this._height) break;
|
|
12038
12039
|
currentLine = {
|
|
12039
12040
|
text: "",
|
|
@@ -12046,7 +12047,7 @@ var DocSimpleSkeleton = class {
|
|
|
12046
12047
|
}
|
|
12047
12048
|
} else if (currentLine.text.length > 0) {
|
|
12048
12049
|
this._lines.push(currentLine);
|
|
12049
|
-
totalHeight += currentLine.height;
|
|
12050
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12050
12051
|
if (totalHeight > this._height) break;
|
|
12051
12052
|
currentLine = {
|
|
12052
12053
|
text,
|
|
@@ -12069,7 +12070,7 @@ var DocSimpleSkeleton = class {
|
|
|
12069
12070
|
}
|
|
12070
12071
|
if (isMandatoryBreak) {
|
|
12071
12072
|
this._lines.push(currentLine);
|
|
12072
|
-
totalHeight += currentLine.height;
|
|
12073
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12073
12074
|
if (totalHeight > this._height) break;
|
|
12074
12075
|
currentLine = {
|
|
12075
12076
|
text: "",
|
|
@@ -12087,7 +12088,7 @@ var DocSimpleSkeleton = class {
|
|
|
12087
12088
|
return this._lines;
|
|
12088
12089
|
}
|
|
12089
12090
|
getTotalHeight() {
|
|
12090
|
-
return this._lines.reduce((acc, line) => acc + line.height, 0);
|
|
12091
|
+
return this._lines.reduce((acc, line) => acc + line.height, 0) + Math.max(0, this._lines.length - 1) * this._lineGap;
|
|
12091
12092
|
}
|
|
12092
12093
|
getTotalWidth() {
|
|
12093
12094
|
return this._lines.reduce((acc, line) => Math.max(acc, line.width), 0);
|
|
@@ -12441,6 +12442,7 @@ const TEXT_OBJECT_ARRAY = [
|
|
|
12441
12442
|
"text",
|
|
12442
12443
|
"fontStyle",
|
|
12443
12444
|
"warp",
|
|
12445
|
+
"lineGap",
|
|
12444
12446
|
"hAlign",
|
|
12445
12447
|
"vAlign",
|
|
12446
12448
|
"width",
|
|
@@ -12453,6 +12455,7 @@ var Text = class Text extends Shape {
|
|
|
12453
12455
|
_defineProperty(this, "text", void 0);
|
|
12454
12456
|
_defineProperty(this, "fontStyle", void 0);
|
|
12455
12457
|
_defineProperty(this, "warp", void 0);
|
|
12458
|
+
_defineProperty(this, "lineGap", void 0);
|
|
12456
12459
|
_defineProperty(this, "hAlign", void 0);
|
|
12457
12460
|
_defineProperty(this, "vAlign", void 0);
|
|
12458
12461
|
_defineProperty(this, "skeleton", void 0);
|
|
@@ -12461,14 +12464,15 @@ var Text = class Text extends Shape {
|
|
|
12461
12464
|
this.text = props.text;
|
|
12462
12465
|
this.fontStyle = props.fontStyle;
|
|
12463
12466
|
this.warp = props.warp ?? false;
|
|
12467
|
+
this.lineGap = props.lineGap ?? 0;
|
|
12464
12468
|
this.hAlign = props.hAlign ?? _univerjs_core.HorizontalAlign.LEFT;
|
|
12465
12469
|
this.vAlign = props.vAlign ?? _univerjs_core.VerticalAlign.TOP;
|
|
12466
|
-
this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height);
|
|
12470
|
+
this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height, this.lineGap);
|
|
12467
12471
|
}
|
|
12468
12472
|
static drawWith(ctx, props, _skeleton) {
|
|
12469
|
-
const { text, fontStyle, warp, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
|
|
12473
|
+
const { text, fontStyle, warp, lineGap = 0, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
|
|
12470
12474
|
const cachedLayout = !_skeleton && !warp ? Text._getCachedLayout(text, fontStyle) : null;
|
|
12471
|
-
const skeleton = cachedLayout ? null : _skeleton ?? new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === _univerjs_core.VerticalAlign.TOP ? height : Infinity);
|
|
12475
|
+
const skeleton = cachedLayout ? null : _skeleton ?? new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === _univerjs_core.VerticalAlign.TOP ? height : Infinity, lineGap);
|
|
12472
12476
|
const lines = (cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.lines) ?? skeleton.calculate();
|
|
12473
12477
|
const totalHeight = (cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.totalHeight) ?? skeleton.getTotalHeight();
|
|
12474
12478
|
let lineTop = top + (vAlign === _univerjs_core.VerticalAlign.TOP ? 0 : vAlign === _univerjs_core.VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
|
|
@@ -12513,7 +12517,7 @@ var Text = class Text extends Shape {
|
|
|
12513
12517
|
lineWidth: 1,
|
|
12514
12518
|
lineType: _univerjs_core.TextDecoration.SINGLE
|
|
12515
12519
|
});
|
|
12516
|
-
lineTop = lineTop + lineHeight;
|
|
12520
|
+
lineTop = lineTop + lineHeight + lineGap;
|
|
12517
12521
|
}
|
|
12518
12522
|
ctx.restore();
|
|
12519
12523
|
return totalHeight;
|
|
@@ -13912,6 +13916,26 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13912
13916
|
}
|
|
13913
13917
|
};
|
|
13914
13918
|
|
|
13919
|
+
//#endregion
|
|
13920
|
+
//#region src/components/docs/layout/header-footer-field.ts
|
|
13921
|
+
function resolveHeaderFooterFieldGlyph(glyph, startIndex, endIndex, customRanges, pageNumber, pageCount) {
|
|
13922
|
+
var _fieldRange$propertie, _fieldRange$propertie2;
|
|
13923
|
+
if (!glyph.content || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_START || glyph.raw === _univerjs_core.DataStreamTreeTokenType.CUSTOM_RANGE_END) return glyph;
|
|
13924
|
+
const fieldRange = customRanges.find((customRange) => {
|
|
13925
|
+
var _customRange$properti;
|
|
13926
|
+
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";
|
|
13927
|
+
});
|
|
13928
|
+
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();
|
|
13929
|
+
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;
|
|
13930
|
+
if (fieldType === "NUMPAGES" && pageCount == null) return glyph;
|
|
13931
|
+
let content = "";
|
|
13932
|
+
if (startIndex === fieldRange.startIndex + 1) content = String(fieldType === "PAGE" ? pageNumber : pageCount);
|
|
13933
|
+
return content === glyph.content ? glyph : {
|
|
13934
|
+
...glyph,
|
|
13935
|
+
content
|
|
13936
|
+
};
|
|
13937
|
+
}
|
|
13938
|
+
|
|
13915
13939
|
//#endregion
|
|
13916
13940
|
//#region src/components/docs/layout/line-breaker/enhancers/utils.ts
|
|
13917
13941
|
/**
|
|
@@ -16958,7 +16982,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16958
16982
|
if (ctx.isDirty) break;
|
|
16959
16983
|
}
|
|
16960
16984
|
const { segmentId } = curPage;
|
|
16961
|
-
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null)
|
|
16985
|
+
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null) rollbackSectionPages(ctx.layoutStartPointer[segmentId], allCurrentSkeletonPages);
|
|
16962
16986
|
return {
|
|
16963
16987
|
pages: allCurrentSkeletonPages,
|
|
16964
16988
|
renderedBlockIdMap,
|
|
@@ -16966,7 +16990,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16966
16990
|
complete: paragraphEndIndex >= sectionNode.children.length
|
|
16967
16991
|
};
|
|
16968
16992
|
}
|
|
16969
|
-
function
|
|
16993
|
+
function rollbackSectionPages(paragraphIndex, allCurrentSkeletonPages) {
|
|
16970
16994
|
let findFirstDirtyLine = false;
|
|
16971
16995
|
for (let pageIndex = 0; pageIndex < allCurrentSkeletonPages.length; pageIndex++) {
|
|
16972
16996
|
const page = allCurrentSkeletonPages[pageIndex];
|
|
@@ -17050,27 +17074,75 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
17050
17074
|
let header;
|
|
17051
17075
|
let footer;
|
|
17052
17076
|
if (headerId) {
|
|
17053
|
-
var _skeHeaders$get;
|
|
17054
|
-
|
|
17077
|
+
var _headerTreeMap$get, _skeHeaders$get;
|
|
17078
|
+
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;
|
|
17079
|
+
const dynamic = fieldRanges === null || fieldRanges === void 0 ? void 0 : fieldRanges.some((range) => {
|
|
17080
|
+
var _range$properties, _range$properties2, _range$properties3;
|
|
17081
|
+
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");
|
|
17082
|
+
});
|
|
17083
|
+
const key = dynamic ? JSON.stringify([
|
|
17084
|
+
sectionId,
|
|
17085
|
+
pageNumber,
|
|
17086
|
+
pageWidth,
|
|
17087
|
+
marginLeft,
|
|
17088
|
+
marginRight,
|
|
17089
|
+
ctx.hasNumPagesFields ? ctx.fieldPageCount : void 0
|
|
17090
|
+
]) : pageWidth;
|
|
17091
|
+
if (typeof key === "string") page.headerLayoutKey = key;
|
|
17092
|
+
if ((_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.has(key)) {
|
|
17055
17093
|
var _skeHeaders$get2;
|
|
17056
|
-
header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(
|
|
17094
|
+
header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(key);
|
|
17057
17095
|
} else if (headerTreeMap && headerTreeMap.has(headerId)) {
|
|
17058
|
-
|
|
17096
|
+
const previousFieldContext = ctx.headerFooterFieldContext;
|
|
17097
|
+
ctx.headerFooterFieldContext = dynamic ? {
|
|
17098
|
+
pageNumber,
|
|
17099
|
+
pageCount: ctx.fieldPageCount
|
|
17100
|
+
} : void 0;
|
|
17101
|
+
try {
|
|
17102
|
+
header = _createSkeletonHeaderFooter(ctx, headerTreeMap.get(headerId), sectionBreakConfig, skeletonResourceReference, headerId, true);
|
|
17103
|
+
header.fieldsResolved = Boolean(dynamic);
|
|
17104
|
+
} finally {
|
|
17105
|
+
ctx.headerFooterFieldContext = previousFieldContext;
|
|
17106
|
+
}
|
|
17059
17107
|
const widths = skeHeaders.get(headerId) ?? /* @__PURE__ */ new Map();
|
|
17060
|
-
widths.set(
|
|
17108
|
+
widths.set(key, header);
|
|
17061
17109
|
skeHeaders.set(headerId, widths);
|
|
17062
17110
|
}
|
|
17063
17111
|
page.headerId = headerId;
|
|
17064
17112
|
}
|
|
17065
17113
|
if (footerId) {
|
|
17066
|
-
var _skeFooters$get;
|
|
17067
|
-
|
|
17114
|
+
var _footerTreeMap$get, _skeFooters$get;
|
|
17115
|
+
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;
|
|
17116
|
+
const dynamic = fieldRanges === null || fieldRanges === void 0 ? void 0 : fieldRanges.some((range) => {
|
|
17117
|
+
var _range$properties4, _range$properties5, _range$properties6;
|
|
17118
|
+
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");
|
|
17119
|
+
});
|
|
17120
|
+
const key = dynamic ? JSON.stringify([
|
|
17121
|
+
sectionId,
|
|
17122
|
+
pageNumber,
|
|
17123
|
+
pageWidth,
|
|
17124
|
+
marginLeft,
|
|
17125
|
+
marginRight,
|
|
17126
|
+
ctx.hasNumPagesFields ? ctx.fieldPageCount : void 0
|
|
17127
|
+
]) : pageWidth;
|
|
17128
|
+
if (typeof key === "string") page.footerLayoutKey = key;
|
|
17129
|
+
if ((_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.has(key)) {
|
|
17068
17130
|
var _skeFooters$get2;
|
|
17069
|
-
footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(
|
|
17131
|
+
footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(key);
|
|
17070
17132
|
} else if (footerTreeMap && footerTreeMap.has(footerId)) {
|
|
17071
|
-
|
|
17133
|
+
const previousFieldContext = ctx.headerFooterFieldContext;
|
|
17134
|
+
ctx.headerFooterFieldContext = dynamic ? {
|
|
17135
|
+
pageNumber,
|
|
17136
|
+
pageCount: ctx.fieldPageCount
|
|
17137
|
+
} : void 0;
|
|
17138
|
+
try {
|
|
17139
|
+
footer = _createSkeletonHeaderFooter(ctx, footerTreeMap.get(footerId), sectionBreakConfig, skeletonResourceReference, footerId, false);
|
|
17140
|
+
footer.fieldsResolved = Boolean(dynamic);
|
|
17141
|
+
} finally {
|
|
17142
|
+
ctx.headerFooterFieldContext = previousFieldContext;
|
|
17143
|
+
}
|
|
17072
17144
|
const widths = skeFooters.get(footerId) ?? /* @__PURE__ */ new Map();
|
|
17073
|
-
widths.set(
|
|
17145
|
+
widths.set(key, footer);
|
|
17074
17146
|
skeFooters.set(footerId, widths);
|
|
17075
17147
|
}
|
|
17076
17148
|
page.footerId = footerId;
|
|
@@ -17079,6 +17151,29 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
17079
17151
|
page.originMarginBottom = marginBottom;
|
|
17080
17152
|
page.marginTop = _getVerticalMargin(marginTop, header);
|
|
17081
17153
|
page.marginBottom = _getVerticalMargin(marginBottom, footer);
|
|
17154
|
+
if (ctx.headerFooterMinimumMargins) for (const [id, layoutKey, margin] of [[
|
|
17155
|
+
headerId,
|
|
17156
|
+
page.headerLayoutKey,
|
|
17157
|
+
"marginTop"
|
|
17158
|
+
], [
|
|
17159
|
+
footerId,
|
|
17160
|
+
page.footerLayoutKey,
|
|
17161
|
+
"marginBottom"
|
|
17162
|
+
]]) {
|
|
17163
|
+
if (layoutKey == null) continue;
|
|
17164
|
+
const key = JSON.stringify([
|
|
17165
|
+
id,
|
|
17166
|
+
sectionId,
|
|
17167
|
+
pageNumber,
|
|
17168
|
+
pageWidth,
|
|
17169
|
+
marginLeft,
|
|
17170
|
+
marginRight,
|
|
17171
|
+
margin
|
|
17172
|
+
]);
|
|
17173
|
+
const maximum = Math.max(page[margin], ctx.headerFooterMinimumMargins.get(key) ?? 0);
|
|
17174
|
+
ctx.headerFooterMinimumMargins.set(key, maximum);
|
|
17175
|
+
if (ctx.fieldCountCycle) page[margin] = maximum;
|
|
17176
|
+
}
|
|
17082
17177
|
const sections = page.sections;
|
|
17083
17178
|
const lastSection = sections[sections.length - 1];
|
|
17084
17179
|
const { marginTop: curPageMT, marginBottom: curPageMB, marginLeft: curPageML, marginRight: curPageMR } = page;
|
|
@@ -17395,8 +17490,13 @@ function resetCellDrawingAnchors(ctx, cellNode, tableId) {
|
|
|
17395
17490
|
if (!anchors) return;
|
|
17396
17491
|
for (const paragraph of cellNode.children[0].children) anchors.delete(paragraph.endIndex);
|
|
17397
17492
|
}
|
|
17398
|
-
function createSkeletonCellPages(
|
|
17493
|
+
function createSkeletonCellPages(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17399
17494
|
var _ctx$dataModel, _ctx$dataModel$getBod;
|
|
17495
|
+
const ctx = {
|
|
17496
|
+
...parentContext,
|
|
17497
|
+
isDirty: false,
|
|
17498
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17499
|
+
};
|
|
17400
17500
|
const sectionNode = cellNode.children[0];
|
|
17401
17501
|
const body = (_ctx$dataModel = ctx.dataModel) === null || _ctx$dataModel === void 0 || (_ctx$dataModel$getBod = _ctx$dataModel.getBody) === null || _ctx$dataModel$getBod === void 0 ? void 0 : _ctx$dataModel$getBod.call(_ctx$dataModel);
|
|
17402
17502
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
@@ -17435,7 +17535,12 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
|
|
|
17435
17535
|
finishVerticalCellLayout(pages, verticalCellWidth);
|
|
17436
17536
|
return pages;
|
|
17437
17537
|
}
|
|
17438
|
-
function startSkeletonCellPagesBuild(
|
|
17538
|
+
function startSkeletonCellPagesBuild(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17539
|
+
const ctx = {
|
|
17540
|
+
...parentContext,
|
|
17541
|
+
isDirty: false,
|
|
17542
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17543
|
+
};
|
|
17439
17544
|
const sectionNode = cellNode.children[0];
|
|
17440
17545
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
17441
17546
|
const { page, sectionBreakConfig: cellSectionBreakConfig, verticalCellWidth } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight, inheritDocumentLinePitch, enableDocumentTableLineGrid, cellPageHeights);
|
|
@@ -18141,6 +18246,7 @@ function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBrea
|
|
|
18141
18246
|
marginTop: 0,
|
|
18142
18247
|
spaceBelowApply: (preLine === null || preLine === void 0 ? void 0 : preLine.spaceBelowApply) ?? 0
|
|
18143
18248
|
} : __getParagraphSpace(((_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) === null || _sectionBreakConfig$d2 === void 0 ? void 0 : _sectionBreakConfig$d2.mode) === "drawingml", lineSpacingApply, suppressCellAutoSpaceAbove ? void 0 : spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine, _shouldSuppressPageTopSpacing(lastPage, column, paragraphConfig, preLine, firstPageNumber, startingSection != null), drawingMLLineHeight);
|
|
18249
|
+
if (preLine) marginTop += sectionBreakConfig.lineGap ?? 0;
|
|
18144
18250
|
if (startingSection && marginTop > 0 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy)) marginTop = _collapseSectionBeforeSpacing(ctx, startingSection.children[0].startIndex - 2, marginTop);
|
|
18145
18251
|
if (positionedCustomBlockOnly) spaceBelowApply = 0;
|
|
18146
18252
|
const isHiddenCellEndMark = lastPage.type === 3 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy) && sectionBreakConfig.cellHiddenEndMarkIndex === paragraphIndex && paragraphConfig.bulletSkeleton == null && glyphGroup.length > 0 && glyphGroup.every(__isStructuralTerminatorGlyph);
|
|
@@ -18278,8 +18384,8 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18278
18384
|
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
18385
|
const lineTop = preLineHeight + ((preLine === null || preLine === void 0 ? void 0 : preLine.top) ?? initialFootnoteTop);
|
|
18280
18386
|
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);
|
|
18387
|
+
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);
|
|
18388
|
+
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
18389
|
let needOpenNewPageByTableLayout = false;
|
|
18284
18390
|
const { deferredInlineGroupAnchorDrawings, deferredTopBottomAnchorDrawings } = _positionLineDrawings(ctx, glyphGroup, column, lastPage, paragraphConfig, lineTop, lineHeight, paragraphAnchorLeft, hasInlineCustomBlock, isParagraphFirstShapedText);
|
|
18285
18391
|
if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
|
|
@@ -18340,7 +18446,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18340
18446
|
if (borderTopSpace > 0) newLine.borderTopSpace = borderTopSpace;
|
|
18341
18447
|
if (borderBottomSpace > 0) newLine.borderBottomSpace = borderBottomSpace;
|
|
18342
18448
|
const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
|
|
18343
|
-
if (!isStandalonePageBoundary)
|
|
18449
|
+
if (!isStandalonePageBoundary) {
|
|
18450
|
+
createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
|
|
18451
|
+
const paragraphDrawingAnchor = pDrawingAnchor === null || pDrawingAnchor === void 0 ? void 0 : pDrawingAnchor.get(paragraphIndex);
|
|
18452
|
+
if (paragraphDrawingAnchor) paragraphDrawingAnchor.left = paragraphAnchorLeft;
|
|
18453
|
+
}
|
|
18344
18454
|
if (deferredTopBottomAnchorDrawings.length > 0) {
|
|
18345
18455
|
__updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, false, true);
|
|
18346
18456
|
__updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings, section.top);
|
|
@@ -18355,6 +18465,10 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
|
|
|
18355
18465
|
if (targetDrawings.length === 0) return;
|
|
18356
18466
|
const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
|
|
18357
18467
|
if (drawings == null || drawings.size === 0) return;
|
|
18468
|
+
for (const drawing of drawings.values()) if (drawing.drawingOrigin.docTransform.positionV.relativeFrom === _univerjs_core.ObjectRelativeFromV.LINE) {
|
|
18469
|
+
var _ctx$skeletonResource;
|
|
18470
|
+
drawing.blockAnchorLeft = ((_ctx$skeletonResource = ctx.skeletonResourceReference) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.drawingAnchor) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.get(column.parent.parent.segmentId)) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.get(paragraphIndex)) === null || _ctx$skeletonResource === void 0 ? void 0 : _ctx$skeletonResource.left) ?? drawing.blockAnchorLeft;
|
|
18471
|
+
}
|
|
18358
18472
|
const floatObjects = [...drawings.values()].filter((drawing) => {
|
|
18359
18473
|
const layoutType = drawing.drawingOrigin.layoutType;
|
|
18360
18474
|
return layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE && layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE;
|
|
@@ -18827,7 +18941,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
|
|
|
18827
18941
|
lineSpacingApply: exactLineSpacingApply
|
|
18828
18942
|
};
|
|
18829
18943
|
}
|
|
18830
|
-
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy) {
|
|
18944
|
+
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy, blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = false) {
|
|
18831
18945
|
var _line$parent;
|
|
18832
18946
|
const column = line.parent;
|
|
18833
18947
|
const section = column === null || column === void 0 ? void 0 : column.parent;
|
|
@@ -18893,6 +19007,9 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId =
|
|
|
18893
19007
|
drawing.lineTop = lineTop;
|
|
18894
19008
|
drawing.columnLeft = column.left;
|
|
18895
19009
|
drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
|
|
19010
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19011
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor;
|
|
19012
|
+
drawing.pageAnchorLeft = normalizeTraditionalColumnAnchor ? page.marginLeft : 0;
|
|
18896
19013
|
drawing.lineHeight = line.lineHeight;
|
|
18897
19014
|
drawings.set(drawing.drawingId, drawing);
|
|
18898
19015
|
}
|
|
@@ -18950,6 +19067,9 @@ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirst
|
|
|
18950
19067
|
} : void 0;
|
|
18951
19068
|
drawing.initialState = true;
|
|
18952
19069
|
drawing.columnLeft = column.left;
|
|
19070
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19071
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL;
|
|
19072
|
+
drawing.pageAnchorLeft = ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL ? page.marginLeft : 0;
|
|
18953
19073
|
drawing.lineTop = absoluteLineTop;
|
|
18954
19074
|
drawing.lineHeight = lineHeight;
|
|
18955
19075
|
drawing.isPageBreak = isPageBreak;
|
|
@@ -19365,7 +19485,7 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
|
|
|
19365
19485
|
const drawingAnchor = (_ctx$skeletonResource = ctx.skeletonResourceReference) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.drawingAnchor) === null || _ctx$skeletonResource === void 0 || (_ctx$skeletonResource = _ctx$skeletonResource.get(segmentId)) === null || _ctx$skeletonResource === void 0 ? void 0 : _ctx$skeletonResource.get(line.paragraphIndex);
|
|
19366
19486
|
if (affectInlineDrawings && affectInlineDrawings.size > 0) {
|
|
19367
19487
|
var _ctx$dataModel$getUni, _ctx$dataModel;
|
|
19368
|
-
updateInlineDrawingPosition(line, affectInlineDrawings, ((_ctx$dataModel$getUni = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni === void 0 ? void 0 : _ctx$dataModel$getUni.call(_ctx$dataModel)) ?? "", drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings, paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.documentCompatibilityPolicy);
|
|
19488
|
+
updateInlineDrawingPosition(line, affectInlineDrawings, ((_ctx$dataModel$getUni = (_ctx$dataModel = ctx.dataModel).getUnitId) === null || _ctx$dataModel$getUni === void 0 ? void 0 : _ctx$dataModel$getUni.call(_ctx$dataModel)) ?? "", drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings, paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.documentCompatibilityPolicy, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.left, ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL);
|
|
19369
19489
|
}
|
|
19370
19490
|
const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
|
|
19371
19491
|
const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
|
|
@@ -19485,7 +19605,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
19485
19605
|
unitId
|
|
19486
19606
|
});
|
|
19487
19607
|
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);
|
|
19608
|
+
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
19609
|
if (headerPage != null) collectPageTables({
|
|
19490
19610
|
contexts,
|
|
19491
19611
|
docsLeft,
|
|
@@ -19500,7 +19620,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
19500
19620
|
tableCellInsetX,
|
|
19501
19621
|
unitId
|
|
19502
19622
|
});
|
|
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);
|
|
19623
|
+
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
19624
|
if (footerPage != null) collectPageTables({
|
|
19505
19625
|
contexts,
|
|
19506
19626
|
docsLeft,
|
|
@@ -21096,6 +21216,26 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
21096
21216
|
for (const glyph of shapedGlyphs) if (isCjkLeftAlignedPunctuation(glyph.content) || isCjkRightAlignedPunctuation(glyph.content) || isCjkCenterAlignedPunctuation(glyph.content)) glyph.adjustability.shrinkability = [0, 0];
|
|
21097
21217
|
}
|
|
21098
21218
|
if (((_sectionBreakConfig$r5 = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r5 === void 0 ? void 0 : _sectionBreakConfig$r5.preservePunctuationSpacing) !== _univerjs_core.BooleanNumber.TRUE && (!traditionalLayout || fixedPunctuationPairs)) punctuationSpaceAdjustment(shapedGlyphs, fixedPunctuationPairs);
|
|
21219
|
+
if (ctx.headerFooterFieldContext) {
|
|
21220
|
+
let index = paragraphNode.contentStartIndex + last;
|
|
21221
|
+
for (let glyphIndex = 0; glyphIndex < shapedGlyphs.length; glyphIndex++) {
|
|
21222
|
+
var _viewModel$getBody3, _glyph$fontStyle, _glyph$ts2;
|
|
21223
|
+
const glyph = shapedGlyphs[glyphIndex];
|
|
21224
|
+
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);
|
|
21225
|
+
index += glyph.count;
|
|
21226
|
+
if (resolved === glyph) continue;
|
|
21227
|
+
const font = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.fontString;
|
|
21228
|
+
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;
|
|
21229
|
+
shapedGlyphs[glyphIndex] = {
|
|
21230
|
+
...resolved,
|
|
21231
|
+
width: Math.max(0, glyph.width + widthDelta),
|
|
21232
|
+
bBox: {
|
|
21233
|
+
...glyph.bBox,
|
|
21234
|
+
width: Math.max(0, glyph.bBox.width + widthDelta)
|
|
21235
|
+
}
|
|
21236
|
+
};
|
|
21237
|
+
}
|
|
21238
|
+
}
|
|
21099
21239
|
appendShapedText(shapedTextList, shapedGlyphs, bk.type, paragraphStyle.fixedTabStops === _univerjs_core.BooleanNumber.TRUE);
|
|
21100
21240
|
last = bk.position;
|
|
21101
21241
|
}
|
|
@@ -21107,8 +21247,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
21107
21247
|
//#endregion
|
|
21108
21248
|
//#region src/components/docs/layout/document-layout-page-patch.ts
|
|
21109
21249
|
function withoutParent(value) {
|
|
21110
|
-
const
|
|
21111
|
-
delete copy.parent;
|
|
21250
|
+
const { parent: _parent, ...copy } = value;
|
|
21112
21251
|
return copy;
|
|
21113
21252
|
}
|
|
21114
21253
|
function serializeDivide(source) {
|
|
@@ -21176,10 +21315,10 @@ function serializeDocumentSkeletonPage(source, omitResourceSources = false) {
|
|
|
21176
21315
|
return {
|
|
21177
21316
|
...geometry,
|
|
21178
21317
|
sections: source.sections.map(serializeSection),
|
|
21179
|
-
noteDecorations
|
|
21318
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21180
21319
|
...decoration,
|
|
21181
21320
|
page: serializeDocumentSkeletonPage(decoration.page, omitResourceSources)
|
|
21182
|
-
})),
|
|
21321
|
+
})) },
|
|
21183
21322
|
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21184
21323
|
...withoutParent(note),
|
|
21185
21324
|
page: serializeDocumentSkeletonPage(note.page, omitResourceSources)
|
|
@@ -21319,18 +21458,18 @@ function hydrateDocumentSkeletonPageMaterializationPlaceholder(source, parent) {
|
|
|
21319
21458
|
return placeholder;
|
|
21320
21459
|
}
|
|
21321
21460
|
function hydrateDocumentSkeletonPageInternal(source, parent, snapshot, resourceSegmentId) {
|
|
21322
|
-
|
|
21461
|
+
const { notes, noteDecorations, ...geometry } = source;
|
|
21323
21462
|
const page = {
|
|
21324
|
-
...
|
|
21463
|
+
...geometry,
|
|
21325
21464
|
sections: [],
|
|
21326
|
-
noteDecorations
|
|
21465
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21327
21466
|
...decoration,
|
|
21328
21467
|
page: hydrateDocumentSkeletonPageInternal(decoration.page, void 0, snapshot, decoration.page.segmentId)
|
|
21329
|
-
})),
|
|
21330
|
-
notes
|
|
21468
|
+
})) },
|
|
21469
|
+
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21331
21470
|
...note,
|
|
21332
21471
|
page: hydrateDocumentSkeletonPageInternal(note.page, void 0, snapshot, note.noteId)
|
|
21333
|
-
})),
|
|
21472
|
+
})) },
|
|
21334
21473
|
skeDrawings: new Map(source.skeDrawings.map(([drawingId, drawing]) => [drawingId, hydrateDrawing(drawing, snapshot, resourceSegmentId)])),
|
|
21335
21474
|
skeTables: /* @__PURE__ */ new Map(),
|
|
21336
21475
|
skeColumnGroups: /* @__PURE__ */ new Map(),
|
|
@@ -23203,6 +23342,8 @@ function serializePaginatedContinuationCheckpoint(page) {
|
|
|
23203
23342
|
sectionId: page.sectionId,
|
|
23204
23343
|
headerId: page.headerId,
|
|
23205
23344
|
footerId: page.footerId,
|
|
23345
|
+
headerLayoutKey: page.headerLayoutKey,
|
|
23346
|
+
footerLayoutKey: page.footerLayoutKey,
|
|
23206
23347
|
pageWidth: page.pageWidth,
|
|
23207
23348
|
pageHeight: page.pageHeight,
|
|
23208
23349
|
pageOrient: page.pageOrient,
|
|
@@ -23279,7 +23420,7 @@ function getSegmentPageFromRelativePath(skeletonData, segmentPageIndex, path) {
|
|
|
23279
23420
|
const rootPage = skeletonData.pages[segmentPageIndex];
|
|
23280
23421
|
if (rootPage == null) return null;
|
|
23281
23422
|
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)];
|
|
23423
|
+
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
23424
|
for (const segmentPage of segmentPages) {
|
|
23284
23425
|
if (segmentPage == null) continue;
|
|
23285
23426
|
const page = getPageFromPath({
|
|
@@ -23310,6 +23451,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23310
23451
|
_defineProperty(this, "_languageDetector", LanguageDetector.getInstance());
|
|
23311
23452
|
_defineProperty(this, "_initialWidth", 0);
|
|
23312
23453
|
_defineProperty(this, "_paginationMetrics", null);
|
|
23454
|
+
_defineProperty(this, "_completedPageCount", void 0);
|
|
23313
23455
|
_defineProperty(this, "_lastCompleteSkeletonData", null);
|
|
23314
23456
|
_defineProperty(this, "_pendingInvalidationAnchor", null);
|
|
23315
23457
|
_defineProperty(this, "_layoutGeneration", 0);
|
|
@@ -23322,7 +23464,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23322
23464
|
_defineProperty(this, "_isolateIncrementalPublications", void 0);
|
|
23323
23465
|
_defineProperty(this, "_modernPageWidth", void 0);
|
|
23324
23466
|
_defineProperty(this, "_modernHorizontalMargin", void 0);
|
|
23467
|
+
_defineProperty(this, "_lineGap", void 0);
|
|
23325
23468
|
this._isolateIncrementalPublications = options.isolateIncrementalPublications !== false;
|
|
23469
|
+
this._lineGap = options.lineGap ?? 0;
|
|
23326
23470
|
}
|
|
23327
23471
|
static create(docViewModel, localeService, options) {
|
|
23328
23472
|
return new DocumentSkeleton(docViewModel, localeService, options);
|
|
@@ -23334,6 +23478,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23334
23478
|
this._layoutPageMaterialized$.complete();
|
|
23335
23479
|
this._skeletonData = null;
|
|
23336
23480
|
this._lastCompleteSkeletonData = null;
|
|
23481
|
+
this._completedPageCount = void 0;
|
|
23337
23482
|
this._pendingInvalidationAnchor = null;
|
|
23338
23483
|
this._externalLayoutProgress = null;
|
|
23339
23484
|
this._externalProtectedPages = null;
|
|
@@ -23351,14 +23496,21 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23351
23496
|
* PS: This method has significant impact on performance.
|
|
23352
23497
|
*/
|
|
23353
23498
|
calculate(bounds) {
|
|
23499
|
+
var _this$_skeletonData;
|
|
23354
23500
|
if (!this.dirty) return;
|
|
23355
23501
|
this.cancelIncrementalLayout();
|
|
23356
23502
|
this._externalLayoutProgress = null;
|
|
23357
23503
|
this._externalProtectedPages = null;
|
|
23358
23504
|
this._externalProtectedContinuousLayout = null;
|
|
23359
|
-
|
|
23360
|
-
|
|
23505
|
+
let ctx = this._prepareLayoutContext();
|
|
23506
|
+
while (true) {
|
|
23507
|
+
this._skeletonData = this._createSkeleton(ctx, bounds);
|
|
23508
|
+
const retry = this._prepareFieldCountRetry(ctx);
|
|
23509
|
+
if (retry == null) break;
|
|
23510
|
+
ctx = retry;
|
|
23511
|
+
}
|
|
23361
23512
|
this._lastCompleteSkeletonData = this._skeletonData;
|
|
23513
|
+
this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
|
|
23362
23514
|
this._pendingInvalidationAnchor = null;
|
|
23363
23515
|
this._paginationMetrics = ctx.paginationMetrics ?? null;
|
|
23364
23516
|
this._dirty$.next(true);
|
|
@@ -23432,6 +23584,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23432
23584
|
lastPublishedBlockCount: incrementalStart.processedBlockCount,
|
|
23433
23585
|
publicationRevision: 0,
|
|
23434
23586
|
reuseUnaffectedTail: (options === null || options === void 0 ? void 0 : options.reuseUnaffectedTail) !== false,
|
|
23587
|
+
paginationRevision: 0,
|
|
23435
23588
|
allowMetadataOnlyStructuralTailReuse: (options === null || options === void 0 ? void 0 : options.allowMetadataOnlyStructuralTailReuse) === true,
|
|
23436
23589
|
reusedTail: false,
|
|
23437
23590
|
tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
|
|
@@ -23478,7 +23631,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23478
23631
|
const hasEarlierOverlappingRange = anchorPageIndex > 0 && previousSkeleton.pages.slice(0, anchorPageIndex).some((page) => previousAnchor >= page.st && previousAnchor <= page.ed);
|
|
23479
23632
|
const anchorBlockOwnsTable = blocks[anchorBlockIndex].block.children.some((child) => child.nodeType === _univerjs_core.DataStreamTreeNodeType.TABLE && anchor >= child.startIndex && anchor <= child.endIndex);
|
|
23480
23633
|
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)) {
|
|
23634
|
+
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
23635
|
const interactionPreviousAnchor = mapCurrentOffsetToPrevious(anchor, invalidation);
|
|
23483
23636
|
const interactionPageIndex = interactionSkeleton == null ? -1 : this._findBodyPageIndex(interactionSkeleton.pages, interactionPreviousAnchor);
|
|
23484
23637
|
const paginatedPrefix = this._preparePaginatedParagraphPrefix(ctx, interactionSkeleton ?? previousSkeleton, blocks[anchorBlockIndex], anchorBlockIndex, interactionPageIndex, invalidation);
|
|
@@ -23808,11 +23961,13 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23808
23961
|
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
23962
|
let didPublish = false;
|
|
23810
23963
|
let didPublishAnchor = false;
|
|
23811
|
-
if (!state.cancelled && canPublish && (!suppressPreAnchorPublication || shouldPublishPriority || state.complete)) {
|
|
23964
|
+
if (!state.cancelled && canPublish && (state.ctx.fieldCountCandidates == null || state.complete) && (!suppressPreAnchorPublication || shouldPublishPriority || state.complete)) {
|
|
23812
23965
|
if (state.mode === "paginated") this._finalizePaginatedPagesForPublication(state, publishedPageCount);
|
|
23813
23966
|
const isFinalPublication = state.complete && publishedPageCount >= pageCount;
|
|
23814
23967
|
if (isFinalPublication) {
|
|
23968
|
+
var _state$ctx$skeleton;
|
|
23815
23969
|
this._lastCompleteSkeletonData = state.ctx.skeleton;
|
|
23970
|
+
this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
|
|
23816
23971
|
this._pendingInvalidationAnchor = null;
|
|
23817
23972
|
}
|
|
23818
23973
|
this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
|
|
@@ -23954,9 +24109,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23954
24109
|
* page or block range while the external executor publishes a newer tail.
|
|
23955
24110
|
*/
|
|
23956
24111
|
beginExternalLayout(options) {
|
|
23957
|
-
var _this$
|
|
24112
|
+
var _this$_skeletonData2;
|
|
23958
24113
|
this.cancelIncrementalLayout();
|
|
23959
|
-
const pages = ((_this$
|
|
24114
|
+
const pages = ((_this$_skeletonData2 = this._skeletonData) === null || _this$_skeletonData2 === void 0 ? void 0 : _this$_skeletonData2.pages) ?? [];
|
|
23960
24115
|
const protectedRange = options.protectedRange;
|
|
23961
24116
|
const protectedPageRange = (protectedRange === null || protectedRange === void 0 ? void 0 : protectedRange.mode) === "paginated" ? protectedRange : void 0;
|
|
23962
24117
|
if (protectedPageRange == null) this._externalProtectedPages = null;
|
|
@@ -24113,6 +24268,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24113
24268
|
if (progress.complete) {
|
|
24114
24269
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24115
24270
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24271
|
+
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24116
24272
|
this._pendingInvalidationAnchor = null;
|
|
24117
24273
|
this._externalProtectedContinuousLayout = null;
|
|
24118
24274
|
}
|
|
@@ -24182,6 +24338,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24182
24338
|
if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
|
|
24183
24339
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24184
24340
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24341
|
+
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24185
24342
|
this._pendingInvalidationAnchor = null;
|
|
24186
24343
|
this._externalProtectedPages = null;
|
|
24187
24344
|
this._externalProtectedContinuousLayout = null;
|
|
@@ -24391,8 +24548,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24391
24548
|
};
|
|
24392
24549
|
}
|
|
24393
24550
|
findBodyPageIndexByCharIndex(charIndex) {
|
|
24394
|
-
var _this$
|
|
24395
|
-
return this._findBodyPageIndex(((_this$
|
|
24551
|
+
var _this$_skeletonData3;
|
|
24552
|
+
return this._findBodyPageIndex(((_this$_skeletonData3 = this._skeletonData) === null || _this$_skeletonData3 === void 0 ? void 0 : _this$_skeletonData3.pages) ?? [], charIndex);
|
|
24396
24553
|
}
|
|
24397
24554
|
findNodeByCharIndex(charIndex, segmentId = "", segmentPageIndex = -1) {
|
|
24398
24555
|
const nodes = this._findNodeByIndex(charIndex, segmentId, segmentPageIndex);
|
|
@@ -24411,12 +24568,12 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24411
24568
|
const { headerId, footerId, pageWidth } = skePage;
|
|
24412
24569
|
if (pageType === 1) {
|
|
24413
24570
|
var _skeHeaders$get;
|
|
24414
|
-
const skeHeader = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
24571
|
+
const skeHeader = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(skePage.headerLayoutKey ?? pageWidth);
|
|
24415
24572
|
if (skeHeader == null) return;
|
|
24416
24573
|
else skePage = skeHeader;
|
|
24417
24574
|
} else if (pageType === 2) {
|
|
24418
24575
|
var _skeFooters$get;
|
|
24419
|
-
const skeFooter = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
24576
|
+
const skeFooter = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(skePage.footerLayoutKey ?? pageWidth);
|
|
24420
24577
|
if (skeFooter == null) return;
|
|
24421
24578
|
else skePage = skeFooter;
|
|
24422
24579
|
}
|
|
@@ -24524,9 +24681,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24524
24681
|
let exactMatch = null;
|
|
24525
24682
|
if (editArea === "HEADER" || editArea === "FOOTER") {
|
|
24526
24683
|
var _skeHeaders$get2, _skeFooters$get2;
|
|
24527
|
-
const headerSke = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(pageWidth);
|
|
24684
|
+
const headerSke = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(page.headerLayoutKey ?? pageWidth);
|
|
24528
24685
|
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);
|
|
24686
|
+
const footerSke = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(page.footerLayoutKey ?? pageWidth);
|
|
24530
24687
|
if (footerSke) exactMatch = exactMatch ?? this._collectNearestNode(footerSke, 2, page, footerId, pi, cache, x, y, pageLength);
|
|
24531
24688
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24532
24689
|
if (exactMatch) return exactMatch;
|
|
@@ -24548,9 +24705,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24548
24705
|
const { headerId, footerId, pageWidth } = page;
|
|
24549
24706
|
if (segmentId !== "" && !this._docViewModel.getNoteTreeMap().has(segmentId)) {
|
|
24550
24707
|
var _skeHeaders$get3, _skeFooters$get3;
|
|
24551
|
-
const headerSke = (_skeHeaders$get3 = skeHeaders.get(headerId)) === null || _skeHeaders$get3 === void 0 ? void 0 : _skeHeaders$get3.get(pageWidth);
|
|
24708
|
+
const headerSke = (_skeHeaders$get3 = skeHeaders.get(headerId)) === null || _skeHeaders$get3 === void 0 ? void 0 : _skeHeaders$get3.get(page.headerLayoutKey ?? pageWidth);
|
|
24552
24709
|
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);
|
|
24710
|
+
const footerSke = (_skeFooters$get3 = skeFooters.get(footerId)) === null || _skeFooters$get3 === void 0 ? void 0 : _skeFooters$get3.get(page.footerLayoutKey ?? pageWidth);
|
|
24554
24711
|
if (footerSke) exactMatch = exactMatch ?? this._collectNearestNode(footerSke, 2, page, footerId, pi, cache, x, y, pageLength);
|
|
24555
24712
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24556
24713
|
if (exactMatch) return exactMatch;
|
|
@@ -24565,7 +24722,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24565
24722
|
continue;
|
|
24566
24723
|
}
|
|
24567
24724
|
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);
|
|
24725
|
+
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
24726
|
if (segmentSke) exactMatch = this._collectNearestNode(segmentSke, segmentId === headerId ? 1 : 2, page, segmentId, segmentPage, cache, x, y, pageLength);
|
|
24570
24727
|
} else exactMatch = this._collectNearestNode(page, 0, page, "", pi, cache, x, y, pageLength);
|
|
24571
24728
|
if (exactMatch) return exactMatch;
|
|
@@ -24735,11 +24892,13 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24735
24892
|
if (!isHitTestAddressableGlyph(glyph)) continue;
|
|
24736
24893
|
const startX = divideLeft + glyph.left;
|
|
24737
24894
|
const endX = startX + glyph.width;
|
|
24895
|
+
const contentTop = startY + (line.marginTop ?? 0) + (line.paddingTop ?? 0);
|
|
24738
24896
|
const node = {
|
|
24739
24897
|
node: glyph,
|
|
24740
24898
|
...segment,
|
|
24741
24899
|
ratioX: x / (startX + endX),
|
|
24742
|
-
ratioY: y / (startY + endY)
|
|
24900
|
+
ratioY: y / (startY + endY),
|
|
24901
|
+
isInsideGlyph: x >= startX && x <= endX && y >= contentTop && y <= contentTop + line.contentHeight
|
|
24743
24902
|
};
|
|
24744
24903
|
if (sameLine && x >= startX && x <= endX) return node;
|
|
24745
24904
|
if (distanceY < nearestDistanceY) {
|
|
@@ -24790,7 +24949,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24790
24949
|
node: glyph,
|
|
24791
24950
|
...segment,
|
|
24792
24951
|
ratioX: x / (startX + endX),
|
|
24793
|
-
ratioY: y / (startY + endY)
|
|
24952
|
+
ratioY: y / (startY + endY),
|
|
24953
|
+
isInsideGlyph: x >= startX && x <= endX && sameLine
|
|
24794
24954
|
};
|
|
24795
24955
|
const hitsGlyphAdvance = x >= startX && x <= endX;
|
|
24796
24956
|
if (sameLine) {
|
|
@@ -24892,6 +25052,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24892
25052
|
return {
|
|
24893
25053
|
generation: state.generation,
|
|
24894
25054
|
publicationRevision: state.publicationRevision,
|
|
25055
|
+
paginationRevision: state.paginationRevision,
|
|
24895
25056
|
didPublish,
|
|
24896
25057
|
didPublishAnchor,
|
|
24897
25058
|
publishedPageCount: state.lastPublishedPageCount,
|
|
@@ -25359,6 +25520,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25359
25520
|
const section = sections[sectionIndex];
|
|
25360
25521
|
const paragraphIndex = Math.max(0, (section === null || section === void 0 ? void 0 : section.children.findIndex(({ endIndex }) => endIndex === layoutAnchor)) ?? 0);
|
|
25361
25522
|
const processedBeforeSection = sections.slice(0, sectionIndex).reduce((count, item) => count + item.children.length, 0);
|
|
25523
|
+
rollbackSectionPages(layoutAnchor, ctx.skeleton.pages);
|
|
25362
25524
|
state.sectionIndex = sectionIndex;
|
|
25363
25525
|
state.paragraphIndex = paragraphIndex;
|
|
25364
25526
|
state.sectionInitialized = false;
|
|
@@ -25411,10 +25573,52 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25411
25573
|
}
|
|
25412
25574
|
for (const hSkeMap of skeleton.skeHeaders.values()) for (const page of hSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
|
|
25413
25575
|
for (const fSkeMap of skeleton.skeFooters.values()) for (const page of fSkeMap.values()) updateInlineDrawingCoordsAndBorder(ctx, [page]);
|
|
25576
|
+
const retry = this._prepareFieldCountRetry(ctx);
|
|
25577
|
+
if (retry != null) {
|
|
25578
|
+
state.paginationRevision++;
|
|
25579
|
+
state.ctx = retry;
|
|
25580
|
+
state.sectionIndex = 0;
|
|
25581
|
+
state.paragraphIndex = 0;
|
|
25582
|
+
state.sectionInitialized = false;
|
|
25583
|
+
state.sectionBreakConfig = null;
|
|
25584
|
+
state.layoutAnchor = null;
|
|
25585
|
+
state.laidOutThrough = -1;
|
|
25586
|
+
state.stableLaidOutThrough = -1;
|
|
25587
|
+
state.processedBlockCount = 0;
|
|
25588
|
+
state.pendingTableBuild = null;
|
|
25589
|
+
state.pendingSlicedTableBuild = null;
|
|
25590
|
+
state.pendingParagraphCheckpoint = null;
|
|
25591
|
+
state.stablePageCount = 0;
|
|
25592
|
+
state.finalizedPageCount = 0;
|
|
25593
|
+
state.lastPublishedPageCount = 0;
|
|
25594
|
+
state.lastPublishedBlockCount = 0;
|
|
25595
|
+
state.anchorPublished = false;
|
|
25596
|
+
state.reuseUnaffectedTail = false;
|
|
25597
|
+
state.reusedTail = false;
|
|
25598
|
+
state.tailConvergencePageCount = 0;
|
|
25599
|
+
state.interactionPageTail = null;
|
|
25600
|
+
state.interactionPageComplete = false;
|
|
25601
|
+
state.interactionWindowComplete = false;
|
|
25602
|
+
state.interactionWindowResume = null;
|
|
25603
|
+
return;
|
|
25604
|
+
}
|
|
25414
25605
|
setPageParent(skeleton.pages, skeleton);
|
|
25415
25606
|
state.complete = true;
|
|
25416
25607
|
state.stableLaidOutThrough = state.laidOutThrough;
|
|
25417
25608
|
}
|
|
25609
|
+
getCompletedPageCount() {
|
|
25610
|
+
return this._completedPageCount;
|
|
25611
|
+
}
|
|
25612
|
+
_prepareFieldCountRetry(ctx) {
|
|
25613
|
+
if (!ctx.hasNumPagesFields || ctx.fieldPageCount === ctx.skeleton.pages.length) return null;
|
|
25614
|
+
const retry = this._prepareLayoutContext();
|
|
25615
|
+
retry.fieldPageCount = ctx.skeleton.pages.length;
|
|
25616
|
+
retry.headerFooterMinimumMargins = ctx.headerFooterMinimumMargins;
|
|
25617
|
+
retry.fieldCountCandidates = ctx.fieldCountCandidates ?? /* @__PURE__ */ new Set();
|
|
25618
|
+
if (ctx.fieldPageCount != null) retry.fieldCountCandidates.add(ctx.fieldPageCount);
|
|
25619
|
+
retry.fieldCountCycle = ctx.fieldCountCycle || retry.fieldCountCandidates.has(retry.fieldPageCount);
|
|
25620
|
+
return retry;
|
|
25621
|
+
}
|
|
25418
25622
|
_prepareLayoutContext() {
|
|
25419
25623
|
var _ctx$noteReferences;
|
|
25420
25624
|
const viewModel = this.getViewModel();
|
|
@@ -25427,6 +25631,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25427
25631
|
};
|
|
25428
25632
|
const { paragraphLineGapDefault = 0, defaultTabStop = 10.5, textStyle = {}, adjustLineHeightInTable = _univerjs_core.BooleanNumber.FALSE } = documentStyle;
|
|
25429
25633
|
const docsConfig = {
|
|
25634
|
+
lineGap: this._lineGap,
|
|
25430
25635
|
headerTreeMap,
|
|
25431
25636
|
footerTreeMap,
|
|
25432
25637
|
lists,
|
|
@@ -25446,7 +25651,17 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25446
25651
|
skeListLevel,
|
|
25447
25652
|
drawingAnchor
|
|
25448
25653
|
};
|
|
25654
|
+
const hasNumPagesFields = [...headerTreeMap.values(), ...footerTreeMap.values()].some((story) => {
|
|
25655
|
+
var _story$getBody;
|
|
25656
|
+
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) => {
|
|
25657
|
+
var _range$properties;
|
|
25658
|
+
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;
|
|
25659
|
+
});
|
|
25660
|
+
});
|
|
25449
25661
|
const ctx = {
|
|
25662
|
+
fieldPageCount: this.getCompletedPageCount(),
|
|
25663
|
+
hasNumPagesFields,
|
|
25664
|
+
headerFooterMinimumMargins: hasNumPagesFields ? /* @__PURE__ */ new Map() : void 0,
|
|
25450
25665
|
viewModel,
|
|
25451
25666
|
dataModel,
|
|
25452
25667
|
noteReferences: documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL ? resolveNoteReferences(dataModel.getSnapshot()) : void 0,
|
|
@@ -25642,8 +25857,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25642
25857
|
let segmentPage = page;
|
|
25643
25858
|
if (segmentId) {
|
|
25644
25859
|
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);
|
|
25860
|
+
const maybeHeaderSke = (_skeHeaders$get5 = skeHeaders.get(segmentId)) === null || _skeHeaders$get5 === void 0 ? void 0 : _skeHeaders$get5.get(page.headerLayoutKey ?? pageWidth);
|
|
25861
|
+
const maybeFooterSke = (_skeFooters$get5 = skeFooters.get(segmentId)) === null || _skeFooters$get5 === void 0 ? void 0 : _skeFooters$get5.get(page.footerLayoutKey ?? pageWidth);
|
|
25647
25862
|
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
25863
|
if (note) segmentPage = note.page;
|
|
25649
25864
|
else if (maybeHeaderSke) segmentPage = maybeHeaderSke;
|
|
@@ -25712,7 +25927,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25712
25927
|
};
|
|
25713
25928
|
|
|
25714
25929
|
//#endregion
|
|
25715
|
-
//#region \0@oxc-project+runtime@0.
|
|
25930
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
25716
25931
|
function __decorateParam(paramIndex, decorator) {
|
|
25717
25932
|
return function(target, key) {
|
|
25718
25933
|
decorator(target, key, paramIndex);
|
|
@@ -25720,7 +25935,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
25720
25935
|
}
|
|
25721
25936
|
|
|
25722
25937
|
//#endregion
|
|
25723
|
-
//#region \0@oxc-project+runtime@0.
|
|
25938
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
25724
25939
|
function __decorate(decorators, target, key, desc) {
|
|
25725
25940
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25726
25941
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25847,6 +26062,8 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
25847
26062
|
_defineProperty(this, "_gridlinesColor", void 0);
|
|
25848
26063
|
_defineProperty(this, "_defaultGridlinesColor", void 0);
|
|
25849
26064
|
_defineProperty(this, "_scene", null);
|
|
26065
|
+
_defineProperty(this, "textLineGap", void 0);
|
|
26066
|
+
this.textLineGap = _configService.getConfig(_univerjs_core.SHEET_TEXT_LINE_GAP) ?? 0;
|
|
25850
26067
|
const themeService = _injector.get(_univerjs_core.ThemeService);
|
|
25851
26068
|
this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
|
|
25852
26069
|
var _this$_scene, _this$_scene2;
|
|
@@ -26177,7 +26394,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26177
26394
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26178
26395
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26179
26396
|
if (typeof colWidth === "number" && wrapStrategy === _univerjs_core.WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(colWidth);
|
|
26180
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26397
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26181
26398
|
documentSkeleton.calculate();
|
|
26182
26399
|
let { height: h = 0 } = getDocsSkeletonPageSize(documentSkeleton, angle) ?? {};
|
|
26183
26400
|
if (documentSkeleton) {
|
|
@@ -26195,7 +26412,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26195
26412
|
const paddingTop = ((_style$pd3 = style.pd) === null || _style$pd3 === void 0 ? void 0 : _style$pd3.t) ?? DEFAULT_PADDING_DATA.t;
|
|
26196
26413
|
const paddingBottom = ((_style$pd4 = style.pd) === null || _style$pd4 === void 0 ? void 0 : _style$pd4.b) ?? DEFAULT_PADDING_DATA.b;
|
|
26197
26414
|
if ((style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP) {
|
|
26198
|
-
const skeleton = new DocSimpleSkeleton((0, _univerjs_core.getDisplayValueFromCell)(cell), getFontStyleString(style).fontCache, (style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP, colWidth - paddingLeft - paddingRight, Infinity);
|
|
26415
|
+
const skeleton = new DocSimpleSkeleton((0, _univerjs_core.getDisplayValueFromCell)(cell), getFontStyleString(style).fontCache, (style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP, colWidth - paddingLeft - paddingRight, Infinity, this.textLineGap);
|
|
26199
26416
|
skeleton.calculate();
|
|
26200
26417
|
return skeleton.getTotalHeight() + paddingTop + paddingBottom;
|
|
26201
26418
|
} else {
|
|
@@ -26311,7 +26528,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26311
26528
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26312
26529
|
if ((style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(currColWidth, Infinity);
|
|
26313
26530
|
else documentModel.updateDocumentDataPageSize(Infinity, Infinity);
|
|
26314
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26531
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26315
26532
|
documentSkeleton.calculate();
|
|
26316
26533
|
measuredWidth = (getDocsSkeletonPageSize(documentSkeleton, angle) ?? { width: 0 }).width;
|
|
26317
26534
|
if (documentSkeleton) {
|
|
@@ -26594,7 +26811,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26594
26811
|
if (fontCache.documentSkeleton) {
|
|
26595
26812
|
const snapshot = fontCache.documentSkeleton.getViewModel().getDataModel().getSnapshot();
|
|
26596
26813
|
const documentModel = new _univerjs_core.DocumentDataModel(scaleDocumentDataForShrinkToFit(snapshot, scale, fallbackFontSize));
|
|
26597
|
-
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService);
|
|
26814
|
+
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService, { lineGap: this.textLineGap });
|
|
26598
26815
|
documentSkeleton.calculate();
|
|
26599
26816
|
fontCache.documentSkeleton = documentSkeleton;
|
|
26600
26817
|
} else fontCache.fontString = getFontStyleString({
|
|
@@ -26647,7 +26864,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26647
26864
|
if (FULL_WIDTH_HORIZONTAL_ALIGNMENTS.has(horizontalAlign)) updateDocumentPageWidth(documentModel, this.getCellWithCoordByIndex(row, col, false));
|
|
26648
26865
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26649
26866
|
if (documentViewModel) {
|
|
26650
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26867
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26651
26868
|
documentSkeleton.calculate();
|
|
26652
26869
|
config = {
|
|
26653
26870
|
documentSkeleton,
|
|
@@ -27111,7 +27328,7 @@ var Font = class extends SheetExtension {
|
|
|
27111
27328
|
this._clipByRenderBounds(renderFontCtx, row, col);
|
|
27112
27329
|
ctx.translate(renderFontCtx.startX + FIX_ONE_PIXEL_BLUR_OFFSET, renderFontCtx.startY + FIX_ONE_PIXEL_BLUR_OFFSET);
|
|
27113
27330
|
if (fontCache.documentSkeleton) this._renderDocuments(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
|
|
27114
|
-
else this._renderText(ctx,
|
|
27331
|
+
else this._renderText(ctx, renderFontCtx);
|
|
27115
27332
|
ctx.restore();
|
|
27116
27333
|
if (fontCache.documentSkeleton) {
|
|
27117
27334
|
var _documentDataModel$ge;
|
|
@@ -27206,7 +27423,7 @@ var Font = class extends SheetExtension {
|
|
|
27206
27423
|
if (image.getAttribute("data-error") === "true") this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27207
27424
|
else try {
|
|
27208
27425
|
ctx.drawImage(image, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27209
|
-
} catch
|
|
27426
|
+
} catch {
|
|
27210
27427
|
this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27211
27428
|
}
|
|
27212
27429
|
ctx.restore();
|
|
@@ -27219,7 +27436,7 @@ var Font = class extends SheetExtension {
|
|
|
27219
27436
|
* @param renderFontContext
|
|
27220
27437
|
* @param row
|
|
27221
27438
|
* @param col
|
|
27222
|
-
* @param
|
|
27439
|
+
* @param padding
|
|
27223
27440
|
*/
|
|
27224
27441
|
_clipByRenderBounds(renderFontContext, row, col, padding = 0) {
|
|
27225
27442
|
var _fontCache$cellData3, _fontCache$cellData4;
|
|
@@ -27263,7 +27480,7 @@ var Font = class extends SheetExtension {
|
|
|
27263
27480
|
renderFontContext.endX = endX;
|
|
27264
27481
|
renderFontContext.endY = endY;
|
|
27265
27482
|
}
|
|
27266
|
-
_renderText(ctx,
|
|
27483
|
+
_renderText(ctx, renderFontCtx) {
|
|
27267
27484
|
var _fontCache$style5, _fontCache$style6, _fontCache$style7, _fontCache$style8, _fontCache$style9;
|
|
27268
27485
|
const { fontCache } = renderFontCtx;
|
|
27269
27486
|
if (!fontCache) return;
|
|
@@ -27283,6 +27500,7 @@ var Font = class extends SheetExtension {
|
|
|
27283
27500
|
text,
|
|
27284
27501
|
fontStyle: fontCache.fontString,
|
|
27285
27502
|
warp: wrapStrategy === _univerjs_core.WrapStrategy.WRAP && vertexAngle === 0,
|
|
27503
|
+
lineGap: renderFontCtx.spreadsheetSkeleton.textLineGap,
|
|
27286
27504
|
hAlign,
|
|
27287
27505
|
vAlign: fontCache.verticalAlign,
|
|
27288
27506
|
width: cellWidth,
|
|
@@ -27706,6 +27924,290 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
27706
27924
|
}
|
|
27707
27925
|
};
|
|
27708
27926
|
|
|
27927
|
+
//#endregion
|
|
27928
|
+
//#region src/group.ts
|
|
27929
|
+
var Group = class extends BaseObject {
|
|
27930
|
+
constructor(key, ...objects) {
|
|
27931
|
+
super(key);
|
|
27932
|
+
_defineProperty(this, "_objects", []);
|
|
27933
|
+
_defineProperty(this, "_selfSizeMode", false);
|
|
27934
|
+
this.addObjects(...objects);
|
|
27935
|
+
}
|
|
27936
|
+
get classType() {
|
|
27937
|
+
return "Group";
|
|
27938
|
+
}
|
|
27939
|
+
set cursor(val) {
|
|
27940
|
+
this.setCursor(val);
|
|
27941
|
+
}
|
|
27942
|
+
getState() {
|
|
27943
|
+
if (this._selfSizeMode) return super.getState();
|
|
27944
|
+
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
27945
|
+
}
|
|
27946
|
+
get width() {
|
|
27947
|
+
if (this._selfSizeMode) return super.width;
|
|
27948
|
+
return this.getState().width || 0;
|
|
27949
|
+
}
|
|
27950
|
+
get height() {
|
|
27951
|
+
if (this._selfSizeMode) return super.height;
|
|
27952
|
+
return this.getState().height || 0;
|
|
27953
|
+
}
|
|
27954
|
+
set width(val) {
|
|
27955
|
+
if (this._selfSizeMode) {
|
|
27956
|
+
super.width = val;
|
|
27957
|
+
return;
|
|
27958
|
+
}
|
|
27959
|
+
const numDelta = val - this.width;
|
|
27960
|
+
this._objects.forEach((o) => {
|
|
27961
|
+
o.resize(o.width + numDelta);
|
|
27962
|
+
});
|
|
27963
|
+
}
|
|
27964
|
+
set height(val) {
|
|
27965
|
+
if (this._selfSizeMode) {
|
|
27966
|
+
super.height = val;
|
|
27967
|
+
return;
|
|
27968
|
+
}
|
|
27969
|
+
const numDelta = val - this.height;
|
|
27970
|
+
this._objects.forEach((o) => {
|
|
27971
|
+
o.resize(void 0, o.height + numDelta);
|
|
27972
|
+
});
|
|
27973
|
+
}
|
|
27974
|
+
get maxZIndex() {
|
|
27975
|
+
let maxZIndex = 0;
|
|
27976
|
+
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
27977
|
+
return maxZIndex;
|
|
27978
|
+
}
|
|
27979
|
+
openSelfSizeMode() {
|
|
27980
|
+
this._selfSizeMode = true;
|
|
27981
|
+
}
|
|
27982
|
+
closeSelfSizeMode() {
|
|
27983
|
+
this._selfSizeMode = false;
|
|
27984
|
+
}
|
|
27985
|
+
reCalculateObjects() {
|
|
27986
|
+
if (this._selfSizeMode) return;
|
|
27987
|
+
const { left = 0, top = 0 } = this.getState();
|
|
27988
|
+
for (const object of this._objects) object.transformByState({
|
|
27989
|
+
left: object.left - left,
|
|
27990
|
+
top: object.top - top
|
|
27991
|
+
});
|
|
27992
|
+
this.transformByState({
|
|
27993
|
+
left,
|
|
27994
|
+
top
|
|
27995
|
+
});
|
|
27996
|
+
}
|
|
27997
|
+
addObjects(...objects) {
|
|
27998
|
+
for (const object of objects) this.addObject(object);
|
|
27999
|
+
}
|
|
28000
|
+
addObject(o) {
|
|
28001
|
+
let object = o;
|
|
28002
|
+
if (isString(o)) {
|
|
28003
|
+
const scene = this.getScene();
|
|
28004
|
+
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
28005
|
+
if (!object) return;
|
|
28006
|
+
object.parent = this;
|
|
28007
|
+
object.isInGroup = true;
|
|
28008
|
+
object.groupKey = this.oKey;
|
|
28009
|
+
this._objects.push(object);
|
|
28010
|
+
} else {
|
|
28011
|
+
o.parent = this;
|
|
28012
|
+
o.isInGroup = true;
|
|
28013
|
+
o.groupKey = this.oKey;
|
|
28014
|
+
this._objects.push(o);
|
|
28015
|
+
}
|
|
28016
|
+
}
|
|
28017
|
+
removeObject(object) {
|
|
28018
|
+
const objects = this.getObjects();
|
|
28019
|
+
const objectsLength = objects.length;
|
|
28020
|
+
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
28021
|
+
const o = objects[i];
|
|
28022
|
+
if (o.oKey === object) {
|
|
28023
|
+
objects.splice(i, 1);
|
|
28024
|
+
this.parent.removeObject(o);
|
|
28025
|
+
return;
|
|
28026
|
+
}
|
|
28027
|
+
}
|
|
28028
|
+
else for (let i = 0; i < objectsLength; i++) {
|
|
28029
|
+
const o = objects[i];
|
|
28030
|
+
if (o === object) {
|
|
28031
|
+
objects.splice(i, 1);
|
|
28032
|
+
this.parent.removeObject(o);
|
|
28033
|
+
return;
|
|
28034
|
+
}
|
|
28035
|
+
}
|
|
28036
|
+
}
|
|
28037
|
+
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
28038
|
+
const objects = [...this.getObjects()];
|
|
28039
|
+
const objectsLength = objects.length;
|
|
28040
|
+
if (width == null) width = this.width;
|
|
28041
|
+
if (height == null) height = this.height;
|
|
28042
|
+
for (let i = 0; i < objectsLength; i++) {
|
|
28043
|
+
const o = objects[i];
|
|
28044
|
+
if (o.oKey === oKey) {
|
|
28045
|
+
objects.splice(i, 1);
|
|
28046
|
+
isTransform && this._transformObject(o, width, height);
|
|
28047
|
+
o.parent = this.parent;
|
|
28048
|
+
o.groupKey = void 0;
|
|
28049
|
+
o.isInGroup = false;
|
|
28050
|
+
this._objects = objects;
|
|
28051
|
+
return;
|
|
28052
|
+
}
|
|
28053
|
+
}
|
|
28054
|
+
}
|
|
28055
|
+
_transformObject(object, groupWidth, groupHeight) {
|
|
28056
|
+
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
28057
|
+
if (object.classType === "Group") object.transformByState({
|
|
28058
|
+
left: transform.left,
|
|
28059
|
+
top: transform.top
|
|
28060
|
+
});
|
|
28061
|
+
else object.transformByState(transform);
|
|
28062
|
+
}
|
|
28063
|
+
getObjectsByOrder() {
|
|
28064
|
+
const objects = [];
|
|
28065
|
+
this._objects.sort(_univerjs_core.sortRules);
|
|
28066
|
+
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
28067
|
+
return objects;
|
|
28068
|
+
}
|
|
28069
|
+
getObjects() {
|
|
28070
|
+
return this._objects;
|
|
28071
|
+
}
|
|
28072
|
+
render(ctx, bounds) {
|
|
28073
|
+
ctx.save();
|
|
28074
|
+
const m = this.transform.getMatrix();
|
|
28075
|
+
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
28076
|
+
const objects = this.getObjectsByOrder();
|
|
28077
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28078
|
+
ctx.restore();
|
|
28079
|
+
}
|
|
28080
|
+
_clear() {
|
|
28081
|
+
this._objects = [];
|
|
28082
|
+
}
|
|
28083
|
+
dispose() {
|
|
28084
|
+
[...this.getObjects()].forEach((o) => {
|
|
28085
|
+
o.dispose();
|
|
28086
|
+
});
|
|
28087
|
+
this._clear();
|
|
28088
|
+
super.dispose();
|
|
28089
|
+
}
|
|
28090
|
+
};
|
|
28091
|
+
|
|
28092
|
+
//#endregion
|
|
28093
|
+
//#region src/drawing-group.ts
|
|
28094
|
+
var DrawingGroupObject = class extends Group {
|
|
28095
|
+
constructor(..._args) {
|
|
28096
|
+
super(..._args);
|
|
28097
|
+
_defineProperty(this, "_selfSizeMode", true);
|
|
28098
|
+
_defineProperty(this, "_baseBound", {
|
|
28099
|
+
left: 0,
|
|
28100
|
+
top: 0,
|
|
28101
|
+
width: 0,
|
|
28102
|
+
height: 0
|
|
28103
|
+
});
|
|
28104
|
+
_defineProperty(this, "_outerShadow", void 0);
|
|
28105
|
+
_defineProperty(this, "_glow", void 0);
|
|
28106
|
+
}
|
|
28107
|
+
setOuterShadow(shadow) {
|
|
28108
|
+
this._outerShadow = shadow;
|
|
28109
|
+
this.makeDirty(true);
|
|
28110
|
+
}
|
|
28111
|
+
setGlow(glow) {
|
|
28112
|
+
this._glow = glow;
|
|
28113
|
+
this.makeDirty(true);
|
|
28114
|
+
}
|
|
28115
|
+
/**
|
|
28116
|
+
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
28117
|
+
* This defines the coordinate space of children within the group.
|
|
28118
|
+
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
28119
|
+
* are tracked independently of children.
|
|
28120
|
+
*/
|
|
28121
|
+
setBaseBound(bound) {
|
|
28122
|
+
this._baseBound = { ...bound };
|
|
28123
|
+
}
|
|
28124
|
+
/**
|
|
28125
|
+
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
28126
|
+
*/
|
|
28127
|
+
getBaseBound() {
|
|
28128
|
+
return { ...this._baseBound };
|
|
28129
|
+
}
|
|
28130
|
+
/**
|
|
28131
|
+
* Override ancestorTransform to use the same render transform as render(),
|
|
28132
|
+
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
28133
|
+
* instead of the standard transform translation.
|
|
28134
|
+
* This ensures children (e.g., Image.isHit) that compose with
|
|
28135
|
+
* parent.ancestorTransform get the correct coordinate space.
|
|
28136
|
+
*/
|
|
28137
|
+
get ancestorTransform() {
|
|
28138
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28139
|
+
const m = this.transform.getMatrix();
|
|
28140
|
+
const centerX = realLeft + realWidth / 2;
|
|
28141
|
+
const centerY = realTop + realHeight / 2;
|
|
28142
|
+
const renderTransform = new Transform([
|
|
28143
|
+
m[0],
|
|
28144
|
+
m[1],
|
|
28145
|
+
m[2],
|
|
28146
|
+
m[3],
|
|
28147
|
+
centerX,
|
|
28148
|
+
centerY
|
|
28149
|
+
]);
|
|
28150
|
+
const parent = this.getParent();
|
|
28151
|
+
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
28152
|
+
return renderTransform;
|
|
28153
|
+
}
|
|
28154
|
+
render(ctx, bounds) {
|
|
28155
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28156
|
+
ctx.save();
|
|
28157
|
+
const m = this.transform.getMatrix();
|
|
28158
|
+
const centerX = realLeft + realWidth / 2;
|
|
28159
|
+
const centerY = realTop + realHeight / 2;
|
|
28160
|
+
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
28161
|
+
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
28162
|
+
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
28163
|
+
if (this._outerShadow) {
|
|
28164
|
+
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
28165
|
+
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
28166
|
+
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
28167
|
+
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
28168
|
+
}
|
|
28169
|
+
const objects = this.getObjectsByOrder();
|
|
28170
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28171
|
+
ctx.restore();
|
|
28172
|
+
}
|
|
28173
|
+
addObjects(...objects) {
|
|
28174
|
+
for (const object of objects) this.addObject(object);
|
|
28175
|
+
}
|
|
28176
|
+
isHit(coord) {
|
|
28177
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28178
|
+
const m = this.transform.getMatrix();
|
|
28179
|
+
const centerX = realLeft + realWidth / 2;
|
|
28180
|
+
const centerY = realTop + realHeight / 2;
|
|
28181
|
+
const renderTransform = new Transform([
|
|
28182
|
+
m[0],
|
|
28183
|
+
m[1],
|
|
28184
|
+
m[2],
|
|
28185
|
+
m[3],
|
|
28186
|
+
centerX,
|
|
28187
|
+
centerY
|
|
28188
|
+
]);
|
|
28189
|
+
const parent = this.getParent();
|
|
28190
|
+
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
28191
|
+
const halfWidth = realWidth / 2;
|
|
28192
|
+
const halfHeight = realHeight / 2;
|
|
28193
|
+
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
28194
|
+
const objects = this.getObjectsByOrder();
|
|
28195
|
+
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
28196
|
+
return false;
|
|
28197
|
+
}
|
|
28198
|
+
dispose() {
|
|
28199
|
+
const objects = [...this.getObjects()];
|
|
28200
|
+
const scene = this.getScene();
|
|
28201
|
+
objects.forEach((o) => {
|
|
28202
|
+
o.dispose();
|
|
28203
|
+
scene === null || scene === void 0 || scene.removeObject(o);
|
|
28204
|
+
});
|
|
28205
|
+
this._objects = [];
|
|
28206
|
+
super.dispose();
|
|
28207
|
+
scene === null || scene === void 0 || scene.removeObject(this);
|
|
28208
|
+
}
|
|
28209
|
+
};
|
|
28210
|
+
|
|
27709
28211
|
//#endregion
|
|
27710
28212
|
//#region src/components/docs/doc-component.ts
|
|
27711
28213
|
var DocComponent = class extends RenderComponent {
|
|
@@ -28152,7 +28654,9 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
28152
28654
|
const { ts: textStyle, content, fontStyle, bBox } = glyph;
|
|
28153
28655
|
const { spanPointWithFont = Vector2.create(0, 0) } = this.extensionOffset;
|
|
28154
28656
|
if (content == null) return;
|
|
28155
|
-
|
|
28657
|
+
const currentKerning = ctx.fontKerning;
|
|
28658
|
+
const fontKerning = (fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontKerning) ?? "auto";
|
|
28659
|
+
if (currentKerning != null && currentKerning !== fontKerning) ctx.fontKerning = fontKerning;
|
|
28156
28660
|
if (!textStyle) {
|
|
28157
28661
|
this._fillText(ctx, glyph, spanPointWithFont);
|
|
28158
28662
|
return;
|
|
@@ -28781,22 +29285,6 @@ function getVisibleContinuousLineRange(lines, viewportTop, viewportBottom, flowT
|
|
|
28781
29285
|
end: low
|
|
28782
29286
|
};
|
|
28783
29287
|
}
|
|
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
29288
|
function resolveHeaderFooterFieldGlyphGroup(divide, context) {
|
|
28801
29289
|
var _context$viewModel;
|
|
28802
29290
|
const { glyphGroup } = divide;
|
|
@@ -28930,8 +29418,21 @@ var Documents = class Documents extends DocComponent {
|
|
|
28930
29418
|
return this.getScene().getEngine();
|
|
28931
29419
|
}
|
|
28932
29420
|
isHit(coord) {
|
|
29421
|
+
if (super.isHit(coord)) {
|
|
29422
|
+
var _this$getScene;
|
|
29423
|
+
const drawingHit = (_this$getScene = this.getScene()) === null || _this$getScene === void 0 ? void 0 : _this$getScene.getAllObjectsByOrderForPick().some((object) => (object.isDrawingObject || object instanceof DrawingGroupObject) && !object.isInGroup && object.visible && object.evented && object.isHit(coord));
|
|
29424
|
+
const skeleton = this.getSkeleton();
|
|
29425
|
+
if (drawingHit && skeleton) {
|
|
29426
|
+
const node = skeleton.findNodeByCoord(this.getInverseCoord(coord), this.pageLayoutType, this.pageMarginLeft, this.pageMarginTop);
|
|
29427
|
+
if (node === null || node === void 0 ? void 0 : node.isInsideGlyph) return true;
|
|
29428
|
+
return this._isHitTable(coord);
|
|
29429
|
+
}
|
|
29430
|
+
return true;
|
|
29431
|
+
}
|
|
29432
|
+
return this._isHitTable(coord);
|
|
29433
|
+
}
|
|
29434
|
+
_isHitTable(coord) {
|
|
28933
29435
|
var _this$getSkeleton;
|
|
28934
|
-
if (super.isHit(coord)) return true;
|
|
28935
29436
|
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
28936
29437
|
if (!skeletonData) return false;
|
|
28937
29438
|
const localCoord = this.getInverseCoord(coord);
|
|
@@ -29024,7 +29525,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29024
29525
|
this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
29025
29526
|
ctx.restore();
|
|
29026
29527
|
}
|
|
29027
|
-
const headerSkeletonPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(pageWidth);
|
|
29528
|
+
const headerSkeletonPage = (_skeHeaders$get = skeHeaders.get(headerId)) === null || _skeHeaders$get === void 0 ? void 0 : _skeHeaders$get.get(page.headerLayoutKey ?? pageWidth);
|
|
29028
29529
|
const headerAlignOffsetNoAngle = Vector2.create(horizontalOffsetNoAngle, (headerSkeletonPage === null || headerSkeletonPage === void 0 ? void 0 : headerSkeletonPage.marginTop) ?? 0);
|
|
29029
29530
|
if (headerSkeletonPage) this._drawHeaderFooter(headerSkeletonPage, ctx, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, headerAlignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, page, true, pages.length, void 0, headerFooterOpacity);
|
|
29030
29531
|
ctx.save();
|
|
@@ -29038,7 +29539,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29038
29539
|
var _this$getSkeleton6;
|
|
29039
29540
|
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
29541
|
}
|
|
29041
|
-
const footerSkeletonPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(pageWidth);
|
|
29542
|
+
const footerSkeletonPage = (_skeFooters$get = skeFooters.get(footerId)) === null || _skeFooters$get === void 0 ? void 0 : _skeFooters$get.get(page.footerLayoutKey ?? pageWidth);
|
|
29042
29543
|
if (footerSkeletonPage) {
|
|
29043
29544
|
const footerAlignOffsetNoAngle = Vector2.create(horizontalOffsetNoAngle, page.pageHeight - (footerSkeletonPage === null || footerSkeletonPage === void 0 ? void 0 : footerSkeletonPage.height) - footerSkeletonPage.marginBottom);
|
|
29044
29545
|
this._drawHeaderFooter(footerSkeletonPage, ctx, extensions, backgroundExtension, preTextBackgroundExtensions, glyphExtensionsExcludeBackground, footerAlignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, page, false, pages.length, void 0, headerFooterOpacity);
|
|
@@ -29642,7 +30143,7 @@ var Documents = class Documents extends DocComponent {
|
|
|
29642
30143
|
const skeleton = this.getSkeleton();
|
|
29643
30144
|
const viewModel = typeof (skeleton === null || skeleton === void 0 ? void 0 : skeleton.getViewModel) === "function" ? skeleton.getViewModel().getSelfOrHeaderFooterViewModel(page.segmentId) : void 0;
|
|
29644
30145
|
const fieldContext = {
|
|
29645
|
-
customRanges: customRangesOverride ?? (viewModel === null || viewModel === void 0 || (_viewModel$getBody = viewModel.getBody()) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.customRanges) ?? [],
|
|
30146
|
+
customRanges: page.fieldsResolved ? [] : customRangesOverride ?? (viewModel === null || viewModel === void 0 || (_viewModel$getBody = viewModel.getBody()) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.customRanges) ?? [],
|
|
29646
30147
|
pageNumber: parentPage.pageNumber,
|
|
29647
30148
|
pageCount,
|
|
29648
30149
|
viewModel
|
|
@@ -34239,290 +34740,6 @@ var CustomObject = class extends BaseObject {
|
|
|
34239
34740
|
}
|
|
34240
34741
|
};
|
|
34241
34742
|
|
|
34242
|
-
//#endregion
|
|
34243
|
-
//#region src/group.ts
|
|
34244
|
-
var Group = class extends BaseObject {
|
|
34245
|
-
constructor(key, ...objects) {
|
|
34246
|
-
super(key);
|
|
34247
|
-
_defineProperty(this, "_objects", []);
|
|
34248
|
-
_defineProperty(this, "_selfSizeMode", false);
|
|
34249
|
-
this.addObjects(...objects);
|
|
34250
|
-
}
|
|
34251
|
-
get classType() {
|
|
34252
|
-
return "Group";
|
|
34253
|
-
}
|
|
34254
|
-
set cursor(val) {
|
|
34255
|
-
this.setCursor(val);
|
|
34256
|
-
}
|
|
34257
|
-
getState() {
|
|
34258
|
-
if (this._selfSizeMode) return super.getState();
|
|
34259
|
-
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
34260
|
-
}
|
|
34261
|
-
get width() {
|
|
34262
|
-
if (this._selfSizeMode) return super.width;
|
|
34263
|
-
return this.getState().width || 0;
|
|
34264
|
-
}
|
|
34265
|
-
get height() {
|
|
34266
|
-
if (this._selfSizeMode) return super.height;
|
|
34267
|
-
return this.getState().height || 0;
|
|
34268
|
-
}
|
|
34269
|
-
set width(val) {
|
|
34270
|
-
if (this._selfSizeMode) {
|
|
34271
|
-
super.width = val;
|
|
34272
|
-
return;
|
|
34273
|
-
}
|
|
34274
|
-
const numDelta = val - this.width;
|
|
34275
|
-
this._objects.forEach((o) => {
|
|
34276
|
-
o.resize(o.width + numDelta);
|
|
34277
|
-
});
|
|
34278
|
-
}
|
|
34279
|
-
set height(val) {
|
|
34280
|
-
if (this._selfSizeMode) {
|
|
34281
|
-
super.height = val;
|
|
34282
|
-
return;
|
|
34283
|
-
}
|
|
34284
|
-
const numDelta = val - this.height;
|
|
34285
|
-
this._objects.forEach((o) => {
|
|
34286
|
-
o.resize(void 0, o.height + numDelta);
|
|
34287
|
-
});
|
|
34288
|
-
}
|
|
34289
|
-
get maxZIndex() {
|
|
34290
|
-
let maxZIndex = 0;
|
|
34291
|
-
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
34292
|
-
return maxZIndex;
|
|
34293
|
-
}
|
|
34294
|
-
openSelfSizeMode() {
|
|
34295
|
-
this._selfSizeMode = true;
|
|
34296
|
-
}
|
|
34297
|
-
closeSelfSizeMode() {
|
|
34298
|
-
this._selfSizeMode = false;
|
|
34299
|
-
}
|
|
34300
|
-
reCalculateObjects() {
|
|
34301
|
-
if (this._selfSizeMode) return;
|
|
34302
|
-
const { left = 0, top = 0 } = this.getState();
|
|
34303
|
-
for (const object of this._objects) object.transformByState({
|
|
34304
|
-
left: object.left - left,
|
|
34305
|
-
top: object.top - top
|
|
34306
|
-
});
|
|
34307
|
-
this.transformByState({
|
|
34308
|
-
left,
|
|
34309
|
-
top
|
|
34310
|
-
});
|
|
34311
|
-
}
|
|
34312
|
-
addObjects(...objects) {
|
|
34313
|
-
for (const object of objects) this.addObject(object);
|
|
34314
|
-
}
|
|
34315
|
-
addObject(o) {
|
|
34316
|
-
let object = o;
|
|
34317
|
-
if (isString(o)) {
|
|
34318
|
-
const scene = this.getScene();
|
|
34319
|
-
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
34320
|
-
if (!object) return;
|
|
34321
|
-
object.parent = this;
|
|
34322
|
-
object.isInGroup = true;
|
|
34323
|
-
object.groupKey = this.oKey;
|
|
34324
|
-
this._objects.push(object);
|
|
34325
|
-
} else {
|
|
34326
|
-
o.parent = this;
|
|
34327
|
-
o.isInGroup = true;
|
|
34328
|
-
o.groupKey = this.oKey;
|
|
34329
|
-
this._objects.push(o);
|
|
34330
|
-
}
|
|
34331
|
-
}
|
|
34332
|
-
removeObject(object) {
|
|
34333
|
-
const objects = this.getObjects();
|
|
34334
|
-
const objectsLength = objects.length;
|
|
34335
|
-
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
34336
|
-
const o = objects[i];
|
|
34337
|
-
if (o.oKey === object) {
|
|
34338
|
-
objects.splice(i, 1);
|
|
34339
|
-
this.parent.removeObject(o);
|
|
34340
|
-
return;
|
|
34341
|
-
}
|
|
34342
|
-
}
|
|
34343
|
-
else for (let i = 0; i < objectsLength; i++) {
|
|
34344
|
-
const o = objects[i];
|
|
34345
|
-
if (o === object) {
|
|
34346
|
-
objects.splice(i, 1);
|
|
34347
|
-
this.parent.removeObject(o);
|
|
34348
|
-
return;
|
|
34349
|
-
}
|
|
34350
|
-
}
|
|
34351
|
-
}
|
|
34352
|
-
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
34353
|
-
const objects = [...this.getObjects()];
|
|
34354
|
-
const objectsLength = objects.length;
|
|
34355
|
-
if (width == null) width = this.width;
|
|
34356
|
-
if (height == null) height = this.height;
|
|
34357
|
-
for (let i = 0; i < objectsLength; i++) {
|
|
34358
|
-
const o = objects[i];
|
|
34359
|
-
if (o.oKey === oKey) {
|
|
34360
|
-
objects.splice(i, 1);
|
|
34361
|
-
isTransform && this._transformObject(o, width, height);
|
|
34362
|
-
o.parent = this.parent;
|
|
34363
|
-
o.groupKey = void 0;
|
|
34364
|
-
o.isInGroup = false;
|
|
34365
|
-
this._objects = objects;
|
|
34366
|
-
return;
|
|
34367
|
-
}
|
|
34368
|
-
}
|
|
34369
|
-
}
|
|
34370
|
-
_transformObject(object, groupWidth, groupHeight) {
|
|
34371
|
-
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
34372
|
-
if (object.classType === "Group") object.transformByState({
|
|
34373
|
-
left: transform.left,
|
|
34374
|
-
top: transform.top
|
|
34375
|
-
});
|
|
34376
|
-
else object.transformByState(transform);
|
|
34377
|
-
}
|
|
34378
|
-
getObjectsByOrder() {
|
|
34379
|
-
const objects = [];
|
|
34380
|
-
this._objects.sort(_univerjs_core.sortRules);
|
|
34381
|
-
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
34382
|
-
return objects;
|
|
34383
|
-
}
|
|
34384
|
-
getObjects() {
|
|
34385
|
-
return this._objects;
|
|
34386
|
-
}
|
|
34387
|
-
render(ctx, bounds) {
|
|
34388
|
-
ctx.save();
|
|
34389
|
-
const m = this.transform.getMatrix();
|
|
34390
|
-
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
34391
|
-
const objects = this.getObjectsByOrder();
|
|
34392
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34393
|
-
ctx.restore();
|
|
34394
|
-
}
|
|
34395
|
-
_clear() {
|
|
34396
|
-
this._objects = [];
|
|
34397
|
-
}
|
|
34398
|
-
dispose() {
|
|
34399
|
-
[...this.getObjects()].forEach((o) => {
|
|
34400
|
-
o.dispose();
|
|
34401
|
-
});
|
|
34402
|
-
this._clear();
|
|
34403
|
-
super.dispose();
|
|
34404
|
-
}
|
|
34405
|
-
};
|
|
34406
|
-
|
|
34407
|
-
//#endregion
|
|
34408
|
-
//#region src/drawing-group.ts
|
|
34409
|
-
var DrawingGroupObject = class extends Group {
|
|
34410
|
-
constructor(..._args) {
|
|
34411
|
-
super(..._args);
|
|
34412
|
-
_defineProperty(this, "_selfSizeMode", true);
|
|
34413
|
-
_defineProperty(this, "_baseBound", {
|
|
34414
|
-
left: 0,
|
|
34415
|
-
top: 0,
|
|
34416
|
-
width: 0,
|
|
34417
|
-
height: 0
|
|
34418
|
-
});
|
|
34419
|
-
_defineProperty(this, "_outerShadow", void 0);
|
|
34420
|
-
_defineProperty(this, "_glow", void 0);
|
|
34421
|
-
}
|
|
34422
|
-
setOuterShadow(shadow) {
|
|
34423
|
-
this._outerShadow = shadow;
|
|
34424
|
-
this.makeDirty(true);
|
|
34425
|
-
}
|
|
34426
|
-
setGlow(glow) {
|
|
34427
|
-
this._glow = glow;
|
|
34428
|
-
this.makeDirty(true);
|
|
34429
|
-
}
|
|
34430
|
-
/**
|
|
34431
|
-
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
34432
|
-
* This defines the coordinate space of children within the group.
|
|
34433
|
-
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
34434
|
-
* are tracked independently of children.
|
|
34435
|
-
*/
|
|
34436
|
-
setBaseBound(bound) {
|
|
34437
|
-
this._baseBound = { ...bound };
|
|
34438
|
-
}
|
|
34439
|
-
/**
|
|
34440
|
-
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
34441
|
-
*/
|
|
34442
|
-
getBaseBound() {
|
|
34443
|
-
return { ...this._baseBound };
|
|
34444
|
-
}
|
|
34445
|
-
/**
|
|
34446
|
-
* Override ancestorTransform to use the same render transform as render(),
|
|
34447
|
-
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
34448
|
-
* instead of the standard transform translation.
|
|
34449
|
-
* This ensures children (e.g., Image.isHit) that compose with
|
|
34450
|
-
* parent.ancestorTransform get the correct coordinate space.
|
|
34451
|
-
*/
|
|
34452
|
-
get ancestorTransform() {
|
|
34453
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34454
|
-
const m = this.transform.getMatrix();
|
|
34455
|
-
const centerX = realLeft + realWidth / 2;
|
|
34456
|
-
const centerY = realTop + realHeight / 2;
|
|
34457
|
-
const renderTransform = new Transform([
|
|
34458
|
-
m[0],
|
|
34459
|
-
m[1],
|
|
34460
|
-
m[2],
|
|
34461
|
-
m[3],
|
|
34462
|
-
centerX,
|
|
34463
|
-
centerY
|
|
34464
|
-
]);
|
|
34465
|
-
const parent = this.getParent();
|
|
34466
|
-
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
34467
|
-
return renderTransform;
|
|
34468
|
-
}
|
|
34469
|
-
render(ctx, bounds) {
|
|
34470
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34471
|
-
ctx.save();
|
|
34472
|
-
const m = this.transform.getMatrix();
|
|
34473
|
-
const centerX = realLeft + realWidth / 2;
|
|
34474
|
-
const centerY = realTop + realHeight / 2;
|
|
34475
|
-
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
34476
|
-
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
34477
|
-
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
34478
|
-
if (this._outerShadow) {
|
|
34479
|
-
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
34480
|
-
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
34481
|
-
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
34482
|
-
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
34483
|
-
}
|
|
34484
|
-
const objects = this.getObjectsByOrder();
|
|
34485
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34486
|
-
ctx.restore();
|
|
34487
|
-
}
|
|
34488
|
-
addObjects(...objects) {
|
|
34489
|
-
for (const object of objects) this.addObject(object);
|
|
34490
|
-
}
|
|
34491
|
-
isHit(coord) {
|
|
34492
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34493
|
-
const m = this.transform.getMatrix();
|
|
34494
|
-
const centerX = realLeft + realWidth / 2;
|
|
34495
|
-
const centerY = realTop + realHeight / 2;
|
|
34496
|
-
const renderTransform = new Transform([
|
|
34497
|
-
m[0],
|
|
34498
|
-
m[1],
|
|
34499
|
-
m[2],
|
|
34500
|
-
m[3],
|
|
34501
|
-
centerX,
|
|
34502
|
-
centerY
|
|
34503
|
-
]);
|
|
34504
|
-
const parent = this.getParent();
|
|
34505
|
-
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
34506
|
-
const halfWidth = realWidth / 2;
|
|
34507
|
-
const halfHeight = realHeight / 2;
|
|
34508
|
-
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
34509
|
-
const objects = this.getObjectsByOrder();
|
|
34510
|
-
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
34511
|
-
return false;
|
|
34512
|
-
}
|
|
34513
|
-
dispose() {
|
|
34514
|
-
const objects = [...this.getObjects()];
|
|
34515
|
-
const scene = this.getScene();
|
|
34516
|
-
objects.forEach((o) => {
|
|
34517
|
-
o.dispose();
|
|
34518
|
-
scene === null || scene === void 0 || scene.removeObject(o);
|
|
34519
|
-
});
|
|
34520
|
-
this._objects = [];
|
|
34521
|
-
super.dispose();
|
|
34522
|
-
scene === null || scene === void 0 || scene.removeObject(this);
|
|
34523
|
-
}
|
|
34524
|
-
};
|
|
34525
|
-
|
|
34526
34743
|
//#endregion
|
|
34527
34744
|
//#region src/floating/util.ts
|
|
34528
34745
|
/**
|
|
@@ -35365,7 +35582,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
35365
35582
|
//#endregion
|
|
35366
35583
|
//#region package.json
|
|
35367
35584
|
var name = "@univerjs/engine-render";
|
|
35368
|
-
var version = "1.0
|
|
35585
|
+
var version = "1.1.0";
|
|
35369
35586
|
|
|
35370
35587
|
//#endregion
|
|
35371
35588
|
//#region src/config/config.ts
|
|
@@ -40036,6 +40253,7 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40036
40253
|
_defineProperty(this, "_viewModel", void 0);
|
|
40037
40254
|
_defineProperty(this, "_skeleton", void 0);
|
|
40038
40255
|
_defineProperty(this, "_lastPublishedPageCount", 0);
|
|
40256
|
+
_defineProperty(this, "_paginationRevision", 0);
|
|
40039
40257
|
_defineProperty(this, "_layoutReason", "initial");
|
|
40040
40258
|
_defineProperty(this, "_didPublishEditAnchor", false);
|
|
40041
40259
|
_defineProperty(this, "_continuousPageSnapshot", null);
|
|
@@ -40051,6 +40269,7 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40051
40269
|
var _options$invalidation;
|
|
40052
40270
|
this._lastPublishedPageCount = 0;
|
|
40053
40271
|
this._layoutReason = (options === null || options === void 0 ? void 0 : options.reason) ?? "initial";
|
|
40272
|
+
this._paginationRevision = 0;
|
|
40054
40273
|
this._didPublishEditAnchor = false;
|
|
40055
40274
|
this._publishedHeaderPages.clear();
|
|
40056
40275
|
this._publishedFooterPages.clear();
|
|
@@ -40131,6 +40350,11 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40131
40350
|
}
|
|
40132
40351
|
_collectPublications(initialProgress) {
|
|
40133
40352
|
let progress = initialProgress;
|
|
40353
|
+
if ((progress.paginationRevision ?? 0) !== this._paginationRevision) {
|
|
40354
|
+
this._paginationRevision = progress.paginationRevision ?? 0;
|
|
40355
|
+
this._lastPublishedPageCount = 0;
|
|
40356
|
+
this._didPublishEditAnchor = false;
|
|
40357
|
+
}
|
|
40134
40358
|
if (!progress.didPublish) return {
|
|
40135
40359
|
progress,
|
|
40136
40360
|
publication: null
|
|
@@ -40244,7 +40468,8 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40244
40468
|
})))]) : null,
|
|
40245
40469
|
drawingAnchor: complete ? [...skeletonData.drawingAnchor ?? []].map(([segmentId, anchors]) => [segmentId, [...anchors].map(([paragraphIndex, anchor]) => [paragraphIndex, {
|
|
40246
40470
|
paragraphIndex: anchor.paragraphIndex,
|
|
40247
|
-
top: anchor.top
|
|
40471
|
+
top: anchor.top,
|
|
40472
|
+
...anchor.left == null ? {} : { left: anchor.left }
|
|
40248
40473
|
}])]) : null
|
|
40249
40474
|
};
|
|
40250
40475
|
}
|
|
@@ -40265,7 +40490,7 @@ exports.CIRCLE_OBJECT_ARRAY = CIRCLE_OBJECT_ARRAY;
|
|
|
40265
40490
|
exports.COLOR_BLACK_RGB = COLOR_BLACK_RGB;
|
|
40266
40491
|
exports.CURSOR_TYPE = CURSOR_TYPE;
|
|
40267
40492
|
exports.Canvas = Canvas;
|
|
40268
|
-
Object.defineProperty(exports,
|
|
40493
|
+
Object.defineProperty(exports, "CanvasColorService", {
|
|
40269
40494
|
enumerable: true,
|
|
40270
40495
|
get: function () {
|
|
40271
40496
|
return CanvasColorService;
|
|
@@ -40311,7 +40536,7 @@ exports.Drawing = Drawing;
|
|
|
40311
40536
|
exports.DrawingGroupObject = DrawingGroupObject;
|
|
40312
40537
|
exports.DumbCanvasColorService = DumbCanvasColorService;
|
|
40313
40538
|
exports.EXPAND_SIZE_FOR_RENDER_OVERFLOW = EXPAND_SIZE_FOR_RENDER_OVERFLOW;
|
|
40314
|
-
Object.defineProperty(exports,
|
|
40539
|
+
Object.defineProperty(exports, "Engine", {
|
|
40315
40540
|
enumerable: true,
|
|
40316
40541
|
get: function () {
|
|
40317
40542
|
return Engine;
|
|
@@ -40365,13 +40590,13 @@ exports.RICHTEXT_OBJECT_ARRAY = RICHTEXT_OBJECT_ARRAY;
|
|
|
40365
40590
|
exports.Rect = Rect;
|
|
40366
40591
|
exports.RegularPolygon = RegularPolygon;
|
|
40367
40592
|
exports.RenderComponent = RenderComponent;
|
|
40368
|
-
Object.defineProperty(exports,
|
|
40593
|
+
Object.defineProperty(exports, "RenderManagerService", {
|
|
40369
40594
|
enumerable: true,
|
|
40370
40595
|
get: function () {
|
|
40371
40596
|
return RenderManagerService;
|
|
40372
40597
|
}
|
|
40373
40598
|
});
|
|
40374
|
-
Object.defineProperty(exports,
|
|
40599
|
+
Object.defineProperty(exports, "RenderUnit", {
|
|
40375
40600
|
enumerable: true,
|
|
40376
40601
|
get: function () {
|
|
40377
40602
|
return RenderUnit;
|
|
@@ -40405,7 +40630,7 @@ exports.SpreadsheetColumnHeader = SpreadsheetColumnHeader;
|
|
|
40405
40630
|
exports.SpreadsheetExtensionRegistry = SpreadsheetExtensionRegistry;
|
|
40406
40631
|
exports.SpreadsheetHeader = SpreadsheetHeader;
|
|
40407
40632
|
exports.SpreadsheetRowHeader = SpreadsheetRowHeader;
|
|
40408
|
-
Object.defineProperty(exports,
|
|
40633
|
+
Object.defineProperty(exports, "SpreadsheetSkeleton", {
|
|
40409
40634
|
enumerable: true,
|
|
40410
40635
|
get: function () {
|
|
40411
40636
|
return SpreadsheetSkeleton;
|
|
@@ -40418,7 +40643,7 @@ exports.Transform = Transform;
|
|
|
40418
40643
|
exports.UNIVER_WATERMARK_LAYER_INDEX = UNIVER_WATERMARK_LAYER_INDEX;
|
|
40419
40644
|
exports.UNIVER_WATERMARK_STORAGE_KEY = UNIVER_WATERMARK_STORAGE_KEY;
|
|
40420
40645
|
exports.UniverPrintingContext = UniverPrintingContext;
|
|
40421
|
-
Object.defineProperty(exports,
|
|
40646
|
+
Object.defineProperty(exports, "UniverRenderEnginePlugin", {
|
|
40422
40647
|
enumerable: true,
|
|
40423
40648
|
get: function () {
|
|
40424
40649
|
return UniverRenderEnginePlugin;
|