@univerjs/engine-render 1.0.0-alpha.7 → 1.0.0-alpha.8
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/af-DK_CjRn6.js +210 -0
- package/lib/as-BPtSu6VN.js +24 -0
- package/lib/be-CrQ0smca.js +24 -0
- package/lib/bg-CrQqGwni.js +24 -0
- package/lib/bn-NCLZcWHi.js +24 -0
- package/lib/ca-SUf6Y2Om.js +51 -0
- package/lib/cjs/index.js +1734 -1786
- package/lib/cop-C3sk0IUo.js +24 -0
- package/lib/cs-CmAteokq.js +30 -0
- package/lib/cu-CBUlrW6Y.js +45 -0
- package/lib/cy-BBPa6z2x.js +24 -0
- package/lib/da-CCDXfXtG.js +24 -0
- package/lib/de-1901-CWoAOigE.js +24 -0
- package/lib/de-1996-BL6awyxG.js +24 -0
- package/lib/de-ch-1901-hVThVHVb.js +24 -0
- package/lib/el-monoton-D3aKqTz2.js +24 -0
- package/lib/el-polyton-ogVWcTzh.js +24 -0
- package/lib/en-gb-B7Al27b_.js +34 -0
- package/lib/es/index.js +1729 -1786
- package/lib/es-DcaaHPU_.js +24 -0
- package/lib/et-B_spaleu.js +24 -0
- package/lib/eu-Ctv_kq9Z.js +24 -0
- package/lib/fi-RW5VB8Yp.js +24 -0
- package/lib/fr-BC2onEz9.js +24 -0
- package/lib/fur-AC12wySk.js +24 -0
- package/lib/ga-Cn6LkudM.js +71 -0
- package/lib/gl-DZGc-K_G.js +24 -0
- package/lib/grc-DOlGgO8T.js +24 -0
- package/lib/gu-Bjl0l-cf.js +24 -0
- package/lib/hi-DsAaTPCC.js +24 -0
- package/lib/hr-DT1SBBes.js +24 -0
- package/lib/hsb-DC_ITc1e.js +59 -0
- package/lib/hu-DVk7Y_ka.js +24 -0
- package/lib/hy-e995ysyO.js +24 -0
- package/lib/ia-Cr4TJH0c.js +35 -0
- package/lib/id-DifDyWg9.js +71 -0
- package/lib/index.js +32032 -0
- package/lib/is-BT8UVRze.js +24 -0
- package/lib/it-Bt_Meacx.js +24 -0
- package/lib/ka-jyoLzyDE.js +24 -0
- package/lib/kmr-Cfwhwuff.js +24 -0
- package/lib/kn-C6Lov-DP.js +24 -0
- package/lib/la-DuvHjUWw.js +24 -0
- package/lib/la-x-classic-yTyAOQEt.js +24 -0
- package/lib/la-x-liturgic-CXeQb4FY.js +24 -0
- package/lib/lt-BBe8DlDF.js +24 -0
- package/lib/lv-Q2BBHnzp.js +24 -0
- package/lib/ml-2xLVYkVY.js +24 -0
- package/lib/mn-cyrl-lHM4n0oC.js +24 -0
- package/lib/mn-cyrl-x-lmc-3aetruI8.js +24 -0
- package/lib/mr-CjWJPVmH.js +24 -0
- package/lib/mul-ethi-D_CMSMEq.js +24 -0
- package/lib/nb-DI8u59ch.js +135 -0
- package/lib/nl-BHQJ6Gvn.js +65 -0
- package/lib/nn-ntZvarUK.js +135 -0
- package/lib/no-B8ItS0F3.js +133 -0
- package/lib/oc-P_i3-xLA.js +24 -0
- package/lib/or-50rxpoq4.js +24 -0
- package/lib/pa-C54UG8eN.js +24 -0
- package/lib/pi-B9cgjyG1.js +24 -0
- package/lib/pl-9fg-ESVt.js +45 -0
- package/lib/pms-BRGfm5gS.js +24 -0
- package/lib/pt-Cum2_NUC.js +24 -0
- package/lib/rm-C0MIK9N4.js +24 -0
- package/lib/ro-0fmdH0HA.js +24 -0
- package/lib/ru-v4l-ayaq.js +209 -0
- package/lib/sa-CKY9c_Vq.js +24 -0
- package/lib/sh-cyrl-BpCRFOmq.js +141 -0
- package/lib/sh-latn-sRy4Tuaj.js +141 -0
- package/lib/sk-_iOeDNrQ.js +30 -0
- package/lib/sl-DpiklF-D.js +24 -0
- package/lib/sr-cyrl-Dpzrbd0W.js +155 -0
- package/lib/sv-CFm5y56M.js +24 -0
- package/lib/ta-BcghgTbD.js +24 -0
- package/lib/te-B5Spl2Jk.js +24 -0
- package/lib/th-DWX5iPSo.js +24 -0
- package/lib/tk-BMbKB10q.js +24 -0
- package/lib/tr-CIHIuzqc.js +24 -0
- package/lib/types/basics/document-node-tools.d.ts +1 -0
- package/lib/types/basics/drawing-effect.d.ts +34 -0
- package/lib/types/basics/i-events.d.ts +0 -6
- package/lib/types/basics/tools.d.ts +1 -22
- package/lib/types/components/docs/document.d.ts +4 -1
- package/lib/types/components/docs/layout/block/paragraph/shaping.d.ts +1 -1
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +8 -0
- package/lib/types/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.d.ts +2 -2
- package/lib/types/components/docs/layout/line-breaker/enhancers/link-enhancer.d.ts +2 -2
- package/lib/types/components/docs/layout/line-breaker/enhancers/whole-entity-enhancer.d.ts +33 -0
- package/lib/types/components/docs/layout/line-breaker/line-breaker.d.ts +1 -0
- package/lib/types/components/docs/layout/model/glyph.d.ts +15 -3
- package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +0 -13
- package/lib/types/components/docs/layout/tools.d.ts +33 -1
- package/lib/types/components/docs/table-render-viewport.d.ts +2 -0
- package/lib/types/components/sheets/sheet.render-skeleton.d.ts +1 -94
- package/lib/types/drawing-group.d.ts +3 -1
- package/lib/types/engine.d.ts +0 -7
- package/lib/types/index.d.ts +4 -2
- package/lib/types/plugin.d.ts +0 -7
- package/lib/types/render-manager/render-manager.service.d.ts +0 -21
- package/lib/types/scene.d.ts +1 -30
- package/lib/types/scene.input-manager.d.ts +1 -3
- package/lib/types/shape/index.d.ts +1 -0
- package/lib/types/shape/line.d.ts +50 -0
- package/lib/types/shape/shape.d.ts +7 -1
- package/lib/types/viewport.d.ts +1 -5
- package/lib/uk-Dir3oxLs.js +24 -0
- package/lib/umd/index.js +2 -3
- package/lib/zh-latn-pinyin-BdYb-Ey_.js +24 -0
- package/package.json +7 -9
- package/lib/types/components/docs/layout/shaping-engine/font-library.d.ts +0 -60
- package/lib/types/components/docs/layout/shaping-engine/text-shaping.d.ts +0 -34
- package/lib/types/services/render-config.service.d.ts +0 -28
package/lib/es/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType,
|
|
2
|
-
import { BehaviorSubject, Observable, Subject, Subscription,
|
|
3
|
-
import { parse } from "opentype.js";
|
|
1
|
+
import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
|
|
2
|
+
import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, shareReplay, startWith } from "rxjs";
|
|
4
3
|
import { franc } from "franc-min";
|
|
5
4
|
import { getOverflowAncestors } from "@floating-ui/dom";
|
|
6
5
|
import { floor, max, min } from "@floating-ui/utils";
|
|
@@ -23,690 +22,81 @@ var __exportAll = (all, no_symbols) => {
|
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
//#endregion
|
|
26
|
-
//#region
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
37
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
-
* See the License for the specific language governing permissions and
|
|
40
|
-
* limitations under the License.
|
|
41
|
-
*/
|
|
42
|
-
let SHAPE_TYPE = /* @__PURE__ */ function(SHAPE_TYPE) {
|
|
43
|
-
SHAPE_TYPE["RECT"] = "rect";
|
|
44
|
-
SHAPE_TYPE["CIRCLE"] = "circle";
|
|
45
|
-
SHAPE_TYPE["PATH"] = "path";
|
|
46
|
-
return SHAPE_TYPE;
|
|
47
|
-
}({});
|
|
48
|
-
let LINK_VIEW_PORT_TYPE = /* @__PURE__ */ function(LINK_VIEW_PORT_TYPE) {
|
|
49
|
-
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["XY"] = 0] = "XY";
|
|
50
|
-
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["X"] = 1] = "X";
|
|
51
|
-
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["Y"] = 2] = "Y";
|
|
52
|
-
return LINK_VIEW_PORT_TYPE;
|
|
53
|
-
}({});
|
|
54
|
-
const MIDDLE_CELL_POS_MAGIC_NUMBER = 1;
|
|
55
|
-
const DEFAULT_FONTFACE_PLANE = "\"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"Microsoft YaHei\", \"WenQuanYi Micro Hei\", sans-serif";
|
|
56
|
-
const DEFAULT_SKELETON_HEADER_FOOTER = {
|
|
57
|
-
lines: [],
|
|
58
|
-
drawings: /* @__PURE__ */ new Map(),
|
|
59
|
-
height: 0,
|
|
60
|
-
st: 0,
|
|
61
|
-
ed: 0,
|
|
62
|
-
marginLeft: 0
|
|
63
|
-
};
|
|
64
|
-
const DEFAULT_SKELETON_HEADER = {
|
|
65
|
-
...DEFAULT_SKELETON_HEADER_FOOTER,
|
|
66
|
-
marginTop: 20
|
|
67
|
-
};
|
|
68
|
-
const DEFAULT_SKELETON_FOOTER = {
|
|
69
|
-
...DEFAULT_SKELETON_HEADER_FOOTER,
|
|
70
|
-
marginBottom: 20
|
|
71
|
-
};
|
|
72
|
-
const DEFAULT_OFFSET_SPACING = 1;
|
|
73
|
-
const DEFAULT_DOCUMENT_FONTSIZE = 14;
|
|
74
|
-
/**
|
|
75
|
-
* https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
|
|
76
|
-
*/
|
|
77
|
-
let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
|
|
78
|
-
CURSOR_TYPE["DEFAULT"] = "default";
|
|
79
|
-
CURSOR_TYPE["AUTO"] = "auto";
|
|
80
|
-
CURSOR_TYPE["CROSSHAIR"] = "crosshair";
|
|
81
|
-
CURSOR_TYPE["POINTER"] = "pointer";
|
|
82
|
-
CURSOR_TYPE["MOVE"] = "move";
|
|
83
|
-
CURSOR_TYPE["EAST_RESIZE"] = "e-resize";
|
|
84
|
-
CURSOR_TYPE["NORTH_EAST_RESIZE"] = "ne-resize";
|
|
85
|
-
CURSOR_TYPE["NORTH_WEST_RESIZE"] = "nw-resize";
|
|
86
|
-
CURSOR_TYPE["NORTH_RESIZE"] = "n-resize";
|
|
87
|
-
CURSOR_TYPE["SOUTH_EAST_RESIZE"] = "se-resize";
|
|
88
|
-
CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
|
|
89
|
-
CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
|
|
90
|
-
CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
|
|
91
|
-
CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
|
|
92
|
-
CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
|
|
93
|
-
CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
|
|
94
|
-
CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
|
|
95
|
-
CURSOR_TYPE["TEXT"] = "text";
|
|
96
|
-
CURSOR_TYPE["WAIT"] = "wait";
|
|
97
|
-
CURSOR_TYPE["HELP"] = "help";
|
|
98
|
-
CURSOR_TYPE["CELL"] = "cell";
|
|
99
|
-
CURSOR_TYPE["NONE"] = "none";
|
|
100
|
-
CURSOR_TYPE["VERTICAL_TEXT"] = "vertical-text";
|
|
101
|
-
CURSOR_TYPE["NO_DROP"] = "no-drop";
|
|
102
|
-
CURSOR_TYPE["GRAB"] = "grab";
|
|
103
|
-
CURSOR_TYPE["GRABBING"] = "grabbing";
|
|
104
|
-
CURSOR_TYPE["ALL_SCROLL"] = "all-scroll";
|
|
105
|
-
CURSOR_TYPE["COLUMN_RESIZE"] = "col-resize";
|
|
106
|
-
CURSOR_TYPE["ROW_RESIZE"] = "row-resize";
|
|
107
|
-
CURSOR_TYPE["PROGRESS"] = "progress";
|
|
108
|
-
CURSOR_TYPE["NOT_ALLOWED"] = "not-allowed";
|
|
109
|
-
CURSOR_TYPE["ZOOM_IN"] = "zoom-in";
|
|
110
|
-
CURSOR_TYPE["ZOOM_OUT"] = "zoom-out";
|
|
111
|
-
return CURSOR_TYPE;
|
|
112
|
-
}({});
|
|
113
|
-
let DOCUMENT_CONTEXT_CLIP_TYPE = /* @__PURE__ */ function(DOCUMENT_CONTEXT_CLIP_TYPE) {
|
|
114
|
-
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["noClip"] = 0] = "noClip";
|
|
115
|
-
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["DOC_SIZE"] = 1] = "DOC_SIZE";
|
|
116
|
-
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_LEFT"] = 2] = "CONTENT_SIZE_LEFT";
|
|
117
|
-
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_CENTER"] = 3] = "CONTENT_SIZE_CENTER";
|
|
118
|
-
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_Right"] = 4] = "CONTENT_SIZE_Right";
|
|
119
|
-
return DOCUMENT_CONTEXT_CLIP_TYPE;
|
|
120
|
-
}({});
|
|
121
|
-
const COLOR_BLACK_RGB = "rgb(0,0,0)";
|
|
122
|
-
let BORDER_TYPE = /* @__PURE__ */ function(BORDER_TYPE) {
|
|
123
|
-
BORDER_TYPE["TOP"] = "t";
|
|
124
|
-
BORDER_TYPE["BOTTOM"] = "b";
|
|
125
|
-
BORDER_TYPE["LEFT"] = "l";
|
|
126
|
-
BORDER_TYPE["RIGHT"] = "r";
|
|
127
|
-
BORDER_TYPE["TL_BR"] = "tl_br";
|
|
128
|
-
BORDER_TYPE["TL_BC"] = "tl_bc";
|
|
129
|
-
BORDER_TYPE["TL_MR"] = "tl_mr";
|
|
130
|
-
BORDER_TYPE["BL_TR"] = "bl_tr";
|
|
131
|
-
BORDER_TYPE["ML_TR"] = "ml_tr";
|
|
132
|
-
BORDER_TYPE["BC_TR"] = "bc_tr";
|
|
133
|
-
return BORDER_TYPE;
|
|
134
|
-
}({});
|
|
135
|
-
let ORIENTATION_TYPE = /* @__PURE__ */ function(ORIENTATION_TYPE) {
|
|
136
|
-
ORIENTATION_TYPE[ORIENTATION_TYPE["UP"] = 0] = "UP";
|
|
137
|
-
ORIENTATION_TYPE[ORIENTATION_TYPE["DOWN"] = 1] = "DOWN";
|
|
138
|
-
return ORIENTATION_TYPE;
|
|
139
|
-
}({});
|
|
140
|
-
let RENDER_CLASS_TYPE = /* @__PURE__ */ function(RENDER_CLASS_TYPE) {
|
|
141
|
-
RENDER_CLASS_TYPE["ENGINE"] = "Engine";
|
|
142
|
-
RENDER_CLASS_TYPE["SCENE"] = "Scene";
|
|
143
|
-
RENDER_CLASS_TYPE["BASE_OBJECT"] = "BaseObject";
|
|
144
|
-
RENDER_CLASS_TYPE["SCENE_VIEWER"] = "SceneViewer";
|
|
145
|
-
RENDER_CLASS_TYPE["CANVAS"] = "Canvas";
|
|
146
|
-
RENDER_CLASS_TYPE["VIEWPORT"] = "Viewport";
|
|
147
|
-
RENDER_CLASS_TYPE["LAYER"] = "Layer";
|
|
148
|
-
RENDER_CLASS_TYPE["GROUP"] = "Group";
|
|
149
|
-
RENDER_CLASS_TYPE["IMAGE"] = "Image";
|
|
150
|
-
RENDER_CLASS_TYPE["SHAPE"] = "Shape";
|
|
151
|
-
RENDER_CLASS_TYPE["TEXT"] = "Text";
|
|
152
|
-
return RENDER_CLASS_TYPE;
|
|
153
|
-
}({});
|
|
154
|
-
const MAXIMUM_ROW_HEIGHT = 2e3;
|
|
155
|
-
const MAXIMUM_COL_WIDTH = 2e3;
|
|
156
|
-
const MIN_COL_WIDTH = 2;
|
|
157
|
-
const FIX_ONE_PIXEL_BLUR_OFFSET = .5;
|
|
158
|
-
const DRAWING_OBJECT_LOWER_LAYER_INDEX = 3;
|
|
159
|
-
const DRAWING_OBJECT_LAYER_INDEX = 4;
|
|
160
|
-
const DRAWING_OBJECT_UPPER_LAYER_INDEX = 5;
|
|
25
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
26
|
+
function _typeof(o) {
|
|
27
|
+
"@babel/helpers - typeof";
|
|
28
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
29
|
+
return typeof o;
|
|
30
|
+
} : function(o) {
|
|
31
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
32
|
+
}, _typeof(o);
|
|
33
|
+
}
|
|
161
34
|
|
|
162
35
|
//#endregion
|
|
163
|
-
//#region
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (opacity != null) return `${RGBA_PAREN + RgbArray.join(",")},${opacity})`;
|
|
172
|
-
return `${RGB_PAREN + RgbArray.join(",")})`;
|
|
173
|
-
};
|
|
174
|
-
const PERCENT_TO_NUMBER_DIVIDE = 100;
|
|
175
|
-
const toPx = (num, ReferenceValue) => {
|
|
176
|
-
if (Tools.isNumber(num)) return num;
|
|
177
|
-
if (ReferenceValue && num && Tools.isString(num) && num.substr(num.length - 1, 1) === "%") return ReferenceValue * (Number.parseFloat(num) / PERCENT_TO_NUMBER_DIVIDE);
|
|
178
|
-
return 0;
|
|
179
|
-
};
|
|
180
|
-
const ONE_FRAME_NUMBER = 16;
|
|
181
|
-
/**
|
|
182
|
-
* Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
|
|
183
|
-
* @param func - the function to be called
|
|
184
|
-
* @param requester - the object that will request the next frame. Falls back to window.
|
|
185
|
-
* @returns frame number
|
|
186
|
-
*/
|
|
187
|
-
const requestNewFrame = (func, requester) => {
|
|
188
|
-
if (!requester) requester = window;
|
|
189
|
-
if (requester.requestPostAnimationFrame) return requester.requestPostAnimationFrame(func);
|
|
190
|
-
if (requester.requestAnimationFrame) return requester.requestAnimationFrame(func);
|
|
191
|
-
if (requester.msRequestAnimationFrame) return requester.msRequestAnimationFrame(func);
|
|
192
|
-
if (requester.webkitRequestAnimationFrame) return requester.webkitRequestAnimationFrame(func);
|
|
193
|
-
if (requester.mozRequestAnimationFrame) return requester.mozRequestAnimationFrame(func);
|
|
194
|
-
if (requester.oRequestAnimationFrame) return requester.oRequestAnimationFrame(func);
|
|
195
|
-
return setTimeout(func, ONE_FRAME_NUMBER);
|
|
196
|
-
};
|
|
197
|
-
const cancelRequestFrame = (requestID, requester) => {
|
|
198
|
-
if (!requester) requester = window;
|
|
199
|
-
if (requester.requestPostAnimationFrame) return requester.cancelPostAnimationFrame(requestID);
|
|
200
|
-
if (requester.requestAnimationFrame) return requester.cancelAnimationFrame(requestID);
|
|
201
|
-
if (requester.msRequestAnimationFrame) return requester.msCancelAnimationFrame(requestID);
|
|
202
|
-
if (requester.webkitRequestAnimationFrame) return requester.webkitCancelAnimationFrame(requestID);
|
|
203
|
-
if (requester.mozRequestAnimationFrame) return requester.mozCancelAnimationFrame(requestID);
|
|
204
|
-
if (requester.oRequestAnimationFrame) return requester.oCancelAnimationFrame(requestID);
|
|
205
|
-
return clearTimeout(requestID);
|
|
206
|
-
};
|
|
207
|
-
const createCanvasElement = () => {
|
|
208
|
-
const canvas = document.createElement("canvas");
|
|
209
|
-
canvas.dir = "ltr";
|
|
210
|
-
try {
|
|
211
|
-
canvas.style = canvas.style || {};
|
|
212
|
-
} catch (e) {
|
|
213
|
-
console.error(e);
|
|
36
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
37
|
+
function toPrimitive(t, r) {
|
|
38
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
39
|
+
var e = t[Symbol.toPrimitive];
|
|
40
|
+
if (void 0 !== e) {
|
|
41
|
+
var i = e.call(t, r || "default");
|
|
42
|
+
if ("object" != _typeof(i)) return i;
|
|
43
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
214
44
|
}
|
|
215
|
-
return
|
|
216
|
-
};
|
|
217
|
-
const createImageElement = () => document.createElement("img");
|
|
218
|
-
const radToDeg = (rad) => rad * DEG180_OVER_PI;
|
|
219
|
-
const degToRad = (deg) => deg * PI_OVER_DEG180;
|
|
220
|
-
/**
|
|
221
|
-
* Gets the pointer prefix to use
|
|
222
|
-
* @param engine defines the engine we are finding the prefix for
|
|
223
|
-
* @returns "pointer" if touch is enabled. Else returns "mouse"
|
|
224
|
-
*/
|
|
225
|
-
const getPointerPrefix = () => {
|
|
226
|
-
let eventPrefix = "pointer";
|
|
227
|
-
if (typeof window !== "undefined" && !window.PointerEvent && typeof navigator !== "undefined") eventPrefix = "mouse";
|
|
228
|
-
if (Tools.isTablet() && !Tools.isIPhone() && !(document && "ontouchend" in document)) eventPrefix = "mouse";
|
|
229
|
-
return eventPrefix;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Utility function to detect if the current user agent is Safari
|
|
233
|
-
* @returns whether or not the current user agent is safari
|
|
234
|
-
*/
|
|
235
|
-
const IsSafari = () => {
|
|
236
|
-
if (Tools.getBrowserType() === "safari") return true;
|
|
237
|
-
return false;
|
|
238
|
-
};
|
|
239
|
-
const GENERATE_RANDOM_KEY_DEFAULT_LENGTH = 4;
|
|
240
|
-
const generateRandomKey = (prefix = "obj", keyLength = GENERATE_RANDOM_KEY_DEFAULT_LENGTH) => {
|
|
241
|
-
const userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
|
|
242
|
-
let mid = "";
|
|
243
|
-
for (let i = 0; i < keyLength; i++) mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
|
|
244
|
-
const time = (/* @__PURE__ */ new Date()).getTime();
|
|
245
|
-
return `${prefix}_${mid}_${time}`;
|
|
246
|
-
};
|
|
247
|
-
function getValueType(value) {
|
|
248
|
-
return Object.prototype.toString.apply(value);
|
|
45
|
+
return ("string" === r ? String : Number)(t);
|
|
249
46
|
}
|
|
250
|
-
|
|
251
|
-
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
50
|
+
function toPropertyKey(t) {
|
|
51
|
+
var i = toPrimitive(t, "string");
|
|
52
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
252
53
|
}
|
|
253
|
-
|
|
254
|
-
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
57
|
+
function _defineProperty(e, r, t) {
|
|
58
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
|
+
value: t,
|
|
60
|
+
enumerable: !0,
|
|
61
|
+
configurable: !0,
|
|
62
|
+
writable: !0
|
|
63
|
+
}) : e[r] = t, e;
|
|
255
64
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return getValueType(value) === "[object Object]";
|
|
270
|
-
}
|
|
271
|
-
function precisionTo(num, accurate) {
|
|
272
|
-
accurate = 10 ** accurate;
|
|
273
|
-
return Math.round(num * accurate) / accurate;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* When drawing lines, it is necessary to align their precision.
|
|
277
|
-
* performance testing
|
|
278
|
-
* var time = performance.now(); for(let i=0;i<100000000;i++){ fixLineWidthByScale(i, 0.666); }; console.log(performance.now()-time);
|
|
279
|
-
*/
|
|
280
|
-
function fixLineWidthByScale(num, scale) {
|
|
281
|
-
return Math.round(num * scale) / scale;
|
|
282
|
-
}
|
|
283
|
-
function getFontStyleString(textStyle) {
|
|
284
|
-
const defaultFont = DEFAULT_STYLES.ff;
|
|
285
|
-
const defaultFontSize = DEFAULT_STYLES.fs;
|
|
286
|
-
if (!textStyle) {
|
|
287
|
-
const fontString = `${defaultFontSize}pt ${defaultFont}`;
|
|
288
|
-
return {
|
|
289
|
-
fontCache: fontString,
|
|
290
|
-
fontString,
|
|
291
|
-
fontSize: defaultFontSize,
|
|
292
|
-
originFontSize: defaultFontSize,
|
|
293
|
-
fontFamily: defaultFont
|
|
294
|
-
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/components/docs/layout/shaping-engine/font-cache.ts
|
|
68
|
+
const DEFAULT_MEASURE_TEXT = "0";
|
|
69
|
+
const getDefaultBaselineOffset = (fontSize) => ({
|
|
70
|
+
sbr: .6,
|
|
71
|
+
sbo: fontSize,
|
|
72
|
+
spr: .6,
|
|
73
|
+
spo: fontSize
|
|
74
|
+
});
|
|
75
|
+
var FontCache = class {
|
|
76
|
+
static get globalFontMeasureCache() {
|
|
77
|
+
return this._globalFontMeasureCache;
|
|
295
78
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
let originFontSize = defaultFontSize;
|
|
301
|
-
if (textStyle.fs) originFontSize = textStyle.fs;
|
|
302
|
-
let fontSize = originFontSize;
|
|
303
|
-
const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
|
|
304
|
-
const { va: baselineOffset } = textStyle;
|
|
305
|
-
if (baselineOffset === BaselineOffset.SUBSCRIPT || baselineOffset === BaselineOffset.SUPERSCRIPT) {
|
|
306
|
-
const { sbr, spr } = FontCache.getBaselineOffsetInfo(fontFamilyResult, fontSize);
|
|
307
|
-
fontSize *= baselineOffset === BaselineOffset.SUBSCRIPT ? sbr : spr;
|
|
79
|
+
static setFontMeasureCache(fontStyle, content, tm) {
|
|
80
|
+
if (!this._globalFontMeasureCache.has(fontStyle)) this._globalFontMeasureCache.set(fontStyle, /* @__PURE__ */ new Map());
|
|
81
|
+
const fontMeasureCache = this._globalFontMeasureCache.get(fontStyle);
|
|
82
|
+
if (fontMeasureCache) fontMeasureCache.set(content, tm);
|
|
308
83
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const family = item.trim().replace(/^['"]|['"]$/g, "");
|
|
322
|
-
return family.includes(" ") ? `"${family}"` : family;
|
|
323
|
-
}).filter(Boolean).join(", ");
|
|
324
|
-
}
|
|
325
|
-
function hasAllLatin(text) {
|
|
326
|
-
if (!/[\u0000-\u024F]/gi.exec(text)) return false;
|
|
327
|
-
return true;
|
|
328
|
-
}
|
|
329
|
-
function hasBasicLatin(text) {
|
|
330
|
-
if (!/[\u0000-\u007F]/gi.exec(text)) return false;
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
function hasLatinOneSupplement(text) {
|
|
334
|
-
if (!/[\u0080-\u00FF]/gi.exec(text)) return false;
|
|
335
|
-
return true;
|
|
336
|
-
}
|
|
337
|
-
function hasLatinExtendedA(text) {
|
|
338
|
-
if (!/[\u0100-\u017F]/gi.exec(text)) return false;
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
function hasLatinExtendedB(text) {
|
|
342
|
-
if (!/[\u0180-\u024F]/gi.exec(text)) return false;
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
346
|
-
function getFirstGrapheme(text) {
|
|
347
|
-
var _it$next$value$segmen, _it$next$value;
|
|
348
|
-
return (_it$next$value$segmen = (_it$next$value = segmenter.segment(text)[Symbol.iterator]().next().value) === null || _it$next$value === void 0 ? void 0 : _it$next$value.segment) !== null && _it$next$value$segmen !== void 0 ? _it$next$value$segmen : null;
|
|
349
|
-
}
|
|
350
|
-
function isEmojiGrapheme(grapheme) {
|
|
351
|
-
if (/\p{Extended_Pictographic}/u.test(grapheme)) return true;
|
|
352
|
-
if (/^\p{Regional_Indicator}{2}$/u.test(grapheme)) return true;
|
|
353
|
-
if (/^[0-9#*]\uFE0F?\u20E3$/u.test(grapheme)) return true;
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
function startWithEmoji(text) {
|
|
357
|
-
const first = getFirstGrapheme(text);
|
|
358
|
-
return first ? isEmojiGrapheme(first) : false;
|
|
359
|
-
}
|
|
360
|
-
function hasArabic(text) {
|
|
361
|
-
return /[\u0600-\u06FF]|[\u0750-\u0750]|[\u0870-\u08FF]|[\uFB50-\uFDFF]|[\uFE70-\uFEFF]/gi.test(text);
|
|
362
|
-
}
|
|
363
|
-
function hasTibetan(text) {
|
|
364
|
-
return /[\u0180-\u024F]/gi.test(text);
|
|
365
|
-
}
|
|
366
|
-
function hasThai(text) {
|
|
367
|
-
return /[\u0E00-\u0E7F]/.test(text);
|
|
368
|
-
}
|
|
369
|
-
function hasSpace(text) {
|
|
370
|
-
return /\s+/g.test(text);
|
|
371
|
-
}
|
|
372
|
-
function isCjkLeftAlignedPunctuation(text) {
|
|
373
|
-
return [
|
|
374
|
-
"”",
|
|
375
|
-
"’",
|
|
376
|
-
",",
|
|
377
|
-
"。",
|
|
378
|
-
".",
|
|
379
|
-
"、",
|
|
380
|
-
":",
|
|
381
|
-
";",
|
|
382
|
-
"?",
|
|
383
|
-
"!",
|
|
384
|
-
"》",
|
|
385
|
-
")",
|
|
386
|
-
"』",
|
|
387
|
-
"」",
|
|
388
|
-
"】",
|
|
389
|
-
"〗",
|
|
390
|
-
"〕",
|
|
391
|
-
"〉",
|
|
392
|
-
"]",
|
|
393
|
-
"}"
|
|
394
|
-
].indexOf(text) > -1;
|
|
395
|
-
}
|
|
396
|
-
function isCjkRightAlignedPunctuation(text) {
|
|
397
|
-
return [
|
|
398
|
-
"“",
|
|
399
|
-
"‘",
|
|
400
|
-
"《",
|
|
401
|
-
"(",
|
|
402
|
-
"『",
|
|
403
|
-
"「",
|
|
404
|
-
"【",
|
|
405
|
-
"〖",
|
|
406
|
-
"〔",
|
|
407
|
-
"〈",
|
|
408
|
-
"[",
|
|
409
|
-
"{"
|
|
410
|
-
].indexOf(text) > -1;
|
|
411
|
-
}
|
|
412
|
-
function isCjkCenterAlignedPunctuation(text) {
|
|
413
|
-
return ["・", "·"].indexOf(text) > -1;
|
|
414
|
-
}
|
|
415
|
-
const one_thousand = 1e3;
|
|
416
|
-
let dpi_cache;
|
|
417
|
-
function getDPI() {
|
|
418
|
-
if (dpi_cache) return dpi_cache;
|
|
419
|
-
let i = 56;
|
|
420
|
-
for (; i < one_thousand * 2; i++) if (matchMedia(`(max-resolution: ${i}dpi)`).matches === true) return i;
|
|
421
|
-
dpi_cache = i;
|
|
422
|
-
setTimeout(() => {
|
|
423
|
-
dpi_cache = null;
|
|
424
|
-
}, one_thousand);
|
|
425
|
-
return i;
|
|
426
|
-
}
|
|
427
|
-
const BENCHMARK_DPI = 72;
|
|
428
|
-
const BENCHMARK_CONVERT_MM = 25.4;
|
|
429
|
-
function ptToPx(pt) {
|
|
430
|
-
return pt / (BENCHMARK_DPI / getDPI());
|
|
431
|
-
}
|
|
432
|
-
function pxToPt(px) {
|
|
433
|
-
return px * (BENCHMARK_DPI / getDPI());
|
|
434
|
-
}
|
|
435
|
-
function ptToMM(px) {
|
|
436
|
-
return px * (getDPI() / BENCHMARK_CONVERT_MM);
|
|
437
|
-
}
|
|
438
|
-
function pxToInch(px) {
|
|
439
|
-
return px * getDPI();
|
|
440
|
-
}
|
|
441
|
-
function getScale(parentScale) {
|
|
442
|
-
const { scaleX = 1, scaleY = 1 } = parentScale;
|
|
443
|
-
return Math.max(scaleX, scaleY);
|
|
444
|
-
}
|
|
445
|
-
function getCellPositionByIndex(row, column, rowHeightAccumulation, columnWidthAccumulation) {
|
|
446
|
-
const startRow = row - 1;
|
|
447
|
-
const startColumn = column - 1;
|
|
448
|
-
const startY = rowHeightAccumulation[startRow] || 0;
|
|
449
|
-
let endY = rowHeightAccumulation[row];
|
|
450
|
-
if (endY == null) endY = rowHeightAccumulation[rowHeightAccumulation.length - 1];
|
|
451
|
-
const startX = columnWidthAccumulation[startColumn] || 0;
|
|
452
|
-
let endX = columnWidthAccumulation[column];
|
|
453
|
-
if (endX == null) endX = columnWidthAccumulation[columnWidthAccumulation.length - 1];
|
|
454
|
-
return {
|
|
455
|
-
startY,
|
|
456
|
-
endY,
|
|
457
|
-
startX,
|
|
458
|
-
endX
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* @deprecated use same function in @univerjs/core
|
|
463
|
-
* @description Get the cell position information of the specified row and column, including the position information of the cell and the merge information of the cell
|
|
464
|
-
* @param {number} row The row index of the cell
|
|
465
|
-
* @param {number} column The column index of the cell
|
|
466
|
-
* @param {number[]} rowHeightAccumulation The accumulated height of each row
|
|
467
|
-
* @param {number[]} columnWidthAccumulation The accumulated width of each column
|
|
468
|
-
* @param {ICellInfo} mergeDataInfo The merge information of the cell
|
|
469
|
-
* @returns {ICellWithCoord} The cell position information of the specified row and column, including the position information of the cell and the merge information of the cell
|
|
470
|
-
*/
|
|
471
|
-
function getCellWithCoordByIndexCore(row, column, rowHeightAccumulation, columnWidthAccumulation, mergeDataInfo) {
|
|
472
|
-
row = Tools.clamp(row, 0, rowHeightAccumulation.length - 1);
|
|
473
|
-
column = Tools.clamp(column, 0, columnWidthAccumulation.length - 1);
|
|
474
|
-
let { startY, endY, startX, endX } = getCellPositionByIndex(row, column, rowHeightAccumulation, columnWidthAccumulation);
|
|
475
|
-
const { isMerged, isMergedMainCell, startRow, startColumn, endRow, endColumn } = mergeDataInfo;
|
|
476
|
-
let mergeInfo = {
|
|
477
|
-
startRow,
|
|
478
|
-
startColumn,
|
|
479
|
-
endRow,
|
|
480
|
-
endColumn,
|
|
481
|
-
startY: 0,
|
|
482
|
-
endY: 0,
|
|
483
|
-
startX: 0,
|
|
484
|
-
endX: 0
|
|
485
|
-
};
|
|
486
|
-
const rowAccumulationCount = rowHeightAccumulation.length - 1;
|
|
487
|
-
const columnAccumulationCount = columnWidthAccumulation.length - 1;
|
|
488
|
-
if (isMerged && startRow !== -1 && startColumn !== -1) {
|
|
489
|
-
const mergeStartY = rowHeightAccumulation[startRow - 1] || 0;
|
|
490
|
-
const mergeEndY = rowHeightAccumulation[endRow] || rowHeightAccumulation[rowAccumulationCount];
|
|
491
|
-
const mergeStartX = columnWidthAccumulation[startColumn - 1] || 0;
|
|
492
|
-
const mergeEndX = columnWidthAccumulation[endColumn] || columnWidthAccumulation[columnAccumulationCount];
|
|
493
|
-
mergeInfo = {
|
|
494
|
-
...mergeInfo,
|
|
495
|
-
startY: mergeStartY,
|
|
496
|
-
endY: mergeEndY,
|
|
497
|
-
startX: mergeStartX,
|
|
498
|
-
endX: mergeEndX
|
|
499
|
-
};
|
|
500
|
-
} else if (!isMerged && endRow !== -1 && endColumn !== -1) {
|
|
501
|
-
const mergeEndY = rowHeightAccumulation[endRow] || rowHeightAccumulation[rowAccumulationCount];
|
|
502
|
-
const mergeEndX = columnWidthAccumulation[endColumn] || columnWidthAccumulation[columnAccumulationCount];
|
|
503
|
-
mergeInfo = {
|
|
504
|
-
...mergeInfo,
|
|
505
|
-
startY,
|
|
506
|
-
endY: mergeEndY,
|
|
507
|
-
startX,
|
|
508
|
-
endX: mergeEndX
|
|
509
|
-
};
|
|
84
|
+
static clearFontMeasureCache(path) {
|
|
85
|
+
const pathArr = path.split("/");
|
|
86
|
+
if (pathArr.length === 1) {
|
|
87
|
+
const fontStyle = pathArr[0];
|
|
88
|
+
this._globalFontMeasureCache.delete(fontStyle);
|
|
89
|
+
} else if (pathArr.length === 2) {
|
|
90
|
+
var _this$_globalFontMeas;
|
|
91
|
+
const fontStyle = pathArr[0];
|
|
92
|
+
const content = pathArr[1];
|
|
93
|
+
(_this$_globalFontMeas = this._globalFontMeasureCache.get(fontStyle)) === null || _this$_globalFontMeas === void 0 || _this$_globalFontMeas.delete(content);
|
|
94
|
+
} else return false;
|
|
95
|
+
return true;
|
|
510
96
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
actualRow: row,
|
|
515
|
-
actualColumn: column,
|
|
516
|
-
startY,
|
|
517
|
-
endY,
|
|
518
|
-
startX,
|
|
519
|
-
endX,
|
|
520
|
-
mergeInfo
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* @deprecated please use getCellWithCoordByIndexCore in @univerjs/core instead
|
|
525
|
-
*/
|
|
526
|
-
const getCellByIndexWithMergeInfo = getCellWithCoordByIndexCore;
|
|
527
|
-
/**
|
|
528
|
-
* Determine whether there are any cells in a row that are not in the merged cells, mainly used for the calculation of auto height
|
|
529
|
-
* @deprecated please use SpreadsheetSkeleton@_hasUnMergedCellInRow
|
|
530
|
-
*/
|
|
531
|
-
function hasUnMergedCellInRow(row, startColumn, endColumn, mergeData) {
|
|
532
|
-
let hasUnMergedCell = false;
|
|
533
|
-
for (let colIndex = startColumn; colIndex <= endColumn; colIndex++) {
|
|
534
|
-
const { isMerged, isMergedMainCell } = getCellInfoInMergeData(row, colIndex, mergeData);
|
|
535
|
-
if (!isMerged && !isMergedMainCell) {
|
|
536
|
-
hasUnMergedCell = true;
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
return hasUnMergedCell;
|
|
541
|
-
}
|
|
542
|
-
function mergeInfoOffset(mergeInfo, offsetX, offsetY) {
|
|
543
|
-
return {
|
|
544
|
-
...mergeInfo,
|
|
545
|
-
startY: mergeInfo.startY + offsetY,
|
|
546
|
-
endY: mergeInfo.endY + offsetY,
|
|
547
|
-
startX: mergeInfo.startX + offsetX,
|
|
548
|
-
endX: mergeInfo.endX + offsetX
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
function isRectIntersect(rect1, rect2) {
|
|
552
|
-
return !(rect1.left > rect2.right || rect1.top > rect2.bottom || rect2.left > rect1.right || rect2.top > rect1.bottom);
|
|
553
|
-
}
|
|
554
|
-
function injectStyle(styles) {
|
|
555
|
-
const styleElement = document.createElement("style");
|
|
556
|
-
document.head.appendChild(styleElement);
|
|
557
|
-
const styleSheet = styleElement.sheet;
|
|
558
|
-
for (const style of styles) styleSheet === null || styleSheet === void 0 || styleSheet.insertRule(style, styleSheet.cssRules.length);
|
|
559
|
-
}
|
|
560
|
-
function checkStyle(content) {
|
|
561
|
-
for (let i = 0, len = document.head.childNodes.length; i < len; i++) {
|
|
562
|
-
const node = document.head.childNodes[i];
|
|
563
|
-
if (node.nodeName === "STYLE" && node.textContent && node.textContent.indexOf(content) > -1) return true;
|
|
564
|
-
}
|
|
565
|
-
return false;
|
|
566
|
-
}
|
|
567
|
-
function pxToNum(unit) {
|
|
568
|
-
return Number(unit.replace(/px/gi, ""));
|
|
569
|
-
}
|
|
570
|
-
function getSizeForDom(dom) {
|
|
571
|
-
const { borderTopWidth, borderLeftWidth, borderRightWidth, borderBottomWidth, width, height } = getComputedStyle(dom);
|
|
572
|
-
return {
|
|
573
|
-
top: pxToNum(borderTopWidth),
|
|
574
|
-
left: pxToNum(borderLeftWidth),
|
|
575
|
-
right: pxToNum(borderRightWidth),
|
|
576
|
-
bottom: pxToNum(borderBottomWidth),
|
|
577
|
-
width: pxToNum(width),
|
|
578
|
-
height: pxToNum(height)
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
*1 pixel * 0.75 = 1 pt
|
|
583
|
-
*/
|
|
584
|
-
const PX_TO_PT_RATIO = .75;
|
|
585
|
-
function ptToPixel(pt) {
|
|
586
|
-
return pt / PX_TO_PT_RATIO;
|
|
587
|
-
}
|
|
588
|
-
function pixelToPt(px) {
|
|
589
|
-
return px * PX_TO_PT_RATIO;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Is cell in view ranges.
|
|
593
|
-
* @param ranges
|
|
594
|
-
* @param rowIndex
|
|
595
|
-
* @param colIndex
|
|
596
|
-
* @returns boolean
|
|
597
|
-
*/
|
|
598
|
-
function inViewRanges(ranges, rowIndex, colIndex) {
|
|
599
|
-
for (const range of ranges) if (rowIndex >= range.startRow && rowIndex <= range.endRow && colIndex >= range.startColumn && colIndex <= range.endColumn) return true;
|
|
600
|
-
return false;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* If there is an intersection in ranges to the mainRanges, extend it to the first set of ranges.
|
|
604
|
-
* @param {IRange[]} mainRanges target ranges
|
|
605
|
-
* @param {IRange[]} ranges
|
|
606
|
-
*/
|
|
607
|
-
function expandRangeIfIntersects(mainRanges, ranges) {
|
|
608
|
-
const intersects = [];
|
|
609
|
-
for (const mainRange of mainRanges) for (const range of ranges) if (Rectangle.simpleRangesIntersect(mainRange, range)) intersects.push(range);
|
|
610
|
-
return mainRanges.concat(intersects);
|
|
611
|
-
}
|
|
612
|
-
function clampRange(range, maxRow, maxColumn) {
|
|
613
|
-
return {
|
|
614
|
-
startRow: Tools.clamp(range.startRow, 0, maxRow),
|
|
615
|
-
endRow: Tools.clamp(range.endRow, 0, maxRow),
|
|
616
|
-
startColumn: Tools.clamp(range.startColumn, 0, maxColumn),
|
|
617
|
-
endColumn: Tools.clamp(range.endColumn, 0, maxColumn)
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Get system highlight color in rgb format.
|
|
622
|
-
*/
|
|
623
|
-
function getSystemHighlightColor() {
|
|
624
|
-
const hiddenEle = document.createElement("div");
|
|
625
|
-
hiddenEle.style.width = "0";
|
|
626
|
-
hiddenEle.style.height = "0";
|
|
627
|
-
hiddenEle.style.backgroundColor = "highlight";
|
|
628
|
-
document.body.append(hiddenEle);
|
|
629
|
-
const highlightColor = getComputedStyle(hiddenEle).backgroundColor;
|
|
630
|
-
hiddenEle.remove();
|
|
631
|
-
return new ColorKit(highlightColor).toRgb();
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
636
|
-
function _typeof(o) {
|
|
637
|
-
"@babel/helpers - typeof";
|
|
638
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
639
|
-
return typeof o;
|
|
640
|
-
} : function(o) {
|
|
641
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
642
|
-
}, _typeof(o);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
647
|
-
function toPrimitive(t, r) {
|
|
648
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
649
|
-
var e = t[Symbol.toPrimitive];
|
|
650
|
-
if (void 0 !== e) {
|
|
651
|
-
var i = e.call(t, r || "default");
|
|
652
|
-
if ("object" != _typeof(i)) return i;
|
|
653
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
654
|
-
}
|
|
655
|
-
return ("string" === r ? String : Number)(t);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
//#endregion
|
|
659
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
660
|
-
function toPropertyKey(t) {
|
|
661
|
-
var i = toPrimitive(t, "string");
|
|
662
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
//#endregion
|
|
666
|
-
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
667
|
-
function _defineProperty(e, r, t) {
|
|
668
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
669
|
-
value: t,
|
|
670
|
-
enumerable: !0,
|
|
671
|
-
configurable: !0,
|
|
672
|
-
writable: !0
|
|
673
|
-
}) : e[r] = t, e;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
//#endregion
|
|
677
|
-
//#region src/components/docs/layout/shaping-engine/font-cache.ts
|
|
678
|
-
const DEFAULT_MEASURE_TEXT = "0";
|
|
679
|
-
const getDefaultBaselineOffset = (fontSize) => ({
|
|
680
|
-
sbr: .6,
|
|
681
|
-
sbo: fontSize,
|
|
682
|
-
spr: .6,
|
|
683
|
-
spo: fontSize
|
|
684
|
-
});
|
|
685
|
-
var FontCache = class {
|
|
686
|
-
static get globalFontMeasureCache() {
|
|
687
|
-
return this._globalFontMeasureCache;
|
|
688
|
-
}
|
|
689
|
-
static setFontMeasureCache(fontStyle, content, tm) {
|
|
690
|
-
if (!this._globalFontMeasureCache.has(fontStyle)) this._globalFontMeasureCache.set(fontStyle, /* @__PURE__ */ new Map());
|
|
691
|
-
const fontMeasureCache = this._globalFontMeasureCache.get(fontStyle);
|
|
692
|
-
if (fontMeasureCache) fontMeasureCache.set(content, tm);
|
|
693
|
-
}
|
|
694
|
-
static clearFontMeasureCache(path) {
|
|
695
|
-
const pathArr = path.split("/");
|
|
696
|
-
if (pathArr.length === 1) {
|
|
697
|
-
const fontStyle = pathArr[0];
|
|
698
|
-
this._globalFontMeasureCache.delete(fontStyle);
|
|
699
|
-
} else if (pathArr.length === 2) {
|
|
700
|
-
var _this$_globalFontMeas;
|
|
701
|
-
const fontStyle = pathArr[0];
|
|
702
|
-
const content = pathArr[1];
|
|
703
|
-
(_this$_globalFontMeas = this._globalFontMeasureCache.get(fontStyle)) === null || _this$_globalFontMeas === void 0 || _this$_globalFontMeas.delete(content);
|
|
704
|
-
} else return false;
|
|
705
|
-
return true;
|
|
706
|
-
}
|
|
707
|
-
static getFontMeasureCache(fontStyle, content) {
|
|
708
|
-
var _this$_globalFontMeas2;
|
|
709
|
-
return (_this$_globalFontMeas2 = this._globalFontMeasureCache.get(fontStyle)) === null || _this$_globalFontMeas2 === void 0 ? void 0 : _this$_globalFontMeas2.get(content);
|
|
97
|
+
static getFontMeasureCache(fontStyle, content) {
|
|
98
|
+
var _this$_globalFontMeas2;
|
|
99
|
+
return (_this$_globalFontMeas2 = this._globalFontMeasureCache.get(fontStyle)) === null || _this$_globalFontMeas2 === void 0 ? void 0 : _this$_globalFontMeas2.get(content);
|
|
710
100
|
}
|
|
711
101
|
static autoCleanFontMeasureCache(cacheLimit = 1e6) {
|
|
712
102
|
let allSize = 0;
|
|
@@ -782,21 +172,6 @@ var FontCache = class {
|
|
|
782
172
|
}
|
|
783
173
|
return bBox;
|
|
784
174
|
}
|
|
785
|
-
static getBBoxFromGlyphInfo(glyphInfo, fontStyle) {
|
|
786
|
-
var _glyph$advanceWidth;
|
|
787
|
-
const glyph = glyphInfo.glyph;
|
|
788
|
-
const font = glyphInfo.font;
|
|
789
|
-
const { y1, y2 } = glyphInfo.boundingBox;
|
|
790
|
-
const scale = ptToPixel(fontStyle.fontSize) / font.unitsPerEm;
|
|
791
|
-
const { ascender, descender } = font;
|
|
792
|
-
return this._calculateBoundingBoxByMeasureText({
|
|
793
|
-
width: ((_glyph$advanceWidth = glyph.advanceWidth) !== null && _glyph$advanceWidth !== void 0 ? _glyph$advanceWidth : 0) * scale,
|
|
794
|
-
fontBoundingBoxAscent: ascender * scale,
|
|
795
|
-
fontBoundingBoxDescent: Math.abs(descender * scale),
|
|
796
|
-
actualBoundingBoxAscent: y2 * scale,
|
|
797
|
-
actualBoundingBoxDescent: Math.abs(y1 * scale)
|
|
798
|
-
}, fontStyle);
|
|
799
|
-
}
|
|
800
175
|
/**
|
|
801
176
|
* Measure text on another canvas.
|
|
802
177
|
* @param content
|
|
@@ -1073,189 +448,717 @@ const CJK_ALL_DATA = [
|
|
|
1073
448
|
function letters() {
|
|
1074
449
|
return regexp.charset(...CJK_LETTER_DATA);
|
|
1075
450
|
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Returns the CJK punctuation charset generated from `cjk-regex@3.4.0`.
|
|
1078
|
-
*/
|
|
1079
|
-
function punctuations() {
|
|
1080
|
-
return regexp.charset(...CJK_PUNCTUATION_DATA);
|
|
451
|
+
/**
|
|
452
|
+
* Returns the CJK punctuation charset generated from `cjk-regex@3.4.0`.
|
|
453
|
+
*/
|
|
454
|
+
function punctuations() {
|
|
455
|
+
return regexp.charset(...CJK_PUNCTUATION_DATA);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Returns the combined CJK letter and punctuation charset generated from `cjk-regex@3.4.0`.
|
|
459
|
+
*/
|
|
460
|
+
function all() {
|
|
461
|
+
return regexp.charset(...CJK_ALL_DATA);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Returns true when text contains CJK letters, excluding punctuation and symbols.
|
|
465
|
+
*/
|
|
466
|
+
function hasCJKText(text) {
|
|
467
|
+
return CJK_LETTER_REG.test(text);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Returns true when text contains CJK letters or CJK punctuation.
|
|
471
|
+
*/
|
|
472
|
+
function hasCJK(text) {
|
|
473
|
+
return CJK_ALL_REG.test(text);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Returns true when text contains CJK punctuation, excluding CJK letters.
|
|
477
|
+
*/
|
|
478
|
+
function hasCJKPunctuation(text) {
|
|
479
|
+
return CJK_PUNCTUATION_REG.test(text);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Namespace-style CJK regex API used by document rendering and layout.
|
|
483
|
+
*/
|
|
484
|
+
const cjk = {
|
|
485
|
+
CJK_LETTER_SOURCE,
|
|
486
|
+
CJK_PUNCTUATION_SOURCE,
|
|
487
|
+
CJK_ALL_SOURCE,
|
|
488
|
+
CJK_LETTER_REG,
|
|
489
|
+
CJK_PUNCTUATION_REG,
|
|
490
|
+
CJK_ALL_REG,
|
|
491
|
+
CJK_LETTER_DATA,
|
|
492
|
+
CJK_PUNCTUATION_DATA,
|
|
493
|
+
CJK_ALL_DATA,
|
|
494
|
+
letters,
|
|
495
|
+
punctuations,
|
|
496
|
+
all,
|
|
497
|
+
hasCJKText,
|
|
498
|
+
hasCJK,
|
|
499
|
+
hasCJKPunctuation
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/basics/const.ts
|
|
504
|
+
/**
|
|
505
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
506
|
+
*
|
|
507
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
508
|
+
* you may not use this file except in compliance with the License.
|
|
509
|
+
* You may obtain a copy of the License at
|
|
510
|
+
*
|
|
511
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
512
|
+
*
|
|
513
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
514
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
515
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
516
|
+
* See the License for the specific language governing permissions and
|
|
517
|
+
* limitations under the License.
|
|
518
|
+
*/
|
|
519
|
+
let SHAPE_TYPE = /* @__PURE__ */ function(SHAPE_TYPE) {
|
|
520
|
+
SHAPE_TYPE["RECT"] = "rect";
|
|
521
|
+
SHAPE_TYPE["CIRCLE"] = "circle";
|
|
522
|
+
SHAPE_TYPE["PATH"] = "path";
|
|
523
|
+
return SHAPE_TYPE;
|
|
524
|
+
}({});
|
|
525
|
+
let LINK_VIEW_PORT_TYPE = /* @__PURE__ */ function(LINK_VIEW_PORT_TYPE) {
|
|
526
|
+
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["XY"] = 0] = "XY";
|
|
527
|
+
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["X"] = 1] = "X";
|
|
528
|
+
LINK_VIEW_PORT_TYPE[LINK_VIEW_PORT_TYPE["Y"] = 2] = "Y";
|
|
529
|
+
return LINK_VIEW_PORT_TYPE;
|
|
530
|
+
}({});
|
|
531
|
+
const MIDDLE_CELL_POS_MAGIC_NUMBER = 1;
|
|
532
|
+
const DEFAULT_FONTFACE_PLANE = "\"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"Microsoft YaHei\", \"WenQuanYi Micro Hei\", sans-serif";
|
|
533
|
+
const DEFAULT_SKELETON_HEADER_FOOTER = {
|
|
534
|
+
lines: [],
|
|
535
|
+
drawings: /* @__PURE__ */ new Map(),
|
|
536
|
+
height: 0,
|
|
537
|
+
st: 0,
|
|
538
|
+
ed: 0,
|
|
539
|
+
marginLeft: 0
|
|
540
|
+
};
|
|
541
|
+
const DEFAULT_SKELETON_HEADER = {
|
|
542
|
+
...DEFAULT_SKELETON_HEADER_FOOTER,
|
|
543
|
+
marginTop: 20
|
|
544
|
+
};
|
|
545
|
+
const DEFAULT_SKELETON_FOOTER = {
|
|
546
|
+
...DEFAULT_SKELETON_HEADER_FOOTER,
|
|
547
|
+
marginBottom: 20
|
|
548
|
+
};
|
|
549
|
+
const DEFAULT_OFFSET_SPACING = 1;
|
|
550
|
+
const DEFAULT_DOCUMENT_FONTSIZE = 14;
|
|
551
|
+
/**
|
|
552
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
|
|
553
|
+
*/
|
|
554
|
+
let CURSOR_TYPE = /* @__PURE__ */ function(CURSOR_TYPE) {
|
|
555
|
+
CURSOR_TYPE["DEFAULT"] = "default";
|
|
556
|
+
CURSOR_TYPE["AUTO"] = "auto";
|
|
557
|
+
CURSOR_TYPE["CROSSHAIR"] = "crosshair";
|
|
558
|
+
CURSOR_TYPE["POINTER"] = "pointer";
|
|
559
|
+
CURSOR_TYPE["MOVE"] = "move";
|
|
560
|
+
CURSOR_TYPE["EAST_RESIZE"] = "e-resize";
|
|
561
|
+
CURSOR_TYPE["NORTH_EAST_RESIZE"] = "ne-resize";
|
|
562
|
+
CURSOR_TYPE["NORTH_WEST_RESIZE"] = "nw-resize";
|
|
563
|
+
CURSOR_TYPE["NORTH_RESIZE"] = "n-resize";
|
|
564
|
+
CURSOR_TYPE["SOUTH_EAST_RESIZE"] = "se-resize";
|
|
565
|
+
CURSOR_TYPE["SOUTH_WEST_RESIZE"] = "sw-resize";
|
|
566
|
+
CURSOR_TYPE["SOUTH_RESIZE"] = "s-resize";
|
|
567
|
+
CURSOR_TYPE["WEST_RESIZE"] = "w-resize";
|
|
568
|
+
CURSOR_TYPE["EAST_WEST_RESIZE"] = "ew-resize";
|
|
569
|
+
CURSOR_TYPE["NORTH_SOUTH_RESIZE"] = "ns-resize";
|
|
570
|
+
CURSOR_TYPE["NORTH_EAST_SOUTH_WEST_RESIZE"] = "nesw-resize";
|
|
571
|
+
CURSOR_TYPE["NORTH_WEST_SOUTH_EAST_RESIZE"] = "nwse-resize";
|
|
572
|
+
CURSOR_TYPE["TEXT"] = "text";
|
|
573
|
+
CURSOR_TYPE["WAIT"] = "wait";
|
|
574
|
+
CURSOR_TYPE["HELP"] = "help";
|
|
575
|
+
CURSOR_TYPE["CELL"] = "cell";
|
|
576
|
+
CURSOR_TYPE["NONE"] = "none";
|
|
577
|
+
CURSOR_TYPE["VERTICAL_TEXT"] = "vertical-text";
|
|
578
|
+
CURSOR_TYPE["NO_DROP"] = "no-drop";
|
|
579
|
+
CURSOR_TYPE["GRAB"] = "grab";
|
|
580
|
+
CURSOR_TYPE["GRABBING"] = "grabbing";
|
|
581
|
+
CURSOR_TYPE["ALL_SCROLL"] = "all-scroll";
|
|
582
|
+
CURSOR_TYPE["COLUMN_RESIZE"] = "col-resize";
|
|
583
|
+
CURSOR_TYPE["ROW_RESIZE"] = "row-resize";
|
|
584
|
+
CURSOR_TYPE["PROGRESS"] = "progress";
|
|
585
|
+
CURSOR_TYPE["NOT_ALLOWED"] = "not-allowed";
|
|
586
|
+
CURSOR_TYPE["ZOOM_IN"] = "zoom-in";
|
|
587
|
+
CURSOR_TYPE["ZOOM_OUT"] = "zoom-out";
|
|
588
|
+
return CURSOR_TYPE;
|
|
589
|
+
}({});
|
|
590
|
+
let DOCUMENT_CONTEXT_CLIP_TYPE = /* @__PURE__ */ function(DOCUMENT_CONTEXT_CLIP_TYPE) {
|
|
591
|
+
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["noClip"] = 0] = "noClip";
|
|
592
|
+
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["DOC_SIZE"] = 1] = "DOC_SIZE";
|
|
593
|
+
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_LEFT"] = 2] = "CONTENT_SIZE_LEFT";
|
|
594
|
+
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_CENTER"] = 3] = "CONTENT_SIZE_CENTER";
|
|
595
|
+
DOCUMENT_CONTEXT_CLIP_TYPE[DOCUMENT_CONTEXT_CLIP_TYPE["CONTENT_SIZE_Right"] = 4] = "CONTENT_SIZE_Right";
|
|
596
|
+
return DOCUMENT_CONTEXT_CLIP_TYPE;
|
|
597
|
+
}({});
|
|
598
|
+
const COLOR_BLACK_RGB = "rgb(0,0,0)";
|
|
599
|
+
let BORDER_TYPE = /* @__PURE__ */ function(BORDER_TYPE) {
|
|
600
|
+
BORDER_TYPE["TOP"] = "t";
|
|
601
|
+
BORDER_TYPE["BOTTOM"] = "b";
|
|
602
|
+
BORDER_TYPE["LEFT"] = "l";
|
|
603
|
+
BORDER_TYPE["RIGHT"] = "r";
|
|
604
|
+
BORDER_TYPE["TL_BR"] = "tl_br";
|
|
605
|
+
BORDER_TYPE["TL_BC"] = "tl_bc";
|
|
606
|
+
BORDER_TYPE["TL_MR"] = "tl_mr";
|
|
607
|
+
BORDER_TYPE["BL_TR"] = "bl_tr";
|
|
608
|
+
BORDER_TYPE["ML_TR"] = "ml_tr";
|
|
609
|
+
BORDER_TYPE["BC_TR"] = "bc_tr";
|
|
610
|
+
return BORDER_TYPE;
|
|
611
|
+
}({});
|
|
612
|
+
let ORIENTATION_TYPE = /* @__PURE__ */ function(ORIENTATION_TYPE) {
|
|
613
|
+
ORIENTATION_TYPE[ORIENTATION_TYPE["UP"] = 0] = "UP";
|
|
614
|
+
ORIENTATION_TYPE[ORIENTATION_TYPE["DOWN"] = 1] = "DOWN";
|
|
615
|
+
return ORIENTATION_TYPE;
|
|
616
|
+
}({});
|
|
617
|
+
let RENDER_CLASS_TYPE = /* @__PURE__ */ function(RENDER_CLASS_TYPE) {
|
|
618
|
+
RENDER_CLASS_TYPE["ENGINE"] = "Engine";
|
|
619
|
+
RENDER_CLASS_TYPE["SCENE"] = "Scene";
|
|
620
|
+
RENDER_CLASS_TYPE["BASE_OBJECT"] = "BaseObject";
|
|
621
|
+
RENDER_CLASS_TYPE["SCENE_VIEWER"] = "SceneViewer";
|
|
622
|
+
RENDER_CLASS_TYPE["CANVAS"] = "Canvas";
|
|
623
|
+
RENDER_CLASS_TYPE["VIEWPORT"] = "Viewport";
|
|
624
|
+
RENDER_CLASS_TYPE["LAYER"] = "Layer";
|
|
625
|
+
RENDER_CLASS_TYPE["GROUP"] = "Group";
|
|
626
|
+
RENDER_CLASS_TYPE["IMAGE"] = "Image";
|
|
627
|
+
RENDER_CLASS_TYPE["SHAPE"] = "Shape";
|
|
628
|
+
RENDER_CLASS_TYPE["TEXT"] = "Text";
|
|
629
|
+
return RENDER_CLASS_TYPE;
|
|
630
|
+
}({});
|
|
631
|
+
const MAXIMUM_ROW_HEIGHT = 2e3;
|
|
632
|
+
const MAXIMUM_COL_WIDTH = 2e3;
|
|
633
|
+
const MIN_COL_WIDTH = 2;
|
|
634
|
+
const FIX_ONE_PIXEL_BLUR_OFFSET = .5;
|
|
635
|
+
const DRAWING_OBJECT_LOWER_LAYER_INDEX = 3;
|
|
636
|
+
const DRAWING_OBJECT_LAYER_INDEX = 4;
|
|
637
|
+
const DRAWING_OBJECT_UPPER_LAYER_INDEX = 5;
|
|
638
|
+
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/basics/i-document-skeleton-cached.ts
|
|
641
|
+
let DocumentSkeletonPageType = /* @__PURE__ */ function(DocumentSkeletonPageType) {
|
|
642
|
+
DocumentSkeletonPageType[DocumentSkeletonPageType["BODY"] = 0] = "BODY";
|
|
643
|
+
DocumentSkeletonPageType[DocumentSkeletonPageType["HEADER"] = 1] = "HEADER";
|
|
644
|
+
DocumentSkeletonPageType[DocumentSkeletonPageType["FOOTER"] = 2] = "FOOTER";
|
|
645
|
+
DocumentSkeletonPageType[DocumentSkeletonPageType["CELL"] = 3] = "CELL";
|
|
646
|
+
return DocumentSkeletonPageType;
|
|
647
|
+
}({});
|
|
648
|
+
let SkeletonType = /* @__PURE__ */ function(SkeletonType) {
|
|
649
|
+
SkeletonType[SkeletonType["GLYPH"] = 0] = "GLYPH";
|
|
650
|
+
SkeletonType[SkeletonType["DIVIDE"] = 1] = "DIVIDE";
|
|
651
|
+
SkeletonType[SkeletonType["LINE"] = 2] = "LINE";
|
|
652
|
+
SkeletonType[SkeletonType["COLUMN"] = 3] = "COLUMN";
|
|
653
|
+
SkeletonType[SkeletonType["SECTION"] = 4] = "SECTION";
|
|
654
|
+
SkeletonType[SkeletonType["PAGE"] = 5] = "PAGE";
|
|
655
|
+
SkeletonType[SkeletonType["DRAWING"] = 6] = "DRAWING";
|
|
656
|
+
SkeletonType[SkeletonType["BULLET"] = 7] = "BULLET";
|
|
657
|
+
SkeletonType[SkeletonType["HEADER"] = 8] = "HEADER";
|
|
658
|
+
SkeletonType[SkeletonType["FOOTER"] = 9] = "FOOTER";
|
|
659
|
+
SkeletonType[SkeletonType["ALL"] = 10] = "ALL";
|
|
660
|
+
return SkeletonType;
|
|
661
|
+
}({});
|
|
662
|
+
let BreakType = /* @__PURE__ */ function(BreakType) {
|
|
663
|
+
BreakType[BreakType["SECTION"] = 0] = "SECTION";
|
|
664
|
+
BreakType[BreakType["PAGE"] = 1] = "PAGE";
|
|
665
|
+
BreakType[BreakType["COLUMN"] = 2] = "COLUMN";
|
|
666
|
+
return BreakType;
|
|
667
|
+
}({});
|
|
668
|
+
let LineType = /* @__PURE__ */ function(LineType) {
|
|
669
|
+
LineType[LineType["PARAGRAPH"] = 0] = "PARAGRAPH";
|
|
670
|
+
LineType[LineType["BLOCK"] = 1] = "BLOCK";
|
|
671
|
+
return LineType;
|
|
672
|
+
}({});
|
|
673
|
+
let GlyphType = /* @__PURE__ */ function(GlyphType) {
|
|
674
|
+
GlyphType[GlyphType["LETTER"] = 0] = "LETTER";
|
|
675
|
+
GlyphType[GlyphType["WORD"] = 1] = "WORD";
|
|
676
|
+
GlyphType[GlyphType["LIST"] = 2] = "LIST";
|
|
677
|
+
GlyphType[GlyphType["PLACEHOLDER"] = 3] = "PLACEHOLDER";
|
|
678
|
+
GlyphType[GlyphType["TAB"] = 4] = "TAB";
|
|
679
|
+
GlyphType[GlyphType["IMAGE"] = 5] = "IMAGE";
|
|
680
|
+
GlyphType[GlyphType["AT"] = 6] = "AT";
|
|
681
|
+
GlyphType[GlyphType["MATH"] = 7] = "MATH";
|
|
682
|
+
GlyphType[GlyphType["MULTI_LINE"] = 8] = "MULTI_LINE";
|
|
683
|
+
GlyphType[GlyphType["CUSTOM"] = 9] = "CUSTOM";
|
|
684
|
+
return GlyphType;
|
|
685
|
+
}({});
|
|
686
|
+
/**
|
|
687
|
+
* Determining the text layout, whether it's vertical or horizontal,
|
|
688
|
+
* data storage is primarily horizontal,
|
|
689
|
+
* and vertical layout is supported through rendering and drawing.
|
|
690
|
+
*/
|
|
691
|
+
let PageLayoutType = /* @__PURE__ */ function(PageLayoutType) {
|
|
692
|
+
PageLayoutType[PageLayoutType["VERTICAL"] = 0] = "VERTICAL";
|
|
693
|
+
PageLayoutType[PageLayoutType["HORIZONTAL"] = 1] = "HORIZONTAL";
|
|
694
|
+
PageLayoutType[PageLayoutType["AUTO"] = 2] = "AUTO";
|
|
695
|
+
return PageLayoutType;
|
|
696
|
+
}({});
|
|
697
|
+
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/basics/document-node-tools.ts
|
|
700
|
+
function hasListGlyph(glyph) {
|
|
701
|
+
var _glyphGroup$;
|
|
702
|
+
const divide = glyph === null || glyph === void 0 ? void 0 : glyph.parent;
|
|
703
|
+
if (divide == null) return false;
|
|
704
|
+
return ((_glyphGroup$ = divide.glyphGroup[0]) === null || _glyphGroup$ === void 0 ? void 0 : _glyphGroup$.glyphType) === 2;
|
|
705
|
+
}
|
|
706
|
+
function isIndentByGlyph(glyph, body) {
|
|
707
|
+
const paragraph = getParagraphByGlyph(glyph, body);
|
|
708
|
+
if (paragraph == null) return false;
|
|
709
|
+
const { paragraphStyle } = paragraph;
|
|
710
|
+
if (paragraphStyle == null) return false;
|
|
711
|
+
return checkParagraphHasIndentByStyle(paragraphStyle);
|
|
712
|
+
}
|
|
713
|
+
function isLastGlyph(glyph) {
|
|
714
|
+
const divide = glyph === null || glyph === void 0 ? void 0 : glyph.parent;
|
|
715
|
+
const line = divide === null || divide === void 0 ? void 0 : divide.parent;
|
|
716
|
+
const glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup;
|
|
717
|
+
const divides = line === null || line === void 0 ? void 0 : line.divides;
|
|
718
|
+
if (glyphGroup && glyph && divides && divide) {
|
|
719
|
+
const glyphIndex = glyphGroup.indexOf(glyph);
|
|
720
|
+
if (divides.indexOf(divide) === divides.length - 1 && glyphIndex === glyphGroup.length - 1) return true;
|
|
721
|
+
}
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
function isFirstGlyph(glyph) {
|
|
725
|
+
const divide = glyph === null || glyph === void 0 ? void 0 : glyph.parent;
|
|
726
|
+
const line = divide === null || divide === void 0 ? void 0 : divide.parent;
|
|
727
|
+
const glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup;
|
|
728
|
+
const divides = line === null || line === void 0 ? void 0 : line.divides;
|
|
729
|
+
if (glyphGroup && glyph && divides && divide) {
|
|
730
|
+
const glyphIndex = glyphGroup.indexOf(glyph);
|
|
731
|
+
const divideIndex = divides.indexOf(divide);
|
|
732
|
+
if (divideIndex === 0 && glyphIndex === 0) return true;
|
|
733
|
+
if (divideIndex === 0 && glyphIndex === 1 && glyphGroup[0].glyphType === 2) return true;
|
|
734
|
+
}
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
function getParagraphByGlyph(glyph, body) {
|
|
738
|
+
var _glyph$parent;
|
|
739
|
+
const line = glyph === null || glyph === void 0 || (_glyph$parent = glyph.parent) === null || _glyph$parent === void 0 ? void 0 : _glyph$parent.parent;
|
|
740
|
+
if (line == null || body == null) return;
|
|
741
|
+
const paragraphs = body.paragraphs;
|
|
742
|
+
if (paragraphs == null) return;
|
|
743
|
+
for (let i = 0; i < paragraphs.length; i++) {
|
|
744
|
+
const paragraph = paragraphs[i];
|
|
745
|
+
const prevParagraph = paragraphs[i - 1];
|
|
746
|
+
if (paragraph.startIndex === line.paragraphIndex) {
|
|
747
|
+
var _prevParagraph$startI;
|
|
748
|
+
return {
|
|
749
|
+
...paragraph,
|
|
750
|
+
paragraphStart: ((_prevParagraph$startI = prevParagraph === null || prevParagraph === void 0 ? void 0 : prevParagraph.startIndex) !== null && _prevParagraph$startI !== void 0 ? _prevParagraph$startI : -1) + 1,
|
|
751
|
+
paragraphEnd: paragraph.startIndex
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function isPlaceholderOrSpace(glyph) {
|
|
757
|
+
if (glyph == null) return false;
|
|
758
|
+
if ([
|
|
759
|
+
DataStreamTreeTokenType.PARAGRAPH,
|
|
760
|
+
DataStreamTreeTokenType.TAB,
|
|
761
|
+
DataStreamTreeTokenType.SECTION_BREAK
|
|
762
|
+
].indexOf(glyph.streamType) !== -1 || glyph.content === DataStreamTreeTokenType.SPACE) return true;
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
function isSameLine(glyph1, glyph2) {
|
|
766
|
+
if (glyph1 == null) return false;
|
|
767
|
+
if (glyph2 == null) return false;
|
|
768
|
+
if (glyph1.parent == null) return false;
|
|
769
|
+
if (glyph2.parent == null) return false;
|
|
770
|
+
return glyph1.parent.parent === glyph2.parent.parent;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
//#endregion
|
|
774
|
+
//#region src/basics/tools.ts
|
|
775
|
+
const DEG180 = 180;
|
|
776
|
+
const PI_OVER_DEG180 = Math.PI / DEG180;
|
|
777
|
+
const DEG180_OVER_PI = DEG180 / Math.PI;
|
|
778
|
+
const RGB_PAREN = "rgb(";
|
|
779
|
+
const RGBA_PAREN = "rgba(";
|
|
780
|
+
const getColor = (RgbArray, opacity) => {
|
|
781
|
+
if (!RgbArray) return `${RGB_PAREN}0,0,0)`;
|
|
782
|
+
if (opacity != null) return `${RGBA_PAREN + RgbArray.join(",")},${opacity})`;
|
|
783
|
+
return `${RGB_PAREN + RgbArray.join(",")})`;
|
|
784
|
+
};
|
|
785
|
+
const PERCENT_TO_NUMBER_DIVIDE = 100;
|
|
786
|
+
const toPx = (num, ReferenceValue) => {
|
|
787
|
+
if (Tools.isNumber(num)) return num;
|
|
788
|
+
if (ReferenceValue && num && Tools.isString(num) && num.substr(num.length - 1, 1) === "%") return ReferenceValue * (Number.parseFloat(num) / PERCENT_TO_NUMBER_DIVIDE);
|
|
789
|
+
return 0;
|
|
790
|
+
};
|
|
791
|
+
const ONE_FRAME_NUMBER = 16;
|
|
792
|
+
/**
|
|
793
|
+
* Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
|
|
794
|
+
* @param func - the function to be called
|
|
795
|
+
* @param requester - the object that will request the next frame. Falls back to window.
|
|
796
|
+
* @returns frame number
|
|
797
|
+
*/
|
|
798
|
+
const requestNewFrame = (func, requester) => {
|
|
799
|
+
if (!requester) requester = window;
|
|
800
|
+
if (requester.requestPostAnimationFrame) return requester.requestPostAnimationFrame(func);
|
|
801
|
+
if (requester.requestAnimationFrame) return requester.requestAnimationFrame(func);
|
|
802
|
+
if (requester.msRequestAnimationFrame) return requester.msRequestAnimationFrame(func);
|
|
803
|
+
if (requester.webkitRequestAnimationFrame) return requester.webkitRequestAnimationFrame(func);
|
|
804
|
+
if (requester.mozRequestAnimationFrame) return requester.mozRequestAnimationFrame(func);
|
|
805
|
+
if (requester.oRequestAnimationFrame) return requester.oRequestAnimationFrame(func);
|
|
806
|
+
return setTimeout(func, ONE_FRAME_NUMBER);
|
|
807
|
+
};
|
|
808
|
+
const cancelRequestFrame = (requestID, requester) => {
|
|
809
|
+
if (!requester) requester = window;
|
|
810
|
+
if (requester.requestPostAnimationFrame) return requester.cancelPostAnimationFrame(requestID);
|
|
811
|
+
if (requester.requestAnimationFrame) return requester.cancelAnimationFrame(requestID);
|
|
812
|
+
if (requester.msRequestAnimationFrame) return requester.msCancelAnimationFrame(requestID);
|
|
813
|
+
if (requester.webkitRequestAnimationFrame) return requester.webkitCancelAnimationFrame(requestID);
|
|
814
|
+
if (requester.mozRequestAnimationFrame) return requester.mozCancelAnimationFrame(requestID);
|
|
815
|
+
if (requester.oRequestAnimationFrame) return requester.oCancelAnimationFrame(requestID);
|
|
816
|
+
return clearTimeout(requestID);
|
|
817
|
+
};
|
|
818
|
+
const createCanvasElement = () => {
|
|
819
|
+
const canvas = document.createElement("canvas");
|
|
820
|
+
canvas.dir = "ltr";
|
|
821
|
+
try {
|
|
822
|
+
canvas.style = canvas.style || {};
|
|
823
|
+
} catch (e) {
|
|
824
|
+
console.error(e);
|
|
825
|
+
}
|
|
826
|
+
return canvas;
|
|
827
|
+
};
|
|
828
|
+
const createImageElement = () => document.createElement("img");
|
|
829
|
+
const radToDeg = (rad) => rad * DEG180_OVER_PI;
|
|
830
|
+
const degToRad = (deg) => deg * PI_OVER_DEG180;
|
|
831
|
+
/**
|
|
832
|
+
* Gets the pointer prefix to use
|
|
833
|
+
* @param engine defines the engine we are finding the prefix for
|
|
834
|
+
* @returns "pointer" if touch is enabled. Else returns "mouse"
|
|
835
|
+
*/
|
|
836
|
+
const getPointerPrefix = () => {
|
|
837
|
+
let eventPrefix = "pointer";
|
|
838
|
+
if (typeof window !== "undefined" && !window.PointerEvent && typeof navigator !== "undefined") eventPrefix = "mouse";
|
|
839
|
+
if (Tools.isTablet() && !Tools.isIPhone() && !(document && "ontouchend" in document)) eventPrefix = "mouse";
|
|
840
|
+
return eventPrefix;
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* Utility function to detect if the current user agent is Safari
|
|
844
|
+
* @returns whether or not the current user agent is safari
|
|
845
|
+
*/
|
|
846
|
+
const IsSafari = () => {
|
|
847
|
+
if (Tools.getBrowserType() === "safari") return true;
|
|
848
|
+
return false;
|
|
849
|
+
};
|
|
850
|
+
const GENERATE_RANDOM_KEY_DEFAULT_LENGTH = 4;
|
|
851
|
+
const generateRandomKey = (prefix = "obj", keyLength = GENERATE_RANDOM_KEY_DEFAULT_LENGTH) => {
|
|
852
|
+
const userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
|
|
853
|
+
let mid = "";
|
|
854
|
+
for (let i = 0; i < keyLength; i++) mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
|
|
855
|
+
const time = (/* @__PURE__ */ new Date()).getTime();
|
|
856
|
+
return `${prefix}_${mid}_${time}`;
|
|
857
|
+
};
|
|
858
|
+
function getValueType(value) {
|
|
859
|
+
return Object.prototype.toString.apply(value);
|
|
860
|
+
}
|
|
861
|
+
function isFunction(value) {
|
|
862
|
+
return getValueType(value) === "[object Function]";
|
|
863
|
+
}
|
|
864
|
+
function isDate(value) {
|
|
865
|
+
return getValueType(value) === "[object Date]";
|
|
866
|
+
}
|
|
867
|
+
function isRegExp(value) {
|
|
868
|
+
return getValueType(value) === "[object RegExp]";
|
|
869
|
+
}
|
|
870
|
+
function isArray(value) {
|
|
871
|
+
return getValueType(value) === "[object Array]";
|
|
872
|
+
}
|
|
873
|
+
function isString(value) {
|
|
874
|
+
return getValueType(value) === "[object String]";
|
|
875
|
+
}
|
|
876
|
+
function isNumber(value) {
|
|
877
|
+
return getValueType(value) === "[object Number]";
|
|
878
|
+
}
|
|
879
|
+
function isObject(value) {
|
|
880
|
+
return getValueType(value) === "[object Object]";
|
|
881
|
+
}
|
|
882
|
+
function precisionTo(num, accurate) {
|
|
883
|
+
accurate = 10 ** accurate;
|
|
884
|
+
return Math.round(num * accurate) / accurate;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* When drawing lines, it is necessary to align their precision.
|
|
888
|
+
* performance testing
|
|
889
|
+
* var time = performance.now(); for(let i=0;i<100000000;i++){ fixLineWidthByScale(i, 0.666); }; console.log(performance.now()-time);
|
|
890
|
+
*/
|
|
891
|
+
function fixLineWidthByScale(num, scale) {
|
|
892
|
+
return Math.round(num * scale) / scale;
|
|
893
|
+
}
|
|
894
|
+
function getFontStyleString(textStyle) {
|
|
895
|
+
const defaultFont = DEFAULT_STYLES.ff;
|
|
896
|
+
const defaultFontSize = DEFAULT_STYLES.fs;
|
|
897
|
+
if (!textStyle) {
|
|
898
|
+
const fontString = `${defaultFontSize}pt ${defaultFont}`;
|
|
899
|
+
return {
|
|
900
|
+
fontCache: fontString,
|
|
901
|
+
fontString,
|
|
902
|
+
fontSize: defaultFontSize,
|
|
903
|
+
originFontSize: defaultFontSize,
|
|
904
|
+
fontFamily: defaultFont
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
let italic = FontStyleType.ITALIC;
|
|
908
|
+
if (textStyle.it === 0 || textStyle.it === void 0) italic = FontStyleType.NORMAL;
|
|
909
|
+
let bold = FontStyleType.BOLD;
|
|
910
|
+
if (textStyle.bl === 0 || textStyle.bl === void 0) bold = FontStyleType.NORMAL;
|
|
911
|
+
let originFontSize = defaultFontSize;
|
|
912
|
+
if (textStyle.fs) originFontSize = textStyle.fs;
|
|
913
|
+
let fontSize = originFontSize;
|
|
914
|
+
const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
|
|
915
|
+
const { va: baselineOffset } = textStyle;
|
|
916
|
+
if (baselineOffset === BaselineOffset.SUBSCRIPT || baselineOffset === BaselineOffset.SUPERSCRIPT) {
|
|
917
|
+
const { sbr, spr } = FontCache.getBaselineOffsetInfo(fontFamilyResult, fontSize);
|
|
918
|
+
fontSize *= baselineOffset === BaselineOffset.SUBSCRIPT ? sbr : spr;
|
|
919
|
+
}
|
|
920
|
+
const fontStringPure = `${italic} ${bold} ${fontSize}pt ${fontFamilyResult}`;
|
|
921
|
+
return {
|
|
922
|
+
fontCache: fontStringPure,
|
|
923
|
+
fontString: `${fontStringPure}, ${DEFAULT_FONTFACE_PLANE} `,
|
|
924
|
+
fontSize,
|
|
925
|
+
originFontSize,
|
|
926
|
+
fontFamily: fontFamilyResult
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
function normalizeFontFamily(fontFamily, defaultFont) {
|
|
930
|
+
if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return defaultFont;
|
|
931
|
+
return fontFamily.split(",").map((item) => {
|
|
932
|
+
const family = item.trim().replace(/^['"]|['"]$/g, "");
|
|
933
|
+
return family.includes(" ") ? `"${family}"` : family;
|
|
934
|
+
}).filter(Boolean).join(", ");
|
|
935
|
+
}
|
|
936
|
+
function hasAllLatin(text) {
|
|
937
|
+
if (!/[\u0000-\u024F]/gi.exec(text)) return false;
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
function hasBasicLatin(text) {
|
|
941
|
+
if (!/[\u0000-\u007F]/gi.exec(text)) return false;
|
|
942
|
+
return true;
|
|
943
|
+
}
|
|
944
|
+
function hasLatinOneSupplement(text) {
|
|
945
|
+
if (!/[\u0080-\u00FF]/gi.exec(text)) return false;
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
948
|
+
function hasLatinExtendedA(text) {
|
|
949
|
+
if (!/[\u0100-\u017F]/gi.exec(text)) return false;
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
function hasLatinExtendedB(text) {
|
|
953
|
+
if (!/[\u0180-\u024F]/gi.exec(text)) return false;
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
957
|
+
function getFirstGrapheme(text) {
|
|
958
|
+
var _it$next$value$segmen, _it$next$value;
|
|
959
|
+
return (_it$next$value$segmen = (_it$next$value = segmenter.segment(text)[Symbol.iterator]().next().value) === null || _it$next$value === void 0 ? void 0 : _it$next$value.segment) !== null && _it$next$value$segmen !== void 0 ? _it$next$value$segmen : null;
|
|
960
|
+
}
|
|
961
|
+
function isEmojiGrapheme(grapheme) {
|
|
962
|
+
if (/\p{Extended_Pictographic}/u.test(grapheme)) return true;
|
|
963
|
+
if (/^\p{Regional_Indicator}{2}$/u.test(grapheme)) return true;
|
|
964
|
+
if (/^[0-9#*]\uFE0F?\u20E3$/u.test(grapheme)) return true;
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
function startWithEmoji(text) {
|
|
968
|
+
const first = getFirstGrapheme(text);
|
|
969
|
+
return first ? isEmojiGrapheme(first) : false;
|
|
970
|
+
}
|
|
971
|
+
function hasArabic(text) {
|
|
972
|
+
return /[\u0600-\u06FF]|[\u0750-\u0750]|[\u0870-\u08FF]|[\uFB50-\uFDFF]|[\uFE70-\uFEFF]/gi.test(text);
|
|
973
|
+
}
|
|
974
|
+
function hasTibetan(text) {
|
|
975
|
+
return /[\u0180-\u024F]/gi.test(text);
|
|
976
|
+
}
|
|
977
|
+
function hasThai(text) {
|
|
978
|
+
return /[\u0E00-\u0E7F]/.test(text);
|
|
979
|
+
}
|
|
980
|
+
function hasSpace(text) {
|
|
981
|
+
return /\s+/g.test(text);
|
|
982
|
+
}
|
|
983
|
+
function isCjkLeftAlignedPunctuation(text) {
|
|
984
|
+
return [
|
|
985
|
+
"”",
|
|
986
|
+
"’",
|
|
987
|
+
",",
|
|
988
|
+
"。",
|
|
989
|
+
".",
|
|
990
|
+
"、",
|
|
991
|
+
":",
|
|
992
|
+
";",
|
|
993
|
+
"?",
|
|
994
|
+
"!",
|
|
995
|
+
"》",
|
|
996
|
+
")",
|
|
997
|
+
"』",
|
|
998
|
+
"」",
|
|
999
|
+
"】",
|
|
1000
|
+
"〗",
|
|
1001
|
+
"〕",
|
|
1002
|
+
"〉",
|
|
1003
|
+
"]",
|
|
1004
|
+
"}"
|
|
1005
|
+
].indexOf(text) > -1;
|
|
1006
|
+
}
|
|
1007
|
+
function isCjkRightAlignedPunctuation(text) {
|
|
1008
|
+
return [
|
|
1009
|
+
"“",
|
|
1010
|
+
"‘",
|
|
1011
|
+
"《",
|
|
1012
|
+
"(",
|
|
1013
|
+
"『",
|
|
1014
|
+
"「",
|
|
1015
|
+
"【",
|
|
1016
|
+
"〖",
|
|
1017
|
+
"〔",
|
|
1018
|
+
"〈",
|
|
1019
|
+
"[",
|
|
1020
|
+
"{"
|
|
1021
|
+
].indexOf(text) > -1;
|
|
1081
1022
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
*/
|
|
1085
|
-
function all() {
|
|
1086
|
-
return regexp.charset(...CJK_ALL_DATA);
|
|
1023
|
+
function isCjkCenterAlignedPunctuation(text) {
|
|
1024
|
+
return ["・", "·"].indexOf(text) > -1;
|
|
1087
1025
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1026
|
+
const one_thousand = 1e3;
|
|
1027
|
+
let dpi_cache;
|
|
1028
|
+
function getDPI() {
|
|
1029
|
+
if (dpi_cache) return dpi_cache;
|
|
1030
|
+
let i = 56;
|
|
1031
|
+
for (; i < one_thousand * 2; i++) if (matchMedia(`(max-resolution: ${i}dpi)`).matches === true) return i;
|
|
1032
|
+
dpi_cache = i;
|
|
1033
|
+
setTimeout(() => {
|
|
1034
|
+
dpi_cache = null;
|
|
1035
|
+
}, one_thousand);
|
|
1036
|
+
return i;
|
|
1093
1037
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
return CJK_ALL_REG.test(text);
|
|
1038
|
+
const BENCHMARK_DPI = 72;
|
|
1039
|
+
const BENCHMARK_CONVERT_MM = 25.4;
|
|
1040
|
+
function ptToPx(pt) {
|
|
1041
|
+
return pt / (BENCHMARK_DPI / getDPI());
|
|
1099
1042
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
*/
|
|
1103
|
-
function hasCJKPunctuation(text) {
|
|
1104
|
-
return CJK_PUNCTUATION_REG.test(text);
|
|
1043
|
+
function pxToPt(px) {
|
|
1044
|
+
return px * (BENCHMARK_DPI / getDPI());
|
|
1105
1045
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
*/
|
|
1109
|
-
const cjk = {
|
|
1110
|
-
CJK_LETTER_SOURCE,
|
|
1111
|
-
CJK_PUNCTUATION_SOURCE,
|
|
1112
|
-
CJK_ALL_SOURCE,
|
|
1113
|
-
CJK_LETTER_REG,
|
|
1114
|
-
CJK_PUNCTUATION_REG,
|
|
1115
|
-
CJK_ALL_REG,
|
|
1116
|
-
CJK_LETTER_DATA,
|
|
1117
|
-
CJK_PUNCTUATION_DATA,
|
|
1118
|
-
CJK_ALL_DATA,
|
|
1119
|
-
letters,
|
|
1120
|
-
punctuations,
|
|
1121
|
-
all,
|
|
1122
|
-
hasCJKText,
|
|
1123
|
-
hasCJK,
|
|
1124
|
-
hasCJKPunctuation
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
//#endregion
|
|
1128
|
-
//#region src/basics/i-document-skeleton-cached.ts
|
|
1129
|
-
let DocumentSkeletonPageType = /* @__PURE__ */ function(DocumentSkeletonPageType) {
|
|
1130
|
-
DocumentSkeletonPageType[DocumentSkeletonPageType["BODY"] = 0] = "BODY";
|
|
1131
|
-
DocumentSkeletonPageType[DocumentSkeletonPageType["HEADER"] = 1] = "HEADER";
|
|
1132
|
-
DocumentSkeletonPageType[DocumentSkeletonPageType["FOOTER"] = 2] = "FOOTER";
|
|
1133
|
-
DocumentSkeletonPageType[DocumentSkeletonPageType["CELL"] = 3] = "CELL";
|
|
1134
|
-
return DocumentSkeletonPageType;
|
|
1135
|
-
}({});
|
|
1136
|
-
let SkeletonType = /* @__PURE__ */ function(SkeletonType) {
|
|
1137
|
-
SkeletonType[SkeletonType["GLYPH"] = 0] = "GLYPH";
|
|
1138
|
-
SkeletonType[SkeletonType["DIVIDE"] = 1] = "DIVIDE";
|
|
1139
|
-
SkeletonType[SkeletonType["LINE"] = 2] = "LINE";
|
|
1140
|
-
SkeletonType[SkeletonType["COLUMN"] = 3] = "COLUMN";
|
|
1141
|
-
SkeletonType[SkeletonType["SECTION"] = 4] = "SECTION";
|
|
1142
|
-
SkeletonType[SkeletonType["PAGE"] = 5] = "PAGE";
|
|
1143
|
-
SkeletonType[SkeletonType["DRAWING"] = 6] = "DRAWING";
|
|
1144
|
-
SkeletonType[SkeletonType["BULLET"] = 7] = "BULLET";
|
|
1145
|
-
SkeletonType[SkeletonType["HEADER"] = 8] = "HEADER";
|
|
1146
|
-
SkeletonType[SkeletonType["FOOTER"] = 9] = "FOOTER";
|
|
1147
|
-
SkeletonType[SkeletonType["ALL"] = 10] = "ALL";
|
|
1148
|
-
return SkeletonType;
|
|
1149
|
-
}({});
|
|
1150
|
-
let BreakType = /* @__PURE__ */ function(BreakType) {
|
|
1151
|
-
BreakType[BreakType["SECTION"] = 0] = "SECTION";
|
|
1152
|
-
BreakType[BreakType["PAGE"] = 1] = "PAGE";
|
|
1153
|
-
BreakType[BreakType["COLUMN"] = 2] = "COLUMN";
|
|
1154
|
-
return BreakType;
|
|
1155
|
-
}({});
|
|
1156
|
-
let LineType = /* @__PURE__ */ function(LineType) {
|
|
1157
|
-
LineType[LineType["PARAGRAPH"] = 0] = "PARAGRAPH";
|
|
1158
|
-
LineType[LineType["BLOCK"] = 1] = "BLOCK";
|
|
1159
|
-
return LineType;
|
|
1160
|
-
}({});
|
|
1161
|
-
let GlyphType = /* @__PURE__ */ function(GlyphType) {
|
|
1162
|
-
GlyphType[GlyphType["LETTER"] = 0] = "LETTER";
|
|
1163
|
-
GlyphType[GlyphType["WORD"] = 1] = "WORD";
|
|
1164
|
-
GlyphType[GlyphType["LIST"] = 2] = "LIST";
|
|
1165
|
-
GlyphType[GlyphType["PLACEHOLDER"] = 3] = "PLACEHOLDER";
|
|
1166
|
-
GlyphType[GlyphType["TAB"] = 4] = "TAB";
|
|
1167
|
-
GlyphType[GlyphType["IMAGE"] = 5] = "IMAGE";
|
|
1168
|
-
GlyphType[GlyphType["AT"] = 6] = "AT";
|
|
1169
|
-
GlyphType[GlyphType["MATH"] = 7] = "MATH";
|
|
1170
|
-
GlyphType[GlyphType["MULTI_LINE"] = 8] = "MULTI_LINE";
|
|
1171
|
-
GlyphType[GlyphType["CUSTOM"] = 9] = "CUSTOM";
|
|
1172
|
-
return GlyphType;
|
|
1173
|
-
}({});
|
|
1174
|
-
/**
|
|
1175
|
-
* Determining the text layout, whether it's vertical or horizontal,
|
|
1176
|
-
* data storage is primarily horizontal,
|
|
1177
|
-
* and vertical layout is supported through rendering and drawing.
|
|
1178
|
-
*/
|
|
1179
|
-
let PageLayoutType = /* @__PURE__ */ function(PageLayoutType) {
|
|
1180
|
-
PageLayoutType[PageLayoutType["VERTICAL"] = 0] = "VERTICAL";
|
|
1181
|
-
PageLayoutType[PageLayoutType["HORIZONTAL"] = 1] = "HORIZONTAL";
|
|
1182
|
-
PageLayoutType[PageLayoutType["AUTO"] = 2] = "AUTO";
|
|
1183
|
-
return PageLayoutType;
|
|
1184
|
-
}({});
|
|
1185
|
-
|
|
1186
|
-
//#endregion
|
|
1187
|
-
//#region src/basics/document-node-tools.ts
|
|
1188
|
-
function hasListGlyph(glyph) {
|
|
1189
|
-
var _glyphGroup$;
|
|
1190
|
-
const divide = glyph === null || glyph === void 0 ? void 0 : glyph.parent;
|
|
1191
|
-
if (divide == null) return false;
|
|
1192
|
-
return ((_glyphGroup$ = divide.glyphGroup[0]) === null || _glyphGroup$ === void 0 ? void 0 : _glyphGroup$.glyphType) === 2;
|
|
1046
|
+
function ptToMM(px) {
|
|
1047
|
+
return px * (getDPI() / BENCHMARK_CONVERT_MM);
|
|
1193
1048
|
}
|
|
1194
|
-
function
|
|
1195
|
-
|
|
1196
|
-
if (paragraph == null) return false;
|
|
1197
|
-
const { paragraphStyle } = paragraph;
|
|
1198
|
-
if (paragraphStyle == null) return false;
|
|
1199
|
-
return checkParagraphHasIndentByStyle(paragraphStyle);
|
|
1049
|
+
function pxToInch(px) {
|
|
1050
|
+
return px * getDPI();
|
|
1200
1051
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
const glyphGroup = divide === null || divide === void 0 ? void 0 : divide.glyphGroup;
|
|
1205
|
-
const divides = line === null || line === void 0 ? void 0 : line.divides;
|
|
1206
|
-
if (glyphGroup && glyph && divides && divide) {
|
|
1207
|
-
const glyphIndex = glyphGroup.indexOf(glyph);
|
|
1208
|
-
if (divides.indexOf(divide) === divides.length - 1 && glyphIndex === glyphGroup.length - 1) return true;
|
|
1209
|
-
}
|
|
1210
|
-
return false;
|
|
1052
|
+
function getScale(parentScale) {
|
|
1053
|
+
const { scaleX = 1, scaleY = 1 } = parentScale;
|
|
1054
|
+
return Math.max(scaleX, scaleY);
|
|
1211
1055
|
}
|
|
1212
|
-
function
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
if (
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1056
|
+
function getCellPositionByIndex(row, column, rowHeightAccumulation, columnWidthAccumulation) {
|
|
1057
|
+
const startRow = row - 1;
|
|
1058
|
+
const startColumn = column - 1;
|
|
1059
|
+
const startY = rowHeightAccumulation[startRow] || 0;
|
|
1060
|
+
let endY = rowHeightAccumulation[row];
|
|
1061
|
+
if (endY == null) endY = rowHeightAccumulation[rowHeightAccumulation.length - 1];
|
|
1062
|
+
const startX = columnWidthAccumulation[startColumn] || 0;
|
|
1063
|
+
let endX = columnWidthAccumulation[column];
|
|
1064
|
+
if (endX == null) endX = columnWidthAccumulation[columnWidthAccumulation.length - 1];
|
|
1065
|
+
return {
|
|
1066
|
+
startY,
|
|
1067
|
+
endY,
|
|
1068
|
+
startX,
|
|
1069
|
+
endX
|
|
1070
|
+
};
|
|
1224
1071
|
}
|
|
1225
|
-
function
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1072
|
+
function mergeInfoOffset(mergeInfo, offsetX, offsetY) {
|
|
1073
|
+
return {
|
|
1074
|
+
...mergeInfo,
|
|
1075
|
+
startY: mergeInfo.startY + offsetY,
|
|
1076
|
+
endY: mergeInfo.endY + offsetY,
|
|
1077
|
+
startX: mergeInfo.startX + offsetX,
|
|
1078
|
+
endX: mergeInfo.endX + offsetX
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
function isRectIntersect(rect1, rect2) {
|
|
1082
|
+
return !(rect1.left > rect2.right || rect1.top > rect2.bottom || rect2.left > rect1.right || rect2.top > rect1.bottom);
|
|
1083
|
+
}
|
|
1084
|
+
function injectStyle(styles) {
|
|
1085
|
+
const styleElement = document.createElement("style");
|
|
1086
|
+
document.head.appendChild(styleElement);
|
|
1087
|
+
const styleSheet = styleElement.sheet;
|
|
1088
|
+
for (const style of styles) styleSheet === null || styleSheet === void 0 || styleSheet.insertRule(style, styleSheet.cssRules.length);
|
|
1089
|
+
}
|
|
1090
|
+
function checkStyle(content) {
|
|
1091
|
+
for (let i = 0, len = document.head.childNodes.length; i < len; i++) {
|
|
1092
|
+
const node = document.head.childNodes[i];
|
|
1093
|
+
if (node.nodeName === "STYLE" && node.textContent && node.textContent.indexOf(content) > -1) return true;
|
|
1242
1094
|
}
|
|
1095
|
+
return false;
|
|
1243
1096
|
}
|
|
1244
|
-
function
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1097
|
+
function pxToNum(unit) {
|
|
1098
|
+
return Number(unit.replace(/px/gi, ""));
|
|
1099
|
+
}
|
|
1100
|
+
function getSizeForDom(dom) {
|
|
1101
|
+
const { borderTopWidth, borderLeftWidth, borderRightWidth, borderBottomWidth, width, height } = getComputedStyle(dom);
|
|
1102
|
+
return {
|
|
1103
|
+
top: pxToNum(borderTopWidth),
|
|
1104
|
+
left: pxToNum(borderLeftWidth),
|
|
1105
|
+
right: pxToNum(borderRightWidth),
|
|
1106
|
+
bottom: pxToNum(borderBottomWidth),
|
|
1107
|
+
width: pxToNum(width),
|
|
1108
|
+
height: pxToNum(height)
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
*1 pixel * 0.75 = 1 pt
|
|
1113
|
+
*/
|
|
1114
|
+
const PX_TO_PT_RATIO = .75;
|
|
1115
|
+
function ptToPixel(pt) {
|
|
1116
|
+
return pt / PX_TO_PT_RATIO;
|
|
1117
|
+
}
|
|
1118
|
+
function pixelToPt(px) {
|
|
1119
|
+
return px * PX_TO_PT_RATIO;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Is cell in view ranges.
|
|
1123
|
+
* @param ranges
|
|
1124
|
+
* @param rowIndex
|
|
1125
|
+
* @param colIndex
|
|
1126
|
+
* @returns boolean
|
|
1127
|
+
*/
|
|
1128
|
+
function inViewRanges(ranges, rowIndex, colIndex) {
|
|
1129
|
+
for (const range of ranges) if (rowIndex >= range.startRow && rowIndex <= range.endRow && colIndex >= range.startColumn && colIndex <= range.endColumn) return true;
|
|
1251
1130
|
return false;
|
|
1252
1131
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1132
|
+
/**
|
|
1133
|
+
* If there is an intersection in ranges to the mainRanges, extend it to the first set of ranges.
|
|
1134
|
+
* @param {IRange[]} mainRanges target ranges
|
|
1135
|
+
* @param {IRange[]} ranges
|
|
1136
|
+
*/
|
|
1137
|
+
function expandRangeIfIntersects(mainRanges, ranges) {
|
|
1138
|
+
const intersects = [];
|
|
1139
|
+
for (const mainRange of mainRanges) for (const range of ranges) if (Rectangle.simpleRangesIntersect(mainRange, range)) intersects.push(range);
|
|
1140
|
+
return mainRanges.concat(intersects);
|
|
1141
|
+
}
|
|
1142
|
+
function clampRange(range, maxRow, maxColumn) {
|
|
1143
|
+
return {
|
|
1144
|
+
startRow: Tools.clamp(range.startRow, 0, maxRow),
|
|
1145
|
+
endRow: Tools.clamp(range.endRow, 0, maxRow),
|
|
1146
|
+
startColumn: Tools.clamp(range.startColumn, 0, maxColumn),
|
|
1147
|
+
endColumn: Tools.clamp(range.endColumn, 0, maxColumn)
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Get system highlight color in rgb format.
|
|
1152
|
+
*/
|
|
1153
|
+
function getSystemHighlightColor() {
|
|
1154
|
+
const hiddenEle = document.createElement("div");
|
|
1155
|
+
hiddenEle.style.width = "0";
|
|
1156
|
+
hiddenEle.style.height = "0";
|
|
1157
|
+
hiddenEle.style.backgroundColor = "highlight";
|
|
1158
|
+
document.body.append(hiddenEle);
|
|
1159
|
+
const highlightColor = getComputedStyle(hiddenEle).backgroundColor;
|
|
1160
|
+
hiddenEle.remove();
|
|
1161
|
+
return new ColorKit(highlightColor).toRgb();
|
|
1259
1162
|
}
|
|
1260
1163
|
|
|
1261
1164
|
//#endregion
|
|
@@ -1315,7 +1218,9 @@ var Vector2 = class Vector2 {
|
|
|
1315
1218
|
static CatmullRom(value1, value2, value3, value4, amount) {
|
|
1316
1219
|
const squared = amount * amount;
|
|
1317
1220
|
const cubed = amount * squared;
|
|
1318
|
-
|
|
1221
|
+
const x = .5 * (2 * value2.x + (-value1.x + value3.x) * amount + (2 * value1.x - 5 * value2.x + 4 * value3.x - value4.x) * squared + (-value1.x + 3 * value2.x - 3 * value3.x + value4.x) * cubed);
|
|
1222
|
+
const y = .5 * (2 * value2.y + (-value1.y + value3.y) * amount + (2 * value1.y - 5 * value2.y + 4 * value3.y - value4.y) * squared + (-value1.y + 3 * value2.y - 3 * value3.y + value4.y) * cubed);
|
|
1223
|
+
return new Vector2(x, y);
|
|
1319
1224
|
}
|
|
1320
1225
|
/**
|
|
1321
1226
|
* Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
|
|
@@ -1351,7 +1256,9 @@ var Vector2 = class Vector2 {
|
|
|
1351
1256
|
const part2 = -2 * cubed + 3 * squared;
|
|
1352
1257
|
const part3 = cubed - 2 * squared + amount;
|
|
1353
1258
|
const part4 = cubed - squared;
|
|
1354
|
-
|
|
1259
|
+
const x = value1.x * part1 + value2.x * part2 + tangent1.x * part3 + tangent2.x * part4;
|
|
1260
|
+
const y = value1.y * part1 + value2.y * part2 + tangent1.y * part3 + tangent2.y * part4;
|
|
1261
|
+
return new Vector2(x, y);
|
|
1355
1262
|
}
|
|
1356
1263
|
/**
|
|
1357
1264
|
* Returns a new Vector2 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
|
|
@@ -1389,7 +1296,9 @@ var Vector2 = class Vector2 {
|
|
|
1389
1296
|
* @returns a new Vector2
|
|
1390
1297
|
*/
|
|
1391
1298
|
static Lerp(start, end, amount) {
|
|
1392
|
-
|
|
1299
|
+
const x = start.x + (end.x - start.x) * amount;
|
|
1300
|
+
const y = start.y + (end.y - start.y) * amount;
|
|
1301
|
+
return new Vector2(x, y);
|
|
1393
1302
|
}
|
|
1394
1303
|
/**
|
|
1395
1304
|
* Gets the dot product of the vector "left" and the vector "right"
|
|
@@ -1428,7 +1337,9 @@ var Vector2 = class Vector2 {
|
|
|
1428
1337
|
* @returns a new Vector2
|
|
1429
1338
|
*/
|
|
1430
1339
|
static Minimize(left, right) {
|
|
1431
|
-
|
|
1340
|
+
const x = left.x < right.x ? left.x : right.x;
|
|
1341
|
+
const y = left.y < right.y ? left.y : right.y;
|
|
1342
|
+
return new Vector2(x, y);
|
|
1432
1343
|
}
|
|
1433
1344
|
/**
|
|
1434
1345
|
* Gets a new Vector2 set with the maximal coordinate values from the "left" and "right" vectors
|
|
@@ -1437,7 +1348,9 @@ var Vector2 = class Vector2 {
|
|
|
1437
1348
|
* @returns a new Vector2
|
|
1438
1349
|
*/
|
|
1439
1350
|
static Maximize(left, right) {
|
|
1440
|
-
|
|
1351
|
+
const x = left.x > right.x ? left.x : right.x;
|
|
1352
|
+
const y = left.y > right.y ? left.y : right.y;
|
|
1353
|
+
return new Vector2(x, y);
|
|
1441
1354
|
}
|
|
1442
1355
|
/**
|
|
1443
1356
|
* Determines if a given vector is included in a triangle
|
|
@@ -3160,7 +3073,7 @@ const MAX_WHEEL_ZOOM_STEP_BELOW_ONE = .07;
|
|
|
3160
3073
|
const LINE_DELTA_PIXEL_SIZE = 16;
|
|
3161
3074
|
const PAGE_DELTA_PIXEL_SIZE = 800;
|
|
3162
3075
|
const ZOOM_RATIO_PRECISION = 100;
|
|
3163
|
-
function clamp(value, min, max) {
|
|
3076
|
+
function clamp$1(value, min, max) {
|
|
3164
3077
|
return Math.min(max, Math.max(min, value));
|
|
3165
3078
|
}
|
|
3166
3079
|
function normalizeWheelDelta(event) {
|
|
@@ -3175,10 +3088,10 @@ function normalizeWheelDelta(event) {
|
|
|
3175
3088
|
function getNextWheelZoomRatio(currentRatio, event) {
|
|
3176
3089
|
const validCurrentRatio = Number.isFinite(currentRatio) ? currentRatio : 1;
|
|
3177
3090
|
const normalizedDelta = normalizeWheelDelta(event);
|
|
3178
|
-
if (normalizedDelta === 0) return clamp(validCurrentRatio, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
3091
|
+
if (normalizedDelta === 0) return clamp$1(validCurrentRatio, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
3179
3092
|
const maxStep = validCurrentRatio < 1 ? MAX_WHEEL_ZOOM_STEP_BELOW_ONE : MAX_WHEEL_ZOOM_STEP;
|
|
3180
|
-
const ratioDelta = clamp(-normalizedDelta * PIXEL_DELTA_TO_ZOOM_RATIO, -maxStep, maxStep);
|
|
3181
|
-
return clamp(Math.round((validCurrentRatio + ratioDelta) * ZOOM_RATIO_PRECISION) / ZOOM_RATIO_PRECISION, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
3093
|
+
const ratioDelta = clamp$1(-normalizedDelta * PIXEL_DELTA_TO_ZOOM_RATIO, -maxStep, maxStep);
|
|
3094
|
+
return clamp$1(Math.round((validCurrentRatio + ratioDelta) * ZOOM_RATIO_PRECISION) / ZOOM_RATIO_PRECISION, MIN_ZOOM_RATIO, MAX_ZOOM_RATIO);
|
|
3182
3095
|
}
|
|
3183
3096
|
|
|
3184
3097
|
//#endregion
|
|
@@ -3932,6 +3845,95 @@ var BaseObject = class extends Disposable {
|
|
|
3932
3845
|
}
|
|
3933
3846
|
};
|
|
3934
3847
|
|
|
3848
|
+
//#endregion
|
|
3849
|
+
//#region src/basics/drawing-effect.ts
|
|
3850
|
+
const DRAWINGML_GLOW_BLUR_SCALE = .5;
|
|
3851
|
+
const GAUSSIAN_BLUR_BOUND_SCALE = 3;
|
|
3852
|
+
function clamp(value, min, max) {
|
|
3853
|
+
return Math.max(min, Math.min(max, value));
|
|
3854
|
+
}
|
|
3855
|
+
function colorWithOpacity(color, opacity) {
|
|
3856
|
+
if (opacity === void 0) return color;
|
|
3857
|
+
const parsedColor = new ColorKit(color);
|
|
3858
|
+
if (!parsedColor.isValid) return color;
|
|
3859
|
+
return parsedColor.setAlpha(parsedColor.getAlpha() * clamp(opacity, 0, 1)).toRgbString();
|
|
3860
|
+
}
|
|
3861
|
+
function cssPixels(value) {
|
|
3862
|
+
return `${Math.abs(value) < Number.EPSILON ? 0 : value}px`;
|
|
3863
|
+
}
|
|
3864
|
+
function toDropShadowFilter(effect) {
|
|
3865
|
+
return `drop-shadow(${cssPixels(effect.offsetX)} ${cssPixels(effect.offsetY)} ${cssPixels(effect.blurRadius)} ${effect.color})`;
|
|
3866
|
+
}
|
|
3867
|
+
function resolveOuterShadowEffect(effect) {
|
|
3868
|
+
var _effect$distance, _effect$direction, _effect$sx, _effect$sy, _effect$blurRadius;
|
|
3869
|
+
if (!(effect === null || effect === void 0 ? void 0 : effect.color)) return;
|
|
3870
|
+
const distance = (_effect$distance = effect.distance) !== null && _effect$distance !== void 0 ? _effect$distance : 0;
|
|
3871
|
+
const direction = ((_effect$direction = effect.direction) !== null && _effect$direction !== void 0 ? _effect$direction : 0) * Math.PI / 180;
|
|
3872
|
+
const sizeScale = (((_effect$sx = effect.sx) !== null && _effect$sx !== void 0 ? _effect$sx : 1) + ((_effect$sy = effect.sy) !== null && _effect$sy !== void 0 ? _effect$sy : 1)) / 2;
|
|
3873
|
+
return {
|
|
3874
|
+
color: colorWithOpacity(effect.color, effect.opacity),
|
|
3875
|
+
blurRadius: Math.max(0, (_effect$blurRadius = effect.blurRadius) !== null && _effect$blurRadius !== void 0 ? _effect$blurRadius : 0) * sizeScale,
|
|
3876
|
+
offsetX: Math.cos(direction) * distance * sizeScale,
|
|
3877
|
+
offsetY: Math.sin(direction) * distance * sizeScale
|
|
3878
|
+
};
|
|
3879
|
+
}
|
|
3880
|
+
function resolveGlowEffect(effect) {
|
|
3881
|
+
var _effect$radius;
|
|
3882
|
+
if (!(effect === null || effect === void 0 ? void 0 : effect.color)) return;
|
|
3883
|
+
return {
|
|
3884
|
+
color: effect.color,
|
|
3885
|
+
blurRadius: Math.max(0, (_effect$radius = effect.radius) !== null && _effect$radius !== void 0 ? _effect$radius : 0) * DRAWINGML_GLOW_BLUR_SCALE,
|
|
3886
|
+
offsetX: 0,
|
|
3887
|
+
offsetY: 0
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3890
|
+
/**
|
|
3891
|
+
* Resolves effects painted from an off-screen alpha mask.
|
|
3892
|
+
*
|
|
3893
|
+
* A glow uses two centered mask passes to match PowerPoint's DrawingML glow density without repainting source content.
|
|
3894
|
+
*/
|
|
3895
|
+
function resolveDrawingEffectMasks(glow, outerShadow) {
|
|
3896
|
+
const effects = [];
|
|
3897
|
+
const resolvedGlow = resolveGlowEffect(glow);
|
|
3898
|
+
const resolvedOuterShadow = resolveOuterShadowEffect(outerShadow);
|
|
3899
|
+
if (resolvedGlow) effects.push(resolvedGlow, resolvedGlow);
|
|
3900
|
+
if (resolvedOuterShadow) effects.push(resolvedOuterShadow);
|
|
3901
|
+
return effects;
|
|
3902
|
+
}
|
|
3903
|
+
function expandDrawingEffectBounds(bounds, glow, outerShadow) {
|
|
3904
|
+
let expandedBounds = { ...bounds };
|
|
3905
|
+
const effects = [resolveGlowEffect(glow), resolveOuterShadowEffect(outerShadow)];
|
|
3906
|
+
for (const effect of effects) {
|
|
3907
|
+
if (!effect) continue;
|
|
3908
|
+
const blurBound = effect.blurRadius * GAUSSIAN_BLUR_BOUND_SCALE;
|
|
3909
|
+
const shadowBounds = {
|
|
3910
|
+
left: expandedBounds.left + effect.offsetX - blurBound,
|
|
3911
|
+
top: expandedBounds.top + effect.offsetY - blurBound,
|
|
3912
|
+
right: expandedBounds.right + effect.offsetX + blurBound,
|
|
3913
|
+
bottom: expandedBounds.bottom + effect.offsetY + blurBound
|
|
3914
|
+
};
|
|
3915
|
+
expandedBounds = {
|
|
3916
|
+
left: Math.min(expandedBounds.left, shadowBounds.left),
|
|
3917
|
+
top: Math.min(expandedBounds.top, shadowBounds.top),
|
|
3918
|
+
right: Math.max(expandedBounds.right, shadowBounds.right),
|
|
3919
|
+
bottom: Math.max(expandedBounds.bottom, shadowBounds.bottom)
|
|
3920
|
+
};
|
|
3921
|
+
}
|
|
3922
|
+
return expandedBounds;
|
|
3923
|
+
}
|
|
3924
|
+
function createDrawingEffectFilter(glow, outerShadow) {
|
|
3925
|
+
const filters = [];
|
|
3926
|
+
const resolvedGlow = resolveGlowEffect(glow);
|
|
3927
|
+
const resolvedOuterShadow = resolveOuterShadowEffect(outerShadow);
|
|
3928
|
+
if (resolvedGlow) filters.push(toDropShadowFilter(resolvedGlow));
|
|
3929
|
+
if (resolvedOuterShadow) filters.push(toDropShadowFilter(resolvedOuterShadow));
|
|
3930
|
+
return filters.join(" ");
|
|
3931
|
+
}
|
|
3932
|
+
function combineDrawingEffectFilter(currentFilter, effectFilter) {
|
|
3933
|
+
if (!effectFilter) return currentFilter;
|
|
3934
|
+
return currentFilter && currentFilter !== "none" ? `${currentFilter} ${effectFilter}` : effectFilter;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3935
3937
|
//#endregion
|
|
3936
3938
|
//#region src/basics/position.ts
|
|
3937
3939
|
function getOffsetRectForDom(ele) {
|
|
@@ -5173,7 +5175,7 @@ var Background = class extends SheetExtension {
|
|
|
5173
5175
|
if (hasMergeData) {
|
|
5174
5176
|
if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1) return;
|
|
5175
5177
|
}
|
|
5176
|
-
const cellInfo = (_backgroundPositions$ = backgroundPositions === null || backgroundPositions === void 0 ? void 0 : backgroundPositions.getValue(row, col)) !== null && _backgroundPositions$ !== void 0 ? _backgroundPositions$ : spreadsheetSkeleton.
|
|
5178
|
+
const cellInfo = (_backgroundPositions$ = backgroundPositions === null || backgroundPositions === void 0 ? void 0 : backgroundPositions.getValue(row, col)) !== null && _backgroundPositions$ !== void 0 ? _backgroundPositions$ : spreadsheetSkeleton.getCellWithCoordByIndex(row, col, false);
|
|
5177
5179
|
if (!cellInfo) return;
|
|
5178
5180
|
if (bgConfigParam || bgColorMatrix.getValue(row, col)) {
|
|
5179
5181
|
renderBGContext.cellInfo = cellInfo;
|
|
@@ -5743,7 +5745,7 @@ var Custom = class extends SheetExtension {
|
|
|
5743
5745
|
if (primaryWithCoord.isMerged) primaryWithCoord = skeleton.getCellWithCoordByIndex(mergeInfo.startRow, mergeInfo.startColumn, false);
|
|
5744
5746
|
const renderInfo = {
|
|
5745
5747
|
data: cellData,
|
|
5746
|
-
style:
|
|
5748
|
+
style: worksheet.getComposedCellStyleByCellData(mergeInfo.startRow, mergeInfo.startColumn, cellData),
|
|
5747
5749
|
primaryWithCoord,
|
|
5748
5750
|
subUnitId,
|
|
5749
5751
|
row,
|
|
@@ -11755,6 +11757,9 @@ const SHAPE_OBJECT_ARRAY = [
|
|
|
11755
11757
|
var Shape = class extends BaseObject {
|
|
11756
11758
|
constructor(key, props) {
|
|
11757
11759
|
super(key);
|
|
11760
|
+
_defineProperty(this, "_renderCacheCanvas", void 0);
|
|
11761
|
+
_defineProperty(this, "_renderCacheBounds", void 0);
|
|
11762
|
+
_defineProperty(this, "_renderCachePixelRatio", 0);
|
|
11758
11763
|
_defineProperty(this, "_hoverCursor", void 0);
|
|
11759
11764
|
_defineProperty(this, "_moveCursor", null);
|
|
11760
11765
|
_defineProperty(this, "_fillRule", "nonzero");
|
|
@@ -11945,6 +11950,46 @@ var Shape = class extends BaseObject {
|
|
|
11945
11950
|
...props
|
|
11946
11951
|
};
|
|
11947
11952
|
}
|
|
11953
|
+
_renderWithCache(ctx, bounds, draw) {
|
|
11954
|
+
var _this$_renderCacheBou, _this$_renderCacheBou2, _this$_renderCacheBou3, _this$_renderCacheBou4, _this$_renderCacheCan, _this$_renderCacheCan2;
|
|
11955
|
+
const transform = ctx.getTransform();
|
|
11956
|
+
const scaleX = Math.hypot(transform.a, transform.b);
|
|
11957
|
+
const scaleY = Math.hypot(transform.c, transform.d);
|
|
11958
|
+
const pixelRatio = Math.max(scaleX, scaleY);
|
|
11959
|
+
if (pixelRatio <= Number.EPSILON) return;
|
|
11960
|
+
const width = Math.ceil((bounds.right - bounds.left) * pixelRatio) / pixelRatio;
|
|
11961
|
+
const height = Math.ceil((bounds.bottom - bounds.top) * pixelRatio) / pixelRatio;
|
|
11962
|
+
if (width <= 0 || height <= 0) return;
|
|
11963
|
+
const cacheBoundsChanged = ((_this$_renderCacheBou = this._renderCacheBounds) === null || _this$_renderCacheBou === void 0 ? void 0 : _this$_renderCacheBou.left) !== bounds.left || ((_this$_renderCacheBou2 = this._renderCacheBounds) === null || _this$_renderCacheBou2 === void 0 ? void 0 : _this$_renderCacheBou2.top) !== bounds.top || ((_this$_renderCacheBou3 = this._renderCacheBounds) === null || _this$_renderCacheBou3 === void 0 ? void 0 : _this$_renderCacheBou3.right) !== bounds.right || ((_this$_renderCacheBou4 = this._renderCacheBounds) === null || _this$_renderCacheBou4 === void 0 ? void 0 : _this$_renderCacheBou4.bottom) !== bounds.bottom;
|
|
11964
|
+
const cacheSizeChanged = ((_this$_renderCacheCan = this._renderCacheCanvas) === null || _this$_renderCacheCan === void 0 ? void 0 : _this$_renderCacheCan.getWidth()) !== width || ((_this$_renderCacheCan2 = this._renderCacheCanvas) === null || _this$_renderCacheCan2 === void 0 ? void 0 : _this$_renderCacheCan2.getHeight()) !== height || this._renderCachePixelRatio !== pixelRatio;
|
|
11965
|
+
if (!this._renderCacheCanvas) {
|
|
11966
|
+
var _this$getEngine;
|
|
11967
|
+
this._renderCacheCanvas = new Canvas({
|
|
11968
|
+
colorService: (_this$getEngine = this.getEngine()) === null || _this$getEngine === void 0 ? void 0 : _this$getEngine.canvasColorService,
|
|
11969
|
+
width,
|
|
11970
|
+
height,
|
|
11971
|
+
pixelRatio
|
|
11972
|
+
});
|
|
11973
|
+
} else if (cacheSizeChanged) this._renderCacheCanvas.setSize(width, height, pixelRatio);
|
|
11974
|
+
if (this.isDirty() || cacheBoundsChanged || cacheSizeChanged) {
|
|
11975
|
+
const cacheContext = this._renderCacheCanvas.getContext();
|
|
11976
|
+
this._renderCacheCanvas.clear();
|
|
11977
|
+
cacheContext.save();
|
|
11978
|
+
cacheContext.translate(-bounds.left, -bounds.top);
|
|
11979
|
+
draw(cacheContext);
|
|
11980
|
+
cacheContext.restore();
|
|
11981
|
+
this._renderCacheBounds = { ...bounds };
|
|
11982
|
+
this._renderCachePixelRatio = pixelRatio;
|
|
11983
|
+
}
|
|
11984
|
+
ctx.drawImage(this._renderCacheCanvas.getCanvasEle(), bounds.left, bounds.top, width, height);
|
|
11985
|
+
}
|
|
11986
|
+
_releaseRenderCache() {
|
|
11987
|
+
var _this$_renderCacheCan3;
|
|
11988
|
+
(_this$_renderCacheCan3 = this._renderCacheCanvas) === null || _this$_renderCacheCan3 === void 0 || _this$_renderCacheCan3.dispose();
|
|
11989
|
+
this._renderCacheCanvas = null;
|
|
11990
|
+
this._renderCacheBounds = null;
|
|
11991
|
+
this._renderCachePixelRatio = 0;
|
|
11992
|
+
}
|
|
11948
11993
|
_draw(ctx, bounds) {
|
|
11949
11994
|
/** abstract */
|
|
11950
11995
|
}
|
|
@@ -11974,6 +12019,10 @@ var Shape = class extends BaseObject {
|
|
|
11974
12019
|
if (hasTransformState) this.transformByState(transformState);
|
|
11975
12020
|
this.makeDirty(true);
|
|
11976
12021
|
}
|
|
12022
|
+
dispose() {
|
|
12023
|
+
this._releaseRenderCache();
|
|
12024
|
+
super.dispose();
|
|
12025
|
+
}
|
|
11977
12026
|
};
|
|
11978
12027
|
|
|
11979
12028
|
//#endregion
|
|
@@ -12422,6 +12471,9 @@ function getDocsTableVirtualContentWidth(viewport) {
|
|
|
12422
12471
|
var _viewport$leadingInse, _viewport$trailingIns;
|
|
12423
12472
|
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);
|
|
12424
12473
|
}
|
|
12474
|
+
function getDocsTableViewportLeft(viewport, fallbackLeft, docsLeft = 0) {
|
|
12475
|
+
return (viewport === null || viewport === void 0 ? void 0 : viewport.viewportLeft) != null ? viewport.viewportLeft - docsLeft : fallbackLeft;
|
|
12476
|
+
}
|
|
12425
12477
|
function hasDocsTableHorizontalViewport(viewport) {
|
|
12426
12478
|
return viewport != null && getDocsTableVirtualContentWidth(viewport) > viewport.viewportWidth;
|
|
12427
12479
|
}
|
|
@@ -12940,13 +12992,19 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
12940
12992
|
_buildHeaderFooterViewModel() {
|
|
12941
12993
|
const { headerModelMap, footerModelMap } = this._documentDataModel;
|
|
12942
12994
|
const viewModels = [];
|
|
12943
|
-
const
|
|
12995
|
+
const rootTableSource = this.getSnapshot().tableSource;
|
|
12944
12996
|
for (const [headerId, headerModel] of headerModelMap) {
|
|
12945
|
-
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel,
|
|
12997
|
+
this._headerTreeMap.set(headerId, new DocumentViewModel(headerModel, {
|
|
12998
|
+
...rootTableSource,
|
|
12999
|
+
...headerModel.getSnapshot().tableSource
|
|
13000
|
+
}));
|
|
12946
13001
|
viewModels.push(this._headerTreeMap.get(headerId));
|
|
12947
13002
|
}
|
|
12948
13003
|
for (const [footerId, footerModel] of footerModelMap) {
|
|
12949
|
-
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel,
|
|
13004
|
+
this._footerTreeMap.set(footerId, new DocumentViewModel(footerModel, {
|
|
13005
|
+
...rootTableSource,
|
|
13006
|
+
...footerModel.getSnapshot().tableSource
|
|
13007
|
+
}));
|
|
12950
13008
|
viewModels.push(this._footerTreeMap.get(footerId));
|
|
12951
13009
|
}
|
|
12952
13010
|
this._segmentViewModels$.next(viewModels);
|
|
@@ -13018,15 +13076,36 @@ function baseAdjustability(content, width) {
|
|
|
13018
13076
|
function createSkeletonWordGlyph(content, config, glyphWidth) {
|
|
13019
13077
|
return _createSkeletonWordOrLetter(1, content, config, glyphWidth);
|
|
13020
13078
|
}
|
|
13021
|
-
function createSkeletonLetterGlyph(content, config, glyphMetrics
|
|
13079
|
+
function createSkeletonLetterGlyph(content, config, glyphMetrics) {
|
|
13022
13080
|
const glyphWidth = typeof glyphMetrics === "number" ? glyphMetrics : glyphMetrics === null || glyphMetrics === void 0 ? void 0 : glyphMetrics.width;
|
|
13023
|
-
const glyph = _createSkeletonWordOrLetter(0, content, config, glyphWidth
|
|
13081
|
+
const glyph = _createSkeletonWordOrLetter(0, content, config, glyphWidth);
|
|
13024
13082
|
if (typeof glyphMetrics === "object") {
|
|
13025
13083
|
if (glyphMetrics.ascent != null) glyph.bBox.ba = glyph.bBox.aba = glyphMetrics.ascent;
|
|
13026
13084
|
if (glyphMetrics.descent != null) glyph.bBox.bd = glyph.bBox.abd = glyphMetrics.descent;
|
|
13027
13085
|
}
|
|
13028
13086
|
return glyph;
|
|
13029
13087
|
}
|
|
13088
|
+
const WHOLE_ENTITY_RENDER_MARKER = "";
|
|
13089
|
+
/**
|
|
13090
|
+
* Creates one non-text skeleton glyph for a whole entity whose source spans
|
|
13091
|
+
* multiple model characters. `raw` and `count` retain the source mapping.
|
|
13092
|
+
*
|
|
13093
|
+
* The zero-width marker keeps the glyph in the document paint loop so a
|
|
13094
|
+
* component extension can render the entity, without painting its model
|
|
13095
|
+
* source as ordinary text.
|
|
13096
|
+
*/
|
|
13097
|
+
function createSkeletonWholeEntityGlyph(raw, config, glyphMetrics) {
|
|
13098
|
+
const glyph = createSkeletonLetterGlyph(raw, config, glyphMetrics);
|
|
13099
|
+
glyph.adjustability = baseAdjustability(WHOLE_ENTITY_RENDER_MARKER, glyph.width);
|
|
13100
|
+
glyph.bBox.width = glyph.width;
|
|
13101
|
+
glyph.content = WHOLE_ENTITY_RENDER_MARKER;
|
|
13102
|
+
glyph.count = raw.length;
|
|
13103
|
+
glyph.glyphType = 3;
|
|
13104
|
+
glyph.isJustifiable = false;
|
|
13105
|
+
glyph.raw = raw;
|
|
13106
|
+
glyph.streamType = DataStreamTreeTokenType.LETTER;
|
|
13107
|
+
return glyph;
|
|
13108
|
+
}
|
|
13030
13109
|
function createSkeletonTabGlyph(config, glyphWidth) {
|
|
13031
13110
|
return _createSkeletonWordOrLetter(4, DataStreamTreeTokenType.TAB, config, glyphWidth);
|
|
13032
13111
|
}
|
|
@@ -13066,7 +13145,7 @@ function createSkeletonCustomBlockGlyph(config, glyphWidth = 0, glyphHeight = 0,
|
|
|
13066
13145
|
drawingId
|
|
13067
13146
|
};
|
|
13068
13147
|
}
|
|
13069
|
-
function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth
|
|
13148
|
+
function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth) {
|
|
13070
13149
|
var _config$documentCompa;
|
|
13071
13150
|
const { fontStyle, textStyle, charSpace = 1, gridType = GridType.LINES, snapToGrid = BooleanNumber.FALSE } = config;
|
|
13072
13151
|
const skipWidthList = [
|
|
@@ -13120,8 +13199,7 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
|
|
|
13120
13199
|
if (content === DataStreamTreeTokenType.PARAGRAPH) streamType = DataStreamTreeTokenType.PARAGRAPH;
|
|
13121
13200
|
let bBox = null;
|
|
13122
13201
|
let xOffset = 0;
|
|
13123
|
-
|
|
13124
|
-
else bBox = FontCache.getTextSize(content, fontStyle);
|
|
13202
|
+
bBox = FontCache.getTextSize(content, fontStyle);
|
|
13125
13203
|
bBox = applyFontMetricCompatibility(content, fontStyle, bBox, (_config$documentCompa = config.documentCompatibilityPolicy) !== null && _config$documentCompa !== void 0 ? _config$documentCompa : getDocumentCompatibilityPolicy());
|
|
13126
13204
|
const { width: contentWidth = 0 } = bBox;
|
|
13127
13205
|
let width = glyphWidth !== null && glyphWidth !== void 0 ? glyphWidth : contentWidth;
|
|
@@ -13129,12 +13207,6 @@ function _createSkeletonWordOrLetter(glyphType, content, config, glyphWidth, gly
|
|
|
13129
13207
|
width = contentWidth + (cjk.hasCJK(content) ? charSpace : charSpace / 2);
|
|
13130
13208
|
if (gridType === GridType.SNAP_TO_CHARS) xOffset = (width - contentWidth) / 2;
|
|
13131
13209
|
}
|
|
13132
|
-
if (glyphInfo && glyphInfo.kerning !== 0 && glyphInfo.font) {
|
|
13133
|
-
const radio = ptToPixel(fontStyle.fontSize) / glyphInfo.font.unitsPerEm;
|
|
13134
|
-
const delta = glyphInfo.kerning * radio;
|
|
13135
|
-
width += delta;
|
|
13136
|
-
xOffset += delta;
|
|
13137
|
-
}
|
|
13138
13210
|
return {
|
|
13139
13211
|
content,
|
|
13140
13212
|
ts: textStyle,
|
|
@@ -15278,7 +15350,7 @@ function lineIterator(pagesOrCells, cb) {
|
|
|
15278
15350
|
}
|
|
15279
15351
|
}
|
|
15280
15352
|
function documentSkeletonTableIterator(pages, options = {}) {
|
|
15281
|
-
const { docsLeft = 0, docsTop = 0, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
|
|
15353
|
+
const { docsLeft = 0, docsTop = 0, includeCells = true, pageMarginTop = 0, resolveViewport = true, skeFooters, skeHeaders, tableCellInsetX = 0, unitId = "" } = options;
|
|
15282
15354
|
const contexts = [];
|
|
15283
15355
|
pages.forEach((rootPage, pageIndex) => {
|
|
15284
15356
|
var _skeHeaders$get, _skeFooters$get, _rootPage$skeColumnGr;
|
|
@@ -15287,6 +15359,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
15287
15359
|
collectPageTables({
|
|
15288
15360
|
contexts,
|
|
15289
15361
|
docsLeft,
|
|
15362
|
+
includeCells,
|
|
15290
15363
|
page: rootPage,
|
|
15291
15364
|
pageIndex,
|
|
15292
15365
|
pageLeft: rootPageLeft,
|
|
@@ -15303,6 +15376,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
15303
15376
|
if (headerPage != null) collectPageTables({
|
|
15304
15377
|
contexts,
|
|
15305
15378
|
docsLeft,
|
|
15379
|
+
includeCells,
|
|
15306
15380
|
page: headerPage,
|
|
15307
15381
|
pageIndex,
|
|
15308
15382
|
pageLeft: rootPageDocumentLeft,
|
|
@@ -15317,6 +15391,7 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
15317
15391
|
if (footerPage != null) collectPageTables({
|
|
15318
15392
|
contexts,
|
|
15319
15393
|
docsLeft,
|
|
15394
|
+
includeCells,
|
|
15320
15395
|
page: footerPage,
|
|
15321
15396
|
pageIndex,
|
|
15322
15397
|
pageLeft: rootPageDocumentLeft,
|
|
@@ -15330,13 +15405,16 @@ function documentSkeletonTableIterator(pages, options = {}) {
|
|
|
15330
15405
|
(_rootPage$skeColumnGr = rootPage.skeColumnGroups) === null || _rootPage$skeColumnGr === void 0 || _rootPage$skeColumnGr.forEach((columnGroup) => {
|
|
15331
15406
|
columnGroup.columns.forEach((columnGroupColumn) => {
|
|
15332
15407
|
const nestedPage = columnGroupColumn.page;
|
|
15408
|
+
const nestedPageLeft = rootPageLeft + columnGroup.left + columnGroupColumn.left + nestedPage.marginLeft;
|
|
15409
|
+
const nestedPageTop = rootPageTop + columnGroup.top + columnGroupColumn.top + nestedPage.marginTop;
|
|
15333
15410
|
collectPageTables({
|
|
15334
15411
|
contexts,
|
|
15335
15412
|
docsLeft,
|
|
15413
|
+
includeCells,
|
|
15336
15414
|
page: nestedPage,
|
|
15337
15415
|
pageIndex,
|
|
15338
|
-
pageLeft:
|
|
15339
|
-
pageTop:
|
|
15416
|
+
pageLeft: nestedPageLeft,
|
|
15417
|
+
pageTop: nestedPageTop,
|
|
15340
15418
|
rootPage,
|
|
15341
15419
|
source: "column",
|
|
15342
15420
|
resolveViewport,
|
|
@@ -15362,9 +15440,10 @@ function documentSkeletonLineIterator(pages, options, cb) {
|
|
|
15362
15440
|
getBounds: (linePage, column, section) => getPageLineBounds(linePage, column, section.columns.length, pageLeft)
|
|
15363
15441
|
}, cb);
|
|
15364
15442
|
(_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 || _page$skeTables.forEach((table) => {
|
|
15365
|
-
const
|
|
15443
|
+
const sourceTableId = getSourceTableId(table.tableId);
|
|
15444
|
+
const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
|
|
15366
15445
|
const hasHorizontalViewport = hasDocsTableHorizontalViewport(viewport);
|
|
15367
|
-
const tableViewportLeft =
|
|
15446
|
+
const tableViewportLeft = getDocsTableViewportLeft(viewport, pageLeft + table.left, docsLeft);
|
|
15368
15447
|
const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
|
|
15369
15448
|
const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
|
|
15370
15449
|
table.rows.forEach((row) => {
|
|
@@ -15484,7 +15563,7 @@ function getPageLineBounds(page, column, columnCount, pageLeft) {
|
|
|
15484
15563
|
}
|
|
15485
15564
|
function collectPageTables(options) {
|
|
15486
15565
|
var _page$skeTables2;
|
|
15487
|
-
const { contexts, docsLeft, page, pageIndex, pageLeft, pageTop, resolveViewport, rootPage, source, tableCellInsetX, unitId } = options;
|
|
15566
|
+
const { contexts, docsLeft, includeCells, page, pageIndex, pageLeft, pageTop, resolveViewport, rootPage, source, tableCellInsetX, unitId } = options;
|
|
15488
15567
|
(_page$skeTables2 = page.skeTables) === null || _page$skeTables2 === void 0 || _page$skeTables2.forEach((table, tableId) => {
|
|
15489
15568
|
var _table$tableId;
|
|
15490
15569
|
const effectiveTableId = (_table$tableId = table.tableId) !== null && _table$tableId !== void 0 ? _table$tableId : tableId;
|
|
@@ -15493,11 +15572,11 @@ function collectPageTables(options) {
|
|
|
15493
15572
|
const sourceTableId = getSourceTableId(effectiveTableId);
|
|
15494
15573
|
const viewport = resolveViewport ? getDocsTableRenderViewport(unitId, sourceTableId) : null;
|
|
15495
15574
|
const hasHorizontalViewport = hasDocsTableHorizontalViewport(viewport);
|
|
15496
|
-
const tableViewportLeft =
|
|
15575
|
+
const tableViewportLeft = getDocsTableViewportLeft(viewport, pageLeft + table.left, docsLeft);
|
|
15497
15576
|
const tableViewportRight = tableViewportLeft + (hasHorizontalViewport ? viewport.viewportWidth : table.width);
|
|
15498
15577
|
const tableScrollLeft = hasHorizontalViewport ? viewport.scrollLeft : 0;
|
|
15499
15578
|
const cells = [];
|
|
15500
|
-
table.rows.forEach((row, rowIndex) => {
|
|
15579
|
+
if (includeCells) table.rows.forEach((row, rowIndex) => {
|
|
15501
15580
|
row.cells.forEach((cell, columnIndex) => {
|
|
15502
15581
|
var _cell$marginLeft, _cell$marginRight, _cell$marginTop, _cell$marginBottom, _cell$pageWidth, _cell$pageHeight, _row$top, _cell$left;
|
|
15503
15582
|
if (cell.isMergedCellCovered) return;
|
|
@@ -15555,10 +15634,6 @@ function collectPageTables(options) {
|
|
|
15555
15634
|
});
|
|
15556
15635
|
});
|
|
15557
15636
|
}
|
|
15558
|
-
function getTableViewportLeft(pageLeft, tableLeft, viewport, docsLeft) {
|
|
15559
|
-
const viewportLeft = viewport === null || viewport === void 0 ? void 0 : viewport.viewportLeft;
|
|
15560
|
-
return viewportLeft != null ? viewportLeft - docsLeft : pageLeft + tableLeft;
|
|
15561
|
-
}
|
|
15562
15637
|
function getSourceTableId(tableId) {
|
|
15563
15638
|
return tableId.includes("#-#") ? tableId.split("#-#")[0] : tableId;
|
|
15564
15639
|
}
|
|
@@ -15729,9 +15804,28 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
|
|
|
15729
15804
|
if (!hasAddonStyle && originTextRun) fontCreateConfigCache.setValue(st, ed, result);
|
|
15730
15805
|
return result;
|
|
15731
15806
|
}
|
|
15807
|
+
/**
|
|
15808
|
+
* Returns whether a custom range should occupy one measured glyph in the
|
|
15809
|
+
* document skeleton while preserving its complete source text in the model.
|
|
15810
|
+
*
|
|
15811
|
+
* Visible whole-entity ranges such as mentions keep their existing shaping.
|
|
15812
|
+
* The atomic behavior is reserved for hidden ranges whose renderer provides
|
|
15813
|
+
* explicit glyph metrics, such as an inline formula.
|
|
15814
|
+
*/
|
|
15815
|
+
function isMeasuredWholeEntityRange(customRange) {
|
|
15816
|
+
if (!(customRange === null || customRange === void 0 ? void 0 : customRange.wholeEntity) || customRange.show !== false) return false;
|
|
15817
|
+
return [
|
|
15818
|
+
customRange.glyphAscentEm,
|
|
15819
|
+
customRange.glyphDescentEm,
|
|
15820
|
+
customRange.glyphWidthEm
|
|
15821
|
+
].every((value) => typeof value === "number" && Number.isFinite(value) && value >= 0);
|
|
15822
|
+
}
|
|
15732
15823
|
function getCustomRangeGlyphMetrics(index, viewModel, paragraphNode, config) {
|
|
15733
15824
|
const customRange = viewModel.getCustomRange(index + paragraphNode.startIndex);
|
|
15734
15825
|
if (!customRange) return;
|
|
15826
|
+
return getCustomRangeGlyphMetricsFromRange(customRange, config);
|
|
15827
|
+
}
|
|
15828
|
+
function getCustomRangeGlyphMetricsFromRange(customRange, config) {
|
|
15735
15829
|
const fontSize = ptToPixel(config.fontStyle.originFontSize);
|
|
15736
15830
|
const toPixels = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value * fontSize : void 0;
|
|
15737
15831
|
const metrics = {
|
|
@@ -16616,14 +16710,15 @@ const BLOCK_LAYOUT_OUTER_SPACING_MAP = /* @__PURE__ */ new Map([
|
|
|
16616
16710
|
[DocumentBlockRangeType.CODE, 32],
|
|
16617
16711
|
[DocumentBlockRangeType.QUOTE, 24]
|
|
16618
16712
|
]);
|
|
16713
|
+
const MAX_KEEP_NEXT_LOOKAHEAD = 32;
|
|
16619
16714
|
function _endsWithToken(text, glyphs, token) {
|
|
16620
16715
|
var _glyphs, _glyphs2;
|
|
16621
16716
|
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;
|
|
16622
16717
|
}
|
|
16623
16718
|
function _isMarkedDocxColumnBreak(viewModel, absoluteIndex) {
|
|
16719
|
+
var _customRange$properti;
|
|
16624
16720
|
const customRange = viewModel.getCustomRange(absoluteIndex);
|
|
16625
|
-
|
|
16626
|
-
return (properties === null || properties === void 0 ? void 0 : properties.docxBreakType) === "column";
|
|
16721
|
+
return (customRange === null || customRange === void 0 || (_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.docxBreakType) === DocxBreakType.COLUMN;
|
|
16627
16722
|
}
|
|
16628
16723
|
function _glyphCount(glyphs) {
|
|
16629
16724
|
return glyphs.reduce((count, glyph) => count + glyph.count, 0);
|
|
@@ -16744,15 +16839,20 @@ function _hasNextAdjacentLayoutBlockRange(blockRanges, blockRange) {
|
|
|
16744
16839
|
const nextBlockRange = _getNextAdjacentBlockRange(blockRanges, blockRange);
|
|
16745
16840
|
return nextBlockRange != null && BLOCK_LAYOUT_OUTER_SPACING_MAP.has(nextBlockRange.blockType) && nextBlockRange.startIndex === blockRange.endIndex + 1;
|
|
16746
16841
|
}
|
|
16747
|
-
function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, documentStyle, useLegacyModernDefaults) {
|
|
16842
|
+
function _applyBlockRangeLayoutParagraphStyle(body, paragraph, paragraphStyle, documentStyle, useLegacyModernDefaults, styles, paragraphStyleId) {
|
|
16748
16843
|
var _body$paragraphs, _BLOCK_LAYOUT_OUTER_S;
|
|
16749
16844
|
const blockRanges = body === null || body === void 0 ? void 0 : body.blockRanges;
|
|
16750
|
-
|
|
16845
|
+
const resolveOptions = {
|
|
16846
|
+
useLegacyModernDefaults,
|
|
16847
|
+
styles,
|
|
16848
|
+
paragraphStyleId
|
|
16849
|
+
};
|
|
16850
|
+
if (!(blockRanges === null || blockRanges === void 0 ? void 0 : blockRanges.length)) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle, resolveOptions);
|
|
16751
16851
|
const blockRange = blockRanges.find((range) => BLOCK_LAYOUT_OUTER_SPACING_MAP.has(range.blockType) && paragraph.startIndex > range.startIndex && paragraph.startIndex < range.endIndex);
|
|
16752
|
-
if (!blockRange) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle,
|
|
16852
|
+
if (!blockRange) return resolveDocumentParagraphStyle(documentStyle, paragraphStyle, resolveOptions);
|
|
16753
16853
|
const style = resolveDocumentParagraphStyle(documentStyle, paragraphStyle, {
|
|
16754
|
-
|
|
16755
|
-
|
|
16854
|
+
...resolveOptions,
|
|
16855
|
+
excludeDocumentOuterSpacing: true
|
|
16756
16856
|
});
|
|
16757
16857
|
if (style.lineSpacing == null) style.lineSpacing = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
|
|
16758
16858
|
const blockParagraphs = ((_body$paragraphs = body === null || body === void 0 ? void 0 : body.paragraphs) !== null && _body$paragraphs !== void 0 ? _body$paragraphs : []).filter((item) => item.startIndex > blockRange.startIndex && item.startIndex < blockRange.endIndex).sort((left, right) => left.startIndex - right.startIndex);
|
|
@@ -16802,6 +16902,158 @@ function _getDrawingSkeletonFormat(drawingOrigin) {
|
|
|
16802
16902
|
function _getNextPageNumber(lastPage) {
|
|
16803
16903
|
return lastPage.pageNumber + 1;
|
|
16804
16904
|
}
|
|
16905
|
+
function _getParagraphLineRefs(pages, paragraphIndex) {
|
|
16906
|
+
const refs = [];
|
|
16907
|
+
for (const page of pages) {
|
|
16908
|
+
var _page$sections;
|
|
16909
|
+
for (const section of (_page$sections = page.sections) !== null && _page$sections !== void 0 ? _page$sections : []) for (const column of section.columns) for (const line of column.lines) if (line.paragraphIndex === paragraphIndex) refs.push({
|
|
16910
|
+
page,
|
|
16911
|
+
column,
|
|
16912
|
+
line
|
|
16913
|
+
});
|
|
16914
|
+
}
|
|
16915
|
+
return refs;
|
|
16916
|
+
}
|
|
16917
|
+
function _hasPageContent(page) {
|
|
16918
|
+
var _page$sections2, _page$skeTables$size, _page$skeTables;
|
|
16919
|
+
return ((_page$sections2 = page.sections) !== null && _page$sections2 !== void 0 ? _page$sections2 : []).some((section) => section.columns.some((column) => !isBlankColumn(column))) || ((_page$skeTables$size = (_page$skeTables = page.skeTables) === null || _page$skeTables === void 0 ? void 0 : _page$skeTables.size) !== null && _page$skeTables$size !== void 0 ? _page$skeTables$size : 0) > 0;
|
|
16920
|
+
}
|
|
16921
|
+
function _hasOnlyExplicitPageBoundaryMarkers(page) {
|
|
16922
|
+
var _page$skeTables$size2, _page$skeTables2, _page$sections3;
|
|
16923
|
+
if (((_page$skeTables$size2 = (_page$skeTables2 = page.skeTables) === null || _page$skeTables2 === void 0 ? void 0 : _page$skeTables2.size) !== null && _page$skeTables$size2 !== void 0 ? _page$skeTables$size2 : 0) > 0) return false;
|
|
16924
|
+
return ((_page$sections3 = page.sections) !== null && _page$sections3 !== void 0 ? _page$sections3 : []).every((section) => section.columns.every((column) => column.lines.every((line) => line.divides.every((divide) => divide.glyphGroup.every(({ raw, streamType }) => raw === DataStreamTreeTokenType.PARAGRAPH || streamType === DataStreamTreeTokenType.PARAGRAPH || raw === DataStreamTreeTokenType.PAGE_BREAK || streamType === DataStreamTreeTokenType.PAGE_BREAK)))));
|
|
16925
|
+
}
|
|
16926
|
+
function _lineSpanHeight(lines) {
|
|
16927
|
+
if (lines.length === 0) return 0;
|
|
16928
|
+
const firstTop = Math.min(...lines.map((line) => line.top));
|
|
16929
|
+
return Math.max(...lines.map((line) => {
|
|
16930
|
+
var _line$spaceBelowApply;
|
|
16931
|
+
return line.top + line.lineHeight + Math.max(0, (_line$spaceBelowApply = line.spaceBelowApply) !== null && _line$spaceBelowApply !== void 0 ? _line$spaceBelowApply : 0);
|
|
16932
|
+
})) - firstTop;
|
|
16933
|
+
}
|
|
16934
|
+
function _columnUsedHeight(column) {
|
|
16935
|
+
return _lineSpanHeight(column.lines);
|
|
16936
|
+
}
|
|
16937
|
+
function _reindexColumnLines(column) {
|
|
16938
|
+
column.lines.forEach((line, index) => {
|
|
16939
|
+
line.lineIndex = index;
|
|
16940
|
+
line.parent = column;
|
|
16941
|
+
});
|
|
16942
|
+
}
|
|
16943
|
+
function _prependLines(sourceColumn, targetColumn, lines) {
|
|
16944
|
+
var _targetColumn$parent$, _targetColumn$parent;
|
|
16945
|
+
if (lines.length === 0 || lines.some((line) => !sourceColumn.lines.includes(line))) return 0;
|
|
16946
|
+
const movedHeight = _lineSpanHeight(lines);
|
|
16947
|
+
const targetHeight = (_targetColumn$parent$ = (_targetColumn$parent = targetColumn.parent) === null || _targetColumn$parent === void 0 ? void 0 : _targetColumn$parent.height) !== null && _targetColumn$parent$ !== void 0 ? _targetColumn$parent$ : Number.POSITIVE_INFINITY;
|
|
16948
|
+
if (movedHeight + _columnUsedHeight(targetColumn) > targetHeight) return 0;
|
|
16949
|
+
const firstTop = Math.min(...lines.map((line) => line.top));
|
|
16950
|
+
const moved = lines.map((line) => {
|
|
16951
|
+
line.top -= firstTop;
|
|
16952
|
+
return line;
|
|
16953
|
+
});
|
|
16954
|
+
const movedSet = new Set(moved);
|
|
16955
|
+
sourceColumn.lines = sourceColumn.lines.filter((line) => !movedSet.has(line));
|
|
16956
|
+
for (const line of targetColumn.lines) line.top += movedHeight;
|
|
16957
|
+
targetColumn.lines.unshift(...moved);
|
|
16958
|
+
sourceColumn.isFull = false;
|
|
16959
|
+
_reindexColumnLines(sourceColumn);
|
|
16960
|
+
_reindexColumnLines(targetColumn);
|
|
16961
|
+
return moved.length;
|
|
16962
|
+
}
|
|
16963
|
+
function _hasExplicitStructuralBreak(shapedTextList) {
|
|
16964
|
+
return shapedTextList.some(({ text, glyphs }) => _endsWithToken(text, glyphs, DataStreamTreeTokenType.PAGE_BREAK) || _endsWithToken(text, glyphs, DataStreamTreeTokenType.COLUMN_BREAK));
|
|
16965
|
+
}
|
|
16966
|
+
function _applyKeepLines(pages, paragraphIndex, metrics) {
|
|
16967
|
+
const refs = _getParagraphLineRefs(pages, paragraphIndex);
|
|
16968
|
+
if (metrics) {
|
|
16969
|
+
metrics.measuredLineCount += refs.length;
|
|
16970
|
+
metrics.peakCheckpointLineCount = Math.max(metrics.peakCheckpointLineCount, refs.length);
|
|
16971
|
+
}
|
|
16972
|
+
const paragraphPages = [...new Set(refs.map(({ page }) => page))];
|
|
16973
|
+
if (paragraphPages.length !== 2 || paragraphPages.some((page) => page.sections.some((section) => section.columns.length !== 1))) return 0;
|
|
16974
|
+
const sourceRefs = refs.filter(({ page }) => page === paragraphPages[0]);
|
|
16975
|
+
const targetRefs = refs.filter(({ page }) => page === paragraphPages[1]);
|
|
16976
|
+
const sourceColumns = [...new Set(sourceRefs.map(({ column }) => column))];
|
|
16977
|
+
const targetColumns = [...new Set(targetRefs.map(({ column }) => column))];
|
|
16978
|
+
if (sourceColumns.length !== 1 || targetColumns.length !== 1) return 0;
|
|
16979
|
+
const movedLineCount = _prependLines(sourceColumns[0], targetColumns[0], sourceRefs.map(({ line }) => line));
|
|
16980
|
+
if (metrics && movedLineCount > 0) {
|
|
16981
|
+
metrics.retryCount += 1;
|
|
16982
|
+
metrics.movedLineCount += movedLineCount;
|
|
16983
|
+
}
|
|
16984
|
+
return movedLineCount;
|
|
16985
|
+
}
|
|
16986
|
+
function _applyKeepNext(pages, originalPage, paragraphIndex, paragraphConfigCache, metrics) {
|
|
16987
|
+
var _originalPage$section;
|
|
16988
|
+
const refs = _getParagraphLineRefs(pages, paragraphIndex);
|
|
16989
|
+
if (metrics) {
|
|
16990
|
+
metrics.measuredLineCount += refs.length;
|
|
16991
|
+
metrics.peakCheckpointLineCount = Math.max(metrics.peakCheckpointLineCount, refs.length);
|
|
16992
|
+
}
|
|
16993
|
+
const targetPages = [...new Set(refs.map(({ page }) => page))];
|
|
16994
|
+
if (refs.length === 0 || targetPages.length !== 1 || targetPages[0] === originalPage || targetPages[0].breakType === 1 || targetPages[0].sections.some((section) => section.columns.length !== 1)) return 0;
|
|
16995
|
+
if (!((_originalPage$section = originalPage.sections) === null || _originalPage$section === void 0 ? void 0 : _originalPage$section.length)) return 0;
|
|
16996
|
+
const sourceSection = getLastSection(originalPage);
|
|
16997
|
+
const sourceColumn = sourceSection === null || sourceSection === void 0 ? void 0 : sourceSection.columns.findLast((column) => column.lines.length > 0);
|
|
16998
|
+
const targetColumn = refs[0].column;
|
|
16999
|
+
if (!sourceColumn || refs.some(({ column }) => column !== targetColumn)) return 0;
|
|
17000
|
+
let start = sourceColumn.lines.length;
|
|
17001
|
+
let scannedParagraphs = 0;
|
|
17002
|
+
while (start > 0 && scannedParagraphs < MAX_KEEP_NEXT_LOOKAHEAD) {
|
|
17003
|
+
var _paragraphConfigCache;
|
|
17004
|
+
const paragraph = sourceColumn.lines[start - 1].paragraphIndex;
|
|
17005
|
+
if (((_paragraphConfigCache = paragraphConfigCache.get(paragraph)) === null || _paragraphConfigCache === void 0 || (_paragraphConfigCache = _paragraphConfigCache.paragraphStyle) === null || _paragraphConfigCache === void 0 ? void 0 : _paragraphConfigCache.keepNext) !== BooleanNumber.TRUE) break;
|
|
17006
|
+
scannedParagraphs += 1;
|
|
17007
|
+
const paragraphStart = sourceColumn.lines.findLastIndex((line, index) => index < start && line.paragraphIndex !== paragraph) + 1;
|
|
17008
|
+
const pageRefs = _getParagraphLineRefs([originalPage], paragraph);
|
|
17009
|
+
if (metrics) {
|
|
17010
|
+
metrics.measuredLineCount += pageRefs.length;
|
|
17011
|
+
metrics.peakCheckpointLineCount = Math.max(metrics.peakCheckpointLineCount, pageRefs.length);
|
|
17012
|
+
}
|
|
17013
|
+
const tailLineCount = start - paragraphStart;
|
|
17014
|
+
if (pageRefs.length !== tailLineCount || pageRefs.some(({ column }) => column !== sourceColumn)) break;
|
|
17015
|
+
start = paragraphStart;
|
|
17016
|
+
}
|
|
17017
|
+
if (metrics) metrics.keepNextScanCount += scannedParagraphs;
|
|
17018
|
+
if (start === sourceColumn.lines.length) return 0;
|
|
17019
|
+
const movedLineCount = _prependLines(sourceColumn, targetColumn, sourceColumn.lines.slice(start));
|
|
17020
|
+
if (metrics && movedLineCount > 0) {
|
|
17021
|
+
metrics.retryCount += 1;
|
|
17022
|
+
metrics.movedLineCount += movedLineCount;
|
|
17023
|
+
}
|
|
17024
|
+
return movedLineCount;
|
|
17025
|
+
}
|
|
17026
|
+
function _applyWidowControl(pages, paragraphIndex, metrics) {
|
|
17027
|
+
const refs = _getParagraphLineRefs(pages, paragraphIndex);
|
|
17028
|
+
if (metrics) {
|
|
17029
|
+
metrics.measuredLineCount += refs.length;
|
|
17030
|
+
metrics.peakCheckpointLineCount = Math.max(metrics.peakCheckpointLineCount, refs.length);
|
|
17031
|
+
}
|
|
17032
|
+
const paragraphPages = [...new Set(refs.map(({ page }) => page))];
|
|
17033
|
+
if (paragraphPages.length < 2 || paragraphPages.some((page) => page.sections.some((section) => section.columns.length !== 1))) return 0;
|
|
17034
|
+
const sourcePage = paragraphPages[paragraphPages.length - 2];
|
|
17035
|
+
const targetPage = paragraphPages[paragraphPages.length - 1];
|
|
17036
|
+
const sourceRefs = refs.filter(({ page }) => page === sourcePage);
|
|
17037
|
+
const targetRefs = refs.filter(({ page }) => page === targetPage);
|
|
17038
|
+
if (sourceRefs.length === 1 && targetRefs.length >= 2) {
|
|
17039
|
+
const movedLineCount = _prependLines(sourceRefs[0].column, targetRefs[0].column, [sourceRefs[0].line]);
|
|
17040
|
+
if (metrics && movedLineCount > 0) {
|
|
17041
|
+
metrics.retryCount += 1;
|
|
17042
|
+
metrics.movedLineCount += movedLineCount;
|
|
17043
|
+
}
|
|
17044
|
+
return movedLineCount;
|
|
17045
|
+
}
|
|
17046
|
+
if (targetRefs.length === 1 && sourceRefs.length >= 3) {
|
|
17047
|
+
const line = sourceRefs[sourceRefs.length - 1];
|
|
17048
|
+
const movedLineCount = _prependLines(line.column, targetRefs[0].column, [line.line]);
|
|
17049
|
+
if (metrics && movedLineCount > 0) {
|
|
17050
|
+
metrics.retryCount += 1;
|
|
17051
|
+
metrics.movedLineCount += movedLineCount;
|
|
17052
|
+
}
|
|
17053
|
+
return movedLineCount;
|
|
17054
|
+
}
|
|
17055
|
+
return 0;
|
|
17056
|
+
}
|
|
16805
17057
|
function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, sectionBreakConfig, tableSkeleton) {
|
|
16806
17058
|
var _viewModel$getSnapsho, _sectionBreakConfig$d, _viewModel$getBody2, _viewModel$getBody3;
|
|
16807
17059
|
const { skeletonResourceReference } = ctx;
|
|
@@ -16813,7 +17065,8 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
16813
17065
|
paragraphId: "para_render_fallback"
|
|
16814
17066
|
};
|
|
16815
17067
|
const { paragraphStyle = {}, bullet } = paragraph;
|
|
16816
|
-
const
|
|
17068
|
+
const documentSnapshot = (_viewModel$getSnapsho = viewModel.getSnapshot) === null || _viewModel$getSnapsho === void 0 ? void 0 : _viewModel$getSnapsho.call(viewModel);
|
|
17069
|
+
const documentStyle = documentSnapshot === null || documentSnapshot === void 0 ? void 0 : documentSnapshot.documentStyle;
|
|
16817
17070
|
const documentCompatibilityPolicy = (_sectionBreakConfig$d = sectionBreakConfig.documentCompatibilityPolicy) !== null && _sectionBreakConfig$d !== void 0 ? _sectionBreakConfig$d : getDocumentCompatibilityPolicy(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor);
|
|
16818
17071
|
const shouldApplyDocumentDefaults = documentCompatibilityPolicy.applyDocumentDefaultParagraphStyle;
|
|
16819
17072
|
const useWordStyleLineHeight = documentCompatibilityPolicy.useWordStyleLineHeight;
|
|
@@ -16827,7 +17080,7 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
16827
17080
|
segmentDrawingAnchorCache = /* @__PURE__ */ new Map();
|
|
16828
17081
|
drawingAnchor === null || drawingAnchor === void 0 || drawingAnchor.set(segmentId, segmentDrawingAnchorCache);
|
|
16829
17082
|
}
|
|
16830
|
-
const resolvedParagraphStyle = _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, documentStyle, shouldApplyDocumentDefaults);
|
|
17083
|
+
const resolvedParagraphStyle = _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, documentStyle, shouldApplyDocumentDefaults, documentSnapshot === null || documentSnapshot === void 0 ? void 0 : documentSnapshot.styles, paragraph.styleId);
|
|
16831
17084
|
const borderBottom = resolvedParagraphStyle.borderBottom;
|
|
16832
17085
|
if (borderBottom) {
|
|
16833
17086
|
var _borderBottom$padding, _borderBottom$width;
|
|
@@ -16877,6 +17130,13 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
16877
17130
|
}
|
|
16878
17131
|
segmentParagraphCache.set(endIndex, paragraphConfig);
|
|
16879
17132
|
let allPages = [curPage];
|
|
17133
|
+
const explicitStructuralBreak = _hasExplicitStructuralBreak(shapedTextList);
|
|
17134
|
+
const traditionalPagination = isTraditionalDocumentCompatibility(documentCompatibilityPolicy);
|
|
17135
|
+
const forcePageBreakBefore = traditionalPagination && resolvedParagraphStyle.pageBreakBefore === BooleanNumber.TRUE && _hasPageContent(curPage) && !_hasOnlyExplicitPageBoundaryMarkers(curPage);
|
|
17136
|
+
if (forcePageBreakBefore) {
|
|
17137
|
+
allPages.push(createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, _getNextPageNumber(curPage), 1));
|
|
17138
|
+
ctx.paragraphsOpenNewPage.add(endIndex);
|
|
17139
|
+
}
|
|
16880
17140
|
let isParagraphFirstShapedText = true;
|
|
16881
17141
|
let shapedTextOffset = 0;
|
|
16882
17142
|
for (const [_index, { text, glyphs, breakPointType }] of _mergeAdjacentCustomBlockShapedTexts(shapedTextList, paragraphNonInlineSkeDrawingsByBlockId).entries()) {
|
|
@@ -16913,6 +17173,17 @@ function lineBreaking(ctx, viewModel, shapedTextList, curPage, paragraphNode, se
|
|
|
16913
17173
|
pushPending();
|
|
16914
17174
|
shapedTextOffset += textGlyphCount;
|
|
16915
17175
|
}
|
|
17176
|
+
const needsPaginationCheckpoint = forcePageBreakBefore || !explicitStructuralBreak && tableSkeleton == null && paragraphNonInlineSkeDrawingsByBlockId.size === 0 && (resolvedParagraphStyle.keepLines === BooleanNumber.TRUE || allPages.length > 1 && (resolvedParagraphStyle.widowControl === BooleanNumber.TRUE || segmentParagraphCache.size > 1));
|
|
17177
|
+
if (traditionalPagination && ctx.paginationMetrics) if (needsPaginationCheckpoint) ctx.paginationMetrics.constrainedParagraphs += 1;
|
|
17178
|
+
else ctx.paginationMetrics.noConstraintParagraphs += 1;
|
|
17179
|
+
if (traditionalPagination && !explicitStructuralBreak && !forcePageBreakBefore && tableSkeleton == null && paragraphNonInlineSkeDrawingsByBlockId.size === 0) {
|
|
17180
|
+
if (resolvedParagraphStyle.keepLines === BooleanNumber.TRUE && _applyKeepLines(allPages, endIndex, ctx.paginationMetrics) > 0) ctx.paragraphsOpenNewPage.add(endIndex);
|
|
17181
|
+
const keepNextMoved = allPages.length > 1 ? _applyKeepNext(allPages, curPage, endIndex, segmentParagraphCache, ctx.paginationMetrics) : 0;
|
|
17182
|
+
if (keepNextMoved > 0) ctx.paragraphsOpenNewPage.add(endIndex);
|
|
17183
|
+
let widowMoved = 0;
|
|
17184
|
+
if (allPages.length > 1 && resolvedParagraphStyle.widowControl === BooleanNumber.TRUE) widowMoved = _applyWidowControl(allPages, endIndex, ctx.paginationMetrics);
|
|
17185
|
+
if (widowMoved > 0 && keepNextMoved === 0 && _applyKeepNext(allPages, curPage, endIndex, segmentParagraphCache, ctx.paginationMetrics) > 0) ctx.paragraphsOpenNewPage.add(endIndex);
|
|
17186
|
+
}
|
|
16916
17187
|
return allPages;
|
|
16917
17188
|
}
|
|
16918
17189
|
function syncActiveParagraphDrawings(glyphs, paragraphNonInlineSkeDrawings, paragraphInlineSkeDrawings, paragraphNonInlineSkeDrawingsByBlockId, paragraphInlineSkeDrawingsByBlockId) {
|
|
@@ -17055,6 +17326,39 @@ var LineBreakerLinkEnhancer = class {
|
|
|
17055
17326
|
}
|
|
17056
17327
|
};
|
|
17057
17328
|
|
|
17329
|
+
//#endregion
|
|
17330
|
+
//#region src/components/docs/layout/line-breaker/enhancers/whole-entity-enhancer.ts
|
|
17331
|
+
/**
|
|
17332
|
+
* Removes line-break opportunities from the interior of measured whole
|
|
17333
|
+
* entities. The model keeps the entity's complete source text, while shaping
|
|
17334
|
+
* treats the inclusive custom range as one unbreakable inline object.
|
|
17335
|
+
*/
|
|
17336
|
+
var LineBreakerWholeEntityEnhancer = class {
|
|
17337
|
+
constructor(_lineBreaker, ranges, _contentStartIndex) {
|
|
17338
|
+
this._lineBreaker = _lineBreaker;
|
|
17339
|
+
this._contentStartIndex = _contentStartIndex;
|
|
17340
|
+
_defineProperty(this, "content", void 0);
|
|
17341
|
+
_defineProperty(this, "_ranges", void 0);
|
|
17342
|
+
_defineProperty(this, "_rangeIndex", 0);
|
|
17343
|
+
this.content = _lineBreaker.content;
|
|
17344
|
+
this._ranges = [...ranges].sort((a, b) => a.startIndex - b.startIndex);
|
|
17345
|
+
}
|
|
17346
|
+
nextBreakPoint() {
|
|
17347
|
+
let breakPoint = this._lineBreaker.nextBreakPoint();
|
|
17348
|
+
while (breakPoint && this._isInsideWholeEntity(breakPoint.position)) breakPoint = this._lineBreaker.nextBreakPoint();
|
|
17349
|
+
return breakPoint;
|
|
17350
|
+
}
|
|
17351
|
+
_isInsideWholeEntity(position) {
|
|
17352
|
+
const absolutePosition = this._contentStartIndex + position;
|
|
17353
|
+
let range = this._ranges[this._rangeIndex];
|
|
17354
|
+
while (range && absolutePosition > range.endIndex) {
|
|
17355
|
+
this._rangeIndex++;
|
|
17356
|
+
range = this._ranges[this._rangeIndex];
|
|
17357
|
+
}
|
|
17358
|
+
return range != null && absolutePosition > range.startIndex && absolutePosition <= range.endIndex;
|
|
17359
|
+
}
|
|
17360
|
+
};
|
|
17361
|
+
|
|
17058
17362
|
//#endregion
|
|
17059
17363
|
//#region src/components/docs/layout/line-breaker/extensions/custom-block-linebreak-extension.ts
|
|
17060
17364
|
const SLASH_B_CODE_POINT = 8;
|
|
@@ -17073,318 +17377,6 @@ function tabLineBreakExtension(breaker) {
|
|
|
17073
17377
|
});
|
|
17074
17378
|
}
|
|
17075
17379
|
|
|
17076
|
-
//#endregion
|
|
17077
|
-
//#region src/components/docs/layout/shaping-engine/font-library.ts
|
|
17078
|
-
function getFontInfoFromFontData(fontData) {
|
|
17079
|
-
const { family, style: styleString } = fontData;
|
|
17080
|
-
let style = 0;
|
|
17081
|
-
let weight = 400;
|
|
17082
|
-
if (/italic/i.test(styleString)) style = 1;
|
|
17083
|
-
switch (true) {
|
|
17084
|
-
case /thin|hairline/i.test(styleString):
|
|
17085
|
-
weight = 100;
|
|
17086
|
-
break;
|
|
17087
|
-
case /(extra|ultra) *light/i.test(styleString):
|
|
17088
|
-
weight = 200;
|
|
17089
|
-
break;
|
|
17090
|
-
case /light/i.test(styleString):
|
|
17091
|
-
weight = 300;
|
|
17092
|
-
break;
|
|
17093
|
-
case /medium/i.test(styleString):
|
|
17094
|
-
weight = 500;
|
|
17095
|
-
break;
|
|
17096
|
-
case /(semi|demi) *bold/i.test(styleString):
|
|
17097
|
-
weight = 600;
|
|
17098
|
-
break;
|
|
17099
|
-
case /bold/i.test(styleString):
|
|
17100
|
-
weight = 700;
|
|
17101
|
-
break;
|
|
17102
|
-
case /(extra|ultra) *bold/i.test(styleString):
|
|
17103
|
-
weight = 800;
|
|
17104
|
-
break;
|
|
17105
|
-
case /black|heavy/i.test(styleString):
|
|
17106
|
-
weight = 900;
|
|
17107
|
-
break;
|
|
17108
|
-
}
|
|
17109
|
-
return {
|
|
17110
|
-
family,
|
|
17111
|
-
variant: {
|
|
17112
|
-
style,
|
|
17113
|
-
weight
|
|
17114
|
-
}
|
|
17115
|
-
};
|
|
17116
|
-
}
|
|
17117
|
-
function getFontInfoFromTextStyle(style) {
|
|
17118
|
-
const { ff, bl = BooleanNumber.FALSE, it = BooleanNumber.FALSE } = style;
|
|
17119
|
-
return {
|
|
17120
|
-
family: ff !== null && ff !== void 0 ? ff : "Arial",
|
|
17121
|
-
variant: {
|
|
17122
|
-
style: it === BooleanNumber.TRUE ? 1 : 0,
|
|
17123
|
-
weight: bl === BooleanNumber.TRUE ? 700 : 400
|
|
17124
|
-
}
|
|
17125
|
-
};
|
|
17126
|
-
}
|
|
17127
|
-
function fontInfoDistance(a, b) {
|
|
17128
|
-
let styleDistance = Number.POSITIVE_INFINITY;
|
|
17129
|
-
if (a.variant.style === b.variant.style) styleDistance = 0;
|
|
17130
|
-
else if (a.variant.style !== 0 && b.variant.style !== 0) styleDistance = 1;
|
|
17131
|
-
else styleDistance = 2;
|
|
17132
|
-
const weightDistance = Math.abs(a.variant.weight - b.variant.weight);
|
|
17133
|
-
return [styleDistance, weightDistance];
|
|
17134
|
-
}
|
|
17135
|
-
function compareFontInfoDistance(a, b) {
|
|
17136
|
-
if (a[0] === b[0] && a[1] === b[1]) return 0;
|
|
17137
|
-
if (a[0] === b[0]) return a[1] > b[1] ? 1 : 2;
|
|
17138
|
-
return a[0] > b[0] ? 1 : 2;
|
|
17139
|
-
}
|
|
17140
|
-
async function checkLocalFontsPermission() {
|
|
17141
|
-
var _window$navigator;
|
|
17142
|
-
if (typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) return false;
|
|
17143
|
-
if (typeof window === "undefined") return false;
|
|
17144
|
-
if (window.navigator == null || ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.permissions) == null) return false;
|
|
17145
|
-
try {
|
|
17146
|
-
return (await window.navigator.permissions.query({ name: "local-fonts" })).state === "granted";
|
|
17147
|
-
} catch (_err) {
|
|
17148
|
-
return false;
|
|
17149
|
-
}
|
|
17150
|
-
}
|
|
17151
|
-
var FontLibrary = class {
|
|
17152
|
-
constructor() {
|
|
17153
|
-
_defineProperty(this, "isReady", false);
|
|
17154
|
-
_defineProperty(this, "_fontBook", /* @__PURE__ */ new Map());
|
|
17155
|
-
this._loadFontsToBook();
|
|
17156
|
-
}
|
|
17157
|
-
async _loadFontsToBook() {
|
|
17158
|
-
if (this.isReady) return;
|
|
17159
|
-
if (!await checkLocalFontsPermission() || !("queryLocalFonts" in window)) return;
|
|
17160
|
-
if (typeof navigator === "object" && navigator.userAgent.includes("Electron")) return;
|
|
17161
|
-
try {
|
|
17162
|
-
const availableFonts = await window.queryLocalFonts({ postscriptNames: [] });
|
|
17163
|
-
for (const font of availableFonts) {
|
|
17164
|
-
const { family, style } = font;
|
|
17165
|
-
let fontMap = this._fontBook.get(family);
|
|
17166
|
-
if (fontMap == null) {
|
|
17167
|
-
fontMap = /* @__PURE__ */ new Map();
|
|
17168
|
-
this._fontBook.set(family, fontMap);
|
|
17169
|
-
}
|
|
17170
|
-
const buffer = await (await font.blob()).arrayBuffer();
|
|
17171
|
-
fontMap.set(style, {
|
|
17172
|
-
font,
|
|
17173
|
-
buffer
|
|
17174
|
-
});
|
|
17175
|
-
}
|
|
17176
|
-
this.isReady = true;
|
|
17177
|
-
} catch (err) {
|
|
17178
|
-
console.error(err);
|
|
17179
|
-
}
|
|
17180
|
-
}
|
|
17181
|
-
findBestMatchFontByStyle(style) {
|
|
17182
|
-
const ff = style.ff;
|
|
17183
|
-
const fontMap = this._fontBook.get(ff);
|
|
17184
|
-
if (fontMap == null) return;
|
|
17185
|
-
let bestFont = null;
|
|
17186
|
-
let bestDistance = [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY];
|
|
17187
|
-
for (const fontWithBuffer of fontMap.values()) {
|
|
17188
|
-
const { font } = fontWithBuffer;
|
|
17189
|
-
const distance = fontInfoDistance(getFontInfoFromFontData(font), getFontInfoFromTextStyle(style));
|
|
17190
|
-
if (bestFont == null) {
|
|
17191
|
-
bestFont = fontWithBuffer;
|
|
17192
|
-
bestDistance = distance;
|
|
17193
|
-
} else if (compareFontInfoDistance(bestDistance, distance) === 1) {
|
|
17194
|
-
bestFont = fontWithBuffer;
|
|
17195
|
-
bestDistance = distance;
|
|
17196
|
-
}
|
|
17197
|
-
}
|
|
17198
|
-
return bestFont;
|
|
17199
|
-
}
|
|
17200
|
-
getValidFontFamilies(families) {
|
|
17201
|
-
return families.filter((family) => this._fontBook.has(family));
|
|
17202
|
-
}
|
|
17203
|
-
};
|
|
17204
|
-
const fontLibrary = new FontLibrary();
|
|
17205
|
-
|
|
17206
|
-
//#endregion
|
|
17207
|
-
//#region src/components/docs/layout/shaping-engine/utils.ts
|
|
17208
|
-
function prepareParagraphBody(body, paragraphIndex) {
|
|
17209
|
-
const { dataStream, paragraphs = [], textRuns = [] } = body;
|
|
17210
|
-
let last = 0;
|
|
17211
|
-
for (let i = 0; i < paragraphs.length; i++) {
|
|
17212
|
-
const { startIndex } = paragraphs[i];
|
|
17213
|
-
if (startIndex === paragraphIndex) break;
|
|
17214
|
-
last = startIndex + 1;
|
|
17215
|
-
}
|
|
17216
|
-
const textRunChunks = [];
|
|
17217
|
-
for (const textRun of textRuns) {
|
|
17218
|
-
const { st, ed } = textRun;
|
|
17219
|
-
if (st >= last && st <= paragraphIndex) textRunChunks.push({
|
|
17220
|
-
...textRun,
|
|
17221
|
-
st: st - last,
|
|
17222
|
-
ed: Math.min(ed, paragraphIndex) - last
|
|
17223
|
-
});
|
|
17224
|
-
else if (ed >= last && ed <= paragraphIndex) textRunChunks.push({
|
|
17225
|
-
...textRun,
|
|
17226
|
-
st: Math.max(st, last) - last,
|
|
17227
|
-
ed: ed - last
|
|
17228
|
-
});
|
|
17229
|
-
}
|
|
17230
|
-
return {
|
|
17231
|
-
dataStream: dataStream.substring(last, paragraphIndex + 1),
|
|
17232
|
-
textRuns: textRunChunks
|
|
17233
|
-
};
|
|
17234
|
-
}
|
|
17235
|
-
function prepareTextChunks(body) {
|
|
17236
|
-
const { dataStream, textRuns = [] } = body;
|
|
17237
|
-
let offset = 0;
|
|
17238
|
-
const chunks = [];
|
|
17239
|
-
for (const textRun of textRuns) {
|
|
17240
|
-
const { st, ed, ts = {} } = textRun;
|
|
17241
|
-
if (st !== offset) chunks.push({ content: dataStream.substring(offset, st) });
|
|
17242
|
-
chunks.push({
|
|
17243
|
-
content: dataStream.substring(st, ed),
|
|
17244
|
-
style: ts
|
|
17245
|
-
});
|
|
17246
|
-
offset = ed;
|
|
17247
|
-
}
|
|
17248
|
-
if (offset !== dataStream.length) chunks.push({ content: dataStream.substring(offset) });
|
|
17249
|
-
return chunks;
|
|
17250
|
-
}
|
|
17251
|
-
|
|
17252
|
-
//#endregion
|
|
17253
|
-
//#region src/components/docs/layout/shaping-engine/text-shaping.ts
|
|
17254
|
-
const fontCache = /* @__PURE__ */ new Map();
|
|
17255
|
-
const glyphCache = /* @__PURE__ */ new Map();
|
|
17256
|
-
const fontFamilyCache = /* @__PURE__ */ new Map();
|
|
17257
|
-
function trimOuterQuotes(value) {
|
|
17258
|
-
const firstChar = value.charCodeAt(0);
|
|
17259
|
-
const lastChar = value.charCodeAt(value.length - 1);
|
|
17260
|
-
const hasLeadingQuote = firstChar === 34 || firstChar === 39;
|
|
17261
|
-
const hasTrailingQuote = lastChar === 34 || lastChar === 39;
|
|
17262
|
-
if (hasLeadingQuote && hasTrailingQuote) return value.slice(1, -1);
|
|
17263
|
-
if (hasLeadingQuote) return value.slice(1);
|
|
17264
|
-
if (hasTrailingQuote) return value.slice(0, -1);
|
|
17265
|
-
return value;
|
|
17266
|
-
}
|
|
17267
|
-
function expandFontFamilies(fontFamily) {
|
|
17268
|
-
if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return [];
|
|
17269
|
-
let families = fontFamilyCache.get(fontFamily);
|
|
17270
|
-
if (families) return families;
|
|
17271
|
-
families = fontFamily.split(",").map((family) => trimOuterQuotes(family.trim())).filter(Boolean);
|
|
17272
|
-
fontFamilyCache.set(fontFamily, families);
|
|
17273
|
-
return families;
|
|
17274
|
-
}
|
|
17275
|
-
const defaultFontFamilies = expandFontFamilies(DEFAULT_FONTFACE_PLANE);
|
|
17276
|
-
function shapeChunk(content, charPosition, used, families, style) {
|
|
17277
|
-
var _style$bl, _style$it, _content$match;
|
|
17278
|
-
let fi = 0;
|
|
17279
|
-
let fontFamily = families[fi];
|
|
17280
|
-
while (used.has(fontFamily)) {
|
|
17281
|
-
fi++;
|
|
17282
|
-
fontFamily = families[fi];
|
|
17283
|
-
}
|
|
17284
|
-
if (!fontFamily) return [{
|
|
17285
|
-
char: content,
|
|
17286
|
-
start: charPosition,
|
|
17287
|
-
end: charPosition + content.length,
|
|
17288
|
-
glyph: null,
|
|
17289
|
-
font: null,
|
|
17290
|
-
kerning: 0,
|
|
17291
|
-
boundingBox: null
|
|
17292
|
-
}];
|
|
17293
|
-
used.add(fontFamily);
|
|
17294
|
-
const { font: fontInfo, buffer: fontBuffer } = fontLibrary.findBestMatchFontByStyle({
|
|
17295
|
-
ff: fontFamily,
|
|
17296
|
-
bl: (_style$bl = style.bl) !== null && _style$bl !== void 0 ? _style$bl : BooleanNumber.FALSE,
|
|
17297
|
-
it: (_style$it = style.it) !== null && _style$it !== void 0 ? _style$it : BooleanNumber.FALSE
|
|
17298
|
-
});
|
|
17299
|
-
let font = fontCache.get(fontInfo.fullName);
|
|
17300
|
-
if (!font) {
|
|
17301
|
-
font = parse(fontBuffer);
|
|
17302
|
-
fontCache.set(fontInfo.fullName, font);
|
|
17303
|
-
}
|
|
17304
|
-
const results = [];
|
|
17305
|
-
const glyphs = font.stringToGlyphs(content);
|
|
17306
|
-
const chars = (_content$match = content.match(/[\s\S]/gu)) !== null && _content$match !== void 0 ? _content$match : [];
|
|
17307
|
-
let gi = 0;
|
|
17308
|
-
let startIndex = 0;
|
|
17309
|
-
while (gi < glyphs.length) {
|
|
17310
|
-
var _chars$gi;
|
|
17311
|
-
const glyph = glyphs[gi];
|
|
17312
|
-
if (glyph.index !== 0) results.push({
|
|
17313
|
-
char: chars[gi],
|
|
17314
|
-
start: startIndex + charPosition,
|
|
17315
|
-
end: startIndex + charPosition + chars[gi].length,
|
|
17316
|
-
glyph,
|
|
17317
|
-
font,
|
|
17318
|
-
kerning: 0,
|
|
17319
|
-
boundingBox: glyph.getBoundingBox()
|
|
17320
|
-
});
|
|
17321
|
-
else {
|
|
17322
|
-
const start = startIndex;
|
|
17323
|
-
const firstGrapheme = getFirstGrapheme(content.substring(start));
|
|
17324
|
-
if (firstGrapheme && isEmojiGrapheme(firstGrapheme)) {
|
|
17325
|
-
let acc = 0;
|
|
17326
|
-
do {
|
|
17327
|
-
acc += chars[gi].length;
|
|
17328
|
-
startIndex += chars[gi].length;
|
|
17329
|
-
gi++;
|
|
17330
|
-
} while (acc < firstGrapheme.length);
|
|
17331
|
-
results.push(...shapeChunk(content.slice(start, start + firstGrapheme.length), charPosition + start, used, families, style));
|
|
17332
|
-
continue;
|
|
17333
|
-
} else {
|
|
17334
|
-
let nextGlyph = glyphs[gi + 1];
|
|
17335
|
-
let nextChar = chars[gi + 1];
|
|
17336
|
-
while ((nextGlyph === null || nextGlyph === void 0 ? void 0 : nextGlyph.index) === 0 && !isEmojiGrapheme(nextChar)) {
|
|
17337
|
-
startIndex += chars[gi].length;
|
|
17338
|
-
gi++;
|
|
17339
|
-
nextGlyph = glyphs[gi + 1];
|
|
17340
|
-
nextChar = chars[gi + 1];
|
|
17341
|
-
}
|
|
17342
|
-
results.push(...shapeChunk(content.slice(start, startIndex + chars[gi].length), charPosition + start, used, families, style));
|
|
17343
|
-
}
|
|
17344
|
-
}
|
|
17345
|
-
startIndex += (_chars$gi = chars[gi]) === null || _chars$gi === void 0 ? void 0 : _chars$gi.length;
|
|
17346
|
-
gi++;
|
|
17347
|
-
}
|
|
17348
|
-
used.delete(fontFamily);
|
|
17349
|
-
return results;
|
|
17350
|
-
}
|
|
17351
|
-
function kerningAdjustment(glyphs) {
|
|
17352
|
-
if (glyphs.length < 2) return;
|
|
17353
|
-
let lastFont = glyphs[0].font;
|
|
17354
|
-
let lastGlyph = glyphs[0].glyph;
|
|
17355
|
-
for (let i = 1; i < glyphs.length; i++) {
|
|
17356
|
-
const { font, glyph } = glyphs[i];
|
|
17357
|
-
if (lastFont !== font || font == null || lastGlyph == null || glyph == null) {
|
|
17358
|
-
lastFont = font;
|
|
17359
|
-
lastGlyph = glyph;
|
|
17360
|
-
continue;
|
|
17361
|
-
}
|
|
17362
|
-
const kerning = font.getKerningValue(lastGlyph, glyph);
|
|
17363
|
-
if (kerning !== 0) glyphs[i].kerning = kerning;
|
|
17364
|
-
lastFont = font;
|
|
17365
|
-
lastGlyph = glyph;
|
|
17366
|
-
}
|
|
17367
|
-
}
|
|
17368
|
-
function textShape(body) {
|
|
17369
|
-
if (!fontLibrary.isReady) return [];
|
|
17370
|
-
const key = JSON.stringify(body);
|
|
17371
|
-
if (glyphCache.has(key)) return glyphCache.get(key);
|
|
17372
|
-
const chunks = prepareTextChunks(body);
|
|
17373
|
-
const glyphs = [];
|
|
17374
|
-
let charPosition = 0;
|
|
17375
|
-
for (const chunk of chunks) {
|
|
17376
|
-
var _style$ff;
|
|
17377
|
-
const { content, style = {} } = chunk;
|
|
17378
|
-
let fontFamilies = [...expandFontFamilies((_style$ff = style.ff) !== null && _style$ff !== void 0 ? _style$ff : "Arial"), ...defaultFontFamilies];
|
|
17379
|
-
fontFamilies = fontLibrary.getValidFontFamilies(fontFamilies);
|
|
17380
|
-
glyphs.push(...shapeChunk(content, charPosition, /* @__PURE__ */ new Set(), fontFamilies, style));
|
|
17381
|
-
charPosition += content.length;
|
|
17382
|
-
}
|
|
17383
|
-
kerningAdjustment(glyphs);
|
|
17384
|
-
glyphCache.set(key, glyphs);
|
|
17385
|
-
return glyphs;
|
|
17386
|
-
}
|
|
17387
|
-
|
|
17388
17380
|
//#endregion
|
|
17389
17381
|
//#region src/components/docs/layout/block/paragraph/language-ruler.ts
|
|
17390
17382
|
function otherHandler(index, charArray, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
|
|
@@ -17506,10 +17498,36 @@ function hyphenConfig(paragraphStyle, sectionBreakConfig) {
|
|
|
17506
17498
|
const { autoHyphenation = BooleanNumber.FALSE } = sectionBreakConfig;
|
|
17507
17499
|
return suppressHyphenation === BooleanNumber.FALSE && autoHyphenation === BooleanNumber.TRUE;
|
|
17508
17500
|
}
|
|
17509
|
-
function
|
|
17501
|
+
function collectMeasuredWholeEntityRanges(content, viewModel, paragraphNode) {
|
|
17502
|
+
var _viewModel$getBody$cu, _viewModel$getBody;
|
|
17503
|
+
const ranges = [];
|
|
17504
|
+
const contentStartIndex = paragraphNode.startIndex;
|
|
17505
|
+
const contentEndIndex = contentStartIndex + content.length - 1;
|
|
17506
|
+
const customRanges = (_viewModel$getBody$cu = (_viewModel$getBody = viewModel.getBody()) === null || _viewModel$getBody === void 0 ? void 0 : _viewModel$getBody.customRanges) !== null && _viewModel$getBody$cu !== void 0 ? _viewModel$getBody$cu : [];
|
|
17507
|
+
for (const customRange of customRanges) {
|
|
17508
|
+
if (!customRange.wholeEntity || customRange.startIndex < contentStartIndex || customRange.endIndex < customRange.startIndex || customRange.endIndex > contentEndIndex) continue;
|
|
17509
|
+
const interceptedRange = viewModel.getCustomRange(customRange.startIndex);
|
|
17510
|
+
if ((interceptedRange === null || interceptedRange === void 0 ? void 0 : interceptedRange.rangeId) === customRange.rangeId && interceptedRange.startIndex === customRange.startIndex && interceptedRange.endIndex === customRange.endIndex && isMeasuredWholeEntityRange(interceptedRange)) ranges.push(interceptedRange);
|
|
17511
|
+
}
|
|
17512
|
+
return ranges.sort((a, b) => a.startIndex - b.startIndex);
|
|
17513
|
+
}
|
|
17514
|
+
function createMeasuredWholeEntityGlyph(content, range, viewModel, paragraphNode, sectionBreakConfig, paragraph) {
|
|
17515
|
+
const relativeStartIndex = range.startIndex - paragraphNode.startIndex;
|
|
17516
|
+
const relativeEndIndex = range.endIndex - paragraphNode.startIndex + 1;
|
|
17517
|
+
const raw = content.slice(relativeStartIndex, relativeEndIndex);
|
|
17518
|
+
const config = getFontCreateConfig(relativeStartIndex, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17519
|
+
const metrics = getCustomRangeGlyphMetricsFromRange(range, config);
|
|
17520
|
+
if (!raw || !metrics) return;
|
|
17521
|
+
return createSkeletonWholeEntityGlyph(raw, config, metrics);
|
|
17522
|
+
}
|
|
17523
|
+
function getShapedGlyphText(glyph) {
|
|
17524
|
+
if (glyph.glyphType === 3 && glyph.streamType === DataStreamTreeTokenType.LETTER && glyph.raw !== glyph.content) return glyph.raw;
|
|
17525
|
+
return glyph.content;
|
|
17526
|
+
}
|
|
17527
|
+
function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
17510
17528
|
const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 10.5, drawings = {} } = sectionBreakConfig;
|
|
17511
17529
|
const shapedTextList = [];
|
|
17512
|
-
|
|
17530
|
+
const lineBreaker = new LineBreaker(content);
|
|
17513
17531
|
const { endIndex } = paragraphNode;
|
|
17514
17532
|
const paragraph = viewModel.getParagraph(endIndex) || {
|
|
17515
17533
|
startIndex: 0,
|
|
@@ -17517,116 +17535,107 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
|
|
|
17517
17535
|
};
|
|
17518
17536
|
const { paragraphStyle = {} } = paragraph;
|
|
17519
17537
|
const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;
|
|
17538
|
+
const measuredWholeEntityRanges = collectMeasuredWholeEntityRanges(content, viewModel, paragraphNode);
|
|
17539
|
+
const measuredWholeEntityRangeByStart = new Map(measuredWholeEntityRanges.map((range) => [range.startIndex - paragraphNode.startIndex, range]));
|
|
17540
|
+
const measuredWholeEntityRangeStarts = measuredWholeEntityRanges.map((range) => range.startIndex - paragraphNode.startIndex);
|
|
17541
|
+
let measuredWholeEntityRangeIndex = 0;
|
|
17520
17542
|
let last = 0;
|
|
17521
17543
|
let bk;
|
|
17522
|
-
let lastGlyphIndex = 0;
|
|
17523
17544
|
const { hyphen, languageDetector } = ctx;
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
tabLineBreakExtension(breaker);
|
|
17528
|
-
customBlockLineBreakExtension(breaker);
|
|
17529
|
-
breaker = new LineBreakerLinkEnhancer(breaker);
|
|
17545
|
+
tabLineBreakExtension(lineBreaker);
|
|
17546
|
+
customBlockLineBreakExtension(lineBreaker);
|
|
17547
|
+
let breaker = new LineBreakerLinkEnhancer(lineBreaker);
|
|
17530
17548
|
const lang = languageDetector.detect(content);
|
|
17531
17549
|
const needHyphen = hyphenConfig(paragraphStyle, sectionBreakConfig);
|
|
17532
17550
|
const doNotHyphenateCaps = sectionBreakConfig.doNotHyphenateCaps === BooleanNumber.TRUE;
|
|
17533
17551
|
if (lang !== "unknown" && needHyphen) if (hyphen.hasPattern(lang)) breaker = new LineBreakerHyphenEnhancer(breaker, hyphen, lang, doNotHyphenateCaps);
|
|
17534
17552
|
else hyphen.loadPattern(lang);
|
|
17553
|
+
breaker = new LineBreakerWholeEntityEnhancer(breaker, measuredWholeEntityRanges, paragraphNode.startIndex);
|
|
17535
17554
|
while (bk = breaker.nextBreakPoint()) {
|
|
17536
17555
|
const word = content.slice(last, bk.position);
|
|
17537
17556
|
const shapedGlyphs = [];
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
const newSpan = createSkeletonLetterGlyph(char, config);
|
|
17556
|
-
shapedGlyphs.push(newSpan);
|
|
17557
|
-
} else {
|
|
17558
|
-
const newSpan = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(start, viewModel, paragraphNode, config), glyphInfo);
|
|
17559
|
-
shapedGlyphs.push(newSpan);
|
|
17557
|
+
let src = word;
|
|
17558
|
+
let i = last;
|
|
17559
|
+
while (src.length > 0) {
|
|
17560
|
+
var _src$match;
|
|
17561
|
+
while (measuredWholeEntityRangeIndex < measuredWholeEntityRangeStarts.length && measuredWholeEntityRangeStarts[measuredWholeEntityRangeIndex] < i) measuredWholeEntityRangeIndex++;
|
|
17562
|
+
const char = (_src$match = src.match(/^[\s\S]/gu)) === null || _src$match === void 0 ? void 0 : _src$match[0];
|
|
17563
|
+
if (char == null) break;
|
|
17564
|
+
const measuredRange = measuredWholeEntityRangeByStart.get(i);
|
|
17565
|
+
if (measuredRange) {
|
|
17566
|
+
const glyph = createMeasuredWholeEntityGlyph(content, measuredRange, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17567
|
+
if (glyph) {
|
|
17568
|
+
shapedGlyphs.push(glyph);
|
|
17569
|
+
const count = measuredRange.endIndex - measuredRange.startIndex + 1;
|
|
17570
|
+
i += count;
|
|
17571
|
+
src = src.substring(count);
|
|
17572
|
+
measuredWholeEntityRangeIndex++;
|
|
17573
|
+
continue;
|
|
17560
17574
|
}
|
|
17575
|
+
measuredWholeEntityRangeIndex++;
|
|
17561
17576
|
}
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17574
|
-
const
|
|
17575
|
-
|
|
17576
|
-
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
const boundingBox = getBoundingBox(angle, 0, width, 0, height);
|
|
17581
|
-
const viewport = getDocsCustomBlockRenderViewport((_viewModel$getDataMod = (_viewModel$getDataMod2 = (_viewModel$getDataMod3 = viewModel.getDataModel()).getUnitId) === null || _viewModel$getDataMod2 === void 0 ? void 0 : _viewModel$getDataMod2.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "", drawingOrigin.drawingId, {
|
|
17582
|
-
fallbackHeight: (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : 0,
|
|
17583
|
-
fallbackWidth: (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : 0
|
|
17584
|
-
});
|
|
17585
|
-
newGlyph = createSkeletonCustomBlockGlyph(config, (_ref = (_viewport$layoutWidth = viewport === null || viewport === void 0 ? void 0 : viewport.layoutWidth) !== null && _viewport$layoutWidth !== void 0 ? _viewport$layoutWidth : viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _ref !== void 0 ? _ref : boundingBox.width, (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : boundingBox.height, drawingOrigin.drawingId);
|
|
17586
|
-
} else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
|
|
17587
|
-
}
|
|
17588
|
-
if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
|
|
17589
|
-
shapedGlyphs.push(newGlyph);
|
|
17590
|
-
i += char.length;
|
|
17591
|
-
src = src.substring(char.length);
|
|
17592
|
-
} else if (/\s/.test(char) || cjk.hasCJK(char)) {
|
|
17593
|
-
const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17594
|
-
let newGlyph = null;
|
|
17595
|
-
if (char === DataStreamTreeTokenType.TAB) newGlyph = createSkeletonTabGlyph(config, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid));
|
|
17596
|
-
else if (char === DataStreamTreeTokenType.PARAGRAPH) {
|
|
17597
|
-
var _sectionBreakConfig$r;
|
|
17598
|
-
if (((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.zeroWidthParagraphBreak) === BooleanNumber.TRUE) newGlyph = createSkeletonLetterGlyph(char, config, 0);
|
|
17599
|
-
else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(i, viewModel, paragraphNode, config));
|
|
17600
|
-
} else newGlyph = createSkeletonLetterGlyph(char, config);
|
|
17601
|
-
shapedGlyphs.push(newGlyph);
|
|
17602
|
-
i += char.length;
|
|
17603
|
-
src = src.substring(char.length);
|
|
17604
|
-
} else if (startWithEmoji(src)) {
|
|
17605
|
-
const { step, glyphGroup } = emojiHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17606
|
-
shapedGlyphs.push(...glyphGroup);
|
|
17607
|
-
i += step;
|
|
17608
|
-
src = src.substring(step);
|
|
17609
|
-
} else if (hasArabic(char)) {
|
|
17610
|
-
const { step, glyphGroup } = ArabicHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17611
|
-
shapedGlyphs.push(...glyphGroup);
|
|
17612
|
-
i += step;
|
|
17613
|
-
src = src.substring(step);
|
|
17614
|
-
} else if (hasTibetan(char)) {
|
|
17615
|
-
const { step, glyphGroup } = TibetanHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17616
|
-
shapedGlyphs.push(...glyphGroup);
|
|
17617
|
-
i += step;
|
|
17618
|
-
src = src.substring(step);
|
|
17619
|
-
} else if (hasThai(char)) {
|
|
17620
|
-
const { step, glyphGroup } = ThaiHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17621
|
-
shapedGlyphs.push(...glyphGroup);
|
|
17622
|
-
i += step;
|
|
17623
|
-
src = src.substring(step);
|
|
17624
|
-
} else {
|
|
17625
|
-
const { step, glyphGroup } = otherHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17626
|
-
shapedGlyphs.push(...glyphGroup);
|
|
17627
|
-
i += step;
|
|
17628
|
-
src = src.substring(step);
|
|
17577
|
+
if (char === DataStreamTreeTokenType.CUSTOM_BLOCK) {
|
|
17578
|
+
const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17579
|
+
let newGlyph = null;
|
|
17580
|
+
const customBlock = viewModel.getCustomBlockWithoutSetCurrentIndex(paragraphNode.startIndex + i);
|
|
17581
|
+
if (customBlock != null) {
|
|
17582
|
+
const { blockId } = customBlock;
|
|
17583
|
+
const drawingOrigin = drawings[blockId];
|
|
17584
|
+
if ((drawingOrigin === null || drawingOrigin === void 0 ? void 0 : drawingOrigin.layoutType) === PositionedObjectLayoutType.INLINE) {
|
|
17585
|
+
var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _boundingBox$height, _boundingBox$width, _ref, _viewport$layoutWidth, _viewport$height;
|
|
17586
|
+
const { angle } = drawingOrigin.docTransform;
|
|
17587
|
+
const { width = 0, height = 0 } = drawingOrigin.docTransform.size;
|
|
17588
|
+
const boundingBox = getBoundingBox(angle, 0, width, 0, height);
|
|
17589
|
+
const viewport = getDocsCustomBlockRenderViewport((_viewModel$getDataMod = (_viewModel$getDataMod2 = (_viewModel$getDataMod3 = viewModel.getDataModel()).getUnitId) === null || _viewModel$getDataMod2 === void 0 ? void 0 : _viewModel$getDataMod2.call(_viewModel$getDataMod3)) !== null && _viewModel$getDataMod !== void 0 ? _viewModel$getDataMod : "", drawingOrigin.drawingId, {
|
|
17590
|
+
fallbackHeight: (_boundingBox$height = boundingBox.height) !== null && _boundingBox$height !== void 0 ? _boundingBox$height : 0,
|
|
17591
|
+
fallbackWidth: (_boundingBox$width = boundingBox.width) !== null && _boundingBox$width !== void 0 ? _boundingBox$width : 0
|
|
17592
|
+
});
|
|
17593
|
+
newGlyph = createSkeletonCustomBlockGlyph(config, (_ref = (_viewport$layoutWidth = viewport === null || viewport === void 0 ? void 0 : viewport.layoutWidth) !== null && _viewport$layoutWidth !== void 0 ? _viewport$layoutWidth : viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _ref !== void 0 ? _ref : boundingBox.width, (_viewport$height = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _viewport$height !== void 0 ? _viewport$height : boundingBox.height, drawingOrigin.drawingId);
|
|
17594
|
+
} else if (drawingOrigin != null) newGlyph = createSkeletonCustomBlockGlyph(config, 0, 0, drawingOrigin.drawingId);
|
|
17629
17595
|
}
|
|
17596
|
+
if (newGlyph == null) newGlyph = createSkeletonLetterGlyph(char, config);
|
|
17597
|
+
shapedGlyphs.push(newGlyph);
|
|
17598
|
+
i += char.length;
|
|
17599
|
+
src = src.substring(char.length);
|
|
17600
|
+
} else if (/\s/.test(char) || cjk.hasCJK(char)) {
|
|
17601
|
+
const config = getFontCreateConfig(i, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17602
|
+
let newGlyph = null;
|
|
17603
|
+
if (char === DataStreamTreeTokenType.TAB) newGlyph = createSkeletonTabGlyph(config, getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid));
|
|
17604
|
+
else if (char === DataStreamTreeTokenType.PARAGRAPH) {
|
|
17605
|
+
var _sectionBreakConfig$r;
|
|
17606
|
+
if (((_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.zeroWidthParagraphBreak) === BooleanNumber.TRUE) newGlyph = createSkeletonLetterGlyph(char, config, 0);
|
|
17607
|
+
else newGlyph = createSkeletonLetterGlyph(char, config, getCustomRangeGlyphMetrics(i, viewModel, paragraphNode, config));
|
|
17608
|
+
} else newGlyph = createSkeletonLetterGlyph(char, config);
|
|
17609
|
+
shapedGlyphs.push(newGlyph);
|
|
17610
|
+
i += char.length;
|
|
17611
|
+
src = src.substring(char.length);
|
|
17612
|
+
} else if (startWithEmoji(src)) {
|
|
17613
|
+
const { step, glyphGroup } = emojiHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17614
|
+
shapedGlyphs.push(...glyphGroup);
|
|
17615
|
+
i += step;
|
|
17616
|
+
src = src.substring(step);
|
|
17617
|
+
} else if (hasArabic(char)) {
|
|
17618
|
+
const { step, glyphGroup } = ArabicHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17619
|
+
shapedGlyphs.push(...glyphGroup);
|
|
17620
|
+
i += step;
|
|
17621
|
+
src = src.substring(step);
|
|
17622
|
+
} else if (hasTibetan(char)) {
|
|
17623
|
+
const { step, glyphGroup } = TibetanHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17624
|
+
shapedGlyphs.push(...glyphGroup);
|
|
17625
|
+
i += step;
|
|
17626
|
+
src = src.substring(step);
|
|
17627
|
+
} else if (hasThai(char)) {
|
|
17628
|
+
const { step, glyphGroup } = ThaiHandler(i, src, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17629
|
+
shapedGlyphs.push(...glyphGroup);
|
|
17630
|
+
i += step;
|
|
17631
|
+
src = src.substring(step);
|
|
17632
|
+
} else {
|
|
17633
|
+
const nextMeasuredRangeStart = measuredWholeEntityRangeStarts[measuredWholeEntityRangeIndex];
|
|
17634
|
+
const sourceBeforeMeasuredRange = nextMeasuredRangeStart == null ? src : src.slice(0, nextMeasuredRangeStart - i);
|
|
17635
|
+
const { step, glyphGroup } = otherHandler(i, sourceBeforeMeasuredRange, viewModel, paragraphNode, sectionBreakConfig, paragraph);
|
|
17636
|
+
shapedGlyphs.push(...glyphGroup);
|
|
17637
|
+
i += step;
|
|
17638
|
+
src = src.substring(step);
|
|
17630
17639
|
}
|
|
17631
17640
|
}
|
|
17632
17641
|
punctuationSpaceAdjustment(shapedGlyphs);
|
|
@@ -17641,7 +17650,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig, use
|
|
|
17641
17650
|
}
|
|
17642
17651
|
const lastShapedGlyphs = shapedGlyphsList[shapedGlyphsList.length - 1];
|
|
17643
17652
|
for (const shapedGlyphs of shapedGlyphsList) {
|
|
17644
|
-
const word = shapedGlyphs.map(
|
|
17653
|
+
const word = shapedGlyphs.map(getShapedGlyphText).join("");
|
|
17645
17654
|
shapedTextList.push({
|
|
17646
17655
|
text: word,
|
|
17647
17656
|
glyphs: shapedGlyphs,
|
|
@@ -18270,7 +18279,8 @@ var LanguageDetector = class LanguageDetector {
|
|
|
18270
18279
|
var _LANG_MAP_TO_HYPHEN_L;
|
|
18271
18280
|
let lang = this._detectCache.get(text);
|
|
18272
18281
|
if (lang) return lang;
|
|
18273
|
-
|
|
18282
|
+
const francLang = franc(text);
|
|
18283
|
+
lang = (_LANG_MAP_TO_HYPHEN_L = LANG_MAP_TO_HYPHEN_LANG[francLang]) !== null && _LANG_MAP_TO_HYPHEN_L !== void 0 ? _LANG_MAP_TO_HYPHEN_L : "unknown";
|
|
18274
18284
|
this._detectCache.set(text, lang);
|
|
18275
18285
|
return lang;
|
|
18276
18286
|
}
|
|
@@ -18282,6 +18292,16 @@ _defineProperty(LanguageDetector, "_instance", null);
|
|
|
18282
18292
|
|
|
18283
18293
|
//#endregion
|
|
18284
18294
|
//#region src/components/docs/layout/doc-skeleton.ts
|
|
18295
|
+
function getEffectiveSectionType(sectionType) {
|
|
18296
|
+
return sectionType == null || sectionType === SectionType.SECTION_TYPE_UNSPECIFIED ? SectionType.NEXT_PAGE : sectionType;
|
|
18297
|
+
}
|
|
18298
|
+
function hasCompatiblePageGeometry(page, config) {
|
|
18299
|
+
const { pageSize, pageOrient, marginTop, marginBottom, marginLeft, marginRight } = config;
|
|
18300
|
+
return page.pageWidth === (pageSize === null || pageSize === void 0 ? void 0 : pageSize.width) && page.pageHeight === (pageSize === null || pageSize === void 0 ? void 0 : pageSize.height) && page.pageOrient === pageOrient && page.originMarginTop === marginTop && page.originMarginBottom === marginBottom && page.marginLeft === marginLeft && page.marginRight === marginRight;
|
|
18301
|
+
}
|
|
18302
|
+
function isTargetPageParity(pageNumber, sectionType) {
|
|
18303
|
+
return sectionType === SectionType.EVEN_PAGE ? pageNumber % 2 === 0 : pageNumber % 2 === 1;
|
|
18304
|
+
}
|
|
18285
18305
|
function removeDupPages(ctx) {
|
|
18286
18306
|
const hash = /* @__PURE__ */ new Set();
|
|
18287
18307
|
ctx.skeleton.pages = ctx.skeleton.pages.filter((page) => {
|
|
@@ -18422,6 +18442,7 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
18422
18442
|
_defineProperty(this, "_languageDetector", LanguageDetector.getInstance());
|
|
18423
18443
|
_defineProperty(this, "_iteratorCount", 0);
|
|
18424
18444
|
_defineProperty(this, "_initialWidth", 0);
|
|
18445
|
+
_defineProperty(this, "_paginationMetrics", null);
|
|
18425
18446
|
}
|
|
18426
18447
|
static create(docViewModel, localeService) {
|
|
18427
18448
|
return new DocumentSkeleton(docViewModel, localeService);
|
|
@@ -18441,14 +18462,23 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
18441
18462
|
* PS: This method has significant impact on performance.
|
|
18442
18463
|
*/
|
|
18443
18464
|
calculate(bounds) {
|
|
18465
|
+
var _ctx$paginationMetric;
|
|
18444
18466
|
if (!this.dirty) return;
|
|
18445
18467
|
const ctx = this._prepareLayoutContext();
|
|
18446
18468
|
this._skeletonData = this._createSkeleton(ctx, bounds);
|
|
18469
|
+
this._paginationMetrics = (_ctx$paginationMetric = ctx.paginationMetrics) !== null && _ctx$paginationMetric !== void 0 ? _ctx$paginationMetric : null;
|
|
18447
18470
|
this._dirty$.next(true);
|
|
18448
18471
|
}
|
|
18449
18472
|
getSkeletonData() {
|
|
18450
18473
|
return this._skeletonData;
|
|
18451
18474
|
}
|
|
18475
|
+
/**
|
|
18476
|
+
* Returns a cloned snapshot of the most recent layout's bounded pagination counters.
|
|
18477
|
+
* These diagnostics describe renderer work and are not part of the document model.
|
|
18478
|
+
*/
|
|
18479
|
+
getPaginationMetrics() {
|
|
18480
|
+
return this._paginationMetrics == null ? null : { ...this._paginationMetrics };
|
|
18481
|
+
}
|
|
18452
18482
|
resetInitialWidth() {
|
|
18453
18483
|
this._initialWidth = 0;
|
|
18454
18484
|
}
|
|
@@ -18990,6 +19020,15 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
18990
19020
|
paragraphConfigCache: /* @__PURE__ */ new Map(),
|
|
18991
19021
|
sectionBreakConfigCache: /* @__PURE__ */ new Map(),
|
|
18992
19022
|
paragraphsOpenNewPage: /* @__PURE__ */ new Set(),
|
|
19023
|
+
paginationMetrics: {
|
|
19024
|
+
constrainedParagraphs: 0,
|
|
19025
|
+
noConstraintParagraphs: 0,
|
|
19026
|
+
measuredLineCount: 0,
|
|
19027
|
+
retryCount: 0,
|
|
19028
|
+
movedLineCount: 0,
|
|
19029
|
+
keepNextScanCount: 0,
|
|
19030
|
+
peakCheckpointLineCount: 0
|
|
19031
|
+
},
|
|
18993
19032
|
hyphen: this._hyphen,
|
|
18994
19033
|
languageDetector: this._languageDetector
|
|
18995
19034
|
};
|
|
@@ -19035,26 +19074,40 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
19035
19074
|
}
|
|
19036
19075
|
}
|
|
19037
19076
|
for (let i = startSectionIndex, len = viewModel.getChildren().length; i < len; i++) {
|
|
19077
|
+
var _viewModel$getSection;
|
|
19038
19078
|
const sectionNode = viewModel.getChildren()[i];
|
|
19039
19079
|
const sectionBreakConfig = prepareSectionBreakConfig(ctx, i);
|
|
19040
19080
|
const { sectionType, columnProperties, columnSeparatorType, sectionTypeNext, pageNumberStart = 1 } = sectionBreakConfig;
|
|
19081
|
+
const explicitPageNumberStart = (_viewModel$getSection = viewModel.getSectionBreak(sectionNode.endIndex)) === null || _viewModel$getSection === void 0 ? void 0 : _viewModel$getSection.pageNumberStart;
|
|
19082
|
+
const effectiveSectionType = getEffectiveSectionType(sectionType);
|
|
19041
19083
|
let curSkeletonPage = getLastPage(allSkeletonPages);
|
|
19042
|
-
let
|
|
19084
|
+
let reuseCurrentPage = false;
|
|
19085
|
+
let reuseNextColumn = false;
|
|
19043
19086
|
ctx.sectionBreakConfigCache.set(sectionNode.endIndex, sectionBreakConfig);
|
|
19044
|
-
if (
|
|
19087
|
+
if (effectiveSectionType === SectionType.NEXT_COLUMN && layoutAnchor == null && curSkeletonPage != null && hasCompatiblePageGeometry(curSkeletonPage, sectionBreakConfig)) {
|
|
19088
|
+
updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
|
|
19089
|
+
reuseNextColumn = this._addNewSectionByNextColumn(curSkeletonPage, columnProperties, columnSeparatorType);
|
|
19090
|
+
}
|
|
19091
|
+
if (effectiveSectionType === SectionType.CONTINUOUS && curSkeletonPage != null && hasCompatiblePageGeometry(curSkeletonPage, sectionBreakConfig)) {
|
|
19045
19092
|
updateBlockIndex(allSkeletonPages, -1, ctx.docsConfig.documentCompatibilityPolicy);
|
|
19046
19093
|
if (layoutAnchor != null && layoutAnchor >= sectionNode.startIndex && layoutAnchor <= sectionNode.endIndex) this._restoreContinuousSection(curSkeletonPage, columnProperties, columnSeparatorType);
|
|
19047
19094
|
else this._addNewSectionByContinuous(curSkeletonPage, columnProperties, columnSeparatorType);
|
|
19048
|
-
|
|
19049
|
-
} else if (
|
|
19050
|
-
|
|
19051
|
-
|
|
19095
|
+
reuseCurrentPage = true;
|
|
19096
|
+
} else if (reuseNextColumn) reuseCurrentPage = true;
|
|
19097
|
+
else if (layoutAnchor == null || curSkeletonPage == null) {
|
|
19098
|
+
let nextPageNumber = curSkeletonPage == null ? pageNumberStart : explicitPageNumberStart !== null && explicitPageNumberStart !== void 0 ? explicitPageNumberStart : curSkeletonPage.pageNumber + 1;
|
|
19099
|
+
if (curSkeletonPage != null && (effectiveSectionType === SectionType.EVEN_PAGE || effectiveSectionType === SectionType.ODD_PAGE) && !isTargetPageParity(nextPageNumber, effectiveSectionType)) {
|
|
19100
|
+
const fillerPage = createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, nextPageNumber);
|
|
19101
|
+
allSkeletonPages.push(fillerPage);
|
|
19102
|
+
nextPageNumber++;
|
|
19103
|
+
}
|
|
19104
|
+
curSkeletonPage = createSkeletonPage(ctx, sectionBreakConfig, skeletonResourceReference, nextPageNumber);
|
|
19052
19105
|
}
|
|
19053
19106
|
const { pages } = dealWithSection(ctx, viewModel, sectionNode, curSkeletonPage, sectionBreakConfig, layoutAnchor);
|
|
19054
19107
|
if (sectionTypeNext === SectionType.CONTINUOUS && columnProperties.length > 0) {}
|
|
19055
|
-
if (
|
|
19056
|
-
const
|
|
19057
|
-
if (
|
|
19108
|
+
if (reuseCurrentPage) {
|
|
19109
|
+
const reusedFirstPage = pages.shift();
|
|
19110
|
+
if (reusedFirstPage && allSkeletonPages.length > 0) allSkeletonPages[allSkeletonPages.length - 1] = reusedFirstPage;
|
|
19058
19111
|
}
|
|
19059
19112
|
allSkeletonPages.push(...pages);
|
|
19060
19113
|
if (ctx.isDirty) break;
|
|
@@ -19086,6 +19139,21 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
19086
19139
|
newSection.parent = curSkeletonPage;
|
|
19087
19140
|
sections.push(newSection);
|
|
19088
19141
|
}
|
|
19142
|
+
_addNewSectionByNextColumn(curSkeletonPage, columnProperties, columnSeparatorType) {
|
|
19143
|
+
var _curSkeletonPage$sect, _curSkeletonPage$sect2;
|
|
19144
|
+
const currentColumn = getLastNotFullColumnInfo(curSkeletonPage);
|
|
19145
|
+
const nextColumnIndex = currentColumn == null ? 0 : currentColumn.index + 1;
|
|
19146
|
+
if (nextColumnIndex >= (columnProperties.length || 1)) return false;
|
|
19147
|
+
const { pageWidth, pageHeight, marginTop, marginBottom, marginLeft, marginRight } = curSkeletonPage;
|
|
19148
|
+
const sectionTop = (_curSkeletonPage$sect = (_curSkeletonPage$sect2 = curSkeletonPage.sections.at(-1)) === null || _curSkeletonPage$sect2 === void 0 ? void 0 : _curSkeletonPage$sect2.top) !== null && _curSkeletonPage$sect !== void 0 ? _curSkeletonPage$sect : 0;
|
|
19149
|
+
const newSection = createSkeletonSection(columnProperties, columnSeparatorType, sectionTop, 0, pageWidth - marginLeft - marginRight, pageHeight - marginTop - marginBottom - sectionTop);
|
|
19150
|
+
newSection.columns.slice(0, nextColumnIndex).forEach((column) => {
|
|
19151
|
+
column.isFull = true;
|
|
19152
|
+
});
|
|
19153
|
+
newSection.parent = curSkeletonPage;
|
|
19154
|
+
curSkeletonPage.sections.push(newSection);
|
|
19155
|
+
return true;
|
|
19156
|
+
}
|
|
19089
19157
|
_restoreContinuousSection(curSkeletonPage, columnProperties, columnSeparatorType) {
|
|
19090
19158
|
const section = curSkeletonPage.sections[curSkeletonPage.sections.length - 1];
|
|
19091
19159
|
if (section == null) return;
|
|
@@ -19174,89 +19242,12 @@ var DocumentSkeleton = class DocumentSkeleton extends Skeleton {
|
|
|
19174
19242
|
...boundary
|
|
19175
19243
|
};
|
|
19176
19244
|
}
|
|
19177
|
-
}
|
|
19178
|
-
}
|
|
19179
|
-
};
|
|
19180
|
-
|
|
19181
|
-
//#endregion
|
|
19182
|
-
//#region src/components/sheets/util.ts
|
|
19183
|
-
function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
19184
|
-
const contentLength = content.length;
|
|
19185
|
-
const { textRotation, paddingData, horizontalAlign = HorizontalAlign.UNSPECIFIED, verticalAlign = VerticalAlign.UNSPECIFIED, wrapStrategy = WrapStrategy.UNSPECIFIED, cellValueType } = config;
|
|
19186
|
-
const { t: marginTop, r: marginRight, b: marginBottom, l: marginLeft } = paddingData || DEFAULT_PADDING_DATA;
|
|
19187
|
-
const { vertexAngle, centerAngle } = convertTextRotation(textRotation);
|
|
19188
|
-
return new DocumentDataModel({
|
|
19189
|
-
id: "d",
|
|
19190
|
-
body: {
|
|
19191
|
-
dataStream: `${content}${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
|
|
19192
|
-
textRuns: [{
|
|
19193
|
-
ts: textStyle,
|
|
19194
|
-
st: 0,
|
|
19195
|
-
ed: contentLength
|
|
19196
|
-
}],
|
|
19197
|
-
paragraphs: [{
|
|
19198
|
-
startIndex: contentLength,
|
|
19199
|
-
paragraphId: createParagraphId(/* @__PURE__ */ new Set()),
|
|
19200
|
-
paragraphStyle: { horizontalAlign }
|
|
19201
|
-
}],
|
|
19202
|
-
sectionBreaks: [{
|
|
19203
|
-
sectionId: createSectionId(/* @__PURE__ */ new Set()),
|
|
19204
|
-
startIndex: contentLength + 1
|
|
19205
|
-
}]
|
|
19206
|
-
},
|
|
19207
|
-
documentStyle: {
|
|
19208
|
-
pageSize: {
|
|
19209
|
-
width: Number.POSITIVE_INFINITY,
|
|
19210
|
-
height: Number.POSITIVE_INFINITY
|
|
19211
|
-
},
|
|
19212
|
-
documentFlavor: DocumentFlavor.UNSPECIFIED,
|
|
19213
|
-
marginTop,
|
|
19214
|
-
marginBottom,
|
|
19215
|
-
marginRight,
|
|
19216
|
-
marginLeft,
|
|
19217
|
-
paragraphLineGapDefault: 0,
|
|
19218
|
-
renderConfig: {
|
|
19219
|
-
horizontalAlign,
|
|
19220
|
-
verticalAlign,
|
|
19221
|
-
centerAngle,
|
|
19222
|
-
vertexAngle,
|
|
19223
|
-
wrapStrategy,
|
|
19224
|
-
cellValueType
|
|
19225
|
-
}
|
|
19226
|
-
},
|
|
19227
|
-
drawings: {},
|
|
19228
|
-
drawingsOrder: []
|
|
19229
|
-
});
|
|
19230
|
-
}
|
|
19231
|
-
function extractOtherStyle(style) {
|
|
19232
|
-
if (!style) return {};
|
|
19233
|
-
const { tr: textRotation, td: textDirection, ht: horizontalAlign, vt: verticalAlign, tb: wrapStrategy, pd: paddingData } = style;
|
|
19234
|
-
return {
|
|
19235
|
-
textRotation,
|
|
19236
|
-
textDirection,
|
|
19237
|
-
horizontalAlign,
|
|
19238
|
-
verticalAlign,
|
|
19239
|
-
wrapStrategy,
|
|
19240
|
-
paddingData
|
|
19241
|
-
};
|
|
19242
|
-
}
|
|
19243
|
-
function getFontFormat(format) {
|
|
19244
|
-
if (!format) return {};
|
|
19245
|
-
const { ff, fs, it, bl, ul, st, ol, cl } = format;
|
|
19246
|
-
const style = {};
|
|
19247
|
-
ff && (style.ff = ff);
|
|
19248
|
-
fs && (style.fs = fs);
|
|
19249
|
-
it && (style.it = it);
|
|
19250
|
-
bl && (style.bl = bl);
|
|
19251
|
-
ul && (style.ul = ul);
|
|
19252
|
-
st && (style.st = st);
|
|
19253
|
-
ol && (style.ol = ol);
|
|
19254
|
-
cl && (style.cl = cl);
|
|
19255
|
-
return style;
|
|
19256
|
-
}
|
|
19245
|
+
}
|
|
19246
|
+
}
|
|
19247
|
+
};
|
|
19257
19248
|
|
|
19258
19249
|
//#endregion
|
|
19259
|
-
//#region \0@oxc-project+runtime@0.
|
|
19250
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
19260
19251
|
function __decorateParam(paramIndex, decorator) {
|
|
19261
19252
|
return function(target, key) {
|
|
19262
19253
|
decorator(target, key, paramIndex);
|
|
@@ -19264,7 +19255,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
19264
19255
|
}
|
|
19265
19256
|
|
|
19266
19257
|
//#endregion
|
|
19267
|
-
//#region \0@oxc-project+runtime@0.
|
|
19258
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
19268
19259
|
function __decorate(decorators, target, key, desc) {
|
|
19269
19260
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19270
19261
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -19274,11 +19265,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
19274
19265
|
|
|
19275
19266
|
//#endregion
|
|
19276
19267
|
//#region src/components/sheets/sheet.render-skeleton.ts
|
|
19277
|
-
const DEFAULT_CELL_DOCUMENT_MODEL_OPTION = {
|
|
19278
|
-
isDeepClone: false,
|
|
19279
|
-
displayRawFormula: false,
|
|
19280
|
-
ignoreTextRotation: false
|
|
19281
|
-
};
|
|
19282
19268
|
const DEFAULT_PADDING_DATA = {
|
|
19283
19269
|
t: 0,
|
|
19284
19270
|
b: 2,
|
|
@@ -19437,12 +19423,6 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
19437
19423
|
this._handleBorderMatrix.reset();
|
|
19438
19424
|
this._overflowCache.reset();
|
|
19439
19425
|
}
|
|
19440
|
-
/**
|
|
19441
|
-
* @deprecated should never expose a property that is provided by another module!
|
|
19442
|
-
*/
|
|
19443
|
-
getStyles() {
|
|
19444
|
-
return this._styles;
|
|
19445
|
-
}
|
|
19446
19426
|
setOverflowCache(value) {
|
|
19447
19427
|
this._overflowCache = value;
|
|
19448
19428
|
}
|
|
@@ -19843,13 +19823,6 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
19843
19823
|
}
|
|
19844
19824
|
return measuredWidth;
|
|
19845
19825
|
}
|
|
19846
|
-
/**
|
|
19847
|
-
* @deprecated use `getRangeByViewport` instead.
|
|
19848
|
-
* @param bounds
|
|
19849
|
-
*/
|
|
19850
|
-
getRangeByBounding(bounds) {
|
|
19851
|
-
return this._getRangeByViewBounding(this.rowHeightAccumulation, this.columnWidthAccumulation, bounds === null || bounds === void 0 ? void 0 : bounds.cacheBound);
|
|
19852
|
-
}
|
|
19853
19826
|
getRangeByViewport(vpInfo) {
|
|
19854
19827
|
return this._getRangeByViewBounding(this.rowHeightAccumulation, this.columnWidthAccumulation, vpInfo === null || vpInfo === void 0 ? void 0 : vpInfo.viewBound);
|
|
19855
19828
|
}
|
|
@@ -19898,171 +19871,10 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
19898
19871
|
const cachedAdjacentCell = (_this$_stylesCache$fo = this._stylesCache.fontMatrix.getValue(row, adjacentColumn)) === null || _this$_stylesCache$fo === void 0 ? void 0 : _this$_stylesCache$fo.cellData;
|
|
19899
19872
|
return !isCellCoverable(cachedAdjacentCell !== null && cachedAdjacentCell !== void 0 ? cachedAdjacentCell : this.worksheet.getCell(row, adjacentColumn)) || hasMergeData && this.intersectMergeRange(row, adjacentColumn);
|
|
19900
19873
|
}
|
|
19901
|
-
/**
|
|
19902
|
-
* Get cell by pos(offsetX, offsetY).
|
|
19903
|
-
* @deprecated Please use `getCellWithCoordByOffset` instead.
|
|
19904
|
-
*/
|
|
19905
|
-
calculateCellIndexByPosition(offsetX, offsetY, scaleX, scaleY, scrollXY) {
|
|
19906
|
-
return this.getCellWithCoordByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY);
|
|
19907
|
-
}
|
|
19908
|
-
/**
|
|
19909
|
-
* This method has the same implementation as `getCellIndexByOffset`,
|
|
19910
|
-
* but uses a different name to maintain backward compatibility with previous calls.
|
|
19911
|
-
*
|
|
19912
|
-
* @deprecated Please use `getCellIndexByOffset` method instead.
|
|
19913
|
-
*/
|
|
19914
|
-
getCellPositionByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY, options) {
|
|
19915
|
-
return this.getCellIndexByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY, options);
|
|
19916
|
-
}
|
|
19917
19874
|
getCellWithMergeInfoByIndex(row, column) {
|
|
19918
19875
|
return this.worksheet.getCellInfoInMergeData(row, column);
|
|
19919
19876
|
}
|
|
19920
19877
|
/**
|
|
19921
|
-
* Same as getColumnIndexByOffsetX
|
|
19922
|
-
* @deprecated Please use `getColumnIndexByOffsetX` method instead.
|
|
19923
|
-
*/
|
|
19924
|
-
getColumnPositionByOffsetX(offsetX, scaleX, scrollXY, options) {
|
|
19925
|
-
return this.getColumnIndexByOffsetX(offsetX, scaleX, scrollXY, options);
|
|
19926
|
-
}
|
|
19927
|
-
/**
|
|
19928
|
-
* Same as getRowIndexByOffsetY
|
|
19929
|
-
* @deprecated Please use `getRowIndexByOffsetY` method instead.
|
|
19930
|
-
*/
|
|
19931
|
-
getRowPositionByOffsetY(offsetY, scaleY, scrollXY, options) {
|
|
19932
|
-
return this.getRowIndexByOffsetY(offsetY, scaleY, scrollXY, options);
|
|
19933
|
-
}
|
|
19934
|
-
/**
|
|
19935
|
-
* Same as getCellWithCoordByIndex, but uses a different name to maintain backward compatibility with previous calls.
|
|
19936
|
-
* @deprecated Please use `getCellWithCoordByIndex` instead.
|
|
19937
|
-
*/
|
|
19938
|
-
getCellByIndex(row, column) {
|
|
19939
|
-
return this.getCellWithCoordByIndex(row, column);
|
|
19940
|
-
}
|
|
19941
|
-
/**
|
|
19942
|
-
* @deprecated Please use `getCellWithCoordByIndex(row, col, false)` instead.
|
|
19943
|
-
* @param row
|
|
19944
|
-
* @param column
|
|
19945
|
-
*/
|
|
19946
|
-
getCellByIndexWithNoHeader(row, column) {
|
|
19947
|
-
return this.getCellWithCoordByIndex(row, column, false);
|
|
19948
|
-
}
|
|
19949
|
-
/**
|
|
19950
|
-
* Only used for cell edit, and no need to rotate text when edit cell content!
|
|
19951
|
-
* @deprecated use same method in worksheet.
|
|
19952
|
-
* @param cell
|
|
19953
|
-
*/
|
|
19954
|
-
getBlankCellDocumentModel(cell) {
|
|
19955
|
-
const documentModelObject = this._getCellDocumentModel(cell, { ignoreTextRotation: true });
|
|
19956
|
-
const textStyle = getFontFormat(this._styles.getStyleByCell(cell));
|
|
19957
|
-
if (documentModelObject != null) {
|
|
19958
|
-
if (documentModelObject.documentModel == null) documentModelObject.documentModel = createDocumentModelWithStyle("", textStyle);
|
|
19959
|
-
return documentModelObject;
|
|
19960
|
-
}
|
|
19961
|
-
const content = "";
|
|
19962
|
-
let fontString = "document";
|
|
19963
|
-
const textRotation = DEFAULT_STYLES.tr;
|
|
19964
|
-
const horizontalAlign = DEFAULT_STYLES.ht;
|
|
19965
|
-
const verticalAlign = DEFAULT_STYLES.vt;
|
|
19966
|
-
const wrapStrategy = DEFAULT_STYLES.tb;
|
|
19967
|
-
const paddingData = DEFAULT_PADDING_DATA;
|
|
19968
|
-
fontString = getFontStyleString({}).fontCache;
|
|
19969
|
-
return {
|
|
19970
|
-
documentModel: createDocumentModelWithStyle(content, textStyle),
|
|
19971
|
-
fontString,
|
|
19972
|
-
textRotation,
|
|
19973
|
-
wrapStrategy,
|
|
19974
|
-
verticalAlign,
|
|
19975
|
-
horizontalAlign,
|
|
19976
|
-
paddingData
|
|
19977
|
-
};
|
|
19978
|
-
}
|
|
19979
|
-
/**
|
|
19980
|
-
* Only used for cell edit, and no need to rotate text when edit cell content!
|
|
19981
|
-
* @deprecated use same method in worksheet.
|
|
19982
|
-
* @param cell
|
|
19983
|
-
*/
|
|
19984
|
-
getCellDocumentModelWithFormula(cell) {
|
|
19985
|
-
return this._getCellDocumentModel(cell, {
|
|
19986
|
-
isDeepClone: true,
|
|
19987
|
-
displayRawFormula: true,
|
|
19988
|
-
ignoreTextRotation: true
|
|
19989
|
-
});
|
|
19990
|
-
}
|
|
19991
|
-
/**
|
|
19992
|
-
* This method generates a document model based on the cell's properties and handles the associated styles and configurations.
|
|
19993
|
-
* If the cell does not exist, it will return null.
|
|
19994
|
-
*
|
|
19995
|
-
* @deprecated use same method in worksheet.
|
|
19996
|
-
* PS: This method has significant impact on performance.
|
|
19997
|
-
* @param cell
|
|
19998
|
-
* @param options
|
|
19999
|
-
*/
|
|
20000
|
-
_getCellDocumentModel(cell, options = DEFAULT_CELL_DOCUMENT_MODEL_OPTION) {
|
|
20001
|
-
var _style$bg;
|
|
20002
|
-
const { isDeepClone, displayRawFormula, ignoreTextRotation } = {
|
|
20003
|
-
...DEFAULT_CELL_DOCUMENT_MODEL_OPTION,
|
|
20004
|
-
...options
|
|
20005
|
-
};
|
|
20006
|
-
const style = this._styles.getStyleByCell(cell);
|
|
20007
|
-
if (!cell) return;
|
|
20008
|
-
let documentModel;
|
|
20009
|
-
let fontString = "document";
|
|
20010
|
-
const cellOtherConfig = extractOtherStyle(style);
|
|
20011
|
-
const textRotation = ignoreTextRotation ? DEFAULT_STYLES.tr : cellOtherConfig.textRotation || DEFAULT_STYLES.tr;
|
|
20012
|
-
let horizontalAlign = cellOtherConfig.horizontalAlign || DEFAULT_STYLES.ht;
|
|
20013
|
-
const verticalAlign = cellOtherConfig.verticalAlign || DEFAULT_STYLES.vt;
|
|
20014
|
-
const wrapStrategy = cellOtherConfig.wrapStrategy || DEFAULT_STYLES.tb;
|
|
20015
|
-
const paddingData = cellOtherConfig.paddingData || DEFAULT_PADDING_DATA;
|
|
20016
|
-
if (cell.f && displayRawFormula) {
|
|
20017
|
-
documentModel = createDocumentModelWithStyle(cell.f.toString(), {}, { verticalAlign });
|
|
20018
|
-
horizontalAlign = DEFAULT_STYLES.ht;
|
|
20019
|
-
} else if (cell.p) {
|
|
20020
|
-
const { centerAngle, vertexAngle } = convertTextRotation(textRotation);
|
|
20021
|
-
documentModel = this._updateConfigAndGetDocumentModel(isDeepClone ? Tools.deepClone(cell.p) : cell.p, horizontalAlign, paddingData, {
|
|
20022
|
-
horizontalAlign,
|
|
20023
|
-
verticalAlign,
|
|
20024
|
-
centerAngle,
|
|
20025
|
-
vertexAngle,
|
|
20026
|
-
wrapStrategy,
|
|
20027
|
-
zeroWidthParagraphBreak: 1
|
|
20028
|
-
});
|
|
20029
|
-
} else if (cell.v != null) {
|
|
20030
|
-
const textStyle = getFontFormat(style);
|
|
20031
|
-
fontString = getFontStyleString(textStyle).fontCache;
|
|
20032
|
-
let cellText = extractPureTextFromCell(cell);
|
|
20033
|
-
if (cell.t === CellValueType.FORCE_STRING && displayRawFormula) cellText = `'${cellText}`;
|
|
20034
|
-
documentModel = createDocumentModelWithStyle(cellText, textStyle, {
|
|
20035
|
-
...cellOtherConfig,
|
|
20036
|
-
textRotation,
|
|
20037
|
-
cellValueType: cell.t
|
|
20038
|
-
});
|
|
20039
|
-
}
|
|
20040
|
-
if (documentModel && cell.linkUrl && cell.linkId) addLinkToDocumentModel(documentModel, cell.linkUrl, cell.linkId);
|
|
20041
|
-
/**
|
|
20042
|
-
* the alignment mode is returned with respect to the offset of the sheet cell,
|
|
20043
|
-
* because the document needs to render the layout for cells and
|
|
20044
|
-
* support alignment across multiple cells (e.g., horizontal alignment of long text in overflow mode).
|
|
20045
|
-
* The alignment mode of the document itself cannot meet this requirement,
|
|
20046
|
-
* so an additional renderConfig needs to be added during the rendering of the document component.
|
|
20047
|
-
* This means that there are two coexisting alignment modes.
|
|
20048
|
-
* In certain cases, such as in an editor, conflicts may arise,
|
|
20049
|
-
* requiring only one alignment mode to be retained.
|
|
20050
|
-
* By removing the relevant configurations in renderConfig,
|
|
20051
|
-
* the alignment mode of the sheet cell can be modified.
|
|
20052
|
-
* The alternative alignment mode is applied to paragraphs within the document.
|
|
20053
|
-
*/
|
|
20054
|
-
return {
|
|
20055
|
-
documentModel,
|
|
20056
|
-
fontString,
|
|
20057
|
-
textRotation,
|
|
20058
|
-
wrapStrategy,
|
|
20059
|
-
verticalAlign,
|
|
20060
|
-
horizontalAlign,
|
|
20061
|
-
paddingData,
|
|
20062
|
-
fill: style === null || style === void 0 || (_style$bg = style.bg) === null || _style$bg === void 0 ? void 0 : _style$bg.rgb
|
|
20063
|
-
};
|
|
20064
|
-
}
|
|
20065
|
-
/**
|
|
20066
19878
|
* Calculate the overflow of cell text. If there is no value on either side of the cell,
|
|
20067
19879
|
* the text content of this cell can be drawn to both sides, not limited by the cell's width.
|
|
20068
19880
|
* Overflow on the left or right is aligned according to the text's horizontal alignment.
|
|
@@ -20518,20 +20330,6 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
20518
20330
|
for (let i = range.startColumn; i <= range.endColumn; i++) if (!this.worksheet.getColVisible(i)) hiddenCols.push(i);
|
|
20519
20331
|
return hiddenCols;
|
|
20520
20332
|
}
|
|
20521
|
-
/**
|
|
20522
|
-
* @deprecated use function `convertTransformToOffsetX` in same package.
|
|
20523
|
-
*/
|
|
20524
|
-
convertTransformToOffsetX(offsetX, scaleX, scrollXY) {
|
|
20525
|
-
const { x: scrollX } = scrollXY;
|
|
20526
|
-
return (offsetX - scrollX) * scaleX;
|
|
20527
|
-
}
|
|
20528
|
-
/**
|
|
20529
|
-
* @deprecated use function `convertTransformToOffsetY` in same package.
|
|
20530
|
-
*/
|
|
20531
|
-
convertTransformToOffsetY(offsetY, scaleY, scrollXY) {
|
|
20532
|
-
const { y: scrollY } = scrollXY;
|
|
20533
|
-
return (offsetY - scrollY) * scaleY;
|
|
20534
|
-
}
|
|
20535
20333
|
};
|
|
20536
20334
|
SpreadsheetSkeleton = __decorate([
|
|
20537
20335
|
__decorateParam(2, Inject(LocaleService)),
|
|
@@ -20704,7 +20502,8 @@ var Font = class extends SheetExtension {
|
|
|
20704
20502
|
uniqueMergeRanges.forEach((range) => {
|
|
20705
20503
|
const fontCache = fontMatrix.getValue(range.startRow, range.startColumn);
|
|
20706
20504
|
if (!fontCache) return;
|
|
20707
|
-
|
|
20505
|
+
const cellInfo = spreadsheetSkeleton.getCellWithCoordByIndex(range.startRow, range.startColumn, false);
|
|
20506
|
+
renderFontContext.cellInfo = cellInfo;
|
|
20708
20507
|
this._renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix, fontCache);
|
|
20709
20508
|
});
|
|
20710
20509
|
ctx.restore();
|
|
@@ -22200,6 +21999,145 @@ var Image$1 = class extends Shape {
|
|
|
22200
21999
|
}
|
|
22201
22000
|
};
|
|
22202
22001
|
|
|
22002
|
+
//#endregion
|
|
22003
|
+
//#region src/shape/line.ts
|
|
22004
|
+
function normalizeLinePosition(position) {
|
|
22005
|
+
const left = Math.min(position.startX, position.endX);
|
|
22006
|
+
const top = Math.min(position.startY, position.endY);
|
|
22007
|
+
return {
|
|
22008
|
+
left,
|
|
22009
|
+
top,
|
|
22010
|
+
width: Math.abs(position.endX - position.startX),
|
|
22011
|
+
height: Math.abs(position.endY - position.startY),
|
|
22012
|
+
startX: position.startX - left,
|
|
22013
|
+
startY: position.startY - top,
|
|
22014
|
+
endX: position.endX - left,
|
|
22015
|
+
endY: position.endY - top
|
|
22016
|
+
};
|
|
22017
|
+
}
|
|
22018
|
+
/**
|
|
22019
|
+
* A line segment defined by two endpoints in its parent's coordinate system.
|
|
22020
|
+
*
|
|
22021
|
+
* The BaseObject bounds are derived internally so callers only describe line geometry.
|
|
22022
|
+
*/
|
|
22023
|
+
var Line = class Line extends Shape {
|
|
22024
|
+
constructor(key, props) {
|
|
22025
|
+
var _props$startX, _props$startY, _props$endX, _props$endY;
|
|
22026
|
+
const position = {
|
|
22027
|
+
startX: (_props$startX = props === null || props === void 0 ? void 0 : props.startX) !== null && _props$startX !== void 0 ? _props$startX : 0,
|
|
22028
|
+
startY: (_props$startY = props === null || props === void 0 ? void 0 : props.startY) !== null && _props$startY !== void 0 ? _props$startY : 0,
|
|
22029
|
+
endX: (_props$endX = props === null || props === void 0 ? void 0 : props.endX) !== null && _props$endX !== void 0 ? _props$endX : 0,
|
|
22030
|
+
endY: (_props$endY = props === null || props === void 0 ? void 0 : props.endY) !== null && _props$endY !== void 0 ? _props$endY : 0
|
|
22031
|
+
};
|
|
22032
|
+
const geometry = normalizeLinePosition(position);
|
|
22033
|
+
const normalizedProps = {
|
|
22034
|
+
...props !== null && props !== void 0 ? props : position,
|
|
22035
|
+
left: geometry.left,
|
|
22036
|
+
top: geometry.top,
|
|
22037
|
+
width: geometry.width,
|
|
22038
|
+
height: geometry.height
|
|
22039
|
+
};
|
|
22040
|
+
super(key, normalizedProps);
|
|
22041
|
+
_defineProperty(this, "_startX", 0);
|
|
22042
|
+
_defineProperty(this, "_startY", 0);
|
|
22043
|
+
_defineProperty(this, "_endX", 0);
|
|
22044
|
+
_defineProperty(this, "_endY", 0);
|
|
22045
|
+
this._startX = geometry.startX;
|
|
22046
|
+
this._startY = geometry.startY;
|
|
22047
|
+
this._endX = geometry.endX;
|
|
22048
|
+
this._endY = geometry.endY;
|
|
22049
|
+
}
|
|
22050
|
+
get startX() {
|
|
22051
|
+
return this.left + this._startX;
|
|
22052
|
+
}
|
|
22053
|
+
get startY() {
|
|
22054
|
+
return this.top + this._startY;
|
|
22055
|
+
}
|
|
22056
|
+
get endX() {
|
|
22057
|
+
return this.left + this._endX;
|
|
22058
|
+
}
|
|
22059
|
+
get endY() {
|
|
22060
|
+
return this.top + this._endY;
|
|
22061
|
+
}
|
|
22062
|
+
static drawWith(ctx, props) {
|
|
22063
|
+
Line._drawSegment(ctx, props.startX, props.startY, props.endX, props.endY, props);
|
|
22064
|
+
}
|
|
22065
|
+
setPoints(position) {
|
|
22066
|
+
const geometry = normalizeLinePosition(position);
|
|
22067
|
+
this._startX = geometry.startX;
|
|
22068
|
+
this._startY = geometry.startY;
|
|
22069
|
+
this._endX = geometry.endX;
|
|
22070
|
+
this._endY = geometry.endY;
|
|
22071
|
+
this.transformByState({
|
|
22072
|
+
left: geometry.left,
|
|
22073
|
+
top: geometry.top,
|
|
22074
|
+
width: geometry.width,
|
|
22075
|
+
height: geometry.height
|
|
22076
|
+
});
|
|
22077
|
+
return this;
|
|
22078
|
+
}
|
|
22079
|
+
setProps(props) {
|
|
22080
|
+
var _props$startX2, _props$startY2, _props$endX2, _props$endY2;
|
|
22081
|
+
if (!props) return this;
|
|
22082
|
+
const position = {
|
|
22083
|
+
startX: (_props$startX2 = props.startX) !== null && _props$startX2 !== void 0 ? _props$startX2 : this.startX,
|
|
22084
|
+
startY: (_props$startY2 = props.startY) !== null && _props$startY2 !== void 0 ? _props$startY2 : this.startY,
|
|
22085
|
+
endX: (_props$endX2 = props.endX) !== null && _props$endX2 !== void 0 ? _props$endX2 : this.endX,
|
|
22086
|
+
endY: (_props$endY2 = props.endY) !== null && _props$endY2 !== void 0 ? _props$endY2 : this.endY
|
|
22087
|
+
};
|
|
22088
|
+
const lineProps = {
|
|
22089
|
+
...props,
|
|
22090
|
+
...position
|
|
22091
|
+
};
|
|
22092
|
+
super.setProps(lineProps);
|
|
22093
|
+
this.setPoints(position);
|
|
22094
|
+
return this;
|
|
22095
|
+
}
|
|
22096
|
+
isHit(coord) {
|
|
22097
|
+
const point = this.getInverseCoord(coord);
|
|
22098
|
+
const width = this._endX - this._startX;
|
|
22099
|
+
const height = this._endY - this._startY;
|
|
22100
|
+
const lengthSquared = width * width + height * height;
|
|
22101
|
+
const parsedHitStrokeWidth = typeof this.hitStrokeWidth === "number" ? this.hitStrokeWidth : Number.parseFloat(this.hitStrokeWidth);
|
|
22102
|
+
const hitStrokeWidth = Number.isFinite(parsedHitStrokeWidth) ? parsedHitStrokeWidth : 0;
|
|
22103
|
+
const tolerance = Math.max(this.strokeWidth, hitStrokeWidth) / 2;
|
|
22104
|
+
const pointX = point.x - this._startX;
|
|
22105
|
+
const pointY = point.y - this._startY;
|
|
22106
|
+
if (lengthSquared === 0) return pointX * pointX + pointY * pointY <= tolerance * tolerance;
|
|
22107
|
+
const projection = Math.max(0, Math.min(1, (pointX * width + pointY * height) / lengthSquared));
|
|
22108
|
+
const offsetX = pointX - projection * width;
|
|
22109
|
+
const offsetY = pointY - projection * height;
|
|
22110
|
+
return offsetX * offsetX + offsetY * offsetY <= tolerance * tolerance;
|
|
22111
|
+
}
|
|
22112
|
+
toJson() {
|
|
22113
|
+
const props = super.toJson();
|
|
22114
|
+
delete props.left;
|
|
22115
|
+
delete props.top;
|
|
22116
|
+
delete props.width;
|
|
22117
|
+
delete props.height;
|
|
22118
|
+
return {
|
|
22119
|
+
...props,
|
|
22120
|
+
startX: this.startX,
|
|
22121
|
+
startY: this.startY,
|
|
22122
|
+
endX: this.endX,
|
|
22123
|
+
endY: this.endY
|
|
22124
|
+
};
|
|
22125
|
+
}
|
|
22126
|
+
_draw(ctx) {
|
|
22127
|
+
Line._drawSegment(ctx, this._startX, this._startY, this._endX, this._endY, this);
|
|
22128
|
+
}
|
|
22129
|
+
static _drawSegment(ctx, startX, startY, endX, endY, props) {
|
|
22130
|
+
if (!props.stroke || props.strokeWidth === 0) return;
|
|
22131
|
+
ctx.save();
|
|
22132
|
+
ctx.beginPath();
|
|
22133
|
+
if (props.strokeDashArray) ctx.setLineDash(props.strokeDashArray);
|
|
22134
|
+
ctx.moveTo(startX, startY);
|
|
22135
|
+
ctx.lineTo(endX, endY);
|
|
22136
|
+
this._renderPaintInOrder(ctx, props);
|
|
22137
|
+
ctx.restore();
|
|
22138
|
+
}
|
|
22139
|
+
};
|
|
22140
|
+
|
|
22203
22141
|
//#endregion
|
|
22204
22142
|
//#region src/shape/path.ts
|
|
22205
22143
|
const PATH_OBJECT_ARRAY = ["dataArray"];
|
|
@@ -23803,13 +23741,28 @@ var FontAndBaseLine = class extends docExtension {
|
|
|
23803
23741
|
this.actualFontMap[fontStringPxStr] = ctx.font;
|
|
23804
23742
|
}
|
|
23805
23743
|
}
|
|
23806
|
-
const { cl: colorStyle, va: baselineOffset, textFill } = textStyle;
|
|
23744
|
+
const { cl: colorStyle, va: baselineOffset, textFill, glow, outerShadow } = textStyle;
|
|
23807
23745
|
const fontColor = getColorStyle(colorStyle) || "rgb(0,0,0)";
|
|
23808
23746
|
if (baselineOffset === BaselineOffset.SUPERSCRIPT) spanPointWithFont.y += -bBox.spo;
|
|
23809
23747
|
else if (baselineOffset === BaselineOffset.SUBSCRIPT) spanPointWithFont.y += bBox.sbo;
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
|
|
23748
|
+
const drawText = () => {
|
|
23749
|
+
if (this._fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fontColor)) return;
|
|
23750
|
+
if (fontColor && this._preFontColor !== fontColor) ctx.fillStyle = fontColor;
|
|
23751
|
+
this._fillText(ctx, glyph, spanPointWithFont);
|
|
23752
|
+
};
|
|
23753
|
+
if (!glow && !outerShadow) {
|
|
23754
|
+
drawText();
|
|
23755
|
+
return;
|
|
23756
|
+
}
|
|
23757
|
+
const effectFilter = createDrawingEffectFilter(glow, outerShadow);
|
|
23758
|
+
if (!effectFilter) {
|
|
23759
|
+
drawText();
|
|
23760
|
+
return;
|
|
23761
|
+
}
|
|
23762
|
+
ctx.save();
|
|
23763
|
+
ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
23764
|
+
drawText();
|
|
23765
|
+
ctx.restore();
|
|
23813
23766
|
}
|
|
23814
23767
|
_fillTextWithTextFill(ctx, glyph, spanPointWithFont, textFill, fallbackColor) {
|
|
23815
23768
|
if (!textFill || textFill.type === "none") return (textFill === null || textFill === void 0 ? void 0 : textFill.type) === "none";
|
|
@@ -24038,7 +23991,7 @@ DocumentsSpanAndLineExtensionRegistry.add(new FontAndBaseLine());
|
|
|
24038
23991
|
//#region src/components/docs/extensions/line.ts
|
|
24039
23992
|
const UNIQUE_KEY = "DefaultDocsLineExtension";
|
|
24040
23993
|
const DOC_EXTENSION_Z_INDEX = 40;
|
|
24041
|
-
var Line = class extends docExtension {
|
|
23994
|
+
var Line$1 = class extends docExtension {
|
|
24042
23995
|
constructor(..._args) {
|
|
24043
23996
|
super(..._args);
|
|
24044
23997
|
_defineProperty(this, "uKey", UNIQUE_KEY);
|
|
@@ -24204,12 +24157,29 @@ var Line = class extends docExtension {
|
|
|
24204
24157
|
return lineType === TextDecoration.DOUBLE || lineType === TextDecoration.WAVY_DOUBLE;
|
|
24205
24158
|
}
|
|
24206
24159
|
};
|
|
24207
|
-
DocumentsSpanAndLineExtensionRegistry.add(new Line());
|
|
24160
|
+
DocumentsSpanAndLineExtensionRegistry.add(new Line$1());
|
|
24208
24161
|
|
|
24209
24162
|
//#endregion
|
|
24210
24163
|
//#region src/components/docs/document.ts
|
|
24211
24164
|
const DEFAULT_BORDER_COLOR = { color: { rgb: "#c7c9cc" } };
|
|
24212
24165
|
const TABLE_VIEWPORT_BORDER_CLIP_PADDING = 2;
|
|
24166
|
+
const TABLE_OVERFLOW_INTERACTION_PADDING = 24;
|
|
24167
|
+
function drawSectionColumnSeparators(ctx, section, height, offsetX = 0, offsetY = 0) {
|
|
24168
|
+
if (section.columns.length < 2) return;
|
|
24169
|
+
ctx.save();
|
|
24170
|
+
ctx.strokeStyle = "#000000";
|
|
24171
|
+
ctx.setLineWidthByPrecision(1);
|
|
24172
|
+
ctx.beginPath();
|
|
24173
|
+
for (const column of section.columns.slice(0, -1)) {
|
|
24174
|
+
if (column.separator !== ColumnSeparatorType.BETWEEN_EACH_COLUMN) continue;
|
|
24175
|
+
const separatorX = offsetX + column.left + column.width + column.spaceWidth / 2;
|
|
24176
|
+
ctx.moveToByPrecision(separatorX, offsetY);
|
|
24177
|
+
ctx.lineToByPrecision(separatorX, offsetY + height);
|
|
24178
|
+
}
|
|
24179
|
+
ctx.stroke();
|
|
24180
|
+
ctx.closePath();
|
|
24181
|
+
ctx.restore();
|
|
24182
|
+
}
|
|
24213
24183
|
var Documents = class Documents extends DocComponent {
|
|
24214
24184
|
constructor(oKey, documentSkeleton, config) {
|
|
24215
24185
|
super(oKey, documentSkeleton, config);
|
|
@@ -24241,6 +24211,31 @@ var Documents = class Documents extends DocComponent {
|
|
|
24241
24211
|
getEngine() {
|
|
24242
24212
|
return this.getScene().getEngine();
|
|
24243
24213
|
}
|
|
24214
|
+
isHit(coord) {
|
|
24215
|
+
var _this$getSkeleton;
|
|
24216
|
+
if (super.isHit(coord)) return true;
|
|
24217
|
+
const skeletonData = (_this$getSkeleton = this.getSkeleton()) === null || _this$getSkeleton === void 0 ? void 0 : _this$getSkeleton.getSkeletonData();
|
|
24218
|
+
if (!skeletonData) return false;
|
|
24219
|
+
const localCoord = this.getInverseCoord(coord);
|
|
24220
|
+
const { pages, skeHeaders, skeFooters } = skeletonData;
|
|
24221
|
+
const unitId = this._getRenderUnitId();
|
|
24222
|
+
const { docsLeft } = this.getOffsetConfig();
|
|
24223
|
+
return documentSkeletonTableIterator(pages, {
|
|
24224
|
+
includeCells: false,
|
|
24225
|
+
pageMarginTop: this.pageMarginTop,
|
|
24226
|
+
resolveViewport: false,
|
|
24227
|
+
skeFooters,
|
|
24228
|
+
skeHeaders,
|
|
24229
|
+
unitId
|
|
24230
|
+
}).some(({ tableId, tableRect }) => {
|
|
24231
|
+
var _viewport$leadingInse;
|
|
24232
|
+
const sourceTableId = getTableIdAndSliceIndex(tableId).tableId;
|
|
24233
|
+
const viewport = getDocsTableRenderViewport(unitId, sourceTableId);
|
|
24234
|
+
const projectedLeft = hasDocsTableHorizontalViewport(viewport) ? getDocsTableViewportLeft(viewport, tableRect.left - ((_viewport$leadingInse = viewport.leadingInsetLeft) !== null && _viewport$leadingInse !== void 0 ? _viewport$leadingInse : 0), docsLeft) : tableRect.left;
|
|
24235
|
+
const projectedRight = hasDocsTableHorizontalViewport(viewport) ? projectedLeft + viewport.viewportWidth : tableRect.right;
|
|
24236
|
+
return localCoord.x >= projectedLeft - TABLE_OVERFLOW_INTERACTION_PADDING && localCoord.x <= projectedRight + TABLE_OVERFLOW_INTERACTION_PADDING && localCoord.y >= tableRect.top - TABLE_OVERFLOW_INTERACTION_PADDING && localCoord.y <= tableRect.bottom + TABLE_OVERFLOW_INTERACTION_PADDING;
|
|
24237
|
+
});
|
|
24238
|
+
}
|
|
24244
24239
|
changeSkeleton(newSkeleton) {
|
|
24245
24240
|
this.setSkeleton(newSkeleton);
|
|
24246
24241
|
return this;
|
|
@@ -24249,8 +24244,8 @@ var Documents = class Documents extends DocComponent {
|
|
|
24249
24244
|
this.draw(ctx, bounds);
|
|
24250
24245
|
}
|
|
24251
24246
|
draw(ctx, bounds) {
|
|
24252
|
-
var _this$
|
|
24253
|
-
const skeletonData = (_this$
|
|
24247
|
+
var _this$getSkeleton2;
|
|
24248
|
+
const skeletonData = (_this$getSkeleton2 = this.getSkeleton()) === null || _this$getSkeleton2 === void 0 ? void 0 : _this$getSkeleton2.getSkeletonData();
|
|
24254
24249
|
if (skeletonData == null || this._drawLiquid == null) return;
|
|
24255
24250
|
this._drawLiquid.reset();
|
|
24256
24251
|
const { pages, skeHeaders, skeFooters } = skeletonData;
|
|
@@ -24284,10 +24279,14 @@ var Documents = class Documents extends DocComponent {
|
|
|
24284
24279
|
const headerAlignOffsetNoAngle = Vector2.create(horizontalOffsetNoAngle, (_headerSkeletonPage$m = headerSkeletonPage === null || headerSkeletonPage === void 0 ? void 0 : headerSkeletonPage.marginTop) !== null && _headerSkeletonPage$m !== void 0 ? _headerSkeletonPage$m : 0);
|
|
24285
24280
|
if (headerSkeletonPage) this._drawHeaderFooter(headerSkeletonPage, ctx, extensions, backgroundExtension, glyphExtensionsExcludeBackground, headerAlignOffsetNoAngle, centerAngle, vertexAngle, renderConfig, parentScale, page, true);
|
|
24286
24281
|
this._startRotation(ctx, finalAngle);
|
|
24287
|
-
for (const section of sections) {
|
|
24282
|
+
for (const [sectionIndex, section] of sections.entries()) {
|
|
24283
|
+
var _sections$slice$find;
|
|
24288
24284
|
const { columns } = section;
|
|
24285
|
+
const nextSectionTop = (_sections$slice$find = sections.slice(sectionIndex + 1).find((candidate) => candidate.top > section.top)) === null || _sections$slice$find === void 0 ? void 0 : _sections$slice$find.top;
|
|
24286
|
+
const separatorHeight = Math.max(0, (nextSectionTop !== null && nextSectionTop !== void 0 ? nextSectionTop : page.pageHeight - pagePaddingTop - pagePaddingBottom) - section.top);
|
|
24289
24287
|
this._drawLiquid.translateSave();
|
|
24290
24288
|
this._drawLiquid.translateSection(section);
|
|
24289
|
+
drawSectionColumnSeparators(ctx, section, separatorHeight, alignOffsetNoAngle.x, alignOffsetNoAngle.y);
|
|
24291
24290
|
for (const column of columns) {
|
|
24292
24291
|
const { lines, width: columnWidth } = column;
|
|
24293
24292
|
this._drawLiquid.translateSave();
|
|
@@ -24395,9 +24394,9 @@ var Documents = class Documents extends DocComponent {
|
|
|
24395
24394
|
drawLiquid.translateSave();
|
|
24396
24395
|
drawLiquid.translate(tableLeft, tableTop);
|
|
24397
24396
|
if (hasDocsTableHorizontalViewport(viewport)) {
|
|
24398
|
-
var _viewport$
|
|
24397
|
+
var _viewport$leadingInse2;
|
|
24399
24398
|
const { x, y } = drawLiquid;
|
|
24400
|
-
const clipLeft = x + page.marginLeft - ((_viewport$
|
|
24399
|
+
const clipLeft = x + page.marginLeft - ((_viewport$leadingInse2 = viewport.leadingInsetLeft) !== null && _viewport$leadingInse2 !== void 0 ? _viewport$leadingInse2 : 0);
|
|
24401
24400
|
ctx.save();
|
|
24402
24401
|
ctx.beginPath();
|
|
24403
24402
|
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);
|
|
@@ -24956,6 +24955,63 @@ function getSparseExtensionDiffRanges(uKey, flags, diffRanges) {
|
|
|
24956
24955
|
default: return diffRanges;
|
|
24957
24956
|
}
|
|
24958
24957
|
}
|
|
24958
|
+
/**
|
|
24959
|
+
* Clip a blit source rectangle to the source canvas bounds and shrink the destination
|
|
24960
|
+
* rectangle proportionally, as required by the HTML spec:
|
|
24961
|
+
* https://html.spec.whatwg.org/multipage/canvas.html#drawing-images
|
|
24962
|
+
* ("the source rectangle must be clipped to the source image and the destination
|
|
24963
|
+
* rectangle must be clipped in the same proportion").
|
|
24964
|
+
*
|
|
24965
|
+
* renderByViewports() blits a region larger than the cache canvas (viewport size plus
|
|
24966
|
+
* the row/column header margins, while frozen viewports use bufferEdge=0 on their long
|
|
24967
|
+
* axis) and relies on this behavior: compliant browsers treat the overflow as
|
|
24968
|
+
* transparent padding. WebKit only implements it since Safari 18 ("Fixed drawImage to
|
|
24969
|
+
* not alter the input source or the destination rectangles"), so on Safari < 18 the
|
|
24970
|
+
* overflowed blit is dropped or distorted and frozen viewports lose their content.
|
|
24971
|
+
*
|
|
24972
|
+
* Returns null when the source rectangle lies entirely outside the canvas, meaning
|
|
24973
|
+
* nothing visible remains to be drawn.
|
|
24974
|
+
*/
|
|
24975
|
+
function clipBlitRectToBounds(rect, sourceWidth, sourceHeight) {
|
|
24976
|
+
let { sx, sy, sw, sh, dx, dy, dw, dh } = rect;
|
|
24977
|
+
if (sx < 0) {
|
|
24978
|
+
const cut = Math.min(-sx, sw);
|
|
24979
|
+
const ratio = cut / sw;
|
|
24980
|
+
dx += dw * ratio;
|
|
24981
|
+
dw -= dw * ratio;
|
|
24982
|
+
sw -= cut;
|
|
24983
|
+
sx = 0;
|
|
24984
|
+
}
|
|
24985
|
+
if (sy < 0) {
|
|
24986
|
+
const cut = Math.min(-sy, sh);
|
|
24987
|
+
const ratio = cut / sh;
|
|
24988
|
+
dy += dh * ratio;
|
|
24989
|
+
dh -= dh * ratio;
|
|
24990
|
+
sh -= cut;
|
|
24991
|
+
sy = 0;
|
|
24992
|
+
}
|
|
24993
|
+
if (sx + sw > sourceWidth) {
|
|
24994
|
+
const clamped = Math.max(sourceWidth - sx, 0);
|
|
24995
|
+
dw *= clamped / sw;
|
|
24996
|
+
sw = clamped;
|
|
24997
|
+
}
|
|
24998
|
+
if (sy + sh > sourceHeight) {
|
|
24999
|
+
const clamped = Math.max(sourceHeight - sy, 0);
|
|
25000
|
+
dh *= clamped / sh;
|
|
25001
|
+
sh = clamped;
|
|
25002
|
+
}
|
|
25003
|
+
if (sw <= 0 || sh <= 0) return null;
|
|
25004
|
+
return {
|
|
25005
|
+
sx,
|
|
25006
|
+
sy,
|
|
25007
|
+
sw,
|
|
25008
|
+
sh,
|
|
25009
|
+
dx,
|
|
25010
|
+
dy,
|
|
25011
|
+
dw,
|
|
25012
|
+
dh
|
|
25013
|
+
};
|
|
25014
|
+
}
|
|
24959
25015
|
var Spreadsheet = class extends SheetComponent {
|
|
24960
25016
|
constructor(oKey, spreadsheetSkeleton, _allowCache = true) {
|
|
24961
25017
|
super(oKey, spreadsheetSkeleton);
|
|
@@ -25270,6 +25326,21 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
25270
25326
|
*/
|
|
25271
25327
|
_applyCache(cacheCanvas, ctx, sx = 0, sy = 0, sw = 0, sh = 0, dx = 0, dy = 0, dw = 0, dh = 0) {
|
|
25272
25328
|
if (!ctx) return;
|
|
25329
|
+
let blitRect = {
|
|
25330
|
+
sx,
|
|
25331
|
+
sy,
|
|
25332
|
+
sw,
|
|
25333
|
+
sh,
|
|
25334
|
+
dx,
|
|
25335
|
+
dy,
|
|
25336
|
+
dw,
|
|
25337
|
+
dh
|
|
25338
|
+
};
|
|
25339
|
+
if (sw > 0 && sh > 0 && dw > 0 && dh > 0) {
|
|
25340
|
+
const clipped = clipBlitRectToBounds(blitRect, cacheCanvas.getWidth(), cacheCanvas.getHeight());
|
|
25341
|
+
if (!clipped) return;
|
|
25342
|
+
blitRect = clipped;
|
|
25343
|
+
}
|
|
25273
25344
|
const pixelRatio = cacheCanvas.getPixelRatio();
|
|
25274
25345
|
const cacheCtx = cacheCanvas.getContext();
|
|
25275
25346
|
cacheCtx.save();
|
|
@@ -25277,7 +25348,7 @@ var Spreadsheet = class extends SheetComponent {
|
|
|
25277
25348
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
25278
25349
|
cacheCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
25279
25350
|
ctx.imageSmoothingEnabled = false;
|
|
25280
|
-
ctx.drawImage(cacheCanvas.getCanvasEle(), sx * pixelRatio, sy * pixelRatio, sw * pixelRatio, sh * pixelRatio, dx * pixelRatio, dy * pixelRatio, dw * pixelRatio, dh * pixelRatio);
|
|
25351
|
+
ctx.drawImage(cacheCanvas.getCanvasEle(), blitRect.sx * pixelRatio, blitRect.sy * pixelRatio, blitRect.sw * pixelRatio, blitRect.sh * pixelRatio, blitRect.dx * pixelRatio, blitRect.dy * pixelRatio, blitRect.dw * pixelRatio, blitRect.dh * pixelRatio);
|
|
25281
25352
|
ctx.restore();
|
|
25282
25353
|
cacheCtx.restore();
|
|
25283
25354
|
}
|
|
@@ -26705,11 +26776,16 @@ var DrawingGroupObject = class extends Group {
|
|
|
26705
26776
|
height: 0
|
|
26706
26777
|
});
|
|
26707
26778
|
_defineProperty(this, "_outerShadow", void 0);
|
|
26779
|
+
_defineProperty(this, "_glow", void 0);
|
|
26708
26780
|
}
|
|
26709
26781
|
setOuterShadow(shadow) {
|
|
26710
26782
|
this._outerShadow = shadow;
|
|
26711
26783
|
this.makeDirty(true);
|
|
26712
26784
|
}
|
|
26785
|
+
setGlow(glow) {
|
|
26786
|
+
this._glow = glow;
|
|
26787
|
+
this.makeDirty(true);
|
|
26788
|
+
}
|
|
26713
26789
|
/**
|
|
26714
26790
|
* Set the baseBound (chOff/chExt in OOXML) for this group.
|
|
26715
26791
|
* This defines the coordinate space of children within the group.
|
|
@@ -26756,6 +26832,8 @@ var DrawingGroupObject = class extends Group {
|
|
|
26756
26832
|
const centerX = realLeft + realWidth / 2;
|
|
26757
26833
|
const centerY = realTop + realHeight / 2;
|
|
26758
26834
|
ctx.transform(m[0], m[1], m[2], m[3], centerX, centerY);
|
|
26835
|
+
const effectFilter = createDrawingEffectFilter(this._glow, void 0);
|
|
26836
|
+
if (effectFilter) ctx.filter = combineDrawingEffectFilter(ctx.filter, effectFilter);
|
|
26759
26837
|
if (this._outerShadow) {
|
|
26760
26838
|
ctx.shadowColor = this._outerShadow.shadowColor;
|
|
26761
26839
|
ctx.shadowBlur = this._outerShadow.shadowBlur;
|
|
@@ -27018,7 +27096,8 @@ let CanvasColorService = class CanvasColorService extends Disposable {
|
|
|
27018
27096
|
CanvasColorService = __decorate([__decorateParam(0, Inject(ThemeService))], CanvasColorService);
|
|
27019
27097
|
function getDarkRenderColorOverride(color) {
|
|
27020
27098
|
var _DARK_RENDER_COLOR_OV;
|
|
27021
|
-
|
|
27099
|
+
const normalized = normalizeRenderColor(color);
|
|
27100
|
+
return (_DARK_RENDER_COLOR_OV = DARK_RENDER_COLOR_OVERRIDES[normalized]) !== null && _DARK_RENDER_COLOR_OV !== void 0 ? _DARK_RENDER_COLOR_OV : null;
|
|
27022
27101
|
}
|
|
27023
27102
|
function normalizeRenderColor(color) {
|
|
27024
27103
|
const trimmed = color.trim().toLowerCase();
|
|
@@ -27232,24 +27311,6 @@ let Engine = class Engine extends Disposable {
|
|
|
27232
27311
|
* @param {true} [resize] If should perform resize when mounted and observe resize event.
|
|
27233
27312
|
*/
|
|
27234
27313
|
mount(element, resize = true) {
|
|
27235
|
-
this.setContainer(element, resize);
|
|
27236
|
-
}
|
|
27237
|
-
/**
|
|
27238
|
-
* Unmount the canvas without disposing it so it can be mounted again.
|
|
27239
|
-
*/
|
|
27240
|
-
unmount() {
|
|
27241
|
-
this._clearResizeListener();
|
|
27242
|
-
if (!this._container) throw new Error("[Engine]: cannot unmount when container is not set!");
|
|
27243
|
-
this._container.removeChild(this.getCanvasElement());
|
|
27244
|
-
this._container = null;
|
|
27245
|
-
}
|
|
27246
|
-
/**
|
|
27247
|
-
* Mount the canvas to the element so it would be rendered on UI.
|
|
27248
|
-
* @deprecated Please use `mount` instead.
|
|
27249
|
-
* @param {HTMLElement} element - The element the canvas will mount on.
|
|
27250
|
-
* @param {true} [resize] If should perform resize when mounted and observe resize event.
|
|
27251
|
-
*/
|
|
27252
|
-
setContainer(element, resize = true) {
|
|
27253
27314
|
if (this._container === element) return;
|
|
27254
27315
|
this._container = element;
|
|
27255
27316
|
this._container.appendChild(this.getCanvasElement());
|
|
@@ -27270,6 +27331,15 @@ let Engine = class Engine extends Disposable {
|
|
|
27270
27331
|
});
|
|
27271
27332
|
}
|
|
27272
27333
|
}
|
|
27334
|
+
/**
|
|
27335
|
+
* Unmount the canvas without disposing it so it can be mounted again.
|
|
27336
|
+
*/
|
|
27337
|
+
unmount() {
|
|
27338
|
+
this._clearResizeListener();
|
|
27339
|
+
if (!this._container) throw new Error("[Engine]: cannot unmount when container is not set!");
|
|
27340
|
+
this._container.removeChild(this.getCanvasElement());
|
|
27341
|
+
this._container = null;
|
|
27342
|
+
}
|
|
27273
27343
|
_clearResizeListener() {
|
|
27274
27344
|
var _this$_resizeListener;
|
|
27275
27345
|
(_this$_resizeListener = this._resizeListenerDisposable) === null || _this$_resizeListener === void 0 || _this$_resizeListener.dispose();
|
|
@@ -27698,7 +27768,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
|
|
|
27698
27768
|
//#endregion
|
|
27699
27769
|
//#region package.json
|
|
27700
27770
|
var name = "@univerjs/engine-render";
|
|
27701
|
-
var version = "1.0.0-alpha.
|
|
27771
|
+
var version = "1.0.0-alpha.8";
|
|
27702
27772
|
|
|
27703
27773
|
//#endregion
|
|
27704
27774
|
//#region src/config/config.ts
|
|
@@ -27758,8 +27828,6 @@ var InputManager = class InputManager extends Disposable {
|
|
|
27758
27828
|
this._onPointerEnter = null;
|
|
27759
27829
|
this._onPointerLeave = null;
|
|
27760
27830
|
this._onMouseWheel = null;
|
|
27761
|
-
this._onKeyDown = null;
|
|
27762
|
-
this._onKeyUp = null;
|
|
27763
27831
|
this._onDragEnter = null;
|
|
27764
27832
|
this._onDragLeave = null;
|
|
27765
27833
|
this._onDragOver = null;
|
|
@@ -27850,12 +27918,6 @@ var InputManager = class InputManager extends Disposable {
|
|
|
27850
27918
|
this._scene.getMainViewport().onMouseWheel$.emitEvent(evt);
|
|
27851
27919
|
if (!isStop && this._shouldDispatchEventToScene(currentObject)) this._scene.onMouseWheel$.emitEvent(evt);
|
|
27852
27920
|
}
|
|
27853
|
-
_onKeyDown(evt) {
|
|
27854
|
-
this._scene.onKeyDown$.emitEvent(evt);
|
|
27855
|
-
}
|
|
27856
|
-
_onKeyUp(evt) {
|
|
27857
|
-
this._scene.onKeyUp$.emitEvent(evt);
|
|
27858
|
-
}
|
|
27859
27921
|
_onDragEnter(evt) {
|
|
27860
27922
|
var _this$_currentObject;
|
|
27861
27923
|
this._currentObject = this._getObjectAtPos(evt.offsetX, evt.offsetY);
|
|
@@ -27893,14 +27955,6 @@ var InputManager = class InputManager extends Disposable {
|
|
|
27893
27955
|
if (!engine) return;
|
|
27894
27956
|
this._onInput$ = engine.onInputChanged$.subscribeEvent((eventData) => {
|
|
27895
27957
|
const evt = eventData;
|
|
27896
|
-
if (eventData.deviceType === 1) switch (eventData.type) {
|
|
27897
|
-
case "keydown":
|
|
27898
|
-
this._onKeyDown(evt);
|
|
27899
|
-
break;
|
|
27900
|
-
case "keyup":
|
|
27901
|
-
this._onKeyUp(evt);
|
|
27902
|
-
break;
|
|
27903
|
-
}
|
|
27904
27958
|
if (eventData.deviceType === 2 || eventData.deviceType === 3) switch (eventData.type) {
|
|
27905
27959
|
case "wheel":
|
|
27906
27960
|
case "DOMMouseScroll":
|
|
@@ -28475,10 +28529,6 @@ var Transformer = class extends Disposable {
|
|
|
28475
28529
|
};
|
|
28476
28530
|
}
|
|
28477
28531
|
attachTo(applyObject) {
|
|
28478
|
-
if (this.hoverEnabled) {
|
|
28479
|
-
this.hoverEnterFunc && applyObject.onPointerEnter$.subscribeEvent(this.hoverEnterFunc);
|
|
28480
|
-
this.hoverLeaveFunc && applyObject.onPointerLeave$.subscribeEvent(this.hoverLeaveFunc);
|
|
28481
|
-
}
|
|
28482
28532
|
this.detachFrom(applyObject);
|
|
28483
28533
|
const observer = applyObject.onPointerDown$.subscribeEvent((evt, state) => {
|
|
28484
28534
|
const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt;
|
|
@@ -28542,7 +28592,10 @@ var Transformer = class extends Disposable {
|
|
|
28542
28592
|
});
|
|
28543
28593
|
state.stopPropagation();
|
|
28544
28594
|
});
|
|
28545
|
-
this.
|
|
28595
|
+
if (this.hoverEnabled) {
|
|
28596
|
+
this.hoverEnterFunc && observer.add(applyObject.onPointerEnter$.subscribeEvent(this.hoverEnterFunc));
|
|
28597
|
+
this.hoverLeaveFunc && observer.add(applyObject.onPointerLeave$.subscribeEvent(this.hoverLeaveFunc));
|
|
28598
|
+
}
|
|
28546
28599
|
this._subscriptionObjectMap.set(applyObject.oKey, observer);
|
|
28547
28600
|
return applyObject;
|
|
28548
28601
|
}
|
|
@@ -28557,6 +28610,8 @@ var Transformer = class extends Disposable {
|
|
|
28557
28610
|
dispose() {
|
|
28558
28611
|
var _this$_topScenePointe, _this$_topScenePointe2, _this$_cancelFocusSub2;
|
|
28559
28612
|
super.dispose();
|
|
28613
|
+
this._subscriptionObjectMap.forEach((subscription) => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe());
|
|
28614
|
+
this._subscriptionObjectMap.clear();
|
|
28560
28615
|
(_this$_topScenePointe = this._topScenePointerMoveSub) === null || _this$_topScenePointe === void 0 || _this$_topScenePointe.unsubscribe();
|
|
28561
28616
|
(_this$_topScenePointe2 = this._topScenePointerUpSub) === null || _this$_topScenePointe2 === void 0 || _this$_topScenePointe2.unsubscribe();
|
|
28562
28617
|
(_this$_cancelFocusSub2 = this._cancelFocusSubscription) === null || _this$_cancelFocusSub2 === void 0 || _this$_cancelFocusSub2.unsubscribe();
|
|
@@ -29513,14 +29568,15 @@ var Transformer = class extends Disposable {
|
|
|
29513
29568
|
if (resizeEnabled && !isCropper) {
|
|
29514
29569
|
const { left: lineLeft, top: lineTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotateLine__", height, width, applyObject);
|
|
29515
29570
|
if (rotateEnabled) {
|
|
29516
|
-
const rotateLine = new
|
|
29571
|
+
const rotateLine = new Line(`__SpreadsheetTransformerRotateLine___${zIndex}`, {
|
|
29517
29572
|
zIndex: zIndex - 1,
|
|
29518
29573
|
evented: false,
|
|
29519
|
-
|
|
29520
|
-
|
|
29521
|
-
|
|
29522
|
-
|
|
29574
|
+
startX: lineLeft,
|
|
29575
|
+
startY: lineTop,
|
|
29576
|
+
endX: lineLeft,
|
|
29577
|
+
endY: lineTop + rotateAnchorOffset,
|
|
29523
29578
|
strokeWidth: borderStrokeWidth,
|
|
29579
|
+
strokeLineCap: "butt",
|
|
29524
29580
|
stroke: rotateStroke !== null && rotateStroke !== void 0 ? rotateStroke : borderStroke
|
|
29525
29581
|
});
|
|
29526
29582
|
const { left: rotateLeft, top: rotateTop } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject);
|
|
@@ -29656,22 +29712,6 @@ var Scene = class extends Disposable {
|
|
|
29656
29712
|
_defineProperty(this, "onDblclick$", new EventSubject());
|
|
29657
29713
|
_defineProperty(this, "onTripleClick$", new EventSubject());
|
|
29658
29714
|
_defineProperty(this, "onMouseWheel$", new EventSubject());
|
|
29659
|
-
_defineProperty(
|
|
29660
|
-
this,
|
|
29661
|
-
/**
|
|
29662
|
-
* @deprecated use `fromGlobalEvent('keydown')` from rx.js instead.
|
|
29663
|
-
*/
|
|
29664
|
-
"onKeyDown$",
|
|
29665
|
-
new EventSubject()
|
|
29666
|
-
);
|
|
29667
|
-
_defineProperty(
|
|
29668
|
-
this,
|
|
29669
|
-
/**
|
|
29670
|
-
* @deprecated use `fromGlobalEvent('keyup')` from rx.js instead.
|
|
29671
|
-
*/
|
|
29672
|
-
"onKeyUp$",
|
|
29673
|
-
new EventSubject()
|
|
29674
|
-
);
|
|
29675
29715
|
_defineProperty(this, "_beforeRender$", new BehaviorSubject(null));
|
|
29676
29716
|
_defineProperty(this, "beforeRender$", this._beforeRender$.asObservable());
|
|
29677
29717
|
_defineProperty(this, "_afterRender$", new BehaviorSubject(null));
|
|
@@ -29827,30 +29867,6 @@ var Scene = class extends Disposable {
|
|
|
29827
29867
|
this.resetCursor();
|
|
29828
29868
|
}
|
|
29829
29869
|
/**
|
|
29830
|
-
* @deprecated use transformByState instead.
|
|
29831
|
-
* @param width
|
|
29832
|
-
* @param height
|
|
29833
|
-
*/
|
|
29834
|
-
resize(width, height) {
|
|
29835
|
-
const preWidth = this.width;
|
|
29836
|
-
if (width !== void 0) this.width = width;
|
|
29837
|
-
const preHeight = this.height;
|
|
29838
|
-
if (height !== void 0) this.height = height;
|
|
29839
|
-
this._transformHandler();
|
|
29840
|
-
this.onTransformChange$.emitEvent({
|
|
29841
|
-
type: 1,
|
|
29842
|
-
value: {
|
|
29843
|
-
width: this.width,
|
|
29844
|
-
height: this.height
|
|
29845
|
-
},
|
|
29846
|
-
preValue: {
|
|
29847
|
-
width: preWidth,
|
|
29848
|
-
height: preHeight
|
|
29849
|
-
}
|
|
29850
|
-
});
|
|
29851
|
-
return this;
|
|
29852
|
-
}
|
|
29853
|
-
/**
|
|
29854
29870
|
* Unlike @scale, this method doesn't emit event.
|
|
29855
29871
|
* @param scaleX
|
|
29856
29872
|
* @param scaleY
|
|
@@ -30168,14 +30184,6 @@ var Scene = class extends Disposable {
|
|
|
30168
30184
|
return this.findViewportByPosToScene(coord);
|
|
30169
30185
|
}
|
|
30170
30186
|
/**
|
|
30171
|
-
* @deprecated use `getScrollXYInfoByViewport` instead.
|
|
30172
|
-
* @param pos
|
|
30173
|
-
* @param viewPort
|
|
30174
|
-
*/
|
|
30175
|
-
getVpScrollXYInfoByPosToVp(pos, viewPort) {
|
|
30176
|
-
return this.getScrollXYInfoByViewport(pos, viewPort);
|
|
30177
|
-
}
|
|
30178
|
-
/**
|
|
30179
30187
|
* getViewportScrollXYInfo by viewport under cursor position
|
|
30180
30188
|
* prev getScrollXYByRelativeCoords
|
|
30181
30189
|
* @param pos
|
|
@@ -30203,14 +30211,6 @@ var Scene = class extends Disposable {
|
|
|
30203
30211
|
};
|
|
30204
30212
|
}
|
|
30205
30213
|
/**
|
|
30206
|
-
* @deprecated use `getCoordRelativeToViewport` instead
|
|
30207
|
-
* @param coord
|
|
30208
|
-
* @returns
|
|
30209
|
-
*/
|
|
30210
|
-
getRelativeToViewportCoord(coord) {
|
|
30211
|
-
return this.getCoordRelativeToViewport(coord);
|
|
30212
|
-
}
|
|
30213
|
-
/**
|
|
30214
30214
|
* Get coord to active viewport.
|
|
30215
30215
|
* In a nested scene scenario, it is necessary to obtain the relative offsets layer by layer.
|
|
30216
30216
|
*
|
|
@@ -30288,8 +30288,6 @@ var Scene = class extends Disposable {
|
|
|
30288
30288
|
this.onDblclick$.complete();
|
|
30289
30289
|
this.onTripleClick$.complete();
|
|
30290
30290
|
this.onMouseWheel$.complete();
|
|
30291
|
-
this.onKeyDown$.complete();
|
|
30292
|
-
this.onKeyUp$.complete();
|
|
30293
30291
|
this._addObject$.complete();
|
|
30294
30292
|
super.dispose();
|
|
30295
30293
|
}
|
|
@@ -30726,8 +30724,6 @@ let RenderManagerService = class RenderManagerService extends Disposable {
|
|
|
30726
30724
|
this._themeService = _themeService;
|
|
30727
30725
|
_defineProperty(this, "_defaultEngine", void 0);
|
|
30728
30726
|
_defineProperty(this, "_renderMap", /* @__PURE__ */ new Map());
|
|
30729
|
-
_defineProperty(this, "_createRender$", new Subject());
|
|
30730
|
-
_defineProperty(this, "createRender$", this._createRender$.asObservable());
|
|
30731
30727
|
_defineProperty(this, "_renderCreated$", new Subject());
|
|
30732
30728
|
_defineProperty(this, "created$", this._renderCreated$.asObservable());
|
|
30733
30729
|
_defineProperty(this, "_renderDisposed$", new Subject());
|
|
@@ -30785,9 +30781,6 @@ let RenderManagerService = class RenderManagerService extends Disposable {
|
|
|
30785
30781
|
});
|
|
30786
30782
|
}));
|
|
30787
30783
|
}
|
|
30788
|
-
create(unitId) {
|
|
30789
|
-
this._createRender$.next(unitId);
|
|
30790
|
-
}
|
|
30791
30784
|
/**
|
|
30792
30785
|
* create renderUnit & init deps from renderDependencies
|
|
30793
30786
|
* @param unitId
|
|
@@ -30821,7 +30814,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
|
|
|
30821
30814
|
* @returns renderUnit:IRender
|
|
30822
30815
|
*/
|
|
30823
30816
|
_createRender(unitId, engine, isMainScene = true, createUnitOptions, parentInjector = this._injector) {
|
|
30824
|
-
const existItem = this.
|
|
30817
|
+
const existItem = this.getRenderUnitById(unitId);
|
|
30825
30818
|
let shouldDestroyEngine = true;
|
|
30826
30819
|
if (existItem != null) {
|
|
30827
30820
|
if (existItem.engine === engine) shouldDestroyEngine = false;
|
|
@@ -30887,15 +30880,6 @@ let RenderManagerService = class RenderManagerService extends Disposable {
|
|
|
30887
30880
|
has(unitId) {
|
|
30888
30881
|
return this._renderMap.has(unitId);
|
|
30889
30882
|
}
|
|
30890
|
-
/**
|
|
30891
|
-
* @deprecated use getRenderUnitById instead
|
|
30892
|
-
* Get RenderUnit from this._renderMap.
|
|
30893
|
-
* @param unitId
|
|
30894
|
-
* @returns RenderUnit, aka IRender
|
|
30895
|
-
*/
|
|
30896
|
-
getRenderById(unitId) {
|
|
30897
|
-
return this._renderMap.get(unitId);
|
|
30898
|
-
}
|
|
30899
30883
|
getRenderUnitById(unitId) {
|
|
30900
30884
|
return this._renderMap.get(unitId);
|
|
30901
30885
|
}
|
|
@@ -30944,40 +30928,8 @@ function withCurrentTypeOfRenderer(type, id, instanceService, renderManagerServi
|
|
|
30944
30928
|
return null;
|
|
30945
30929
|
}
|
|
30946
30930
|
|
|
30947
|
-
//#endregion
|
|
30948
|
-
//#region src/services/render-config.service.ts
|
|
30949
|
-
/**
|
|
30950
|
-
* This service carries managers render config that would be passed
|
|
30951
|
-
* to every widget, so some rendering could be optimized.
|
|
30952
|
-
*
|
|
30953
|
-
* @deprecated Will be replaced by ICanvasColorService.
|
|
30954
|
-
*/
|
|
30955
|
-
var UniverRenderConfigService = class {
|
|
30956
|
-
constructor() {
|
|
30957
|
-
_defineProperty(this, "_renderConfig", { ok: "111" });
|
|
30958
|
-
_defineProperty(this, "_updateSignal$", new Subject());
|
|
30959
|
-
_defineProperty(this, "updateSignal$", this._updateSignal$.pipe(debounceTime(4)));
|
|
30960
|
-
}
|
|
30961
|
-
setRenderConfig(key, value) {
|
|
30962
|
-
if (value == null) {
|
|
30963
|
-
delete this._renderConfig[key];
|
|
30964
|
-
return;
|
|
30965
|
-
}
|
|
30966
|
-
this._renderConfig[key] = value;
|
|
30967
|
-
}
|
|
30968
|
-
getRenderConfig() {
|
|
30969
|
-
return this._renderConfig;
|
|
30970
|
-
}
|
|
30971
|
-
};
|
|
30972
|
-
|
|
30973
30931
|
//#endregion
|
|
30974
30932
|
//#region src/plugin.ts
|
|
30975
|
-
/**
|
|
30976
|
-
* The global rendering engine.
|
|
30977
|
-
*
|
|
30978
|
-
* @deprecated There will be no more default global render engine in the future.
|
|
30979
|
-
*/
|
|
30980
|
-
const IRenderingEngine = createIdentifier("univer.render-engine");
|
|
30981
30933
|
const PLUGIN_NAME = "UNIVER_RENDER_ENGINE_PLUGIN";
|
|
30982
30934
|
let UniverRenderEnginePlugin = class UniverRenderEnginePlugin extends Plugin {
|
|
30983
30935
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
@@ -30989,12 +30941,7 @@ let UniverRenderEnginePlugin = class UniverRenderEnginePlugin extends Plugin {
|
|
|
30989
30941
|
this._configService.setConfig(ENGINE_RENDER_PLUGIN_CONFIG_KEY, rest);
|
|
30990
30942
|
}
|
|
30991
30943
|
onStarting() {
|
|
30992
|
-
registerDependencies(this._injector, [
|
|
30993
|
-
[UniverRenderConfigService],
|
|
30994
|
-
[ICanvasColorService, { useClass: CanvasColorService }],
|
|
30995
|
-
[IRenderingEngine, { useClass: Engine }],
|
|
30996
|
-
[IRenderManagerService, { useClass: RenderManagerService }]
|
|
30997
|
-
]);
|
|
30944
|
+
registerDependencies(this._injector, [[ICanvasColorService, { useClass: CanvasColorService }], [IRenderManagerService, { useClass: RenderManagerService }]]);
|
|
30998
30945
|
}
|
|
30999
30946
|
};
|
|
31000
30947
|
_defineProperty(UniverRenderEnginePlugin, "pluginName", PLUGIN_NAME);
|
|
@@ -31044,6 +30991,7 @@ var Viewport = class {
|
|
|
31044
30991
|
constructor(viewportKey, scene, props) {
|
|
31045
30992
|
var _this$scene$getEngine;
|
|
31046
30993
|
_defineProperty(this, "_viewportKey", "");
|
|
30994
|
+
_defineProperty(this, "_transformChangeSubscription", void 0);
|
|
31047
30995
|
_defineProperty(
|
|
31048
30996
|
this,
|
|
31049
30997
|
/**
|
|
@@ -31134,8 +31082,8 @@ var Viewport = class {
|
|
|
31134
31082
|
this._isWheelPreventDefaultX = (props === null || props === void 0 ? void 0 : props.isWheelPreventDefaultX) || false;
|
|
31135
31083
|
this._isWheelPreventDefaultY = (props === null || props === void 0 ? void 0 : props.isWheelPreventDefaultY) || false;
|
|
31136
31084
|
this.resetCanvasSizeAndUpdateScroll();
|
|
31137
|
-
this.
|
|
31138
|
-
(_this$scene$getEngine = this.scene.getEngine()) === null || _this$scene$getEngine === void 0
|
|
31085
|
+
this.calcViewportInfo();
|
|
31086
|
+
this._transformChangeSubscription = (_this$scene$getEngine = this.scene.getEngine()) === null || _this$scene$getEngine === void 0 ? void 0 : _this$scene$getEngine.onTransformChange$.subscribeEvent(() => {
|
|
31139
31087
|
this.markForceDirty(true);
|
|
31140
31088
|
});
|
|
31141
31089
|
this.markForceDirty(true);
|
|
@@ -31651,13 +31599,6 @@ var Viewport = class {
|
|
|
31651
31599
|
};
|
|
31652
31600
|
}
|
|
31653
31601
|
/**
|
|
31654
|
-
* Get viewport info
|
|
31655
|
-
* @deprecated use `calcViewportInfo`
|
|
31656
|
-
*/
|
|
31657
|
-
getBounding() {
|
|
31658
|
-
return this.calcViewportInfo();
|
|
31659
|
-
}
|
|
31660
|
-
/**
|
|
31661
31602
|
* convert vector to scene coordinate, include row & col
|
|
31662
31603
|
* @param vec
|
|
31663
31604
|
* @returns Vector2
|
|
@@ -31734,7 +31675,9 @@ var Viewport = class {
|
|
|
31734
31675
|
this._clipViewport = false;
|
|
31735
31676
|
}
|
|
31736
31677
|
dispose() {
|
|
31737
|
-
var _this$_scrollBar, _this$_cacheCanvas;
|
|
31678
|
+
var _this$_transformChang, _this$_scrollBar, _this$_cacheCanvas;
|
|
31679
|
+
(_this$_transformChang = this._transformChangeSubscription) === null || _this$_transformChang === void 0 || _this$_transformChang.unsubscribe();
|
|
31680
|
+
this._transformChangeSubscription = void 0;
|
|
31738
31681
|
this.onMouseWheel$.complete();
|
|
31739
31682
|
this.onScrollAfter$.complete();
|
|
31740
31683
|
this.onScrollEnd$.complete();
|
|
@@ -32086,4 +32029,4 @@ var Viewport = class {
|
|
|
32086
32029
|
};
|
|
32087
32030
|
|
|
32088
32031
|
//#endregion
|
|
32089
|
-
export { BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService,
|
|
32032
|
+
export { BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, Line, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateRectRotate, cancelRequestFrame, checkStyle, cjk, clampRange, clearLineByBorderType, combineDrawingEffectFilter, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createDrawingEffectFilter, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandDrawingEffectBounds, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getCellPositionByIndex, getCharSpaceApply, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsCustomBlockRenderViewport, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getShrinkToFitScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasSpace, hasThai, hasTibetan, inViewRanges, injectStyle, isArray, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, mergeInfoOffset, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, resolveDrawingEffectMasks, resolveGlowEffect, resolveOuterShadowEffect, scaleDocumentDataForShrinkToFit, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
|