@univerjs/engine-render 1.0.4 → 1.2.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 +568 -352
- package/lib/es/index.js +563 -347
- package/lib/index.js +563 -347
- package/lib/types/basics/document-node-tools.d.ts +1 -0
- package/lib/types/basics/i-document-skeleton-cached.d.ts +4 -0
- package/lib/types/basics/interfaces.d.ts +3 -0
- package/lib/types/components/docs/document.d.ts +1 -0
- package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +2 -2
- 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 +9 -1
- package/lib/types/components/docs/layout/model/page.d.ts +2 -2
- package/lib/types/components/docs/view-model/document-view-model.d.ts +5 -0
- package/lib/types/components/docs/view-model/heading-sections.d.ts +26 -0
- 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/umd/index.js +5 -5
- package/package.json +6 -6
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,
|
|
@@ -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;
|
|
@@ -13122,6 +13126,48 @@ var DataStreamTreeNode = class DataStreamTreeNode {
|
|
|
13122
13126
|
}
|
|
13123
13127
|
};
|
|
13124
13128
|
|
|
13129
|
+
//#endregion
|
|
13130
|
+
//#region src/components/docs/view-model/heading-sections.ts
|
|
13131
|
+
/** Each table cell and modern column has its own heading hierarchy. */
|
|
13132
|
+
function getHeadingSections(sections, getParagraph) {
|
|
13133
|
+
const result = [];
|
|
13134
|
+
function visitFlow(nodes, endOffset) {
|
|
13135
|
+
const open = [];
|
|
13136
|
+
for (const node of nodes) {
|
|
13137
|
+
var _paragraph$paragraphS;
|
|
13138
|
+
const paragraph = node.nodeType === _univerjs_core.DataStreamTreeNodeType.PARAGRAPH && node.children.length === 0 ? getParagraph(node.endIndex) : void 0;
|
|
13139
|
+
const level = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType;
|
|
13140
|
+
if (paragraph && level != null && level >= _univerjs_core.NamedStyleType.HEADING_1 && level <= _univerjs_core.NamedStyleType.HEADING_5) {
|
|
13141
|
+
while (open.length && open[open.length - 1].level >= level) open.pop().section.endOffset = node.startIndex;
|
|
13142
|
+
const section = {
|
|
13143
|
+
paragraphId: paragraph.paragraphId,
|
|
13144
|
+
paragraphIndex: paragraph.startIndex,
|
|
13145
|
+
startOffset: paragraph.startIndex + 1,
|
|
13146
|
+
endOffset,
|
|
13147
|
+
collapsed: paragraph.headingCollapsed === true
|
|
13148
|
+
};
|
|
13149
|
+
result.push(section);
|
|
13150
|
+
open.push({
|
|
13151
|
+
level,
|
|
13152
|
+
section
|
|
13153
|
+
});
|
|
13154
|
+
}
|
|
13155
|
+
visitContainers(node);
|
|
13156
|
+
}
|
|
13157
|
+
}
|
|
13158
|
+
function visitContainers(node) {
|
|
13159
|
+
if (node.nodeType === _univerjs_core.DataStreamTreeNodeType.TABLE_CELL || node.nodeType === _univerjs_core.DataStreamTreeNodeType.COLUMN) {
|
|
13160
|
+
const nodes = node.children.flatMap((child) => child.nodeType === _univerjs_core.DataStreamTreeNodeType.SECTION_BREAK ? child.children : [child]);
|
|
13161
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : node.endIndex);
|
|
13162
|
+
return;
|
|
13163
|
+
}
|
|
13164
|
+
for (const child of node.children) visitContainers(child);
|
|
13165
|
+
}
|
|
13166
|
+
const nodes = sections.flatMap((section) => section.children);
|
|
13167
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : 0);
|
|
13168
|
+
return result.sort((a, b) => a.paragraphIndex - b.paragraphIndex);
|
|
13169
|
+
}
|
|
13170
|
+
|
|
13125
13171
|
//#endregion
|
|
13126
13172
|
//#region src/components/docs/view-model/document-view-model.ts
|
|
13127
13173
|
const NON_STRUCTURAL_ROOT_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -13446,6 +13492,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13446
13492
|
_defineProperty(this, "_treeNodes", []);
|
|
13447
13493
|
_defineProperty(this, "_treeNodesByStartIndex", []);
|
|
13448
13494
|
_defineProperty(this, "_plainTopLevelParagraphNodes", []);
|
|
13495
|
+
_defineProperty(this, "_headingSections", null);
|
|
13496
|
+
_defineProperty(this, "_collapsedHeadingSections", null);
|
|
13449
13497
|
_defineProperty(this, "_metadataCachesDirty", false);
|
|
13450
13498
|
_defineProperty(this, "_textRunsOrderedAndDisjoint", true);
|
|
13451
13499
|
_defineProperty(this, "_paragraphsOrdered", true);
|
|
@@ -13489,6 +13537,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13489
13537
|
this._treeNodes = [];
|
|
13490
13538
|
this._treeNodesByStartIndex = [];
|
|
13491
13539
|
this._plainTopLevelParagraphNodes = [];
|
|
13540
|
+
this._headingSections = null;
|
|
13541
|
+
this._collapsedHeadingSections = null;
|
|
13492
13542
|
this._lastTextRun = null;
|
|
13493
13543
|
this._noteTreeMap.forEach((viewModel) => viewModel.dispose());
|
|
13494
13544
|
this._noteTreeMap.clear();
|
|
@@ -13516,6 +13566,41 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13516
13566
|
getChildren() {
|
|
13517
13567
|
return this._children;
|
|
13518
13568
|
}
|
|
13569
|
+
getHeadingSections() {
|
|
13570
|
+
const snapshot = this.getSnapshot();
|
|
13571
|
+
if (snapshot.documentStyle.documentFlavor !== _univerjs_core.DocumentFlavor.MODERN) return [];
|
|
13572
|
+
this._headingSections ??= getHeadingSections(this._children, (index) => {
|
|
13573
|
+
var _paragraph$paragraphS;
|
|
13574
|
+
const paragraph = this.getParagraph(index);
|
|
13575
|
+
if (!(paragraph === null || paragraph === void 0 ? void 0 : paragraph.styleId) || ((_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType) != null) return paragraph;
|
|
13576
|
+
return {
|
|
13577
|
+
...paragraph,
|
|
13578
|
+
paragraphStyle: (0, _univerjs_core.resolveDocumentParagraphStyle)(snapshot.documentStyle, paragraph.paragraphStyle, {
|
|
13579
|
+
styles: snapshot.styles,
|
|
13580
|
+
paragraphStyleId: paragraph.styleId
|
|
13581
|
+
})
|
|
13582
|
+
};
|
|
13583
|
+
});
|
|
13584
|
+
return this._headingSections;
|
|
13585
|
+
}
|
|
13586
|
+
getCollapsedHeadingAtOffset(offset) {
|
|
13587
|
+
if (!this._collapsedHeadingSections) {
|
|
13588
|
+
this._collapsedHeadingSections = [];
|
|
13589
|
+
for (const section of this.getHeadingSections()) {
|
|
13590
|
+
const previous = this._collapsedHeadingSections[this._collapsedHeadingSections.length - 1];
|
|
13591
|
+
if (section.collapsed && section.endOffset > section.startOffset && (!previous || section.startOffset >= previous.endOffset)) this._collapsedHeadingSections.push(section);
|
|
13592
|
+
}
|
|
13593
|
+
}
|
|
13594
|
+
let low = 0;
|
|
13595
|
+
let high = this._collapsedHeadingSections.length - 1;
|
|
13596
|
+
while (low <= high) {
|
|
13597
|
+
const middle = Math.floor((low + high) / 2);
|
|
13598
|
+
const section = this._collapsedHeadingSections[middle];
|
|
13599
|
+
if (offset < section.startOffset) high = middle - 1;
|
|
13600
|
+
else if (offset >= section.endOffset) low = middle + 1;
|
|
13601
|
+
else return section;
|
|
13602
|
+
}
|
|
13603
|
+
}
|
|
13519
13604
|
getBody() {
|
|
13520
13605
|
const presentation = getDocumentLayoutPresentation(this._documentDataModel);
|
|
13521
13606
|
return presentation ? presentation.getSnapshot(this._documentDataModel.getSnapshot()).body : this._documentDataModel.getBody();
|
|
@@ -13536,6 +13621,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13536
13621
|
return this;
|
|
13537
13622
|
}
|
|
13538
13623
|
reset(documentDataModel) {
|
|
13624
|
+
this._headingSections = null;
|
|
13625
|
+
this._collapsedHeadingSections = null;
|
|
13539
13626
|
this._children.forEach((child) => child.dispose());
|
|
13540
13627
|
this._textRunsCache.clear();
|
|
13541
13628
|
this._paragraphCache.clear();
|
|
@@ -13561,6 +13648,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13561
13648
|
if (edit.insertText.length > 0 && !this._insertPlainText(edit.offset, edit.insertText)) return false;
|
|
13562
13649
|
}
|
|
13563
13650
|
this._documentDataModel = documentDataModel;
|
|
13651
|
+
this._headingSections = null;
|
|
13652
|
+
this._collapsedHeadingSections = null;
|
|
13564
13653
|
this._metadataCachesDirty = true;
|
|
13565
13654
|
this._lastTextRun = null;
|
|
13566
13655
|
if (!this._textRunsOrderedAndDisjoint) this._buildTextRunsCache();
|
|
@@ -13570,6 +13659,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13570
13659
|
const rootFields = getNonStructuralMutationRootFields(actions);
|
|
13571
13660
|
if (rootFields == null) return false;
|
|
13572
13661
|
this._documentDataModel = documentDataModel;
|
|
13662
|
+
this._headingSections = null;
|
|
13663
|
+
this._collapsedHeadingSections = null;
|
|
13573
13664
|
this._metadataCachesDirty = true;
|
|
13574
13665
|
this._lastTextRun = null;
|
|
13575
13666
|
if (rootFields.has("tableSource")) {
|
|
@@ -16708,7 +16799,23 @@ function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsB
|
|
|
16708
16799
|
|
|
16709
16800
|
//#endregion
|
|
16710
16801
|
//#region src/components/docs/layout/block/paragraph/paragraph-layout.ts
|
|
16802
|
+
/**
|
|
16803
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16804
|
+
*
|
|
16805
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16806
|
+
* you may not use this file except in compliance with the License.
|
|
16807
|
+
* You may obtain a copy of the License at
|
|
16808
|
+
*
|
|
16809
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16810
|
+
*
|
|
16811
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16812
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16813
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16814
|
+
* See the License for the specific language governing permissions and
|
|
16815
|
+
* limitations under the License.
|
|
16816
|
+
*/
|
|
16711
16817
|
function dealWidthParagraph(ctx, viewModel, paragraphNode, curPage, sectionBreakConfig, nextParagraphNode) {
|
|
16818
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) return [curPage];
|
|
16712
16819
|
clearFontCreateConfigCache();
|
|
16713
16820
|
const { content = "", children } = paragraphNode;
|
|
16714
16821
|
let tableSkeleton = null;
|
|
@@ -16961,6 +17068,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16961
17068
|
const paragraphEndIndex = Math.min(sectionNode.children.length, paragraphStartIndex + ((options === null || options === void 0 ? void 0 : options.maxParagraphs) ?? Number.POSITIVE_INFINITY));
|
|
16962
17069
|
for (let i = paragraphStartIndex; i < paragraphEndIndex; i++) {
|
|
16963
17070
|
const paragraphNode = sectionNode.children[i];
|
|
17071
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) continue;
|
|
16964
17072
|
let skeletonPages = [];
|
|
16965
17073
|
let currentPageCache = curPage;
|
|
16966
17074
|
if (allCurrentSkeletonPages.length > 0) currentPageCache = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];
|
|
@@ -16978,7 +17086,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16978
17086
|
if (ctx.isDirty) break;
|
|
16979
17087
|
}
|
|
16980
17088
|
const { segmentId } = curPage;
|
|
16981
|
-
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null)
|
|
17089
|
+
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null) rollbackSectionPages(ctx.layoutStartPointer[segmentId], allCurrentSkeletonPages);
|
|
16982
17090
|
return {
|
|
16983
17091
|
pages: allCurrentSkeletonPages,
|
|
16984
17092
|
renderedBlockIdMap,
|
|
@@ -16986,7 +17094,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16986
17094
|
complete: paragraphEndIndex >= sectionNode.children.length
|
|
16987
17095
|
};
|
|
16988
17096
|
}
|
|
16989
|
-
function
|
|
17097
|
+
function rollbackSectionPages(paragraphIndex, allCurrentSkeletonPages) {
|
|
16990
17098
|
let findFirstDirtyLine = false;
|
|
16991
17099
|
for (let pageIndex = 0; pageIndex < allCurrentSkeletonPages.length; pageIndex++) {
|
|
16992
17100
|
const page = allCurrentSkeletonPages[pageIndex];
|
|
@@ -17486,8 +17594,13 @@ function resetCellDrawingAnchors(ctx, cellNode, tableId) {
|
|
|
17486
17594
|
if (!anchors) return;
|
|
17487
17595
|
for (const paragraph of cellNode.children[0].children) anchors.delete(paragraph.endIndex);
|
|
17488
17596
|
}
|
|
17489
|
-
function createSkeletonCellPages(
|
|
17597
|
+
function createSkeletonCellPages(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17490
17598
|
var _ctx$dataModel, _ctx$dataModel$getBod;
|
|
17599
|
+
const ctx = {
|
|
17600
|
+
...parentContext,
|
|
17601
|
+
isDirty: false,
|
|
17602
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17603
|
+
};
|
|
17491
17604
|
const sectionNode = cellNode.children[0];
|
|
17492
17605
|
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);
|
|
17493
17606
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
@@ -17526,7 +17639,12 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
|
|
|
17526
17639
|
finishVerticalCellLayout(pages, verticalCellWidth);
|
|
17527
17640
|
return pages;
|
|
17528
17641
|
}
|
|
17529
|
-
function startSkeletonCellPagesBuild(
|
|
17642
|
+
function startSkeletonCellPagesBuild(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17643
|
+
const ctx = {
|
|
17644
|
+
...parentContext,
|
|
17645
|
+
isDirty: false,
|
|
17646
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17647
|
+
};
|
|
17530
17648
|
const sectionNode = cellNode.children[0];
|
|
17531
17649
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
17532
17650
|
const { page, sectionBreakConfig: cellSectionBreakConfig, verticalCellWidth } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight, inheritDocumentLinePitch, enableDocumentTableLineGrid, cellPageHeights);
|
|
@@ -18232,6 +18350,7 @@ function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBrea
|
|
|
18232
18350
|
marginTop: 0,
|
|
18233
18351
|
spaceBelowApply: (preLine === null || preLine === void 0 ? void 0 : preLine.spaceBelowApply) ?? 0
|
|
18234
18352
|
} : __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);
|
|
18353
|
+
if (preLine) marginTop += sectionBreakConfig.lineGap ?? 0;
|
|
18235
18354
|
if (startingSection && marginTop > 0 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy)) marginTop = _collapseSectionBeforeSpacing(ctx, startingSection.children[0].startIndex - 2, marginTop);
|
|
18236
18355
|
if (positionedCustomBlockOnly) spaceBelowApply = 0;
|
|
18237
18356
|
const isHiddenCellEndMark = lastPage.type === 3 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy) && sectionBreakConfig.cellHiddenEndMarkIndex === paragraphIndex && paragraphConfig.bulletSkeleton == null && glyphGroup.length > 0 && glyphGroup.every(__isStructuralTerminatorGlyph);
|
|
@@ -18378,7 +18497,9 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18378
18497
|
needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, pages, column, section, skeTablesInParagraph, paragraphConfig.paragraphIndex, sectionBreakConfig, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get2 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get2 === void 0 ? void 0 : _pDrawingAnchor$get2.top);
|
|
18379
18498
|
}
|
|
18380
18499
|
const hasSameParagraphTopBottomDrawingWithInline = hasInlineCustomBlock && paragraphNonInlineSkeDrawings != null && [...paragraphNonInlineSkeDrawings.values()].some((drawing) => drawing.drawingOrigin.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
|
|
18381
|
-
|
|
18500
|
+
let tableFlowTop = lineTop;
|
|
18501
|
+
for (const item of skeTablesInParagraph ?? []) if (item.hasPositioned && item.table.parent === lastPage && item.table.tableSource.textWrap === _univerjs_core.TableTextWrapType.NONE) tableFlowTop = Math.max(lineTop, item.table.top + item.table.height - section.top);
|
|
18502
|
+
const calculatedLineTop = positionedCustomBlockOnly ? tableFlowTop : calculateLineTopByDrawings(lineHeight, tableFlowTop, lastPage, headerPage, footerPage, column.left, column.width, section.top, isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy) ? Math.max(24, Math.min(__getGlyphGroupWidth(glyphGroup) - .001, column.width - 1)) : 0);
|
|
18382
18503
|
const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
|
|
18383
18504
|
const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
|
|
18384
18505
|
const clipsSameParagraphInlineDrawing = hasSameParagraphTopBottomDrawingWithInline && newLineTop < section.height;
|
|
@@ -18431,7 +18552,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18431
18552
|
if (borderTopSpace > 0) newLine.borderTopSpace = borderTopSpace;
|
|
18432
18553
|
if (borderBottomSpace > 0) newLine.borderBottomSpace = borderBottomSpace;
|
|
18433
18554
|
const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
|
|
18434
|
-
if (!isStandalonePageBoundary)
|
|
18555
|
+
if (!isStandalonePageBoundary) {
|
|
18556
|
+
createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
|
|
18557
|
+
const paragraphDrawingAnchor = pDrawingAnchor === null || pDrawingAnchor === void 0 ? void 0 : pDrawingAnchor.get(paragraphIndex);
|
|
18558
|
+
if (paragraphDrawingAnchor) paragraphDrawingAnchor.left = paragraphAnchorLeft;
|
|
18559
|
+
}
|
|
18435
18560
|
if (deferredTopBottomAnchorDrawings.length > 0) {
|
|
18436
18561
|
__updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, false, true);
|
|
18437
18562
|
__updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings, section.top);
|
|
@@ -18446,6 +18571,10 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
|
|
|
18446
18571
|
if (targetDrawings.length === 0) return;
|
|
18447
18572
|
const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
|
|
18448
18573
|
if (drawings == null || drawings.size === 0) return;
|
|
18574
|
+
for (const drawing of drawings.values()) if (drawing.drawingOrigin.docTransform.positionV.relativeFrom === _univerjs_core.ObjectRelativeFromV.LINE) {
|
|
18575
|
+
var _ctx$skeletonResource;
|
|
18576
|
+
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;
|
|
18577
|
+
}
|
|
18449
18578
|
const floatObjects = [...drawings.values()].filter((drawing) => {
|
|
18450
18579
|
const layoutType = drawing.drawingOrigin.layoutType;
|
|
18451
18580
|
return layoutType !== _univerjs_core.PositionedObjectLayoutType.INLINE && layoutType !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE;
|
|
@@ -18918,7 +19047,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
|
|
|
18918
19047
|
lineSpacingApply: exactLineSpacingApply
|
|
18919
19048
|
};
|
|
18920
19049
|
}
|
|
18921
|
-
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy) {
|
|
19050
|
+
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy, blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = false) {
|
|
18922
19051
|
var _line$parent;
|
|
18923
19052
|
const column = line.parent;
|
|
18924
19053
|
const section = column === null || column === void 0 ? void 0 : column.parent;
|
|
@@ -18984,6 +19113,9 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId =
|
|
|
18984
19113
|
drawing.lineTop = lineTop;
|
|
18985
19114
|
drawing.columnLeft = column.left;
|
|
18986
19115
|
drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
|
|
19116
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19117
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor;
|
|
19118
|
+
drawing.pageAnchorLeft = normalizeTraditionalColumnAnchor ? page.marginLeft : 0;
|
|
18987
19119
|
drawing.lineHeight = line.lineHeight;
|
|
18988
19120
|
drawings.set(drawing.drawingId, drawing);
|
|
18989
19121
|
}
|
|
@@ -19041,6 +19173,9 @@ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirst
|
|
|
19041
19173
|
} : void 0;
|
|
19042
19174
|
drawing.initialState = true;
|
|
19043
19175
|
drawing.columnLeft = column.left;
|
|
19176
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19177
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL;
|
|
19178
|
+
drawing.pageAnchorLeft = ctx.dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.TRADITIONAL ? page.marginLeft : 0;
|
|
19044
19179
|
drawing.lineTop = absoluteLineTop;
|
|
19045
19180
|
drawing.lineHeight = lineHeight;
|
|
19046
19181
|
drawing.isPageBreak = isPageBreak;
|
|
@@ -19456,7 +19591,7 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
|
|
|
19456
19591
|
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);
|
|
19457
19592
|
if (affectInlineDrawings && affectInlineDrawings.size > 0) {
|
|
19458
19593
|
var _ctx$dataModel$getUni, _ctx$dataModel;
|
|
19459
|
-
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);
|
|
19594
|
+
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);
|
|
19460
19595
|
}
|
|
19461
19596
|
const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
|
|
19462
19597
|
const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
|
|
@@ -21218,8 +21353,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
21218
21353
|
//#endregion
|
|
21219
21354
|
//#region src/components/docs/layout/document-layout-page-patch.ts
|
|
21220
21355
|
function withoutParent(value) {
|
|
21221
|
-
const
|
|
21222
|
-
delete copy.parent;
|
|
21356
|
+
const { parent: _parent, ...copy } = value;
|
|
21223
21357
|
return copy;
|
|
21224
21358
|
}
|
|
21225
21359
|
function serializeDivide(source) {
|
|
@@ -21287,10 +21421,10 @@ function serializeDocumentSkeletonPage(source, omitResourceSources = false) {
|
|
|
21287
21421
|
return {
|
|
21288
21422
|
...geometry,
|
|
21289
21423
|
sections: source.sections.map(serializeSection),
|
|
21290
|
-
noteDecorations
|
|
21424
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21291
21425
|
...decoration,
|
|
21292
21426
|
page: serializeDocumentSkeletonPage(decoration.page, omitResourceSources)
|
|
21293
|
-
})),
|
|
21427
|
+
})) },
|
|
21294
21428
|
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21295
21429
|
...withoutParent(note),
|
|
21296
21430
|
page: serializeDocumentSkeletonPage(note.page, omitResourceSources)
|
|
@@ -21430,18 +21564,18 @@ function hydrateDocumentSkeletonPageMaterializationPlaceholder(source, parent) {
|
|
|
21430
21564
|
return placeholder;
|
|
21431
21565
|
}
|
|
21432
21566
|
function hydrateDocumentSkeletonPageInternal(source, parent, snapshot, resourceSegmentId) {
|
|
21433
|
-
|
|
21567
|
+
const { notes, noteDecorations, ...geometry } = source;
|
|
21434
21568
|
const page = {
|
|
21435
|
-
...
|
|
21569
|
+
...geometry,
|
|
21436
21570
|
sections: [],
|
|
21437
|
-
noteDecorations
|
|
21571
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21438
21572
|
...decoration,
|
|
21439
21573
|
page: hydrateDocumentSkeletonPageInternal(decoration.page, void 0, snapshot, decoration.page.segmentId)
|
|
21440
|
-
})),
|
|
21441
|
-
notes
|
|
21574
|
+
})) },
|
|
21575
|
+
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21442
21576
|
...note,
|
|
21443
21577
|
page: hydrateDocumentSkeletonPageInternal(note.page, void 0, snapshot, note.noteId)
|
|
21444
|
-
})),
|
|
21578
|
+
})) },
|
|
21445
21579
|
skeDrawings: new Map(source.skeDrawings.map(([drawingId, drawing]) => [drawingId, hydrateDrawing(drawing, snapshot, resourceSegmentId)])),
|
|
21446
21580
|
skeTables: /* @__PURE__ */ new Map(),
|
|
21447
21581
|
skeColumnGroups: /* @__PURE__ */ new Map(),
|
|
@@ -23425,6 +23559,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23425
23559
|
_defineProperty(this, "_paginationMetrics", null);
|
|
23426
23560
|
_defineProperty(this, "_completedPageCount", void 0);
|
|
23427
23561
|
_defineProperty(this, "_lastCompleteSkeletonData", null);
|
|
23562
|
+
_defineProperty(this, "_completedHeadingCollapseSignature", "[]");
|
|
23563
|
+
_defineProperty(this, "_publishedHeadingCollapseSignature", "[]");
|
|
23428
23564
|
_defineProperty(this, "_pendingInvalidationAnchor", null);
|
|
23429
23565
|
_defineProperty(this, "_layoutGeneration", 0);
|
|
23430
23566
|
_defineProperty(this, "_activeLayout", null);
|
|
@@ -23436,7 +23572,9 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23436
23572
|
_defineProperty(this, "_isolateIncrementalPublications", void 0);
|
|
23437
23573
|
_defineProperty(this, "_modernPageWidth", void 0);
|
|
23438
23574
|
_defineProperty(this, "_modernHorizontalMargin", void 0);
|
|
23575
|
+
_defineProperty(this, "_lineGap", void 0);
|
|
23439
23576
|
this._isolateIncrementalPublications = options.isolateIncrementalPublications !== false;
|
|
23577
|
+
this._lineGap = options.lineGap ?? 0;
|
|
23440
23578
|
}
|
|
23441
23579
|
static create(docViewModel, localeService, options) {
|
|
23442
23580
|
return new DocumentSkeleton(docViewModel, localeService, options);
|
|
@@ -23480,29 +23618,48 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23480
23618
|
ctx = retry;
|
|
23481
23619
|
}
|
|
23482
23620
|
this._lastCompleteSkeletonData = this._skeletonData;
|
|
23621
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23622
|
+
this._publishedHeadingCollapseSignature = this._completedHeadingCollapseSignature;
|
|
23483
23623
|
this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
|
|
23484
23624
|
this._pendingInvalidationAnchor = null;
|
|
23485
23625
|
this._paginationMetrics = ctx.paginationMetrics ?? null;
|
|
23486
23626
|
this._dirty$.next(true);
|
|
23487
23627
|
}
|
|
23628
|
+
_getHeadingCollapseSignature() {
|
|
23629
|
+
return JSON.stringify(this.getViewModel().getHeadingSections().filter((heading) => heading.collapsed).map((heading) => [
|
|
23630
|
+
heading.paragraphId,
|
|
23631
|
+
heading.startOffset,
|
|
23632
|
+
heading.endOffset
|
|
23633
|
+
]));
|
|
23634
|
+
}
|
|
23488
23635
|
startIncrementalLayout(options) {
|
|
23489
|
-
|
|
23490
|
-
|
|
23636
|
+
const headingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23637
|
+
const headingVisibilityChanged = headingCollapseSignature !== this._completedHeadingCollapseSignature || headingCollapseSignature !== this._publishedHeadingCollapseSignature;
|
|
23638
|
+
const layoutOptions = headingVisibilityChanged ? {
|
|
23639
|
+
...options,
|
|
23640
|
+
anchor: 0,
|
|
23641
|
+
priorityAnchor: (options === null || options === void 0 ? void 0 : options.priorityAnchor) ?? (options === null || options === void 0 ? void 0 : options.anchor) ?? 0,
|
|
23642
|
+
invalidation: void 0,
|
|
23643
|
+
reuseUnaffectedTail: false,
|
|
23644
|
+
preserveInteractionWindow: false
|
|
23645
|
+
} : options;
|
|
23646
|
+
this._modernPageWidth = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernPageWidth;
|
|
23647
|
+
this._modernHorizontalMargin = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernHorizontalMargin;
|
|
23491
23648
|
this.cancelIncrementalLayout();
|
|
23492
23649
|
this._externalLayoutProgress = null;
|
|
23493
23650
|
this._externalProtectedPages = null;
|
|
23494
23651
|
this._externalProtectedContinuousLayout = null;
|
|
23495
23652
|
const generation = ++this._layoutGeneration;
|
|
23496
|
-
const reason = (
|
|
23653
|
+
const reason = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reason) ?? ((layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor) == null ? "initial" : "edit");
|
|
23497
23654
|
const dataModel = this.getViewModel().getDataModel();
|
|
23498
23655
|
const sections = this.getViewModel().getChildren();
|
|
23499
23656
|
const topLevelBlocks = this._getTopLevelBlocks(sections);
|
|
23500
23657
|
const mode = dataModel.documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.MODERN ? "continuous" : "paginated";
|
|
23501
|
-
const priorityAnchor = (
|
|
23658
|
+
const priorityAnchor = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.priorityAnchor) ?? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor);
|
|
23502
23659
|
const hasPublishedCheckpoint = this._skeletonData != null || this._lastCompleteSkeletonData != null;
|
|
23503
23660
|
const previousSkeleton = this._lastCompleteSkeletonData ?? this._skeletonData;
|
|
23504
|
-
const invalidation =
|
|
23505
|
-
const layoutAnchor =
|
|
23661
|
+
const invalidation = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.invalidation;
|
|
23662
|
+
const layoutAnchor = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor;
|
|
23506
23663
|
const invalidationAnchor = layoutAnchor == null ? this._pendingInvalidationAnchor ?? void 0 : Math.min(layoutAnchor, this._pendingInvalidationAnchor ?? layoutAnchor);
|
|
23507
23664
|
const mutationDelta = invalidation == null ? 0 : invalidation.newEnd - invalidation.oldEnd;
|
|
23508
23665
|
let priorityPageAnchor = priorityAnchor;
|
|
@@ -23515,7 +23672,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23515
23672
|
const previousPriorityPage = priorityPageIndex < 0 ? null : (previousSkeleton === null || previousSkeleton === void 0 ? void 0 : previousSkeleton.pages[priorityPageIndex]) ?? null;
|
|
23516
23673
|
const previousPriorityPageEnd = previousPriorityPage == null ? null : getLastBodyFlowCharIndex(previousPriorityPage);
|
|
23517
23674
|
const priorityPageEnd = previousPriorityPageEnd == null ? null : previousPriorityPageEnd + (invalidation != null && invalidation.oldStart <= previousPriorityPageEnd ? mutationDelta : 0);
|
|
23518
|
-
const incrementalStart = this._prepareIncrementalLayoutStart(invalidationAnchor, mode, invalidation, (
|
|
23675
|
+
const incrementalStart = this._prepareIncrementalLayoutStart(invalidationAnchor, mode, invalidation, (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.preserveInteractionWindow) === true, (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) === false);
|
|
23519
23676
|
this._pendingInvalidationAnchor = hasPublishedCheckpoint ? invalidationAnchor ?? null : null;
|
|
23520
23677
|
this._activeLayout = {
|
|
23521
23678
|
generation,
|
|
@@ -23529,6 +23686,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23529
23686
|
sectionBreakConfig: null,
|
|
23530
23687
|
layoutAnchor: incrementalStart.layoutAnchor,
|
|
23531
23688
|
priorityAnchor: priorityAnchor ?? null,
|
|
23689
|
+
minimumPublicationHeight: mode === "continuous" && headingVisibilityChanged && this._skeletonData != null ? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.minimumPublicationHeight) ?? 0 : 0,
|
|
23532
23690
|
priorityPageIndex,
|
|
23533
23691
|
priorityPageEnd,
|
|
23534
23692
|
interactionPageTail: incrementalStart.interactionPageTail,
|
|
@@ -23553,16 +23711,16 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23553
23711
|
lastPublishedPageCount: incrementalStart.ctx.skeleton.pages.length > 0 ? Math.max(0, incrementalStart.ctx.skeleton.pages.length - 1) : 0,
|
|
23554
23712
|
lastPublishedBlockCount: incrementalStart.processedBlockCount,
|
|
23555
23713
|
publicationRevision: 0,
|
|
23556
|
-
reuseUnaffectedTail: (
|
|
23714
|
+
reuseUnaffectedTail: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) !== false,
|
|
23557
23715
|
paginationRevision: 0,
|
|
23558
|
-
allowMetadataOnlyStructuralTailReuse: (
|
|
23716
|
+
allowMetadataOnlyStructuralTailReuse: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.allowMetadataOnlyStructuralTailReuse) === true,
|
|
23559
23717
|
reusedTail: false,
|
|
23560
23718
|
tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
|
|
23561
23719
|
dirtyRetries: /* @__PURE__ */ new Map(),
|
|
23562
23720
|
preparedHyphenationNodes: /* @__PURE__ */ new WeakSet(),
|
|
23563
23721
|
pendingHyphenation: null,
|
|
23564
23722
|
hyphenationError: null,
|
|
23565
|
-
waitForHyphenationPatterns: (
|
|
23723
|
+
waitForHyphenationPatterns: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.waitForHyphenationPatterns) === true
|
|
23566
23724
|
};
|
|
23567
23725
|
return generation;
|
|
23568
23726
|
}
|
|
@@ -23937,10 +24095,12 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23937
24095
|
if (isFinalPublication) {
|
|
23938
24096
|
var _state$ctx$skeleton;
|
|
23939
24097
|
this._lastCompleteSkeletonData = state.ctx.skeleton;
|
|
24098
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23940
24099
|
this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
|
|
23941
24100
|
this._pendingInvalidationAnchor = null;
|
|
23942
24101
|
}
|
|
23943
24102
|
this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
|
|
24103
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23944
24104
|
this._paginationMetrics = state.ctx.paginationMetrics ?? null;
|
|
23945
24105
|
this._dirty$.next(true);
|
|
23946
24106
|
didPublish = true;
|
|
@@ -23965,6 +24125,19 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23965
24125
|
const startIndex = ((_stablePages$at = stablePages.at(-1)) === null || _stablePages$at === void 0 ? void 0 : _stablePages$at.ed) ?? -1;
|
|
23966
24126
|
updateBlockIndex(activePages, startIndex, state.ctx.docsConfig.documentCompatibilityPolicy);
|
|
23967
24127
|
mergeContinuousDuplicatePages(activePages, state.mode === "continuous");
|
|
24128
|
+
if (state.mode === "continuous") {
|
|
24129
|
+
const paragraphConfigCache = new Map([...state.ctx.paragraphConfigCache].map(([segmentId, configs]) => [segmentId, new Map([...configs].map(([index, config]) => {
|
|
24130
|
+
var _config$paragraphInli;
|
|
24131
|
+
return [index, ((_config$paragraphInli = config.paragraphInlineSkeDrawings) === null || _config$paragraphInli === void 0 ? void 0 : _config$paragraphInli.size) ? {
|
|
24132
|
+
...config,
|
|
24133
|
+
paragraphInlineSkeDrawings: new Map([...config.paragraphInlineSkeDrawings].map(([id, drawing]) => [id, { ...drawing }]))
|
|
24134
|
+
} : config];
|
|
24135
|
+
}))]));
|
|
24136
|
+
updateInlineDrawingCoordsAndBorder({
|
|
24137
|
+
...state.ctx,
|
|
24138
|
+
paragraphConfigCache
|
|
24139
|
+
}, activePages);
|
|
24140
|
+
}
|
|
23968
24141
|
const flowPages = [...stablePages, ...activePages];
|
|
23969
24142
|
const currentPriorityPageIndex = state.priorityAnchor == null ? -1 : this._findBodyPageIndex(flowPages, state.priorityAnchor);
|
|
23970
24143
|
const previousPriorityPage = previous === null || previous === void 0 ? void 0 : previous.pages[state.priorityPageIndex];
|
|
@@ -24238,6 +24411,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24238
24411
|
if (progress.complete) {
|
|
24239
24412
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24240
24413
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24414
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24241
24415
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24242
24416
|
this._pendingInvalidationAnchor = null;
|
|
24243
24417
|
this._externalProtectedContinuousLayout = null;
|
|
@@ -24308,6 +24482,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24308
24482
|
if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
|
|
24309
24483
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24310
24484
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24485
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24311
24486
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24312
24487
|
this._pendingInvalidationAnchor = null;
|
|
24313
24488
|
this._externalProtectedPages = null;
|
|
@@ -24315,6 +24490,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24315
24490
|
}
|
|
24316
24491
|
this._skeletonData = skeletonData;
|
|
24317
24492
|
this._externalLayoutProgress = progress.complete ? null : progress;
|
|
24493
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24318
24494
|
this._dirty$.next(true);
|
|
24319
24495
|
this._layoutProgress$.next(progress);
|
|
24320
24496
|
return { didReplaceProtectedPages };
|
|
@@ -24368,7 +24544,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24368
24544
|
const firstUnprotectedLineOffset = flow.lines.findIndex((line) => line.st > protectedEndOffset);
|
|
24369
24545
|
if (firstUnprotectedLineOffset < 0) return null;
|
|
24370
24546
|
const existingColumn = (_skeletonData$pages$p = skeletonData.pages[publication.block.pageIndex]) === null || _skeletonData$pages$p === void 0 || (_skeletonData$pages$p = _skeletonData$pages$p.sections[flow.sectionIndex]) === null || _skeletonData$pages$p === void 0 ? void 0 : _skeletonData$pages$p.columns[flow.columnIndex];
|
|
24371
|
-
if (existingColumn == null)
|
|
24547
|
+
if (existingColumn == null) return null;
|
|
24372
24548
|
const firstUnprotectedLine = flow.lines[firstUnprotectedLineOffset];
|
|
24373
24549
|
const matchingTailLineIndex = existingColumn.lines.findIndex((line) => line.st >= firstUnprotectedLine.st);
|
|
24374
24550
|
const targetLineIndex = matchingTailLineIndex < 0 ? existingColumn.lines.length : matchingTailLineIndex;
|
|
@@ -24862,11 +25038,13 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24862
25038
|
if (!isHitTestAddressableGlyph(glyph)) continue;
|
|
24863
25039
|
const startX = divideLeft + glyph.left;
|
|
24864
25040
|
const endX = startX + glyph.width;
|
|
25041
|
+
const contentTop = startY + (line.marginTop ?? 0) + (line.paddingTop ?? 0);
|
|
24865
25042
|
const node = {
|
|
24866
25043
|
node: glyph,
|
|
24867
25044
|
...segment,
|
|
24868
25045
|
ratioX: x / (startX + endX),
|
|
24869
|
-
ratioY: y / (startY + endY)
|
|
25046
|
+
ratioY: y / (startY + endY),
|
|
25047
|
+
isInsideGlyph: x >= startX && x <= endX && y >= contentTop && y <= contentTop + line.contentHeight
|
|
24870
25048
|
};
|
|
24871
25049
|
if (sameLine && x >= startX && x <= endX) return node;
|
|
24872
25050
|
if (distanceY < nearestDistanceY) {
|
|
@@ -24917,7 +25095,8 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
24917
25095
|
node: glyph,
|
|
24918
25096
|
...segment,
|
|
24919
25097
|
ratioX: x / (startX + endX),
|
|
24920
|
-
ratioY: y / (startY + endY)
|
|
25098
|
+
ratioY: y / (startY + endY),
|
|
25099
|
+
isInsideGlyph: x >= startX && x <= endX && sameLine
|
|
24921
25100
|
};
|
|
24922
25101
|
const hitsGlyphAdvance = x >= startX && x <= endX;
|
|
24923
25102
|
if (sameLine) {
|
|
@@ -25100,7 +25279,23 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25100
25279
|
const anchor = state.priorityAnchor;
|
|
25101
25280
|
if (anchor == null || state.complete) return true;
|
|
25102
25281
|
if (state.interactionPageComplete) return true;
|
|
25103
|
-
if (state.mode === "continuous")
|
|
25282
|
+
if (state.mode === "continuous") {
|
|
25283
|
+
if (state.laidOutThrough < anchor) return false;
|
|
25284
|
+
if (state.minimumPublicationHeight <= 0) return true;
|
|
25285
|
+
let height = 0;
|
|
25286
|
+
for (const page of state.ctx.skeleton.pages) for (const section of page.sections) {
|
|
25287
|
+
let sectionHeight = 0;
|
|
25288
|
+
for (const column of section.columns) for (let index = column.lines.length - 1; index >= 0; index--) {
|
|
25289
|
+
const line = column.lines[index];
|
|
25290
|
+
if (line.paragraphIndex <= state.stableLaidOutThrough) {
|
|
25291
|
+
sectionHeight = Math.max(sectionHeight, line.top + line.lineHeight);
|
|
25292
|
+
break;
|
|
25293
|
+
}
|
|
25294
|
+
}
|
|
25295
|
+
height += sectionHeight;
|
|
25296
|
+
}
|
|
25297
|
+
return height >= state.minimumPublicationHeight;
|
|
25298
|
+
}
|
|
25104
25299
|
if (state.priorityPageEnd != null) {
|
|
25105
25300
|
var _state$invalidation;
|
|
25106
25301
|
const requiredOffset = Math.max(anchor, state.priorityPageEnd, ((_state$invalidation = state.invalidation) === null || _state$invalidation === void 0 ? void 0 : _state$invalidation.newEnd) ?? anchor);
|
|
@@ -25287,7 +25482,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25287
25482
|
const curSkeletonPage = getLastPage(ctx.skeleton.pages);
|
|
25288
25483
|
if (sectionBreakConfig == null || curSkeletonPage == null) throw new Error("Incremental document layout failed to initialize a section page.");
|
|
25289
25484
|
const paragraphNode = sectionNode.children[state.paragraphIndex];
|
|
25290
|
-
const tableNode =
|
|
25485
|
+
const tableNode = paragraphNode && !ctx.viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex) && paragraphNode.children.length === 1 && paragraphNode.children[0].nodeType === _univerjs_core.DataStreamTreeNodeType.TABLE ? paragraphNode.children[0] : null;
|
|
25291
25486
|
if (tableNode != null) {
|
|
25292
25487
|
state.pendingTableBuild ??= startTableSkeletonBuild(ctx, curSkeletonPage, ctx.viewModel, tableNode, sectionBreakConfig);
|
|
25293
25488
|
if (state.pendingTableBuild != null && !stepTableSkeletonBuild(state.pendingTableBuild)) return;
|
|
@@ -25487,6 +25682,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25487
25682
|
const section = sections[sectionIndex];
|
|
25488
25683
|
const paragraphIndex = Math.max(0, (section === null || section === void 0 ? void 0 : section.children.findIndex(({ endIndex }) => endIndex === layoutAnchor)) ?? 0);
|
|
25489
25684
|
const processedBeforeSection = sections.slice(0, sectionIndex).reduce((count, item) => count + item.children.length, 0);
|
|
25685
|
+
rollbackSectionPages(layoutAnchor, ctx.skeleton.pages);
|
|
25490
25686
|
state.sectionIndex = sectionIndex;
|
|
25491
25687
|
state.paragraphIndex = paragraphIndex;
|
|
25492
25688
|
state.sectionInitialized = false;
|
|
@@ -25597,6 +25793,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25597
25793
|
};
|
|
25598
25794
|
const { paragraphLineGapDefault = 0, defaultTabStop = 10.5, textStyle = {}, adjustLineHeightInTable = _univerjs_core.BooleanNumber.FALSE } = documentStyle;
|
|
25599
25795
|
const docsConfig = {
|
|
25796
|
+
lineGap: this._lineGap,
|
|
25600
25797
|
headerTreeMap,
|
|
25601
25798
|
footerTreeMap,
|
|
25602
25799
|
lists,
|
|
@@ -25892,7 +26089,7 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
25892
26089
|
};
|
|
25893
26090
|
|
|
25894
26091
|
//#endregion
|
|
25895
|
-
//#region \0@oxc-project+runtime@0.
|
|
26092
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
25896
26093
|
function __decorateParam(paramIndex, decorator) {
|
|
25897
26094
|
return function(target, key) {
|
|
25898
26095
|
decorator(target, key, paramIndex);
|
|
@@ -25900,7 +26097,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
25900
26097
|
}
|
|
25901
26098
|
|
|
25902
26099
|
//#endregion
|
|
25903
|
-
//#region \0@oxc-project+runtime@0.
|
|
26100
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
25904
26101
|
function __decorate(decorators, target, key, desc) {
|
|
25905
26102
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25906
26103
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -26027,6 +26224,8 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26027
26224
|
_defineProperty(this, "_gridlinesColor", void 0);
|
|
26028
26225
|
_defineProperty(this, "_defaultGridlinesColor", void 0);
|
|
26029
26226
|
_defineProperty(this, "_scene", null);
|
|
26227
|
+
_defineProperty(this, "textLineGap", void 0);
|
|
26228
|
+
this.textLineGap = _configService.getConfig(_univerjs_core.SHEET_TEXT_LINE_GAP) ?? 0;
|
|
26030
26229
|
const themeService = _injector.get(_univerjs_core.ThemeService);
|
|
26031
26230
|
this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
|
|
26032
26231
|
var _this$_scene, _this$_scene2;
|
|
@@ -26357,7 +26556,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26357
26556
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26358
26557
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26359
26558
|
if (typeof colWidth === "number" && wrapStrategy === _univerjs_core.WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(colWidth);
|
|
26360
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26559
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26361
26560
|
documentSkeleton.calculate();
|
|
26362
26561
|
let { height: h = 0 } = getDocsSkeletonPageSize(documentSkeleton, angle) ?? {};
|
|
26363
26562
|
if (documentSkeleton) {
|
|
@@ -26375,7 +26574,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26375
26574
|
const paddingTop = ((_style$pd3 = style.pd) === null || _style$pd3 === void 0 ? void 0 : _style$pd3.t) ?? DEFAULT_PADDING_DATA.t;
|
|
26376
26575
|
const paddingBottom = ((_style$pd4 = style.pd) === null || _style$pd4 === void 0 ? void 0 : _style$pd4.b) ?? DEFAULT_PADDING_DATA.b;
|
|
26377
26576
|
if ((style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP) {
|
|
26378
|
-
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);
|
|
26577
|
+
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);
|
|
26379
26578
|
skeleton.calculate();
|
|
26380
26579
|
return skeleton.getTotalHeight() + paddingTop + paddingBottom;
|
|
26381
26580
|
} else {
|
|
@@ -26491,7 +26690,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26491
26690
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26492
26691
|
if ((style === null || style === void 0 ? void 0 : style.tb) === _univerjs_core.WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(currColWidth, Infinity);
|
|
26493
26692
|
else documentModel.updateDocumentDataPageSize(Infinity, Infinity);
|
|
26494
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26693
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26495
26694
|
documentSkeleton.calculate();
|
|
26496
26695
|
measuredWidth = (getDocsSkeletonPageSize(documentSkeleton, angle) ?? { width: 0 }).width;
|
|
26497
26696
|
if (documentSkeleton) {
|
|
@@ -26774,7 +26973,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26774
26973
|
if (fontCache.documentSkeleton) {
|
|
26775
26974
|
const snapshot = fontCache.documentSkeleton.getViewModel().getDataModel().getSnapshot();
|
|
26776
26975
|
const documentModel = new _univerjs_core.DocumentDataModel(scaleDocumentDataForShrinkToFit(snapshot, scale, fallbackFontSize));
|
|
26777
|
-
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService);
|
|
26976
|
+
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService, { lineGap: this.textLineGap });
|
|
26778
26977
|
documentSkeleton.calculate();
|
|
26779
26978
|
fontCache.documentSkeleton = documentSkeleton;
|
|
26780
26979
|
} else fontCache.fontString = getFontStyleString({
|
|
@@ -26827,7 +27026,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends _univerjs_core.Sheet
|
|
|
26827
27026
|
if (FULL_WIDTH_HORIZONTAL_ALIGNMENTS.has(horizontalAlign)) updateDocumentPageWidth(documentModel, this.getCellWithCoordByIndex(row, col, false));
|
|
26828
27027
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26829
27028
|
if (documentViewModel) {
|
|
26830
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
27029
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26831
27030
|
documentSkeleton.calculate();
|
|
26832
27031
|
config = {
|
|
26833
27032
|
documentSkeleton,
|
|
@@ -27291,7 +27490,7 @@ var Font = class extends SheetExtension {
|
|
|
27291
27490
|
this._clipByRenderBounds(renderFontCtx, row, col);
|
|
27292
27491
|
ctx.translate(renderFontCtx.startX + FIX_ONE_PIXEL_BLUR_OFFSET, renderFontCtx.startY + FIX_ONE_PIXEL_BLUR_OFFSET);
|
|
27293
27492
|
if (fontCache.documentSkeleton) this._renderDocuments(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
|
|
27294
|
-
else this._renderText(ctx,
|
|
27493
|
+
else this._renderText(ctx, renderFontCtx);
|
|
27295
27494
|
ctx.restore();
|
|
27296
27495
|
if (fontCache.documentSkeleton) {
|
|
27297
27496
|
var _documentDataModel$ge;
|
|
@@ -27386,7 +27585,7 @@ var Font = class extends SheetExtension {
|
|
|
27386
27585
|
if (image.getAttribute("data-error") === "true") this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27387
27586
|
else try {
|
|
27388
27587
|
ctx.drawImage(image, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27389
|
-
} catch
|
|
27588
|
+
} catch {
|
|
27390
27589
|
this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27391
27590
|
}
|
|
27392
27591
|
ctx.restore();
|
|
@@ -27399,7 +27598,7 @@ var Font = class extends SheetExtension {
|
|
|
27399
27598
|
* @param renderFontContext
|
|
27400
27599
|
* @param row
|
|
27401
27600
|
* @param col
|
|
27402
|
-
* @param
|
|
27601
|
+
* @param padding
|
|
27403
27602
|
*/
|
|
27404
27603
|
_clipByRenderBounds(renderFontContext, row, col, padding = 0) {
|
|
27405
27604
|
var _fontCache$cellData3, _fontCache$cellData4;
|
|
@@ -27443,7 +27642,7 @@ var Font = class extends SheetExtension {
|
|
|
27443
27642
|
renderFontContext.endX = endX;
|
|
27444
27643
|
renderFontContext.endY = endY;
|
|
27445
27644
|
}
|
|
27446
|
-
_renderText(ctx,
|
|
27645
|
+
_renderText(ctx, renderFontCtx) {
|
|
27447
27646
|
var _fontCache$style5, _fontCache$style6, _fontCache$style7, _fontCache$style8, _fontCache$style9;
|
|
27448
27647
|
const { fontCache } = renderFontCtx;
|
|
27449
27648
|
if (!fontCache) return;
|
|
@@ -27463,6 +27662,7 @@ var Font = class extends SheetExtension {
|
|
|
27463
27662
|
text,
|
|
27464
27663
|
fontStyle: fontCache.fontString,
|
|
27465
27664
|
warp: wrapStrategy === _univerjs_core.WrapStrategy.WRAP && vertexAngle === 0,
|
|
27665
|
+
lineGap: renderFontCtx.spreadsheetSkeleton.textLineGap,
|
|
27466
27666
|
hAlign,
|
|
27467
27667
|
vAlign: fontCache.verticalAlign,
|
|
27468
27668
|
width: cellWidth,
|
|
@@ -27886,6 +28086,290 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
27886
28086
|
}
|
|
27887
28087
|
};
|
|
27888
28088
|
|
|
28089
|
+
//#endregion
|
|
28090
|
+
//#region src/group.ts
|
|
28091
|
+
var Group = class extends BaseObject {
|
|
28092
|
+
constructor(key, ...objects) {
|
|
28093
|
+
super(key);
|
|
28094
|
+
_defineProperty(this, "_objects", []);
|
|
28095
|
+
_defineProperty(this, "_selfSizeMode", false);
|
|
28096
|
+
this.addObjects(...objects);
|
|
28097
|
+
}
|
|
28098
|
+
get classType() {
|
|
28099
|
+
return "Group";
|
|
28100
|
+
}
|
|
28101
|
+
set cursor(val) {
|
|
28102
|
+
this.setCursor(val);
|
|
28103
|
+
}
|
|
28104
|
+
getState() {
|
|
28105
|
+
if (this._selfSizeMode) return super.getState();
|
|
28106
|
+
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
28107
|
+
}
|
|
28108
|
+
get width() {
|
|
28109
|
+
if (this._selfSizeMode) return super.width;
|
|
28110
|
+
return this.getState().width || 0;
|
|
28111
|
+
}
|
|
28112
|
+
get height() {
|
|
28113
|
+
if (this._selfSizeMode) return super.height;
|
|
28114
|
+
return this.getState().height || 0;
|
|
28115
|
+
}
|
|
28116
|
+
set width(val) {
|
|
28117
|
+
if (this._selfSizeMode) {
|
|
28118
|
+
super.width = val;
|
|
28119
|
+
return;
|
|
28120
|
+
}
|
|
28121
|
+
const numDelta = val - this.width;
|
|
28122
|
+
this._objects.forEach((o) => {
|
|
28123
|
+
o.resize(o.width + numDelta);
|
|
28124
|
+
});
|
|
28125
|
+
}
|
|
28126
|
+
set height(val) {
|
|
28127
|
+
if (this._selfSizeMode) {
|
|
28128
|
+
super.height = val;
|
|
28129
|
+
return;
|
|
28130
|
+
}
|
|
28131
|
+
const numDelta = val - this.height;
|
|
28132
|
+
this._objects.forEach((o) => {
|
|
28133
|
+
o.resize(void 0, o.height + numDelta);
|
|
28134
|
+
});
|
|
28135
|
+
}
|
|
28136
|
+
get maxZIndex() {
|
|
28137
|
+
let maxZIndex = 0;
|
|
28138
|
+
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
28139
|
+
return maxZIndex;
|
|
28140
|
+
}
|
|
28141
|
+
openSelfSizeMode() {
|
|
28142
|
+
this._selfSizeMode = true;
|
|
28143
|
+
}
|
|
28144
|
+
closeSelfSizeMode() {
|
|
28145
|
+
this._selfSizeMode = false;
|
|
28146
|
+
}
|
|
28147
|
+
reCalculateObjects() {
|
|
28148
|
+
if (this._selfSizeMode) return;
|
|
28149
|
+
const { left = 0, top = 0 } = this.getState();
|
|
28150
|
+
for (const object of this._objects) object.transformByState({
|
|
28151
|
+
left: object.left - left,
|
|
28152
|
+
top: object.top - top
|
|
28153
|
+
});
|
|
28154
|
+
this.transformByState({
|
|
28155
|
+
left,
|
|
28156
|
+
top
|
|
28157
|
+
});
|
|
28158
|
+
}
|
|
28159
|
+
addObjects(...objects) {
|
|
28160
|
+
for (const object of objects) this.addObject(object);
|
|
28161
|
+
}
|
|
28162
|
+
addObject(o) {
|
|
28163
|
+
let object = o;
|
|
28164
|
+
if (isString(o)) {
|
|
28165
|
+
const scene = this.getScene();
|
|
28166
|
+
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
28167
|
+
if (!object) return;
|
|
28168
|
+
object.parent = this;
|
|
28169
|
+
object.isInGroup = true;
|
|
28170
|
+
object.groupKey = this.oKey;
|
|
28171
|
+
this._objects.push(object);
|
|
28172
|
+
} else {
|
|
28173
|
+
o.parent = this;
|
|
28174
|
+
o.isInGroup = true;
|
|
28175
|
+
o.groupKey = this.oKey;
|
|
28176
|
+
this._objects.push(o);
|
|
28177
|
+
}
|
|
28178
|
+
}
|
|
28179
|
+
removeObject(object) {
|
|
28180
|
+
const objects = this.getObjects();
|
|
28181
|
+
const objectsLength = objects.length;
|
|
28182
|
+
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
28183
|
+
const o = objects[i];
|
|
28184
|
+
if (o.oKey === object) {
|
|
28185
|
+
objects.splice(i, 1);
|
|
28186
|
+
this.parent.removeObject(o);
|
|
28187
|
+
return;
|
|
28188
|
+
}
|
|
28189
|
+
}
|
|
28190
|
+
else for (let i = 0; i < objectsLength; i++) {
|
|
28191
|
+
const o = objects[i];
|
|
28192
|
+
if (o === object) {
|
|
28193
|
+
objects.splice(i, 1);
|
|
28194
|
+
this.parent.removeObject(o);
|
|
28195
|
+
return;
|
|
28196
|
+
}
|
|
28197
|
+
}
|
|
28198
|
+
}
|
|
28199
|
+
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
28200
|
+
const objects = [...this.getObjects()];
|
|
28201
|
+
const objectsLength = objects.length;
|
|
28202
|
+
if (width == null) width = this.width;
|
|
28203
|
+
if (height == null) height = this.height;
|
|
28204
|
+
for (let i = 0; i < objectsLength; i++) {
|
|
28205
|
+
const o = objects[i];
|
|
28206
|
+
if (o.oKey === oKey) {
|
|
28207
|
+
objects.splice(i, 1);
|
|
28208
|
+
isTransform && this._transformObject(o, width, height);
|
|
28209
|
+
o.parent = this.parent;
|
|
28210
|
+
o.groupKey = void 0;
|
|
28211
|
+
o.isInGroup = false;
|
|
28212
|
+
this._objects = objects;
|
|
28213
|
+
return;
|
|
28214
|
+
}
|
|
28215
|
+
}
|
|
28216
|
+
}
|
|
28217
|
+
_transformObject(object, groupWidth, groupHeight) {
|
|
28218
|
+
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
28219
|
+
if (object.classType === "Group") object.transformByState({
|
|
28220
|
+
left: transform.left,
|
|
28221
|
+
top: transform.top
|
|
28222
|
+
});
|
|
28223
|
+
else object.transformByState(transform);
|
|
28224
|
+
}
|
|
28225
|
+
getObjectsByOrder() {
|
|
28226
|
+
const objects = [];
|
|
28227
|
+
this._objects.sort(_univerjs_core.sortRules);
|
|
28228
|
+
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
28229
|
+
return objects;
|
|
28230
|
+
}
|
|
28231
|
+
getObjects() {
|
|
28232
|
+
return this._objects;
|
|
28233
|
+
}
|
|
28234
|
+
render(ctx, bounds) {
|
|
28235
|
+
ctx.save();
|
|
28236
|
+
const m = this.transform.getMatrix();
|
|
28237
|
+
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
28238
|
+
const objects = this.getObjectsByOrder();
|
|
28239
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28240
|
+
ctx.restore();
|
|
28241
|
+
}
|
|
28242
|
+
_clear() {
|
|
28243
|
+
this._objects = [];
|
|
28244
|
+
}
|
|
28245
|
+
dispose() {
|
|
28246
|
+
[...this.getObjects()].forEach((o) => {
|
|
28247
|
+
o.dispose();
|
|
28248
|
+
});
|
|
28249
|
+
this._clear();
|
|
28250
|
+
super.dispose();
|
|
28251
|
+
}
|
|
28252
|
+
};
|
|
28253
|
+
|
|
28254
|
+
//#endregion
|
|
28255
|
+
//#region src/drawing-group.ts
|
|
28256
|
+
var DrawingGroupObject = class extends Group {
|
|
28257
|
+
constructor(..._args) {
|
|
28258
|
+
super(..._args);
|
|
28259
|
+
_defineProperty(this, "_selfSizeMode", true);
|
|
28260
|
+
_defineProperty(this, "_baseBound", {
|
|
28261
|
+
left: 0,
|
|
28262
|
+
top: 0,
|
|
28263
|
+
width: 0,
|
|
28264
|
+
height: 0
|
|
28265
|
+
});
|
|
28266
|
+
_defineProperty(this, "_outerShadow", void 0);
|
|
28267
|
+
_defineProperty(this, "_glow", void 0);
|
|
28268
|
+
}
|
|
28269
|
+
setOuterShadow(shadow) {
|
|
28270
|
+
this._outerShadow = shadow;
|
|
28271
|
+
this.makeDirty(true);
|
|
28272
|
+
}
|
|
28273
|
+
setGlow(glow) {
|
|
28274
|
+
this._glow = glow;
|
|
28275
|
+
this.makeDirty(true);
|
|
28276
|
+
}
|
|
28277
|
+
/**
|
|
28278
|
+
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
28279
|
+
* This defines the coordinate space of children within the group.
|
|
28280
|
+
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
28281
|
+
* are tracked independently of children.
|
|
28282
|
+
*/
|
|
28283
|
+
setBaseBound(bound) {
|
|
28284
|
+
this._baseBound = { ...bound };
|
|
28285
|
+
}
|
|
28286
|
+
/**
|
|
28287
|
+
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
28288
|
+
*/
|
|
28289
|
+
getBaseBound() {
|
|
28290
|
+
return { ...this._baseBound };
|
|
28291
|
+
}
|
|
28292
|
+
/**
|
|
28293
|
+
* Override ancestorTransform to use the same render transform as render(),
|
|
28294
|
+
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
28295
|
+
* instead of the standard transform translation.
|
|
28296
|
+
* This ensures children (e.g., Image.isHit) that compose with
|
|
28297
|
+
* parent.ancestorTransform get the correct coordinate space.
|
|
28298
|
+
*/
|
|
28299
|
+
get ancestorTransform() {
|
|
28300
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28301
|
+
const m = this.transform.getMatrix();
|
|
28302
|
+
const centerX = realLeft + realWidth / 2;
|
|
28303
|
+
const centerY = realTop + realHeight / 2;
|
|
28304
|
+
const renderTransform = new Transform([
|
|
28305
|
+
m[0],
|
|
28306
|
+
m[1],
|
|
28307
|
+
m[2],
|
|
28308
|
+
m[3],
|
|
28309
|
+
centerX,
|
|
28310
|
+
centerY
|
|
28311
|
+
]);
|
|
28312
|
+
const parent = this.getParent();
|
|
28313
|
+
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
28314
|
+
return renderTransform;
|
|
28315
|
+
}
|
|
28316
|
+
render(ctx, bounds) {
|
|
28317
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28318
|
+
ctx.save();
|
|
28319
|
+
const m = this.transform.getMatrix();
|
|
28320
|
+
const centerX = realLeft + realWidth / 2;
|
|
28321
|
+
const centerY = realTop + realHeight / 2;
|
|
28322
|
+
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
28323
|
+
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
28324
|
+
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
28325
|
+
if (this._outerShadow) {
|
|
28326
|
+
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
28327
|
+
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
28328
|
+
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
28329
|
+
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
28330
|
+
}
|
|
28331
|
+
const objects = this.getObjectsByOrder();
|
|
28332
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28333
|
+
ctx.restore();
|
|
28334
|
+
}
|
|
28335
|
+
addObjects(...objects) {
|
|
28336
|
+
for (const object of objects) this.addObject(object);
|
|
28337
|
+
}
|
|
28338
|
+
isHit(coord) {
|
|
28339
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28340
|
+
const m = this.transform.getMatrix();
|
|
28341
|
+
const centerX = realLeft + realWidth / 2;
|
|
28342
|
+
const centerY = realTop + realHeight / 2;
|
|
28343
|
+
const renderTransform = new Transform([
|
|
28344
|
+
m[0],
|
|
28345
|
+
m[1],
|
|
28346
|
+
m[2],
|
|
28347
|
+
m[3],
|
|
28348
|
+
centerX,
|
|
28349
|
+
centerY
|
|
28350
|
+
]);
|
|
28351
|
+
const parent = this.getParent();
|
|
28352
|
+
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
28353
|
+
const halfWidth = realWidth / 2;
|
|
28354
|
+
const halfHeight = realHeight / 2;
|
|
28355
|
+
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
28356
|
+
const objects = this.getObjectsByOrder();
|
|
28357
|
+
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
28358
|
+
return false;
|
|
28359
|
+
}
|
|
28360
|
+
dispose() {
|
|
28361
|
+
const objects = [...this.getObjects()];
|
|
28362
|
+
const scene = this.getScene();
|
|
28363
|
+
objects.forEach((o) => {
|
|
28364
|
+
o.dispose();
|
|
28365
|
+
scene === null || scene === void 0 || scene.removeObject(o);
|
|
28366
|
+
});
|
|
28367
|
+
this._objects = [];
|
|
28368
|
+
super.dispose();
|
|
28369
|
+
scene === null || scene === void 0 || scene.removeObject(this);
|
|
28370
|
+
}
|
|
28371
|
+
};
|
|
28372
|
+
|
|
27889
28373
|
//#endregion
|
|
27890
28374
|
//#region src/components/docs/doc-component.ts
|
|
27891
28375
|
var DocComponent = class extends RenderComponent {
|
|
@@ -28332,7 +28816,9 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
28332
28816
|
const { ts: textStyle, content, fontStyle, bBox } = glyph;
|
|
28333
28817
|
const { spanPointWithFont = Vector2.create(0, 0) } = this.extensionOffset;
|
|
28334
28818
|
if (content == null) return;
|
|
28335
|
-
|
|
28819
|
+
const currentKerning = ctx.fontKerning;
|
|
28820
|
+
const fontKerning = (fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontKerning) ?? "auto";
|
|
28821
|
+
if (currentKerning != null && currentKerning !== fontKerning) ctx.fontKerning = fontKerning;
|
|
28336
28822
|
if (!textStyle) {
|
|
28337
28823
|
this._fillText(ctx, glyph, spanPointWithFont);
|
|
28338
28824
|
return;
|
|
@@ -29094,8 +29580,21 @@ var Documents = class Documents extends DocComponent {
|
|
|
29094
29580
|
return this.getScene().getEngine();
|
|
29095
29581
|
}
|
|
29096
29582
|
isHit(coord) {
|
|
29583
|
+
if (super.isHit(coord)) {
|
|
29584
|
+
var _this$getScene;
|
|
29585
|
+
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));
|
|
29586
|
+
const skeleton = this.getSkeleton();
|
|
29587
|
+
if (drawingHit && skeleton) {
|
|
29588
|
+
const node = skeleton.findNodeByCoord(this.getInverseCoord(coord), this.pageLayoutType, this.pageMarginLeft, this.pageMarginTop);
|
|
29589
|
+
if (node === null || node === void 0 ? void 0 : node.isInsideGlyph) return true;
|
|
29590
|
+
return this._isHitTable(coord);
|
|
29591
|
+
}
|
|
29592
|
+
return true;
|
|
29593
|
+
}
|
|
29594
|
+
return this._isHitTable(coord);
|
|
29595
|
+
}
|
|
29596
|
+
_isHitTable(coord) {
|
|
29097
29597
|
var _this$getSkeleton;
|
|
29098
|
-
if (super.isHit(coord)) return true;
|
|
29099
29598
|
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
29100
29599
|
if (!skeletonData) return false;
|
|
29101
29600
|
const localCoord = this.getInverseCoord(coord);
|
|
@@ -34403,290 +34902,6 @@ var CustomObject = class extends BaseObject {
|
|
|
34403
34902
|
}
|
|
34404
34903
|
};
|
|
34405
34904
|
|
|
34406
|
-
//#endregion
|
|
34407
|
-
//#region src/group.ts
|
|
34408
|
-
var Group = class extends BaseObject {
|
|
34409
|
-
constructor(key, ...objects) {
|
|
34410
|
-
super(key);
|
|
34411
|
-
_defineProperty(this, "_objects", []);
|
|
34412
|
-
_defineProperty(this, "_selfSizeMode", false);
|
|
34413
|
-
this.addObjects(...objects);
|
|
34414
|
-
}
|
|
34415
|
-
get classType() {
|
|
34416
|
-
return "Group";
|
|
34417
|
-
}
|
|
34418
|
-
set cursor(val) {
|
|
34419
|
-
this.setCursor(val);
|
|
34420
|
-
}
|
|
34421
|
-
getState() {
|
|
34422
|
-
if (this._selfSizeMode) return super.getState();
|
|
34423
|
-
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
34424
|
-
}
|
|
34425
|
-
get width() {
|
|
34426
|
-
if (this._selfSizeMode) return super.width;
|
|
34427
|
-
return this.getState().width || 0;
|
|
34428
|
-
}
|
|
34429
|
-
get height() {
|
|
34430
|
-
if (this._selfSizeMode) return super.height;
|
|
34431
|
-
return this.getState().height || 0;
|
|
34432
|
-
}
|
|
34433
|
-
set width(val) {
|
|
34434
|
-
if (this._selfSizeMode) {
|
|
34435
|
-
super.width = val;
|
|
34436
|
-
return;
|
|
34437
|
-
}
|
|
34438
|
-
const numDelta = val - this.width;
|
|
34439
|
-
this._objects.forEach((o) => {
|
|
34440
|
-
o.resize(o.width + numDelta);
|
|
34441
|
-
});
|
|
34442
|
-
}
|
|
34443
|
-
set height(val) {
|
|
34444
|
-
if (this._selfSizeMode) {
|
|
34445
|
-
super.height = val;
|
|
34446
|
-
return;
|
|
34447
|
-
}
|
|
34448
|
-
const numDelta = val - this.height;
|
|
34449
|
-
this._objects.forEach((o) => {
|
|
34450
|
-
o.resize(void 0, o.height + numDelta);
|
|
34451
|
-
});
|
|
34452
|
-
}
|
|
34453
|
-
get maxZIndex() {
|
|
34454
|
-
let maxZIndex = 0;
|
|
34455
|
-
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
34456
|
-
return maxZIndex;
|
|
34457
|
-
}
|
|
34458
|
-
openSelfSizeMode() {
|
|
34459
|
-
this._selfSizeMode = true;
|
|
34460
|
-
}
|
|
34461
|
-
closeSelfSizeMode() {
|
|
34462
|
-
this._selfSizeMode = false;
|
|
34463
|
-
}
|
|
34464
|
-
reCalculateObjects() {
|
|
34465
|
-
if (this._selfSizeMode) return;
|
|
34466
|
-
const { left = 0, top = 0 } = this.getState();
|
|
34467
|
-
for (const object of this._objects) object.transformByState({
|
|
34468
|
-
left: object.left - left,
|
|
34469
|
-
top: object.top - top
|
|
34470
|
-
});
|
|
34471
|
-
this.transformByState({
|
|
34472
|
-
left,
|
|
34473
|
-
top
|
|
34474
|
-
});
|
|
34475
|
-
}
|
|
34476
|
-
addObjects(...objects) {
|
|
34477
|
-
for (const object of objects) this.addObject(object);
|
|
34478
|
-
}
|
|
34479
|
-
addObject(o) {
|
|
34480
|
-
let object = o;
|
|
34481
|
-
if (isString(o)) {
|
|
34482
|
-
const scene = this.getScene();
|
|
34483
|
-
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
34484
|
-
if (!object) return;
|
|
34485
|
-
object.parent = this;
|
|
34486
|
-
object.isInGroup = true;
|
|
34487
|
-
object.groupKey = this.oKey;
|
|
34488
|
-
this._objects.push(object);
|
|
34489
|
-
} else {
|
|
34490
|
-
o.parent = this;
|
|
34491
|
-
o.isInGroup = true;
|
|
34492
|
-
o.groupKey = this.oKey;
|
|
34493
|
-
this._objects.push(o);
|
|
34494
|
-
}
|
|
34495
|
-
}
|
|
34496
|
-
removeObject(object) {
|
|
34497
|
-
const objects = this.getObjects();
|
|
34498
|
-
const objectsLength = objects.length;
|
|
34499
|
-
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
34500
|
-
const o = objects[i];
|
|
34501
|
-
if (o.oKey === object) {
|
|
34502
|
-
objects.splice(i, 1);
|
|
34503
|
-
this.parent.removeObject(o);
|
|
34504
|
-
return;
|
|
34505
|
-
}
|
|
34506
|
-
}
|
|
34507
|
-
else for (let i = 0; i < objectsLength; i++) {
|
|
34508
|
-
const o = objects[i];
|
|
34509
|
-
if (o === object) {
|
|
34510
|
-
objects.splice(i, 1);
|
|
34511
|
-
this.parent.removeObject(o);
|
|
34512
|
-
return;
|
|
34513
|
-
}
|
|
34514
|
-
}
|
|
34515
|
-
}
|
|
34516
|
-
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
34517
|
-
const objects = [...this.getObjects()];
|
|
34518
|
-
const objectsLength = objects.length;
|
|
34519
|
-
if (width == null) width = this.width;
|
|
34520
|
-
if (height == null) height = this.height;
|
|
34521
|
-
for (let i = 0; i < objectsLength; i++) {
|
|
34522
|
-
const o = objects[i];
|
|
34523
|
-
if (o.oKey === oKey) {
|
|
34524
|
-
objects.splice(i, 1);
|
|
34525
|
-
isTransform && this._transformObject(o, width, height);
|
|
34526
|
-
o.parent = this.parent;
|
|
34527
|
-
o.groupKey = void 0;
|
|
34528
|
-
o.isInGroup = false;
|
|
34529
|
-
this._objects = objects;
|
|
34530
|
-
return;
|
|
34531
|
-
}
|
|
34532
|
-
}
|
|
34533
|
-
}
|
|
34534
|
-
_transformObject(object, groupWidth, groupHeight) {
|
|
34535
|
-
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
34536
|
-
if (object.classType === "Group") object.transformByState({
|
|
34537
|
-
left: transform.left,
|
|
34538
|
-
top: transform.top
|
|
34539
|
-
});
|
|
34540
|
-
else object.transformByState(transform);
|
|
34541
|
-
}
|
|
34542
|
-
getObjectsByOrder() {
|
|
34543
|
-
const objects = [];
|
|
34544
|
-
this._objects.sort(_univerjs_core.sortRules);
|
|
34545
|
-
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
34546
|
-
return objects;
|
|
34547
|
-
}
|
|
34548
|
-
getObjects() {
|
|
34549
|
-
return this._objects;
|
|
34550
|
-
}
|
|
34551
|
-
render(ctx, bounds) {
|
|
34552
|
-
ctx.save();
|
|
34553
|
-
const m = this.transform.getMatrix();
|
|
34554
|
-
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
34555
|
-
const objects = this.getObjectsByOrder();
|
|
34556
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34557
|
-
ctx.restore();
|
|
34558
|
-
}
|
|
34559
|
-
_clear() {
|
|
34560
|
-
this._objects = [];
|
|
34561
|
-
}
|
|
34562
|
-
dispose() {
|
|
34563
|
-
[...this.getObjects()].forEach((o) => {
|
|
34564
|
-
o.dispose();
|
|
34565
|
-
});
|
|
34566
|
-
this._clear();
|
|
34567
|
-
super.dispose();
|
|
34568
|
-
}
|
|
34569
|
-
};
|
|
34570
|
-
|
|
34571
|
-
//#endregion
|
|
34572
|
-
//#region src/drawing-group.ts
|
|
34573
|
-
var DrawingGroupObject = class extends Group {
|
|
34574
|
-
constructor(..._args) {
|
|
34575
|
-
super(..._args);
|
|
34576
|
-
_defineProperty(this, "_selfSizeMode", true);
|
|
34577
|
-
_defineProperty(this, "_baseBound", {
|
|
34578
|
-
left: 0,
|
|
34579
|
-
top: 0,
|
|
34580
|
-
width: 0,
|
|
34581
|
-
height: 0
|
|
34582
|
-
});
|
|
34583
|
-
_defineProperty(this, "_outerShadow", void 0);
|
|
34584
|
-
_defineProperty(this, "_glow", void 0);
|
|
34585
|
-
}
|
|
34586
|
-
setOuterShadow(shadow) {
|
|
34587
|
-
this._outerShadow = shadow;
|
|
34588
|
-
this.makeDirty(true);
|
|
34589
|
-
}
|
|
34590
|
-
setGlow(glow) {
|
|
34591
|
-
this._glow = glow;
|
|
34592
|
-
this.makeDirty(true);
|
|
34593
|
-
}
|
|
34594
|
-
/**
|
|
34595
|
-
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
34596
|
-
* This defines the coordinate space of children within the group.
|
|
34597
|
-
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
34598
|
-
* are tracked independently of children.
|
|
34599
|
-
*/
|
|
34600
|
-
setBaseBound(bound) {
|
|
34601
|
-
this._baseBound = { ...bound };
|
|
34602
|
-
}
|
|
34603
|
-
/**
|
|
34604
|
-
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
34605
|
-
*/
|
|
34606
|
-
getBaseBound() {
|
|
34607
|
-
return { ...this._baseBound };
|
|
34608
|
-
}
|
|
34609
|
-
/**
|
|
34610
|
-
* Override ancestorTransform to use the same render transform as render(),
|
|
34611
|
-
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
34612
|
-
* instead of the standard transform translation.
|
|
34613
|
-
* This ensures children (e.g., Image.isHit) that compose with
|
|
34614
|
-
* parent.ancestorTransform get the correct coordinate space.
|
|
34615
|
-
*/
|
|
34616
|
-
get ancestorTransform() {
|
|
34617
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34618
|
-
const m = this.transform.getMatrix();
|
|
34619
|
-
const centerX = realLeft + realWidth / 2;
|
|
34620
|
-
const centerY = realTop + realHeight / 2;
|
|
34621
|
-
const renderTransform = new Transform([
|
|
34622
|
-
m[0],
|
|
34623
|
-
m[1],
|
|
34624
|
-
m[2],
|
|
34625
|
-
m[3],
|
|
34626
|
-
centerX,
|
|
34627
|
-
centerY
|
|
34628
|
-
]);
|
|
34629
|
-
const parent = this.getParent();
|
|
34630
|
-
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
34631
|
-
return renderTransform;
|
|
34632
|
-
}
|
|
34633
|
-
render(ctx, bounds) {
|
|
34634
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34635
|
-
ctx.save();
|
|
34636
|
-
const m = this.transform.getMatrix();
|
|
34637
|
-
const centerX = realLeft + realWidth / 2;
|
|
34638
|
-
const centerY = realTop + realHeight / 2;
|
|
34639
|
-
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
34640
|
-
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
34641
|
-
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
34642
|
-
if (this._outerShadow) {
|
|
34643
|
-
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
34644
|
-
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
34645
|
-
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
34646
|
-
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
34647
|
-
}
|
|
34648
|
-
const objects = this.getObjectsByOrder();
|
|
34649
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34650
|
-
ctx.restore();
|
|
34651
|
-
}
|
|
34652
|
-
addObjects(...objects) {
|
|
34653
|
-
for (const object of objects) this.addObject(object);
|
|
34654
|
-
}
|
|
34655
|
-
isHit(coord) {
|
|
34656
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34657
|
-
const m = this.transform.getMatrix();
|
|
34658
|
-
const centerX = realLeft + realWidth / 2;
|
|
34659
|
-
const centerY = realTop + realHeight / 2;
|
|
34660
|
-
const renderTransform = new Transform([
|
|
34661
|
-
m[0],
|
|
34662
|
-
m[1],
|
|
34663
|
-
m[2],
|
|
34664
|
-
m[3],
|
|
34665
|
-
centerX,
|
|
34666
|
-
centerY
|
|
34667
|
-
]);
|
|
34668
|
-
const parent = this.getParent();
|
|
34669
|
-
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
34670
|
-
const halfWidth = realWidth / 2;
|
|
34671
|
-
const halfHeight = realHeight / 2;
|
|
34672
|
-
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
34673
|
-
const objects = this.getObjectsByOrder();
|
|
34674
|
-
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
34675
|
-
return false;
|
|
34676
|
-
}
|
|
34677
|
-
dispose() {
|
|
34678
|
-
const objects = [...this.getObjects()];
|
|
34679
|
-
const scene = this.getScene();
|
|
34680
|
-
objects.forEach((o) => {
|
|
34681
|
-
o.dispose();
|
|
34682
|
-
scene === null || scene === void 0 || scene.removeObject(o);
|
|
34683
|
-
});
|
|
34684
|
-
this._objects = [];
|
|
34685
|
-
super.dispose();
|
|
34686
|
-
scene === null || scene === void 0 || scene.removeObject(this);
|
|
34687
|
-
}
|
|
34688
|
-
};
|
|
34689
|
-
|
|
34690
34905
|
//#endregion
|
|
34691
34906
|
//#region src/floating/util.ts
|
|
34692
34907
|
/**
|
|
@@ -35529,7 +35744,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
35529
35744
|
//#endregion
|
|
35530
35745
|
//#region package.json
|
|
35531
35746
|
var name = "@univerjs/engine-render";
|
|
35532
|
-
var version = "1.0
|
|
35747
|
+
var version = "1.2.0";
|
|
35533
35748
|
|
|
35534
35749
|
//#endregion
|
|
35535
35750
|
//#region src/config/config.ts
|
|
@@ -40415,7 +40630,8 @@ var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
|
40415
40630
|
})))]) : null,
|
|
40416
40631
|
drawingAnchor: complete ? [...skeletonData.drawingAnchor ?? []].map(([segmentId, anchors]) => [segmentId, [...anchors].map(([paragraphIndex, anchor]) => [paragraphIndex, {
|
|
40417
40632
|
paragraphIndex: anchor.paragraphIndex,
|
|
40418
|
-
top: anchor.top
|
|
40633
|
+
top: anchor.top,
|
|
40634
|
+
...anchor.left == null ? {} : { left: anchor.left }
|
|
40419
40635
|
}])]) : null
|
|
40420
40636
|
};
|
|
40421
40637
|
}
|
|
@@ -40436,7 +40652,7 @@ exports.CIRCLE_OBJECT_ARRAY = CIRCLE_OBJECT_ARRAY;
|
|
|
40436
40652
|
exports.COLOR_BLACK_RGB = COLOR_BLACK_RGB;
|
|
40437
40653
|
exports.CURSOR_TYPE = CURSOR_TYPE;
|
|
40438
40654
|
exports.Canvas = Canvas;
|
|
40439
|
-
Object.defineProperty(exports,
|
|
40655
|
+
Object.defineProperty(exports, "CanvasColorService", {
|
|
40440
40656
|
enumerable: true,
|
|
40441
40657
|
get: function () {
|
|
40442
40658
|
return CanvasColorService;
|
|
@@ -40482,7 +40698,7 @@ exports.Drawing = Drawing;
|
|
|
40482
40698
|
exports.DrawingGroupObject = DrawingGroupObject;
|
|
40483
40699
|
exports.DumbCanvasColorService = DumbCanvasColorService;
|
|
40484
40700
|
exports.EXPAND_SIZE_FOR_RENDER_OVERFLOW = EXPAND_SIZE_FOR_RENDER_OVERFLOW;
|
|
40485
|
-
Object.defineProperty(exports,
|
|
40701
|
+
Object.defineProperty(exports, "Engine", {
|
|
40486
40702
|
enumerable: true,
|
|
40487
40703
|
get: function () {
|
|
40488
40704
|
return Engine;
|
|
@@ -40536,13 +40752,13 @@ exports.RICHTEXT_OBJECT_ARRAY = RICHTEXT_OBJECT_ARRAY;
|
|
|
40536
40752
|
exports.Rect = Rect;
|
|
40537
40753
|
exports.RegularPolygon = RegularPolygon;
|
|
40538
40754
|
exports.RenderComponent = RenderComponent;
|
|
40539
|
-
Object.defineProperty(exports,
|
|
40755
|
+
Object.defineProperty(exports, "RenderManagerService", {
|
|
40540
40756
|
enumerable: true,
|
|
40541
40757
|
get: function () {
|
|
40542
40758
|
return RenderManagerService;
|
|
40543
40759
|
}
|
|
40544
40760
|
});
|
|
40545
|
-
Object.defineProperty(exports,
|
|
40761
|
+
Object.defineProperty(exports, "RenderUnit", {
|
|
40546
40762
|
enumerable: true,
|
|
40547
40763
|
get: function () {
|
|
40548
40764
|
return RenderUnit;
|
|
@@ -40576,7 +40792,7 @@ exports.SpreadsheetColumnHeader = SpreadsheetColumnHeader;
|
|
|
40576
40792
|
exports.SpreadsheetExtensionRegistry = SpreadsheetExtensionRegistry;
|
|
40577
40793
|
exports.SpreadsheetHeader = SpreadsheetHeader;
|
|
40578
40794
|
exports.SpreadsheetRowHeader = SpreadsheetRowHeader;
|
|
40579
|
-
Object.defineProperty(exports,
|
|
40795
|
+
Object.defineProperty(exports, "SpreadsheetSkeleton", {
|
|
40580
40796
|
enumerable: true,
|
|
40581
40797
|
get: function () {
|
|
40582
40798
|
return SpreadsheetSkeleton;
|
|
@@ -40589,7 +40805,7 @@ exports.Transform = Transform;
|
|
|
40589
40805
|
exports.UNIVER_WATERMARK_LAYER_INDEX = UNIVER_WATERMARK_LAYER_INDEX;
|
|
40590
40806
|
exports.UNIVER_WATERMARK_STORAGE_KEY = UNIVER_WATERMARK_STORAGE_KEY;
|
|
40591
40807
|
exports.UniverPrintingContext = UniverPrintingContext;
|
|
40592
|
-
Object.defineProperty(exports,
|
|
40808
|
+
Object.defineProperty(exports, "UniverRenderEnginePlugin", {
|
|
40593
40809
|
enumerable: true,
|
|
40594
40810
|
get: function () {
|
|
40595
40811
|
return UniverRenderEnginePlugin;
|