@univerjs/core 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -429,7 +429,7 @@ function throttle(fn, wait = 16) {
429
429
  }
430
430
 
431
431
  //#endregion
432
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
432
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
433
433
  function _typeof(o) {
434
434
  "@babel/helpers - typeof";
435
435
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -440,7 +440,7 @@ function _typeof(o) {
440
440
  }
441
441
 
442
442
  //#endregion
443
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
443
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
444
444
  function toPrimitive(t, r) {
445
445
  if ("object" != _typeof(t) || !t) return t;
446
446
  var e = t[Symbol.toPrimitive];
@@ -453,14 +453,14 @@ function toPrimitive(t, r) {
453
453
  }
454
454
 
455
455
  //#endregion
456
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
456
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
457
457
  function toPropertyKey(t) {
458
458
  var i = toPrimitive(t, "string");
459
459
  return "symbol" == _typeof(i) ? i : i + "";
460
460
  }
461
461
 
462
462
  //#endregion
463
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
463
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
464
464
  function _defineProperty(e, r, t) {
465
465
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
466
466
  value: t,
@@ -1387,7 +1387,7 @@ const topLevelDomainSet = new Set([
1387
1387
  "zm",
1388
1388
  "zw"
1389
1389
  ]);
1390
- const re_weburl = new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$", "i");
1390
+ const re_weburl = /* @__PURE__ */ new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$", "i");
1391
1391
  function isLegalUrl(url) {
1392
1392
  if (!Number.isNaN(+url)) return false;
1393
1393
  if (url.startsWith("http://localhost:3002") || url.startsWith("localhost:3002")) return true;
@@ -1415,6 +1415,20 @@ function normalizeUrl(urlStr) {
1415
1415
  * @param {string} baseURL - The base URL to use for resolution.
1416
1416
  * @returns {string} - The resolved URL.
1417
1417
  */
1418
+ function isSafeUrl(url) {
1419
+ if (!url || typeof url !== "string") return false;
1420
+ try {
1421
+ const base = typeof window !== "undefined" && window.location ? window.location.origin : "http://localhost";
1422
+ const parsed = new URL(url, base);
1423
+ return [
1424
+ "http:",
1425
+ "https:",
1426
+ "mailto:"
1427
+ ].includes(parsed.protocol);
1428
+ } catch {
1429
+ return false;
1430
+ }
1431
+ }
1418
1432
  function resolveWithBasePath(url, baseURL) {
1419
1433
  try {
1420
1434
  const base = new URL(baseURL);
@@ -1519,8 +1533,12 @@ var Tools = class Tools {
1519
1533
  /** @deprecated This method is deprecated, please use `import { merge } from '@univerjs/core` instead */
1520
1534
  static deepMerge(target, ...sources) {
1521
1535
  sources.forEach((item) => item && deepItem(item));
1536
+ function isDangerousKey(key) {
1537
+ return key === "__proto__" || key === "constructor" || key === "prototype";
1538
+ }
1522
1539
  function deepArray(array, to) {
1523
1540
  array.forEach((value, key) => {
1541
+ if (typeof key === "string" && isDangerousKey(key)) return;
1524
1542
  if (Tools.isArray(value)) {
1525
1543
  var _to$key;
1526
1544
  const origin = (_to$key = to[key]) !== null && _to$key !== void 0 ? _to$key : [];
@@ -1540,6 +1558,7 @@ var Tools = class Tools {
1540
1558
  }
1541
1559
  function deepObject(object, to) {
1542
1560
  Object.keys(object).forEach((key) => {
1561
+ if (isDangerousKey(key)) return;
1543
1562
  const value = object[key];
1544
1563
  if (Tools.isObject(value)) {
1545
1564
  var _to$key3;
@@ -1560,6 +1579,7 @@ var Tools = class Tools {
1560
1579
  }
1561
1580
  function deepItem(item) {
1562
1581
  Object.keys(item).forEach((key) => {
1582
+ if (isDangerousKey(key)) return;
1563
1583
  const value = item[key];
1564
1584
  if (Tools.isArray(value)) {
1565
1585
  var _target$key;
@@ -1711,7 +1731,8 @@ var Tools = class Tools {
1711
1731
  */
1712
1732
  static chatAtABC(n) {
1713
1733
  const ord_a = "a".charCodeAt(0);
1714
- const len = "z".charCodeAt(0) - ord_a + 1;
1734
+ "z".charCodeAt(0);
1735
+ const len = 26;
1715
1736
  let s = "";
1716
1737
  while (n >= 0) {
1717
1738
  s = String.fromCharCode(n % len + ord_a) + s;
@@ -1788,9 +1809,16 @@ const isNodeEnv = () => {
1788
1809
  * @returns {RegExp} The generated regular expression
1789
1810
  */
1790
1811
  function createREGEXFromWildChar(wildChar) {
1791
- const regexpStr = wildChar.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\*/g, ".*").replace(/\\\?/g, ".");
1812
+ const regexpStr = escapeRegExp(wildChar).replace(/\\\*/g, ".*").replace(/\\\?/g, ".");
1792
1813
  return new RegExp(`^${regexpStr}$`, "i");
1793
1814
  }
1815
+ /**
1816
+ * Escapes characters that have special meaning in a regular expression so the
1817
+ * returned string can be safely embedded in a RegExp pattern as literal text.
1818
+ */
1819
+ function escapeRegExp(str) {
1820
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1821
+ }
1794
1822
 
1795
1823
  //#endregion
1796
1824
  //#region src/types/enum/auto-fill-series.ts
@@ -2115,6 +2143,7 @@ let LocaleType = /* @__PURE__ */ function(LocaleType) {
2115
2143
  LocaleType["ZH_CN"] = "zhCN";
2116
2144
  LocaleType["RU_RU"] = "ruRU";
2117
2145
  LocaleType["ZH_TW"] = "zhTW";
2146
+ LocaleType["ZH_HK"] = "zhHK";
2118
2147
  LocaleType["VI_VN"] = "viVN";
2119
2148
  LocaleType["FA_IR"] = "faIR";
2120
2149
  LocaleType["JA_JP"] = "jaJP";
@@ -2122,6 +2151,12 @@ let LocaleType = /* @__PURE__ */ function(LocaleType) {
2122
2151
  LocaleType["ES_ES"] = "esES";
2123
2152
  LocaleType["CA_ES"] = "caES";
2124
2153
  LocaleType["SK_SK"] = "skSK";
2154
+ LocaleType["PT_BR"] = "ptBR";
2155
+ LocaleType["DE_DE"] = "deDE";
2156
+ LocaleType["IT_IT"] = "itIT";
2157
+ LocaleType["ID_ID"] = "idID";
2158
+ LocaleType["PL_PL"] = "plPL";
2159
+ LocaleType["AR_SA"] = "arSA";
2125
2160
  return LocaleType;
2126
2161
  }({});
2127
2162
 
@@ -2983,245 +3018,554 @@ const STYLE_KEYS = defineExactKeys()([
2983
3018
  ]);
2984
3019
 
2985
3020
  //#endregion
2986
- //#region src/docs/data-model/empty-snapshot.ts
2987
- function getEmptySnapshot$1(unitID = generateRandomId(6), locale = "enUS", title = "") {
2988
- return {
2989
- id: unitID,
2990
- locale,
2991
- title,
2992
- tableSource: {},
2993
- drawings: {},
2994
- drawingsOrder: [],
2995
- headers: {},
2996
- footers: {},
2997
- body: {
2998
- dataStream: "\r\n",
2999
- textRuns: [],
3000
- customBlocks: [],
3001
- tables: [],
3002
- paragraphs: [{
3003
- startIndex: 0,
3004
- paragraphStyle: {
3005
- spaceAbove: { v: 5 },
3006
- lineSpacing: 1,
3007
- spaceBelow: { v: 0 }
3008
- }
3009
- }],
3010
- sectionBreaks: [{ startIndex: 1 }]
3011
- },
3012
- documentStyle: {
3013
- pageSize: {
3014
- width: 595 / .75,
3015
- height: 842 / .75
3016
- },
3017
- documentFlavor: 1,
3018
- marginTop: 50,
3019
- marginBottom: 50,
3020
- marginRight: 50,
3021
- marginLeft: 50,
3022
- renderConfig: {
3023
- zeroWidthParagraphBreak: 0,
3024
- vertexAngle: 0,
3025
- centerAngle: 0,
3026
- background: { rgb: "#ccc" }
3027
- },
3028
- autoHyphenation: 1,
3029
- doNotHyphenateCaps: 0,
3030
- consecutiveHyphenLimit: 2,
3031
- defaultHeaderId: "",
3032
- defaultFooterId: "",
3033
- evenPageHeaderId: "",
3034
- evenPageFooterId: "",
3035
- firstPageHeaderId: "",
3036
- firstPageFooterId: "",
3037
- evenAndOddHeaders: 0,
3038
- useFirstPageHeaderFooter: 0,
3039
- marginHeader: 30,
3040
- marginFooter: 30
3041
- },
3042
- settings: {}
3043
- };
3044
- }
3045
-
3046
- //#endregion
3047
- //#region src/shared/command-enum.ts
3021
+ //#region src/types/const/const.ts
3048
3022
  /**
3049
- * Copyright 2023-present DreamNum Co., Ltd.
3050
- *
3051
- * Licensed under the Apache License, Version 2.0 (the "License");
3052
- * you may not use this file except in compliance with the License.
3053
- * You may obtain a copy of the License at
3054
- *
3055
- * http://www.apache.org/licenses/LICENSE-2.0
3056
- *
3057
- * Unless required by applicable law or agreed to in writing, software
3058
- * distributed under the License is distributed on an "AS IS" BASIS,
3059
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3060
- * See the License for the specific language governing permissions and
3061
- * limitations under the License.
3023
+ * Used as an illegal range array return value
3062
3024
  */
3063
- let UpdateDocsAttributeType = /* @__PURE__ */ function(UpdateDocsAttributeType) {
3064
- UpdateDocsAttributeType[UpdateDocsAttributeType["COVER"] = 0] = "COVER";
3065
- UpdateDocsAttributeType[UpdateDocsAttributeType["REPLACE"] = 1] = "REPLACE";
3066
- return UpdateDocsAttributeType;
3067
- }({});
3068
-
3069
- //#endregion
3070
- //#region src/docs/data-model/text-x/action-types.ts
3071
- let TextXActionType = /* @__PURE__ */ function(TextXActionType) {
3072
- TextXActionType["RETAIN"] = "r";
3073
- TextXActionType["INSERT"] = "i";
3074
- TextXActionType["DELETE"] = "d";
3075
- return TextXActionType;
3076
- }({});
3077
-
3078
- //#endregion
3079
- //#region src/services/config/config.service.ts
3025
+ const DEFAULT_RANGE_ARRAY = {
3026
+ sheetId: "",
3027
+ range: {
3028
+ startRow: -1,
3029
+ endRow: -1,
3030
+ startColumn: -1,
3031
+ endColumn: -1
3032
+ }
3033
+ };
3080
3034
  /**
3081
- * IConfig provides universal configuration for the whole application.
3035
+ * Used as an illegal range return value
3082
3036
  */
3083
- const IConfigService = (0, _wendellhu_redi.createIdentifier)("univer.config-service");
3084
- var ConfigService = class {
3085
- constructor() {
3086
- _defineProperty(this, "_configChanged$", new rxjs.Subject());
3087
- _defineProperty(this, "configChanged$", this._configChanged$.asObservable());
3088
- _defineProperty(this, "_config", /* @__PURE__ */ new Map());
3089
- }
3090
- dispose() {
3091
- this._config.clear();
3092
- this._configChanged$.complete();
3093
- }
3094
- getConfig(id) {
3095
- return this._config.get(id);
3096
- }
3097
- setConfig(id, value, options) {
3098
- var _this$_config$get;
3099
- const { merge: isMerge = false } = options || {};
3100
- let nextValue = (_this$_config$get = this._config.get(id)) !== null && _this$_config$get !== void 0 ? _this$_config$get : {};
3101
- if (isMerge) nextValue = (0, lodash_es.merge)(nextValue, value);
3102
- else nextValue = value;
3103
- this._config.set(id, nextValue);
3104
- this._configChanged$.next({ [id]: nextValue });
3105
- }
3106
- deleteConfig(id) {
3107
- return this._config.delete(id);
3108
- }
3109
- subscribeConfigValue$(key) {
3110
- return new rxjs.Observable((observer) => {
3111
- if (Object.prototype.hasOwnProperty.call(this._config, key)) observer.next(this._config.get(key));
3112
- const sub = this.configChanged$.pipe((0, rxjs.filter)((c) => Object.prototype.hasOwnProperty.call(c, key))).subscribe((c) => observer.next(c[key]));
3113
- return () => sub.unsubscribe();
3114
- });
3115
- }
3037
+ const DEFAULT_RANGE = {
3038
+ startRow: -1,
3039
+ startColumn: -1,
3040
+ endRow: -1,
3041
+ endColumn: -1
3116
3042
  };
3117
-
3118
- //#endregion
3119
- //#region src/services/context/context.service.ts
3120
3043
  /**
3121
- * Copyright 2023-present DreamNum Co., Ltd.
3122
- *
3123
- * Licensed under the Apache License, Version 2.0 (the "License");
3124
- * you may not use this file except in compliance with the License.
3125
- * You may obtain a copy of the License at
3126
- *
3127
- * http://www.apache.org/licenses/LICENSE-2.0
3128
- *
3129
- * Unless required by applicable law or agreed to in writing, software
3130
- * distributed under the License is distributed on an "AS IS" BASIS,
3131
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3132
- * See the License for the specific language governing permissions and
3133
- * limitations under the License.
3044
+ * Used as an init selection return value
3134
3045
  */
3135
- const IContextService = (0, _wendellhu_redi.createIdentifier)("univer.context-service");
3136
- var ContextService = class extends Disposable {
3137
- constructor(..._args) {
3138
- super(..._args);
3139
- _defineProperty(this, "_contextChanged$", new rxjs.Subject());
3140
- _defineProperty(this, "contextChanged$", this._contextChanged$.asObservable());
3141
- _defineProperty(this, "_contextMap", /* @__PURE__ */ new Map());
3142
- }
3143
- dispose() {
3144
- super.dispose();
3145
- this._contextChanged$.complete();
3146
- this._contextMap.clear();
3147
- }
3148
- getContextValue(key) {
3149
- var _this$_contextMap$get;
3150
- return (_this$_contextMap$get = this._contextMap.get(key)) !== null && _this$_contextMap$get !== void 0 ? _this$_contextMap$get : false;
3151
- }
3152
- setContextValue(key, value) {
3153
- this._contextMap.set(key, value);
3154
- this._contextChanged$.next({ [key]: value });
3155
- }
3156
- subscribeContextValue$(key) {
3157
- return new rxjs.Observable((observer) => {
3158
- const contextChangeSubscription = this._contextChanged$.pipe((0, rxjs.filter)((event) => typeof event[key] !== "undefined")).subscribe((event) => observer.next(event[key]));
3159
- if (this._contextMap.has(key)) observer.next(this._contextMap.get(key));
3160
- return () => contextChangeSubscription.unsubscribe();
3161
- });
3162
- }
3046
+ const DEFAULT_SELECTION = {
3047
+ startRow: 0,
3048
+ startColumn: 0,
3049
+ endRow: 0,
3050
+ endColumn: 0
3163
3051
  };
3164
-
3165
- //#endregion
3166
- //#region src/services/log/log.service.ts
3167
3052
  /**
3168
- * Copyright 2023-present DreamNum Co., Ltd.
3169
- *
3170
- * Licensed under the Apache License, Version 2.0 (the "License");
3171
- * you may not use this file except in compliance with the License.
3172
- * You may obtain a copy of the License at
3173
- *
3174
- * http://www.apache.org/licenses/LICENSE-2.0
3175
- *
3176
- * Unless required by applicable law or agreed to in writing, software
3177
- * distributed under the License is distributed on an "AS IS" BASIS,
3178
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3179
- * See the License for the specific language governing permissions and
3180
- * limitations under the License.
3053
+ * Used as an init cell return value
3181
3054
  */
3182
- let LogLevel = /* @__PURE__ */ function(LogLevel) {
3183
- LogLevel[LogLevel["SILENT"] = 0] = "SILENT";
3184
- LogLevel[LogLevel["ERROR"] = 1] = "ERROR";
3185
- LogLevel[LogLevel["WARN"] = 2] = "WARN";
3186
- LogLevel[LogLevel["INFO"] = 3] = "INFO";
3187
- LogLevel[LogLevel["VERBOSE"] = 4] = "VERBOSE";
3188
- return LogLevel;
3189
- }({});
3190
- const ILogService = (0, _wendellhu_redi.createIdentifier)("univer.log");
3191
- var DesktopLogService = class extends Disposable {
3192
- constructor(..._args) {
3193
- super(..._args);
3194
- _defineProperty(this, "_logLevel", 3);
3195
- _defineProperty(this, "_deduction", /* @__PURE__ */ new Set());
3196
- }
3197
- dispose() {
3198
- super.dispose();
3199
- this._logLevel = 3;
3200
- this._deduction.clear();
3201
- }
3202
- debug(...args) {
3203
- if (this._logLevel >= 4) this._log(console.debug, ...args);
3204
- }
3205
- log(...args) {
3206
- if (this._logLevel >= 3) this._log(console.log, ...args);
3207
- }
3208
- warn(...args) {
3209
- if (this._logLevel >= 2) this._log(console.warn, ...args);
3210
- }
3211
- error(...args) {
3212
- if (this._logLevel >= 1) this._log(console.error, ...args);
3213
- }
3214
- deprecate(...args) {
3215
- if (this._logLevel >= 2) this._logWithDeduplication(console.error, ...args);
3216
- }
3217
- setLogLevel(logLevel) {
3218
- this._logLevel = logLevel;
3219
- }
3220
- _log(method, ...args) {
3221
- const firstArg = args[0];
3222
- if (/^\[(.*?)\]/g.test(firstArg)) method(`\x1B[97;104m${firstArg}\x1B[0m`, ...args.slice(1));
3223
- else method(...args);
3224
- }
3055
+ const DEFAULT_CELL = {
3056
+ row: 0,
3057
+ column: 0
3058
+ };
3059
+ /**
3060
+ * Default styles.
3061
+ */
3062
+ const DEFAULT_STYLES = {
3063
+ /**
3064
+ * fontFamily
3065
+ */
3066
+ ff: "Arial",
3067
+ /**
3068
+ * fontSize
3069
+ */
3070
+ fs: 11,
3071
+ /**
3072
+ * italic
3073
+ * 0: false
3074
+ * 1: true
3075
+ */
3076
+ it: 0,
3077
+ /**
3078
+ * bold
3079
+ * 0: false
3080
+ * 1: true
3081
+ */
3082
+ bl: 0,
3083
+ /**
3084
+ * underline
3085
+ */
3086
+ ul: { s: 0 },
3087
+ /**
3088
+ * strikethrough
3089
+ */
3090
+ st: { s: 0 },
3091
+ /**
3092
+ * overline
3093
+ */
3094
+ ol: { s: 0 },
3095
+ /**
3096
+ * textRotation
3097
+ */
3098
+ tr: {
3099
+ a: 0,
3100
+ /**
3101
+ * true : 1
3102
+ * false : 0
3103
+ */
3104
+ v: 0
3105
+ },
3106
+ /**
3107
+ * textDirection
3108
+ */
3109
+ td: 0,
3110
+ /**
3111
+ * color
3112
+ */
3113
+ cl: { rgb: "#000000" },
3114
+ /**
3115
+ * background
3116
+ */
3117
+ bg: { rgb: "#fff" },
3118
+ /**
3119
+ * horizontalAlignment
3120
+ */
3121
+ ht: 0,
3122
+ /**
3123
+ * verticalAlignment
3124
+ */
3125
+ vt: 0,
3126
+ /**
3127
+ * wrapStrategy
3128
+ */
3129
+ tb: 0,
3130
+ /**
3131
+ * padding
3132
+ */
3133
+ pd: {
3134
+ t: 0,
3135
+ r: 0,
3136
+ b: 0,
3137
+ l: 0
3138
+ },
3139
+ n: null,
3140
+ /**
3141
+ * border
3142
+ */
3143
+ bd: {
3144
+ b: null,
3145
+ l: null,
3146
+ r: null,
3147
+ t: null
3148
+ }
3149
+ };
3150
+ const SHEET_EDITOR_UNITS = [
3151
+ DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
3152
+ DOCS_ZEN_EDITOR_UNIT_ID_KEY,
3153
+ DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY
3154
+ ];
3155
+ const NAMED_STYLE_MAP = {
3156
+ [4]: {
3157
+ fs: 20,
3158
+ bl: 1
3159
+ },
3160
+ [5]: {
3161
+ fs: 18,
3162
+ bl: 1
3163
+ },
3164
+ [6]: {
3165
+ fs: 16,
3166
+ bl: 1
3167
+ },
3168
+ [7]: {
3169
+ fs: 14,
3170
+ bl: 1
3171
+ },
3172
+ [8]: {
3173
+ fs: 12,
3174
+ bl: 1
3175
+ },
3176
+ [1]: null,
3177
+ [2]: {
3178
+ fs: 26,
3179
+ bl: 1
3180
+ },
3181
+ [3]: {
3182
+ fs: 15,
3183
+ cl: { rgb: "#999999" }
3184
+ },
3185
+ [0]: null
3186
+ };
3187
+ const DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = 1.5;
3188
+ const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = 0;
3189
+ const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = 8;
3190
+ const NAMED_STYLE_SPACE_MAP = {
3191
+ [4]: {
3192
+ spaceAbove: { v: 20 },
3193
+ spaceBelow: { v: 10 }
3194
+ },
3195
+ [5]: {
3196
+ spaceAbove: { v: 18 },
3197
+ spaceBelow: { v: 10 }
3198
+ },
3199
+ [6]: {
3200
+ spaceAbove: { v: 16 },
3201
+ spaceBelow: { v: 10 }
3202
+ },
3203
+ [7]: {
3204
+ spaceAbove: { v: 14 },
3205
+ spaceBelow: { v: 8 }
3206
+ },
3207
+ [8]: {
3208
+ spaceAbove: { v: 12 },
3209
+ spaceBelow: { v: 8 }
3210
+ },
3211
+ [1]: {
3212
+ spaceAbove: { v: 0 },
3213
+ spaceBelow: { v: 8 }
3214
+ },
3215
+ [2]: {
3216
+ spaceAbove: { v: 0 },
3217
+ spaceBelow: { v: 7 }
3218
+ },
3219
+ [3]: {
3220
+ spaceAbove: { v: 0 },
3221
+ spaceBelow: { v: 16 }
3222
+ },
3223
+ [0]: null
3224
+ };
3225
+ const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
3226
+ const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
3227
+
3228
+ //#endregion
3229
+ //#region src/types/const/extension-names.ts
3230
+ /**
3231
+ * Copyright 2023-present DreamNum Co., Ltd.
3232
+ *
3233
+ * Licensed under the Apache License, Version 2.0 (the "License");
3234
+ * you may not use this file except in compliance with the License.
3235
+ * You may obtain a copy of the License at
3236
+ *
3237
+ * http://www.apache.org/licenses/LICENSE-2.0
3238
+ *
3239
+ * Unless required by applicable law or agreed to in writing, software
3240
+ * distributed under the License is distributed on an "AS IS" BASIS,
3241
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3242
+ * See the License for the specific language governing permissions and
3243
+ * limitations under the License.
3244
+ */
3245
+ let EXTENSION_NAMES = /* @__PURE__ */ function(EXTENSION_NAMES) {
3246
+ EXTENSION_NAMES["ARRAY_CONVERTOR"] = "ARRAY_CONVERTOR";
3247
+ EXTENSION_NAMES["MATRIX_CONVERTOR"] = "MATRIX_CONVERTOR";
3248
+ return EXTENSION_NAMES;
3249
+ }({});
3250
+
3251
+ //#endregion
3252
+ //#region src/types/const/page-size.ts
3253
+ const PAGE_SIZE = {
3254
+ ["A3"]: {
3255
+ width: 1123,
3256
+ height: 1587
3257
+ },
3258
+ ["A4"]: {
3259
+ width: 794,
3260
+ height: 1124
3261
+ },
3262
+ ["A5"]: {
3263
+ width: 559,
3264
+ height: 794
3265
+ },
3266
+ ["B4"]: {
3267
+ width: 944,
3268
+ height: 1344
3269
+ },
3270
+ ["B5"]: {
3271
+ width: 665,
3272
+ height: 944
3273
+ },
3274
+ ["Executive"]: {
3275
+ width: 696,
3276
+ height: 1008
3277
+ },
3278
+ ["Folio"]: {
3279
+ width: 816,
3280
+ height: 1248
3281
+ },
3282
+ ["Legal"]: {
3283
+ width: 816,
3284
+ height: 1344
3285
+ },
3286
+ ["Letter"]: {
3287
+ width: 816,
3288
+ height: 1056
3289
+ },
3290
+ ["Statement"]: {
3291
+ width: 528,
3292
+ height: 816
3293
+ },
3294
+ ["Tabloid"]: {
3295
+ width: 1056,
3296
+ height: 1632
3297
+ }
3298
+ };
3299
+ let ModernDocumentWidthMode = /* @__PURE__ */ function(ModernDocumentWidthMode) {
3300
+ ModernDocumentWidthMode["NARROW"] = "narrow";
3301
+ ModernDocumentWidthMode["MEDIUM"] = "medium";
3302
+ ModernDocumentWidthMode["WIDE"] = "wide";
3303
+ return ModernDocumentWidthMode;
3304
+ }({});
3305
+ const MODERN_DOCUMENT_WIDTH = {
3306
+ ["narrow"]: PAGE_SIZE["A4"].width,
3307
+ ["medium"]: 960,
3308
+ ["wide"]: PAGE_SIZE["A3"].width
3309
+ };
3310
+ const MODERN_DOCUMENT_DEFAULT_MARGIN = 50 / .75;
3311
+
3312
+ //#endregion
3313
+ //#region src/types/const/theme-color-map.ts
3314
+ const THEME_COLORS = { ["Office"]: {
3315
+ [4]: "#4472C4",
3316
+ [5]: "#ED7D31",
3317
+ [6]: "#A5A5A5",
3318
+ [7]: "#70AD47",
3319
+ [8]: "#5B9BD5",
3320
+ [9]: "#70AD47",
3321
+ [0]: "#000000",
3322
+ [2]: "#44546A",
3323
+ [1]: "#FFFFFF",
3324
+ [3]: "#E7E6E6",
3325
+ [10]: "#0563C1",
3326
+ [11]: "#954F72"
3327
+ } };
3328
+
3329
+ //#endregion
3330
+ //#region src/docs/data-model/empty-snapshot.ts
3331
+ function getEmptySnapshot$1(unitID = generateRandomId(6), locale = "enUS", title = "") {
3332
+ return {
3333
+ id: unitID,
3334
+ locale,
3335
+ title,
3336
+ tableSource: {},
3337
+ drawings: {},
3338
+ drawingsOrder: [],
3339
+ headers: {},
3340
+ footers: {},
3341
+ body: {
3342
+ dataStream: "\r\n",
3343
+ textRuns: [],
3344
+ customBlocks: [],
3345
+ tables: [],
3346
+ paragraphs: [{
3347
+ startIndex: 0,
3348
+ paragraphStyle: {
3349
+ spaceAbove: { v: 0 },
3350
+ lineSpacing: DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
3351
+ spaceBelow: { v: 8 }
3352
+ }
3353
+ }],
3354
+ sectionBreaks: [{ startIndex: 1 }]
3355
+ },
3356
+ documentStyle: {
3357
+ pageSize: {
3358
+ width: MODERN_DOCUMENT_WIDTH["medium"],
3359
+ height: 842 / .75
3360
+ },
3361
+ documentFlavor: 2,
3362
+ marginTop: 50,
3363
+ marginBottom: 50,
3364
+ marginRight: 50,
3365
+ marginLeft: 50,
3366
+ renderConfig: {
3367
+ zeroWidthParagraphBreak: 0,
3368
+ vertexAngle: 0,
3369
+ centerAngle: 0,
3370
+ background: { rgb: "#ccc" }
3371
+ },
3372
+ autoHyphenation: 1,
3373
+ doNotHyphenateCaps: 0,
3374
+ consecutiveHyphenLimit: 2,
3375
+ defaultHeaderId: "",
3376
+ defaultFooterId: "",
3377
+ evenPageHeaderId: "",
3378
+ evenPageFooterId: "",
3379
+ firstPageHeaderId: "",
3380
+ firstPageFooterId: "",
3381
+ evenAndOddHeaders: 0,
3382
+ useFirstPageHeaderFooter: 0,
3383
+ marginHeader: 30,
3384
+ marginFooter: 30
3385
+ },
3386
+ settings: {}
3387
+ };
3388
+ }
3389
+
3390
+ //#endregion
3391
+ //#region src/shared/command-enum.ts
3392
+ /**
3393
+ * Copyright 2023-present DreamNum Co., Ltd.
3394
+ *
3395
+ * Licensed under the Apache License, Version 2.0 (the "License");
3396
+ * you may not use this file except in compliance with the License.
3397
+ * You may obtain a copy of the License at
3398
+ *
3399
+ * http://www.apache.org/licenses/LICENSE-2.0
3400
+ *
3401
+ * Unless required by applicable law or agreed to in writing, software
3402
+ * distributed under the License is distributed on an "AS IS" BASIS,
3403
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3404
+ * See the License for the specific language governing permissions and
3405
+ * limitations under the License.
3406
+ */
3407
+ let UpdateDocsAttributeType = /* @__PURE__ */ function(UpdateDocsAttributeType) {
3408
+ UpdateDocsAttributeType[UpdateDocsAttributeType["COVER"] = 0] = "COVER";
3409
+ UpdateDocsAttributeType[UpdateDocsAttributeType["REPLACE"] = 1] = "REPLACE";
3410
+ return UpdateDocsAttributeType;
3411
+ }({});
3412
+
3413
+ //#endregion
3414
+ //#region src/docs/data-model/text-x/action-types.ts
3415
+ let TextXActionType = /* @__PURE__ */ function(TextXActionType) {
3416
+ TextXActionType["RETAIN"] = "r";
3417
+ TextXActionType["INSERT"] = "i";
3418
+ TextXActionType["DELETE"] = "d";
3419
+ return TextXActionType;
3420
+ }({});
3421
+
3422
+ //#endregion
3423
+ //#region src/services/config/config.service.ts
3424
+ /**
3425
+ * IConfig provides universal configuration for the whole application.
3426
+ */
3427
+ const IConfigService = (0, _wendellhu_redi.createIdentifier)("univer.config-service");
3428
+ var ConfigService = class {
3429
+ constructor() {
3430
+ _defineProperty(this, "_configChanged$", new rxjs.Subject());
3431
+ _defineProperty(this, "configChanged$", this._configChanged$.asObservable());
3432
+ _defineProperty(this, "_config", /* @__PURE__ */ new Map());
3433
+ }
3434
+ dispose() {
3435
+ this._config.clear();
3436
+ this._configChanged$.complete();
3437
+ }
3438
+ getConfig(id) {
3439
+ return this._config.get(id);
3440
+ }
3441
+ setConfig(id, value, options) {
3442
+ var _this$_config$get;
3443
+ const { merge: isMerge = false } = options || {};
3444
+ let nextValue = (_this$_config$get = this._config.get(id)) !== null && _this$_config$get !== void 0 ? _this$_config$get : {};
3445
+ if (isMerge) nextValue = (0, lodash_es.merge)(nextValue, value);
3446
+ else nextValue = value;
3447
+ this._config.set(id, nextValue);
3448
+ this._configChanged$.next({ [id]: nextValue });
3449
+ }
3450
+ deleteConfig(id) {
3451
+ return this._config.delete(id);
3452
+ }
3453
+ subscribeConfigValue$(key) {
3454
+ return new rxjs.Observable((observer) => {
3455
+ if (Object.prototype.hasOwnProperty.call(this._config, key)) observer.next(this._config.get(key));
3456
+ const sub = this.configChanged$.pipe((0, rxjs.filter)((c) => Object.prototype.hasOwnProperty.call(c, key))).subscribe((c) => observer.next(c[key]));
3457
+ return () => sub.unsubscribe();
3458
+ });
3459
+ }
3460
+ };
3461
+
3462
+ //#endregion
3463
+ //#region src/services/context/context.service.ts
3464
+ /**
3465
+ * Copyright 2023-present DreamNum Co., Ltd.
3466
+ *
3467
+ * Licensed under the Apache License, Version 2.0 (the "License");
3468
+ * you may not use this file except in compliance with the License.
3469
+ * You may obtain a copy of the License at
3470
+ *
3471
+ * http://www.apache.org/licenses/LICENSE-2.0
3472
+ *
3473
+ * Unless required by applicable law or agreed to in writing, software
3474
+ * distributed under the License is distributed on an "AS IS" BASIS,
3475
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3476
+ * See the License for the specific language governing permissions and
3477
+ * limitations under the License.
3478
+ */
3479
+ const IContextService = (0, _wendellhu_redi.createIdentifier)("univer.context-service");
3480
+ var ContextService = class extends Disposable {
3481
+ constructor(..._args) {
3482
+ super(..._args);
3483
+ _defineProperty(this, "_contextChanged$", new rxjs.Subject());
3484
+ _defineProperty(this, "contextChanged$", this._contextChanged$.asObservable());
3485
+ _defineProperty(this, "_contextMap", /* @__PURE__ */ new Map());
3486
+ }
3487
+ dispose() {
3488
+ super.dispose();
3489
+ this._contextChanged$.complete();
3490
+ this._contextMap.clear();
3491
+ }
3492
+ getContextValue(key) {
3493
+ var _this$_contextMap$get;
3494
+ return (_this$_contextMap$get = this._contextMap.get(key)) !== null && _this$_contextMap$get !== void 0 ? _this$_contextMap$get : false;
3495
+ }
3496
+ setContextValue(key, value) {
3497
+ this._contextMap.set(key, value);
3498
+ this._contextChanged$.next({ [key]: value });
3499
+ }
3500
+ subscribeContextValue$(key) {
3501
+ return new rxjs.Observable((observer) => {
3502
+ const contextChangeSubscription = this._contextChanged$.pipe((0, rxjs.filter)((event) => typeof event[key] !== "undefined")).subscribe((event) => observer.next(event[key]));
3503
+ if (this._contextMap.has(key)) observer.next(this._contextMap.get(key));
3504
+ return () => contextChangeSubscription.unsubscribe();
3505
+ });
3506
+ }
3507
+ };
3508
+
3509
+ //#endregion
3510
+ //#region src/services/log/log.service.ts
3511
+ /**
3512
+ * Copyright 2023-present DreamNum Co., Ltd.
3513
+ *
3514
+ * Licensed under the Apache License, Version 2.0 (the "License");
3515
+ * you may not use this file except in compliance with the License.
3516
+ * You may obtain a copy of the License at
3517
+ *
3518
+ * http://www.apache.org/licenses/LICENSE-2.0
3519
+ *
3520
+ * Unless required by applicable law or agreed to in writing, software
3521
+ * distributed under the License is distributed on an "AS IS" BASIS,
3522
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3523
+ * See the License for the specific language governing permissions and
3524
+ * limitations under the License.
3525
+ */
3526
+ let LogLevel = /* @__PURE__ */ function(LogLevel) {
3527
+ LogLevel[LogLevel["SILENT"] = 0] = "SILENT";
3528
+ LogLevel[LogLevel["ERROR"] = 1] = "ERROR";
3529
+ LogLevel[LogLevel["WARN"] = 2] = "WARN";
3530
+ LogLevel[LogLevel["INFO"] = 3] = "INFO";
3531
+ LogLevel[LogLevel["VERBOSE"] = 4] = "VERBOSE";
3532
+ return LogLevel;
3533
+ }({});
3534
+ const ILogService = (0, _wendellhu_redi.createIdentifier)("univer.log");
3535
+ var DesktopLogService = class extends Disposable {
3536
+ constructor(..._args) {
3537
+ super(..._args);
3538
+ _defineProperty(this, "_logLevel", 3);
3539
+ _defineProperty(this, "_deduction", /* @__PURE__ */ new Set());
3540
+ }
3541
+ dispose() {
3542
+ super.dispose();
3543
+ this._logLevel = 3;
3544
+ this._deduction.clear();
3545
+ }
3546
+ debug(...args) {
3547
+ if (this._logLevel >= 4) this._log(console.debug, ...args);
3548
+ }
3549
+ log(...args) {
3550
+ if (this._logLevel >= 3) this._log(console.log, ...args);
3551
+ }
3552
+ warn(...args) {
3553
+ if (this._logLevel >= 2) this._log(console.warn, ...args);
3554
+ }
3555
+ error(...args) {
3556
+ if (this._logLevel >= 1) this._log(console.error, ...args);
3557
+ }
3558
+ deprecate(...args) {
3559
+ if (this._logLevel >= 2) this._logWithDeduplication(console.error, ...args);
3560
+ }
3561
+ setLogLevel(logLevel) {
3562
+ this._logLevel = logLevel;
3563
+ }
3564
+ _log(method, ...args) {
3565
+ const firstArg = args[0];
3566
+ if (/^\[(.*?)\]/g.test(firstArg)) method(`\x1B[97;104m${firstArg}\x1B[0m`, ...args.slice(1));
3567
+ else method(...args);
3568
+ }
3225
3569
  _logWithDeduplication(method, ...args) {
3226
3570
  const hashed = hashLogContent(...args);
3227
3571
  if (this._deduction.has(hashed)) return;
@@ -3234,7 +3578,7 @@ function hashLogContent(...args) {
3234
3578
  }
3235
3579
 
3236
3580
  //#endregion
3237
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
3581
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
3238
3582
  function __decorateParam(paramIndex, decorator) {
3239
3583
  return function(target, key) {
3240
3584
  decorator(target, key, paramIndex);
@@ -3242,7 +3586,7 @@ function __decorateParam(paramIndex, decorator) {
3242
3586
  }
3243
3587
 
3244
3588
  //#endregion
3245
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
3589
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
3246
3590
  function __decorate(decorators, target, key, desc) {
3247
3591
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3248
3592
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4980,11 +5324,10 @@ function getCellValueType(cell) {
4980
5324
  }
4981
5325
  function isNullCell(cell) {
4982
5326
  if (cell == null) return true;
4983
- const { v, f, si, p, custom } = cell;
5327
+ const { v, f, si, p } = cell;
4984
5328
  if (!(v == null || typeof v === "string" && v.length === 0)) return false;
4985
5329
  if (f != null && f.length > 0 || si != null && si.length > 0) return false;
4986
5330
  if (p != null) return false;
4987
- if (custom != null) return false;
4988
5331
  return true;
4989
5332
  }
4990
5333
  function isCellV(cell) {
@@ -5092,23 +5435,6 @@ let CellModeEnum = /* @__PURE__ */ function(CellModeEnum) {
5092
5435
  return CellModeEnum;
5093
5436
  }({});
5094
5437
 
5095
- //#endregion
5096
- //#region src/types/const/theme-color-map.ts
5097
- const THEME_COLORS = { ["Office"]: {
5098
- [4]: "#4472C4",
5099
- [5]: "#ED7D31",
5100
- [6]: "#A5A5A5",
5101
- [7]: "#70AD47",
5102
- [8]: "#5B9BD5",
5103
- [9]: "#70AD47",
5104
- [0]: "#000000",
5105
- [2]: "#44546A",
5106
- [1]: "#FFFFFF",
5107
- [3]: "#E7E6E6",
5108
- [10]: "#0563C1",
5109
- [11]: "#954F72"
5110
- } };
5111
-
5112
5438
  //#endregion
5113
5439
  //#region src/shared/numfmt.ts
5114
5440
  /**
@@ -5168,16 +5494,42 @@ const isPatternEqualWithoutDecimal = (patternA, patternB) => {
5168
5494
  };
5169
5495
  const ignoreCommonPatterns = new Set(["m d"]);
5170
5496
  const ignoreAMPMPatterns = new Set(["h:mm AM/PM", "hh:mm AM/PM"]);
5171
- const currencySymbols = new Set([
5497
+ const currencySymbols = [
5498
+ "Rp",
5499
+ "zł",
5500
+ "NT$",
5501
+ "R$",
5502
+ "HK$",
5172
5503
  "$",
5504
+ "£",
5173
5505
  "¥",
5174
- "",
5506
+ "¤",
5507
+ "֏",
5508
+ "؋",
5509
+ "৳",
5510
+ "฿",
5511
+ "៛",
5512
+ "₡",
5513
+ "₦",
5514
+ "₩",
5515
+ "₪",
5175
5516
  "₫",
5176
- "NT$",
5177
5517
  "€",
5178
- "",
5518
+ "",
5519
+ "₮",
5520
+ "₱",
5521
+ "₲",
5522
+ "₴",
5523
+ "₸",
5524
+ "₹",
5525
+ "₺",
5526
+ "₼",
5527
+ "₽",
5528
+ "₾",
5529
+ "₿",
5179
5530
  "﷼"
5180
- ]);
5531
+ ];
5532
+ const currencySymbolSet = new Set(currencySymbols);
5181
5533
  /**
5182
5534
  * Get the numfmt parse value, and filter out the parse error.
5183
5535
  */
@@ -5207,7 +5559,7 @@ const getNumfmtParseValueFilter = (value) => {
5207
5559
  */
5208
5560
  if (z.includes("#,##0")) {
5209
5561
  if (/[.,]$/.test(value)) return null;
5210
- const normalized = value.replace(new RegExp(`^[${[...currencySymbols].join("")}]+`), "").trim();
5562
+ const normalized = value.replace(new RegExp(`^[${[...currencySymbolSet].join("")}]+`), "").trim();
5211
5563
  if (normalized.includes(",")) {
5212
5564
  if (!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(normalized)) return null;
5213
5565
  }
@@ -6669,26 +7021,11 @@ function mergeIntervals(intervals) {
6669
7021
  }
6670
7022
  }
6671
7023
  merged.push([currentStart, currentEnd]);
6672
- return merged;
6673
- }
6674
-
6675
- //#endregion
6676
- //#region src/shared/locale.ts
6677
- /**
6678
- * Copyright 2023-present DreamNum Co., Ltd.
6679
- *
6680
- * Licensed under the Apache License, Version 2.0 (the "License");
6681
- * you may not use this file except in compliance with the License.
6682
- * You may obtain a copy of the License at
6683
- *
6684
- * http://www.apache.org/licenses/LICENSE-2.0
6685
- *
6686
- * Unless required by applicable law or agreed to in writing, software
6687
- * distributed under the License is distributed on an "AS IS" BASIS,
6688
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6689
- * See the License for the specific language governing permissions and
6690
- * limitations under the License.
6691
- */
7024
+ return merged;
7025
+ }
7026
+
7027
+ //#endregion
7028
+ //#region src/shared/locale.ts
6692
7029
  /**
6693
7030
  * Merges multiple locale objects into a single locale object.
6694
7031
  * It can accept either multiple locale objects as arguments or a single array of locale objects.
@@ -6699,7 +7036,7 @@ function mergeLocales(...locales) {
6699
7036
  let mergedLocales;
6700
7037
  if (locales.length === 1 && Array.isArray(locales[0])) mergedLocales = locales[0];
6701
7038
  else mergedLocales = locales;
6702
- return (0, lodash_es.merge)({}, ...mergedLocales);
7039
+ return Object.assign({}, ...mergedLocales);
6703
7040
  }
6704
7041
 
6705
7042
  //#endregion
@@ -6922,337 +7259,92 @@ var LRUMap = class {
6922
7259
  return e ? e.value : void 0;
6923
7260
  }
6924
7261
  delete(key) {
6925
- const entry = this._keymap.get(key);
6926
- if (!entry) return;
6927
- this._keymap.delete(entry.key);
6928
- if (entry[NEWER] && entry[OLDER]) {
6929
- entry[OLDER][NEWER] = entry[NEWER];
6930
- entry[NEWER][OLDER] = entry[OLDER];
6931
- } else if (entry[NEWER]) {
6932
- entry[NEWER][OLDER] = void 0;
6933
- this.oldest = entry[NEWER];
6934
- } else if (entry[OLDER]) {
6935
- entry[OLDER][NEWER] = void 0;
6936
- this.newest = entry[OLDER];
6937
- } else this.oldest = this.newest = void 0;
6938
- this.size--;
6939
- return entry.value;
6940
- }
6941
- clear() {
6942
- this.oldest = void 0;
6943
- this.newest = void 0;
6944
- this.size = 0;
6945
- this._keymap.clear();
6946
- }
6947
- keys() {
6948
- return new KeyIterator(this.oldest);
6949
- }
6950
- values() {
6951
- return new ValueIterator(this.oldest);
6952
- }
6953
- entries() {
6954
- return this[Symbol.iterator]();
6955
- }
6956
- [_Symbol$iterator4]() {
6957
- return new EntryIterator(this.oldest);
6958
- }
6959
- forEach(fun, thisObj) {
6960
- if (typeof thisObj !== "object") thisObj = this;
6961
- let entry = this.oldest;
6962
- while (entry) {
6963
- fun.call(thisObj, entry.value, entry.key, this);
6964
- entry = entry[NEWER];
6965
- }
6966
- }
6967
- toJSON() {
6968
- const s = new Array(this.size);
6969
- let i = 0;
6970
- let entry = this.oldest;
6971
- while (entry) {
6972
- s[i++] = {
6973
- key: entry.key,
6974
- value: entry.value
6975
- };
6976
- entry = entry[NEWER];
6977
- }
6978
- return s;
6979
- }
6980
- toString() {
6981
- let s = String();
6982
- let entry = this.oldest;
6983
- while (entry) {
6984
- s += `${String(entry.key)}:${entry.value}`;
6985
- entry = entry[NEWER];
6986
- if (entry) s += " < ";
6987
- }
6988
- return s;
6989
- }
6990
- };
6991
- var LRUHelper = class {
6992
- static hasLength(array, size) {
6993
- return array.length === size;
6994
- }
6995
- static getValueType(value) {
6996
- return Object.prototype.toString.apply(value);
6997
- }
6998
- static isObject(value) {
6999
- return this.getValueType(value) === "[object Object]";
7000
- }
7001
- static isIterable(value) {
7002
- return value[Symbol.iterator] != null;
7003
- }
7004
- static isNumber(value) {
7005
- return this.getValueType(value) === "[object Number]";
7006
- }
7007
- };
7008
-
7009
- //#endregion
7010
- //#region src/shared/max-row-column.ts
7011
- /**
7012
- * Copyright 2023-present DreamNum Co., Ltd.
7013
- *
7014
- * Licensed under the Apache License, Version 2.0 (the "License");
7015
- * you may not use this file except in compliance with the License.
7016
- * You may obtain a copy of the License at
7017
- *
7018
- * http://www.apache.org/licenses/LICENSE-2.0
7019
- *
7020
- * Unless required by applicable law or agreed to in writing, software
7021
- * distributed under the License is distributed on an "AS IS" BASIS,
7022
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7023
- * See the License for the specific language governing permissions and
7024
- * limitations under the License.
7025
- */
7026
- /**
7027
- * Convert Excel column label to number
7028
- * @param label Column label (e.g., "A", "Z", "AA", "XFD")
7029
- * @returns Column number (e.g., 1, 26, 27, 16384)
7030
- */
7031
- function columnLabelToNumber(label) {
7032
- let n = 0;
7033
- for (let i = 0; i < label.length; i++) {
7034
- const c = label.charCodeAt(i);
7035
- if (c < 65 || c > 90) return -1;
7036
- n = n * 26 + (c - 64);
7037
- }
7038
- return n;
7039
- }
7040
- /**
7041
- * Maximum number of rows and columns in Excel
7042
- * Rows: 1,048,576
7043
- * Columns: 16,384 (equivalent to column XFD)
7044
- */
7045
- const MAX_ROW_COUNT = 1048576;
7046
- const MAX_COLUMN_COUNT = 16384;
7047
-
7048
- //#endregion
7049
- //#region src/types/const/const.ts
7050
- /**
7051
- * Used as an illegal range array return value
7052
- */
7053
- const DEFAULT_RANGE_ARRAY = {
7054
- sheetId: "",
7055
- range: {
7056
- startRow: -1,
7057
- endRow: -1,
7058
- startColumn: -1,
7059
- endColumn: -1
7060
- }
7061
- };
7062
- /**
7063
- * Used as an illegal range return value
7064
- */
7065
- const DEFAULT_RANGE = {
7066
- startRow: -1,
7067
- startColumn: -1,
7068
- endRow: -1,
7069
- endColumn: -1
7070
- };
7071
- /**
7072
- * Used as an init selection return value
7073
- */
7074
- const DEFAULT_SELECTION = {
7075
- startRow: 0,
7076
- startColumn: 0,
7077
- endRow: 0,
7078
- endColumn: 0
7079
- };
7080
- /**
7081
- * Used as an init cell return value
7082
- */
7083
- const DEFAULT_CELL = {
7084
- row: 0,
7085
- column: 0
7086
- };
7087
- /**
7088
- * Default styles.
7089
- */
7090
- const DEFAULT_STYLES = {
7091
- /**
7092
- * fontFamily
7093
- */
7094
- ff: "Arial",
7095
- /**
7096
- * fontSize
7097
- */
7098
- fs: 11,
7099
- /**
7100
- * italic
7101
- * 0: false
7102
- * 1: true
7103
- */
7104
- it: 0,
7105
- /**
7106
- * bold
7107
- * 0: false
7108
- * 1: true
7109
- */
7110
- bl: 0,
7111
- /**
7112
- * underline
7113
- */
7114
- ul: { s: 0 },
7115
- /**
7116
- * strikethrough
7117
- */
7118
- st: { s: 0 },
7119
- /**
7120
- * overline
7121
- */
7122
- ol: { s: 0 },
7123
- /**
7124
- * textRotation
7125
- */
7126
- tr: {
7127
- a: 0,
7128
- /**
7129
- * true : 1
7130
- * false : 0
7131
- */
7132
- v: 0
7133
- },
7134
- /**
7135
- * textDirection
7136
- */
7137
- td: 0,
7138
- /**
7139
- * color
7140
- */
7141
- cl: { rgb: "#000000" },
7142
- /**
7143
- * background
7144
- */
7145
- bg: { rgb: "#fff" },
7146
- /**
7147
- * horizontalAlignment
7148
- */
7149
- ht: 0,
7150
- /**
7151
- * verticalAlignment
7152
- */
7153
- vt: 0,
7154
- /**
7155
- * wrapStrategy
7156
- */
7157
- tb: 0,
7158
- /**
7159
- * padding
7160
- */
7161
- pd: {
7162
- t: 0,
7163
- r: 0,
7164
- b: 0,
7165
- l: 0
7166
- },
7167
- n: null,
7168
- /**
7169
- * border
7170
- */
7171
- bd: {
7172
- b: null,
7173
- l: null,
7174
- r: null,
7175
- t: null
7262
+ const entry = this._keymap.get(key);
7263
+ if (!entry) return;
7264
+ this._keymap.delete(entry.key);
7265
+ if (entry[NEWER] && entry[OLDER]) {
7266
+ entry[OLDER][NEWER] = entry[NEWER];
7267
+ entry[NEWER][OLDER] = entry[OLDER];
7268
+ } else if (entry[NEWER]) {
7269
+ entry[NEWER][OLDER] = void 0;
7270
+ this.oldest = entry[NEWER];
7271
+ } else if (entry[OLDER]) {
7272
+ entry[OLDER][NEWER] = void 0;
7273
+ this.newest = entry[OLDER];
7274
+ } else this.oldest = this.newest = void 0;
7275
+ this.size--;
7276
+ return entry.value;
7277
+ }
7278
+ clear() {
7279
+ this.oldest = void 0;
7280
+ this.newest = void 0;
7281
+ this.size = 0;
7282
+ this._keymap.clear();
7283
+ }
7284
+ keys() {
7285
+ return new KeyIterator(this.oldest);
7286
+ }
7287
+ values() {
7288
+ return new ValueIterator(this.oldest);
7289
+ }
7290
+ entries() {
7291
+ return this[Symbol.iterator]();
7292
+ }
7293
+ [_Symbol$iterator4]() {
7294
+ return new EntryIterator(this.oldest);
7295
+ }
7296
+ forEach(fun, thisObj) {
7297
+ if (typeof thisObj !== "object") thisObj = this;
7298
+ let entry = this.oldest;
7299
+ while (entry) {
7300
+ fun.call(thisObj, entry.value, entry.key, this);
7301
+ entry = entry[NEWER];
7302
+ }
7303
+ }
7304
+ toJSON() {
7305
+ const s = new Array(this.size);
7306
+ let i = 0;
7307
+ let entry = this.oldest;
7308
+ while (entry) {
7309
+ s[i++] = {
7310
+ key: entry.key,
7311
+ value: entry.value
7312
+ };
7313
+ entry = entry[NEWER];
7314
+ }
7315
+ return s;
7316
+ }
7317
+ toString() {
7318
+ let s = String();
7319
+ let entry = this.oldest;
7320
+ while (entry) {
7321
+ s += `${String(entry.key)}:${entry.value}`;
7322
+ entry = entry[NEWER];
7323
+ if (entry) s += " < ";
7324
+ }
7325
+ return s;
7176
7326
  }
7177
7327
  };
7178
- const SHEET_EDITOR_UNITS = [
7179
- DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
7180
- DOCS_ZEN_EDITOR_UNIT_ID_KEY,
7181
- DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY
7182
- ];
7183
- const NAMED_STYLE_MAP = {
7184
- [4]: {
7185
- fs: 20,
7186
- bl: 1
7187
- },
7188
- [5]: {
7189
- fs: 18,
7190
- bl: 1
7191
- },
7192
- [6]: {
7193
- fs: 16,
7194
- bl: 1
7195
- },
7196
- [7]: {
7197
- fs: 14,
7198
- bl: 1
7199
- },
7200
- [8]: {
7201
- fs: 12,
7202
- bl: 1
7203
- },
7204
- [1]: null,
7205
- [2]: {
7206
- fs: 26,
7207
- bl: 1
7208
- },
7209
- [3]: {
7210
- fs: 15,
7211
- cl: { rgb: "#999999" }
7212
- },
7213
- [0]: null
7214
- };
7215
- const BOTTOM_P = 4;
7216
- const NAMED_STYLE_SPACE_MAP = {
7217
- [4]: {
7218
- spaceAbove: { v: 20 },
7219
- spaceBelow: { v: 6 + BOTTOM_P }
7220
- },
7221
- [5]: {
7222
- spaceAbove: { v: 18 },
7223
- spaceBelow: { v: 6 + BOTTOM_P }
7224
- },
7225
- [6]: {
7226
- spaceAbove: { v: 16 },
7227
- spaceBelow: { v: 6 + BOTTOM_P }
7228
- },
7229
- [7]: {
7230
- spaceAbove: { v: 14 },
7231
- spaceBelow: { v: 4 + BOTTOM_P }
7232
- },
7233
- [8]: {
7234
- spaceAbove: { v: 12 },
7235
- spaceBelow: { v: 4 + BOTTOM_P }
7236
- },
7237
- [1]: {
7238
- spaceAbove: { v: 0 },
7239
- spaceBelow: { v: 0 }
7240
- },
7241
- [2]: {
7242
- spaceAbove: { v: 0 },
7243
- spaceBelow: { v: 3 + BOTTOM_P }
7244
- },
7245
- [3]: {
7246
- spaceAbove: { v: 0 },
7247
- spaceBelow: { v: 16 }
7248
- },
7249
- [0]: null
7328
+ var LRUHelper = class {
7329
+ static hasLength(array, size) {
7330
+ return array.length === size;
7331
+ }
7332
+ static getValueType(value) {
7333
+ return Object.prototype.toString.apply(value);
7334
+ }
7335
+ static isObject(value) {
7336
+ return this.getValueType(value) === "[object Object]";
7337
+ }
7338
+ static isIterable(value) {
7339
+ return value[Symbol.iterator] != null;
7340
+ }
7341
+ static isNumber(value) {
7342
+ return this.getValueType(value) === "[object Number]";
7343
+ }
7250
7344
  };
7251
- const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
7252
- const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
7253
7345
 
7254
7346
  //#endregion
7255
- //#region src/types/const/extension-names.ts
7347
+ //#region src/shared/max-row-column.ts
7256
7348
  /**
7257
7349
  * Copyright 2023-present DreamNum Co., Ltd.
7258
7350
  *
@@ -7268,60 +7360,27 @@ const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
7268
7360
  * See the License for the specific language governing permissions and
7269
7361
  * limitations under the License.
7270
7362
  */
7271
- let EXTENSION_NAMES = /* @__PURE__ */ function(EXTENSION_NAMES) {
7272
- EXTENSION_NAMES["ARRAY_CONVERTOR"] = "ARRAY_CONVERTOR";
7273
- EXTENSION_NAMES["MATRIX_CONVERTOR"] = "MATRIX_CONVERTOR";
7274
- return EXTENSION_NAMES;
7275
- }({});
7276
-
7277
- //#endregion
7278
- //#region src/types/const/page-size.ts
7279
- const PAGE_SIZE = {
7280
- ["A3"]: {
7281
- width: 1123,
7282
- height: 1587
7283
- },
7284
- ["A4"]: {
7285
- width: 794,
7286
- height: 1124
7287
- },
7288
- ["A5"]: {
7289
- width: 559,
7290
- height: 794
7291
- },
7292
- ["B4"]: {
7293
- width: 944,
7294
- height: 1344
7295
- },
7296
- ["B5"]: {
7297
- width: 665,
7298
- height: 944
7299
- },
7300
- ["Executive"]: {
7301
- width: 696,
7302
- height: 1008
7303
- },
7304
- ["Folio"]: {
7305
- width: 816,
7306
- height: 1248
7307
- },
7308
- ["Legal"]: {
7309
- width: 816,
7310
- height: 1344
7311
- },
7312
- ["Letter"]: {
7313
- width: 816,
7314
- height: 1056
7315
- },
7316
- ["Statement"]: {
7317
- width: 528,
7318
- height: 816
7319
- },
7320
- ["Tabloid"]: {
7321
- width: 1056,
7322
- height: 1632
7363
+ /**
7364
+ * Convert Excel column label to number
7365
+ * @param label Column label (e.g., "A", "Z", "AA", "XFD")
7366
+ * @returns Column number (e.g., 1, 26, 27, 16384)
7367
+ */
7368
+ function columnLabelToNumber(label) {
7369
+ let n = 0;
7370
+ for (let i = 0; i < label.length; i++) {
7371
+ const c = label.charCodeAt(i);
7372
+ if (c < 65 || c > 90) return -1;
7373
+ n = n * 26 + (c - 64);
7323
7374
  }
7324
- };
7375
+ return n;
7376
+ }
7377
+ /**
7378
+ * Maximum number of rows and columns in Excel
7379
+ * Rows: 1,048,576
7380
+ * Columns: 16,384 (equivalent to column XFD)
7381
+ */
7382
+ const MAX_ROW_COUNT = 1048576;
7383
+ const MAX_COLUMN_COUNT = 16384;
7325
7384
 
7326
7385
  //#endregion
7327
7386
  //#region src/sheets/range.ts
@@ -8816,7 +8875,7 @@ function ABCToNumber(a) {
8816
8875
  return numOut - 1;
8817
8876
  }
8818
8877
  const orderA = "A".charCodeAt(0);
8819
- const orderZ = "Z".charCodeAt(0);
8878
+ "Z".charCodeAt(0);
8820
8879
  const order_a = "a".charCodeAt(0);
8821
8880
  "z".charCodeAt(0);
8822
8881
  /**
@@ -8825,7 +8884,7 @@ const order_a = "a".charCodeAt(0);
8825
8884
  * @returns
8826
8885
  */
8827
8886
  function numberToABC(n) {
8828
- const len = orderZ - orderA + 1;
8887
+ const len = 26;
8829
8888
  let s = "";
8830
8889
  while (n >= 0) {
8831
8890
  s = String.fromCharCode(n % len + orderA) + s;
@@ -8854,7 +8913,7 @@ function repeatStringNumTimes(string, times) {
8854
8913
  * @returns
8855
8914
  */
8856
8915
  function numberToListABC(n, uppercase = false) {
8857
- const len = orderZ - orderA + 1;
8916
+ const len = 26;
8858
8917
  let order = order_a;
8859
8918
  if (uppercase) order = orderA;
8860
8919
  return repeatStringNumTimes(String.fromCharCode(n % len + order), Math.floor(n / len) + 1);
@@ -9077,6 +9136,30 @@ function insertTables(body, insertBody, textLength, currentIndex) {
9077
9136
  tables.sort(sortRulesFactory("startIndex"));
9078
9137
  }
9079
9138
  }
9139
+ function insertBlockRanges(body, insertBody, textLength, currentIndex) {
9140
+ var _insertBody$blockRang;
9141
+ if (!body.blockRanges && !((_insertBody$blockRang = insertBody.blockRanges) === null || _insertBody$blockRang === void 0 ? void 0 : _insertBody$blockRang.length)) return;
9142
+ if (!body.blockRanges) body.blockRanges = [];
9143
+ const { blockRanges } = body;
9144
+ for (let i = 0, len = blockRanges.length; i < len; i++) {
9145
+ const blockRange = blockRanges[i];
9146
+ const { startIndex, endIndex } = blockRange;
9147
+ if (startIndex >= currentIndex) {
9148
+ blockRange.startIndex += textLength;
9149
+ blockRange.endIndex += textLength;
9150
+ } else if (endIndex >= currentIndex) blockRange.endIndex += textLength;
9151
+ }
9152
+ const insertBlockRanges = insertBody.blockRanges;
9153
+ if (insertBlockRanges) {
9154
+ for (let i = 0, len = insertBlockRanges.length; i < len; i++) {
9155
+ const blockRange = insertBlockRanges[i];
9156
+ blockRange.startIndex += currentIndex;
9157
+ blockRange.endIndex += currentIndex;
9158
+ }
9159
+ blockRanges.push(...insertBlockRanges);
9160
+ blockRanges.sort(sortRulesFactory("startIndex"));
9161
+ }
9162
+ }
9080
9163
  const ID_SPLIT_SYMBOL = "$";
9081
9164
  const getRootId = (id) => id.split(ID_SPLIT_SYMBOL)[0];
9082
9165
  function mergeContinuousRanges(ranges) {
@@ -9412,6 +9495,37 @@ function deleteCustomRanges(body, textLength, currentIndex) {
9412
9495
  }
9413
9496
  return removeCustomRanges;
9414
9497
  }
9498
+ function deleteBlockRanges(body, textLength, currentIndex) {
9499
+ const { blockRanges } = body;
9500
+ const startIndex = currentIndex;
9501
+ const endIndex = currentIndex + textLength - 1;
9502
+ const removeBlockRanges = [];
9503
+ if (blockRanges) {
9504
+ const newBlockRanges = [];
9505
+ for (let i = 0, len = blockRanges.length; i < len; i++) {
9506
+ const blockRange = blockRanges[i];
9507
+ const { startIndex: st, endIndex: ed } = blockRange;
9508
+ if (st >= startIndex && ed <= endIndex) {
9509
+ removeBlockRanges.push(blockRange);
9510
+ continue;
9511
+ } else if (Math.max(startIndex, st) <= Math.min(endIndex, ed)) {
9512
+ const segments = horizontalLineSegmentsSubtraction(st, ed, startIndex, endIndex);
9513
+ if (segments.length === 0) {
9514
+ removeBlockRanges.push(blockRange);
9515
+ continue;
9516
+ }
9517
+ blockRange.startIndex = segments[0];
9518
+ blockRange.endIndex = segments[1];
9519
+ } else if (endIndex < st) {
9520
+ blockRange.startIndex -= textLength;
9521
+ blockRange.endIndex -= textLength;
9522
+ }
9523
+ newBlockRanges.push(blockRange);
9524
+ }
9525
+ body.blockRanges = newBlockRanges;
9526
+ }
9527
+ return removeBlockRanges;
9528
+ }
9415
9529
  function deleteCustomDecorations(body, textLength, currentIndex, needOffset = true) {
9416
9530
  const { customDecorations } = body;
9417
9531
  const startIndex = currentIndex;
@@ -9878,6 +9992,7 @@ function updateAttribute(body, updateBody, textLength, currentIndex, coverType)
9878
9992
  sectionBreaks: updateSectionBreaks(body, updateBody, textLength, currentIndex, coverType),
9879
9993
  customBlocks: updateCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
9880
9994
  tables: updateTables(body, updateBody, textLength, currentIndex, coverType),
9995
+ blockRanges: updateBlockRanges(body, updateBody, textLength, currentIndex, coverType),
9881
9996
  customRanges: updateCustomRanges(body, updateBody, textLength, currentIndex, coverType),
9882
9997
  customDecorations: updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType)
9883
9998
  };
@@ -10119,6 +10234,21 @@ function updateTables(body, updateBody, textLength, currentIndex, coverType) {
10119
10234
  insertTables(body, updateBody, textLength, currentIndex);
10120
10235
  return removeTables;
10121
10236
  }
10237
+ function updateBlockRanges(body, updateBody, textLength, currentIndex, coverType) {
10238
+ const { blockRanges } = body;
10239
+ const { blockRanges: updateDataBlockRanges } = updateBody;
10240
+ if (blockRanges == null || updateDataBlockRanges == null) return;
10241
+ const removeBlockRanges = deleteBlockRanges(body, textLength, currentIndex);
10242
+ if (coverType !== 1) updateBody.blockRanges = updateDataBlockRanges.map((updateBlockRange) => {
10243
+ const removeBlockRange = removeBlockRanges.find((blockRange) => blockRange.blockId === updateBlockRange.blockId);
10244
+ return removeBlockRange ? {
10245
+ ...removeBlockRange,
10246
+ ...updateBlockRange
10247
+ } : updateBlockRange;
10248
+ });
10249
+ insertBlockRanges(body, updateBody, textLength, currentIndex);
10250
+ return removeBlockRanges;
10251
+ }
10122
10252
  function updateCustomRanges(body, updateBody, textLength, currentIndex, _coverType) {
10123
10253
  if (!body.customRanges) body.customRanges = [];
10124
10254
  splitCustomRangesByIndex(body.customRanges, currentIndex);
@@ -10233,21 +10363,50 @@ function getTableSlice(body, startOffset, endOffset) {
10233
10363
  for (const table of tables) {
10234
10364
  const clonedTable = Tools.deepClone(table);
10235
10365
  const { startIndex, endIndex } = clonedTable;
10236
- if (startIndex >= startOffset && endIndex <= endOffset) newTables.push({
10366
+ if (Math.max(startIndex, startOffset) < Math.min(endIndex, endOffset)) newTables.push({
10237
10367
  ...clonedTable,
10368
+ startIndex: Math.max(startIndex, startOffset) - startOffset,
10369
+ endIndex: Math.min(endIndex, endOffset) - startOffset
10370
+ });
10371
+ }
10372
+ return newTables;
10373
+ }
10374
+ function getBlockRangeSlice(body, startOffset, endOffset) {
10375
+ const { blockRanges = [] } = body;
10376
+ const newBlockRanges = [];
10377
+ for (const blockRange of blockRanges) {
10378
+ const clonedBlockRange = Tools.deepClone(blockRange);
10379
+ const { startIndex, endIndex } = clonedBlockRange;
10380
+ if (startIndex >= startOffset && endIndex < endOffset) newBlockRanges.push({
10381
+ ...clonedBlockRange,
10238
10382
  startIndex: startIndex - startOffset,
10239
10383
  endIndex: endIndex - startOffset
10240
10384
  });
10241
10385
  }
10242
- return newTables;
10386
+ return newBlockRanges;
10243
10387
  }
10244
- function getParagraphsSlice(body, startOffset, endOffset) {
10388
+ function getParagraphsSlice(body, startOffset, endOffset, type = 1) {
10245
10389
  const { paragraphs = [] } = body;
10246
10390
  const newParagraphs = [];
10247
- for (const paragraph of paragraphs) {
10248
- const { startIndex } = paragraph;
10249
- if (startIndex >= startOffset && startIndex < endOffset) {
10391
+ if (type === 1) {
10392
+ for (const paragraph of paragraphs) {
10393
+ const { startIndex } = paragraph;
10394
+ if (startIndex >= startOffset && startIndex < endOffset) newParagraphs.push(Tools.deepClone(paragraph));
10395
+ }
10396
+ if (newParagraphs.length) return newParagraphs.map((p) => ({
10397
+ ...p,
10398
+ startIndex: p.startIndex - startOffset
10399
+ }));
10400
+ return;
10401
+ }
10402
+ const sortedParagraphs = [...paragraphs].sort((a, b) => a.startIndex - b.startIndex);
10403
+ for (let index = 0; index < sortedParagraphs.length; index++) {
10404
+ const paragraph = sortedParagraphs[index];
10405
+ const paragraphStart = index > 0 ? sortedParagraphs[index - 1].startIndex + 1 : 0;
10406
+ const paragraphEnd = paragraph.startIndex;
10407
+ if (paragraphEnd >= startOffset && paragraphEnd < endOffset || Math.max(paragraphStart, startOffset) < Math.min(paragraphEnd, endOffset)) {
10250
10408
  const copy = Tools.deepClone(paragraph);
10409
+ copy.startIndex = Math.min(Math.max(paragraphEnd, startOffset), endOffset);
10251
10410
  newParagraphs.push(copy);
10252
10411
  }
10253
10412
  }
@@ -10286,7 +10445,9 @@ function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, typ
10286
10445
  docBody.textRuns = getTextRunSlice(body, startOffset, endOffset, returnEmptyArray);
10287
10446
  const newTables = getTableSlice(body, startOffset, endOffset);
10288
10447
  if (newTables.length) docBody.tables = newTables;
10289
- docBody.paragraphs = getParagraphsSlice(body, startOffset, endOffset);
10448
+ const newBlockRanges = getBlockRangeSlice(body, startOffset, endOffset);
10449
+ if (newBlockRanges.length) docBody.blockRanges = newBlockRanges;
10450
+ docBody.paragraphs = getParagraphsSlice(body, startOffset, endOffset, type);
10290
10451
  if (type === 1) {
10291
10452
  const customDecorations = getCustomDecorationSlice(body, startOffset, endOffset);
10292
10453
  if (customDecorations) docBody.customDecorations = customDecorations;
@@ -10299,7 +10460,7 @@ function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, typ
10299
10460
  return docBody;
10300
10461
  }
10301
10462
  function normalizeBody(body) {
10302
- const { dataStream, textRuns, paragraphs, customRanges, customDecorations, tables } = body;
10463
+ const { dataStream, textRuns, paragraphs, customRanges, customDecorations, tables, blockRanges } = body;
10303
10464
  let leftOffset = 0;
10304
10465
  let rightOffset = 0;
10305
10466
  customRanges === null || customRanges === void 0 || customRanges.forEach((range) => {
@@ -10337,7 +10498,8 @@ function normalizeBody(body) {
10337
10498
  paragraphs,
10338
10499
  customRanges,
10339
10500
  customDecorations,
10340
- tables
10501
+ tables,
10502
+ blockRanges
10341
10503
  };
10342
10504
  }
10343
10505
  function getCustomRangeSlice(body, startOffset, endOffset) {
@@ -10399,8 +10561,8 @@ function composeCustomDecorations(updateDataCustomDecorations, originCustomDecor
10399
10561
  function composeBody(thisBody, otherBody, coverType = 0) {
10400
10562
  if (otherBody.dataStream !== "") throw new Error("Cannot compose other body with non-empty dataStream");
10401
10563
  const retBody = { dataStream: thisBody.dataStream };
10402
- const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations = [] } = thisBody;
10403
- const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations = [] } = otherBody;
10564
+ const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations = [], blockRanges: thisBlockRanges = [] } = thisBody;
10565
+ const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations = [], blockRanges: otherBlockRanges = [] } = otherBody;
10404
10566
  retBody.textRuns = composeTextRuns(otherTextRuns, thisTextRuns, coverType);
10405
10567
  retBody.customRanges = composeCustomRanges(otherCustomRanges, thisCustomRanges, coverType);
10406
10568
  const customDecorations = composeCustomDecorations(otherCustomDecorations, thisCustomDecorations, coverType);
@@ -10428,13 +10590,22 @@ function composeBody(thisBody, otherBody, coverType = 0) {
10428
10590
  if (thisIndex < thisParagraphs.length) paragraphs.push(...thisParagraphs.slice(thisIndex));
10429
10591
  if (otherIndex < otherParagraphs.length) paragraphs.push(...otherParagraphs.slice(otherIndex));
10430
10592
  if (paragraphs.length) retBody.paragraphs = paragraphs;
10593
+ const blockRanges = composeDocumentBlockRanges(thisBlockRanges, otherBlockRanges);
10594
+ if (blockRanges.length) retBody.blockRanges = blockRanges;
10431
10595
  return retBody;
10432
10596
  }
10597
+ function composeDocumentBlockRanges(thisRanges, otherRanges) {
10598
+ if (!thisRanges.length) return otherRanges;
10599
+ if (!otherRanges.length) return thisRanges;
10600
+ const byId = new Map(thisRanges.map((range) => [range.blockId, Tools.deepClone(range)]));
10601
+ otherRanges.forEach((range) => byId.set(range.blockId, Tools.deepClone(range)));
10602
+ return Array.from(byId.values()).sort((left, right) => left.startIndex - right.startIndex);
10603
+ }
10433
10604
  function isUselessRetainAction(action) {
10434
10605
  const { body } = action;
10435
10606
  if (body == null) return true;
10436
- const { textRuns, paragraphs, customRanges, customBlocks, customDecorations, tables } = body;
10437
- if (textRuns == null && paragraphs == null && customRanges == null && customBlocks == null && customDecorations == null && tables == null) return true;
10607
+ const { textRuns, paragraphs, customRanges, customBlocks, customDecorations, tables, blockRanges } = body;
10608
+ if (textRuns == null && paragraphs == null && customRanges == null && customBlocks == null && customDecorations == null && tables == null && blockRanges == null) return true;
10438
10609
  return false;
10439
10610
  }
10440
10611
 
@@ -10521,6 +10692,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
10521
10692
  const removeSectionBreaks = deleteSectionBreaks(body, textLength, currentIndex);
10522
10693
  const removeCustomBlocks = deleteCustomBlocks(body, textLength, currentIndex);
10523
10694
  const removeTables = deleteTables(body, textLength, currentIndex);
10695
+ const removeBlockRanges = deleteBlockRanges(body, textLength, currentIndex);
10524
10696
  const removeCustomRanges = deleteCustomRanges(body, textLength, currentIndex);
10525
10697
  const removeCustomDecorations = deleteCustomDecorations(body, textLength, currentIndex);
10526
10698
  let removeDataStream = "";
@@ -10535,6 +10707,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
10535
10707
  sectionBreaks: removeSectionBreaks,
10536
10708
  customBlocks: removeCustomBlocks,
10537
10709
  tables: removeTables,
10710
+ blockRanges: removeBlockRanges,
10538
10711
  customRanges: removeCustomRanges,
10539
10712
  customDecorations: removeCustomDecorations
10540
10713
  };
@@ -10549,6 +10722,7 @@ function updateAttributeByInsert(body, insertBody, textLength, currentIndex) {
10549
10722
  insertSectionBreaks(body, insertBody, textLength, currentIndex);
10550
10723
  insertCustomBlocks(body, insertBody, textLength, currentIndex);
10551
10724
  insertTables(body, insertBody, textLength, currentIndex);
10725
+ insertBlockRanges(body, insertBody, textLength, currentIndex);
10552
10726
  insertCustomRanges(body, insertBody, textLength, currentIndex);
10553
10727
  insertCustomDecorations(body, insertBody, textLength, currentIndex);
10554
10728
  }
@@ -10764,8 +10938,8 @@ function transformBody(thisAction, otherAction, priority = false) {
10764
10938
  if (thisBody == null || thisBody.dataStream !== "" || otherBody == null || otherBody.dataStream !== "") throw new Error("Data stream is not supported in retain transform.");
10765
10939
  const retBody = { dataStream: "" };
10766
10940
  const coverType = otherCoverType;
10767
- const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations } = thisBody;
10768
- const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations } = otherBody;
10941
+ const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], blockRanges: thisBlockRanges = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations } = thisBody;
10942
+ const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], blockRanges: otherBlockRanges = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations } = otherBody;
10769
10943
  const textRuns = transformTextRuns(thisTextRuns, otherTextRuns, thisCoverType, otherCoverType, priority ? 1 : 0);
10770
10944
  if (textRuns) retBody.textRuns = textRuns;
10771
10945
  const customRanges = transformCustomRanges(thisCustomRanges, otherCustomRanges, thisCoverType, otherCoverType, priority ? 1 : 0);
@@ -10795,11 +10969,21 @@ function transformBody(thisAction, otherAction, priority = false) {
10795
10969
  }
10796
10970
  if (otherIndex < otherParagraphs.length) paragraphs.push(...otherParagraphs.slice(otherIndex));
10797
10971
  if (paragraphs.length) retBody.paragraphs = paragraphs;
10972
+ const blockRanges = transformBlockRanges(thisBlockRanges, otherBlockRanges, priority);
10973
+ if (blockRanges.length) retBody.blockRanges = blockRanges;
10798
10974
  return {
10799
10975
  coverType,
10800
10976
  body: retBody
10801
10977
  };
10802
10978
  }
10979
+ function transformBlockRanges(thisBlockRanges, otherBlockRanges, priority) {
10980
+ if (!thisBlockRanges.length) return otherBlockRanges;
10981
+ if (!otherBlockRanges.length) return [];
10982
+ return otherBlockRanges.map((otherBlockRange) => {
10983
+ const thisBlockRange = thisBlockRanges.find((blockRange) => blockRange.blockId === otherBlockRange.blockId);
10984
+ return thisBlockRange && priority ? Tools.deepMerge(otherBlockRange, thisBlockRange) : otherBlockRange;
10985
+ });
10986
+ }
10803
10987
 
10804
10988
  //#endregion
10805
10989
  //#region src/docs/data-model/text-x/text-x.ts
@@ -11132,6 +11316,7 @@ let DataStreamTreeNodeType = /* @__PURE__ */ function(DataStreamTreeNodeType) {
11132
11316
  DataStreamTreeNodeType["TABLE"] = "TABLE";
11133
11317
  DataStreamTreeNodeType["TABLE_ROW"] = "TABLE_ROW";
11134
11318
  DataStreamTreeNodeType["TABLE_CELL"] = "TABLE_CELL";
11319
+ DataStreamTreeNodeType["BLOCK"] = "BLOCK";
11135
11320
  DataStreamTreeNodeType["CUSTOM_BLOCK"] = "CUSTOM_BLOCK";
11136
11321
  return DataStreamTreeNodeType;
11137
11322
  }({});
@@ -11144,6 +11329,8 @@ let DataStreamTreeTokenType = /* @__PURE__ */ function(DataStreamTreeTokenType)
11144
11329
  DataStreamTreeTokenType["TABLE_CELL_END"] = "";
11145
11330
  DataStreamTreeTokenType["TABLE_ROW_END"] = "";
11146
11331
  DataStreamTreeTokenType["TABLE_END"] = "";
11332
+ DataStreamTreeTokenType["BLOCK_START"] = "";
11333
+ DataStreamTreeTokenType["BLOCK_END"] = "";
11147
11334
  /**
11148
11335
  * @deprecated
11149
11336
  */
@@ -11174,11 +11361,13 @@ const tags = [
11174
11361
  "",
11175
11362
  "",
11176
11363
  "",
11177
- ""
11364
+ "",
11365
+ "",
11366
+ ""
11178
11367
  ];
11179
11368
  const getPlainText = (dataStream) => {
11180
- const text = dataStream.endsWith("\r\n") ? dataStream.slice(0, -2) : dataStream;
11181
- return tags.reduce((res, curr) => res.replaceAll(curr, ""), text);
11369
+ const text = tags.reduce((res, curr) => res.replaceAll(curr, ""), dataStream);
11370
+ return text.endsWith("\r\n") ? text.slice(0, -2) : text;
11182
11371
  };
11183
11372
  const isEmptyDocument = (dataStream) => {
11184
11373
  if (!dataStream) return true;
@@ -14790,7 +14979,7 @@ const IURLImageService = (0, _wendellhu_redi.createIdentifier)("core.url-image.s
14790
14979
  //#endregion
14791
14980
  //#region package.json
14792
14981
  var name = "@univerjs/core";
14793
- var version = "0.24.0";
14982
+ var version = "0.25.0";
14794
14983
 
14795
14984
  //#endregion
14796
14985
  //#region src/sheets/empty-snapshot.ts
@@ -14936,10 +15125,12 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
14936
15125
  width: Number.POSITIVE_INFINITY,
14937
15126
  height: Number.POSITIVE_INFINITY
14938
15127
  },
15128
+ documentFlavor: 0,
14939
15129
  marginTop,
14940
15130
  marginBottom,
14941
15131
  marginRight,
14942
15132
  marginLeft,
15133
+ paragraphLineGapDefault: 0,
14943
15134
  renderConfig: {
14944
15135
  horizontalAlign,
14945
15136
  verticalAlign,
@@ -15044,14 +15235,7 @@ function getFontStyleString(textStyle) {
15044
15235
  if (textStyle.bl === 0 || textStyle.bl === void 0) bold = "normal";
15045
15236
  let originFontSize = defaultFontSize;
15046
15237
  if (textStyle.fs) originFontSize = Math.ceil(textStyle.fs);
15047
- let fontFamilyResult = defaultFont;
15048
- if (textStyle.ff) {
15049
- let fontFamily = textStyle.ff;
15050
- fontFamily = fontFamily.replace(/"/g, "").replace(/'/g, "");
15051
- if (fontFamily.indexOf(" ") > -1) fontFamily = `"${fontFamily}"`;
15052
- if (fontFamily == null) fontFamily = defaultFont;
15053
- fontFamilyResult = fontFamily;
15054
- }
15238
+ const fontFamilyResult = normalizeFontFamily(textStyle.ff, defaultFont);
15055
15239
  const { va: baselineOffset } = textStyle;
15056
15240
  let fontSize = originFontSize;
15057
15241
  if (baselineOffset === 2 || baselineOffset === 3) {
@@ -15067,6 +15251,13 @@ function getFontStyleString(textStyle) {
15067
15251
  fontFamily: fontFamilyResult
15068
15252
  };
15069
15253
  }
15254
+ function normalizeFontFamily(fontFamily, defaultFont) {
15255
+ if (!(fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily.trim())) return defaultFont;
15256
+ return fontFamily.split(",").map((item) => {
15257
+ const family = item.trim().replace(/^['"]|['"]$/g, "");
15258
+ return family.includes(" ") ? `"${family}"` : family;
15259
+ }).filter(Boolean).join(", ");
15260
+ }
15070
15261
  function getBaselineOffsetInfo(_fontFamily, fontSize) {
15071
15262
  return getDefaultBaselineOffset(fontSize);
15072
15263
  }
@@ -16887,6 +17078,8 @@ var Worksheet = class Worksheet {
16887
17078
  width: Number.POSITIVE_INFINITY,
16888
17079
  height: Number.POSITIVE_INFINITY
16889
17080
  };
17081
+ documentData.documentStyle.documentFlavor = 0;
17082
+ documentData.documentStyle.paragraphLineGapDefault = 0;
16890
17083
  documentData.documentStyle.renderConfig = {
16891
17084
  ...documentData.documentStyle.renderConfig,
16892
17085
  ...renderConfig
@@ -18009,7 +18202,14 @@ let PluginService = class PluginService {
18009
18202
  const { type, pluginName, packageName, version } = ctor;
18010
18203
  if (type === _univerjs_protocol.UniverType.UNRECOGNIZED) throw new Error(`[PluginService]: invalid plugin type for ${ctor.name}. Please assign a "type" to your plugin.`);
18011
18204
  if (!pluginName) throw new Error(`[PluginService]: no plugin name for ${ctor.name}. Please assign a "pluginName" to your plugin.`);
18012
- if (version && version !== Plugin.version) throw new Error(`[PluginService]: package "${packageName !== null && packageName !== void 0 ? packageName : "UNKNOWN"}" version mismatch. Plugin version is "${version}" but @univerjs/core version is "${Plugin.version}". Please make sure all @univerjs packages use the same version.`);
18205
+ if (version && version !== Plugin.version) this._logService.error("[PluginService]", [
18206
+ "Plugin version mismatch.",
18207
+ ` plugin: "${pluginName || ctor.name}"`,
18208
+ ` package: "${packageName}"`,
18209
+ ` plugin version: "${version}"`,
18210
+ ` core version: "${Plugin.version}"`,
18211
+ " registration will continue, but please make sure all @univerjs packages use the same version."
18212
+ ].join("\n"));
18013
18213
  if (this._seenPlugins.has(pluginName)) throw new Error(`[PluginService]: duplicated plugin name for "${pluginName}". Maybe a plugin that dependents on "${pluginName} has already registered it. In that case please register "${pluginName}" before the that plugin.`);
18014
18214
  this._seenPlugins.add(ctor.pluginName);
18015
18215
  }
@@ -19462,6 +19662,8 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
19462
19662
  width: Number.POSITIVE_INFINITY,
19463
19663
  height: Number.POSITIVE_INFINITY
19464
19664
  };
19665
+ documentData.documentStyle.documentFlavor = 0;
19666
+ documentData.documentStyle.paragraphLineGapDefault = 0;
19465
19667
  documentData.documentStyle.renderConfig = {
19466
19668
  ...documentData.documentStyle.renderConfig,
19467
19669
  ...renderConfig
@@ -20129,6 +20331,9 @@ exports.CustomDecorationType = CustomDecorationType;
20129
20331
  exports.CustomRangeType = CustomRangeType;
20130
20332
  exports.DEFAULT_CELL = DEFAULT_CELL;
20131
20333
  exports.DEFAULT_DOC = DEFAULT_DOC;
20334
+ exports.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;
20335
+ exports.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE;
20336
+ exports.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW;
20132
20337
  exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID = DEFAULT_DOCUMENT_SUB_COMPONENT_ID;
20133
20338
  exports.DEFAULT_EMPTY_DOCUMENT_VALUE = DEFAULT_EMPTY_DOCUMENT_VALUE;
20134
20339
  exports.DEFAULT_NUMBER_FORMAT = DEFAULT_NUMBER_FORMAT;
@@ -20278,6 +20483,8 @@ Object.defineProperty(exports, 'LookUp', {
20278
20483
  });
20279
20484
  exports.MAX_COLUMN_COUNT = MAX_COLUMN_COUNT;
20280
20485
  exports.MAX_ROW_COUNT = MAX_ROW_COUNT;
20486
+ exports.MODERN_DOCUMENT_DEFAULT_MARGIN = MODERN_DOCUMENT_DEFAULT_MARGIN;
20487
+ exports.MODERN_DOCUMENT_WIDTH = MODERN_DOCUMENT_WIDTH;
20281
20488
  exports.MOVE_BUFFER_VALUE = MOVE_BUFFER_VALUE;
20282
20489
  Object.defineProperty(exports, 'Many', {
20283
20490
  enumerable: true,
@@ -20293,6 +20500,7 @@ Object.defineProperty(exports, 'MentionIOLocalService', {
20293
20500
  }
20294
20501
  });
20295
20502
  exports.MentionType = MentionType;
20503
+ exports.ModernDocumentWidthMode = ModernDocumentWidthMode;
20296
20504
  exports.NAMED_STYLE_MAP = NAMED_STYLE_MAP;
20297
20505
  exports.NAMED_STYLE_SPACE_MAP = NAMED_STYLE_SPACE_MAP;
20298
20506
  exports.NamedStyleType = NamedStyleType;
@@ -20495,6 +20703,7 @@ exports.createInternalEditorID = createInternalEditorID;
20495
20703
  exports.createREGEXFromWildChar = createREGEXFromWildChar;
20496
20704
  exports.createRowColIter = createRowColIter;
20497
20705
  exports.createSheetGapTestConfig = createSheetGapTestConfig;
20706
+ exports.currencySymbols = currencySymbols;
20498
20707
  exports.customNameCharacterCheck = customNameCharacterCheck;
20499
20708
  exports.dateKit = dateKit;
20500
20709
  Object.defineProperty(exports, 'debounce', {
@@ -20508,6 +20717,7 @@ exports.dedupeBy = dedupeBy;
20508
20717
  exports.deepCompare = deepCompare;
20509
20718
  exports.delayAnimationFrame = delayAnimationFrame;
20510
20719
  exports.deleteContent = deleteContent;
20720
+ exports.escapeRegExp = escapeRegExp;
20511
20721
  exports.extractPureTextFromCell = extractPureTextFromCell;
20512
20722
  Object.defineProperty(exports, 'forwardRef', {
20513
20723
  enumerable: true,
@@ -20614,6 +20824,7 @@ exports.isPatternEqualWithoutDecimal = isPatternEqualWithoutDecimal;
20614
20824
  exports.isRangesEqual = isRangesEqual;
20615
20825
  exports.isRealNum = isRealNum;
20616
20826
  exports.isSafeNumeric = isSafeNumeric;
20827
+ exports.isSafeUrl = isSafeUrl;
20617
20828
  exports.isSameStyleTextRun = isSameStyleTextRun;
20618
20829
  exports.isTextFormat = isTextFormat;
20619
20830
  exports.isUnitRangesEqual = isUnitRangesEqual;
@@ -20654,6 +20865,7 @@ exports.nameCharacterCheck = nameCharacterCheck;
20654
20865
  exports.noop = noop;
20655
20866
  exports.normalizeBody = normalizeBody;
20656
20867
  exports.normalizeTextRuns = normalizeTextRuns;
20868
+ exports.normalizeUrl = normalizeUrl;
20657
20869
  exports.numberToABC = numberToABC;
20658
20870
  exports.numberToListABC = numberToListABC;
20659
20871
  Object.defineProperty(exports, 'numfmt', {