@univerjs/engine-render 0.25.0 → 1.0.0-alpha.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 +1192 -262
- package/lib/es/index.js +1193 -263
- package/lib/types/basics/document-node-tools.d.ts +1 -0
- package/lib/types/basics/i-document-skeleton-cached.d.ts +2 -1
- package/lib/types/basics/interfaces.d.ts +6 -0
- package/lib/types/basics/transformer-config.d.ts +17 -0
- package/lib/types/components/docs/doc-background.d.ts +4 -0
- package/lib/types/components/docs/document-compatibility.d.ts +43 -0
- package/lib/types/components/docs/document.d.ts +4 -0
- package/lib/types/components/docs/extensions/background-runs.d.ts +22 -0
- package/lib/types/components/docs/extensions/font-and-base-line.d.ts +10 -0
- package/lib/types/components/docs/layout/block/paragraph/layout-ruler.d.ts +17 -3
- package/lib/types/components/docs/layout/model/line.d.ts +1 -1
- package/lib/types/components/docs/layout/tools.d.ts +4 -1
- package/lib/types/components/docs/table-render-viewport.d.ts +4 -0
- package/lib/types/components/sheets/extensions/border.d.ts +2 -2
- package/lib/types/components/sheets/interfaces.d.ts +6 -6
- package/lib/types/index.d.ts +6 -5
- package/lib/types/render-manager/render-manager.service.d.ts +1 -0
- package/lib/types/scene.transformer.d.ts +20 -0
- package/lib/types/services/canvas-color.service.d.ts +1 -0
- package/lib/types/shape/image.d.ts +3 -0
- package/lib/umd/index.js +2 -2
- package/package.json +8 -8
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, 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, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge,
|
|
1
|
+
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, 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, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, addLinkToDocumentModel, checkParagraphHasIndentByStyle, createIdentifier, createParagraphId, deleteContent, extractPureTextFromCell, getCellInfoInMergeData, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, registerDependencies, remove, requestImmediateMacroTask, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
2
|
import * as cjk from "cjk-regex";
|
|
3
3
|
import { BehaviorSubject, Observable, Subject, Subscription, debounceTime, distinctUntilChanged, shareReplay, startWith } from "rxjs";
|
|
4
4
|
import { parse } from "opentype.js";
|
|
@@ -640,7 +640,7 @@ function getSystemHighlightColor() {
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
//#endregion
|
|
643
|
-
//#region \0@oxc-project+runtime@0.
|
|
643
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
644
644
|
function _typeof(o) {
|
|
645
645
|
"@babel/helpers - typeof";
|
|
646
646
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -651,7 +651,7 @@ function _typeof(o) {
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
//#endregion
|
|
654
|
-
//#region \0@oxc-project+runtime@0.
|
|
654
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
655
655
|
function toPrimitive(t, r) {
|
|
656
656
|
if ("object" != _typeof(t) || !t) return t;
|
|
657
657
|
var e = t[Symbol.toPrimitive];
|
|
@@ -664,14 +664,14 @@ function toPrimitive(t, r) {
|
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
//#endregion
|
|
667
|
-
//#region \0@oxc-project+runtime@0.
|
|
667
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
668
668
|
function toPropertyKey(t) {
|
|
669
669
|
var i = toPrimitive(t, "string");
|
|
670
670
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
//#endregion
|
|
674
|
-
//#region \0@oxc-project+runtime@0.
|
|
674
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
675
675
|
function _defineProperty(e, r, t) {
|
|
676
676
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
677
677
|
value: t,
|
|
@@ -2288,8 +2288,8 @@ var Path2 = class {
|
|
|
2288
2288
|
const from = this._lines[o - 1];
|
|
2289
2289
|
const to = this._lines[o];
|
|
2290
2290
|
for (let n = 1; n < lines.length; n++) {
|
|
2291
|
-
const contrastFrom =
|
|
2292
|
-
const contrastTo =
|
|
2291
|
+
const contrastFrom = lines[n - 1];
|
|
2292
|
+
const contrastTo = lines[n];
|
|
2293
2293
|
const point = this._intersection({
|
|
2294
2294
|
from,
|
|
2295
2295
|
to
|
|
@@ -10853,8 +10853,8 @@ const TINF_OK = 0;
|
|
|
10853
10853
|
const TINF_DATA_ERROR = -3;
|
|
10854
10854
|
var Tree = class {
|
|
10855
10855
|
constructor() {
|
|
10856
|
-
_defineProperty(this, "table", new Uint16Array(16));
|
|
10857
|
-
_defineProperty(this, "trans", new Uint16Array(288));
|
|
10856
|
+
_defineProperty(this, "table", /* @__PURE__ */ new Uint16Array(16));
|
|
10857
|
+
_defineProperty(this, "trans", /* @__PURE__ */ new Uint16Array(288));
|
|
10858
10858
|
}
|
|
10859
10859
|
};
|
|
10860
10860
|
var Data = class {
|
|
@@ -10879,10 +10879,10 @@ var Data = class {
|
|
|
10879
10879
|
};
|
|
10880
10880
|
const sltree = new Tree();
|
|
10881
10881
|
const sdtree = new Tree();
|
|
10882
|
-
const length_bits = new Uint8Array(30);
|
|
10883
|
-
const length_base = new Uint16Array(30);
|
|
10884
|
-
const dist_bits = new Uint8Array(30);
|
|
10885
|
-
const dist_base = new Uint16Array(30);
|
|
10882
|
+
const length_bits = /* @__PURE__ */ new Uint8Array(30);
|
|
10883
|
+
const length_base = /* @__PURE__ */ new Uint16Array(30);
|
|
10884
|
+
const dist_bits = /* @__PURE__ */ new Uint8Array(30);
|
|
10885
|
+
const dist_base = /* @__PURE__ */ new Uint16Array(30);
|
|
10886
10886
|
const clcidx = new Uint8Array([
|
|
10887
10887
|
16,
|
|
10888
10888
|
17,
|
|
@@ -10905,7 +10905,7 @@ const clcidx = new Uint8Array([
|
|
|
10905
10905
|
15
|
|
10906
10906
|
]);
|
|
10907
10907
|
const code_tree = new Tree();
|
|
10908
|
-
const lengths = new Uint8Array(320);
|
|
10908
|
+
const lengths = /* @__PURE__ */ new Uint8Array(320);
|
|
10909
10909
|
function tinf_build_bits_base(bits, base, delta, first) {
|
|
10910
10910
|
let i;
|
|
10911
10911
|
let sum;
|
|
@@ -10930,7 +10930,7 @@ function tinf_build_fixed_trees(lt, dt) {
|
|
|
10930
10930
|
dt.table[5] = 32;
|
|
10931
10931
|
for (i = 0; i < 32; ++i) dt.trans[i] = i;
|
|
10932
10932
|
}
|
|
10933
|
-
const offs = new Uint16Array(16);
|
|
10933
|
+
const offs = /* @__PURE__ */ new Uint16Array(16);
|
|
10934
10934
|
function tinf_build_tree(t, lengths, off, num) {
|
|
10935
10935
|
let i;
|
|
10936
10936
|
let sum;
|
|
@@ -12086,6 +12086,13 @@ function getDocsTableRenderViewport(unitId, tableId) {
|
|
|
12086
12086
|
var _docsTableRenderViewp;
|
|
12087
12087
|
return (_docsTableRenderViewp = docsTableRenderViewportProvider === null || docsTableRenderViewportProvider === void 0 ? void 0 : docsTableRenderViewportProvider(unitId, tableId)) !== null && _docsTableRenderViewp !== void 0 ? _docsTableRenderViewp : null;
|
|
12088
12088
|
}
|
|
12089
|
+
function getDocsTableVirtualContentWidth(viewport) {
|
|
12090
|
+
var _viewport$leadingInse, _viewport$trailingIns;
|
|
12091
|
+
return ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0) + viewport.contentWidth + ((_viewport$trailingIns = viewport.trailingInsetRight) !== null && _viewport$trailingIns !== void 0 ? _viewport$trailingIns : 0);
|
|
12092
|
+
}
|
|
12093
|
+
function hasDocsTableHorizontalViewport(viewport) {
|
|
12094
|
+
return viewport != null && getDocsTableVirtualContentWidth(viewport) > viewport.viewportWidth;
|
|
12095
|
+
}
|
|
12089
12096
|
|
|
12090
12097
|
//#endregion
|
|
12091
12098
|
//#region src/components/docs/view-model/data-stream-tree-node.ts
|
|
@@ -12556,6 +12563,68 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12556
12563
|
}
|
|
12557
12564
|
};
|
|
12558
12565
|
|
|
12566
|
+
//#endregion
|
|
12567
|
+
//#region src/components/docs/document-compatibility.ts
|
|
12568
|
+
const MODERN_DOCUMENT_COMPATIBILITY_POLICY = {
|
|
12569
|
+
mode: "modern",
|
|
12570
|
+
applyDocumentDefaultParagraphStyle: true,
|
|
12571
|
+
useWordStyleLineHeight: true,
|
|
12572
|
+
font: { metricScaleRules: [] },
|
|
12573
|
+
table: {
|
|
12574
|
+
currentPageOverflowTolerance: 0,
|
|
12575
|
+
rowOverflowTolerance: 0,
|
|
12576
|
+
allowImportedTableMarginOverflow: false
|
|
12577
|
+
}
|
|
12578
|
+
};
|
|
12579
|
+
const TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY = {
|
|
12580
|
+
mode: "traditional",
|
|
12581
|
+
applyDocumentDefaultParagraphStyle: false,
|
|
12582
|
+
useWordStyleLineHeight: true,
|
|
12583
|
+
font: { metricScaleRules: [{
|
|
12584
|
+
fontFamily: /^calibri$/i,
|
|
12585
|
+
minFontSize: 20,
|
|
12586
|
+
fontString: /\bbold\b/i,
|
|
12587
|
+
content: /^[\d/]+$/u,
|
|
12588
|
+
widthScale: .92
|
|
12589
|
+
}] },
|
|
12590
|
+
table: {
|
|
12591
|
+
currentPageOverflowTolerance: 12,
|
|
12592
|
+
rowOverflowTolerance: 4,
|
|
12593
|
+
allowImportedTableMarginOverflow: true
|
|
12594
|
+
}
|
|
12595
|
+
};
|
|
12596
|
+
const UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY = {
|
|
12597
|
+
mode: "unspecified",
|
|
12598
|
+
applyDocumentDefaultParagraphStyle: false,
|
|
12599
|
+
useWordStyleLineHeight: false,
|
|
12600
|
+
font: { metricScaleRules: [] },
|
|
12601
|
+
table: {
|
|
12602
|
+
currentPageOverflowTolerance: 0,
|
|
12603
|
+
rowOverflowTolerance: 0,
|
|
12604
|
+
allowImportedTableMarginOverflow: false
|
|
12605
|
+
}
|
|
12606
|
+
};
|
|
12607
|
+
function getDocumentCompatibilityPolicy(documentFlavor) {
|
|
12608
|
+
if (documentFlavor === DocumentFlavor.MODERN) return MODERN_DOCUMENT_COMPATIBILITY_POLICY;
|
|
12609
|
+
if (documentFlavor === DocumentFlavor.TRADITIONAL) return TRADITIONAL_DOCUMENT_COMPATIBILITY_POLICY;
|
|
12610
|
+
return UNSPECIFIED_DOCUMENT_COMPATIBILITY_POLICY;
|
|
12611
|
+
}
|
|
12612
|
+
function applyFontMetricCompatibility(content, fontStyle, bBox, policy) {
|
|
12613
|
+
const fontFamilies = fontStyle.fontFamily.split(",").map((item) => item.trim().replace(/^['"]|['"]$/g, ""));
|
|
12614
|
+
const rule = policy.font.metricScaleRules.find((rule) => (rule.minFontSize == null || fontStyle.originFontSize >= rule.minFontSize) && (rule.fontString == null || rule.fontString.test(fontStyle.fontString)) && (rule.content == null || rule.content.test(content)) && fontFamilies.some((family) => rule.fontFamily.test(family)));
|
|
12615
|
+
if ((rule === null || rule === void 0 ? void 0 : rule.widthScale) == null) return bBox;
|
|
12616
|
+
return {
|
|
12617
|
+
...bBox,
|
|
12618
|
+
width: bBox.width * rule.widthScale
|
|
12619
|
+
};
|
|
12620
|
+
}
|
|
12621
|
+
function isTraditionalDocumentCompatibility(policy) {
|
|
12622
|
+
return policy.mode === "traditional";
|
|
12623
|
+
}
|
|
12624
|
+
function shouldAllowImportedTableMarginOverflow(policy, tableSource) {
|
|
12625
|
+
return policy.table.allowImportedTableMarginOverflow && tableSource != null && typeof tableSource === "object" && "docxWidth" in tableSource;
|
|
12626
|
+
}
|
|
12627
|
+
|
|
12559
12628
|
//#endregion
|
|
12560
12629
|
//#region src/components/docs/layout/model/glyph.ts
|
|
12561
12630
|
function isSpace(char) {
|
|
@@ -12636,6 +12705,7 @@ function createSkeletonCustomBlockGlyph(config, glyphWidth = 0, glyphHeight = 0,
|
|
|
12636
12705
|
};
|
|
12637
12706
|
}
|
|
12638
12707
|
function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, glyphInfo) {
|
|
12708
|
+
var _config$documentCompa;
|
|
12639
12709
|
const { fontStyle, textStyle, charSpace = 1, gridType = GridType.LINES, snapToGrid = BooleanNumber.FALSE } = config;
|
|
12640
12710
|
const skipWidthList = [
|
|
12641
12711
|
DataStreamTreeTokenType.SECTION_BREAK,
|
|
@@ -12686,6 +12756,7 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
|
|
|
12686
12756
|
let xOffset = 0;
|
|
12687
12757
|
if (glyphInfo && glyphInfo.boundingBox && glyphInfo.font) bBox = FontCache.getBBoxFromGlyphInfo(glyphInfo, fontStyle);
|
|
12688
12758
|
else bBox = FontCache.getTextSize(content, fontStyle);
|
|
12759
|
+
bBox = applyFontMetricCompatibility(content, fontStyle, bBox, (_config$documentCompa = config.documentCompatibilityPolicy) !== null && _config$documentCompa !== void 0 ? _config$documentCompa : getDocumentCompatibilityPolicy());
|
|
12689
12760
|
const { width: contentWidth = 0 } = bBox;
|
|
12690
12761
|
let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
|
|
12691
12762
|
if (validationGrid(gridType, snapToGrid)) {
|
|
@@ -12806,11 +12877,11 @@ function createSkeletonLine(paragraphIndex, lineType, lineBoundingBox, columnWid
|
|
|
12806
12877
|
lineSke.isBehindTable = true;
|
|
12807
12878
|
lineSke.tableId = tableId;
|
|
12808
12879
|
}
|
|
12809
|
-
lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP)));
|
|
12880
|
+
lineSke.divides = _calculateDividesByDrawings(lineHeight, lineTop, columnWidth, paddingLeft, paddingRight, page, headerPage, footerPage, new Map(Array.from(pageSkeDrawings).filter(([_, drawing]) => drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.INLINE && drawing.drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE)), headersDrawings, footersDrawings, new Map(Array.from(pageSkeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.WRAP)));
|
|
12810
12881
|
for (const divide of lineSke.divides) divide.parent = lineSke;
|
|
12811
12882
|
return lineSke;
|
|
12812
12883
|
}
|
|
12813
|
-
function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage) {
|
|
12884
|
+
function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, headerPage, footerPage, columnLeft = 0, columnWidth = 0) {
|
|
12814
12885
|
let maxTop = lineTop;
|
|
12815
12886
|
const pageSkeDrawings = page.skeDrawings;
|
|
12816
12887
|
const skeNonWrapTables = new Map(Array.from(page.skeTables).filter(([_, table]) => table.tableSource.textWrap === TableTextWrapType.NONE));
|
|
@@ -12827,6 +12898,8 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
|
|
|
12827
12898
|
pageSkeDrawings === null || pageSkeDrawings === void 0 || pageSkeDrawings.forEach((drawing) => {
|
|
12828
12899
|
const top = _getLineTopWidthWrapTopBottom(drawing, lineHeight, lineTop);
|
|
12829
12900
|
if (top) maxTop = Math.max(maxTop, top);
|
|
12901
|
+
const blockingWrapTop = _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth);
|
|
12902
|
+
if (blockingWrapTop) maxTop = Math.max(maxTop, blockingWrapTop);
|
|
12830
12903
|
});
|
|
12831
12904
|
skeNonWrapTables === null || skeNonWrapTables === void 0 || skeNonWrapTables.forEach((table) => {
|
|
12832
12905
|
const top = _getLineTopWidthWrapNone(table, lineHeight, lineTop);
|
|
@@ -12834,6 +12907,37 @@ function calculateLineTopByDrawings(lineHeight = 15.6, lineTop = 0, page, header
|
|
|
12834
12907
|
});
|
|
12835
12908
|
return maxTop;
|
|
12836
12909
|
}
|
|
12910
|
+
function _getLineTopWithFullColumnWrap(drawing, lineHeight, lineTop, columnLeft, columnWidth) {
|
|
12911
|
+
if (columnWidth <= 0) return;
|
|
12912
|
+
const { aTop, height, aLeft, width, angle = 0, drawingOrigin } = drawing;
|
|
12913
|
+
const { layoutType, distL = 0, distT = 0, distB = 0, distR = 0, wrapText } = drawingOrigin;
|
|
12914
|
+
if (layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return;
|
|
12915
|
+
let top = aTop;
|
|
12916
|
+
let drawingHeight = height;
|
|
12917
|
+
let left = aLeft - columnLeft;
|
|
12918
|
+
let drawingWidth = width;
|
|
12919
|
+
if (angle !== 0) {
|
|
12920
|
+
var _boundingBox$top, _boundingBox$height, _boundingBox$left, _boundingBox$width;
|
|
12921
|
+
const boundingBox = getBoundingBox(angle, left, width, top, height);
|
|
12922
|
+
top = (_boundingBox$top = boundingBox.top) !== null && _boundingBox$top !== void 0 ? _boundingBox$top : top;
|
|
12923
|
+
drawingHeight = (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : drawingHeight;
|
|
12924
|
+
left = (_boundingBox$left = boundingBox.left) !== null && _boundingBox$left !== void 0 ? _boundingBox$left : left;
|
|
12925
|
+
drawingWidth = (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : drawingWidth;
|
|
12926
|
+
}
|
|
12927
|
+
const newTop = top - (layoutType === PositionedObjectLayoutType.WRAP_SQUARE ? distT : 0);
|
|
12928
|
+
const newHeight = drawingHeight + (layoutType === PositionedObjectLayoutType.WRAP_SQUARE ? distB + distT : 0);
|
|
12929
|
+
const bottom = newTop + newHeight;
|
|
12930
|
+
if (bottom <= lineTop) return;
|
|
12931
|
+
const split = __getSplitWidthNoAngle(top, drawingHeight, left, drawingWidth, newTop, Math.max(1, newHeight), columnWidth, {
|
|
12932
|
+
distL,
|
|
12933
|
+
distT,
|
|
12934
|
+
distB,
|
|
12935
|
+
distR
|
|
12936
|
+
}, layoutType, wrapText);
|
|
12937
|
+
if (!split) return;
|
|
12938
|
+
if (split.left > 0 || split.left + split.width < columnWidth) return;
|
|
12939
|
+
return bottom;
|
|
12940
|
+
}
|
|
12837
12941
|
function _getLineTopWidthWrapNone(table, lineHeight, lineTop) {
|
|
12838
12942
|
const { top, height } = table;
|
|
12839
12943
|
if (top + height < lineTop || top > lineHeight + lineTop) return;
|
|
@@ -13033,6 +13137,7 @@ function _calculateDivideByDrawings(columnWidth, drawingSplit) {
|
|
|
13033
13137
|
divideSkeleton.push(divide);
|
|
13034
13138
|
}
|
|
13035
13139
|
}
|
|
13140
|
+
if (divideSkeleton.length === 0 && columnWidth > 0) return [__getDivideSKe(0, columnWidth)];
|
|
13036
13141
|
return divideSkeleton;
|
|
13037
13142
|
}
|
|
13038
13143
|
function __getDivideSKe(left, width) {
|
|
@@ -13089,17 +13194,11 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = Colu
|
|
|
13089
13194
|
let colWidth = 0;
|
|
13090
13195
|
let spaceWidth = 0;
|
|
13091
13196
|
if (columnProperties.length === 0) columns.push(_getSkeletonColumn(left, sectionWidth, 0, ColumnSeparatorType.NONE));
|
|
13092
|
-
else for (
|
|
13093
|
-
const { width, paddingEnd } = columnProperties[i];
|
|
13197
|
+
else for (const { width, paddingEnd } of _fitColumnProperties(columnProperties, sectionWidth)) {
|
|
13094
13198
|
spaceWidth = paddingEnd;
|
|
13095
13199
|
colWidth = width;
|
|
13096
13200
|
columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
|
|
13097
13201
|
left += colWidth + spaceWidth;
|
|
13098
|
-
if (i === columnProperties.length - 1) {
|
|
13099
|
-
colWidth = sectionWidth !== Number.POSITIVE_INFINITY ? sectionWidth - colWidth : width;
|
|
13100
|
-
spaceWidth = 0;
|
|
13101
|
-
columns.push(_getSkeletonColumn(left, colWidth, spaceWidth, columnSeparatorType));
|
|
13102
|
-
}
|
|
13103
13202
|
}
|
|
13104
13203
|
const newSection = {
|
|
13105
13204
|
columns,
|
|
@@ -13114,6 +13213,42 @@ function createSkeletonSection(columnProperties = [], columnSeparatorType = Colu
|
|
|
13114
13213
|
});
|
|
13115
13214
|
return newSection;
|
|
13116
13215
|
}
|
|
13216
|
+
function _fitColumnProperties(columnProperties, sectionWidth) {
|
|
13217
|
+
if (sectionWidth === Number.POSITIVE_INFINITY || columnProperties.length === 0) return columnProperties;
|
|
13218
|
+
const safeSectionWidth = Math.max(0, sectionWidth);
|
|
13219
|
+
const widths = columnProperties.map(({ width }) => Math.max(0, width));
|
|
13220
|
+
const spaces = columnProperties.map(({ paddingEnd }, index) => index === columnProperties.length - 1 ? 0 : Math.max(0, paddingEnd));
|
|
13221
|
+
const totalWidth = widths.reduce((sum, width) => sum + width, 0);
|
|
13222
|
+
if (safeSectionWidth === 0) return columnProperties.map((columnProperty) => ({
|
|
13223
|
+
...columnProperty,
|
|
13224
|
+
width: 0,
|
|
13225
|
+
paddingEnd: 0
|
|
13226
|
+
}));
|
|
13227
|
+
if (totalWidth <= 0) {
|
|
13228
|
+
const equalWidth = safeSectionWidth / columnProperties.length;
|
|
13229
|
+
return columnProperties.map((columnProperty, index) => ({
|
|
13230
|
+
...columnProperty,
|
|
13231
|
+
width: equalWidth,
|
|
13232
|
+
paddingEnd: 0
|
|
13233
|
+
}));
|
|
13234
|
+
}
|
|
13235
|
+
if (totalWidth > safeSectionWidth) {
|
|
13236
|
+
const scale = safeSectionWidth / totalWidth;
|
|
13237
|
+
return columnProperties.map((columnProperty, index) => ({
|
|
13238
|
+
...columnProperty,
|
|
13239
|
+
width: widths[index] * scale,
|
|
13240
|
+
paddingEnd: 0
|
|
13241
|
+
}));
|
|
13242
|
+
}
|
|
13243
|
+
const spaceBudget = safeSectionWidth - totalWidth;
|
|
13244
|
+
const totalSpace = spaces.reduce((sum, space) => sum + space, 0);
|
|
13245
|
+
const fittedSpaces = totalSpace > spaceBudget && totalSpace > 0 ? spaces.map((space) => space / totalSpace * spaceBudget) : spaces;
|
|
13246
|
+
return columnProperties.map((columnProperty, index) => ({
|
|
13247
|
+
...columnProperty,
|
|
13248
|
+
width: widths[index],
|
|
13249
|
+
paddingEnd: fittedSpaces[index]
|
|
13250
|
+
}));
|
|
13251
|
+
}
|
|
13117
13252
|
function setColumnFullState(column, state) {
|
|
13118
13253
|
column.isFull = state;
|
|
13119
13254
|
}
|
|
@@ -13214,12 +13349,13 @@ function createTableSkeleton(ctx, curPage, viewModel, tableNode, sectionBreakCon
|
|
|
13214
13349
|
function rollbackListCache(listLevel, table) {
|
|
13215
13350
|
const { startIndex, endIndex } = table;
|
|
13216
13351
|
for (const paragraphLists of listLevel.values()) for (const paragraphList of paragraphLists) {
|
|
13352
|
+
if (paragraphList == null) continue;
|
|
13217
13353
|
const paragraphListIndex = paragraphList.findIndex((p) => p.paragraph.startIndex > startIndex && p.paragraph.startIndex < endIndex);
|
|
13218
13354
|
if (paragraphListIndex > -1) paragraphList.splice(paragraphListIndex);
|
|
13219
13355
|
}
|
|
13220
13356
|
}
|
|
13221
13357
|
function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakConfig, availableHeight) {
|
|
13222
|
-
var _viewModel$getTableBy2;
|
|
13358
|
+
var _viewModel$getTableBy2, _sectionBreakConfig$d;
|
|
13223
13359
|
const skeTables = [];
|
|
13224
13360
|
const { startIndex, endIndex, children: rowNodes } = tableNode;
|
|
13225
13361
|
const table = (_viewModel$getTableBy2 = viewModel.getTableByStartIndex(startIndex)) === null || _viewModel$getTableBy2 === void 0 ? void 0 : _viewModel$getTableBy2.tableSource;
|
|
@@ -13242,9 +13378,10 @@ function createTableSkeletons(ctx, curPage, viewModel, tableNode, sectionBreakCo
|
|
|
13242
13378
|
skeTables.push(curTableSkeleton);
|
|
13243
13379
|
for (const rowNode of rowNodes) dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, rowNodes.indexOf(rowNode), table, createCache);
|
|
13244
13380
|
updateTableSkeletonsPosition(createCache, curPage, skeTables, table);
|
|
13381
|
+
const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy();
|
|
13245
13382
|
return {
|
|
13246
13383
|
skeTables,
|
|
13247
|
-
fromCurrentPage: skeTables[0].height <= availableHeight
|
|
13384
|
+
fromCurrentPage: skeTables[0].height <= availableHeight + documentCompatibilityPolicy.table.currentPageOverflowTolerance
|
|
13248
13385
|
};
|
|
13249
13386
|
}
|
|
13250
13387
|
function updateTableSkeletonsPosition(cache, curPage, skeTables, table) {
|
|
@@ -13274,14 +13411,16 @@ function getAvailableHeight(curPage, cache, hasRepeatHeader) {
|
|
|
13274
13411
|
return pageContentHeight;
|
|
13275
13412
|
}
|
|
13276
13413
|
function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig, rowNode, row, table, cache, isRepeatRow = false) {
|
|
13414
|
+
var _sectionBreakConfig$d2;
|
|
13277
13415
|
const pageContentHeight = getAvailableHeight(curPage, cache, false);
|
|
13278
13416
|
const availableHeight = getAvailableHeight(curPage, cache, true);
|
|
13417
|
+
const documentCompatibilityPolicy = (_sectionBreakConfig$d2 = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d2 !== void 0 ? _sectionBreakConfig$d2 : getDocumentCompatibilityPolicy();
|
|
13279
13418
|
const { children: cellNodes, startIndex, endIndex } = rowNode;
|
|
13280
13419
|
const rowSource = table.tableRows[row];
|
|
13281
13420
|
const { trHeight, cantSplit } = rowSource;
|
|
13282
13421
|
const rowSkeletons = [];
|
|
13283
13422
|
const { hRule, val } = trHeight;
|
|
13284
|
-
const canRowSplit = cantSplit
|
|
13423
|
+
const canRowSplit = cantSplit !== BooleanNumber.TRUE && trHeight.hRule === TableRowHeightRule.AUTO;
|
|
13285
13424
|
const MAX_FONT_SIZE = 72;
|
|
13286
13425
|
const needOpenNewTable = cache.remainHeight <= MAX_FONT_SIZE;
|
|
13287
13426
|
let curTableSkeleton = getCurTableSkeleton(skeTables);
|
|
@@ -13327,7 +13466,8 @@ function dealWithTableRow(ctx, curPage, skeTables, viewModel, sectionBreakConfig
|
|
|
13327
13466
|
while (rowSkeletons.length > 0) {
|
|
13328
13467
|
const rowSkeleton = rowSkeletons.shift();
|
|
13329
13468
|
const lastRow = curTableSkeleton.rows[curTableSkeleton.rows.length - 1];
|
|
13330
|
-
|
|
13469
|
+
const rowOverflowHeight = rowSkeleton.height - cache.remainHeight;
|
|
13470
|
+
if (cache.remainHeight < MAX_FONT_SIZE || rowOverflowHeight > documentCompatibilityPolicy.table.rowOverflowTolerance) {
|
|
13331
13471
|
cache.remainHeight = getAvailableHeight(curPage, cache, row !== 0 && rowSkeleton.index !== lastRow.index);
|
|
13332
13472
|
cache.rowTop = 0;
|
|
13333
13473
|
if (curTableSkeleton.rows.length > 0) {
|
|
@@ -13503,18 +13643,22 @@ function getTableIdAndSliceIndex(tableSliceId) {
|
|
|
13503
13643
|
|
|
13504
13644
|
//#endregion
|
|
13505
13645
|
//#region src/components/docs/layout/block/paragraph/layout-ruler.ts
|
|
13646
|
+
const LINE_LAYOUT_OVERFLOW_TOLERANCE = 2;
|
|
13647
|
+
const FLOAT_OBJECT_RELAYOUT_LIMIT = 5;
|
|
13506
13648
|
function layoutParagraph(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType = "Normal") {
|
|
13507
13649
|
if (isParagraphFirstShapedText) if (paragraphConfig.bulletSkeleton) {
|
|
13650
|
+
var _paragraphProperties$;
|
|
13508
13651
|
const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig;
|
|
13509
13652
|
const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5 } = sectionBreakConfig;
|
|
13510
13653
|
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
|
|
13511
13654
|
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
13512
13655
|
const bulletGlyph = createSkeletonBulletGlyph(glyphGroup[0], bulletSkeleton, charSpaceApply);
|
|
13513
13656
|
const paragraphProperties = bulletSkeleton.paragraphProperties || {};
|
|
13514
|
-
paragraphConfig.paragraphStyle =
|
|
13657
|
+
paragraphConfig.paragraphStyle = {
|
|
13515
13658
|
...paragraphProperties,
|
|
13516
|
-
hanging: { v: bulletGlyph.width }
|
|
13517
|
-
|
|
13659
|
+
hanging: (_paragraphProperties$ = paragraphProperties.hanging) !== null && _paragraphProperties$ !== void 0 ? _paragraphProperties$ : { v: bulletGlyph.width },
|
|
13660
|
+
...paragraphConfig.paragraphStyle
|
|
13661
|
+
};
|
|
13518
13662
|
_lineOperator(ctx, [bulletGlyph, ...glyphGroup], pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
|
|
13519
13663
|
} else _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
|
|
13520
13664
|
else _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType);
|
|
@@ -13543,6 +13687,11 @@ function isGlyphGroupBeyondContentBox(glyphGroup, left, divideWidth) {
|
|
|
13543
13687
|
}
|
|
13544
13688
|
return isBeyondContentBox;
|
|
13545
13689
|
}
|
|
13690
|
+
function shouldKeepOverflowingTextOnLine(sectionBreakConfig) {
|
|
13691
|
+
var _sectionBreakConfig$r;
|
|
13692
|
+
const wrapStrategy = (_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy;
|
|
13693
|
+
return wrapStrategy === WrapStrategy.CLIP || wrapStrategy === WrapStrategy.OVERFLOW;
|
|
13694
|
+
}
|
|
13546
13695
|
function _getConsecutiveHyphenLineCount(divide) {
|
|
13547
13696
|
var _divide$parent;
|
|
13548
13697
|
const column = (_divide$parent = divide.parent) === null || _divide$parent === void 0 ? void 0 : _divide$parent.parent;
|
|
@@ -13578,12 +13727,20 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
|
|
|
13578
13727
|
const preOffsetLeft = ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.width) || 0) + ((lastGlyph === null || lastGlyph === void 0 ? void 0 : lastGlyph.left) || 0);
|
|
13579
13728
|
const { hyphenationZone } = sectionBreakConfig;
|
|
13580
13729
|
if (preOffsetLeft + width > divide.width) {
|
|
13730
|
+
if (shouldKeepOverflowingTextOnLine(sectionBreakConfig)) {
|
|
13731
|
+
addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
|
|
13732
|
+
updateDivideInfo(divide, { breakType: breakPointType });
|
|
13733
|
+
return;
|
|
13734
|
+
}
|
|
13581
13735
|
updateDivideInfo(divide, { isFull: true });
|
|
13582
13736
|
const hyphenLineCount = _getConsecutiveHyphenLineCount(divideInfo.divide);
|
|
13583
13737
|
const { consecutiveHyphenLimit = Number.POSITIVE_INFINITY } = sectionBreakConfig;
|
|
13584
13738
|
if (divideInfo.isLast && glyphGroup.length === 1 && (glyphGroup[0].content === DataStreamTreeTokenType.SPACE || glyphGroup[0].content === DataStreamTreeTokenType.PARAGRAPH)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
|
|
13585
13739
|
else if (divideInfo.isLast && !isGlyphGroupBeyondContentBox(glyphGroup, preOffsetLeft, divide.width) && isGlyphGroupEndWithWhiteSpaces(glyphGroup)) addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
|
|
13586
|
-
else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
|
|
13740
|
+
else if (!isLast && (divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0 && glyphGroup.length === 1 && glyphGroup[0].streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyphGroup[0].width > divide.width) {
|
|
13741
|
+
updateDivideInfo(divide, { isFull: true });
|
|
13742
|
+
_divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultSpanLineHeight);
|
|
13743
|
+
} else if ((divide === null || divide === void 0 ? void 0 : divide.glyphGroup.length) === 0) {
|
|
13587
13744
|
const sliceGlyphGroup = [];
|
|
13588
13745
|
while (glyphGroup.length) {
|
|
13589
13746
|
sliceGlyphGroup.push(glyphGroup.shift());
|
|
@@ -13608,11 +13765,16 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
|
|
|
13608
13765
|
} else {
|
|
13609
13766
|
const currentLine = divide.parent;
|
|
13610
13767
|
const maxBox = __maxFontBoundingBoxByGlyphGroup(glyphGroup);
|
|
13611
|
-
if (currentLine &&
|
|
13768
|
+
if (currentLine && __isZeroWidthNonFlowFloatingAnchorLine(__getGlyphGroupByLine(currentLine), paragraphConfig.paragraphNonInlineSkeDrawings) && __hasFlowGlyph(glyphGroup)) {
|
|
13769
|
+
for (const lineDivide of currentLine.divides) updateDivideInfo(lineDivide, { isFull: true });
|
|
13770
|
+
_lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, false, breakPointType);
|
|
13771
|
+
return;
|
|
13772
|
+
}
|
|
13773
|
+
if (currentLine && maxBox && !__isNullLine(currentLine) && __hasFlowGlyph(__getGlyphGroupByLine(currentLine)) && !__isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings)) {
|
|
13612
13774
|
const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
|
|
13613
13775
|
const { boundingBoxAscent, boundingBoxDescent } = maxBox;
|
|
13614
|
-
const { contentHeight } =
|
|
13615
|
-
if (currentLine.contentHeight
|
|
13776
|
+
const { contentHeight } = getLineHeightMetrics(boundingBoxAscent + boundingBoxDescent, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight);
|
|
13777
|
+
if (contentHeight - currentLine.contentHeight > LINE_LAYOUT_OVERFLOW_TOLERANCE) {
|
|
13616
13778
|
const spanGroupCached = __getGlyphGroupByLine(currentLine);
|
|
13617
13779
|
const spanGroupCachedLen = spanGroupCached.length;
|
|
13618
13780
|
let newGlyphGroup = [];
|
|
@@ -13628,6 +13790,15 @@ function _divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphCo
|
|
|
13628
13790
|
return;
|
|
13629
13791
|
}
|
|
13630
13792
|
}
|
|
13793
|
+
if (currentLine === null || currentLine === void 0 ? void 0 : currentLine.parent) {
|
|
13794
|
+
const anchorDrawings = __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphConfig.paragraphNonInlineSkeDrawings);
|
|
13795
|
+
if (anchorDrawings.length > 0) {
|
|
13796
|
+
var _paragraphConfig$para, _paragraphConfig$pDra;
|
|
13797
|
+
const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, (_paragraphConfig$para = paragraphConfig.paragraphStyle) === null || _paragraphConfig$para === void 0 ? void 0 : _paragraphConfig$para.indentStart);
|
|
13798
|
+
const drawings = __getDrawingPosition(currentLine.top, currentLine.lineHeight, currentLine.parent, true, (_paragraphConfig$pDra = paragraphConfig.pDrawingAnchor) === null || _paragraphConfig$pDra === void 0 || (_paragraphConfig$pDra = _paragraphConfig$pDra.get(paragraphConfig.paragraphIndex)) === null || _paragraphConfig$pDra === void 0 ? void 0 : _paragraphConfig$pDra.top, anchorDrawings, paragraphAnchorLeft);
|
|
13799
|
+
__updateDrawingPosition(currentLine.parent, drawings);
|
|
13800
|
+
}
|
|
13801
|
+
}
|
|
13631
13802
|
addGlyphToDivide(divide, glyphGroup, preOffsetLeft);
|
|
13632
13803
|
updateDivideInfo(divide, { breakType: breakPointType });
|
|
13633
13804
|
}
|
|
@@ -13653,6 +13824,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
13653
13824
|
const descent = Math.max(...glyphGroup.map((glyph) => glyph.bBox.bd));
|
|
13654
13825
|
const glyphLineHeight = defaultGlyphLineHeight || ascent + descent;
|
|
13655
13826
|
const { paragraphStyle: originParagraphStyle = {}, paragraphNonInlineSkeDrawings, skeTablesInParagraph, skeHeaders, skeFooters, pDrawingAnchor, paragraphIndex } = paragraphConfig;
|
|
13827
|
+
const isZeroWidthNonFlowFloatingAnchorLine = __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings);
|
|
13656
13828
|
const { namedStyleType } = originParagraphStyle;
|
|
13657
13829
|
const namedStyle = namedStyleType !== void 0 ? NAMED_STYLE_SPACE_MAP[namedStyleType] : null;
|
|
13658
13830
|
const { spaceAbove, spaceBelow, indentFirstLine, hanging, indentStart, indentEnd } = {
|
|
@@ -13661,9 +13833,22 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
13661
13833
|
spaceBelow: (_originParagraphStyle2 = originParagraphStyle.spaceBelow) !== null && _originParagraphStyle2 !== void 0 ? _originParagraphStyle2 : namedStyle === null || namedStyle === void 0 ? void 0 : namedStyle.spaceBelow
|
|
13662
13834
|
};
|
|
13663
13835
|
const { paragraphLineGapDefault, linePitch, lineSpacing, spacingRule, snapToGrid, gridType } = getLineHeightConfig(sectionBreakConfig, paragraphConfig);
|
|
13664
|
-
const
|
|
13665
|
-
const
|
|
13836
|
+
const hasInlineCustomBlock = glyphGroup.some((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0);
|
|
13837
|
+
const glyphGroupCustomBlockIds = new Set(glyphGroup.filter((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null).map((glyph) => glyph.drawingId));
|
|
13838
|
+
let { paddingTop, paddingBottom, contentHeight, lineSpacingApply } = getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, paragraphConfig.useWordStyleLineHeight, !hasInlineCustomBlock);
|
|
13839
|
+
let { marginTop, spaceBelowApply } = __getParagraphSpace(ctx, lineSpacingApply, spaceAbove, spaceBelow, isParagraphFirstShapedText, preLine);
|
|
13840
|
+
if (isZeroWidthNonFlowFloatingAnchorLine) {
|
|
13841
|
+
paddingTop = 0;
|
|
13842
|
+
paddingBottom = 0;
|
|
13843
|
+
contentHeight = 0;
|
|
13844
|
+
lineSpacingApply = 0;
|
|
13845
|
+
marginTop = 0;
|
|
13846
|
+
spaceBelowApply = 0;
|
|
13847
|
+
}
|
|
13666
13848
|
const lineHeight = marginTop + paddingTop + contentHeight + paddingBottom;
|
|
13849
|
+
const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
|
|
13850
|
+
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
13851
|
+
const paragraphAnchorLeft = __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart);
|
|
13667
13852
|
let section = column.parent;
|
|
13668
13853
|
if (!section) section = getLastSection(lastPage);
|
|
13669
13854
|
const lineTop = ((preLine === null || preLine === void 0 ? void 0 : preLine.lineHeight) || 0) + ((preLine === null || preLine === void 0 ? void 0 : preLine.top) || 0);
|
|
@@ -13680,16 +13865,22 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
13680
13865
|
if (relativeLineDrawings.length > 0) __updateAndPositionDrawings(ctx, preLine.top, preLine.lineHeight, column, relativeLineDrawings, preLine.paragraphIndex, isParagraphFirstShapedText);
|
|
13681
13866
|
}
|
|
13682
13867
|
}
|
|
13868
|
+
let deferredInlineGroupAnchorDrawings = [];
|
|
13683
13869
|
if (paragraphNonInlineSkeDrawings != null && paragraphNonInlineSkeDrawings.size > 0) {
|
|
13684
13870
|
var _pDrawingAnchor$get;
|
|
13685
|
-
|
|
13871
|
+
let targetDrawings = [...paragraphNonInlineSkeDrawings.values()].filter((drawing) => drawing.drawingOrigin.docTransform.positionV.relativeFrom !== ObjectRelativeFromV.LINE);
|
|
13872
|
+
if (hasInlineCustomBlock) {
|
|
13873
|
+
deferredInlineGroupAnchorDrawings = targetDrawings.filter((drawing) => glyphGroupCustomBlockIds.has(drawing.drawingId) && drawing.drawingOrigin.docTransform.positionV.relativeFrom === ObjectRelativeFromV.LINE);
|
|
13874
|
+
targetDrawings = targetDrawings.filter((drawing) => !deferredInlineGroupAnchorDrawings.includes(drawing));
|
|
13875
|
+
}
|
|
13876
|
+
__updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get === void 0 ? void 0 : _pDrawingAnchor$get.top, paragraphAnchorLeft);
|
|
13686
13877
|
}
|
|
13687
13878
|
if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {
|
|
13688
13879
|
var _pDrawingAnchor$get2;
|
|
13689
13880
|
needOpenNewPageByTableLayout = _updateAndPositionTable(ctx, lineTop, lineHeight, lastPage, 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);
|
|
13690
13881
|
}
|
|
13691
13882
|
const newLineTop = calculateLineTopByDrawings(lineHeight, lineTop, lastPage, headerPage, footerPage);
|
|
13692
|
-
if (lineHeight + newLineTop
|
|
13883
|
+
if (lineHeight + newLineTop - section.height > LINE_LAYOUT_OVERFLOW_TOLERANCE && column.lines.length > 0 && lastPage.sections.length > 0 || needOpenNewPageByTableLayout) {
|
|
13693
13884
|
setColumnFullState(column, true);
|
|
13694
13885
|
_columnOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
|
|
13695
13886
|
if (isParagraphFirstShapedText && paragraphNonInlineSkeDrawings && paragraphNonInlineSkeDrawings.size > 0) for (const drawing of paragraphNonInlineSkeDrawings.values()) {
|
|
@@ -13703,8 +13894,7 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
13703
13894
|
return;
|
|
13704
13895
|
}
|
|
13705
13896
|
const lineIndex = preLine ? preLine.lineIndex + 1 : 0;
|
|
13706
|
-
|
|
13707
|
-
let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid), isParagraphFirstShapedText);
|
|
13897
|
+
let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply, isParagraphFirstShapedText);
|
|
13708
13898
|
if (paddingLeft + paddingRight >= column.width) {
|
|
13709
13899
|
const leftPercent = paddingLeft / (paddingLeft + paddingRight);
|
|
13710
13900
|
paddingLeft = column.width * leftPercent - .5;
|
|
@@ -13725,12 +13915,16 @@ function _lineOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConf
|
|
|
13725
13915
|
newLine.parent = column;
|
|
13726
13916
|
createAndUpdateBlockAnchor(paragraphIndex, newLine, lineTop, pDrawingAnchor);
|
|
13727
13917
|
_divideOperator(ctx, glyphGroup, pages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText, breakPointType, defaultGlyphLineHeight);
|
|
13918
|
+
if (deferredInlineGroupAnchorDrawings.length > 0) {
|
|
13919
|
+
var _pDrawingAnchor$get3;
|
|
13920
|
+
__updateAndPositionDrawings(ctx, lineTop, lineHeight, column, deferredInlineGroupAnchorDrawings, paragraphConfig.paragraphIndex, isParagraphFirstShapedText, pDrawingAnchor === null || pDrawingAnchor === void 0 || (_pDrawingAnchor$get3 = pDrawingAnchor.get(paragraphIndex)) === null || _pDrawingAnchor$get3 === void 0 ? void 0 : _pDrawingAnchor$get3.top, paragraphAnchorLeft, true);
|
|
13921
|
+
}
|
|
13728
13922
|
}
|
|
13729
|
-
function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop) {
|
|
13923
|
+
function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDrawings, paragraphIndex, isParagraphFirstShapedText, drawingAnchorTop, drawingAnchorLeft = 0, skipRelayoutCheck = false) {
|
|
13730
13924
|
if (targetDrawings.length === 0) return;
|
|
13731
|
-
const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings);
|
|
13925
|
+
const drawings = __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, drawingAnchorTop, targetDrawings, drawingAnchorLeft);
|
|
13732
13926
|
if (drawings == null || drawings.size === 0) return;
|
|
13733
|
-
|
|
13927
|
+
const floatObjects = [...drawings.values()].filter((drawing) => {
|
|
13734
13928
|
const layoutType = drawing.drawingOrigin.layoutType;
|
|
13735
13929
|
return layoutType !== PositionedObjectLayoutType.INLINE && layoutType !== PositionedObjectLayoutType.WRAP_NONE;
|
|
13736
13930
|
}).map((drawing) => {
|
|
@@ -13743,10 +13937,13 @@ function __updateAndPositionDrawings(ctx, lineTop, lineHeight, column, targetDra
|
|
|
13743
13937
|
width,
|
|
13744
13938
|
height,
|
|
13745
13939
|
angle,
|
|
13940
|
+
behindDoc: drawingOrigin.behindDoc,
|
|
13941
|
+
layoutType: drawingOrigin.layoutType,
|
|
13746
13942
|
type: "IMAGE",
|
|
13747
13943
|
positionV
|
|
13748
13944
|
};
|
|
13749
|
-
})
|
|
13945
|
+
});
|
|
13946
|
+
if (!skipRelayoutCheck) _reLayoutCheck(ctx, floatObjects, column, paragraphIndex);
|
|
13750
13947
|
__updateDrawingPosition(column, drawings);
|
|
13751
13948
|
}
|
|
13752
13949
|
function __updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop) {
|
|
@@ -13779,6 +13976,22 @@ function __getWrapTablePosition(table, column, lineTop, lineHeight, drawingAncho
|
|
|
13779
13976
|
top: (_getPositionVertical = getPositionVertical(positionV, page, lineTop, lineHeight, height, drawingAnchorTop, isPageBreak)) !== null && _getPositionVertical !== void 0 ? _getPositionVertical : 0
|
|
13780
13977
|
};
|
|
13781
13978
|
}
|
|
13979
|
+
function __avoidFlowAffectingDrawingsForTable(table, page, column) {
|
|
13980
|
+
const tableTop = table.top;
|
|
13981
|
+
const tableBottom = table.top + table.height;
|
|
13982
|
+
const tableRight = table.left + table.width;
|
|
13983
|
+
for (const drawing of page.skeDrawings.values()) {
|
|
13984
|
+
var _drawingOrigin$distR;
|
|
13985
|
+
const drawingOrigin = drawing.drawingOrigin;
|
|
13986
|
+
if (drawingOrigin == null || drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE || drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE || drawingOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
|
|
13987
|
+
const drawingTop = drawing.aTop;
|
|
13988
|
+
const drawingBottom = drawing.aTop + drawing.height;
|
|
13989
|
+
if (drawingTop >= tableBottom || drawingBottom <= tableTop) continue;
|
|
13990
|
+
const drawingRight = drawing.aLeft + drawing.width + ((_drawingOrigin$distR = drawingOrigin.distR) !== null && _drawingOrigin$distR !== void 0 ? _drawingOrigin$distR : 0);
|
|
13991
|
+
if (drawing.aLeft >= tableRight || drawingRight <= table.left) continue;
|
|
13992
|
+
if (drawingRight + table.width <= column.width) table.left = Math.max(table.left, drawingRight);
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13782
13995
|
function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section, skeTablesInParagraph, paragraphIndex, sectionBreakConfig, drawingAnchorTop) {
|
|
13783
13996
|
if (skeTablesInParagraph.length === 0) return false;
|
|
13784
13997
|
const firstUnPositionedTable = skeTablesInParagraph.find((table) => table.hasPositioned === false);
|
|
@@ -13788,6 +14001,7 @@ function _updateAndPositionTable(ctx, lineTop, lineHeight, page, column, section
|
|
|
13788
14001
|
if (firstUnPositionedTable.isSlideTable === false) switch (tableSource.textWrap) {
|
|
13789
14002
|
case TableTextWrapType.NONE:
|
|
13790
14003
|
table.top = lineTop;
|
|
14004
|
+
__avoidFlowAffectingDrawingsForTable(table, page, column);
|
|
13791
14005
|
break;
|
|
13792
14006
|
case TableTextWrapType.WRAP:
|
|
13793
14007
|
__updateWrapTablePosition(ctx, table, lineTop, lineHeight, column, paragraphIndex, drawingAnchorTop);
|
|
@@ -13841,15 +14055,47 @@ function _getCustomBlockIdsInLine(line) {
|
|
|
13841
14055
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) customBlockIds.push(glyph.drawingId);
|
|
13842
14056
|
return customBlockIds;
|
|
13843
14057
|
}
|
|
14058
|
+
function __isZeroWidthNonFlowFloatingAnchorLine(glyphGroup, paragraphNonInlineSkeDrawings) {
|
|
14059
|
+
return __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings).length > 0;
|
|
14060
|
+
}
|
|
14061
|
+
function __getZeroWidthNonFlowFloatingAnchorDrawings(glyphGroup, paragraphNonInlineSkeDrawings) {
|
|
14062
|
+
const drawings = [];
|
|
14063
|
+
for (const glyph of glyphGroup) {
|
|
14064
|
+
if (__isStructuralTerminatorGlyph(glyph)) continue;
|
|
14065
|
+
if (__isIgnorableZeroSizeGlyph(glyph)) continue;
|
|
14066
|
+
if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.width !== 0 || glyph.drawingId == null) return [];
|
|
14067
|
+
const drawing = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.get(glyph.drawingId);
|
|
14068
|
+
const drawingOrigin = drawing === null || drawing === void 0 ? void 0 : drawing.drawingOrigin;
|
|
14069
|
+
if (drawing == null || drawingOrigin == null) return [];
|
|
14070
|
+
if (drawingOrigin.layoutType !== PositionedObjectLayoutType.WRAP_NONE) return [];
|
|
14071
|
+
drawings.push(drawing);
|
|
14072
|
+
}
|
|
14073
|
+
return drawings;
|
|
14074
|
+
}
|
|
14075
|
+
function __isIgnorableZeroSizeGlyph(glyph) {
|
|
14076
|
+
return glyph.content === "" && glyph.drawingId == null && glyph.width === 0 && glyph.bBox.ba + glyph.bBox.bd === 0;
|
|
14077
|
+
}
|
|
14078
|
+
function __isStructuralTerminatorGlyph(glyph) {
|
|
14079
|
+
return glyph.streamType === DataStreamTreeTokenType.PARAGRAPH || glyph.streamType === DataStreamTreeTokenType.SECTION_BREAK || glyph.streamType === DataStreamTreeTokenType.DOCS_END;
|
|
14080
|
+
}
|
|
14081
|
+
function __hasFlowGlyph(glyphGroup) {
|
|
14082
|
+
return glyphGroup.some((glyph) => {
|
|
14083
|
+
if (__isStructuralTerminatorGlyph(glyph)) return false;
|
|
14084
|
+
if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK) return glyph.width !== 0;
|
|
14085
|
+
return glyph.content !== "" || glyph.width > 0 || glyph.bBox.ba + glyph.bBox.bd > 0;
|
|
14086
|
+
});
|
|
14087
|
+
}
|
|
13844
14088
|
function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
|
|
13845
14089
|
var _column$parent2;
|
|
13846
14090
|
const page = (_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : _column$parent2.parent;
|
|
13847
|
-
|
|
14091
|
+
const flowAffectingFloatObjects = floatObjects.filter((floatObject) => floatObject.behindDoc !== BooleanNumber.TRUE || floatObject.layoutType != null && floatObject.layoutType !== PositionedObjectLayoutType.WRAP_NONE);
|
|
14092
|
+
if (flowAffectingFloatObjects.length === 0 || page == null) return;
|
|
13848
14093
|
let needBreakLineIterator = false;
|
|
13849
|
-
for (const floatObject of
|
|
14094
|
+
for (const floatObject of flowAffectingFloatObjects) {
|
|
13850
14095
|
var _floatObjectCache$pag, _page$sections$;
|
|
13851
14096
|
const floatObjectCache = ctx.floatObjectsCache.get(floatObject.id);
|
|
13852
14097
|
if (floatObjectCache == null || floatObjectCache.page.segmentId !== page.segmentId) continue;
|
|
14098
|
+
if (floatObjectCache.count >= FLOAT_OBJECT_RELAYOUT_LIMIT) continue;
|
|
13853
14099
|
const cachePageStartParagraphIndex = (_floatObjectCache$pag = floatObjectCache.page.sections[0]) === null || _floatObjectCache$pag === void 0 || (_floatObjectCache$pag = _floatObjectCache$pag.columns[0]) === null || _floatObjectCache$pag === void 0 || (_floatObjectCache$pag = _floatObjectCache$pag.lines[0]) === null || _floatObjectCache$pag === void 0 ? void 0 : _floatObjectCache$pag.paragraphIndex;
|
|
13854
14100
|
const startIndex = (_page$sections$ = page.sections[0]) === null || _page$sections$ === void 0 || (_page$sections$ = _page$sections$.columns[0]) === null || _page$sections$ === void 0 || (_page$sections$ = _page$sections$.lines[0]) === null || _page$sections$ === void 0 ? void 0 : _page$sections$.paragraphIndex;
|
|
13855
14101
|
if (floatObjectCache.page && cachePageStartParagraphIndex && startIndex && cachePageStartParagraphIndex !== startIndex) {
|
|
@@ -13875,7 +14121,7 @@ function _reLayoutCheck(ctx, floatObjects, column, paragraphIndex) {
|
|
|
13875
14121
|
const { lineHeight, top } = line;
|
|
13876
14122
|
const { width: columnWidth, left: columnLeft } = column;
|
|
13877
14123
|
if (needBreakLineIterator) return;
|
|
13878
|
-
for (const floatObject of
|
|
14124
|
+
for (const floatObject of flowAffectingFloatObjects.values()) {
|
|
13879
14125
|
let targetObject = floatObject;
|
|
13880
14126
|
if (ctx.floatObjectsCache.has(floatObject.id)) {
|
|
13881
14127
|
const drawingCache = ctx.floatObjectsCache.get(floatObject.id);
|
|
@@ -13913,7 +14159,7 @@ function checkRelativeDrawingNeedRePosition(ctx, floatObject) {
|
|
|
13913
14159
|
if (drawingCache == null) return false;
|
|
13914
14160
|
if (relativeFrom === ObjectRelativeFromV.PARAGRAPH || relativeFrom === ObjectRelativeFromV.LINE) {
|
|
13915
14161
|
const { count, floatObject: prevObject } = drawingCache;
|
|
13916
|
-
if (count <
|
|
14162
|
+
if (count < FLOAT_OBJECT_RELAYOUT_LIMIT && Math.abs(floatObject.top - prevObject.top) > 5) return true;
|
|
13917
14163
|
}
|
|
13918
14164
|
return false;
|
|
13919
14165
|
}
|
|
@@ -13970,43 +14216,87 @@ function __getParagraphSpace(ctx, lineSpacing = 0, spaceAbove, spaceBelow, isPar
|
|
|
13970
14216
|
spaceBelowApply
|
|
13971
14217
|
};
|
|
13972
14218
|
}
|
|
13973
|
-
function
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
14219
|
+
function __getParagraphAnchorLeft(sectionBreakConfig, paragraphConfig, indentStart) {
|
|
14220
|
+
const { paragraphStyle = {} } = paragraphConfig;
|
|
14221
|
+
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
|
|
14222
|
+
const { gridType = GridType.LINES } = sectionBreakConfig;
|
|
14223
|
+
const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);
|
|
14224
|
+
const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);
|
|
14225
|
+
const paragraphAnchorLeft = getNumberUnitValue(indentStart, charSpaceApply);
|
|
14226
|
+
if (paragraphAnchorLeft > 0) return paragraphAnchorLeft;
|
|
14227
|
+
return getNumberUnitValue(paragraphConfig.docxFallbackAnchorLeft, charSpaceApply);
|
|
14228
|
+
}
|
|
14229
|
+
function getLineHeightMetrics(glyphLineHeight, paragraphLineGapDefault, linePitch, gridType, lineSpacing, spacingRule, snapToGrid, useWordStyleLineHeight = true, scaleAutoLineSpacingByGlyphHeight = true) {
|
|
14230
|
+
if (!useWordStyleLineHeight) {
|
|
14231
|
+
let paddingTop = paragraphLineGapDefault;
|
|
14232
|
+
let paddingBottom = paragraphLineGapDefault;
|
|
14233
|
+
if (gridType === GridType.DEFAULT || snapToGrid === BooleanNumber.FALSE) {
|
|
14234
|
+
if (spacingRule === SpacingRule.AUTO) return {
|
|
14235
|
+
paddingTop,
|
|
14236
|
+
paddingBottom,
|
|
14237
|
+
contentHeight: lineSpacing * glyphLineHeight,
|
|
14238
|
+
lineSpacingApply: glyphLineHeight
|
|
14239
|
+
};
|
|
14240
|
+
return {
|
|
14241
|
+
paddingTop,
|
|
14242
|
+
paddingBottom,
|
|
14243
|
+
contentHeight: Math.max(lineSpacing, glyphLineHeight),
|
|
14244
|
+
lineSpacingApply: lineSpacing
|
|
14245
|
+
};
|
|
14246
|
+
}
|
|
14247
|
+
let lineSpacingApply = 0;
|
|
14248
|
+
if (spacingRule === SpacingRule.AUTO) lineSpacingApply = lineSpacing * linePitch;
|
|
14249
|
+
else lineSpacingApply = lineSpacing;
|
|
14250
|
+
if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
|
|
14251
|
+
else lineSpacingApply = glyphLineHeight;
|
|
14252
|
+
return {
|
|
13978
14253
|
paddingTop,
|
|
13979
14254
|
paddingBottom,
|
|
13980
|
-
contentHeight:
|
|
13981
|
-
lineSpacingApply
|
|
14255
|
+
contentHeight: glyphLineHeight,
|
|
14256
|
+
lineSpacingApply
|
|
13982
14257
|
};
|
|
14258
|
+
}
|
|
14259
|
+
const usesDocumentGrid = spacingRule === SpacingRule.AUTO && snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT;
|
|
14260
|
+
if (spacingRule === SpacingRule.AUTO) {
|
|
14261
|
+
const lineSpacingApply = usesDocumentGrid ? lineSpacing * linePitch : scaleAutoLineSpacingByGlyphHeight ? lineSpacing * glyphLineHeight : glyphLineHeight;
|
|
14262
|
+
const padding = (lineSpacingApply - glyphLineHeight) / 2;
|
|
13983
14263
|
return {
|
|
13984
|
-
paddingTop,
|
|
13985
|
-
paddingBottom,
|
|
13986
|
-
contentHeight:
|
|
13987
|
-
lineSpacingApply
|
|
14264
|
+
paddingTop: padding,
|
|
14265
|
+
paddingBottom: padding,
|
|
14266
|
+
contentHeight: glyphLineHeight,
|
|
14267
|
+
lineSpacingApply
|
|
14268
|
+
};
|
|
14269
|
+
}
|
|
14270
|
+
if (spacingRule === SpacingRule.AT_LEAST) {
|
|
14271
|
+
const lineSpacingApply = Math.max(lineSpacing, glyphLineHeight);
|
|
14272
|
+
const padding = (lineSpacingApply - glyphLineHeight) / 2;
|
|
14273
|
+
return {
|
|
14274
|
+
paddingTop: padding,
|
|
14275
|
+
paddingBottom: padding,
|
|
14276
|
+
contentHeight: glyphLineHeight,
|
|
14277
|
+
lineSpacingApply
|
|
13988
14278
|
};
|
|
13989
14279
|
}
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
else lineSpacingApply = lineSpacing;
|
|
13993
|
-
if (glyphLineHeight + paragraphLineGapDefault * 2 < lineSpacingApply) paddingTop = paddingBottom = (lineSpacingApply - glyphLineHeight) / 2;
|
|
13994
|
-
else lineSpacingApply = glyphLineHeight;
|
|
14280
|
+
const exactLineSpacingApply = snapToGrid === BooleanNumber.TRUE && gridType !== GridType.DEFAULT ? Math.max(lineSpacing, linePitch) : lineSpacing;
|
|
14281
|
+
const exactPadding = (exactLineSpacingApply - glyphLineHeight) / 2;
|
|
13995
14282
|
return {
|
|
13996
|
-
paddingTop,
|
|
13997
|
-
paddingBottom,
|
|
14283
|
+
paddingTop: exactPadding,
|
|
14284
|
+
paddingBottom: exactPadding,
|
|
13998
14285
|
contentHeight: glyphLineHeight,
|
|
13999
|
-
lineSpacingApply
|
|
14286
|
+
lineSpacingApply: exactLineSpacingApply
|
|
14000
14287
|
};
|
|
14001
14288
|
}
|
|
14002
|
-
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop) {
|
|
14003
|
-
var _line$parent;
|
|
14289
|
+
function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnchorTop, paragraphNonInlineSkeDrawings) {
|
|
14290
|
+
var _line$parent, _section$top;
|
|
14004
14291
|
const column = line.parent;
|
|
14292
|
+
const section = column === null || column === void 0 ? void 0 : column.parent;
|
|
14005
14293
|
const page = line === null || line === void 0 || (_line$parent = line.parent) === null || _line$parent === void 0 || (_line$parent = _line$parent.parent) === null || _line$parent === void 0 ? void 0 : _line$parent.parent;
|
|
14006
14294
|
if (page == null || column == null) return;
|
|
14007
14295
|
const isPageBreak = __checkPageBreak(column);
|
|
14008
14296
|
const drawings = /* @__PURE__ */ new Map();
|
|
14009
14297
|
const { top, lineHeight, marginBottom = 0 } = line;
|
|
14298
|
+
const sectionTop = (_section$top = section === null || section === void 0 ? void 0 : section.top) !== null && _section$top !== void 0 ? _section$top : 0;
|
|
14299
|
+
const lineTop = sectionTop + top;
|
|
14010
14300
|
for (const divide of line.divides) for (const glyph of divide.glyphGroup) if (glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.width !== 0) {
|
|
14011
14301
|
const { drawingId } = glyph;
|
|
14012
14302
|
if (drawingId == null) continue;
|
|
@@ -14017,21 +14307,37 @@ function updateInlineDrawingPosition(line, paragraphInlineSkeDrawings, blockAnch
|
|
|
14017
14307
|
const { size, angle } = docTransform;
|
|
14018
14308
|
const { width = 0, height = 0 } = size;
|
|
14019
14309
|
const glyphHeight = glyph.bBox.bd + glyph.bBox.ba;
|
|
14020
|
-
drawing.aLeft = divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
|
|
14021
|
-
|
|
14310
|
+
drawing.aLeft = column.left + divide.left + divide.paddingLeft + glyph.left + .5 * glyph.width - .5 * width || 0;
|
|
14311
|
+
if (glyph.width > divide.width) {
|
|
14312
|
+
var _paragraphNonInlineSk;
|
|
14313
|
+
for (const positionedDrawing of (_paragraphNonInlineSk = paragraphNonInlineSkeDrawings === null || paragraphNonInlineSkeDrawings === void 0 ? void 0 : paragraphNonInlineSkeDrawings.values()) !== null && _paragraphNonInlineSk !== void 0 ? _paragraphNonInlineSk : []) {
|
|
14314
|
+
const positionedOrigin = positionedDrawing.drawingOrigin;
|
|
14315
|
+
if (positionedOrigin == null || positionedOrigin.layoutType === PositionedObjectLayoutType.INLINE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_NONE || positionedOrigin.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) continue;
|
|
14316
|
+
const positionedBottom = positionedDrawing.aTop + positionedDrawing.height;
|
|
14317
|
+
const lineBottom = lineTop + lineHeight;
|
|
14318
|
+
if (positionedDrawing.aTop >= lineBottom || positionedBottom <= lineTop) continue;
|
|
14319
|
+
const positionedRight = positionedDrawing.aLeft + positionedDrawing.width;
|
|
14320
|
+
const drawingRight = drawing.aLeft + width;
|
|
14321
|
+
if (positionedDrawing.aLeft < drawingRight && positionedRight > drawing.aLeft) {
|
|
14322
|
+
var _positionedOrigin$dis;
|
|
14323
|
+
drawing.aLeft = Math.max(drawing.aLeft, positionedDrawing.aLeft + positionedDrawing.width + ((_positionedOrigin$dis = positionedOrigin.distR) !== null && _positionedOrigin$dis !== void 0 ? _positionedOrigin$dis : 0));
|
|
14324
|
+
}
|
|
14325
|
+
}
|
|
14326
|
+
}
|
|
14327
|
+
drawing.aTop = lineTop + lineHeight - .5 * glyphHeight - .5 * height - marginBottom;
|
|
14022
14328
|
drawing.width = width;
|
|
14023
14329
|
drawing.height = height;
|
|
14024
14330
|
drawing.angle = angle;
|
|
14025
14331
|
drawing.isPageBreak = isPageBreak;
|
|
14026
|
-
drawing.lineTop =
|
|
14332
|
+
drawing.lineTop = lineTop;
|
|
14027
14333
|
drawing.columnLeft = column.left;
|
|
14028
|
-
drawing.blockAnchorTop = blockAnchorTop
|
|
14334
|
+
drawing.blockAnchorTop = blockAnchorTop == null ? lineTop : sectionTop + blockAnchorTop;
|
|
14029
14335
|
drawing.lineHeight = line.lineHeight;
|
|
14030
14336
|
drawings.set(drawing.drawingId, drawing);
|
|
14031
14337
|
}
|
|
14032
14338
|
page.skeDrawings = new Map([...page.skeDrawings, ...drawings]);
|
|
14033
14339
|
}
|
|
14034
|
-
function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = []) {
|
|
14340
|
+
function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShapedText, blockAnchorTop, needPositionDrawings = [], blockAnchorLeft = 0) {
|
|
14035
14341
|
var _column$parent3;
|
|
14036
14342
|
const page = (_column$parent3 = column.parent) === null || _column$parent3 === void 0 ? void 0 : _column$parent3.parent;
|
|
14037
14343
|
if (page == null || needPositionDrawings.length === 0) return;
|
|
@@ -14045,7 +14351,12 @@ function __getDrawingPosition(lineTop, lineHeight, column, isParagraphFirstShape
|
|
|
14045
14351
|
const { docTransform } = drawingOrigin;
|
|
14046
14352
|
const { positionH, positionV, size, angle } = docTransform;
|
|
14047
14353
|
const { width = 0, height = 0 } = size;
|
|
14048
|
-
|
|
14354
|
+
let aLeft = (_getPositionHorizon2 = getPositionHorizon(positionH, column, page, width, isPageBreak)) !== null && _getPositionHorizon2 !== void 0 ? _getPositionHorizon2 : 0;
|
|
14355
|
+
if (positionH.relativeFrom === ObjectRelativeFromH.COLUMN && blockAnchorLeft > 0) {
|
|
14356
|
+
const renderedColumnOrigin = isPageBreak ? 0 : column.left || page.marginLeft;
|
|
14357
|
+
aLeft += blockAnchorLeft - renderedColumnOrigin;
|
|
14358
|
+
}
|
|
14359
|
+
drawing.aLeft = aLeft;
|
|
14049
14360
|
drawing.aTop = (_getPositionVertical2 = getPositionVertical(positionV, page, lineTop, lineHeight, height, blockAnchorTop, isPageBreak)) !== null && _getPositionVertical2 !== void 0 ? _getPositionVertical2 : 0;
|
|
14050
14361
|
drawing.width = width;
|
|
14051
14362
|
drawing.height = height;
|
|
@@ -14114,7 +14425,7 @@ function __getGlyphGroupByLine({ divides }) {
|
|
|
14114
14425
|
return divides.flatMap((divide) => divide.glyphGroup);
|
|
14115
14426
|
}
|
|
14116
14427
|
function __isNullLine(line) {
|
|
14117
|
-
return
|
|
14428
|
+
return __getGlyphGroupByLine(line).every((glyph) => !glyph.content && !glyph.drawingId);
|
|
14118
14429
|
}
|
|
14119
14430
|
|
|
14120
14431
|
//#endregion
|
|
@@ -14197,6 +14508,7 @@ function isColumnFull(page) {
|
|
|
14197
14508
|
function getNumberUnitValue(unitValue, benchMark) {
|
|
14198
14509
|
if (!unitValue) return 0;
|
|
14199
14510
|
const { v: value, u: unit } = unitValue;
|
|
14511
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 0;
|
|
14200
14512
|
if (!unit) return value;
|
|
14201
14513
|
if (unit === NumberUnitType.PIXEL) return value;
|
|
14202
14514
|
return value * benchMark;
|
|
@@ -14211,18 +14523,22 @@ function validationGrid(gridType = GridType.LINES, snapToGrid = BooleanNumber.FA
|
|
|
14211
14523
|
return snapToGrid === BooleanNumber.TRUE && (gridType === GridType.LINES_AND_CHARS || gridType === GridType.SNAP_TO_CHARS);
|
|
14212
14524
|
}
|
|
14213
14525
|
function getLineHeightConfig(sectionBreakConfig, paragraphConfig) {
|
|
14214
|
-
const { paragraphStyle = {} } = paragraphConfig;
|
|
14526
|
+
const { paragraphStyle = {}, useWordStyleLineHeight = false } = paragraphConfig;
|
|
14215
14527
|
const { linePitch = 15.6, gridType = GridType.LINES, paragraphLineGapDefault = 0 } = sectionBreakConfig;
|
|
14216
|
-
const
|
|
14528
|
+
const hasDocumentGrid = gridType === GridType.LINES_AND_CHARS || gridType === GridType.SNAP_TO_CHARS;
|
|
14529
|
+
const defaultSnapToGrid = useWordStyleLineHeight && !hasDocumentGrid ? BooleanNumber.FALSE : BooleanNumber.TRUE;
|
|
14530
|
+
const { lineSpacing = 0, spacingRule = SpacingRule.AUTO, snapToGrid = defaultSnapToGrid } = paragraphStyle;
|
|
14217
14531
|
let lineSpacingApply = lineSpacing;
|
|
14218
|
-
if (
|
|
14532
|
+
if (useWordStyleLineHeight && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
|
|
14533
|
+
else if (!useWordStyleLineHeight && (gridType === GridType.LINES || gridType === GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
|
|
14219
14534
|
return {
|
|
14220
14535
|
paragraphLineGapDefault,
|
|
14221
14536
|
linePitch,
|
|
14222
14537
|
gridType,
|
|
14223
14538
|
lineSpacing: lineSpacingApply,
|
|
14224
14539
|
spacingRule,
|
|
14225
|
-
snapToGrid
|
|
14540
|
+
snapToGrid,
|
|
14541
|
+
useWordStyleLineHeight
|
|
14226
14542
|
};
|
|
14227
14543
|
}
|
|
14228
14544
|
function getCharSpaceConfig(sectionBreakConfig, paragraphConfig) {
|
|
@@ -14329,13 +14645,16 @@ function updateBlockIndex(pages, start = -1) {
|
|
|
14329
14645
|
}
|
|
14330
14646
|
function updateInlineDrawingCoordsAndBorder(ctx, pages) {
|
|
14331
14647
|
lineIterator(pages, (line, _, __, page) => {
|
|
14332
|
-
var _ctx$paragraphConfigC, _ctx$skeletonResource;
|
|
14648
|
+
var _ctx$paragraphConfigC, _ctx$skeletonResource, _paragraphStyle$shadi;
|
|
14333
14649
|
const { segmentId } = page;
|
|
14334
14650
|
const paragraphConfig = (_ctx$paragraphConfigC = ctx.paragraphConfigCache.get(segmentId)) === null || _ctx$paragraphConfigC === void 0 ? void 0 : _ctx$paragraphConfigC.get(line.paragraphIndex);
|
|
14335
14651
|
const affectInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphInlineSkeDrawings;
|
|
14652
|
+
const affectNonInlineDrawings = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphNonInlineSkeDrawings;
|
|
14336
14653
|
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);
|
|
14337
|
-
if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top);
|
|
14654
|
+
if (affectInlineDrawings && affectInlineDrawings.size > 0) updateInlineDrawingPosition(line, affectInlineDrawings, drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.top, affectNonInlineDrawings);
|
|
14338
14655
|
const paragraphStyle = paragraphConfig === null || paragraphConfig === void 0 ? void 0 : paragraphConfig.paragraphStyle;
|
|
14656
|
+
const paragraphBackgroundColor = paragraphStyle === null || paragraphStyle === void 0 || (_paragraphStyle$shadi = paragraphStyle.shading) === null || _paragraphStyle$shadi === void 0 ? void 0 : _paragraphStyle$shadi.backgroundColor;
|
|
14657
|
+
if (paragraphBackgroundColor) line.backgroundColor = paragraphBackgroundColor;
|
|
14339
14658
|
if (line.divides.length > 0) {
|
|
14340
14659
|
const lastDivide = line.divides[line.divides.length - 1];
|
|
14341
14660
|
const lastGlyph = lastDivide.glyphGroup[lastDivide.glyphGroup.length - 1];
|
|
@@ -14405,14 +14724,12 @@ function getPositionHorizon(positionH, column, page, objectWidth, isPageBreak =
|
|
|
14405
14724
|
return absoluteLeft;
|
|
14406
14725
|
}
|
|
14407
14726
|
}
|
|
14408
|
-
else if (posOffset) {
|
|
14409
|
-
const { pageWidth, marginLeft, marginRight } = page;
|
|
14410
|
-
const boundaryRight = pageWidth - marginRight;
|
|
14727
|
+
else if (posOffset != null) {
|
|
14411
14728
|
let absoluteLeft = 0;
|
|
14729
|
+
const { marginLeft } = page;
|
|
14412
14730
|
if (relativeFrom === ObjectRelativeFromH.COLUMN) absoluteLeft = (isPageBreak ? 0 : (column === null || column === void 0 ? void 0 : column.left) || 0) + posOffset;
|
|
14413
14731
|
else if (relativeFrom === ObjectRelativeFromH.LEFT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.MARGIN) absoluteLeft = posOffset + marginLeft;
|
|
14414
14732
|
else if (relativeFrom === ObjectRelativeFromH.RIGHT_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.INSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.OUTSIDE_MARGIN) {} else if (relativeFrom === ObjectRelativeFromH.PAGE) absoluteLeft = posOffset;
|
|
14415
|
-
if (absoluteLeft + objectWidth > boundaryRight) absoluteLeft = boundaryRight - objectWidth;
|
|
14416
14733
|
return absoluteLeft;
|
|
14417
14734
|
} else if (percent) {
|
|
14418
14735
|
const { pageWidth, marginLeft, marginRight } = page;
|
|
@@ -14474,9 +14791,9 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
|
|
|
14474
14791
|
};
|
|
14475
14792
|
}
|
|
14476
14793
|
function getBulletParagraphTextStyle(bullet, viewModel) {
|
|
14477
|
-
var _lists$listType
|
|
14794
|
+
var _lists$listType;
|
|
14478
14795
|
const { listType } = bullet;
|
|
14479
|
-
return (_lists$listType
|
|
14796
|
+
return (_lists$listType = viewModel.getDataModel().getBulletPresetList()[listType]) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType.nestingLevel) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType[0]) === null || _lists$listType === void 0 || (_lists$listType = _lists$listType.paragraphProperties) === null || _lists$listType === void 0 ? void 0 : _lists$listType.textStyle;
|
|
14480
14797
|
}
|
|
14481
14798
|
const DEFAULT_TEXT_RUN = {
|
|
14482
14799
|
ts: {},
|
|
@@ -14484,6 +14801,7 @@ const DEFAULT_TEXT_RUN = {
|
|
|
14484
14801
|
ed: 0
|
|
14485
14802
|
};
|
|
14486
14803
|
function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
|
|
14804
|
+
var _sectionBreakConfig$d;
|
|
14487
14805
|
const { gridType = GridType.LINES, charSpace = 0, documentTextStyle = {}, pageSize = {
|
|
14488
14806
|
width: Number.POSITIVE_INFINITY,
|
|
14489
14807
|
height: Number.POSITIVE_INFINITY
|
|
@@ -14515,16 +14833,20 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
|
|
|
14515
14833
|
...customRangeStyle,
|
|
14516
14834
|
...bulletTextStyle
|
|
14517
14835
|
};
|
|
14836
|
+
const fontStyle = getFontStyleString(textStyle);
|
|
14837
|
+
const mixTextStyle = {
|
|
14838
|
+
...documentTextStyle,
|
|
14839
|
+
...textStyle
|
|
14840
|
+
};
|
|
14841
|
+
const pageWidth = pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight;
|
|
14518
14842
|
const result = {
|
|
14519
|
-
fontStyle
|
|
14520
|
-
textStyle:
|
|
14521
|
-
...documentTextStyle,
|
|
14522
|
-
...textStyle
|
|
14523
|
-
},
|
|
14843
|
+
fontStyle,
|
|
14844
|
+
textStyle: mixTextStyle,
|
|
14524
14845
|
charSpace,
|
|
14525
14846
|
gridType,
|
|
14526
14847
|
snapToGrid,
|
|
14527
|
-
|
|
14848
|
+
documentCompatibilityPolicy: (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy(),
|
|
14849
|
+
pageWidth
|
|
14528
14850
|
};
|
|
14529
14851
|
if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
|
|
14530
14852
|
return result;
|
|
@@ -14659,17 +14981,6 @@ function resetContext(ctx) {
|
|
|
14659
14981
|
ctx.isDirty = false;
|
|
14660
14982
|
(_ctx$skeleton$drawing = ctx.skeleton.drawingAnchor) === null || _ctx$skeleton$drawing === void 0 || _ctx$skeleton$drawing.clear();
|
|
14661
14983
|
}
|
|
14662
|
-
function mergeByV(object, originObject, type) {
|
|
14663
|
-
const mergeIterator = (obj, originObj, key) => {
|
|
14664
|
-
if (key !== "v") if (typeof originObj === "object") return mergeWith(obj, originObj, mergeIterator);
|
|
14665
|
-
else return originObj !== null && originObj !== void 0 ? originObj : obj;
|
|
14666
|
-
if (typeof originObj === "number") {
|
|
14667
|
-
if (typeof obj === "number") return type === "max" ? Math.max(originObj, obj) : Math.min(originObj, obj);
|
|
14668
|
-
}
|
|
14669
|
-
return originObj !== null && originObj !== void 0 ? originObj : obj;
|
|
14670
|
-
};
|
|
14671
|
-
return mergeWith(object, originObject, mergeIterator);
|
|
14672
|
-
}
|
|
14673
14984
|
function getPageFromPath(skeletonData, path) {
|
|
14674
14985
|
const pathCopy = [...path];
|
|
14675
14986
|
let page = null;
|
|
@@ -14735,7 +15046,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
14735
15046
|
header = (_skeHeaders$get2 = skeHeaders.get(headerId)) === null || _skeHeaders$get2 === void 0 ? void 0 : _skeHeaders$get2.get(pageWidth);
|
|
14736
15047
|
} else if (headerTreeMap && headerTreeMap.has(headerId)) {
|
|
14737
15048
|
header = _createSkeletonHeaderFooter(ctx, headerTreeMap.get(headerId), sectionBreakConfig, skeletonResourceReference, headerId, true);
|
|
14738
|
-
skeHeaders.set(headerId, new Map([[pageWidth, header]]));
|
|
15049
|
+
skeHeaders.set(headerId, /* @__PURE__ */ new Map([[pageWidth, header]]));
|
|
14739
15050
|
}
|
|
14740
15051
|
page.headerId = headerId;
|
|
14741
15052
|
}
|
|
@@ -14746,7 +15057,7 @@ function createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference,
|
|
|
14746
15057
|
footer = (_skeFooters$get2 = skeFooters.get(footerId)) === null || _skeFooters$get2 === void 0 ? void 0 : _skeFooters$get2.get(pageWidth);
|
|
14747
15058
|
} else if (footerTreeMap && footerTreeMap.has(footerId)) {
|
|
14748
15059
|
footer = _createSkeletonHeaderFooter(ctx, footerTreeMap.get(footerId), sectionBreakConfig, skeletonResourceReference, footerId, false);
|
|
14749
|
-
skeFooters.set(footerId, new Map([[pageWidth, footer]]));
|
|
15060
|
+
skeFooters.set(footerId, /* @__PURE__ */ new Map([[pageWidth, footer]]));
|
|
14750
15061
|
}
|
|
14751
15062
|
page.footerId = footerId;
|
|
14752
15063
|
}
|
|
@@ -14841,9 +15152,22 @@ function createNullCellPage(ctx, sectionBreakConfig, tableConfig, row, col, avai
|
|
|
14841
15152
|
const { skeletonResourceReference } = ctx;
|
|
14842
15153
|
const { cellMargin, tableRows, tableColumns, tableId } = tableConfig;
|
|
14843
15154
|
const cellConfig = tableRows[row].tableCells[col];
|
|
14844
|
-
|
|
15155
|
+
let { start = { v: 10 }, end = { v: 10 }, top = { v: 5 }, bottom = { v: 5 } } = (_ref = (_cellConfig$margin = cellConfig.margin) !== null && _cellConfig$margin !== void 0 ? _cellConfig$margin : cellMargin) !== null && _ref !== void 0 ? _ref : {};
|
|
14845
15156
|
const columnSpan = Math.max(1, (_cellConfig$columnSpa = cellConfig.columnSpan) !== null && _cellConfig$columnSpa !== void 0 ? _cellConfig$columnSpa : 1);
|
|
14846
15157
|
const pageWidth = tableColumns.slice(col, col + columnSpan).reduce((sum, column) => sum + column.size.width.v, 0);
|
|
15158
|
+
if (start.v + end.v >= pageWidth) {
|
|
15159
|
+
const marginWidth = start.v + end.v;
|
|
15160
|
+
const availableMarginWidth = Math.max(0, pageWidth - 1);
|
|
15161
|
+
const startRatio = marginWidth > 0 ? start.v / marginWidth : .5;
|
|
15162
|
+
start = {
|
|
15163
|
+
...start,
|
|
15164
|
+
v: availableMarginWidth * startRatio
|
|
15165
|
+
};
|
|
15166
|
+
end = {
|
|
15167
|
+
...end,
|
|
15168
|
+
v: availableMarginWidth - start.v
|
|
15169
|
+
};
|
|
15170
|
+
}
|
|
14847
15171
|
const pageHeight = maxCellPageHeight;
|
|
14848
15172
|
const cellSectionBreakConfig = {
|
|
14849
15173
|
lists,
|
|
@@ -14911,11 +15235,8 @@ function applyTrailingCellBlockRangeSpaceBelow(pages, body, cellEndIndex) {
|
|
|
14911
15235
|
page.height += lastLine.spaceBelowApply || trailingBlockRangeSpace;
|
|
14912
15236
|
}
|
|
14913
15237
|
}
|
|
14914
|
-
function _getVerticalMargin(marginTB,
|
|
14915
|
-
|
|
14916
|
-
const HeaderFooterPageHeight = headerOrFooter.height + headerOrFooter.marginTop + headerOrFooter.marginBottom;
|
|
14917
|
-
const maxMargin = getHeaderFooterMaxHeight(pageHeight);
|
|
14918
|
-
return Math.min(maxMargin, Math.max(marginTB, HeaderFooterPageHeight));
|
|
15238
|
+
function _getVerticalMargin(marginTB, _headerOrFooter, _pageHeight) {
|
|
15239
|
+
return marginTB;
|
|
14919
15240
|
}
|
|
14920
15241
|
|
|
14921
15242
|
//#endregion
|
|
@@ -15028,7 +15349,26 @@ function adjustGlyphsInDivide(divide, justificationRatio, extraJustification) {
|
|
|
15028
15349
|
* Therefore, multiple calculations are performed, which may impact performance.
|
|
15029
15350
|
* Needs optimization for efficiency.
|
|
15030
15351
|
*/
|
|
15031
|
-
function
|
|
15352
|
+
function shouldAllowOverflowHorizontalOffset(sectionBreakConfig) {
|
|
15353
|
+
var _sectionBreakConfig$r;
|
|
15354
|
+
return ((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.wrapStrategy) === WrapStrategy.OVERFLOW;
|
|
15355
|
+
}
|
|
15356
|
+
function getGlyphGroupInkBounds(divide) {
|
|
15357
|
+
if (divide.glyphGroup.length === 0) return null;
|
|
15358
|
+
let left = Infinity;
|
|
15359
|
+
let right = -Infinity;
|
|
15360
|
+
for (const glyph of divide.glyphGroup) {
|
|
15361
|
+
const glyphLeft = glyph.left + glyph.xOffset;
|
|
15362
|
+
left = Math.min(left, glyphLeft);
|
|
15363
|
+
right = Math.max(right, glyphLeft + glyph.bBox.width);
|
|
15364
|
+
}
|
|
15365
|
+
if (!Number.isFinite(left) || !Number.isFinite(right)) return null;
|
|
15366
|
+
return {
|
|
15367
|
+
left,
|
|
15368
|
+
right
|
|
15369
|
+
};
|
|
15370
|
+
}
|
|
15371
|
+
function horizontalAlignHandler(line, horizontalAlign, allowOverflowHorizontalOffset = false) {
|
|
15032
15372
|
const { divides } = line;
|
|
15033
15373
|
for (let i = 0; i < divides.length; i++) {
|
|
15034
15374
|
const divide = divides[i];
|
|
@@ -15067,9 +15407,12 @@ function horizontalAlignHandler(line, horizontalAlign) {
|
|
|
15067
15407
|
divide.glyphGroupWidth = glyphGroupWidth;
|
|
15068
15408
|
}
|
|
15069
15409
|
}
|
|
15070
|
-
|
|
15410
|
+
const inkBounds = allowOverflowHorizontalOffset ? getGlyphGroupInkBounds(divide) : null;
|
|
15411
|
+
if (horizontalAlign === HorizontalAlign.CENTER && inkBounds) divide.paddingLeft = width / 2 - (inkBounds.left + inkBounds.right) / 2;
|
|
15412
|
+
else if (horizontalAlign === HorizontalAlign.RIGHT && inkBounds) divide.paddingLeft = width - inkBounds.right;
|
|
15413
|
+
else if (horizontalAlign === HorizontalAlign.CENTER) divide.paddingLeft = (width - glyphGroupWidth) / 2;
|
|
15071
15414
|
else if (horizontalAlign === HorizontalAlign.RIGHT) divide.paddingLeft = width - glyphGroupWidth;
|
|
15072
|
-
divide.paddingLeft = Math.max(divide.paddingLeft, 0);
|
|
15415
|
+
if (!allowOverflowHorizontalOffset) divide.paddingLeft = Math.max(divide.paddingLeft, 0);
|
|
15073
15416
|
}
|
|
15074
15417
|
}
|
|
15075
15418
|
function restoreLastCJKGlyphWidth(line) {
|
|
@@ -15114,7 +15457,10 @@ function addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, parag
|
|
|
15114
15457
|
}
|
|
15115
15458
|
function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
|
|
15116
15459
|
const { endIndex } = paragraphNode;
|
|
15117
|
-
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
15460
|
+
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
15461
|
+
startIndex: 0,
|
|
15462
|
+
paragraphId: "para_render_fallback"
|
|
15463
|
+
};
|
|
15118
15464
|
lineIterator(pages, (line) => {
|
|
15119
15465
|
if (line.paragraphIndex !== paragraph.startIndex) return;
|
|
15120
15466
|
const { paragraphStyle = {} } = paragraph;
|
|
@@ -15122,7 +15468,7 @@ function lineAdjustment(pages, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
15122
15468
|
shrinkStartAndEndCJKPunctuation(line);
|
|
15123
15469
|
restoreLastCJKGlyphWidth(line);
|
|
15124
15470
|
addHyphenDash(line, viewModel, paragraphNode, sectionBreakConfig, paragraphStyle);
|
|
15125
|
-
horizontalAlignHandler(line, horizontalAlign);
|
|
15471
|
+
horizontalAlignHandler(line, horizontalAlign, shouldAllowOverflowHorizontalOffset(sectionBreakConfig));
|
|
15126
15472
|
});
|
|
15127
15473
|
}
|
|
15128
15474
|
|
|
@@ -15317,11 +15663,43 @@ function ___getLevelAndSuffix(levelAndSuffixPre) {
|
|
|
15317
15663
|
|
|
15318
15664
|
//#endregion
|
|
15319
15665
|
//#region src/components/docs/layout/block/paragraph/linebreaking.ts
|
|
15320
|
-
const BLOCK_LAYOUT_OUTER_SPACING_MAP = new Map([
|
|
15321
|
-
[
|
|
15322
|
-
[
|
|
15323
|
-
[
|
|
15666
|
+
const BLOCK_LAYOUT_OUTER_SPACING_MAP = /* @__PURE__ */ new Map([
|
|
15667
|
+
[DocumentBlockRangeType.CALLOUT, 34],
|
|
15668
|
+
[DocumentBlockRangeType.CODE, 32],
|
|
15669
|
+
[DocumentBlockRangeType.QUOTE, 24]
|
|
15324
15670
|
]);
|
|
15671
|
+
function _endsWithToken(text, glyphs, token) {
|
|
15672
|
+
var _glyphs, _glyphs2;
|
|
15673
|
+
return text.endsWith(token) || ((_glyphs = glyphs[glyphs.length - 1]) === null || _glyphs === void 0 ? void 0 : _glyphs.raw) === token || ((_glyphs2 = glyphs[glyphs.length - 1]) === null || _glyphs2 === void 0 ? void 0 : _glyphs2.streamType) === token;
|
|
15674
|
+
}
|
|
15675
|
+
function _isMarkedDocxColumnBreak(viewModel, absoluteIndex) {
|
|
15676
|
+
const customRange = viewModel.getCustomRange(absoluteIndex);
|
|
15677
|
+
const properties = customRange === null || customRange === void 0 ? void 0 : customRange.properties;
|
|
15678
|
+
return (properties === null || properties === void 0 ? void 0 : properties.docxBreakType) === "column";
|
|
15679
|
+
}
|
|
15680
|
+
function _glyphCount(glyphs) {
|
|
15681
|
+
return glyphs.reduce((count, glyph) => count + glyph.count, 0);
|
|
15682
|
+
}
|
|
15683
|
+
function _hasOnlyCustomBlockGlyphs(glyphs) {
|
|
15684
|
+
return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK);
|
|
15685
|
+
}
|
|
15686
|
+
function _mergeAdjacentCustomBlockShapedTexts(shapedTextList) {
|
|
15687
|
+
const mergedShapedTextList = [];
|
|
15688
|
+
for (const shapedText of shapedTextList) {
|
|
15689
|
+
const lastShapedText = mergedShapedTextList[mergedShapedTextList.length - 1];
|
|
15690
|
+
if (lastShapedText && _hasOnlyCustomBlockGlyphs(lastShapedText.glyphs) && _hasOnlyCustomBlockGlyphs(shapedText.glyphs)) {
|
|
15691
|
+
lastShapedText.text += shapedText.text;
|
|
15692
|
+
lastShapedText.glyphs.push(...shapedText.glyphs);
|
|
15693
|
+
lastShapedText.breakPointType = shapedText.breakPointType;
|
|
15694
|
+
continue;
|
|
15695
|
+
}
|
|
15696
|
+
mergedShapedTextList.push({
|
|
15697
|
+
...shapedText,
|
|
15698
|
+
glyphs: [...shapedText.glyphs]
|
|
15699
|
+
});
|
|
15700
|
+
}
|
|
15701
|
+
return mergedShapedTextList;
|
|
15702
|
+
}
|
|
15325
15703
|
function _getListLevelAncestors(bullet, listLevel) {
|
|
15326
15704
|
if (!bullet || !listLevel) return;
|
|
15327
15705
|
const { listId, nestingLevel } = bullet;
|
|
@@ -15392,12 +15770,23 @@ function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, s
|
|
|
15392
15770
|
if ((lastParagraph === null || lastParagraph === void 0 ? void 0 : lastParagraph.startIndex) === paragraph.startIndex && !_hasNextAdjacentLayoutBlockRange(blockRanges, blockRange)) _withMinSpacing(style, "spaceBelow", outerSpacing);
|
|
15393
15771
|
return style;
|
|
15394
15772
|
}
|
|
15395
|
-
function
|
|
15396
|
-
var
|
|
15397
|
-
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15773
|
+
function _isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings) {
|
|
15774
|
+
var _paragraphNode$blocks, _paragraphNode$conten;
|
|
15775
|
+
if (!((_paragraphNode$blocks = paragraphNode.blocks) === null || _paragraphNode$blocks === void 0 ? void 0 : _paragraphNode$blocks.length)) return false;
|
|
15776
|
+
if (!((_paragraphNode$conten = paragraphNode.content) !== null && _paragraphNode$conten !== void 0 ? _paragraphNode$conten : "").split("").every((char) => char === DataStreamTreeTokenType.CUSTOM_BLOCK || char === DataStreamTreeTokenType.PARAGRAPH || char === DataStreamTreeTokenType.SECTION_BREAK)) return false;
|
|
15777
|
+
return paragraphNode.blocks.every((charIndex) => {
|
|
15778
|
+
const customBlock = viewModel.getCustomBlock(charIndex);
|
|
15779
|
+
const drawing = customBlock == null ? null : drawings[customBlock.blockId];
|
|
15780
|
+
return drawing != null && drawing.layoutType !== PositionedObjectLayoutType.INLINE;
|
|
15781
|
+
});
|
|
15782
|
+
}
|
|
15783
|
+
function _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocument) {
|
|
15784
|
+
var _paragraph$paragraphS, _paragraph$paragraphS2, _viewModel$getBody$pa, _viewModel$getBody, _paragraphs$0$paragra, _paragraphs$, _paragraphs$0$paragra2;
|
|
15785
|
+
if (!isTraditionalDocument) return;
|
|
15786
|
+
if (((_paragraph$paragraphS = (_paragraph$paragraphS2 = paragraph.paragraphStyle) === null || _paragraph$paragraphS2 === void 0 || (_paragraph$paragraphS2 = _paragraph$paragraphS2.indentStart) === null || _paragraph$paragraphS2 === void 0 ? void 0 : _paragraph$paragraphS2.v) !== null && _paragraph$paragraphS !== void 0 ? _paragraph$paragraphS : 0) > 0) return;
|
|
15787
|
+
if (!_isOnlyFloatingCustomBlockParagraph(viewModel, paragraphNode, drawings)) return;
|
|
15788
|
+
const paragraphs = [...(_viewModel$getBody$pa = (_viewModel$getBody = viewModel.getBody) === null || _viewModel$getBody === void 0 || (_viewModel$getBody = _viewModel$getBody.call(viewModel)) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.paragraphs) !== null && _viewModel$getBody$pa !== void 0 ? _viewModel$getBody$pa : []].filter((item) => item.startIndex > paragraph.startIndex).sort((left, right) => left.startIndex - right.startIndex);
|
|
15789
|
+
return ((_paragraphs$0$paragra = (_paragraphs$ = paragraphs[0]) === null || _paragraphs$ === void 0 || (_paragraphs$ = _paragraphs$.paragraphStyle) === null || _paragraphs$ === void 0 || (_paragraphs$ = _paragraphs$.indentStart) === null || _paragraphs$ === void 0 ? void 0 : _paragraphs$.v) !== null && _paragraphs$0$paragra !== void 0 ? _paragraphs$0$paragra : 0) > 0 ? (_paragraphs$0$paragra2 = paragraphs[0].paragraphStyle) === null || _paragraphs$0$paragra2 === void 0 ? void 0 : _paragraphs$0$paragra2.indentStart : void 0;
|
|
15401
15790
|
}
|
|
15402
15791
|
function _getDrawingSkeletonFormat(drawingOrigin) {
|
|
15403
15792
|
const { drawingId } = drawingOrigin;
|
|
@@ -15421,16 +15810,24 @@ function _getNextPageNumber(lastPage) {
|
|
|
15421
15810
|
return lastPage.pageNumber + 1;
|
|
15422
15811
|
}
|
|
15423
15812
|
function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
|
|
15424
|
-
var _viewModel$
|
|
15813
|
+
var _sectionBreakConfig$d, _viewModel$getSnapsho, _viewModel$getBody2, _viewModel$getBody3;
|
|
15425
15814
|
const { skeletonResourceReference } = ctx;
|
|
15426
15815
|
const { lists, drawings = {}, localeService } = sectionBreakConfig;
|
|
15427
15816
|
const { endIndex, blocks = [], children } = paragraphNode;
|
|
15428
15817
|
const { segmentId } = curPage;
|
|
15429
|
-
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
15818
|
+
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
15819
|
+
startIndex: 0,
|
|
15820
|
+
paragraphId: "para_render_fallback"
|
|
15821
|
+
};
|
|
15430
15822
|
const { paragraphStyle = {}, bullet } = paragraph;
|
|
15823
|
+
const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy((_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 || (_viewModel$getSnapsho = _viewModel$getSnapsho.call(viewModel)) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.documentStyle.documentFlavor);
|
|
15824
|
+
const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
|
|
15825
|
+
const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
|
|
15431
15826
|
const { skeHeaders, skeFooters, skeListLevel, drawingAnchor } = skeletonResourceReference;
|
|
15432
15827
|
const paragraphNonInlineSkeDrawings = /* @__PURE__ */ new Map();
|
|
15433
15828
|
const paragraphInlineSkeDrawings = /* @__PURE__ */ new Map();
|
|
15829
|
+
const paragraphNonInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
|
|
15830
|
+
const paragraphInlineSkeDrawingsByBlockId = /* @__PURE__ */ new Map();
|
|
15434
15831
|
let segmentDrawingAnchorCache = drawingAnchor === null || drawingAnchor === void 0 ? void 0 : drawingAnchor.get(segmentId);
|
|
15435
15832
|
if (segmentDrawingAnchorCache == null) {
|
|
15436
15833
|
segmentDrawingAnchorCache = /* @__PURE__ */ new Map();
|
|
@@ -15438,7 +15835,10 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
15438
15835
|
}
|
|
15439
15836
|
const paragraphConfig = {
|
|
15440
15837
|
paragraphIndex: endIndex,
|
|
15441
|
-
|
|
15838
|
+
documentCompatibilityPolicy,
|
|
15839
|
+
paragraphStyle: _applyBlockRangeLayoutParagraphStyle((_viewModel$getBody2 = (_viewModel$getBody3 = viewModel.getBody) === null || _viewModel$getBody3 === void 0 ? void 0 : _viewModel$getBody3.call(viewModel)) !== null && _viewModel$getBody2 !== void 0 ? _viewModel$getBody2 : null, paragraph, paragraphStyle, shouldApplyDocumentDefaults),
|
|
15840
|
+
docxFallbackAnchorLeft: _getFollowingIndentedParagraphAnchorLeft(viewModel, paragraph, paragraphNode, drawings, isTraditionalDocumentCompatibility(documentCompatibilityPolicy)),
|
|
15841
|
+
useWordStyleLineHeight,
|
|
15442
15842
|
paragraphNonInlineSkeDrawings,
|
|
15443
15843
|
paragraphInlineSkeDrawings,
|
|
15444
15844
|
skeTablesInParagraph: tableSkeleton ? [{
|
|
@@ -15471,36 +15871,60 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
15471
15871
|
if (customBlock == null) continue;
|
|
15472
15872
|
const { blockId } = customBlock;
|
|
15473
15873
|
const drawingOrigin = drawings[blockId];
|
|
15474
|
-
if (drawingOrigin
|
|
15475
|
-
|
|
15874
|
+
if (drawingOrigin == null) continue;
|
|
15875
|
+
if (drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) paragraphInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
|
|
15876
|
+
else paragraphNonInlineSkeDrawingsByBlockId.set(blockId, _getDrawingSkeletonFormat(drawingOrigin));
|
|
15476
15877
|
}
|
|
15477
15878
|
segmentParagraphCache.set(endIndex, paragraphConfig);
|
|
15478
15879
|
let allPages = [curPage];
|
|
15479
15880
|
let isParagraphFirstShapedText = true;
|
|
15480
|
-
|
|
15881
|
+
let shapedTextOffset = 0;
|
|
15882
|
+
for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList).entries()) {
|
|
15883
|
+
const textStartIndex = paragraphNode.startIndex + shapedTextOffset;
|
|
15884
|
+
const textGlyphCount = _glyphCount(glyphs);
|
|
15885
|
+
const textEndIndex = textStartIndex + textGlyphCount;
|
|
15481
15886
|
const pushPending = () => {
|
|
15482
15887
|
if (glyphs.length === 0) return;
|
|
15483
|
-
|
|
15888
|
+
syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId);
|
|
15889
|
+
allPages = layoutParagraph(ctx, glyphs, allPages, sectionBreakConfig, paragraphConfig, isParagraphFirstShapedText || hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId), breakPointType);
|
|
15484
15890
|
isParagraphFirstShapedText = false;
|
|
15485
15891
|
};
|
|
15486
|
-
if (text
|
|
15892
|
+
if (_endsWithToken(text, glyphs, DataStreamTreeTokenType.PAGE_BREAK)) {
|
|
15487
15893
|
pushPending();
|
|
15488
15894
|
allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(allPages[allPages.length - 1]), 1));
|
|
15489
15895
|
paragraphNonInlineSkeDrawings.clear();
|
|
15490
|
-
|
|
15896
|
+
isParagraphFirstShapedText = true;
|
|
15897
|
+
shapedTextOffset += textGlyphCount;
|
|
15491
15898
|
continue;
|
|
15492
|
-
} else if (text
|
|
15899
|
+
} else if (_endsWithToken(text, glyphs, DataStreamTreeTokenType.COLUMN_BREAK) && (!isTraditionalDocumentCompatibility(documentCompatibilityPolicy) || _isMarkedDocxColumnBreak(viewModel, textEndIndex - 1))) {
|
|
15493
15900
|
pushPending();
|
|
15494
15901
|
const lastPage = allPages[allPages.length - 1];
|
|
15495
15902
|
const columnInfo = getLastNotFullColumnInfo(lastPage);
|
|
15496
15903
|
if (columnInfo && !columnInfo.isLast) setColumnFullState(columnInfo.column, true);
|
|
15497
15904
|
else allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(lastPage), 2));
|
|
15905
|
+
shapedTextOffset += textGlyphCount;
|
|
15498
15906
|
continue;
|
|
15499
15907
|
}
|
|
15500
15908
|
pushPending();
|
|
15909
|
+
shapedTextOffset += textGlyphCount;
|
|
15501
15910
|
}
|
|
15502
15911
|
return allPages;
|
|
15503
15912
|
}
|
|
15913
|
+
function syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId) {
|
|
15914
|
+
for (const glyph of glyphs) {
|
|
15915
|
+
if (glyph.streamType !== DataStreamTreeTokenType.CUSTOM_BLOCK || glyph.drawingId == null) continue;
|
|
15916
|
+
const inlineDrawing = paragraphInlineSkeDrawingsByBlockId.get(glyph.drawingId);
|
|
15917
|
+
if (inlineDrawing != null) {
|
|
15918
|
+
paragraphInlineSkeDrawings.set(glyph.drawingId, inlineDrawing);
|
|
15919
|
+
continue;
|
|
15920
|
+
}
|
|
15921
|
+
const nonInlineDrawing = paragraphNonInlineSkeDrawingsByBlockId.get(glyph.drawingId);
|
|
15922
|
+
if (nonInlineDrawing != null) paragraphNonInlineSkeDrawings.set(glyph.drawingId, nonInlineDrawing);
|
|
15923
|
+
}
|
|
15924
|
+
}
|
|
15925
|
+
function hasOnlyFloatingCustomBlockGlyphs(glyphs, paragraphNonInlineSkeDrawingsByBlockId) {
|
|
15926
|
+
return glyphs.length > 0 && glyphs.every((glyph) => glyph.streamType === DataStreamTreeTokenType.CUSTOM_BLOCK && glyph.drawingId != null && paragraphNonInlineSkeDrawingsByBlockId.has(glyph.drawingId));
|
|
15927
|
+
}
|
|
15504
15928
|
|
|
15505
15929
|
//#endregion
|
|
15506
15930
|
//#region src/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.ts
|
|
@@ -15824,6 +16248,26 @@ function prepareTextChunks(body) {
|
|
|
15824
16248
|
//#region src/components/docs/layout/shaping-engine/text-shaping.ts
|
|
15825
16249
|
const fontCache = /* @__PURE__ */ new Map();
|
|
15826
16250
|
const glyphCache = /* @__PURE__ */ new Map();
|
|
16251
|
+
const fontFamilyCache = /* @__PURE__ */ new Map();
|
|
16252
|
+
function trimOuterQuotes(value) {
|
|
16253
|
+
const firstChar = value.charCodeAt(0);
|
|
16254
|
+
const lastChar = value.charCodeAt(value.length - 1);
|
|
16255
|
+
const hasLeadingQuote = firstChar === 34 || firstChar === 39;
|
|
16256
|
+
const hasTrailingQuote = lastChar === 34 || lastChar === 39;
|
|
16257
|
+
if (hasLeadingQuote && hasTrailingQuote) return value.slice(1, -1);
|
|
16258
|
+
if (hasLeadingQuote) return value.slice(1);
|
|
16259
|
+
if (hasTrailingQuote) return value.slice(0, -1);
|
|
16260
|
+
return value;
|
|
16261
|
+
}
|
|
16262
|
+
function expandFontFamilies(fontFamily) {
|
|
16263
|
+
if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return [];
|
|
16264
|
+
let families = fontFamilyCache.get(fontFamily);
|
|
16265
|
+
if (families) return families;
|
|
16266
|
+
families = fontFamily.split(",").map((family) => trimOuterQuotes(family.trim())).filter(Boolean);
|
|
16267
|
+
fontFamilyCache.set(fontFamily, families);
|
|
16268
|
+
return families;
|
|
16269
|
+
}
|
|
16270
|
+
const defaultFontFamilies = expandFontFamilies(DEFAULT_FONTFACE_PLANE);
|
|
15827
16271
|
function shapeChunk(content, charPosition, used, families, style) {
|
|
15828
16272
|
var _style$bl, _style$it, _content$match;
|
|
15829
16273
|
let fi = 0;
|
|
@@ -15926,8 +16370,7 @@ function textShape(body) {
|
|
|
15926
16370
|
for (const chunk of chunks) {
|
|
15927
16371
|
var _style$ff;
|
|
15928
16372
|
const { content, style = {} } = chunk;
|
|
15929
|
-
let fontFamilies =
|
|
15930
|
-
fontFamilies.unshift((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial");
|
|
16373
|
+
let fontFamilies = [...expandFontFamilies((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial"), ...defaultFontFamilies];
|
|
15931
16374
|
fontFamilies = fontLibrary.getValidFontFamilies(fontFamilies);
|
|
15932
16375
|
glyphs.push(...shapeChunk(content, charPosition, /* @__PURE__ */ new Set(), fontFamilies, style));
|
|
15933
16376
|
charPosition += content.length;
|
|
@@ -15965,7 +16408,7 @@ function ArabicHandler(index, charArray, viewModel, paragraphNode, sectionBreakC
|
|
|
15965
16408
|
for (let i = 0; i < charArray.length; i++) {
|
|
15966
16409
|
const newChar = charArray[i];
|
|
15967
16410
|
if (hasArabic(newChar)) {
|
|
15968
|
-
glyph.
|
|
16411
|
+
glyph.push(newChar);
|
|
15969
16412
|
step++;
|
|
15970
16413
|
} else break;
|
|
15971
16414
|
}
|
|
@@ -16062,7 +16505,10 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
|
|
|
16062
16505
|
const shapedTextList = [];
|
|
16063
16506
|
let breaker = new LineBreaker(content);
|
|
16064
16507
|
const { endIndex } = paragraphNode;
|
|
16065
|
-
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
16508
|
+
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
16509
|
+
startIndex: 0,
|
|
16510
|
+
paragraphId: "para_render_fallback"
|
|
16511
|
+
};
|
|
16066
16512
|
const { paragraphStyle = {} } = paragraph;
|
|
16067
16513
|
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
|
|
16068
16514
|
let last = 0;
|
|
@@ -16121,12 +16567,12 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
|
|
|
16121
16567
|
if (customBlock != null) {
|
|
16122
16568
|
const { blockId } = customBlock;
|
|
16123
16569
|
const drawingOrigin = drawings[blockId];
|
|
16124
|
-
if (drawingOrigin.layoutType === PositionedObjectLayoutType.INLINE) {
|
|
16570
|
+
if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === PositionedObjectLayoutType.INLINE) {
|
|
16125
16571
|
const { angle } = drawingOrigin.docTransform;
|
|
16126
16572
|
const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
|
|
16127
16573
|
const boundingBox = getBoundingBox(angle, 0, width, 0, height);
|
|
16128
16574
|
newGlyph = createSkeletonCustomBlockGlyph(config, boundingBox.width, boundingBox.height, drawingOrigin.drawingId);
|
|
16129
|
-
} else newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
|
|
16575
|
+
} else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
|
|
16130
16576
|
}
|
|
16131
16577
|
if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
|
|
16132
16578
|
shapedGlyphs.push(newGlyph);
|
|
@@ -17068,9 +17514,9 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
17068
17514
|
const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
|
|
17069
17515
|
(_this$_findLiquid = this._findLiquid) === null || _this$_findLiquid === void 0 || _this$_findLiquid.translateSave();
|
|
17070
17516
|
(_this$_findLiquid2 = this._findLiquid) === null || _this$_findLiquid2 === void 0 || _this$_findLiquid2.translate(tableLeft, tableTop);
|
|
17071
|
-
if (viewport
|
|
17072
|
-
var _this$_findLiquid4;
|
|
17073
|
-
const visibleLeft = this._findLiquid.x;
|
|
17517
|
+
if (hasDocsTableHorizontalViewport(viewport)) {
|
|
17518
|
+
var _viewport$leadingInse, _this$_findLiquid4;
|
|
17519
|
+
const visibleLeft = this._findLiquid.x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
|
|
17074
17520
|
const visibleRight = visibleLeft + viewport.viewportWidth;
|
|
17075
17521
|
if (x < visibleLeft || x > visibleRight) {
|
|
17076
17522
|
var _this$_findLiquid3;
|
|
@@ -17166,6 +17612,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
17166
17612
|
lists,
|
|
17167
17613
|
drawings,
|
|
17168
17614
|
localeService: this._localeService,
|
|
17615
|
+
documentCompatibilityPolicy: getDocumentCompatibilityPolicy(documentStyle.documentFlavor),
|
|
17169
17616
|
paragraphLineGapDefault,
|
|
17170
17617
|
defaultTabStop,
|
|
17171
17618
|
documentTextStyle: textStyle
|
|
@@ -17240,7 +17687,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
17240
17687
|
let curSkeletonPage = getLastPage(allSkeletonPages);
|
|
17241
17688
|
let isContinuous = false;
|
|
17242
17689
|
ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
|
|
17243
|
-
if (sectionType === SectionType.CONTINUOUS) {
|
|
17690
|
+
if (sectionType === SectionType.CONTINUOUS && curSkeletonPage != null) {
|
|
17244
17691
|
updateBlockIndex(allSkeletonPages);
|
|
17245
17692
|
this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
|
|
17246
17693
|
isContinuous = true;
|
|
@@ -17372,6 +17819,7 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
|
17372
17819
|
}],
|
|
17373
17820
|
paragraphs: [{
|
|
17374
17821
|
startIndex: contentLength,
|
|
17822
|
+
paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
|
|
17375
17823
|
paragraphStyle: { horizontalAlign }
|
|
17376
17824
|
}],
|
|
17377
17825
|
sectionBreaks: [{ startIndex: contentLength + 1 }]
|
|
@@ -17428,7 +17876,7 @@ function getFontFormat(format) {
|
|
|
17428
17876
|
}
|
|
17429
17877
|
|
|
17430
17878
|
//#endregion
|
|
17431
|
-
//#region \0@oxc-project+runtime@0.
|
|
17879
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
17432
17880
|
function __decorateParam(paramIndex, decorator) {
|
|
17433
17881
|
return function(target, key) {
|
|
17434
17882
|
decorator(target, key, paramIndex);
|
|
@@ -17436,7 +17884,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
17436
17884
|
}
|
|
17437
17885
|
|
|
17438
17886
|
//#endregion
|
|
17439
|
-
//#region \0@oxc-project+runtime@0.
|
|
17887
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
17440
17888
|
function __decorate(decorators, target, key, desc) {
|
|
17441
17889
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17442
17890
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18249,7 +18697,7 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
18249
18697
|
this.makeDirty(true);
|
|
18250
18698
|
}
|
|
18251
18699
|
_setBorderStylesCache(row, col, style, options) {
|
|
18252
|
-
if (Tools.isDefine(this._handleBorderMatrix.getValue(row, col))) return;
|
|
18700
|
+
if (Tools.isDefine(this._handleBorderMatrix.getValue(row, col)) && !(options === null || options === void 0 ? void 0 : options.mergeRange)) return;
|
|
18253
18701
|
if (!((options === null || options === void 0 ? void 0 : options.cacheItem) || {
|
|
18254
18702
|
bg: true,
|
|
18255
18703
|
border: true
|
|
@@ -19388,6 +19836,56 @@ var docExtension = class extends ComponentExtension {
|
|
|
19388
19836
|
}
|
|
19389
19837
|
};
|
|
19390
19838
|
|
|
19839
|
+
//#endregion
|
|
19840
|
+
//#region src/components/docs/extensions/background-runs.ts
|
|
19841
|
+
function collectBackgroundGlyphRuns(glyphGroup) {
|
|
19842
|
+
const runs = [];
|
|
19843
|
+
let activeGlyph = null;
|
|
19844
|
+
let activeColor = "";
|
|
19845
|
+
let activeLeft = 0;
|
|
19846
|
+
let activeRight = 0;
|
|
19847
|
+
const flush = () => {
|
|
19848
|
+
if (!activeGlyph) return;
|
|
19849
|
+
runs.push({
|
|
19850
|
+
glyph: {
|
|
19851
|
+
...activeGlyph,
|
|
19852
|
+
width: activeRight - activeLeft
|
|
19853
|
+
},
|
|
19854
|
+
left: activeLeft,
|
|
19855
|
+
width: activeRight - activeLeft
|
|
19856
|
+
});
|
|
19857
|
+
activeGlyph = null;
|
|
19858
|
+
activeColor = "";
|
|
19859
|
+
activeLeft = 0;
|
|
19860
|
+
activeRight = 0;
|
|
19861
|
+
};
|
|
19862
|
+
for (const glyph of glyphGroup) {
|
|
19863
|
+
var _glyph$ts;
|
|
19864
|
+
if (!glyph.content || glyph.content === "\r") {
|
|
19865
|
+
flush();
|
|
19866
|
+
continue;
|
|
19867
|
+
}
|
|
19868
|
+
const backgroundColor = ((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.bg) ? getColorStyle(glyph.ts.bg) : "";
|
|
19869
|
+
if (!backgroundColor) {
|
|
19870
|
+
flush();
|
|
19871
|
+
continue;
|
|
19872
|
+
}
|
|
19873
|
+
const glyphLeft = glyph.left;
|
|
19874
|
+
const glyphRight = glyph.left + glyph.width;
|
|
19875
|
+
if (activeGlyph && activeColor === backgroundColor) {
|
|
19876
|
+
activeRight = Math.max(activeRight, glyphRight);
|
|
19877
|
+
continue;
|
|
19878
|
+
}
|
|
19879
|
+
flush();
|
|
19880
|
+
activeGlyph = glyph;
|
|
19881
|
+
activeColor = backgroundColor;
|
|
19882
|
+
activeLeft = glyphLeft;
|
|
19883
|
+
activeRight = glyphRight;
|
|
19884
|
+
}
|
|
19885
|
+
flush();
|
|
19886
|
+
return runs;
|
|
19887
|
+
}
|
|
19888
|
+
|
|
19391
19889
|
//#endregion
|
|
19392
19890
|
//#region src/components/docs/extensions/background.ts
|
|
19393
19891
|
const UNIQUE_KEY$3 = "DefaultDocsBackgroundExtension";
|
|
@@ -19803,7 +20301,6 @@ var Image$1 = class extends Shape {
|
|
|
19803
20301
|
this.makeDirty(true);
|
|
19804
20302
|
} else if (config.url) {
|
|
19805
20303
|
this._native = document.createElement("img");
|
|
19806
|
-
this._native.src = config.url;
|
|
19807
20304
|
this._native.crossOrigin = "anonymous";
|
|
19808
20305
|
this._native.onload = () => {
|
|
19809
20306
|
var _config$success, _this$getEngine;
|
|
@@ -19818,6 +20315,7 @@ var Image$1 = class extends Shape {
|
|
|
19818
20315
|
this.makeDirty(true);
|
|
19819
20316
|
}
|
|
19820
20317
|
};
|
|
20318
|
+
this._native.src = config.url;
|
|
19821
20319
|
}
|
|
19822
20320
|
this._init();
|
|
19823
20321
|
}
|
|
@@ -19831,10 +20329,17 @@ var Image$1 = class extends Shape {
|
|
|
19831
20329
|
var _this$_props$opacity;
|
|
19832
20330
|
return (_this$_props$opacity = this._props.opacity) !== null && _this$_props$opacity !== void 0 ? _this$_props$opacity : 1;
|
|
19833
20331
|
}
|
|
20332
|
+
get clipBounds() {
|
|
20333
|
+
return this._props.clipBounds;
|
|
20334
|
+
}
|
|
19834
20335
|
setOpacity(opacity) {
|
|
19835
20336
|
this._props.opacity = opacity;
|
|
19836
20337
|
this.makeDirty(true);
|
|
19837
20338
|
}
|
|
20339
|
+
setClipBounds(clipBounds) {
|
|
20340
|
+
this._props.clipBounds = clipBounds;
|
|
20341
|
+
this.makeDirty(true);
|
|
20342
|
+
}
|
|
19838
20343
|
setClipService(clipService) {
|
|
19839
20344
|
this._clipService = clipService;
|
|
19840
20345
|
}
|
|
@@ -19851,10 +20356,10 @@ var Image$1 = class extends Shape {
|
|
|
19851
20356
|
}
|
|
19852
20357
|
changeSource(url) {
|
|
19853
20358
|
if (this._native == null) this._native = document.createElement("img");
|
|
19854
|
-
this._native.src = url;
|
|
19855
20359
|
this._native.onload = () => {
|
|
19856
20360
|
this.makeDirty(true);
|
|
19857
20361
|
};
|
|
20362
|
+
this._native.src = url;
|
|
19858
20363
|
}
|
|
19859
20364
|
resetSize() {
|
|
19860
20365
|
if (this._native == null) return;
|
|
@@ -19960,6 +20465,12 @@ var Image$1 = class extends Shape {
|
|
|
19960
20465
|
}
|
|
19961
20466
|
const m = this.transform.getMatrix();
|
|
19962
20467
|
mainCtx.save();
|
|
20468
|
+
const { clipBounds } = this;
|
|
20469
|
+
if (clipBounds) {
|
|
20470
|
+
mainCtx.beginPath();
|
|
20471
|
+
mainCtx.rect(clipBounds.left, clipBounds.top, clipBounds.width, clipBounds.height);
|
|
20472
|
+
mainCtx.clip();
|
|
20473
|
+
}
|
|
19963
20474
|
const centerX = realLeft + realWidth / 2;
|
|
19964
20475
|
const centerY = realTop + realHeight / 2;
|
|
19965
20476
|
mainCtx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
@@ -21600,6 +22111,7 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
21600
22111
|
"actualFontMap",
|
|
21601
22112
|
{}
|
|
21602
22113
|
);
|
|
22114
|
+
_defineProperty(this, "_textFillImageCache", /* @__PURE__ */ new Map());
|
|
21603
22115
|
}
|
|
21604
22116
|
draw(ctx, _parentScale, glyph, _, _more) {
|
|
21605
22117
|
var _glyph$parent;
|
|
@@ -21618,13 +22130,162 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
21618
22130
|
this.actualFontMap[fontStringPxStr] = ctx.font;
|
|
21619
22131
|
}
|
|
21620
22132
|
}
|
|
21621
|
-
const { cl: colorStyle, va: baselineOffset } = textStyle;
|
|
22133
|
+
const { cl: colorStyle, va: baselineOffset, textFill } = textStyle;
|
|
21622
22134
|
const fontColor = getColorStyle(colorStyle) || "rgb(0,0,0)";
|
|
21623
|
-
if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
|
|
21624
22135
|
if (baselineOffset === BaselineOffset.SUPERSCRIPT) spanPointWithFont.y += -bBox.spo;
|
|
21625
22136
|
else if (baselineOffset === BaselineOffset.SUBSCRIPT) spanPointWithFont.y += bBox.sbo;
|
|
22137
|
+
if (this._fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fontColor)) return;
|
|
22138
|
+
if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
|
|
21626
22139
|
this._fillText(ctx, glyph, spanPointWithFont);
|
|
21627
22140
|
}
|
|
22141
|
+
_fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fallbackColor) {
|
|
22142
|
+
if (!textFill || textFill.type === "none") return (textFill === null || textFill === void 0 ? void 0 : textFill.type) === "none";
|
|
22143
|
+
const { content, glyphType } = glyph;
|
|
22144
|
+
if (content == null || glyphType === 2) return false;
|
|
22145
|
+
const { renderConfig } = this.extensionOffset;
|
|
22146
|
+
const { vertexAngle, centerAngle } = renderConfig !== null && renderConfig !== void 0 ? renderConfig : {};
|
|
22147
|
+
const VERTICAL_DEG = 90;
|
|
22148
|
+
if (vertexAngle === VERTICAL_DEG && centerAngle === VERTICAL_DEG) return false;
|
|
22149
|
+
const bounds = this._getGlyphPaintBounds(glyph, spanPointWithFont);
|
|
22150
|
+
if (bounds.width <= 0 || bounds.height <= 0) return false;
|
|
22151
|
+
const color = this._colorWithOpacity(textFill.color || fallbackColor, textFill.opacity);
|
|
22152
|
+
if (textFill.type === "solid") {
|
|
22153
|
+
ctx.fillStyle = color;
|
|
22154
|
+
this._fillText(ctx, glyph, spanPointWithFont);
|
|
22155
|
+
return true;
|
|
22156
|
+
}
|
|
22157
|
+
if (textFill.type === "gradient") {
|
|
22158
|
+
const gradient = this._createTextGradient(ctx, bounds, textFill, fallbackColor);
|
|
22159
|
+
if (!gradient) return false;
|
|
22160
|
+
ctx.fillStyle = gradient;
|
|
22161
|
+
this._fillText(ctx, glyph, spanPointWithFont);
|
|
22162
|
+
return true;
|
|
22163
|
+
}
|
|
22164
|
+
if (textFill.type === "picture") {
|
|
22165
|
+
const pattern = this._createTextPicturePattern(ctx, bounds, textFill);
|
|
22166
|
+
if (!pattern) return false;
|
|
22167
|
+
ctx.fillStyle = pattern;
|
|
22168
|
+
this._fillText(ctx, glyph, spanPointWithFont);
|
|
22169
|
+
return true;
|
|
22170
|
+
}
|
|
22171
|
+
return false;
|
|
22172
|
+
}
|
|
22173
|
+
_getGlyphPaintBounds(glyph, spanPointWithFont) {
|
|
22174
|
+
const { width, bBox } = glyph;
|
|
22175
|
+
const textWidth = Math.max(width, bBox.width, 1);
|
|
22176
|
+
const textHeight = Math.max(bBox.aba + bBox.abd, 1);
|
|
22177
|
+
return {
|
|
22178
|
+
left: spanPointWithFont.x,
|
|
22179
|
+
top: spanPointWithFont.y - bBox.aba,
|
|
22180
|
+
width: textWidth,
|
|
22181
|
+
height: textHeight
|
|
22182
|
+
};
|
|
22183
|
+
}
|
|
22184
|
+
_createTextGradient(ctx, bounds, textFill, fallbackColor) {
|
|
22185
|
+
var _gradient$type, _gradient$angle, _context;
|
|
22186
|
+
const gradient = textFill.gradient;
|
|
22187
|
+
const type = (_gradient$type = gradient === null || gradient === void 0 ? void 0 : gradient.type) !== null && _gradient$type !== void 0 ? _gradient$type : "linear";
|
|
22188
|
+
const angle = (_gradient$angle = gradient === null || gradient === void 0 ? void 0 : gradient.angle) !== null && _gradient$angle !== void 0 ? _gradient$angle : 0;
|
|
22189
|
+
const stops = this._normalizeGradientStops(gradient === null || gradient === void 0 ? void 0 : gradient.stops, textFill.color || fallbackColor);
|
|
22190
|
+
const centerX = bounds.left + bounds.width / 2;
|
|
22191
|
+
const centerY = bounds.top + bounds.height / 2;
|
|
22192
|
+
let canvasGradient;
|
|
22193
|
+
if (type === "radial") {
|
|
22194
|
+
const radius = Math.max(bounds.width, bounds.height) / 2;
|
|
22195
|
+
canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
|
|
22196
|
+
} else if (type === "angular" && "createConicGradient" in ((_context = ctx._context) !== null && _context !== void 0 ? _context : ctx)) {
|
|
22197
|
+
var _context2;
|
|
22198
|
+
canvasGradient = ((_context2 = ctx._context) !== null && _context2 !== void 0 ? _context2 : ctx).createConicGradient((angle - 90) * Math.PI / 180, centerX, centerY);
|
|
22199
|
+
} else if (type === "diamond") {
|
|
22200
|
+
const radius = Math.max(bounds.width, bounds.height) / 2;
|
|
22201
|
+
canvasGradient = ctx.createRadialGradient(centerX, centerY, 0, centerX, centerY, radius);
|
|
22202
|
+
} else {
|
|
22203
|
+
const line = this._getLinearGradientLine(bounds, angle);
|
|
22204
|
+
canvasGradient = ctx.createLinearGradient(line.x0, line.y0, line.x1, line.y1);
|
|
22205
|
+
}
|
|
22206
|
+
for (const stop of stops) {
|
|
22207
|
+
var _textFill$opacity, _stop$opacity;
|
|
22208
|
+
const opacity = ((_textFill$opacity = textFill.opacity) !== null && _textFill$opacity !== void 0 ? _textFill$opacity : 1) * ((_stop$opacity = stop.opacity) !== null && _stop$opacity !== void 0 ? _stop$opacity : 1);
|
|
22209
|
+
canvasGradient.addColorStop(stop.offset, this._colorWithOpacity(stop.color, opacity));
|
|
22210
|
+
}
|
|
22211
|
+
return canvasGradient;
|
|
22212
|
+
}
|
|
22213
|
+
_createTextPicturePattern(ctx, bounds, textFill) {
|
|
22214
|
+
var _textFill$picture, _ref, _textFill$picture$opa, _textFill$picture2, _textFill$picture3, _pattern$setTransform;
|
|
22215
|
+
const source = (_textFill$picture = textFill.picture) === null || _textFill$picture === void 0 ? void 0 : _textFill$picture.source;
|
|
22216
|
+
if (!source) return null;
|
|
22217
|
+
const image = this._getTextFillImage(source);
|
|
22218
|
+
if (!image || !image.complete || !(image.naturalWidth || image.width)) return null;
|
|
22219
|
+
const canvas = document.createElement("canvas");
|
|
22220
|
+
canvas.width = Math.max(1, Math.ceil(bounds.width));
|
|
22221
|
+
canvas.height = Math.max(1, Math.ceil(bounds.height));
|
|
22222
|
+
const canvasContext = canvas.getContext("2d");
|
|
22223
|
+
if (!canvasContext) return null;
|
|
22224
|
+
canvasContext.globalAlpha = this._clamp((_ref = (_textFill$picture$opa = (_textFill$picture2 = textFill.picture) === null || _textFill$picture2 === void 0 ? void 0 : _textFill$picture2.opacity) !== null && _textFill$picture$opa !== void 0 ? _textFill$picture$opa : textFill.opacity) !== null && _ref !== void 0 ? _ref : 1, 0, 1);
|
|
22225
|
+
if (((_textFill$picture3 = textFill.picture) === null || _textFill$picture3 === void 0 ? void 0 : _textFill$picture3.mode) === "tile") {
|
|
22226
|
+
var _textFill$picture$sca, _textFill$picture$sca2, _textFill$picture$off, _textFill$picture$off2;
|
|
22227
|
+
const scaleX = (_textFill$picture$sca = textFill.picture.scaleX) !== null && _textFill$picture$sca !== void 0 ? _textFill$picture$sca : 1;
|
|
22228
|
+
const scaleY = (_textFill$picture$sca2 = textFill.picture.scaleY) !== null && _textFill$picture$sca2 !== void 0 ? _textFill$picture$sca2 : 1;
|
|
22229
|
+
const cellWidth = Math.max(1, (image.naturalWidth || image.width) * scaleX);
|
|
22230
|
+
const cellHeight = Math.max(1, (image.naturalHeight || image.height) * scaleY);
|
|
22231
|
+
const offsetX = (_textFill$picture$off = textFill.picture.offsetX) !== null && _textFill$picture$off !== void 0 ? _textFill$picture$off : 0;
|
|
22232
|
+
const offsetY = (_textFill$picture$off2 = textFill.picture.offsetY) !== null && _textFill$picture$off2 !== void 0 ? _textFill$picture$off2 : 0;
|
|
22233
|
+
for (let x = (offsetX % cellWidth + cellWidth) % cellWidth - cellWidth; x < canvas.width; x += cellWidth) for (let y = (offsetY % cellHeight + cellHeight) % cellHeight - cellHeight; y < canvas.height; y += cellHeight) canvasContext.drawImage(image, x, y, cellWidth, cellHeight);
|
|
22234
|
+
} else canvasContext.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
22235
|
+
const pattern = ctx.createPattern(canvas, "no-repeat");
|
|
22236
|
+
pattern === null || pattern === void 0 || (_pattern$setTransform = pattern.setTransform) === null || _pattern$setTransform === void 0 || _pattern$setTransform.call(pattern, new DOMMatrix().translate(bounds.left, bounds.top));
|
|
22237
|
+
return pattern;
|
|
22238
|
+
}
|
|
22239
|
+
_getTextFillImage(source) {
|
|
22240
|
+
const cached = this._textFillImageCache.get(source);
|
|
22241
|
+
if (cached) return cached;
|
|
22242
|
+
const image = new Image();
|
|
22243
|
+
image.crossOrigin = "anonymous";
|
|
22244
|
+
image.src = source;
|
|
22245
|
+
this._textFillImageCache.set(source, image);
|
|
22246
|
+
return image.complete ? image : null;
|
|
22247
|
+
}
|
|
22248
|
+
_normalizeGradientStops(stops, fallbackColor) {
|
|
22249
|
+
return (stops && stops.length >= 2 ? stops : [{
|
|
22250
|
+
offset: 0,
|
|
22251
|
+
color: fallbackColor
|
|
22252
|
+
}, {
|
|
22253
|
+
offset: 100,
|
|
22254
|
+
color: "#ffffff"
|
|
22255
|
+
}]).map((stop) => ({
|
|
22256
|
+
color: stop.color,
|
|
22257
|
+
offset: this._clamp(stop.offset > 1 ? stop.offset / 100 : stop.offset, 0, 1),
|
|
22258
|
+
opacity: stop.opacity
|
|
22259
|
+
}));
|
|
22260
|
+
}
|
|
22261
|
+
_getLinearGradientLine(bounds, angle) {
|
|
22262
|
+
const angleRad = angle * Math.PI / 180;
|
|
22263
|
+
const centerX = bounds.left + bounds.width / 2;
|
|
22264
|
+
const centerY = bounds.top + bounds.height / 2;
|
|
22265
|
+
const cos = Math.cos(angleRad);
|
|
22266
|
+
const sin = Math.sin(angleRad);
|
|
22267
|
+
const halfDiagonal = (Math.abs(bounds.width * cos) + Math.abs(bounds.height * sin)) / 2;
|
|
22268
|
+
return {
|
|
22269
|
+
x0: centerX - cos * halfDiagonal,
|
|
22270
|
+
y0: centerY - sin * halfDiagonal,
|
|
22271
|
+
x1: centerX + cos * halfDiagonal,
|
|
22272
|
+
y1: centerY + sin * halfDiagonal
|
|
22273
|
+
};
|
|
22274
|
+
}
|
|
22275
|
+
_colorWithOpacity(color, opacity) {
|
|
22276
|
+
if (opacity === void 0 || opacity >= 1) return color;
|
|
22277
|
+
const alpha = this._clamp(opacity, 0, 1);
|
|
22278
|
+
const hex = color.trim();
|
|
22279
|
+
if (/^#[0-9a-f]{3}$/i.test(hex)) {
|
|
22280
|
+
const [, r, g, b] = hex;
|
|
22281
|
+
return `rgba(${Number.parseInt(r + r, 16)}, ${Number.parseInt(g + g, 16)}, ${Number.parseInt(b + b, 16)}, ${alpha})`;
|
|
22282
|
+
}
|
|
22283
|
+
if (/^#[0-9a-f]{6}$/i.test(hex)) return `rgba(${Number.parseInt(hex.slice(1, 3), 16)}, ${Number.parseInt(hex.slice(3, 5), 16)}, ${Number.parseInt(hex.slice(5, 7), 16)}, ${alpha})`;
|
|
22284
|
+
return color;
|
|
22285
|
+
}
|
|
22286
|
+
_clamp(value, min, max) {
|
|
22287
|
+
return Math.max(min, Math.min(max, value));
|
|
22288
|
+
}
|
|
21628
22289
|
_fillText(ctx, glyph, spanPointWithFont) {
|
|
21629
22290
|
const { renderConfig, spanStartPoint, centerPoint } = this.extensionOffset;
|
|
21630
22291
|
const { content, width, bBox } = glyph;
|
|
@@ -21972,24 +22633,14 @@ var Documents = class Documents extends DocComponent {
|
|
|
21972
22633
|
this._drawLiquid.translateSave();
|
|
21973
22634
|
this._drawLiquid.translateLine(line, true, true);
|
|
21974
22635
|
rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i]);
|
|
22636
|
+
this._drawLineBackground(ctx, page, line);
|
|
21975
22637
|
const divideLength = divides.length;
|
|
21976
22638
|
for (let i = 0; i < divideLength; i++) {
|
|
21977
22639
|
const divide = divides[i];
|
|
21978
22640
|
const { glyphGroup } = divide;
|
|
21979
22641
|
this._drawLiquid.translateSave();
|
|
21980
22642
|
this._drawLiquid.translateDivide(divide, isVertical && wrapStrategy === WrapStrategy.WRAP, verticalAlign, rotatedHeightStore);
|
|
21981
|
-
|
|
21982
|
-
if (!glyph.content || glyph.content.length === 0) continue;
|
|
21983
|
-
const { width: spanWidth, left: spanLeft } = glyph;
|
|
21984
|
-
const { x: translateX, y: translateY } = this._drawLiquid;
|
|
21985
|
-
const originTranslate = Vector2.create(translateX, translateY);
|
|
21986
|
-
const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
|
|
21987
|
-
const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
|
|
21988
|
-
if (backgroundExtension) {
|
|
21989
|
-
backgroundExtension.extensionOffset = extensionOffset;
|
|
21990
|
-
backgroundExtension.draw(ctx, parentScale, glyph);
|
|
21991
|
-
}
|
|
21992
|
-
}
|
|
22643
|
+
this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
|
|
21993
22644
|
for (const glyph of glyphGroup) {
|
|
21994
22645
|
if (!glyph.content || glyph.content.length === 0) continue;
|
|
21995
22646
|
const { width: spanWidth, left: spanLeft, xOffset } = glyph;
|
|
@@ -22045,15 +22696,18 @@ var Documents = class Documents extends DocComponent {
|
|
|
22045
22696
|
const viewport = this._getTableViewport(page, tableSkeleton, renderUnitId, sourceTableId);
|
|
22046
22697
|
drawLiquid.translateSave();
|
|
22047
22698
|
drawLiquid.translate(tableLeft, tableTop);
|
|
22048
|
-
if (viewport
|
|
22699
|
+
if (hasDocsTableHorizontalViewport(viewport)) {
|
|
22700
|
+
var _viewport$leadingInse;
|
|
22049
22701
|
const { x, y } = drawLiquid;
|
|
22702
|
+
const clipLeft = x + page.marginLeft - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0);
|
|
22050
22703
|
ctx.save();
|
|
22051
22704
|
ctx.beginPath();
|
|
22052
|
-
ctx.rectByPrecision(
|
|
22705
|
+
ctx.rectByPrecision(clipLeft - TABLE_VIEWPORT_BORDER_CLIP_PADDING, y + page.marginTop - TABLE_VIEWPORT_BORDER_CLIP_PADDING, viewport.viewportWidth + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2, tableSkeleton.height + TABLE_VIEWPORT_BORDER_CLIP_PADDING * 2);
|
|
22053
22706
|
ctx.closePath();
|
|
22054
22707
|
ctx.clip();
|
|
22055
22708
|
drawLiquid.translate(-viewport.scrollLeft, 0);
|
|
22056
22709
|
}
|
|
22710
|
+
this._drawTableCellBackgrounds(ctx, page, tableSkeleton);
|
|
22057
22711
|
for (const row of rows) {
|
|
22058
22712
|
const { top: rowTop, cells } = row;
|
|
22059
22713
|
drawLiquid.translateSave();
|
|
@@ -22068,16 +22722,49 @@ var Documents = class Documents extends DocComponent {
|
|
|
22068
22722
|
}
|
|
22069
22723
|
drawLiquid.translateRestore();
|
|
22070
22724
|
}
|
|
22071
|
-
if (viewport
|
|
22725
|
+
if (hasDocsTableHorizontalViewport(viewport)) ctx.restore();
|
|
22072
22726
|
drawLiquid.translateRestore();
|
|
22073
22727
|
}
|
|
22074
22728
|
}
|
|
22729
|
+
_drawTableCellBackgrounds(ctx, page, tableSkeleton) {
|
|
22730
|
+
if (this._drawLiquid == null) return;
|
|
22731
|
+
const backgrounds = /* @__PURE__ */ new Map();
|
|
22732
|
+
const tableX = this._drawLiquid.x + page.marginLeft;
|
|
22733
|
+
const tableY = this._drawLiquid.y + page.marginTop;
|
|
22734
|
+
for (const row of tableSkeleton.rows) row.cells.forEach((cell, index) => {
|
|
22735
|
+
var _cellSource$backgroun, _backgrounds$get;
|
|
22736
|
+
if (cell.isMergedCellCovered) return;
|
|
22737
|
+
const cellSource = row.rowSource.tableCells[index];
|
|
22738
|
+
if (!cellSource || cellSource.rowSpan === 0 || cellSource.columnSpan === 0) return;
|
|
22739
|
+
const color = (_cellSource$backgroun = cellSource.backgroundColor) === null || _cellSource$backgroun === void 0 ? void 0 : _cellSource$backgroun.rgb;
|
|
22740
|
+
if (!color) return;
|
|
22741
|
+
const rects = (_backgrounds$get = backgrounds.get(color)) !== null && _backgrounds$get !== void 0 ? _backgrounds$get : [];
|
|
22742
|
+
rects.push({
|
|
22743
|
+
x: tableX + cell.left,
|
|
22744
|
+
y: tableY + row.top,
|
|
22745
|
+
width: cell.pageWidth,
|
|
22746
|
+
height: cell.pageHeight
|
|
22747
|
+
});
|
|
22748
|
+
backgrounds.set(color, rects);
|
|
22749
|
+
});
|
|
22750
|
+
backgrounds.forEach((rects, color) => {
|
|
22751
|
+
ctx.save();
|
|
22752
|
+
ctx.fillStyle = color;
|
|
22753
|
+
ctx.beginPath();
|
|
22754
|
+
rects.forEach(({ x, y, width, height }) => {
|
|
22755
|
+
rectByPrecisionBounds(ctx, x, y, width, height);
|
|
22756
|
+
});
|
|
22757
|
+
ctx.fill();
|
|
22758
|
+
ctx.closePath();
|
|
22759
|
+
ctx.restore();
|
|
22760
|
+
});
|
|
22761
|
+
}
|
|
22075
22762
|
_getTableViewport(page, tableSkeleton, unitId, tableId) {
|
|
22076
22763
|
const viewport = getDocsTableRenderViewport(unitId, tableId);
|
|
22077
22764
|
if (viewport) return viewport;
|
|
22078
22765
|
const { pageWidth, marginLeft = 0, marginRight = 0 } = page;
|
|
22079
22766
|
if (!Number.isFinite(pageWidth)) return null;
|
|
22080
|
-
const viewportWidth = Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
|
|
22767
|
+
const viewportWidth = shouldAllowImportedTableMarginOverflow(this._getDocumentCompatibilityPolicy(), tableSkeleton.tableSource) ? Math.max(0, pageWidth - Math.max(0, marginLeft + tableSkeleton.left)) : Math.max(0, pageWidth - marginLeft - marginRight - tableSkeleton.left);
|
|
22081
22768
|
if (viewportWidth <= 0 || tableSkeleton.width <= viewportWidth) return null;
|
|
22082
22769
|
return {
|
|
22083
22770
|
contentWidth: tableSkeleton.width,
|
|
@@ -22092,6 +22779,26 @@ var Documents = class Documents extends DocComponent {
|
|
|
22092
22779
|
const dataModel = viewModel === null || viewModel === void 0 || (_viewModel$getDataMod = viewModel.getDataModel) === null || _viewModel$getDataMod === void 0 ? void 0 : _viewModel$getDataMod.call(viewModel);
|
|
22093
22780
|
return (_dataModel$getUnitId = dataModel === null || dataModel === void 0 || (_dataModel$getUnitId2 = dataModel.getUnitId) === null || _dataModel$getUnitId2 === void 0 ? void 0 : _dataModel$getUnitId2.call(dataModel)) !== null && _dataModel$getUnitId !== void 0 ? _dataModel$getUnitId : this.oKey;
|
|
22094
22781
|
}
|
|
22782
|
+
_getDocumentCompatibilityPolicy() {
|
|
22783
|
+
var _skeleton$getViewMode2, _skeleton$getViewMode3;
|
|
22784
|
+
const skeleton = this.getSkeleton();
|
|
22785
|
+
return getDocumentCompatibilityPolicy(skeleton === null || skeleton === void 0 || (_skeleton$getViewMode2 = skeleton.getViewModel) === null || _skeleton$getViewMode2 === void 0 || (_skeleton$getViewMode2 = _skeleton$getViewMode2.call(skeleton)) === null || _skeleton$getViewMode2 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode2.getSnapshot) === null || _skeleton$getViewMode3 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode3.call(_skeleton$getViewMode2)) === null || _skeleton$getViewMode3 === void 0 || (_skeleton$getViewMode3 = _skeleton$getViewMode3.documentStyle) === null || _skeleton$getViewMode3 === void 0 ? void 0 : _skeleton$getViewMode3.documentFlavor);
|
|
22786
|
+
}
|
|
22787
|
+
_drawLineBackground(ctx, page, line, left = 0, top = 0) {
|
|
22788
|
+
var _line$backgroundColor;
|
|
22789
|
+
const color = (_line$backgroundColor = line.backgroundColor) === null || _line$backgroundColor === void 0 ? void 0 : _line$backgroundColor.rgb;
|
|
22790
|
+
if (!color || this._drawLiquid == null) return;
|
|
22791
|
+
let { x, y } = this._drawLiquid;
|
|
22792
|
+
const { pageWidth, marginLeft, marginRight, marginTop } = page;
|
|
22793
|
+
x += marginLeft + (left !== null && left !== void 0 ? left : 0);
|
|
22794
|
+
y -= line.marginTop;
|
|
22795
|
+
y -= line.paddingTop;
|
|
22796
|
+
y += marginTop + top;
|
|
22797
|
+
ctx.save();
|
|
22798
|
+
ctx.fillStyle = color;
|
|
22799
|
+
fillRectByPrecisionBounds(ctx, x, y, pageWidth - marginLeft - marginRight, line.lineHeight);
|
|
22800
|
+
ctx.restore();
|
|
22801
|
+
}
|
|
22095
22802
|
_drawBorderBottom(ctx, page, line, left = 0, top = 0) {
|
|
22096
22803
|
var _line$borderBottom$pa, _line$borderBottom, _line$borderBottom$co, _line$borderBottom2;
|
|
22097
22804
|
if (this._drawLiquid == null) return;
|
|
@@ -22112,9 +22819,21 @@ var Documents = class Documents extends DocComponent {
|
|
|
22112
22819
|
});
|
|
22113
22820
|
ctx.restore();
|
|
22114
22821
|
}
|
|
22822
|
+
_drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension) {
|
|
22823
|
+
if (!backgroundExtension || this._drawLiquid == null) return;
|
|
22824
|
+
const backgroundRuns = collectBackgroundGlyphRuns(glyphGroup);
|
|
22825
|
+
for (const backgroundRun of backgroundRuns) {
|
|
22826
|
+
const { glyph, left: spanLeft, width: spanWidth } = backgroundRun;
|
|
22827
|
+
const { x: translateX, y: translateY } = this._drawLiquid;
|
|
22828
|
+
const originTranslate = Vector2.create(translateX, translateY);
|
|
22829
|
+
const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
|
|
22830
|
+
backgroundExtension.extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
|
|
22831
|
+
backgroundExtension.draw(ctx, parentScale, glyph);
|
|
22832
|
+
}
|
|
22833
|
+
}
|
|
22115
22834
|
_drawTableCell(ctx, page, cell, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale) {
|
|
22116
22835
|
if (this._drawLiquid == null) return;
|
|
22117
|
-
this._drawTableCellBordersAndBg(ctx, page, cell);
|
|
22836
|
+
this._drawTableCellBordersAndBg(ctx, page, cell, false);
|
|
22118
22837
|
const { sections, marginLeft, marginTop } = cell;
|
|
22119
22838
|
alignOffsetNoAngle = Vector2.create(alignOffsetNoAngle.x + marginLeft, alignOffsetNoAngle.y + marginTop);
|
|
22120
22839
|
ctx.save();
|
|
@@ -22151,24 +22870,14 @@ var Documents = class Documents extends DocComponent {
|
|
|
22151
22870
|
} else {
|
|
22152
22871
|
this._drawLiquid.translateSave();
|
|
22153
22872
|
this._drawLiquid.translateLine(line, true, true);
|
|
22873
|
+
this._drawLineBackground(ctx, cell, line, page.marginLeft, page.marginTop);
|
|
22154
22874
|
const divideLength = divides.length;
|
|
22155
22875
|
for (let i = 0; i < divideLength; i++) {
|
|
22156
22876
|
const divide = divides[i];
|
|
22157
22877
|
const { glyphGroup } = divide;
|
|
22158
22878
|
this._drawLiquid.translateSave();
|
|
22159
22879
|
this._drawLiquid.translateDivide(divide);
|
|
22160
|
-
|
|
22161
|
-
if (!glyph.content || glyph.content.length === 0) continue;
|
|
22162
|
-
const { width: spanWidth, left: spanLeft } = glyph;
|
|
22163
|
-
const { x: translateX, y: translateY } = this._drawLiquid;
|
|
22164
|
-
const originTranslate = Vector2.create(translateX, translateY);
|
|
22165
|
-
const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
|
|
22166
|
-
const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
|
|
22167
|
-
if (backgroundExtension) {
|
|
22168
|
-
backgroundExtension.extensionOffset = extensionOffset;
|
|
22169
|
-
backgroundExtension.draw(ctx, parentScale, glyph);
|
|
22170
|
-
}
|
|
22171
|
-
}
|
|
22880
|
+
this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
|
|
22172
22881
|
for (const glyph of glyphGroup) {
|
|
22173
22882
|
if (!glyph.content || glyph.content.length === 0) continue;
|
|
22174
22883
|
const { width: spanWidth, left: spanLeft, xOffset } = glyph;
|
|
@@ -22200,8 +22909,8 @@ var Documents = class Documents extends DocComponent {
|
|
|
22200
22909
|
}
|
|
22201
22910
|
ctx.restore();
|
|
22202
22911
|
}
|
|
22203
|
-
_drawTableCellBordersAndBg(ctx, page, cell) {
|
|
22204
|
-
var _rowSke$index, _cellSource$
|
|
22912
|
+
_drawTableCellBordersAndBg(ctx, page, cell, drawBackground = true) {
|
|
22913
|
+
var _rowSke$index, _cellSource$backgroun2;
|
|
22205
22914
|
const { marginLeft, marginTop } = page;
|
|
22206
22915
|
const { pageWidth, pageHeight } = cell;
|
|
22207
22916
|
const rowSke = cell.parent;
|
|
@@ -22216,10 +22925,10 @@ var Documents = class Documents extends DocComponent {
|
|
|
22216
22925
|
let { x, y } = this._drawLiquid;
|
|
22217
22926
|
x += marginLeft;
|
|
22218
22927
|
y += marginTop;
|
|
22219
|
-
if ((_cellSource$
|
|
22928
|
+
if (drawBackground && ((_cellSource$backgroun2 = cellSource.backgroundColor) === null || _cellSource$backgroun2 === void 0 ? void 0 : _cellSource$backgroun2.rgb)) {
|
|
22220
22929
|
ctx.save();
|
|
22221
22930
|
ctx.fillStyle = cellSource.backgroundColor.rgb;
|
|
22222
|
-
ctx
|
|
22931
|
+
fillRectByPrecisionBounds(ctx, x, y, pageWidth, pageHeight);
|
|
22223
22932
|
ctx.restore();
|
|
22224
22933
|
}
|
|
22225
22934
|
const position = {
|
|
@@ -22267,8 +22976,9 @@ var Documents = class Documents extends DocComponent {
|
|
|
22267
22976
|
}
|
|
22268
22977
|
_drawHeaderFooter(page, ctx, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, parentPage, isHeader = true) {
|
|
22269
22978
|
if (this._drawLiquid == null) return;
|
|
22270
|
-
const { sections } = page;
|
|
22979
|
+
const { sections, skeTables } = page;
|
|
22271
22980
|
const { y: originY } = this._drawLiquid;
|
|
22981
|
+
if (skeTables.size > 0) this._drawTable(ctx, page, skeTables, extensions, backgroundExtension, glyphExtensionsExcludeBackground, alignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale);
|
|
22272
22982
|
for (const section of sections) {
|
|
22273
22983
|
const { columns } = section;
|
|
22274
22984
|
this._drawLiquid.translateSave();
|
|
@@ -22297,33 +23007,20 @@ var Documents = class Documents extends DocComponent {
|
|
|
22297
23007
|
this._drawLiquid.translateSave();
|
|
22298
23008
|
this._drawLiquid.translateLine(line, true, true);
|
|
22299
23009
|
const { y } = this._drawLiquid;
|
|
22300
|
-
if (isHeader) {
|
|
22301
|
-
if (y - originY + alignOffset.y
|
|
23010
|
+
if (!isHeader) {
|
|
23011
|
+
if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
|
|
22302
23012
|
this._drawLiquid.translateRestore();
|
|
22303
23013
|
continue;
|
|
22304
23014
|
}
|
|
22305
|
-
} else if (y - originY + alignOffset.y + lineHeight < (parentPage.pageHeight - 100) / 2 + 100) {
|
|
22306
|
-
this._drawLiquid.translateRestore();
|
|
22307
|
-
continue;
|
|
22308
23015
|
}
|
|
23016
|
+
this._drawLineBackground(ctx, page, line, parentPage.marginLeft);
|
|
22309
23017
|
const divideLength = divides.length;
|
|
22310
23018
|
for (let i = 0; i < divideLength; i++) {
|
|
22311
23019
|
const divide = divides[i];
|
|
22312
23020
|
const { glyphGroup } = divide;
|
|
22313
23021
|
this._drawLiquid.translateSave();
|
|
22314
23022
|
this._drawLiquid.translateDivide(divide);
|
|
22315
|
-
|
|
22316
|
-
if (!glyph.content || glyph.content.length === 0) continue;
|
|
22317
|
-
const { width: spanWidth, left: spanLeft } = glyph;
|
|
22318
|
-
const { x: translateX, y: translateY } = this._drawLiquid;
|
|
22319
|
-
const originTranslate = Vector2.create(translateX, translateY);
|
|
22320
|
-
const centerPoint = Vector2.create(spanWidth / 2, lineHeight / 2);
|
|
22321
|
-
const extensionOffset = { spanStartPoint: calculateRectRotate(originTranslate.addByPoint(spanLeft, 0), centerPoint, centerAngle, vertexAngle, alignOffset) };
|
|
22322
|
-
if (backgroundExtension) {
|
|
22323
|
-
backgroundExtension.extensionOffset = extensionOffset;
|
|
22324
|
-
backgroundExtension.draw(ctx, parentScale, glyph);
|
|
22325
|
-
}
|
|
22326
|
-
}
|
|
23023
|
+
this._drawGlyphGroupBackgrounds(ctx, parentScale, glyphGroup, lineHeight, alignOffset, centerAngle, vertexAngle, backgroundExtension);
|
|
22327
23024
|
for (const glyph of glyphGroup) {
|
|
22328
23025
|
if (!glyph.content || glyph.content.length === 0) continue;
|
|
22329
23026
|
const { width: spanWidth, left: spanLeft, xOffset } = glyph;
|
|
@@ -22359,18 +23056,19 @@ var Documents = class Documents extends DocComponent {
|
|
|
22359
23056
|
* In Excel, if horizontal alignment is not specified,
|
|
22360
23057
|
* rotated text aligns to the right when rotated downwards and aligns to the left when rotated upwards.
|
|
22361
23058
|
*/
|
|
22362
|
-
|
|
23059
|
+
let resolvedHorizontalAlign = horizontalAlign;
|
|
23060
|
+
if (resolvedHorizontalAlign === HorizontalAlign.UNSPECIFIED) if (centerAngleDeg === 90 && vertexAngleDeg === 90) resolvedHorizontalAlign = HorizontalAlign.CENTER;
|
|
22363
23061
|
else if (vertexAngleDeg > 0 && vertexAngleDeg !== 90 || vertexAngleDeg === -90)
|
|
22364
23062
|
/**
|
|
22365
23063
|
* https://github.com/dream-num/univer-pro/issues/334
|
|
22366
23064
|
*/
|
|
22367
|
-
|
|
22368
|
-
else if (cellValueType === CellValueType.NUMBER)
|
|
22369
|
-
else if (cellValueType === CellValueType.BOOLEAN)
|
|
22370
|
-
else
|
|
23065
|
+
resolvedHorizontalAlign = HorizontalAlign.RIGHT;
|
|
23066
|
+
else if (cellValueType === CellValueType.NUMBER) resolvedHorizontalAlign = HorizontalAlign.RIGHT;
|
|
23067
|
+
else if (cellValueType === CellValueType.BOOLEAN) resolvedHorizontalAlign = HorizontalAlign.CENTER;
|
|
23068
|
+
else resolvedHorizontalAlign = HorizontalAlign.LEFT;
|
|
22371
23069
|
let offsetLeft = 0;
|
|
22372
|
-
if (
|
|
22373
|
-
else if (
|
|
23070
|
+
if (resolvedHorizontalAlign === HorizontalAlign.CENTER) offsetLeft = (this.width - pageWidth) / 2;
|
|
23071
|
+
else if (resolvedHorizontalAlign === HorizontalAlign.RIGHT) offsetLeft = this.width - pageWidth - pagePaddingRight;
|
|
22374
23072
|
else offsetLeft = pagePaddingLeft;
|
|
22375
23073
|
return offsetLeft;
|
|
22376
23074
|
}
|
|
@@ -22404,6 +23102,22 @@ function setTableCellBorderDash(ctx, dashStyle) {
|
|
|
22404
23102
|
}
|
|
22405
23103
|
ctx.setLineDash([0]);
|
|
22406
23104
|
}
|
|
23105
|
+
function fillRectByPrecisionBounds(ctx, x, y, width, height) {
|
|
23106
|
+
const { scaleX, scaleY } = ctx.getScale();
|
|
23107
|
+
const startX = fixLineWidthByScale(x, scaleX);
|
|
23108
|
+
const startY = fixLineWidthByScale(y, scaleY);
|
|
23109
|
+
const endX = fixLineWidthByScale(x + width, scaleX);
|
|
23110
|
+
const endY = fixLineWidthByScale(y + height, scaleY);
|
|
23111
|
+
ctx.fillRect(startX, startY, endX - startX, endY - startY);
|
|
23112
|
+
}
|
|
23113
|
+
function rectByPrecisionBounds(ctx, x, y, width, height) {
|
|
23114
|
+
const { scaleX, scaleY } = ctx.getScale();
|
|
23115
|
+
const startX = fixLineWidthByScale(x, scaleX);
|
|
23116
|
+
const startY = fixLineWidthByScale(y, scaleY);
|
|
23117
|
+
const endX = fixLineWidthByScale(x + width, scaleX);
|
|
23118
|
+
const endY = fixLineWidthByScale(y + height, scaleY);
|
|
23119
|
+
ctx.rect(startX, startY, endX - startX, endY - startY);
|
|
23120
|
+
}
|
|
22407
23121
|
|
|
22408
23122
|
//#endregion
|
|
22409
23123
|
//#region src/components/sheets/spreadsheet.ts
|
|
@@ -23616,6 +24330,8 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23616
24330
|
_defineProperty(this, "_pageFillColor", void 0);
|
|
23617
24331
|
_defineProperty(this, "_pageStrokeColor", void 0);
|
|
23618
24332
|
_defineProperty(this, "_marginStrokeColor", void 0);
|
|
24333
|
+
_defineProperty(this, "_pageBackgroundSource", void 0);
|
|
24334
|
+
_defineProperty(this, "_pageBackgroundImage", void 0);
|
|
23619
24335
|
this._drawLiquid = new Liquid();
|
|
23620
24336
|
this._backgroundFillColor = config === null || config === void 0 ? void 0 : config.backgroundFillColor;
|
|
23621
24337
|
this._pageFillColor = config === null || config === void 0 ? void 0 : config.pageFillColor;
|
|
@@ -23639,7 +24355,7 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23639
24355
|
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
23640
24356
|
const docDataModel = (_this$getSkeleton2 = this.getSkeleton()) === null || _this$getSkeleton2 === void 0 ? void 0 : _this$getSkeleton2.getViewModel().getDataModel();
|
|
23641
24357
|
if (skeletonData == null || docDataModel == null) return;
|
|
23642
|
-
const { documentFlavor } = docDataModel.getSnapshot().documentStyle;
|
|
24358
|
+
const { documentFlavor, background } = docDataModel.getSnapshot().documentStyle;
|
|
23643
24359
|
const workspaceFill = (_this$_backgroundFill = this._backgroundFillColor) !== null && _this$_backgroundFill !== void 0 ? _this$_backgroundFill : documentFlavor === DocumentFlavor.MODERN ? PAGE_FILL_COLOR : DOCS_WORKSPACE_FILL_COLOR;
|
|
23644
24360
|
this._drawWorkspaceBackground(ctx, workspaceFill, bounds);
|
|
23645
24361
|
if (documentFlavor === DocumentFlavor.MODERN) return;
|
|
@@ -23668,6 +24384,7 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23668
24384
|
zIndex: 3
|
|
23669
24385
|
};
|
|
23670
24386
|
Rect.drawWith(ctx, backgroundOptions);
|
|
24387
|
+
this._drawPageBackgroundImage(ctx, background === null || background === void 0 ? void 0 : background.source, pageWidth !== null && pageWidth !== void 0 ? pageWidth : width, pageHeight !== null && pageHeight !== void 0 ? pageHeight : height);
|
|
23671
24388
|
const IDENTIFIER_WIDTH = 15;
|
|
23672
24389
|
const marginIdentification = {
|
|
23673
24390
|
dataArray: [
|
|
@@ -23748,6 +24465,22 @@ var DocBackground = class DocBackground extends DocComponent {
|
|
|
23748
24465
|
});
|
|
23749
24466
|
ctx.restore();
|
|
23750
24467
|
}
|
|
24468
|
+
_drawPageBackgroundImage(ctx, source, width, height) {
|
|
24469
|
+
if (!source || width <= 0 || height <= 0) return;
|
|
24470
|
+
const image = this._getPageBackgroundImage(source);
|
|
24471
|
+
if (!image.complete) return;
|
|
24472
|
+
ctx.drawImage(image, 0, 0, width, height);
|
|
24473
|
+
}
|
|
24474
|
+
_getPageBackgroundImage(source) {
|
|
24475
|
+
if (this._pageBackgroundSource === source && this._pageBackgroundImage != null) return this._pageBackgroundImage;
|
|
24476
|
+
const image = document.createElement("img");
|
|
24477
|
+
image.crossOrigin = "anonymous";
|
|
24478
|
+
image.onload = () => this.makeDirty(true);
|
|
24479
|
+
image.src = source;
|
|
24480
|
+
this._pageBackgroundSource = source;
|
|
24481
|
+
this._pageBackgroundImage = image;
|
|
24482
|
+
return image;
|
|
24483
|
+
}
|
|
23751
24484
|
changeSkeleton(newSkeleton) {
|
|
23752
24485
|
this.setSkeleton(newSkeleton);
|
|
23753
24486
|
return this;
|
|
@@ -24184,6 +24917,42 @@ var DumbCanvasColorService = class {
|
|
|
24184
24917
|
return color;
|
|
24185
24918
|
}
|
|
24186
24919
|
};
|
|
24920
|
+
const DARK_RENDER_COLOR_OVERRIDES = {
|
|
24921
|
+
"#17212b": "#e2e8f0",
|
|
24922
|
+
"#64748b": "#94a3b8",
|
|
24923
|
+
"#d9e0e7": "#253044",
|
|
24924
|
+
"#edf1f5": "#1b2535",
|
|
24925
|
+
"#eef2f6": "#1b2535",
|
|
24926
|
+
"#f2f5f8": "#101827",
|
|
24927
|
+
"#f3f6fa": "#18243a",
|
|
24928
|
+
"#f4f8ff": "#172a46",
|
|
24929
|
+
"#f5f9ff": "#12233a",
|
|
24930
|
+
"#f7f9fb": "#0d1422",
|
|
24931
|
+
"#f7f9fc": "#0d1422",
|
|
24932
|
+
"#f8fafc": "#0f172a",
|
|
24933
|
+
"#fbfcfd": "#07111f",
|
|
24934
|
+
"#fcfdff": "#050914",
|
|
24935
|
+
"#e8f1ff": "#173a69",
|
|
24936
|
+
"#eaf5ff": "#12315a",
|
|
24937
|
+
"#dbeafe": "#1e3a8a",
|
|
24938
|
+
"#bfdbfe": "#60a5fa",
|
|
24939
|
+
"#93c5fd": "#60a5fa",
|
|
24940
|
+
"#8eb6f5": "#60a5fa",
|
|
24941
|
+
"#60a5fa": "#60a5fa",
|
|
24942
|
+
"#2563eb": "#60a5fa",
|
|
24943
|
+
"#1d64d8": "#93c5fd",
|
|
24944
|
+
"#1d5cff": "#60a5fa",
|
|
24945
|
+
"#0f766e": "#2dd4bf",
|
|
24946
|
+
"#d7f4ef": "#134e4a",
|
|
24947
|
+
"rgba(37,99,235,0.05)": "rgba(96,165,250,0.16)",
|
|
24948
|
+
"rgba(37,99,235,0.06)": "rgba(96,165,250,0.18)",
|
|
24949
|
+
"rgba(37,99,235,0.08)": "rgba(96,165,250,0.22)",
|
|
24950
|
+
"rgba(37,99,235,0.12)": "rgba(96,165,250,0.26)",
|
|
24951
|
+
"rgba(37,99,235,0.18)": "rgba(96,165,250,0.30)",
|
|
24952
|
+
"rgba(37,99,235,0.28)": "rgba(96,165,250,0.38)",
|
|
24953
|
+
"rgba(239,246,255,0.88)": "rgba(30,64,175,0.72)",
|
|
24954
|
+
"rgba(148,163,184,0.45)": "rgba(148,163,184,0.52)"
|
|
24955
|
+
};
|
|
24187
24956
|
let CanvasColorService = class CanvasColorService extends Disposable {
|
|
24188
24957
|
constructor(_themeService) {
|
|
24189
24958
|
super();
|
|
@@ -24194,8 +24963,14 @@ let CanvasColorService = class CanvasColorService extends Disposable {
|
|
|
24194
24963
|
getRenderColor(color) {
|
|
24195
24964
|
if (!this._themeService.darkMode) return color;
|
|
24196
24965
|
if (this._cache.has(color)) return this._cache.get(color);
|
|
24966
|
+
if (normalizeRenderColor(color) === "transparent") {
|
|
24967
|
+
this._cache.set(color, "transparent");
|
|
24968
|
+
return "transparent";
|
|
24969
|
+
}
|
|
24197
24970
|
let cachedColor = "";
|
|
24198
|
-
|
|
24971
|
+
const mappedColor = getDarkRenderColorOverride(color);
|
|
24972
|
+
if (mappedColor) cachedColor = mappedColor;
|
|
24973
|
+
else if (color.startsWith("#")) {
|
|
24199
24974
|
cachedColor = rgbToHex(this._invertAlgo(hexToRgb(color)));
|
|
24200
24975
|
if (color.length === 5) {
|
|
24201
24976
|
const alpha = color.charAt(4);
|
|
@@ -24227,6 +25002,15 @@ let CanvasColorService = class CanvasColorService extends Disposable {
|
|
|
24227
25002
|
}
|
|
24228
25003
|
};
|
|
24229
25004
|
CanvasColorService = __decorate([__decorateParam(0, Inject(ThemeService))], CanvasColorService);
|
|
25005
|
+
function getDarkRenderColorOverride(color) {
|
|
25006
|
+
var _DARK_RENDER_COLOR_OV;
|
|
25007
|
+
return (_DARK_RENDER_COLOR_OV = DARK_RENDER_COLOR_OVERRIDES[normalizeRenderColor(color)]) !== null && _DARK_RENDER_COLOR_OV !== void 0 ? _DARK_RENDER_COLOR_OV : null;
|
|
25008
|
+
}
|
|
25009
|
+
function normalizeRenderColor(color) {
|
|
25010
|
+
const trimmed = color.trim().toLowerCase();
|
|
25011
|
+
if (trimmed.startsWith("rgb")) return trimmed.replace(/\s+/g, "");
|
|
25012
|
+
return trimmed;
|
|
25013
|
+
}
|
|
24230
25014
|
function hexToRgb(_hex) {
|
|
24231
25015
|
const hex = _hex.replace(/^#/, "");
|
|
24232
25016
|
let r;
|
|
@@ -24900,7 +25684,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
24900
25684
|
//#endregion
|
|
24901
25685
|
//#region package.json
|
|
24902
25686
|
var name = "@univerjs/engine-render";
|
|
24903
|
-
var version = "0.
|
|
25687
|
+
var version = "1.0.0-alpha.0";
|
|
24904
25688
|
|
|
24905
25689
|
//#endregion
|
|
24906
25690
|
//#region src/config/config.ts
|
|
@@ -25372,7 +26156,47 @@ const DEFAULT_TRANSFORMER_LAYER_INDEX = 2;
|
|
|
25372
26156
|
const MINI_WIDTH_LIMIT = 20;
|
|
25373
26157
|
const MINI_HEIGHT_LIMIT = 20;
|
|
25374
26158
|
const DEFAULT_CONTROL_PLUS_INDEX = 5e3;
|
|
25375
|
-
const SINGLE_ACTIVE_OBJECT_TYPE_MAP = new Set([6]);
|
|
26159
|
+
const SINGLE_ACTIVE_OBJECT_TYPE_MAP = /* @__PURE__ */ new Set([6]);
|
|
26160
|
+
const ROTATE_ICON_SIZE = 14;
|
|
26161
|
+
var TransformerRotateIcon = class extends Rect {
|
|
26162
|
+
_draw(ctx) {
|
|
26163
|
+
const iconWidth = this.width || ROTATE_ICON_SIZE;
|
|
26164
|
+
const iconHeight = this.height || ROTATE_ICON_SIZE;
|
|
26165
|
+
const scaleX = iconWidth / 24;
|
|
26166
|
+
const scaleY = iconHeight / 24;
|
|
26167
|
+
ctx.save();
|
|
26168
|
+
ctx.scale(scaleX, scaleY);
|
|
26169
|
+
ctx.beginPath();
|
|
26170
|
+
ctx.lineWidth = (this.strokeWidth || 2) / Math.max(scaleX, scaleY);
|
|
26171
|
+
ctx.lineCap = "round";
|
|
26172
|
+
ctx.lineJoin = "round";
|
|
26173
|
+
ctx.strokeStyle = this.stroke || "currentColor";
|
|
26174
|
+
ctx.moveTo(21, 12);
|
|
26175
|
+
ctx.arc(12, 12, 9, 0, Math.PI * 1.5, false);
|
|
26176
|
+
ctx.bezierCurveTo(14.52, 3, 16.93, 4, 18.74, 5.74);
|
|
26177
|
+
ctx.lineTo(21, 8);
|
|
26178
|
+
ctx.moveTo(21, 3);
|
|
26179
|
+
ctx.lineTo(21, 8);
|
|
26180
|
+
ctx.lineTo(16, 8);
|
|
26181
|
+
ctx.stroke();
|
|
26182
|
+
ctx.restore();
|
|
26183
|
+
}
|
|
26184
|
+
};
|
|
26185
|
+
var TransformerAnchor = class extends Rect {
|
|
26186
|
+
_draw(ctx) {
|
|
26187
|
+
if (!this.shadowColor || !this.shadowBlur && !this.shadowOffsetX && !this.shadowOffsetY) {
|
|
26188
|
+
Rect.drawWith(ctx, this);
|
|
26189
|
+
return;
|
|
26190
|
+
}
|
|
26191
|
+
ctx.save();
|
|
26192
|
+
ctx.shadowColor = this.shadowColor;
|
|
26193
|
+
ctx.shadowBlur = this.shadowBlur;
|
|
26194
|
+
ctx.shadowOffsetX = this.shadowOffsetX;
|
|
26195
|
+
ctx.shadowOffsetY = this.shadowOffsetY;
|
|
26196
|
+
Rect.drawWith(ctx, this);
|
|
26197
|
+
ctx.restore();
|
|
26198
|
+
}
|
|
26199
|
+
};
|
|
25376
26200
|
/**
|
|
25377
26201
|
* Transformer constructor. Transformer is a special type of group that allow you transform
|
|
25378
26202
|
* primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
|
|
@@ -25391,8 +26215,16 @@ var Transformer = class extends Disposable {
|
|
|
25391
26215
|
_defineProperty(this, "rotationSnaps", []);
|
|
25392
26216
|
_defineProperty(this, "rotationSnapTolerance", 5);
|
|
25393
26217
|
_defineProperty(this, "rotateAnchorOffset", 50);
|
|
26218
|
+
_defineProperty(this, "rotateAnchorPosition", "top");
|
|
26219
|
+
_defineProperty(this, "rotateLineEnabled", true);
|
|
25394
26220
|
_defineProperty(this, "rotateSize", 10);
|
|
25395
26221
|
_defineProperty(this, "rotateCornerRadius", 10);
|
|
26222
|
+
_defineProperty(this, "rotateFill", void 0);
|
|
26223
|
+
_defineProperty(this, "rotateStroke", void 0);
|
|
26224
|
+
_defineProperty(this, "rotateStrokeWidth", void 0);
|
|
26225
|
+
_defineProperty(this, "rotateIconEnabled", false);
|
|
26226
|
+
_defineProperty(this, "rotateIconStroke", void 0);
|
|
26227
|
+
_defineProperty(this, "rotateIconStrokeWidth", 1.5);
|
|
25396
26228
|
_defineProperty(this, "borderEnabled", true);
|
|
25397
26229
|
_defineProperty(this, "borderStroke", "rgb(97, 97, 97)");
|
|
25398
26230
|
_defineProperty(this, "borderStrokeWidth", 1);
|
|
@@ -25403,10 +26235,19 @@ var Transformer = class extends Disposable {
|
|
|
25403
26235
|
_defineProperty(this, "anchorStrokeWidth", 1);
|
|
25404
26236
|
_defineProperty(this, "anchorSize", 10);
|
|
25405
26237
|
_defineProperty(this, "anchorCornerRadius", 10);
|
|
26238
|
+
_defineProperty(this, "anchorStyle", "default");
|
|
26239
|
+
_defineProperty(this, "anchorSideLongSize", 16);
|
|
26240
|
+
_defineProperty(this, "anchorSideShortSize", 5);
|
|
26241
|
+
_defineProperty(this, "anchorSideCornerRadius", 2.5);
|
|
26242
|
+
_defineProperty(this, "anchorShadowColor", void 0);
|
|
26243
|
+
_defineProperty(this, "anchorShadowBlur", 0);
|
|
26244
|
+
_defineProperty(this, "anchorShadowOffsetX", 0);
|
|
26245
|
+
_defineProperty(this, "anchorShadowOffsetY", 0);
|
|
25406
26246
|
_defineProperty(this, "keepRatio", true);
|
|
25407
26247
|
_defineProperty(this, "centeredScaling", false);
|
|
25408
26248
|
_defineProperty(this, "zeroLeft", 0);
|
|
25409
26249
|
_defineProperty(this, "zeroTop", 0);
|
|
26250
|
+
_defineProperty(this, "moveBoundaryEnabled", true);
|
|
25410
26251
|
_defineProperty(
|
|
25411
26252
|
this,
|
|
25412
26253
|
/**
|
|
@@ -25520,9 +26361,9 @@ var Transformer = class extends Disposable {
|
|
|
25520
26361
|
}
|
|
25521
26362
|
_getConfig(applyObject) {
|
|
25522
26363
|
const objectTransformerConfig = applyObject.transformerConfig;
|
|
25523
|
-
let { isCropper, hoverEnabled, hoverEnterFunc, hoverLeaveFunc, resizeEnabled, rotateEnabled, rotationSnaps, rotationSnapTolerance, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderDash, borderSpacing, anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorCornerRadius, keepRatio, centeredScaling, enabledAnchors, flipEnabled, ignoreStroke, boundBoxFunc, useSingleNodeRotation, shouldOverdrawWholeArea } = this;
|
|
26364
|
+
let { isCropper, hoverEnabled, hoverEnterFunc, hoverLeaveFunc, resizeEnabled, rotateEnabled, rotationSnaps, rotationSnapTolerance, rotateAnchorOffset, rotateAnchorPosition, rotateLineEnabled, rotateSize, rotateCornerRadius, rotateFill, rotateStroke, rotateStrokeWidth, rotateIconEnabled, rotateIconStroke, rotateIconStrokeWidth, borderEnabled, borderStroke, borderStrokeWidth, borderDash, borderSpacing, anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorCornerRadius, anchorStyle, anchorSideLongSize, anchorSideShortSize, anchorSideCornerRadius, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY, keepRatio, centeredScaling, enabledAnchors, flipEnabled, ignoreStroke, boundBoxFunc, useSingleNodeRotation, shouldOverdrawWholeArea, moveBoundaryEnabled } = this;
|
|
25524
26365
|
if (objectTransformerConfig != null) {
|
|
25525
|
-
var _objectTransformerCon, _objectTransformerCon2, _objectTransformerCon3, _objectTransformerCon4, _objectTransformerCon5, _objectTransformerCon6, _objectTransformerCon7, _objectTransformerCon8, _objectTransformerCon9, _objectTransformerCon10, _objectTransformerCon11, _objectTransformerCon12, _objectTransformerCon13, _objectTransformerCon14, _objectTransformerCon15, _objectTransformerCon16, _objectTransformerCon17, _objectTransformerCon18, _objectTransformerCon19, _objectTransformerCon20, _objectTransformerCon21, _objectTransformerCon22, _objectTransformerCon23, _objectTransformerCon24, _objectTransformerCon25, _objectTransformerCon26, _objectTransformerCon27, _objectTransformerCon28, _objectTransformerCon29;
|
|
26366
|
+
var _objectTransformerCon, _objectTransformerCon2, _objectTransformerCon3, _objectTransformerCon4, _objectTransformerCon5, _objectTransformerCon6, _objectTransformerCon7, _objectTransformerCon8, _objectTransformerCon9, _objectTransformerCon10, _objectTransformerCon11, _objectTransformerCon12, _objectTransformerCon13, _objectTransformerCon14, _objectTransformerCon15, _objectTransformerCon16, _objectTransformerCon17, _objectTransformerCon18, _objectTransformerCon19, _objectTransformerCon20, _objectTransformerCon21, _objectTransformerCon22, _objectTransformerCon23, _objectTransformerCon24, _objectTransformerCon25, _objectTransformerCon26, _objectTransformerCon27, _objectTransformerCon28, _objectTransformerCon29, _objectTransformerCon30, _objectTransformerCon31, _objectTransformerCon32, _objectTransformerCon33, _objectTransformerCon34, _objectTransformerCon35, _objectTransformerCon36, _objectTransformerCon37, _objectTransformerCon38, _objectTransformerCon39, _objectTransformerCon40, _objectTransformerCon41, _objectTransformerCon42, _objectTransformerCon43, _objectTransformerCon44, _objectTransformerCon45, _objectTransformerCon46;
|
|
25526
26367
|
isCropper = (_objectTransformerCon = objectTransformerConfig.isCropper) !== null && _objectTransformerCon !== void 0 ? _objectTransformerCon : isCropper;
|
|
25527
26368
|
hoverEnabled = (_objectTransformerCon2 = objectTransformerConfig.hoverEnabled) !== null && _objectTransformerCon2 !== void 0 ? _objectTransformerCon2 : hoverEnabled;
|
|
25528
26369
|
hoverEnterFunc = (_objectTransformerCon3 = objectTransformerConfig.hoverEnterFunc) !== null && _objectTransformerCon3 !== void 0 ? _objectTransformerCon3 : hoverEnterFunc;
|
|
@@ -25532,26 +26373,43 @@ var Transformer = class extends Disposable {
|
|
|
25532
26373
|
rotationSnaps = (_objectTransformerCon7 = objectTransformerConfig.rotationSnaps) !== null && _objectTransformerCon7 !== void 0 ? _objectTransformerCon7 : rotationSnaps;
|
|
25533
26374
|
rotationSnapTolerance = (_objectTransformerCon8 = objectTransformerConfig.rotationSnapTolerance) !== null && _objectTransformerCon8 !== void 0 ? _objectTransformerCon8 : rotationSnapTolerance;
|
|
25534
26375
|
rotateAnchorOffset = (_objectTransformerCon9 = objectTransformerConfig.rotateAnchorOffset) !== null && _objectTransformerCon9 !== void 0 ? _objectTransformerCon9 : rotateAnchorOffset;
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
25538
|
-
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
|
|
25546
|
-
|
|
25547
|
-
|
|
25548
|
-
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25552
|
-
|
|
25553
|
-
|
|
25554
|
-
|
|
26376
|
+
rotateAnchorPosition = (_objectTransformerCon10 = objectTransformerConfig.rotateAnchorPosition) !== null && _objectTransformerCon10 !== void 0 ? _objectTransformerCon10 : rotateAnchorPosition;
|
|
26377
|
+
rotateLineEnabled = (_objectTransformerCon11 = objectTransformerConfig.rotateLineEnabled) !== null && _objectTransformerCon11 !== void 0 ? _objectTransformerCon11 : rotateLineEnabled;
|
|
26378
|
+
rotateSize = (_objectTransformerCon12 = objectTransformerConfig.rotateSize) !== null && _objectTransformerCon12 !== void 0 ? _objectTransformerCon12 : rotateSize;
|
|
26379
|
+
rotateCornerRadius = (_objectTransformerCon13 = objectTransformerConfig.rotateCornerRadius) !== null && _objectTransformerCon13 !== void 0 ? _objectTransformerCon13 : rotateCornerRadius;
|
|
26380
|
+
rotateFill = (_objectTransformerCon14 = objectTransformerConfig.rotateFill) !== null && _objectTransformerCon14 !== void 0 ? _objectTransformerCon14 : rotateFill;
|
|
26381
|
+
rotateStroke = (_objectTransformerCon15 = objectTransformerConfig.rotateStroke) !== null && _objectTransformerCon15 !== void 0 ? _objectTransformerCon15 : rotateStroke;
|
|
26382
|
+
rotateStrokeWidth = (_objectTransformerCon16 = objectTransformerConfig.rotateStrokeWidth) !== null && _objectTransformerCon16 !== void 0 ? _objectTransformerCon16 : rotateStrokeWidth;
|
|
26383
|
+
rotateIconEnabled = (_objectTransformerCon17 = objectTransformerConfig.rotateIconEnabled) !== null && _objectTransformerCon17 !== void 0 ? _objectTransformerCon17 : rotateIconEnabled;
|
|
26384
|
+
rotateIconStroke = (_objectTransformerCon18 = objectTransformerConfig.rotateIconStroke) !== null && _objectTransformerCon18 !== void 0 ? _objectTransformerCon18 : rotateIconStroke;
|
|
26385
|
+
rotateIconStrokeWidth = (_objectTransformerCon19 = objectTransformerConfig.rotateIconStrokeWidth) !== null && _objectTransformerCon19 !== void 0 ? _objectTransformerCon19 : rotateIconStrokeWidth;
|
|
26386
|
+
borderEnabled = (_objectTransformerCon20 = objectTransformerConfig.borderEnabled) !== null && _objectTransformerCon20 !== void 0 ? _objectTransformerCon20 : borderEnabled;
|
|
26387
|
+
borderStroke = (_objectTransformerCon21 = objectTransformerConfig.borderStroke) !== null && _objectTransformerCon21 !== void 0 ? _objectTransformerCon21 : borderStroke;
|
|
26388
|
+
borderStrokeWidth = (_objectTransformerCon22 = objectTransformerConfig.borderStrokeWidth) !== null && _objectTransformerCon22 !== void 0 ? _objectTransformerCon22 : borderStrokeWidth;
|
|
26389
|
+
borderDash = (_objectTransformerCon23 = objectTransformerConfig.borderDash) !== null && _objectTransformerCon23 !== void 0 ? _objectTransformerCon23 : borderDash;
|
|
26390
|
+
borderSpacing = (_objectTransformerCon24 = objectTransformerConfig.borderSpacing) !== null && _objectTransformerCon24 !== void 0 ? _objectTransformerCon24 : borderSpacing;
|
|
26391
|
+
anchorFill = (_objectTransformerCon25 = objectTransformerConfig.anchorFill) !== null && _objectTransformerCon25 !== void 0 ? _objectTransformerCon25 : anchorFill;
|
|
26392
|
+
anchorStroke = (_objectTransformerCon26 = objectTransformerConfig.anchorStroke) !== null && _objectTransformerCon26 !== void 0 ? _objectTransformerCon26 : anchorStroke;
|
|
26393
|
+
anchorStrokeWidth = (_objectTransformerCon27 = objectTransformerConfig.anchorStrokeWidth) !== null && _objectTransformerCon27 !== void 0 ? _objectTransformerCon27 : anchorStrokeWidth;
|
|
26394
|
+
anchorSize = (_objectTransformerCon28 = objectTransformerConfig.anchorSize) !== null && _objectTransformerCon28 !== void 0 ? _objectTransformerCon28 : anchorSize;
|
|
26395
|
+
anchorCornerRadius = (_objectTransformerCon29 = objectTransformerConfig.anchorCornerRadius) !== null && _objectTransformerCon29 !== void 0 ? _objectTransformerCon29 : anchorCornerRadius;
|
|
26396
|
+
anchorStyle = (_objectTransformerCon30 = objectTransformerConfig.anchorStyle) !== null && _objectTransformerCon30 !== void 0 ? _objectTransformerCon30 : anchorStyle;
|
|
26397
|
+
anchorSideLongSize = (_objectTransformerCon31 = objectTransformerConfig.anchorSideLongSize) !== null && _objectTransformerCon31 !== void 0 ? _objectTransformerCon31 : anchorSideLongSize;
|
|
26398
|
+
anchorSideShortSize = (_objectTransformerCon32 = objectTransformerConfig.anchorSideShortSize) !== null && _objectTransformerCon32 !== void 0 ? _objectTransformerCon32 : anchorSideShortSize;
|
|
26399
|
+
anchorSideCornerRadius = (_objectTransformerCon33 = objectTransformerConfig.anchorSideCornerRadius) !== null && _objectTransformerCon33 !== void 0 ? _objectTransformerCon33 : anchorSideCornerRadius;
|
|
26400
|
+
anchorShadowColor = (_objectTransformerCon34 = objectTransformerConfig.anchorShadowColor) !== null && _objectTransformerCon34 !== void 0 ? _objectTransformerCon34 : anchorShadowColor;
|
|
26401
|
+
anchorShadowBlur = (_objectTransformerCon35 = objectTransformerConfig.anchorShadowBlur) !== null && _objectTransformerCon35 !== void 0 ? _objectTransformerCon35 : anchorShadowBlur;
|
|
26402
|
+
anchorShadowOffsetX = (_objectTransformerCon36 = objectTransformerConfig.anchorShadowOffsetX) !== null && _objectTransformerCon36 !== void 0 ? _objectTransformerCon36 : anchorShadowOffsetX;
|
|
26403
|
+
anchorShadowOffsetY = (_objectTransformerCon37 = objectTransformerConfig.anchorShadowOffsetY) !== null && _objectTransformerCon37 !== void 0 ? _objectTransformerCon37 : anchorShadowOffsetY;
|
|
26404
|
+
keepRatio = (_objectTransformerCon38 = objectTransformerConfig.keepRatio) !== null && _objectTransformerCon38 !== void 0 ? _objectTransformerCon38 : keepRatio;
|
|
26405
|
+
centeredScaling = (_objectTransformerCon39 = objectTransformerConfig.centeredScaling) !== null && _objectTransformerCon39 !== void 0 ? _objectTransformerCon39 : centeredScaling;
|
|
26406
|
+
enabledAnchors = (_objectTransformerCon40 = objectTransformerConfig.enabledAnchors) !== null && _objectTransformerCon40 !== void 0 ? _objectTransformerCon40 : enabledAnchors;
|
|
26407
|
+
flipEnabled = (_objectTransformerCon41 = objectTransformerConfig.flipEnabled) !== null && _objectTransformerCon41 !== void 0 ? _objectTransformerCon41 : flipEnabled;
|
|
26408
|
+
ignoreStroke = (_objectTransformerCon42 = objectTransformerConfig.ignoreStroke) !== null && _objectTransformerCon42 !== void 0 ? _objectTransformerCon42 : ignoreStroke;
|
|
26409
|
+
boundBoxFunc = (_objectTransformerCon43 = objectTransformerConfig.boundBoxFunc) !== null && _objectTransformerCon43 !== void 0 ? _objectTransformerCon43 : boundBoxFunc;
|
|
26410
|
+
useSingleNodeRotation = (_objectTransformerCon44 = objectTransformerConfig.useSingleNodeRotation) !== null && _objectTransformerCon44 !== void 0 ? _objectTransformerCon44 : useSingleNodeRotation;
|
|
26411
|
+
shouldOverdrawWholeArea = (_objectTransformerCon45 = objectTransformerConfig.shouldOverdrawWholeArea) !== null && _objectTransformerCon45 !== void 0 ? _objectTransformerCon45 : shouldOverdrawWholeArea;
|
|
26412
|
+
moveBoundaryEnabled = (_objectTransformerCon46 = objectTransformerConfig.moveBoundaryEnabled) !== null && _objectTransformerCon46 !== void 0 ? _objectTransformerCon46 : moveBoundaryEnabled;
|
|
25555
26413
|
}
|
|
25556
26414
|
return {
|
|
25557
26415
|
isCropper,
|
|
@@ -25563,8 +26421,16 @@ var Transformer = class extends Disposable {
|
|
|
25563
26421
|
rotationSnaps,
|
|
25564
26422
|
rotationSnapTolerance,
|
|
25565
26423
|
rotateAnchorOffset,
|
|
26424
|
+
rotateAnchorPosition,
|
|
26425
|
+
rotateLineEnabled,
|
|
25566
26426
|
rotateSize,
|
|
25567
26427
|
rotateCornerRadius,
|
|
26428
|
+
rotateFill,
|
|
26429
|
+
rotateStroke,
|
|
26430
|
+
rotateStrokeWidth,
|
|
26431
|
+
rotateIconEnabled,
|
|
26432
|
+
rotateIconStroke,
|
|
26433
|
+
rotateIconStrokeWidth,
|
|
25568
26434
|
borderEnabled,
|
|
25569
26435
|
borderStroke,
|
|
25570
26436
|
borderStrokeWidth,
|
|
@@ -25575,6 +26441,14 @@ var Transformer = class extends Disposable {
|
|
|
25575
26441
|
anchorStrokeWidth,
|
|
25576
26442
|
anchorSize,
|
|
25577
26443
|
anchorCornerRadius,
|
|
26444
|
+
anchorStyle,
|
|
26445
|
+
anchorSideLongSize,
|
|
26446
|
+
anchorSideShortSize,
|
|
26447
|
+
anchorSideCornerRadius,
|
|
26448
|
+
anchorShadowColor,
|
|
26449
|
+
anchorShadowBlur,
|
|
26450
|
+
anchorShadowOffsetX,
|
|
26451
|
+
anchorShadowOffsetY,
|
|
25578
26452
|
keepRatio,
|
|
25579
26453
|
centeredScaling,
|
|
25580
26454
|
enabledAnchors,
|
|
@@ -25582,7 +26456,8 @@ var Transformer = class extends Disposable {
|
|
|
25582
26456
|
ignoreStroke,
|
|
25583
26457
|
boundBoxFunc,
|
|
25584
26458
|
useSingleNodeRotation,
|
|
25585
|
-
shouldOverdrawWholeArea
|
|
26459
|
+
shouldOverdrawWholeArea,
|
|
26460
|
+
moveBoundaryEnabled
|
|
25586
26461
|
};
|
|
25587
26462
|
}
|
|
25588
26463
|
attachTo(applyObject) {
|
|
@@ -25616,7 +26491,7 @@ var Transformer = class extends Disposable {
|
|
|
25616
26491
|
this._copperSelectedObject = applyObject;
|
|
25617
26492
|
this._changeStart$.next({
|
|
25618
26493
|
target: applyObject,
|
|
25619
|
-
objects: new Map([[applyObject.oKey, applyObject]]),
|
|
26494
|
+
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
25620
26495
|
type: 0
|
|
25621
26496
|
});
|
|
25622
26497
|
}
|
|
@@ -25644,7 +26519,7 @@ var Transformer = class extends Disposable {
|
|
|
25644
26519
|
event
|
|
25645
26520
|
});
|
|
25646
26521
|
else this._changeEnd$.next({
|
|
25647
|
-
objects: new Map([[applyObject.oKey, applyObject]]),
|
|
26522
|
+
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
25648
26523
|
type: 2,
|
|
25649
26524
|
offsetX,
|
|
25650
26525
|
offsetY,
|
|
@@ -25691,6 +26566,10 @@ var Transformer = class extends Disposable {
|
|
|
25691
26566
|
});
|
|
25692
26567
|
}
|
|
25693
26568
|
_checkMoveBoundary(moveObject, moveLeft, moveTop, ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight) {
|
|
26569
|
+
if (this._getConfig(moveObject).moveBoundaryEnabled === false) return {
|
|
26570
|
+
moveLeft,
|
|
26571
|
+
moveTop
|
|
26572
|
+
};
|
|
25694
26573
|
const { left, top, width, height } = moveObject;
|
|
25695
26574
|
let resultMoveLeft = moveLeft;
|
|
25696
26575
|
let resultMoveTop = moveTop;
|
|
@@ -25740,7 +26619,7 @@ var Transformer = class extends Disposable {
|
|
|
25740
26619
|
moveTop = boundary.moveTop;
|
|
25741
26620
|
cropper.translate(moveLeft + cropper.left, moveTop + cropper.top);
|
|
25742
26621
|
this._changing$.next({
|
|
25743
|
-
objects: new Map([[cropper.oKey, cropper]]),
|
|
26622
|
+
objects: /* @__PURE__ */ new Map([[cropper.oKey, cropper]]),
|
|
25744
26623
|
moveX: moveLeft,
|
|
25745
26624
|
moveY: moveTop,
|
|
25746
26625
|
type: 1,
|
|
@@ -25775,7 +26654,7 @@ var Transformer = class extends Disposable {
|
|
|
25775
26654
|
} else {
|
|
25776
26655
|
this._moveFunc(applyObject, type, x, y, keepRatio, isCropper, isGroup);
|
|
25777
26656
|
this._changing$.next({
|
|
25778
|
-
objects: new Map([[applyObject.oKey, applyObject]]),
|
|
26657
|
+
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
25779
26658
|
type: 1,
|
|
25780
26659
|
offsetX: moveOffsetX,
|
|
25781
26660
|
offsetY: moveOffsetY
|
|
@@ -26022,7 +26901,7 @@ var Transformer = class extends Disposable {
|
|
|
26022
26901
|
});
|
|
26023
26902
|
} else {
|
|
26024
26903
|
this._changeStart$.next({
|
|
26025
|
-
objects: new Map([[applyObject.oKey, applyObject]]),
|
|
26904
|
+
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
26026
26905
|
type: 0
|
|
26027
26906
|
});
|
|
26028
26907
|
const { width, height, left, top } = applyObject.getState();
|
|
@@ -26063,7 +26942,7 @@ var Transformer = class extends Disposable {
|
|
|
26063
26942
|
} else {
|
|
26064
26943
|
this._recoverySizeBoundary([applyObject], ancestorLeft, ancestorTop, topSceneWidth, topSceneHeight);
|
|
26065
26944
|
this._changeEnd$.next({
|
|
26066
|
-
objects: new Map([[applyObject.oKey, applyObject]]),
|
|
26945
|
+
objects: /* @__PURE__ */ new Map([[applyObject.oKey, applyObject]]),
|
|
26067
26946
|
type: 2,
|
|
26068
26947
|
offsetX,
|
|
26069
26948
|
offsetY,
|
|
@@ -26138,7 +27017,11 @@ var Transformer = class extends Disposable {
|
|
|
26138
27017
|
_rotateMoving(moveOffsetX, moveOffsetY, centerX, centerY, agentOrigin) {
|
|
26139
27018
|
const { ancestorScaleX, ancestorScaleY } = this._scene;
|
|
26140
27019
|
if (this._moveBufferBlocker(moveOffsetX, moveOffsetY)) return;
|
|
26141
|
-
|
|
27020
|
+
const moveSceneX = moveOffsetX / ancestorScaleX + this._viewportScrollX;
|
|
27021
|
+
const moveSceneY = moveOffsetY / ancestorScaleY + this._viewportScrollY;
|
|
27022
|
+
const startSceneX = this._startOffsetX / ancestorScaleX + this._viewportScrollX;
|
|
27023
|
+
const startSceneY = this._startOffsetY / ancestorScaleY + this._viewportScrollY;
|
|
27024
|
+
let angle = agentOrigin + radToDeg(Math.atan2(moveSceneY - centerY, moveSceneX - centerX) - Math.atan2(startSceneY - centerY, startSceneX - centerX));
|
|
26142
27025
|
if (angle < 0) angle = 360 + angle;
|
|
26143
27026
|
angle %= 360;
|
|
26144
27027
|
angle = this._smoothAccuracy(angle);
|
|
@@ -26195,6 +27078,23 @@ var Transformer = class extends Disposable {
|
|
|
26195
27078
|
}
|
|
26196
27079
|
return cursor;
|
|
26197
27080
|
}
|
|
27081
|
+
_createRotateIcon(applyObject, zIndex, left, top) {
|
|
27082
|
+
const { rotateSize, rotateIconStroke, rotateIconStrokeWidth, borderStroke } = this._getConfig(applyObject);
|
|
27083
|
+
const iconOffset = (rotateSize - ROTATE_ICON_SIZE) / 2;
|
|
27084
|
+
return new TransformerRotateIcon(`__SpreadsheetTransformerRotate___ICON_${zIndex}`, {
|
|
27085
|
+
zIndex,
|
|
27086
|
+
evented: false,
|
|
27087
|
+
left: left + iconOffset,
|
|
27088
|
+
top: top + iconOffset,
|
|
27089
|
+
width: ROTATE_ICON_SIZE,
|
|
27090
|
+
height: ROTATE_ICON_SIZE,
|
|
27091
|
+
fill: null,
|
|
27092
|
+
stroke: rotateIconStroke !== null && rotateIconStroke !== void 0 ? rotateIconStroke : borderStroke,
|
|
27093
|
+
strokeWidth: rotateIconStrokeWidth,
|
|
27094
|
+
strokeLineCap: "round",
|
|
27095
|
+
strokeLineJoin: "round"
|
|
27096
|
+
});
|
|
27097
|
+
}
|
|
26198
27098
|
_getCopperAnchorPosition(type, height, width, applyObject) {
|
|
26199
27099
|
const { borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
|
|
26200
27100
|
let left = 0;
|
|
@@ -26241,17 +27141,18 @@ var Transformer = class extends Disposable {
|
|
|
26241
27141
|
};
|
|
26242
27142
|
}
|
|
26243
27143
|
_getRotateAnchorPosition(type, height, width, applyObject) {
|
|
26244
|
-
const { rotateAnchorOffset, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
|
|
27144
|
+
const { rotateAnchorOffset, rotateAnchorPosition, rotateSize, borderStrokeWidth, borderSpacing, anchorSize } = this._getConfig(applyObject);
|
|
27145
|
+
const isBottomRotateAnchor = rotateAnchorPosition === "bottom";
|
|
26245
27146
|
let left = -anchorSize / 2;
|
|
26246
27147
|
let top = -anchorSize / 2;
|
|
26247
27148
|
switch (type) {
|
|
26248
27149
|
case "__SpreadsheetTransformerRotate__":
|
|
26249
27150
|
left = width / 2 - rotateSize / 2;
|
|
26250
|
-
top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
|
|
27151
|
+
top = isBottomRotateAnchor ? height + rotateAnchorOffset + borderSpacing + borderStrokeWidth * 2 : -rotateAnchorOffset - borderSpacing - borderStrokeWidth * 2 - rotateSize;
|
|
26251
27152
|
break;
|
|
26252
27153
|
case "__SpreadsheetTransformerRotateLine__":
|
|
26253
27154
|
left = width / 2;
|
|
26254
|
-
top = -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
|
|
27155
|
+
top = isBottomRotateAnchor ? height + borderSpacing + borderStrokeWidth : -rotateAnchorOffset - borderSpacing - borderStrokeWidth;
|
|
26255
27156
|
break;
|
|
26256
27157
|
case "__SpreadsheetTransformerResizeLT__":
|
|
26257
27158
|
left += -borderSpacing - borderStrokeWidth;
|
|
@@ -26291,21 +27192,43 @@ var Transformer = class extends Disposable {
|
|
|
26291
27192
|
top
|
|
26292
27193
|
};
|
|
26293
27194
|
}
|
|
27195
|
+
_isMiddleAnchor(type) {
|
|
27196
|
+
return type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeLM__" || type === "__SpreadsheetTransformerResizeRM__" || type === "__SpreadsheetTransformerResizeCB__";
|
|
27197
|
+
}
|
|
27198
|
+
_getResizeAnchorProps(type, applyObject) {
|
|
27199
|
+
const { anchorSize, anchorCornerRadius, anchorStyle, anchorSideLongSize, anchorSideShortSize, anchorSideCornerRadius } = this._getConfig(applyObject);
|
|
27200
|
+
if (anchorStyle !== "canva" || !this._isMiddleAnchor(type)) return {
|
|
27201
|
+
width: anchorSize,
|
|
27202
|
+
height: anchorSize,
|
|
27203
|
+
radius: anchorStyle === "canva" ? anchorSize / 2 : anchorCornerRadius
|
|
27204
|
+
};
|
|
27205
|
+
const isHorizontal = type === "__SpreadsheetTransformerResizeCT__" || type === "__SpreadsheetTransformerResizeCB__";
|
|
27206
|
+
return {
|
|
27207
|
+
width: isHorizontal ? anchorSideLongSize : anchorSideShortSize,
|
|
27208
|
+
height: isHorizontal ? anchorSideShortSize : anchorSideLongSize,
|
|
27209
|
+
radius: anchorSideCornerRadius
|
|
27210
|
+
};
|
|
27211
|
+
}
|
|
26294
27212
|
_createResizeAnchor(type, applyObject, zIndex) {
|
|
26295
27213
|
const { height = 0, width = 0, scaleX = 1, scaleY = 1 } = applyObject.getState();
|
|
26296
|
-
const { anchorFill, anchorStroke, anchorStrokeWidth,
|
|
27214
|
+
const { anchorFill, anchorStroke, anchorStrokeWidth, anchorSize, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY } = this._getConfig(applyObject);
|
|
26297
27215
|
const { left, top } = this._getRotateAnchorPosition(type, height, width, applyObject);
|
|
27216
|
+
const anchorProps = this._getResizeAnchorProps(type, applyObject);
|
|
26298
27217
|
const cursor = this._getRotateAnchorCursor(type);
|
|
26299
|
-
const anchor = new
|
|
27218
|
+
const anchor = new TransformerAnchor(`${type}_${zIndex}`, {
|
|
26300
27219
|
zIndex: zIndex - 1,
|
|
26301
27220
|
fill: anchorFill,
|
|
26302
27221
|
stroke: anchorStroke,
|
|
26303
27222
|
strokeWidth: anchorStrokeWidth,
|
|
26304
|
-
width:
|
|
26305
|
-
height:
|
|
26306
|
-
radius:
|
|
26307
|
-
left,
|
|
26308
|
-
top
|
|
27223
|
+
width: anchorProps.width,
|
|
27224
|
+
height: anchorProps.height,
|
|
27225
|
+
radius: anchorProps.radius,
|
|
27226
|
+
left: left + (anchorSize - anchorProps.width) / 2,
|
|
27227
|
+
top: top + (anchorSize - anchorProps.height) / 2,
|
|
27228
|
+
shadowColor: anchorShadowColor,
|
|
27229
|
+
shadowBlur: anchorShadowBlur,
|
|
27230
|
+
shadowOffsetX: anchorShadowOffsetX,
|
|
27231
|
+
shadowOffsetY: anchorShadowOffsetY
|
|
26309
27232
|
});
|
|
26310
27233
|
this._attachHover(anchor, cursor, "default");
|
|
26311
27234
|
return anchor;
|
|
@@ -26553,7 +27476,7 @@ var Transformer = class extends Disposable {
|
|
|
26553
27476
|
_createControl(applyObject, isSkipOnCropper = true) {
|
|
26554
27477
|
const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState();
|
|
26555
27478
|
const angle = applyObject.angle;
|
|
26556
|
-
const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
|
|
27479
|
+
const { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateLineEnabled, rotateSize, rotateCornerRadius, rotateFill, rotateStroke, rotateStrokeWidth, rotateIconEnabled, anchorShadowColor, anchorShadowBlur, anchorShadowOffsetX, anchorShadowOffsetY, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
|
|
26557
27480
|
if (isSkipOnCropper && isCropper) return;
|
|
26558
27481
|
const oKey = applyObject.oKey;
|
|
26559
27482
|
const zIndex = this._selectedObjectMap.size + applyObject.maxZIndex + DEFAULT_CONTROL_PLUS_INDEX;
|
|
@@ -26584,19 +27507,26 @@ var Transformer = class extends Disposable {
|
|
|
26584
27507
|
});
|
|
26585
27508
|
const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
|
|
26586
27509
|
const cursor = this._getRotateAnchorCursor("__SpreadsheetTransformerRotate__");
|
|
26587
|
-
const rotate = new
|
|
27510
|
+
const rotate = new TransformerAnchor(`__SpreadsheetTransformerRotate___${zIndex}`, {
|
|
26588
27511
|
zIndex: zIndex - 1,
|
|
26589
27512
|
left: rotateLeft,
|
|
26590
27513
|
top: rotateTop,
|
|
26591
27514
|
height: rotateSize,
|
|
26592
27515
|
width: rotateSize,
|
|
26593
27516
|
radius: rotateCornerRadius,
|
|
26594
|
-
|
|
26595
|
-
|
|
27517
|
+
fill: rotateFill,
|
|
27518
|
+
strokeWidth: rotateStrokeWidth !== null && rotateStrokeWidth !== void 0 ? rotateStrokeWidth : borderStrokeWidth * 2,
|
|
27519
|
+
stroke: rotateStroke !== null && rotateStroke !== void 0 ? rotateStroke : borderStroke,
|
|
27520
|
+
shadowColor: anchorShadowColor,
|
|
27521
|
+
shadowBlur: anchorShadowBlur,
|
|
27522
|
+
shadowOffsetX: anchorShadowOffsetX,
|
|
27523
|
+
shadowOffsetY: anchorShadowOffsetY
|
|
26596
27524
|
});
|
|
26597
27525
|
this._attachEventToRotate(rotate, applyObject);
|
|
26598
27526
|
this._attachHover(rotate, cursor, "default");
|
|
26599
|
-
groupElements.push(rotateLine
|
|
27527
|
+
if (rotateLineEnabled) groupElements.push(rotateLine);
|
|
27528
|
+
groupElements.push(rotate);
|
|
27529
|
+
if (rotateIconEnabled) groupElements.push(this._createRotateIcon(applyObject, zIndex, rotateLeft, rotateTop));
|
|
26600
27530
|
}
|
|
26601
27531
|
}
|
|
26602
27532
|
if (resizeEnabled) for (let i = 0, len = enabledAnchors.length; i < len; i++) {
|