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