@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/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, JSON1, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TabStopAlignment, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextDecoration, TextX, TextXActionType, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, characterSpacingControlType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, getRichTextEditPath, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, numfmt, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
1
|
+
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, JSON1, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NamedStyleType, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SHEET_TEXT_LINE_GAP, SectionType, SheetSkeleton, Skeleton, SpacingRule, TabStopAlignment, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextDecoration, TextX, TextXActionType, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, characterSpacingControlType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, getRichTextEditPath, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, numfmt, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
2
|
import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, merge as merge$1, shareReplay, startWith } from "rxjs";
|
|
3
3
|
import { franc } from "franc-min";
|
|
4
4
|
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
@@ -22,7 +22,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
//#region \0@oxc-project+runtime@0.
|
|
25
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
26
26
|
function _typeof(o) {
|
|
27
27
|
"@babel/helpers - typeof";
|
|
28
28
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -33,7 +33,7 @@ function _typeof(o) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
37
37
|
function toPrimitive(t, r) {
|
|
38
38
|
if ("object" != _typeof(t) || !t) return t;
|
|
39
39
|
var e = t[Symbol.toPrimitive];
|
|
@@ -46,14 +46,14 @@ function toPrimitive(t, r) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
50
50
|
function toPropertyKey(t) {
|
|
51
51
|
var i = toPrimitive(t, "string");
|
|
52
52
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region \0@oxc-project+runtime@0.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
57
57
|
function _defineProperty(e, r, t) {
|
|
58
58
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
59
|
value: t,
|
|
@@ -11919,12 +11919,13 @@ var LineBreaker = class {
|
|
|
11919
11919
|
* limitations under the License.
|
|
11920
11920
|
*/
|
|
11921
11921
|
var DocSimpleSkeleton = class {
|
|
11922
|
-
constructor(_text, _fontStyle, _warp, _width, _height) {
|
|
11922
|
+
constructor(_text, _fontStyle, _warp, _width, _height, _lineGap = 0) {
|
|
11923
11923
|
this._text = _text;
|
|
11924
11924
|
this._fontStyle = _fontStyle;
|
|
11925
11925
|
this._warp = _warp;
|
|
11926
11926
|
this._width = _width;
|
|
11927
11927
|
this._height = _height;
|
|
11928
|
+
this._lineGap = _lineGap;
|
|
11928
11929
|
_defineProperty(this, "_lineBreaker", void 0);
|
|
11929
11930
|
_defineProperty(this, "_lines", []);
|
|
11930
11931
|
_defineProperty(this, "_dirty", true);
|
|
@@ -11976,7 +11977,7 @@ var DocSimpleSkeleton = class {
|
|
|
11976
11977
|
if (textSize.width > this._width) {
|
|
11977
11978
|
if (currentLine.text.length > 0) {
|
|
11978
11979
|
this._lines.push(currentLine);
|
|
11979
|
-
totalHeight += currentLine.height;
|
|
11980
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
11980
11981
|
if (totalHeight > this._height) break;
|
|
11981
11982
|
currentLine = {
|
|
11982
11983
|
text: "",
|
|
@@ -12032,7 +12033,7 @@ var DocSimpleSkeleton = class {
|
|
|
12032
12033
|
remainingText = remainingText.slice(charCount);
|
|
12033
12034
|
if (remainingText.length > 0) {
|
|
12034
12035
|
this._lines.push(currentLine);
|
|
12035
|
-
totalHeight += currentLine.height;
|
|
12036
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12036
12037
|
if (totalHeight > this._height) break;
|
|
12037
12038
|
currentLine = {
|
|
12038
12039
|
text: "",
|
|
@@ -12045,7 +12046,7 @@ var DocSimpleSkeleton = class {
|
|
|
12045
12046
|
}
|
|
12046
12047
|
} else if (currentLine.text.length > 0) {
|
|
12047
12048
|
this._lines.push(currentLine);
|
|
12048
|
-
totalHeight += currentLine.height;
|
|
12049
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12049
12050
|
if (totalHeight > this._height) break;
|
|
12050
12051
|
currentLine = {
|
|
12051
12052
|
text,
|
|
@@ -12068,7 +12069,7 @@ var DocSimpleSkeleton = class {
|
|
|
12068
12069
|
}
|
|
12069
12070
|
if (isMandatoryBreak) {
|
|
12070
12071
|
this._lines.push(currentLine);
|
|
12071
|
-
totalHeight += currentLine.height;
|
|
12072
|
+
totalHeight += currentLine.height + (this._lines.length > 1 ? this._lineGap : 0);
|
|
12072
12073
|
if (totalHeight > this._height) break;
|
|
12073
12074
|
currentLine = {
|
|
12074
12075
|
text: "",
|
|
@@ -12086,7 +12087,7 @@ var DocSimpleSkeleton = class {
|
|
|
12086
12087
|
return this._lines;
|
|
12087
12088
|
}
|
|
12088
12089
|
getTotalHeight() {
|
|
12089
|
-
return this._lines.reduce((acc, line) => acc + line.height, 0);
|
|
12090
|
+
return this._lines.reduce((acc, line) => acc + line.height, 0) + Math.max(0, this._lines.length - 1) * this._lineGap;
|
|
12090
12091
|
}
|
|
12091
12092
|
getTotalWidth() {
|
|
12092
12093
|
return this._lines.reduce((acc, line) => Math.max(acc, line.width), 0);
|
|
@@ -12440,6 +12441,7 @@ const TEXT_OBJECT_ARRAY = [
|
|
|
12440
12441
|
"text",
|
|
12441
12442
|
"fontStyle",
|
|
12442
12443
|
"warp",
|
|
12444
|
+
"lineGap",
|
|
12443
12445
|
"hAlign",
|
|
12444
12446
|
"vAlign",
|
|
12445
12447
|
"width",
|
|
@@ -12452,6 +12454,7 @@ var Text = class Text extends Shape {
|
|
|
12452
12454
|
_defineProperty(this, "text", void 0);
|
|
12453
12455
|
_defineProperty(this, "fontStyle", void 0);
|
|
12454
12456
|
_defineProperty(this, "warp", void 0);
|
|
12457
|
+
_defineProperty(this, "lineGap", void 0);
|
|
12455
12458
|
_defineProperty(this, "hAlign", void 0);
|
|
12456
12459
|
_defineProperty(this, "vAlign", void 0);
|
|
12457
12460
|
_defineProperty(this, "skeleton", void 0);
|
|
@@ -12460,14 +12463,15 @@ var Text = class Text extends Shape {
|
|
|
12460
12463
|
this.text = props.text;
|
|
12461
12464
|
this.fontStyle = props.fontStyle;
|
|
12462
12465
|
this.warp = props.warp ?? false;
|
|
12466
|
+
this.lineGap = props.lineGap ?? 0;
|
|
12463
12467
|
this.hAlign = props.hAlign ?? HorizontalAlign.LEFT;
|
|
12464
12468
|
this.vAlign = props.vAlign ?? VerticalAlign.TOP;
|
|
12465
|
-
this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height);
|
|
12469
|
+
this.skeleton = new DocSimpleSkeleton(props.text, props.fontStyle, Boolean(props.warp), props.width, props.height, this.lineGap);
|
|
12466
12470
|
}
|
|
12467
12471
|
static drawWith(ctx, props, _skeleton) {
|
|
12468
|
-
const { text, fontStyle, warp, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
|
|
12472
|
+
const { text, fontStyle, warp, lineGap = 0, hAlign, vAlign, width, height, left = 0, top = 0, cellValueType } = props;
|
|
12469
12473
|
const cachedLayout = !_skeleton && !warp ? Text._getCachedLayout(text, fontStyle) : null;
|
|
12470
|
-
const skeleton = cachedLayout ? null : _skeleton ?? new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === VerticalAlign.TOP ? height : Infinity);
|
|
12474
|
+
const skeleton = cachedLayout ? null : _skeleton ?? new DocSimpleSkeleton(text, fontStyle, Boolean(warp), width, vAlign === VerticalAlign.TOP ? height : Infinity, lineGap);
|
|
12471
12475
|
const lines = (cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.lines) ?? skeleton.calculate();
|
|
12472
12476
|
const totalHeight = (cachedLayout === null || cachedLayout === void 0 ? void 0 : cachedLayout.totalHeight) ?? skeleton.getTotalHeight();
|
|
12473
12477
|
let lineTop = top + (vAlign === VerticalAlign.TOP ? 0 : vAlign === VerticalAlign.MIDDLE ? (height - totalHeight) / 2 : height - totalHeight);
|
|
@@ -12512,7 +12516,7 @@ var Text = class Text extends Shape {
|
|
|
12512
12516
|
lineWidth: 1,
|
|
12513
12517
|
lineType: TextDecoration.SINGLE
|
|
12514
12518
|
});
|
|
12515
|
-
lineTop = lineTop + lineHeight;
|
|
12519
|
+
lineTop = lineTop + lineHeight + lineGap;
|
|
12516
12520
|
}
|
|
12517
12521
|
ctx.restore();
|
|
12518
12522
|
return totalHeight;
|
|
@@ -13121,6 +13125,48 @@ var DataStreamTreeNode = class DataStreamTreeNode {
|
|
|
13121
13125
|
}
|
|
13122
13126
|
};
|
|
13123
13127
|
|
|
13128
|
+
//#endregion
|
|
13129
|
+
//#region src/components/docs/view-model/heading-sections.ts
|
|
13130
|
+
/** Each table cell and modern column has its own heading hierarchy. */
|
|
13131
|
+
function getHeadingSections(sections, getParagraph) {
|
|
13132
|
+
const result = [];
|
|
13133
|
+
function visitFlow(nodes, endOffset) {
|
|
13134
|
+
const open = [];
|
|
13135
|
+
for (const node of nodes) {
|
|
13136
|
+
var _paragraph$paragraphS;
|
|
13137
|
+
const paragraph = node.nodeType === DataStreamTreeNodeType.PARAGRAPH && node.children.length === 0 ? getParagraph(node.endIndex) : void 0;
|
|
13138
|
+
const level = paragraph === null || paragraph === void 0 || (_paragraph$paragraphS = paragraph.paragraphStyle) === null || _paragraph$paragraphS === void 0 ? void 0 : _paragraph$paragraphS.namedStyleType;
|
|
13139
|
+
if (paragraph && level != null && level >= NamedStyleType.HEADING_1 && level <= NamedStyleType.HEADING_5) {
|
|
13140
|
+
while (open.length && open[open.length - 1].level >= level) open.pop().section.endOffset = node.startIndex;
|
|
13141
|
+
const section = {
|
|
13142
|
+
paragraphId: paragraph.paragraphId,
|
|
13143
|
+
paragraphIndex: paragraph.startIndex,
|
|
13144
|
+
startOffset: paragraph.startIndex + 1,
|
|
13145
|
+
endOffset,
|
|
13146
|
+
collapsed: paragraph.headingCollapsed === true
|
|
13147
|
+
};
|
|
13148
|
+
result.push(section);
|
|
13149
|
+
open.push({
|
|
13150
|
+
level,
|
|
13151
|
+
section
|
|
13152
|
+
});
|
|
13153
|
+
}
|
|
13154
|
+
visitContainers(node);
|
|
13155
|
+
}
|
|
13156
|
+
}
|
|
13157
|
+
function visitContainers(node) {
|
|
13158
|
+
if (node.nodeType === DataStreamTreeNodeType.TABLE_CELL || node.nodeType === DataStreamTreeNodeType.COLUMN) {
|
|
13159
|
+
const nodes = node.children.flatMap((child) => child.nodeType === DataStreamTreeNodeType.SECTION_BREAK ? child.children : [child]);
|
|
13160
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : node.endIndex);
|
|
13161
|
+
return;
|
|
13162
|
+
}
|
|
13163
|
+
for (const child of node.children) visitContainers(child);
|
|
13164
|
+
}
|
|
13165
|
+
const nodes = sections.flatMap((section) => section.children);
|
|
13166
|
+
visitFlow(nodes, nodes.length ? nodes[nodes.length - 1].endIndex + 1 : 0);
|
|
13167
|
+
return result.sort((a, b) => a.paragraphIndex - b.paragraphIndex);
|
|
13168
|
+
}
|
|
13169
|
+
|
|
13124
13170
|
//#endregion
|
|
13125
13171
|
//#region src/components/docs/view-model/document-view-model.ts
|
|
13126
13172
|
const NON_STRUCTURAL_ROOT_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -13445,6 +13491,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13445
13491
|
_defineProperty(this, "_treeNodes", []);
|
|
13446
13492
|
_defineProperty(this, "_treeNodesByStartIndex", []);
|
|
13447
13493
|
_defineProperty(this, "_plainTopLevelParagraphNodes", []);
|
|
13494
|
+
_defineProperty(this, "_headingSections", null);
|
|
13495
|
+
_defineProperty(this, "_collapsedHeadingSections", null);
|
|
13448
13496
|
_defineProperty(this, "_metadataCachesDirty", false);
|
|
13449
13497
|
_defineProperty(this, "_textRunsOrderedAndDisjoint", true);
|
|
13450
13498
|
_defineProperty(this, "_paragraphsOrdered", true);
|
|
@@ -13488,6 +13536,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13488
13536
|
this._treeNodes = [];
|
|
13489
13537
|
this._treeNodesByStartIndex = [];
|
|
13490
13538
|
this._plainTopLevelParagraphNodes = [];
|
|
13539
|
+
this._headingSections = null;
|
|
13540
|
+
this._collapsedHeadingSections = null;
|
|
13491
13541
|
this._lastTextRun = null;
|
|
13492
13542
|
this._noteTreeMap.forEach((viewModel) => viewModel.dispose());
|
|
13493
13543
|
this._noteTreeMap.clear();
|
|
@@ -13515,6 +13565,41 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13515
13565
|
getChildren() {
|
|
13516
13566
|
return this._children;
|
|
13517
13567
|
}
|
|
13568
|
+
getHeadingSections() {
|
|
13569
|
+
const snapshot = this.getSnapshot();
|
|
13570
|
+
if (snapshot.documentStyle.documentFlavor !== DocumentFlavor.MODERN) return [];
|
|
13571
|
+
this._headingSections ??= getHeadingSections(this._children, (index) => {
|
|
13572
|
+
var _paragraph$paragraphS;
|
|
13573
|
+
const paragraph = this.getParagraph(index);
|
|
13574
|
+
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;
|
|
13575
|
+
return {
|
|
13576
|
+
...paragraph,
|
|
13577
|
+
paragraphStyle: resolveDocumentParagraphStyle(snapshot.documentStyle, paragraph.paragraphStyle, {
|
|
13578
|
+
styles: snapshot.styles,
|
|
13579
|
+
paragraphStyleId: paragraph.styleId
|
|
13580
|
+
})
|
|
13581
|
+
};
|
|
13582
|
+
});
|
|
13583
|
+
return this._headingSections;
|
|
13584
|
+
}
|
|
13585
|
+
getCollapsedHeadingAtOffset(offset) {
|
|
13586
|
+
if (!this._collapsedHeadingSections) {
|
|
13587
|
+
this._collapsedHeadingSections = [];
|
|
13588
|
+
for (const section of this.getHeadingSections()) {
|
|
13589
|
+
const previous = this._collapsedHeadingSections[this._collapsedHeadingSections.length - 1];
|
|
13590
|
+
if (section.collapsed && section.endOffset > section.startOffset && (!previous || section.startOffset >= previous.endOffset)) this._collapsedHeadingSections.push(section);
|
|
13591
|
+
}
|
|
13592
|
+
}
|
|
13593
|
+
let low = 0;
|
|
13594
|
+
let high = this._collapsedHeadingSections.length - 1;
|
|
13595
|
+
while (low <= high) {
|
|
13596
|
+
const middle = Math.floor((low + high) / 2);
|
|
13597
|
+
const section = this._collapsedHeadingSections[middle];
|
|
13598
|
+
if (offset < section.startOffset) high = middle - 1;
|
|
13599
|
+
else if (offset >= section.endOffset) low = middle + 1;
|
|
13600
|
+
else return section;
|
|
13601
|
+
}
|
|
13602
|
+
}
|
|
13518
13603
|
getBody() {
|
|
13519
13604
|
const presentation = getDocumentLayoutPresentation(this._documentDataModel);
|
|
13520
13605
|
return presentation ? presentation.getSnapshot(this._documentDataModel.getSnapshot()).body : this._documentDataModel.getBody();
|
|
@@ -13535,6 +13620,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13535
13620
|
return this;
|
|
13536
13621
|
}
|
|
13537
13622
|
reset(documentDataModel) {
|
|
13623
|
+
this._headingSections = null;
|
|
13624
|
+
this._collapsedHeadingSections = null;
|
|
13538
13625
|
this._children.forEach((child) => child.dispose());
|
|
13539
13626
|
this._textRunsCache.clear();
|
|
13540
13627
|
this._paragraphCache.clear();
|
|
@@ -13560,6 +13647,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13560
13647
|
if (edit.insertText.length > 0 && !this._insertPlainText(edit.offset, edit.insertText)) return false;
|
|
13561
13648
|
}
|
|
13562
13649
|
this._documentDataModel = documentDataModel;
|
|
13650
|
+
this._headingSections = null;
|
|
13651
|
+
this._collapsedHeadingSections = null;
|
|
13563
13652
|
this._metadataCachesDirty = true;
|
|
13564
13653
|
this._lastTextRun = null;
|
|
13565
13654
|
if (!this._textRunsOrderedAndDisjoint) this._buildTextRunsCache();
|
|
@@ -13569,6 +13658,8 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
13569
13658
|
const rootFields = getNonStructuralMutationRootFields(actions);
|
|
13570
13659
|
if (rootFields == null) return false;
|
|
13571
13660
|
this._documentDataModel = documentDataModel;
|
|
13661
|
+
this._headingSections = null;
|
|
13662
|
+
this._collapsedHeadingSections = null;
|
|
13572
13663
|
this._metadataCachesDirty = true;
|
|
13573
13664
|
this._lastTextRun = null;
|
|
13574
13665
|
if (rootFields.has("tableSource")) {
|
|
@@ -16707,7 +16798,23 @@ function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsB
|
|
|
16707
16798
|
|
|
16708
16799
|
//#endregion
|
|
16709
16800
|
//#region src/components/docs/layout/block/paragraph/paragraph-layout.ts
|
|
16801
|
+
/**
|
|
16802
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
16803
|
+
*
|
|
16804
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16805
|
+
* you may not use this file except in compliance with the License.
|
|
16806
|
+
* You may obtain a copy of the License at
|
|
16807
|
+
*
|
|
16808
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16809
|
+
*
|
|
16810
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16811
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16812
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16813
|
+
* See the License for the specific language governing permissions and
|
|
16814
|
+
* limitations under the License.
|
|
16815
|
+
*/
|
|
16710
16816
|
function dealWidthParagraph(ctx, viewModel, paragraphNode, curPage, sectionBreakConfig, nextParagraphNode) {
|
|
16817
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) return [curPage];
|
|
16711
16818
|
clearFontCreateConfigCache();
|
|
16712
16819
|
const { content = "", children } = paragraphNode;
|
|
16713
16820
|
let tableSkeleton = null;
|
|
@@ -16960,6 +17067,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16960
17067
|
const paragraphEndIndex = Math.min(sectionNode.children.length, paragraphStartIndex + ((options === null || options === void 0 ? void 0 : options.maxParagraphs) ?? Number.POSITIVE_INFINITY));
|
|
16961
17068
|
for (let i = paragraphStartIndex; i < paragraphEndIndex; i++) {
|
|
16962
17069
|
const paragraphNode = sectionNode.children[i];
|
|
17070
|
+
if (viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex)) continue;
|
|
16963
17071
|
let skeletonPages = [];
|
|
16964
17072
|
let currentPageCache = curPage;
|
|
16965
17073
|
if (allCurrentSkeletonPages.length > 0) currentPageCache = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];
|
|
@@ -16977,7 +17085,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16977
17085
|
if (ctx.isDirty) break;
|
|
16978
17086
|
}
|
|
16979
17087
|
const { segmentId } = curPage;
|
|
16980
|
-
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null)
|
|
17088
|
+
if (ctx.isDirty && ctx.layoutStartPointer[segmentId] != null) rollbackSectionPages(ctx.layoutStartPointer[segmentId], allCurrentSkeletonPages);
|
|
16981
17089
|
return {
|
|
16982
17090
|
pages: allCurrentSkeletonPages,
|
|
16983
17091
|
renderedBlockIdMap,
|
|
@@ -16985,7 +17093,7 @@ function dealWithSection(ctx, viewModel, sectionNode, curPage, sectionBreakConfi
|
|
|
16985
17093
|
complete: paragraphEndIndex >= sectionNode.children.length
|
|
16986
17094
|
};
|
|
16987
17095
|
}
|
|
16988
|
-
function
|
|
17096
|
+
function rollbackSectionPages(paragraphIndex, allCurrentSkeletonPages) {
|
|
16989
17097
|
let findFirstDirtyLine = false;
|
|
16990
17098
|
for (let pageIndex = 0; pageIndex < allCurrentSkeletonPages.length; pageIndex++) {
|
|
16991
17099
|
const page = allCurrentSkeletonPages[pageIndex];
|
|
@@ -17485,8 +17593,13 @@ function resetCellDrawingAnchors(ctx, cellNode, tableId) {
|
|
|
17485
17593
|
if (!anchors) return;
|
|
17486
17594
|
for (const paragraph of cellNode.children[0].children) anchors.delete(paragraph.endIndex);
|
|
17487
17595
|
}
|
|
17488
|
-
function createSkeletonCellPages(
|
|
17596
|
+
function createSkeletonCellPages(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17489
17597
|
var _ctx$dataModel, _ctx$dataModel$getBod;
|
|
17598
|
+
const ctx = {
|
|
17599
|
+
...parentContext,
|
|
17600
|
+
isDirty: false,
|
|
17601
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17602
|
+
};
|
|
17490
17603
|
const sectionNode = cellNode.children[0];
|
|
17491
17604
|
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);
|
|
17492
17605
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
@@ -17525,7 +17638,12 @@ function createSkeletonCellPages(ctx, viewModel, cellNode, sectionBreakConfig, t
|
|
|
17525
17638
|
finishVerticalCellLayout(pages, verticalCellWidth);
|
|
17526
17639
|
return pages;
|
|
17527
17640
|
}
|
|
17528
|
-
function startSkeletonCellPagesBuild(
|
|
17641
|
+
function startSkeletonCellPagesBuild(parentContext, viewModel, cellNode, sectionBreakConfig, tableConfig, row, col, availableHeight = Number.POSITIVE_INFINITY, maxCellPageHeight = Number.POSITIVE_INFINITY, cellPageHeights) {
|
|
17642
|
+
const ctx = {
|
|
17643
|
+
...parentContext,
|
|
17644
|
+
isDirty: false,
|
|
17645
|
+
layoutStartPointer: { ...parentContext.layoutStartPointer }
|
|
17646
|
+
};
|
|
17529
17647
|
const sectionNode = cellNode.children[0];
|
|
17530
17648
|
const { enableDocumentTableLineGrid, inheritDocumentLinePitch } = getCellLineGridOptions(sectionBreakConfig);
|
|
17531
17649
|
const { page, sectionBreakConfig: cellSectionBreakConfig, verticalCellWidth } = createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, availableHeight, maxCellPageHeight, inheritDocumentLinePitch, enableDocumentTableLineGrid, cellPageHeights);
|
|
@@ -18231,6 +18349,7 @@ function _getParagraphLineMetrics(ctx, glyphGroup, lastPage, column, sectionBrea
|
|
|
18231
18349
|
marginTop: 0,
|
|
18232
18350
|
spaceBelowApply: (preLine === null || preLine === void 0 ? void 0 : preLine.spaceBelowApply) ?? 0
|
|
18233
18351
|
} : __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);
|
|
18352
|
+
if (preLine) marginTop += sectionBreakConfig.lineGap ?? 0;
|
|
18234
18353
|
if (startingSection && marginTop > 0 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy)) marginTop = _collapseSectionBeforeSpacing(ctx, startingSection.children[0].startIndex - 2, marginTop);
|
|
18235
18354
|
if (positionedCustomBlockOnly) spaceBelowApply = 0;
|
|
18236
18355
|
const isHiddenCellEndMark = lastPage.type === 3 && isTraditionalDocumentCompatibility(paragraphConfig.documentCompatibilityPolicy) && sectionBreakConfig.cellHiddenEndMarkIndex === paragraphIndex && paragraphConfig.bulletSkeleton == null && glyphGroup.length > 0 && glyphGroup.every(__isStructuralTerminatorGlyph);
|
|
@@ -18377,7 +18496,9 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18377
18496
|
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);
|
|
18378
18497
|
}
|
|
18379
18498
|
const hasSameParagraphTopBottomDrawingWithInline = hasInlineCustomBlock && paragraphNonInlineSkeDrawings != null && [...paragraphNonInlineSkeDrawings.values()].some((drawing) => drawing.drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM);
|
|
18380
|
-
|
|
18499
|
+
let tableFlowTop = lineTop;
|
|
18500
|
+
for (const item of skeTablesInParagraph ?? []) if (item.hasPositioned && item.table.parent === lastPage && item.table.tableSource.textWrap === TableTextWrapType.NONE) tableFlowTop = Math.max(lineTop, item.table.top + item.table.height - section.top);
|
|
18501
|
+
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);
|
|
18381
18502
|
const previousTopBottomCustomBlockFlowBottom = deferredTopBottomAnchorDrawings.length > 0 ? paragraphConfig.topBottomCustomBlockFlowBottom : void 0;
|
|
18382
18503
|
const newLineTop = previousTopBottomCustomBlockFlowBottom == null ? calculatedLineTop : Math.max(calculatedLineTop, previousTopBottomCustomBlockFlowBottom);
|
|
18383
18504
|
const clipsSameParagraphInlineDrawing = hasSameParagraphTopBottomDrawingWithInline && newLineTop < section.height;
|
|
@@ -18430,7 +18551,11 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
18430
18551
|
if (borderTopSpace > 0) newLine.borderTopSpace = borderTopSpace;
|
|
18431
18552
|
if (borderBottomSpace > 0) newLine.borderBottomSpace = borderBottomSpace;
|
|
18432
18553
|
const blockAnchorTop = deferredTopBottomAnchorDrawings.length > 0 ? newLineTop : lineTop;
|
|
18433
|
-
if (!isStandalonePageBoundary)
|
|
18554
|
+
if (!isStandalonePageBoundary) {
|
|
18555
|
+
createAndUpdateBlockAnchor(paragraphIndex, newLine, blockAnchorTop, pDrawingAnchor);
|
|
18556
|
+
const paragraphDrawingAnchor = pDrawingAnchor === null || pDrawingAnchor === void 0 ? void 0 : pDrawingAnchor.get(paragraphIndex);
|
|
18557
|
+
if (paragraphDrawingAnchor) paragraphDrawingAnchor.left = paragraphAnchorLeft;
|
|
18558
|
+
}
|
|
18434
18559
|
if (deferredTopBottomAnchorDrawings.length > 0) {
|
|
18435
18560
|
__updateAndPositionDrawings(ctx, newLineTop, lineHeight, column, deferredTopBottomAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, blockAnchorTop, paragraphAnchorLeft, false, true);
|
|
18436
18561
|
__updateTopBottomCustomBlockFlowBottom(paragraphConfig, deferredTopBottomAnchorDrawings, section.top);
|
|
@@ -18445,6 +18570,10 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
|
|
|
18445
18570
|
if (targetDrawings.length === 0) return;
|
|
18446
18571
|
const drawings = __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
|
|
18447
18572
|
if (drawings == null || drawings.size === 0) return;
|
|
18573
|
+
for (const drawing of drawings.values()) if (drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE) {
|
|
18574
|
+
var _ctx$skeletonResource;
|
|
18575
|
+
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;
|
|
18576
|
+
}
|
|
18448
18577
|
const floatObjects = [...drawings.values()].filter((drawing) => {
|
|
18449
18578
|
const layoutType = drawing.drawingOrigin.layoutType;
|
|
18450
18579
|
return layoutType !== PositionedObjectLayoutType.INLINE && layoutType !== PositionedObjectLayoutType.WRAP_NONE;
|
|
@@ -18917,7 +19046,7 @@ function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitc
|
|
|
18917
19046
|
lineSpacingApply: exactLineSpacingApply
|
|
18918
19047
|
};
|
|
18919
19048
|
}
|
|
18920
|
-
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy) {
|
|
19049
|
+
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId = "", blockAnchorTop, paragraphNonInlineSkeDrawings, documentCompatibilityPolicy, blockAnchorLeft = 0, normalizeTraditionalColumnAnchor = false) {
|
|
18921
19050
|
var _line$parent;
|
|
18922
19051
|
const column = line.parent;
|
|
18923
19052
|
const section = column === null || column === void 0 ? void 0 : column.parent;
|
|
@@ -18983,6 +19112,9 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, unitId =
|
|
|
18983
19112
|
drawing.lineTop = lineTop;
|
|
18984
19113
|
drawing.columnLeft = column.left;
|
|
18985
19114
|
drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
|
|
19115
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19116
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor;
|
|
19117
|
+
drawing.pageAnchorLeft = normalizeTraditionalColumnAnchor ? page.marginLeft : 0;
|
|
18986
19118
|
drawing.lineHeight = line.lineHeight;
|
|
18987
19119
|
drawings.set(drawing.drawingId, drawing);
|
|
18988
19120
|
}
|
|
@@ -19040,6 +19172,9 @@ function __getDrawingPosition(ctx, lineTop, lineHeight, column, isParagraphFirst
|
|
|
19040
19172
|
} : void 0;
|
|
19041
19173
|
drawing.initialState = true;
|
|
19042
19174
|
drawing.columnLeft = column.left;
|
|
19175
|
+
drawing.blockAnchorLeft = blockAnchorLeft;
|
|
19176
|
+
drawing.normalizeTraditionalColumnAnchor = normalizeTraditionalColumnAnchor && ctx.dataModel.documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL;
|
|
19177
|
+
drawing.pageAnchorLeft = ctx.dataModel.documentStyle.documentFlavor === DocumentFlavor.TRADITIONAL ? page.marginLeft : 0;
|
|
19043
19178
|
drawing.lineTop = absoluteLineTop;
|
|
19044
19179
|
drawing.lineHeight = lineHeight;
|
|
19045
19180
|
drawing.isPageBreak = isPageBreak;
|
|
@@ -19455,7 +19590,7 @@ function updateInlineDrawingCoordsAndBorder(ctx, pages) {
|
|
|
19455
19590
|
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);
|
|
19456
19591
|
if (affectInlineDrawings && affectInlineDrawings.size > 0) {
|
|
19457
19592
|
var _ctx$dataModel$getUni, _ctx$dataModel;
|
|
19458
|
-
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);
|
|
19593
|
+
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 === DocumentFlavor.TRADITIONAL);
|
|
19459
19594
|
}
|
|
19460
19595
|
const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
|
|
19461
19596
|
const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
|
|
@@ -21217,8 +21352,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
21217
21352
|
//#endregion
|
|
21218
21353
|
//#region src/components/docs/layout/document-layout-page-patch.ts
|
|
21219
21354
|
function withoutParent(value) {
|
|
21220
|
-
const
|
|
21221
|
-
delete copy.parent;
|
|
21355
|
+
const { parent: _parent, ...copy } = value;
|
|
21222
21356
|
return copy;
|
|
21223
21357
|
}
|
|
21224
21358
|
function serializeDivide(source) {
|
|
@@ -21286,10 +21420,10 @@ function serializeDocumentSkeletonPage(source, omitResourceSources = false) {
|
|
|
21286
21420
|
return {
|
|
21287
21421
|
...geometry,
|
|
21288
21422
|
sections: source.sections.map(serializeSection),
|
|
21289
|
-
noteDecorations
|
|
21423
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21290
21424
|
...decoration,
|
|
21291
21425
|
page: serializeDocumentSkeletonPage(decoration.page, omitResourceSources)
|
|
21292
|
-
})),
|
|
21426
|
+
})) },
|
|
21293
21427
|
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21294
21428
|
...withoutParent(note),
|
|
21295
21429
|
page: serializeDocumentSkeletonPage(note.page, omitResourceSources)
|
|
@@ -21429,18 +21563,18 @@ function hydrateDocumentSkeletonPageMaterializationPlaceholder(source, parent) {
|
|
|
21429
21563
|
return placeholder;
|
|
21430
21564
|
}
|
|
21431
21565
|
function hydrateDocumentSkeletonPageInternal(source, parent, snapshot, resourceSegmentId) {
|
|
21432
|
-
|
|
21566
|
+
const { notes, noteDecorations, ...geometry } = source;
|
|
21433
21567
|
const page = {
|
|
21434
|
-
...
|
|
21568
|
+
...geometry,
|
|
21435
21569
|
sections: [],
|
|
21436
|
-
noteDecorations
|
|
21570
|
+
...noteDecorations == null ? {} : { noteDecorations: noteDecorations.map((decoration) => ({
|
|
21437
21571
|
...decoration,
|
|
21438
21572
|
page: hydrateDocumentSkeletonPageInternal(decoration.page, void 0, snapshot, decoration.page.segmentId)
|
|
21439
|
-
})),
|
|
21440
|
-
notes
|
|
21573
|
+
})) },
|
|
21574
|
+
...notes == null ? {} : { notes: notes.map((note) => ({
|
|
21441
21575
|
...note,
|
|
21442
21576
|
page: hydrateDocumentSkeletonPageInternal(note.page, void 0, snapshot, note.noteId)
|
|
21443
|
-
})),
|
|
21577
|
+
})) },
|
|
21444
21578
|
skeDrawings: new Map(source.skeDrawings.map(([drawingId, drawing]) => [drawingId, hydrateDrawing(drawing, snapshot, resourceSegmentId)])),
|
|
21445
21579
|
skeTables: /* @__PURE__ */ new Map(),
|
|
21446
21580
|
skeColumnGroups: /* @__PURE__ */ new Map(),
|
|
@@ -23424,6 +23558,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23424
23558
|
_defineProperty(this, "_paginationMetrics", null);
|
|
23425
23559
|
_defineProperty(this, "_completedPageCount", void 0);
|
|
23426
23560
|
_defineProperty(this, "_lastCompleteSkeletonData", null);
|
|
23561
|
+
_defineProperty(this, "_completedHeadingCollapseSignature", "[]");
|
|
23562
|
+
_defineProperty(this, "_publishedHeadingCollapseSignature", "[]");
|
|
23427
23563
|
_defineProperty(this, "_pendingInvalidationAnchor", null);
|
|
23428
23564
|
_defineProperty(this, "_layoutGeneration", 0);
|
|
23429
23565
|
_defineProperty(this, "_activeLayout", null);
|
|
@@ -23435,7 +23571,9 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23435
23571
|
_defineProperty(this, "_isolateIncrementalPublications", void 0);
|
|
23436
23572
|
_defineProperty(this, "_modernPageWidth", void 0);
|
|
23437
23573
|
_defineProperty(this, "_modernHorizontalMargin", void 0);
|
|
23574
|
+
_defineProperty(this, "_lineGap", void 0);
|
|
23438
23575
|
this._isolateIncrementalPublications = options.isolateIncrementalPublications !== false;
|
|
23576
|
+
this._lineGap = options.lineGap ?? 0;
|
|
23439
23577
|
}
|
|
23440
23578
|
static create(docViewModel, localeService, options) {
|
|
23441
23579
|
return new DocumentSkeleton(docViewModel, localeService, options);
|
|
@@ -23479,29 +23617,48 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23479
23617
|
ctx = retry;
|
|
23480
23618
|
}
|
|
23481
23619
|
this._lastCompleteSkeletonData = this._skeletonData;
|
|
23620
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23621
|
+
this._publishedHeadingCollapseSignature = this._completedHeadingCollapseSignature;
|
|
23482
23622
|
this._completedPageCount = (_this$_skeletonData = this._skeletonData) === null || _this$_skeletonData === void 0 ? void 0 : _this$_skeletonData.pages.length;
|
|
23483
23623
|
this._pendingInvalidationAnchor = null;
|
|
23484
23624
|
this._paginationMetrics = ctx.paginationMetrics ?? null;
|
|
23485
23625
|
this._dirty$.next(true);
|
|
23486
23626
|
}
|
|
23627
|
+
_getHeadingCollapseSignature() {
|
|
23628
|
+
return JSON.stringify(this.getViewModel().getHeadingSections().filter((heading) => heading.collapsed).map((heading) => [
|
|
23629
|
+
heading.paragraphId,
|
|
23630
|
+
heading.startOffset,
|
|
23631
|
+
heading.endOffset
|
|
23632
|
+
]));
|
|
23633
|
+
}
|
|
23487
23634
|
startIncrementalLayout(options) {
|
|
23488
|
-
|
|
23489
|
-
|
|
23635
|
+
const headingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23636
|
+
const headingVisibilityChanged = headingCollapseSignature !== this._completedHeadingCollapseSignature || headingCollapseSignature !== this._publishedHeadingCollapseSignature;
|
|
23637
|
+
const layoutOptions = headingVisibilityChanged ? {
|
|
23638
|
+
...options,
|
|
23639
|
+
anchor: 0,
|
|
23640
|
+
priorityAnchor: (options === null || options === void 0 ? void 0 : options.priorityAnchor) ?? (options === null || options === void 0 ? void 0 : options.anchor) ?? 0,
|
|
23641
|
+
invalidation: void 0,
|
|
23642
|
+
reuseUnaffectedTail: false,
|
|
23643
|
+
preserveInteractionWindow: false
|
|
23644
|
+
} : options;
|
|
23645
|
+
this._modernPageWidth = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernPageWidth;
|
|
23646
|
+
this._modernHorizontalMargin = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.modernHorizontalMargin;
|
|
23490
23647
|
this.cancelIncrementalLayout();
|
|
23491
23648
|
this._externalLayoutProgress = null;
|
|
23492
23649
|
this._externalProtectedPages = null;
|
|
23493
23650
|
this._externalProtectedContinuousLayout = null;
|
|
23494
23651
|
const generation = ++this._layoutGeneration;
|
|
23495
|
-
const reason = (
|
|
23652
|
+
const reason = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reason) ?? ((layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor) == null ? "initial" : "edit");
|
|
23496
23653
|
const dataModel = this.getViewModel().getDataModel();
|
|
23497
23654
|
const sections = this.getViewModel().getChildren();
|
|
23498
23655
|
const topLevelBlocks = this._getTopLevelBlocks(sections);
|
|
23499
23656
|
const mode = dataModel.documentStyle.documentFlavor === DocumentFlavor.MODERN ? "continuous" : "paginated";
|
|
23500
|
-
const priorityAnchor = (
|
|
23657
|
+
const priorityAnchor = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.priorityAnchor) ?? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor);
|
|
23501
23658
|
const hasPublishedCheckpoint = this._skeletonData != null || this._lastCompleteSkeletonData != null;
|
|
23502
23659
|
const previousSkeleton = this._lastCompleteSkeletonData ?? this._skeletonData;
|
|
23503
|
-
const invalidation =
|
|
23504
|
-
const layoutAnchor =
|
|
23660
|
+
const invalidation = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.invalidation;
|
|
23661
|
+
const layoutAnchor = layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.anchor;
|
|
23505
23662
|
const invalidationAnchor = layoutAnchor == null ? this._pendingInvalidationAnchor ?? void 0 : Math.min(layoutAnchor, this._pendingInvalidationAnchor ?? layoutAnchor);
|
|
23506
23663
|
const mutationDelta = invalidation == null ? 0 : invalidation.newEnd - invalidation.oldEnd;
|
|
23507
23664
|
let priorityPageAnchor = priorityAnchor;
|
|
@@ -23514,7 +23671,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23514
23671
|
const previousPriorityPage = priorityPageIndex < 0 ? null : (previousSkeleton === null || previousSkeleton === void 0 ? void 0 : previousSkeleton.pages[priorityPageIndex]) ?? null;
|
|
23515
23672
|
const previousPriorityPageEnd = previousPriorityPage == null ? null : getLastBodyFlowCharIndex(previousPriorityPage);
|
|
23516
23673
|
const priorityPageEnd = previousPriorityPageEnd == null ? null : previousPriorityPageEnd + (invalidation != null && invalidation.oldStart <= previousPriorityPageEnd ? mutationDelta : 0);
|
|
23517
|
-
const incrementalStart = this._prepareIncrementalLayoutStart(invalidationAnchor, mode, invalidation, (
|
|
23674
|
+
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);
|
|
23518
23675
|
this._pendingInvalidationAnchor = hasPublishedCheckpoint ? invalidationAnchor ?? null : null;
|
|
23519
23676
|
this._activeLayout = {
|
|
23520
23677
|
generation,
|
|
@@ -23528,6 +23685,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23528
23685
|
sectionBreakConfig: null,
|
|
23529
23686
|
layoutAnchor: incrementalStart.layoutAnchor,
|
|
23530
23687
|
priorityAnchor: priorityAnchor ?? null,
|
|
23688
|
+
minimumPublicationHeight: mode === "continuous" && headingVisibilityChanged && this._skeletonData != null ? (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.minimumPublicationHeight) ?? 0 : 0,
|
|
23531
23689
|
priorityPageIndex,
|
|
23532
23690
|
priorityPageEnd,
|
|
23533
23691
|
interactionPageTail: incrementalStart.interactionPageTail,
|
|
@@ -23552,16 +23710,16 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23552
23710
|
lastPublishedPageCount: incrementalStart.ctx.skeleton.pages.length > 0 ? Math.max(0, incrementalStart.ctx.skeleton.pages.length - 1) : 0,
|
|
23553
23711
|
lastPublishedBlockCount: incrementalStart.processedBlockCount,
|
|
23554
23712
|
publicationRevision: 0,
|
|
23555
|
-
reuseUnaffectedTail: (
|
|
23713
|
+
reuseUnaffectedTail: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.reuseUnaffectedTail) !== false,
|
|
23556
23714
|
paginationRevision: 0,
|
|
23557
|
-
allowMetadataOnlyStructuralTailReuse: (
|
|
23715
|
+
allowMetadataOnlyStructuralTailReuse: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.allowMetadataOnlyStructuralTailReuse) === true,
|
|
23558
23716
|
reusedTail: false,
|
|
23559
23717
|
tailConvergencePageCount: incrementalStart.ctx.skeleton.pages.length,
|
|
23560
23718
|
dirtyRetries: /* @__PURE__ */ new Map(),
|
|
23561
23719
|
preparedHyphenationNodes: /* @__PURE__ */ new WeakSet(),
|
|
23562
23720
|
pendingHyphenation: null,
|
|
23563
23721
|
hyphenationError: null,
|
|
23564
|
-
waitForHyphenationPatterns: (
|
|
23722
|
+
waitForHyphenationPatterns: (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.waitForHyphenationPatterns) === true
|
|
23565
23723
|
};
|
|
23566
23724
|
return generation;
|
|
23567
23725
|
}
|
|
@@ -23936,10 +24094,12 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23936
24094
|
if (isFinalPublication) {
|
|
23937
24095
|
var _state$ctx$skeleton;
|
|
23938
24096
|
this._lastCompleteSkeletonData = state.ctx.skeleton;
|
|
24097
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23939
24098
|
this._completedPageCount = (_state$ctx$skeleton = state.ctx.skeleton) === null || _state$ctx$skeleton === void 0 ? void 0 : _state$ctx$skeleton.pages.length;
|
|
23940
24099
|
this._pendingInvalidationAnchor = null;
|
|
23941
24100
|
}
|
|
23942
24101
|
this._skeletonData = isFinalPublication ? state.ctx.skeleton : !this._isolateIncrementalPublications && state.mode === "paginated" ? this._createSharedPublishablePartialSkeleton(state, publishedPageCount) : this._createPublishablePartialSkeleton(state, publishedPageCount);
|
|
24102
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
23943
24103
|
this._paginationMetrics = state.ctx.paginationMetrics ?? null;
|
|
23944
24104
|
this._dirty$.next(true);
|
|
23945
24105
|
didPublish = true;
|
|
@@ -23964,6 +24124,19 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
23964
24124
|
const startIndex = ((_stablePages$at = stablePages.at(-1)) === null || _stablePages$at === void 0 ? void 0 : _stablePages$at.ed) ?? -1;
|
|
23965
24125
|
updateBlockIndex(activePages, startIndex, state.ctx.docsConfig.documentCompatibilityPolicy);
|
|
23966
24126
|
mergeContinuousDuplicatePages(activePages, state.mode === "continuous");
|
|
24127
|
+
if (state.mode === "continuous") {
|
|
24128
|
+
const paragraphConfigCache = new Map([...state.ctx.paragraphConfigCache].map(([segmentId, configs]) => [segmentId, new Map([...configs].map(([index, config]) => {
|
|
24129
|
+
var _config$paragraphInli;
|
|
24130
|
+
return [index, ((_config$paragraphInli = config.paragraphInlineSkeDrawings) === null || _config$paragraphInli === void 0 ? void 0 : _config$paragraphInli.size) ? {
|
|
24131
|
+
...config,
|
|
24132
|
+
paragraphInlineSkeDrawings: new Map([...config.paragraphInlineSkeDrawings].map(([id, drawing]) => [id, { ...drawing }]))
|
|
24133
|
+
} : config];
|
|
24134
|
+
}))]));
|
|
24135
|
+
updateInlineDrawingCoordsAndBorder({
|
|
24136
|
+
...state.ctx,
|
|
24137
|
+
paragraphConfigCache
|
|
24138
|
+
}, activePages);
|
|
24139
|
+
}
|
|
23967
24140
|
const flowPages = [...stablePages, ...activePages];
|
|
23968
24141
|
const currentPriorityPageIndex = state.priorityAnchor == null ? -1 : this._findBodyPageIndex(flowPages, state.priorityAnchor);
|
|
23969
24142
|
const previousPriorityPage = previous === null || previous === void 0 ? void 0 : previous.pages[state.priorityPageIndex];
|
|
@@ -24237,6 +24410,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24237
24410
|
if (progress.complete) {
|
|
24238
24411
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24239
24412
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24413
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24240
24414
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24241
24415
|
this._pendingInvalidationAnchor = null;
|
|
24242
24416
|
this._externalProtectedContinuousLayout = null;
|
|
@@ -24307,6 +24481,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24307
24481
|
if (publicationToApply.resources.drawingAnchor != null) skeletonData.drawingAnchor = hydrateDrawingAnchors(publicationToApply.resources.drawingAnchor);
|
|
24308
24482
|
setPageParent(skeletonData.pages, skeletonData);
|
|
24309
24483
|
this._lastCompleteSkeletonData = skeletonData;
|
|
24484
|
+
this._completedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24310
24485
|
this._completedPageCount = skeletonData === null || skeletonData === void 0 ? void 0 : skeletonData.pages.length;
|
|
24311
24486
|
this._pendingInvalidationAnchor = null;
|
|
24312
24487
|
this._externalProtectedPages = null;
|
|
@@ -24314,6 +24489,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24314
24489
|
}
|
|
24315
24490
|
this._skeletonData = skeletonData;
|
|
24316
24491
|
this._externalLayoutProgress = progress.complete ? null : progress;
|
|
24492
|
+
this._publishedHeadingCollapseSignature = this._getHeadingCollapseSignature();
|
|
24317
24493
|
this._dirty$.next(true);
|
|
24318
24494
|
this._layoutProgress$.next(progress);
|
|
24319
24495
|
return { didReplaceProtectedPages };
|
|
@@ -24367,7 +24543,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24367
24543
|
const firstUnprotectedLineOffset = flow.lines.findIndex((line) => line.st > protectedEndOffset);
|
|
24368
24544
|
if (firstUnprotectedLineOffset < 0) return null;
|
|
24369
24545
|
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];
|
|
24370
|
-
if (existingColumn == null)
|
|
24546
|
+
if (existingColumn == null) return null;
|
|
24371
24547
|
const firstUnprotectedLine = flow.lines[firstUnprotectedLineOffset];
|
|
24372
24548
|
const matchingTailLineIndex = existingColumn.lines.findIndex((line) => line.st >= firstUnprotectedLine.st);
|
|
24373
24549
|
const targetLineIndex = matchingTailLineIndex < 0 ? existingColumn.lines.length : matchingTailLineIndex;
|
|
@@ -24861,11 +25037,13 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24861
25037
|
if (!isHitTestAddressableGlyph(glyph)) continue;
|
|
24862
25038
|
const startX = divideLeft + glyph.left;
|
|
24863
25039
|
const endX = startX + glyph.width;
|
|
25040
|
+
const contentTop = startY + (line.marginTop ?? 0) + (line.paddingTop ?? 0);
|
|
24864
25041
|
const node = {
|
|
24865
25042
|
node: glyph,
|
|
24866
25043
|
...segment,
|
|
24867
25044
|
ratioX: x / (startX + endX),
|
|
24868
|
-
ratioY: y / (startY + endY)
|
|
25045
|
+
ratioY: y / (startY + endY),
|
|
25046
|
+
isInsideGlyph: x >= startX && x <= endX && y >= contentTop && y <= contentTop + line.contentHeight
|
|
24869
25047
|
};
|
|
24870
25048
|
if (sameLine && x >= startX && x <= endX) return node;
|
|
24871
25049
|
if (distanceY < nearestDistanceY) {
|
|
@@ -24916,7 +25094,8 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
24916
25094
|
node: glyph,
|
|
24917
25095
|
...segment,
|
|
24918
25096
|
ratioX: x / (startX + endX),
|
|
24919
|
-
ratioY: y / (startY + endY)
|
|
25097
|
+
ratioY: y / (startY + endY),
|
|
25098
|
+
isInsideGlyph: x >= startX && x <= endX && sameLine
|
|
24920
25099
|
};
|
|
24921
25100
|
const hitsGlyphAdvance = x >= startX && x <= endX;
|
|
24922
25101
|
if (sameLine) {
|
|
@@ -25099,7 +25278,23 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25099
25278
|
const anchor = state.priorityAnchor;
|
|
25100
25279
|
if (anchor == null || state.complete) return true;
|
|
25101
25280
|
if (state.interactionPageComplete) return true;
|
|
25102
|
-
if (state.mode === "continuous")
|
|
25281
|
+
if (state.mode === "continuous") {
|
|
25282
|
+
if (state.laidOutThrough < anchor) return false;
|
|
25283
|
+
if (state.minimumPublicationHeight <= 0) return true;
|
|
25284
|
+
let height = 0;
|
|
25285
|
+
for (const page of state.ctx.skeleton.pages) for (const section of page.sections) {
|
|
25286
|
+
let sectionHeight = 0;
|
|
25287
|
+
for (const column of section.columns) for (let index = column.lines.length - 1; index >= 0; index--) {
|
|
25288
|
+
const line = column.lines[index];
|
|
25289
|
+
if (line.paragraphIndex <= state.stableLaidOutThrough) {
|
|
25290
|
+
sectionHeight = Math.max(sectionHeight, line.top + line.lineHeight);
|
|
25291
|
+
break;
|
|
25292
|
+
}
|
|
25293
|
+
}
|
|
25294
|
+
height += sectionHeight;
|
|
25295
|
+
}
|
|
25296
|
+
return height >= state.minimumPublicationHeight;
|
|
25297
|
+
}
|
|
25103
25298
|
if (state.priorityPageEnd != null) {
|
|
25104
25299
|
var _state$invalidation;
|
|
25105
25300
|
const requiredOffset = Math.max(anchor, state.priorityPageEnd, ((_state$invalidation = state.invalidation) === null || _state$invalidation === void 0 ? void 0 : _state$invalidation.newEnd) ?? anchor);
|
|
@@ -25286,7 +25481,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25286
25481
|
const curSkeletonPage = getLastPage(ctx.skeleton.pages);
|
|
25287
25482
|
if (sectionBreakConfig == null || curSkeletonPage == null) throw new Error("Incremental document layout failed to initialize a section page.");
|
|
25288
25483
|
const paragraphNode = sectionNode.children[state.paragraphIndex];
|
|
25289
|
-
const tableNode =
|
|
25484
|
+
const tableNode = paragraphNode && !ctx.viewModel.getCollapsedHeadingAtOffset(paragraphNode.startIndex) && paragraphNode.children.length === 1 && paragraphNode.children[0].nodeType === DataStreamTreeNodeType.TABLE ? paragraphNode.children[0] : null;
|
|
25290
25485
|
if (tableNode != null) {
|
|
25291
25486
|
state.pendingTableBuild ??= startTableSkeletonBuild(ctx, curSkeletonPage, ctx.viewModel, tableNode, sectionBreakConfig);
|
|
25292
25487
|
if (state.pendingTableBuild != null && !stepTableSkeletonBuild(state.pendingTableBuild)) return;
|
|
@@ -25486,6 +25681,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25486
25681
|
const section = sections[sectionIndex];
|
|
25487
25682
|
const paragraphIndex = Math.max(0, (section === null || section === void 0 ? void 0 : section.children.findIndex(({ endIndex }) => endIndex === layoutAnchor)) ?? 0);
|
|
25488
25683
|
const processedBeforeSection = sections.slice(0, sectionIndex).reduce((count, item) => count + item.children.length, 0);
|
|
25684
|
+
rollbackSectionPages(layoutAnchor, ctx.skeleton.pages);
|
|
25489
25685
|
state.sectionIndex = sectionIndex;
|
|
25490
25686
|
state.paragraphIndex = paragraphIndex;
|
|
25491
25687
|
state.sectionInitialized = false;
|
|
@@ -25596,6 +25792,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25596
25792
|
};
|
|
25597
25793
|
const { paragraphLineGapDefault = 0, defaultTabStop = 10.5, textStyle = {}, adjustLineHeightInTable = BooleanNumber.FALSE } = documentStyle;
|
|
25598
25794
|
const docsConfig = {
|
|
25795
|
+
lineGap: this._lineGap,
|
|
25599
25796
|
headerTreeMap,
|
|
25600
25797
|
footerTreeMap,
|
|
25601
25798
|
lists,
|
|
@@ -25891,7 +26088,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
25891
26088
|
};
|
|
25892
26089
|
|
|
25893
26090
|
//#endregion
|
|
25894
|
-
//#region \0@oxc-project+runtime@0.
|
|
26091
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
25895
26092
|
function __decorateParam(paramIndex, decorator) {
|
|
25896
26093
|
return function(target, key) {
|
|
25897
26094
|
decorator(target, key, paramIndex);
|
|
@@ -25899,7 +26096,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
25899
26096
|
}
|
|
25900
26097
|
|
|
25901
26098
|
//#endregion
|
|
25902
|
-
//#region \0@oxc-project+runtime@0.
|
|
26099
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
25903
26100
|
function __decorate(decorators, target, key, desc) {
|
|
25904
26101
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25905
26102
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -26026,6 +26223,8 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26026
26223
|
_defineProperty(this, "_gridlinesColor", void 0);
|
|
26027
26224
|
_defineProperty(this, "_defaultGridlinesColor", void 0);
|
|
26028
26225
|
_defineProperty(this, "_scene", null);
|
|
26226
|
+
_defineProperty(this, "textLineGap", void 0);
|
|
26227
|
+
this.textLineGap = _configService.getConfig(SHEET_TEXT_LINE_GAP) ?? 0;
|
|
26029
26228
|
const themeService = _injector.get(ThemeService);
|
|
26030
26229
|
this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
|
|
26031
26230
|
var _this$_scene, _this$_scene2;
|
|
@@ -26356,7 +26555,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26356
26555
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26357
26556
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26358
26557
|
if (typeof colWidth === "number" && wrapStrategy === WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(colWidth);
|
|
26359
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26558
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26360
26559
|
documentSkeleton.calculate();
|
|
26361
26560
|
let { height: h = 0 } = getDocsSkeletonPageSize(documentSkeleton, angle) ?? {};
|
|
26362
26561
|
if (documentSkeleton) {
|
|
@@ -26374,7 +26573,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26374
26573
|
const paddingTop = ((_style$pd3 = style.pd) === null || _style$pd3 === void 0 ? void 0 : _style$pd3.t) ?? DEFAULT_PADDING_DATA.t;
|
|
26375
26574
|
const paddingBottom = ((_style$pd4 = style.pd) === null || _style$pd4 === void 0 ? void 0 : _style$pd4.b) ?? DEFAULT_PADDING_DATA.b;
|
|
26376
26575
|
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP) {
|
|
26377
|
-
const skeleton = new DocSimpleSkeleton(getDisplayValueFromCell(cell), getFontStyleString(style).fontCache, (style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP, colWidth - paddingLeft - paddingRight, Infinity);
|
|
26576
|
+
const skeleton = new DocSimpleSkeleton(getDisplayValueFromCell(cell), getFontStyleString(style).fontCache, (style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP, colWidth - paddingLeft - paddingRight, Infinity, this.textLineGap);
|
|
26378
26577
|
skeleton.calculate();
|
|
26379
26578
|
return skeleton.getTotalHeight() + paddingTop + paddingBottom;
|
|
26380
26579
|
} else {
|
|
@@ -26490,7 +26689,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26490
26689
|
const { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
26491
26690
|
if ((style === null || style === void 0 ? void 0 : style.tb) === WrapStrategy.WRAP) documentModel.updateDocumentDataPageSize(currColWidth, Infinity);
|
|
26492
26691
|
else documentModel.updateDocumentDataPageSize(Infinity, Infinity);
|
|
26493
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
26692
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26494
26693
|
documentSkeleton.calculate();
|
|
26495
26694
|
measuredWidth = (getDocsSkeletonPageSize(documentSkeleton, angle) ?? { width: 0 }).width;
|
|
26496
26695
|
if (documentSkeleton) {
|
|
@@ -26773,7 +26972,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26773
26972
|
if (fontCache.documentSkeleton) {
|
|
26774
26973
|
const snapshot = fontCache.documentSkeleton.getViewModel().getDataModel().getSnapshot();
|
|
26775
26974
|
const documentModel = new DocumentDataModel(scaleDocumentDataForShrinkToFit(snapshot, scale, fallbackFontSize));
|
|
26776
|
-
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService);
|
|
26975
|
+
const documentSkeleton = DocumentSkeleton.create(new DocumentViewModel(documentModel), this._localeService, { lineGap: this.textLineGap });
|
|
26777
26976
|
documentSkeleton.calculate();
|
|
26778
26977
|
fontCache.documentSkeleton = documentSkeleton;
|
|
26779
26978
|
} else fontCache.fontString = getFontStyleString({
|
|
@@ -26826,7 +27025,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
26826
27025
|
if (FULL_WIDTH_HORIZONTAL_ALIGNMENTS.has(horizontalAlign)) updateDocumentPageWidth(documentModel, this.getCellWithCoordByIndex(row, col, false));
|
|
26827
27026
|
const documentViewModel = new DocumentViewModel(documentModel);
|
|
26828
27027
|
if (documentViewModel) {
|
|
26829
|
-
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService);
|
|
27028
|
+
const documentSkeleton = DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: this.textLineGap });
|
|
26830
27029
|
documentSkeleton.calculate();
|
|
26831
27030
|
config = {
|
|
26832
27031
|
documentSkeleton,
|
|
@@ -27290,7 +27489,7 @@ var Font = class extends SheetExtension {
|
|
|
27290
27489
|
this._clipByRenderBounds(renderFontCtx, row, col);
|
|
27291
27490
|
ctx.translate(renderFontCtx.startX + FIX_ONE_PIXEL_BLUR_OFFSET, renderFontCtx.startY + FIX_ONE_PIXEL_BLUR_OFFSET);
|
|
27292
27491
|
if (fontCache.documentSkeleton) this._renderDocuments(ctx, row, col, renderFontCtx, spreadsheetSkeleton.overflowCache);
|
|
27293
|
-
else this._renderText(ctx,
|
|
27492
|
+
else this._renderText(ctx, renderFontCtx);
|
|
27294
27493
|
ctx.restore();
|
|
27295
27494
|
if (fontCache.documentSkeleton) {
|
|
27296
27495
|
var _documentDataModel$ge;
|
|
@@ -27385,7 +27584,7 @@ var Font = class extends SheetExtension {
|
|
|
27385
27584
|
if (image.getAttribute("data-error") === "true") this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27386
27585
|
else try {
|
|
27387
27586
|
ctx.drawImage(image, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27388
|
-
} catch
|
|
27587
|
+
} catch {
|
|
27389
27588
|
this._drawFallbackImage(ctx, -rotatedWidth / 2, -rotatedHeight / 2, width, height);
|
|
27390
27589
|
}
|
|
27391
27590
|
ctx.restore();
|
|
@@ -27398,7 +27597,7 @@ var Font = class extends SheetExtension {
|
|
|
27398
27597
|
* @param renderFontContext
|
|
27399
27598
|
* @param row
|
|
27400
27599
|
* @param col
|
|
27401
|
-
* @param
|
|
27600
|
+
* @param padding
|
|
27402
27601
|
*/
|
|
27403
27602
|
_clipByRenderBounds(renderFontContext, row, col, padding = 0) {
|
|
27404
27603
|
var _fontCache$cellData3, _fontCache$cellData4;
|
|
@@ -27442,7 +27641,7 @@ var Font = class extends SheetExtension {
|
|
|
27442
27641
|
renderFontContext.endX = endX;
|
|
27443
27642
|
renderFontContext.endY = endY;
|
|
27444
27643
|
}
|
|
27445
|
-
_renderText(ctx,
|
|
27644
|
+
_renderText(ctx, renderFontCtx) {
|
|
27446
27645
|
var _fontCache$style5, _fontCache$style6, _fontCache$style7, _fontCache$style8, _fontCache$style9;
|
|
27447
27646
|
const { fontCache } = renderFontCtx;
|
|
27448
27647
|
if (!fontCache) return;
|
|
@@ -27462,6 +27661,7 @@ var Font = class extends SheetExtension {
|
|
|
27462
27661
|
text,
|
|
27463
27662
|
fontStyle: fontCache.fontString,
|
|
27464
27663
|
warp: wrapStrategy === WrapStrategy.WRAP && vertexAngle === 0,
|
|
27664
|
+
lineGap: renderFontCtx.spreadsheetSkeleton.textLineGap,
|
|
27465
27665
|
hAlign,
|
|
27466
27666
|
vAlign: fontCache.verticalAlign,
|
|
27467
27667
|
width: cellWidth,
|
|
@@ -27885,6 +28085,290 @@ var SpreadsheetRowHeader = class extends SpreadsheetHeader {
|
|
|
27885
28085
|
}
|
|
27886
28086
|
};
|
|
27887
28087
|
|
|
28088
|
+
//#endregion
|
|
28089
|
+
//#region src/group.ts
|
|
28090
|
+
var Group = class extends BaseObject {
|
|
28091
|
+
constructor(key, ...objects) {
|
|
28092
|
+
super(key);
|
|
28093
|
+
_defineProperty(this, "_objects", []);
|
|
28094
|
+
_defineProperty(this, "_selfSizeMode", false);
|
|
28095
|
+
this.addObjects(...objects);
|
|
28096
|
+
}
|
|
28097
|
+
get classType() {
|
|
28098
|
+
return "Group";
|
|
28099
|
+
}
|
|
28100
|
+
set cursor(val) {
|
|
28101
|
+
this.setCursor(val);
|
|
28102
|
+
}
|
|
28103
|
+
getState() {
|
|
28104
|
+
if (this._selfSizeMode) return super.getState();
|
|
28105
|
+
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
28106
|
+
}
|
|
28107
|
+
get width() {
|
|
28108
|
+
if (this._selfSizeMode) return super.width;
|
|
28109
|
+
return this.getState().width || 0;
|
|
28110
|
+
}
|
|
28111
|
+
get height() {
|
|
28112
|
+
if (this._selfSizeMode) return super.height;
|
|
28113
|
+
return this.getState().height || 0;
|
|
28114
|
+
}
|
|
28115
|
+
set width(val) {
|
|
28116
|
+
if (this._selfSizeMode) {
|
|
28117
|
+
super.width = val;
|
|
28118
|
+
return;
|
|
28119
|
+
}
|
|
28120
|
+
const numDelta = val - this.width;
|
|
28121
|
+
this._objects.forEach((o) => {
|
|
28122
|
+
o.resize(o.width + numDelta);
|
|
28123
|
+
});
|
|
28124
|
+
}
|
|
28125
|
+
set height(val) {
|
|
28126
|
+
if (this._selfSizeMode) {
|
|
28127
|
+
super.height = val;
|
|
28128
|
+
return;
|
|
28129
|
+
}
|
|
28130
|
+
const numDelta = val - this.height;
|
|
28131
|
+
this._objects.forEach((o) => {
|
|
28132
|
+
o.resize(void 0, o.height + numDelta);
|
|
28133
|
+
});
|
|
28134
|
+
}
|
|
28135
|
+
get maxZIndex() {
|
|
28136
|
+
let maxZIndex = 0;
|
|
28137
|
+
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
28138
|
+
return maxZIndex;
|
|
28139
|
+
}
|
|
28140
|
+
openSelfSizeMode() {
|
|
28141
|
+
this._selfSizeMode = true;
|
|
28142
|
+
}
|
|
28143
|
+
closeSelfSizeMode() {
|
|
28144
|
+
this._selfSizeMode = false;
|
|
28145
|
+
}
|
|
28146
|
+
reCalculateObjects() {
|
|
28147
|
+
if (this._selfSizeMode) return;
|
|
28148
|
+
const { left = 0, top = 0 } = this.getState();
|
|
28149
|
+
for (const object of this._objects) object.transformByState({
|
|
28150
|
+
left: object.left - left,
|
|
28151
|
+
top: object.top - top
|
|
28152
|
+
});
|
|
28153
|
+
this.transformByState({
|
|
28154
|
+
left,
|
|
28155
|
+
top
|
|
28156
|
+
});
|
|
28157
|
+
}
|
|
28158
|
+
addObjects(...objects) {
|
|
28159
|
+
for (const object of objects) this.addObject(object);
|
|
28160
|
+
}
|
|
28161
|
+
addObject(o) {
|
|
28162
|
+
let object = o;
|
|
28163
|
+
if (isString(o)) {
|
|
28164
|
+
const scene = this.getScene();
|
|
28165
|
+
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
28166
|
+
if (!object) return;
|
|
28167
|
+
object.parent = this;
|
|
28168
|
+
object.isInGroup = true;
|
|
28169
|
+
object.groupKey = this.oKey;
|
|
28170
|
+
this._objects.push(object);
|
|
28171
|
+
} else {
|
|
28172
|
+
o.parent = this;
|
|
28173
|
+
o.isInGroup = true;
|
|
28174
|
+
o.groupKey = this.oKey;
|
|
28175
|
+
this._objects.push(o);
|
|
28176
|
+
}
|
|
28177
|
+
}
|
|
28178
|
+
removeObject(object) {
|
|
28179
|
+
const objects = this.getObjects();
|
|
28180
|
+
const objectsLength = objects.length;
|
|
28181
|
+
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
28182
|
+
const o = objects[i];
|
|
28183
|
+
if (o.oKey === object) {
|
|
28184
|
+
objects.splice(i, 1);
|
|
28185
|
+
this.parent.removeObject(o);
|
|
28186
|
+
return;
|
|
28187
|
+
}
|
|
28188
|
+
}
|
|
28189
|
+
else for (let i = 0; i < objectsLength; i++) {
|
|
28190
|
+
const o = objects[i];
|
|
28191
|
+
if (o === object) {
|
|
28192
|
+
objects.splice(i, 1);
|
|
28193
|
+
this.parent.removeObject(o);
|
|
28194
|
+
return;
|
|
28195
|
+
}
|
|
28196
|
+
}
|
|
28197
|
+
}
|
|
28198
|
+
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
28199
|
+
const objects = [...this.getObjects()];
|
|
28200
|
+
const objectsLength = objects.length;
|
|
28201
|
+
if (width == null) width = this.width;
|
|
28202
|
+
if (height == null) height = this.height;
|
|
28203
|
+
for (let i = 0; i < objectsLength; i++) {
|
|
28204
|
+
const o = objects[i];
|
|
28205
|
+
if (o.oKey === oKey) {
|
|
28206
|
+
objects.splice(i, 1);
|
|
28207
|
+
isTransform && this._transformObject(o, width, height);
|
|
28208
|
+
o.parent = this.parent;
|
|
28209
|
+
o.groupKey = void 0;
|
|
28210
|
+
o.isInGroup = false;
|
|
28211
|
+
this._objects = objects;
|
|
28212
|
+
return;
|
|
28213
|
+
}
|
|
28214
|
+
}
|
|
28215
|
+
}
|
|
28216
|
+
_transformObject(object, groupWidth, groupHeight) {
|
|
28217
|
+
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
28218
|
+
if (object.classType === "Group") object.transformByState({
|
|
28219
|
+
left: transform.left,
|
|
28220
|
+
top: transform.top
|
|
28221
|
+
});
|
|
28222
|
+
else object.transformByState(transform);
|
|
28223
|
+
}
|
|
28224
|
+
getObjectsByOrder() {
|
|
28225
|
+
const objects = [];
|
|
28226
|
+
this._objects.sort(sortRules);
|
|
28227
|
+
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
28228
|
+
return objects;
|
|
28229
|
+
}
|
|
28230
|
+
getObjects() {
|
|
28231
|
+
return this._objects;
|
|
28232
|
+
}
|
|
28233
|
+
render(ctx, bounds) {
|
|
28234
|
+
ctx.save();
|
|
28235
|
+
const m = this.transform.getMatrix();
|
|
28236
|
+
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
28237
|
+
const objects = this.getObjectsByOrder();
|
|
28238
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28239
|
+
ctx.restore();
|
|
28240
|
+
}
|
|
28241
|
+
_clear() {
|
|
28242
|
+
this._objects = [];
|
|
28243
|
+
}
|
|
28244
|
+
dispose() {
|
|
28245
|
+
[...this.getObjects()].forEach((o) => {
|
|
28246
|
+
o.dispose();
|
|
28247
|
+
});
|
|
28248
|
+
this._clear();
|
|
28249
|
+
super.dispose();
|
|
28250
|
+
}
|
|
28251
|
+
};
|
|
28252
|
+
|
|
28253
|
+
//#endregion
|
|
28254
|
+
//#region src/drawing-group.ts
|
|
28255
|
+
var DrawingGroupObject = class extends Group {
|
|
28256
|
+
constructor(..._args) {
|
|
28257
|
+
super(..._args);
|
|
28258
|
+
_defineProperty(this, "_selfSizeMode", true);
|
|
28259
|
+
_defineProperty(this, "_baseBound", {
|
|
28260
|
+
left: 0,
|
|
28261
|
+
top: 0,
|
|
28262
|
+
width: 0,
|
|
28263
|
+
height: 0
|
|
28264
|
+
});
|
|
28265
|
+
_defineProperty(this, "_outerShadow", void 0);
|
|
28266
|
+
_defineProperty(this, "_glow", void 0);
|
|
28267
|
+
}
|
|
28268
|
+
setOuterShadow(shadow) {
|
|
28269
|
+
this._outerShadow = shadow;
|
|
28270
|
+
this.makeDirty(true);
|
|
28271
|
+
}
|
|
28272
|
+
setGlow(glow) {
|
|
28273
|
+
this._glow = glow;
|
|
28274
|
+
this.makeDirty(true);
|
|
28275
|
+
}
|
|
28276
|
+
/**
|
|
28277
|
+
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
28278
|
+
* This defines the coordinate space of children within the group.
|
|
28279
|
+
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
28280
|
+
* are tracked independently of children.
|
|
28281
|
+
*/
|
|
28282
|
+
setBaseBound(bound) {
|
|
28283
|
+
this._baseBound = { ...bound };
|
|
28284
|
+
}
|
|
28285
|
+
/**
|
|
28286
|
+
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
28287
|
+
*/
|
|
28288
|
+
getBaseBound() {
|
|
28289
|
+
return { ...this._baseBound };
|
|
28290
|
+
}
|
|
28291
|
+
/**
|
|
28292
|
+
* Override ancestorTransform to use the same render transform as render(),
|
|
28293
|
+
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
28294
|
+
* instead of the standard transform translation.
|
|
28295
|
+
* This ensures children (e.g., Image.isHit) that compose with
|
|
28296
|
+
* parent.ancestorTransform get the correct coordinate space.
|
|
28297
|
+
*/
|
|
28298
|
+
get ancestorTransform() {
|
|
28299
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28300
|
+
const m = this.transform.getMatrix();
|
|
28301
|
+
const centerX = realLeft + realWidth / 2;
|
|
28302
|
+
const centerY = realTop + realHeight / 2;
|
|
28303
|
+
const renderTransform = new Transform([
|
|
28304
|
+
m[0],
|
|
28305
|
+
m[1],
|
|
28306
|
+
m[2],
|
|
28307
|
+
m[3],
|
|
28308
|
+
centerX,
|
|
28309
|
+
centerY
|
|
28310
|
+
]);
|
|
28311
|
+
const parent = this.getParent();
|
|
28312
|
+
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
28313
|
+
return renderTransform;
|
|
28314
|
+
}
|
|
28315
|
+
render(ctx, bounds) {
|
|
28316
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28317
|
+
ctx.save();
|
|
28318
|
+
const m = this.transform.getMatrix();
|
|
28319
|
+
const centerX = realLeft + realWidth / 2;
|
|
28320
|
+
const centerY = realTop + realHeight / 2;
|
|
28321
|
+
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
28322
|
+
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
28323
|
+
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
28324
|
+
if (this._outerShadow) {
|
|
28325
|
+
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
28326
|
+
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
28327
|
+
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
28328
|
+
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
28329
|
+
}
|
|
28330
|
+
const objects = this.getObjectsByOrder();
|
|
28331
|
+
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
28332
|
+
ctx.restore();
|
|
28333
|
+
}
|
|
28334
|
+
addObjects(...objects) {
|
|
28335
|
+
for (const object of objects) this.addObject(object);
|
|
28336
|
+
}
|
|
28337
|
+
isHit(coord) {
|
|
28338
|
+
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
28339
|
+
const m = this.transform.getMatrix();
|
|
28340
|
+
const centerX = realLeft + realWidth / 2;
|
|
28341
|
+
const centerY = realTop + realHeight / 2;
|
|
28342
|
+
const renderTransform = new Transform([
|
|
28343
|
+
m[0],
|
|
28344
|
+
m[1],
|
|
28345
|
+
m[2],
|
|
28346
|
+
m[3],
|
|
28347
|
+
centerX,
|
|
28348
|
+
centerY
|
|
28349
|
+
]);
|
|
28350
|
+
const parent = this.getParent();
|
|
28351
|
+
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
28352
|
+
const halfWidth = realWidth / 2;
|
|
28353
|
+
const halfHeight = realHeight / 2;
|
|
28354
|
+
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
28355
|
+
const objects = this.getObjectsByOrder();
|
|
28356
|
+
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
28357
|
+
return false;
|
|
28358
|
+
}
|
|
28359
|
+
dispose() {
|
|
28360
|
+
const objects = [...this.getObjects()];
|
|
28361
|
+
const scene = this.getScene();
|
|
28362
|
+
objects.forEach((o) => {
|
|
28363
|
+
o.dispose();
|
|
28364
|
+
scene === null || scene === void 0 || scene.removeObject(o);
|
|
28365
|
+
});
|
|
28366
|
+
this._objects = [];
|
|
28367
|
+
super.dispose();
|
|
28368
|
+
scene === null || scene === void 0 || scene.removeObject(this);
|
|
28369
|
+
}
|
|
28370
|
+
};
|
|
28371
|
+
|
|
27888
28372
|
//#endregion
|
|
27889
28373
|
//#region src/components/docs/doc-component.ts
|
|
27890
28374
|
var DocComponent = class extends RenderComponent {
|
|
@@ -28331,7 +28815,9 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
28331
28815
|
const { ts: textStyle, content, fontStyle, bBox } = glyph;
|
|
28332
28816
|
const { spanPointWithFont = Vector2.create(0, 0) } = this.extensionOffset;
|
|
28333
28817
|
if (content == null) return;
|
|
28334
|
-
|
|
28818
|
+
const currentKerning = ctx.fontKerning;
|
|
28819
|
+
const fontKerning = (fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.fontKerning) ?? "auto";
|
|
28820
|
+
if (currentKerning != null && currentKerning !== fontKerning) ctx.fontKerning = fontKerning;
|
|
28335
28821
|
if (!textStyle) {
|
|
28336
28822
|
this._fillText(ctx, glyph, spanPointWithFont);
|
|
28337
28823
|
return;
|
|
@@ -29093,8 +29579,21 @@ var Documents = class Documents extends DocComponent {
|
|
|
29093
29579
|
return this.getScene().getEngine();
|
|
29094
29580
|
}
|
|
29095
29581
|
isHit(coord) {
|
|
29582
|
+
if (super.isHit(coord)) {
|
|
29583
|
+
var _this$getScene;
|
|
29584
|
+
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));
|
|
29585
|
+
const skeleton = this.getSkeleton();
|
|
29586
|
+
if (drawingHit && skeleton) {
|
|
29587
|
+
const node = skeleton.findNodeByCoord(this.getInverseCoord(coord), this.pageLayoutType, this.pageMarginLeft, this.pageMarginTop);
|
|
29588
|
+
if (node === null || node === void 0 ? void 0 : node.isInsideGlyph) return true;
|
|
29589
|
+
return this._isHitTable(coord);
|
|
29590
|
+
}
|
|
29591
|
+
return true;
|
|
29592
|
+
}
|
|
29593
|
+
return this._isHitTable(coord);
|
|
29594
|
+
}
|
|
29595
|
+
_isHitTable(coord) {
|
|
29096
29596
|
var _this$getSkeleton;
|
|
29097
|
-
if (super.isHit(coord)) return true;
|
|
29098
29597
|
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
29099
29598
|
if (!skeletonData) return false;
|
|
29100
29599
|
const localCoord = this.getInverseCoord(coord);
|
|
@@ -34402,290 +34901,6 @@ var CustomObject = class extends BaseObject {
|
|
|
34402
34901
|
}
|
|
34403
34902
|
};
|
|
34404
34903
|
|
|
34405
|
-
//#endregion
|
|
34406
|
-
//#region src/group.ts
|
|
34407
|
-
var Group = class extends BaseObject {
|
|
34408
|
-
constructor(key, ...objects) {
|
|
34409
|
-
super(key);
|
|
34410
|
-
_defineProperty(this, "_objects", []);
|
|
34411
|
-
_defineProperty(this, "_selfSizeMode", false);
|
|
34412
|
-
this.addObjects(...objects);
|
|
34413
|
-
}
|
|
34414
|
-
get classType() {
|
|
34415
|
-
return "Group";
|
|
34416
|
-
}
|
|
34417
|
-
set cursor(val) {
|
|
34418
|
-
this.setCursor(val);
|
|
34419
|
-
}
|
|
34420
|
-
getState() {
|
|
34421
|
-
if (this._selfSizeMode) return super.getState();
|
|
34422
|
-
return getGroupState(this.left, this.top, this._objects.map((o) => o.getState()));
|
|
34423
|
-
}
|
|
34424
|
-
get width() {
|
|
34425
|
-
if (this._selfSizeMode) return super.width;
|
|
34426
|
-
return this.getState().width || 0;
|
|
34427
|
-
}
|
|
34428
|
-
get height() {
|
|
34429
|
-
if (this._selfSizeMode) return super.height;
|
|
34430
|
-
return this.getState().height || 0;
|
|
34431
|
-
}
|
|
34432
|
-
set width(val) {
|
|
34433
|
-
if (this._selfSizeMode) {
|
|
34434
|
-
super.width = val;
|
|
34435
|
-
return;
|
|
34436
|
-
}
|
|
34437
|
-
const numDelta = val - this.width;
|
|
34438
|
-
this._objects.forEach((o) => {
|
|
34439
|
-
o.resize(o.width + numDelta);
|
|
34440
|
-
});
|
|
34441
|
-
}
|
|
34442
|
-
set height(val) {
|
|
34443
|
-
if (this._selfSizeMode) {
|
|
34444
|
-
super.height = val;
|
|
34445
|
-
return;
|
|
34446
|
-
}
|
|
34447
|
-
const numDelta = val - this.height;
|
|
34448
|
-
this._objects.forEach((o) => {
|
|
34449
|
-
o.resize(void 0, o.height + numDelta);
|
|
34450
|
-
});
|
|
34451
|
-
}
|
|
34452
|
-
get maxZIndex() {
|
|
34453
|
-
let maxZIndex = 0;
|
|
34454
|
-
for (const object of this._objects) maxZIndex = Math.max(maxZIndex, object.zIndex);
|
|
34455
|
-
return maxZIndex;
|
|
34456
|
-
}
|
|
34457
|
-
openSelfSizeMode() {
|
|
34458
|
-
this._selfSizeMode = true;
|
|
34459
|
-
}
|
|
34460
|
-
closeSelfSizeMode() {
|
|
34461
|
-
this._selfSizeMode = false;
|
|
34462
|
-
}
|
|
34463
|
-
reCalculateObjects() {
|
|
34464
|
-
if (this._selfSizeMode) return;
|
|
34465
|
-
const { left = 0, top = 0 } = this.getState();
|
|
34466
|
-
for (const object of this._objects) object.transformByState({
|
|
34467
|
-
left: object.left - left,
|
|
34468
|
-
top: object.top - top
|
|
34469
|
-
});
|
|
34470
|
-
this.transformByState({
|
|
34471
|
-
left,
|
|
34472
|
-
top
|
|
34473
|
-
});
|
|
34474
|
-
}
|
|
34475
|
-
addObjects(...objects) {
|
|
34476
|
-
for (const object of objects) this.addObject(object);
|
|
34477
|
-
}
|
|
34478
|
-
addObject(o) {
|
|
34479
|
-
let object = o;
|
|
34480
|
-
if (isString(o)) {
|
|
34481
|
-
const scene = this.getScene();
|
|
34482
|
-
object = scene === null || scene === void 0 ? void 0 : scene.getObject(o);
|
|
34483
|
-
if (!object) return;
|
|
34484
|
-
object.parent = this;
|
|
34485
|
-
object.isInGroup = true;
|
|
34486
|
-
object.groupKey = this.oKey;
|
|
34487
|
-
this._objects.push(object);
|
|
34488
|
-
} else {
|
|
34489
|
-
o.parent = this;
|
|
34490
|
-
o.isInGroup = true;
|
|
34491
|
-
o.groupKey = this.oKey;
|
|
34492
|
-
this._objects.push(o);
|
|
34493
|
-
}
|
|
34494
|
-
}
|
|
34495
|
-
removeObject(object) {
|
|
34496
|
-
const objects = this.getObjects();
|
|
34497
|
-
const objectsLength = objects.length;
|
|
34498
|
-
if (isString(object)) for (let i = 0; i < objectsLength; i++) {
|
|
34499
|
-
const o = objects[i];
|
|
34500
|
-
if (o.oKey === object) {
|
|
34501
|
-
objects.splice(i, 1);
|
|
34502
|
-
this.parent.removeObject(o);
|
|
34503
|
-
return;
|
|
34504
|
-
}
|
|
34505
|
-
}
|
|
34506
|
-
else for (let i = 0; i < objectsLength; i++) {
|
|
34507
|
-
const o = objects[i];
|
|
34508
|
-
if (o === object) {
|
|
34509
|
-
objects.splice(i, 1);
|
|
34510
|
-
this.parent.removeObject(o);
|
|
34511
|
-
return;
|
|
34512
|
-
}
|
|
34513
|
-
}
|
|
34514
|
-
}
|
|
34515
|
-
removeSelfObjectAndTransform(oKey, width, height, isTransform = false) {
|
|
34516
|
-
const objects = [...this.getObjects()];
|
|
34517
|
-
const objectsLength = objects.length;
|
|
34518
|
-
if (width == null) width = this.width;
|
|
34519
|
-
if (height == null) height = this.height;
|
|
34520
|
-
for (let i = 0; i < objectsLength; i++) {
|
|
34521
|
-
const o = objects[i];
|
|
34522
|
-
if (o.oKey === oKey) {
|
|
34523
|
-
objects.splice(i, 1);
|
|
34524
|
-
isTransform && this._transformObject(o, width, height);
|
|
34525
|
-
o.parent = this.parent;
|
|
34526
|
-
o.groupKey = void 0;
|
|
34527
|
-
o.isInGroup = false;
|
|
34528
|
-
this._objects = objects;
|
|
34529
|
-
return;
|
|
34530
|
-
}
|
|
34531
|
-
}
|
|
34532
|
-
}
|
|
34533
|
-
_transformObject(object, groupWidth, groupHeight) {
|
|
34534
|
-
const transform = transformObjectOutOfGroup(object.getState(), this.getState(), groupWidth, groupHeight);
|
|
34535
|
-
if (object.classType === "Group") object.transformByState({
|
|
34536
|
-
left: transform.left,
|
|
34537
|
-
top: transform.top
|
|
34538
|
-
});
|
|
34539
|
-
else object.transformByState(transform);
|
|
34540
|
-
}
|
|
34541
|
-
getObjectsByOrder() {
|
|
34542
|
-
const objects = [];
|
|
34543
|
-
this._objects.sort(sortRules);
|
|
34544
|
-
for (const o of this._objects) if (o.visible) objects.push(o);
|
|
34545
|
-
return objects;
|
|
34546
|
-
}
|
|
34547
|
-
getObjects() {
|
|
34548
|
-
return this._objects;
|
|
34549
|
-
}
|
|
34550
|
-
render(ctx, bounds) {
|
|
34551
|
-
ctx.save();
|
|
34552
|
-
const m = this.transform.getMatrix();
|
|
34553
|
-
ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
34554
|
-
const objects = this.getObjectsByOrder();
|
|
34555
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34556
|
-
ctx.restore();
|
|
34557
|
-
}
|
|
34558
|
-
_clear() {
|
|
34559
|
-
this._objects = [];
|
|
34560
|
-
}
|
|
34561
|
-
dispose() {
|
|
34562
|
-
[...this.getObjects()].forEach((o) => {
|
|
34563
|
-
o.dispose();
|
|
34564
|
-
});
|
|
34565
|
-
this._clear();
|
|
34566
|
-
super.dispose();
|
|
34567
|
-
}
|
|
34568
|
-
};
|
|
34569
|
-
|
|
34570
|
-
//#endregion
|
|
34571
|
-
//#region src/drawing-group.ts
|
|
34572
|
-
var DrawingGroupObject = class extends Group {
|
|
34573
|
-
constructor(..._args) {
|
|
34574
|
-
super(..._args);
|
|
34575
|
-
_defineProperty(this, "_selfSizeMode", true);
|
|
34576
|
-
_defineProperty(this, "_baseBound", {
|
|
34577
|
-
left: 0,
|
|
34578
|
-
top: 0,
|
|
34579
|
-
width: 0,
|
|
34580
|
-
height: 0
|
|
34581
|
-
});
|
|
34582
|
-
_defineProperty(this, "_outerShadow", void 0);
|
|
34583
|
-
_defineProperty(this, "_glow", void 0);
|
|
34584
|
-
}
|
|
34585
|
-
setOuterShadow(shadow) {
|
|
34586
|
-
this._outerShadow = shadow;
|
|
34587
|
-
this.makeDirty(true);
|
|
34588
|
-
}
|
|
34589
|
-
setGlow(glow) {
|
|
34590
|
-
this._glow = glow;
|
|
34591
|
-
this.makeDirty(true);
|
|
34592
|
-
}
|
|
34593
|
-
/**
|
|
34594
|
-
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
34595
|
-
* This defines the coordinate space of children within the group.
|
|
34596
|
-
* When set, the group automatically enters selfSizeMode so its dimensions
|
|
34597
|
-
* are tracked independently of children.
|
|
34598
|
-
*/
|
|
34599
|
-
setBaseBound(bound) {
|
|
34600
|
-
this._baseBound = { ...bound };
|
|
34601
|
-
}
|
|
34602
|
-
/**
|
|
34603
|
-
* Get the baseBound (chOff/chExt in OOXML) for this group.
|
|
34604
|
-
*/
|
|
34605
|
-
getBaseBound() {
|
|
34606
|
-
return { ...this._baseBound };
|
|
34607
|
-
}
|
|
34608
|
-
/**
|
|
34609
|
-
* Override ancestorTransform to use the same render transform as render(),
|
|
34610
|
-
* which uses [m[0], m[1], m[2], m[3], centerX, centerY] from realBound
|
|
34611
|
-
* instead of the standard transform translation.
|
|
34612
|
-
* This ensures children (e.g., Image.isHit) that compose with
|
|
34613
|
-
* parent.ancestorTransform get the correct coordinate space.
|
|
34614
|
-
*/
|
|
34615
|
-
get ancestorTransform() {
|
|
34616
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34617
|
-
const m = this.transform.getMatrix();
|
|
34618
|
-
const centerX = realLeft + realWidth / 2;
|
|
34619
|
-
const centerY = realTop + realHeight / 2;
|
|
34620
|
-
const renderTransform = new Transform([
|
|
34621
|
-
m[0],
|
|
34622
|
-
m[1],
|
|
34623
|
-
m[2],
|
|
34624
|
-
m[3],
|
|
34625
|
-
centerX,
|
|
34626
|
-
centerY
|
|
34627
|
-
]);
|
|
34628
|
-
const parent = this.getParent();
|
|
34629
|
-
if (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group") return parent.ancestorTransform.multiply(renderTransform);
|
|
34630
|
-
return renderTransform;
|
|
34631
|
-
}
|
|
34632
|
-
render(ctx, bounds) {
|
|
34633
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34634
|
-
ctx.save();
|
|
34635
|
-
const m = this.transform.getMatrix();
|
|
34636
|
-
const centerX = realLeft + realWidth / 2;
|
|
34637
|
-
const centerY = realTop + realHeight / 2;
|
|
34638
|
-
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
34639
|
-
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
34640
|
-
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
34641
|
-
if (this._outerShadow) {
|
|
34642
|
-
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
34643
|
-
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
34644
|
-
ctx.shadowOffsetX = this._outerShadow.shadowOffsetX;
|
|
34645
|
-
ctx.shadowOffsetY = this._outerShadow.shadowOffsetY;
|
|
34646
|
-
}
|
|
34647
|
-
const objects = this.getObjectsByOrder();
|
|
34648
|
-
for (let i = 0; i < objects.length; i++) objects[i].render(ctx, bounds);
|
|
34649
|
-
ctx.restore();
|
|
34650
|
-
}
|
|
34651
|
-
addObjects(...objects) {
|
|
34652
|
-
for (const object of objects) this.addObject(object);
|
|
34653
|
-
}
|
|
34654
|
-
isHit(coord) {
|
|
34655
|
-
const { left: realLeft, top: realTop, width: realWidth, height: realHeight } = this.getRealBound();
|
|
34656
|
-
const m = this.transform.getMatrix();
|
|
34657
|
-
const centerX = realLeft + realWidth / 2;
|
|
34658
|
-
const centerY = realTop + realHeight / 2;
|
|
34659
|
-
const renderTransform = new Transform([
|
|
34660
|
-
m[0],
|
|
34661
|
-
m[1],
|
|
34662
|
-
m[2],
|
|
34663
|
-
m[3],
|
|
34664
|
-
centerX,
|
|
34665
|
-
centerY
|
|
34666
|
-
]);
|
|
34667
|
-
const parent = this.getParent();
|
|
34668
|
-
const oCoord = (this.isInGroup && (parent === null || parent === void 0 ? void 0 : parent.classType) === "Group" ? parent.ancestorTransform.multiply(renderTransform) : renderTransform).invert().applyPoint(coord);
|
|
34669
|
-
const halfWidth = realWidth / 2;
|
|
34670
|
-
const halfHeight = realHeight / 2;
|
|
34671
|
-
if (oCoord.x < -halfWidth || oCoord.x > halfWidth || oCoord.y < -halfHeight || oCoord.y > halfHeight) return false;
|
|
34672
|
-
const objects = this.getObjectsByOrder();
|
|
34673
|
-
for (let i = 0; i < objects.length; i++) if (objects[i].isHit(coord)) return true;
|
|
34674
|
-
return false;
|
|
34675
|
-
}
|
|
34676
|
-
dispose() {
|
|
34677
|
-
const objects = [...this.getObjects()];
|
|
34678
|
-
const scene = this.getScene();
|
|
34679
|
-
objects.forEach((o) => {
|
|
34680
|
-
o.dispose();
|
|
34681
|
-
scene === null || scene === void 0 || scene.removeObject(o);
|
|
34682
|
-
});
|
|
34683
|
-
this._objects = [];
|
|
34684
|
-
super.dispose();
|
|
34685
|
-
scene === null || scene === void 0 || scene.removeObject(this);
|
|
34686
|
-
}
|
|
34687
|
-
};
|
|
34688
|
-
|
|
34689
34904
|
//#endregion
|
|
34690
34905
|
//#region src/floating/util.ts
|
|
34691
34906
|
/**
|
|
@@ -35528,7 +35743,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
35528
35743
|
//#endregion
|
|
35529
35744
|
//#region package.json
|
|
35530
35745
|
var name = "@univerjs/engine-render";
|
|
35531
|
-
var version = "1.0
|
|
35746
|
+
var version = "1.2.0";
|
|
35532
35747
|
|
|
35533
35748
|
//#endregion
|
|
35534
35749
|
//#region src/config/config.ts
|
|
@@ -40414,7 +40629,8 @@ var DocumentLayoutSession = class extends Disposable {
|
|
|
40414
40629
|
})))]) : null,
|
|
40415
40630
|
drawingAnchor: complete ? [...skeletonData.drawingAnchor ?? []].map(([segmentId, anchors]) => [segmentId, [...anchors].map(([paragraphIndex, anchor]) => [paragraphIndex, {
|
|
40416
40631
|
paragraphIndex: anchor.paragraphIndex,
|
|
40417
|
-
top: anchor.top
|
|
40632
|
+
top: anchor.top,
|
|
40633
|
+
...anchor.left == null ? {} : { left: anchor.left }
|
|
40418
40634
|
}])]) : null
|
|
40419
40635
|
};
|
|
40420
40636
|
}
|