@univerjs/core 1.0.0-alpha.7 → 1.0.0-beta.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/facade.js +7 -139
- package/lib/cjs/index.js +832 -929
- package/lib/es/facade.js +9 -135
- package/lib/es/index.js +826 -932
- package/lib/facade.js +9 -135
- package/lib/index.js +826 -932
- package/lib/types/bases/index.d.ts +3 -2
- package/lib/types/bases/record-identity.d.ts +22 -0
- package/lib/types/bases/typedef.d.ts +255 -23
- package/lib/types/docs/data-model/index.d.ts +1 -1
- package/lib/types/docs/data-model/paragraph-style.d.ts +7 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +28 -9
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +1 -0
- package/lib/types/docs/data-model/types.d.ts +0 -2
- package/lib/types/facade/f-event.d.ts +9 -9
- package/lib/types/facade/f-univer.d.ts +1 -22
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/services/context/context.d.ts +0 -2
- package/lib/types/services/instance/instance.service.d.ts +0 -8
- package/lib/types/shared/cache/image-cache.d.ts +1 -1
- package/lib/types/shared/common.d.ts +0 -5
- package/lib/types/shared/object-matrix.d.ts +0 -14
- package/lib/types/shared/rectangle.d.ts +0 -15
- package/lib/types/shared/tools.d.ts +0 -2
- package/lib/types/sheets/sheet-skeleton.d.ts +3 -7
- package/lib/types/sheets/typedef.d.ts +0 -14
- package/lib/types/sheets/workbook.d.ts +0 -2
- package/lib/types/sheets/worksheet.d.ts +0 -6
- package/lib/types/types/const/page-size.d.ts +2 -0
- package/lib/types/types/enum/text-style.d.ts +3 -1
- package/lib/types/types/enum/theme-color-type.d.ts +0 -4
- package/lib/types/types/interfaces/i-cell-custom-render.d.ts +0 -2
- package/lib/types/types/interfaces/i-document-data.d.ts +113 -12
- package/lib/types/types/interfaces/i-need-check-disposable.d.ts +1 -1
- package/lib/types/types/interfaces/i-style-data.d.ts +43 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +22 -21
- package/package.json +4 -4
- package/lib/types/facade/f-hooks.d.ts +0 -74
package/lib/cjs/index.js
CHANGED
|
@@ -152,7 +152,7 @@ function installShims() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
//#endregion
|
|
155
|
-
//#region \0@oxc-project+runtime@0.
|
|
155
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
156
156
|
function _typeof(o) {
|
|
157
157
|
"@babel/helpers - typeof";
|
|
158
158
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -163,7 +163,7 @@ function _typeof(o) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region \0@oxc-project+runtime@0.
|
|
166
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
167
167
|
function toPrimitive(t, r) {
|
|
168
168
|
if ("object" != _typeof(t) || !t) return t;
|
|
169
169
|
var e = t[Symbol.toPrimitive];
|
|
@@ -176,14 +176,14 @@ function toPrimitive(t, r) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
//#endregion
|
|
179
|
-
//#region \0@oxc-project+runtime@0.
|
|
179
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
180
180
|
function toPropertyKey(t) {
|
|
181
181
|
var i = toPrimitive(t, "string");
|
|
182
182
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
187
187
|
function _defineProperty(e, r, t) {
|
|
188
188
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
189
189
|
value: t,
|
|
@@ -712,76 +712,6 @@ var Tools = class Tools {
|
|
|
712
712
|
if (isIE11) return "IE11";
|
|
713
713
|
return "Unknown browser";
|
|
714
714
|
}
|
|
715
|
-
/** @deprecated This method is deprecated, please use `import { merge } from '@univerjs/core` instead */
|
|
716
|
-
static deepMerge(target, ...sources) {
|
|
717
|
-
sources.forEach((item) => item && deepItem(item));
|
|
718
|
-
function isDangerousKey(key) {
|
|
719
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
720
|
-
}
|
|
721
|
-
function deepArray(array, to) {
|
|
722
|
-
array.forEach((value, key) => {
|
|
723
|
-
if (typeof key === "string" && isDangerousKey(key)) return;
|
|
724
|
-
if (Tools.isArray(value)) {
|
|
725
|
-
var _to$key;
|
|
726
|
-
const origin = (_to$key = to[key]) !== null && _to$key !== void 0 ? _to$key : [];
|
|
727
|
-
to[key] = origin;
|
|
728
|
-
deepArray(value, origin);
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
if (Tools.isObject(value)) {
|
|
732
|
-
var _to$key2;
|
|
733
|
-
const origin = (_to$key2 = to[key]) !== null && _to$key2 !== void 0 ? _to$key2 : {};
|
|
734
|
-
to[key] = origin;
|
|
735
|
-
deepObject(value, origin);
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
to[key] = value;
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
function deepObject(object, to) {
|
|
742
|
-
Object.keys(object).forEach((key) => {
|
|
743
|
-
if (isDangerousKey(key)) return;
|
|
744
|
-
const value = object[key];
|
|
745
|
-
if (Tools.isObject(value)) {
|
|
746
|
-
var _to$key3;
|
|
747
|
-
const origin = (_to$key3 = to[key]) !== null && _to$key3 !== void 0 ? _to$key3 : {};
|
|
748
|
-
to[key] = origin;
|
|
749
|
-
deepObject(value, origin);
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
if (Tools.isArray(value)) {
|
|
753
|
-
var _to$key4;
|
|
754
|
-
const origin = (_to$key4 = to[key]) !== null && _to$key4 !== void 0 ? _to$key4 : [];
|
|
755
|
-
to[key] = origin;
|
|
756
|
-
deepArray(value, origin);
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
to[key] = value;
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
function deepItem(item) {
|
|
763
|
-
Object.keys(item).forEach((key) => {
|
|
764
|
-
if (isDangerousKey(key)) return;
|
|
765
|
-
const value = item[key];
|
|
766
|
-
if (Tools.isArray(value)) {
|
|
767
|
-
var _target$key;
|
|
768
|
-
const origin = (_target$key = target[key]) !== null && _target$key !== void 0 ? _target$key : [];
|
|
769
|
-
target[key] = origin;
|
|
770
|
-
deepArray(value, origin);
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
if (Tools.isObject(value)) {
|
|
774
|
-
var _target$key2;
|
|
775
|
-
const origin = (_target$key2 = target[key]) !== null && _target$key2 !== void 0 ? _target$key2 : {};
|
|
776
|
-
target[key] = origin;
|
|
777
|
-
deepObject(value, origin);
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
target[key] = value;
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
return target;
|
|
784
|
-
}
|
|
785
715
|
static diffValue(one, two) {
|
|
786
716
|
return isValueEqual(one, two);
|
|
787
717
|
}
|
|
@@ -1568,6 +1498,8 @@ let TextDecoration = /* @__PURE__ */ function(TextDecoration) {
|
|
|
1568
1498
|
TextDecoration[TextDecoration["WAVY_DOUBLE"] = 15] = "WAVY_DOUBLE";
|
|
1569
1499
|
TextDecoration[TextDecoration["WAVY_HEAVY"] = 16] = "WAVY_HEAVY";
|
|
1570
1500
|
TextDecoration[TextDecoration["WORDS"] = 17] = "WORDS";
|
|
1501
|
+
TextDecoration[TextDecoration["SINGLE_ACCOUNTING"] = 18] = "SINGLE_ACCOUNTING";
|
|
1502
|
+
TextDecoration[TextDecoration["DOUBLE_ACCOUNTING"] = 19] = "DOUBLE_ACCOUNTING";
|
|
1571
1503
|
return TextDecoration;
|
|
1572
1504
|
}({});
|
|
1573
1505
|
/**
|
|
@@ -1681,8 +1613,6 @@ let CellValueType = /* @__PURE__ */ function(CellValueType) {
|
|
|
1681
1613
|
*/
|
|
1682
1614
|
/**
|
|
1683
1615
|
* Theme color type enum
|
|
1684
|
-
*
|
|
1685
|
-
* @deprecated
|
|
1686
1616
|
*/
|
|
1687
1617
|
let ThemeColorType = /* @__PURE__ */ function(ThemeColorType) {
|
|
1688
1618
|
/**
|
|
@@ -1710,8 +1640,6 @@ let ThemeColorType = /* @__PURE__ */ function(ThemeColorType) {
|
|
|
1710
1640
|
}({});
|
|
1711
1641
|
/**
|
|
1712
1642
|
* Preset theme names.
|
|
1713
|
-
*
|
|
1714
|
-
* @deprecated
|
|
1715
1643
|
*/
|
|
1716
1644
|
let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
1717
1645
|
ThemeColors["OFFICE"] = "Office";
|
|
@@ -1743,7 +1671,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1743
1671
|
//#endregion
|
|
1744
1672
|
//#region package.json
|
|
1745
1673
|
var name = "@univerjs/core";
|
|
1746
|
-
var version = "1.0.0-
|
|
1674
|
+
var version = "1.0.0-beta.0";
|
|
1747
1675
|
|
|
1748
1676
|
//#endregion
|
|
1749
1677
|
//#region src/common/array.ts
|
|
@@ -1952,9 +1880,8 @@ var ConfigService = class {
|
|
|
1952
1880
|
return this._config.get(id);
|
|
1953
1881
|
}
|
|
1954
1882
|
setConfig(id, value, options) {
|
|
1955
|
-
var _this$_config$get;
|
|
1956
1883
|
const { merge: isMerge = false } = options || {};
|
|
1957
|
-
let nextValue =
|
|
1884
|
+
let nextValue = this._config.get(id) ?? {};
|
|
1958
1885
|
if (isMerge) nextValue = (0, lodash_es.merge)(nextValue, value);
|
|
1959
1886
|
else nextValue = value;
|
|
1960
1887
|
this._config.set(id, nextValue);
|
|
@@ -2003,8 +1930,7 @@ var ContextService = class extends Disposable {
|
|
|
2003
1930
|
this._contextMap.clear();
|
|
2004
1931
|
}
|
|
2005
1932
|
getContextValue(key) {
|
|
2006
|
-
|
|
2007
|
-
return (_this$_contextMap$get = this._contextMap.get(key)) !== null && _this$_contextMap$get !== void 0 ? _this$_contextMap$get : false;
|
|
1933
|
+
return this._contextMap.get(key) ?? false;
|
|
2008
1934
|
}
|
|
2009
1935
|
setContextValue(key, value) {
|
|
2010
1936
|
this._contextMap.set(key, value);
|
|
@@ -2091,7 +2017,7 @@ function hashLogContent(...args) {
|
|
|
2091
2017
|
}
|
|
2092
2018
|
|
|
2093
2019
|
//#endregion
|
|
2094
|
-
//#region \0@oxc-project+runtime@0.
|
|
2020
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
2095
2021
|
function __decorateParam(paramIndex, decorator) {
|
|
2096
2022
|
return function(target, key) {
|
|
2097
2023
|
decorator(target, key, paramIndex);
|
|
@@ -2099,7 +2025,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
2099
2025
|
}
|
|
2100
2026
|
|
|
2101
2027
|
//#endregion
|
|
2102
|
-
//#region \0@oxc-project+runtime@0.
|
|
2028
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
2103
2029
|
function __decorate(decorators, target, key, desc) {
|
|
2104
2030
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2105
2031
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2262,7 +2188,7 @@ let CommandService = class CommandService extends Disposable {
|
|
|
2262
2188
|
params
|
|
2263
2189
|
};
|
|
2264
2190
|
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
|
|
2265
|
-
const _options = options
|
|
2191
|
+
const _options = options ?? {};
|
|
2266
2192
|
this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
|
|
2267
2193
|
if (this._disposed) {
|
|
2268
2194
|
stackItemDisposable.dispose();
|
|
@@ -2302,13 +2228,12 @@ let CommandService = class CommandService extends Disposable {
|
|
|
2302
2228
|
if (command.type === 2) {
|
|
2303
2229
|
const triggerCommand = findLast(this._commandExecutionStack, (item) => item.type === 0);
|
|
2304
2230
|
if (triggerCommand) {
|
|
2305
|
-
|
|
2306
|
-
commandInfo.params = (_commandInfo$params = commandInfo.params) !== null && _commandInfo$params !== void 0 ? _commandInfo$params : {};
|
|
2231
|
+
commandInfo.params = commandInfo.params ?? {};
|
|
2307
2232
|
commandInfo.params.trigger = triggerCommand.id;
|
|
2308
2233
|
}
|
|
2309
2234
|
}
|
|
2310
2235
|
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
|
|
2311
|
-
const _options = options
|
|
2236
|
+
const _options = options ?? {};
|
|
2312
2237
|
this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
|
|
2313
2238
|
if (this._disposed) {
|
|
2314
2239
|
stackItemDisposable.dispose();
|
|
@@ -3396,18 +3321,18 @@ const COLORS = {
|
|
|
3396
3321
|
};
|
|
3397
3322
|
var ColorKit = class ColorKit {
|
|
3398
3323
|
static mix(color1, color2, amount) {
|
|
3399
|
-
var _rgb1$a, _rgb2$a;
|
|
3400
3324
|
amount = Math.min(1, Math.max(0, amount));
|
|
3401
3325
|
const rgb1 = new ColorKit(color1).toRgb();
|
|
3402
3326
|
const rgb2 = new ColorKit(color2).toRgb();
|
|
3403
|
-
const alpha1 =
|
|
3404
|
-
const alpha2 =
|
|
3405
|
-
|
|
3327
|
+
const alpha1 = rgb1.a ?? 1;
|
|
3328
|
+
const alpha2 = rgb2.a ?? 1;
|
|
3329
|
+
const rgba = {
|
|
3406
3330
|
r: (rgb2.r - rgb1.r) * amount + rgb1.r,
|
|
3407
3331
|
g: (rgb2.g - rgb1.g) * amount + rgb1.g,
|
|
3408
3332
|
b: (rgb2.b - rgb1.b) * amount + rgb1.b,
|
|
3409
3333
|
a: (alpha2 - alpha1) * amount + alpha1
|
|
3410
|
-
}
|
|
3334
|
+
};
|
|
3335
|
+
return new ColorKit(rgba);
|
|
3411
3336
|
}
|
|
3412
3337
|
static getContrastRatio(foreground, background) {
|
|
3413
3338
|
const lumA = new ColorKit(foreground).getLuminance();
|
|
@@ -3505,8 +3430,7 @@ var ColorKit = class ColorKit {
|
|
|
3505
3430
|
return (r * 299 + g * 587 + b * 114) / 1e3;
|
|
3506
3431
|
}
|
|
3507
3432
|
getAlpha() {
|
|
3508
|
-
|
|
3509
|
-
return (_this$_color$a = this._color.a) !== null && _this$_color$a !== void 0 ? _this$_color$a : 1;
|
|
3433
|
+
return this._color.a ?? 1;
|
|
3510
3434
|
}
|
|
3511
3435
|
isDark() {
|
|
3512
3436
|
return this.getBrightness() < 128;
|
|
@@ -3903,57 +3827,6 @@ let DOC_RANGE_TYPE = /* @__PURE__ */ function(DOC_RANGE_TYPE) {
|
|
|
3903
3827
|
DOC_RANGE_TYPE["TEXT"] = "TEXT";
|
|
3904
3828
|
return DOC_RANGE_TYPE;
|
|
3905
3829
|
}({});
|
|
3906
|
-
/**
|
|
3907
|
-
* Determines whether the cell(row, column) is within the range of the merged cells.
|
|
3908
|
-
* @deprecated please use worksheet.getCellInfoInMergeData instead
|
|
3909
|
-
*/
|
|
3910
|
-
function getCellInfoInMergeData(row, column, mergeData) {
|
|
3911
|
-
let isMerged = false;
|
|
3912
|
-
let isMergedMainCell = false;
|
|
3913
|
-
let newEndRow = row;
|
|
3914
|
-
let newEndColumn = column;
|
|
3915
|
-
let mergeRow = row;
|
|
3916
|
-
let mergeColumn = column;
|
|
3917
|
-
if (mergeData == null) return {
|
|
3918
|
-
actualRow: row,
|
|
3919
|
-
actualColumn: column,
|
|
3920
|
-
isMergedMainCell,
|
|
3921
|
-
isMerged,
|
|
3922
|
-
endRow: newEndRow,
|
|
3923
|
-
endColumn: newEndColumn,
|
|
3924
|
-
startRow: mergeRow,
|
|
3925
|
-
startColumn: mergeColumn
|
|
3926
|
-
};
|
|
3927
|
-
for (let i = 0; i < mergeData.length; i++) {
|
|
3928
|
-
const { startRow: startRowMarge, endRow: endRowMarge, startColumn: startColumnMarge, endColumn: endColumnMarge } = mergeData[i];
|
|
3929
|
-
if (row === startRowMarge && column === startColumnMarge) {
|
|
3930
|
-
newEndRow = endRowMarge;
|
|
3931
|
-
newEndColumn = endColumnMarge;
|
|
3932
|
-
mergeRow = startRowMarge;
|
|
3933
|
-
mergeColumn = startColumnMarge;
|
|
3934
|
-
isMergedMainCell = true;
|
|
3935
|
-
break;
|
|
3936
|
-
}
|
|
3937
|
-
if (row >= startRowMarge && row <= endRowMarge && column >= startColumnMarge && column <= endColumnMarge) {
|
|
3938
|
-
newEndRow = endRowMarge;
|
|
3939
|
-
newEndColumn = endColumnMarge;
|
|
3940
|
-
mergeRow = startRowMarge;
|
|
3941
|
-
mergeColumn = startColumnMarge;
|
|
3942
|
-
isMerged = true;
|
|
3943
|
-
break;
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
return {
|
|
3947
|
-
actualRow: row,
|
|
3948
|
-
actualColumn: column,
|
|
3949
|
-
isMergedMainCell,
|
|
3950
|
-
isMerged,
|
|
3951
|
-
endRow: newEndRow,
|
|
3952
|
-
endColumn: newEndColumn,
|
|
3953
|
-
startRow: mergeRow,
|
|
3954
|
-
startColumn: mergeColumn
|
|
3955
|
-
};
|
|
3956
|
-
}
|
|
3957
3830
|
let CellModeEnum = /* @__PURE__ */ function(CellModeEnum) {
|
|
3958
3831
|
CellModeEnum["Raw"] = "raw";
|
|
3959
3832
|
CellModeEnum["Intercepted"] = "intercepted";
|
|
@@ -4149,7 +4022,6 @@ const dateCodes = [
|
|
|
4149
4022
|
["hm", 9]
|
|
4150
4023
|
];
|
|
4151
4024
|
function info(partitions, currencyId = null) {
|
|
4152
|
-
var _positive$scale;
|
|
4153
4025
|
const [partPositive, partNegative] = partitions;
|
|
4154
4026
|
if (!partPositive) throw new TypeError("Cannot read properties of undefined (reading 'frac_max')");
|
|
4155
4027
|
const positive = isParsedSection$1(partPositive) ? partPositive : void 0;
|
|
@@ -4161,8 +4033,8 @@ function info(partitions, currencyId = null) {
|
|
|
4161
4033
|
isDate: isDate(partitions),
|
|
4162
4034
|
isText: isText(partitions),
|
|
4163
4035
|
isPercent: isPercent(partitions),
|
|
4164
|
-
maxDecimals: (positive === null || positive === void 0 ? void 0 : positive.general) ? 9 : fracMax
|
|
4165
|
-
scale: (
|
|
4036
|
+
maxDecimals: (positive === null || positive === void 0 ? void 0 : positive.general) ? 9 : fracMax ?? 0,
|
|
4037
|
+
scale: (positive === null || positive === void 0 ? void 0 : positive.scale) ?? 1,
|
|
4166
4038
|
color: 0,
|
|
4167
4039
|
parentheses: 0,
|
|
4168
4040
|
grouped: (positive === null || positive === void 0 ? void 0 : positive.grouping) ? 1 : 0,
|
|
@@ -4245,11 +4117,10 @@ function info(partitions, currencyId = null) {
|
|
|
4245
4117
|
return Object.freeze(output);
|
|
4246
4118
|
}
|
|
4247
4119
|
function dateInfo(partitions) {
|
|
4248
|
-
var _positive$date;
|
|
4249
4120
|
const [partPositive] = partitions;
|
|
4250
4121
|
if (!partPositive) throw new TypeError("Cannot read properties of undefined (reading 'date')");
|
|
4251
4122
|
const positive = isParsedSection$1(partPositive) ? partPositive : void 0;
|
|
4252
|
-
const date = (
|
|
4123
|
+
const date = (positive === null || positive === void 0 ? void 0 : positive.date) ?? 0;
|
|
4253
4124
|
return {
|
|
4254
4125
|
year: !!(date & 2),
|
|
4255
4126
|
month: !!(date & 4),
|
|
@@ -5825,8 +5696,7 @@ function getAbsoluteDecimal(value) {
|
|
|
5825
5696
|
} : value;
|
|
5826
5697
|
}
|
|
5827
5698
|
function getDecimalExponent(value) {
|
|
5828
|
-
|
|
5829
|
-
return (_value$exponent = value === null || value === void 0 ? void 0 : value.exponent) !== null && _value$exponent !== void 0 ? _value$exponent : 0;
|
|
5699
|
+
return (value === null || value === void 0 ? void 0 : value.exponent) ?? 0;
|
|
5830
5700
|
}
|
|
5831
5701
|
function usesShortestSignificand(value) {
|
|
5832
5702
|
return !value || value.exponent < -308;
|
|
@@ -6012,7 +5882,6 @@ function legacyRound(number, places = 0) {
|
|
|
6012
5882
|
return Math.round(number);
|
|
6013
5883
|
}
|
|
6014
5884
|
function runPart(value, part, options, locale, decimalValue = null) {
|
|
6015
|
-
var _options$grouping$, _options$grouping$2;
|
|
6016
5885
|
const section = part;
|
|
6017
5886
|
let renderValue = value;
|
|
6018
5887
|
let numericValue = value;
|
|
@@ -6075,8 +5944,8 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
6075
5944
|
const roundedInteger = Math.abs(Number.isSafeInteger(numericValue) && places === 0 ? numericValue : legacyRound(numericValue, places));
|
|
6076
5945
|
integer += roundedInteger < 1 ? "" : Math.floor(roundedInteger);
|
|
6077
5946
|
}
|
|
6078
|
-
const primaryGroup =
|
|
6079
|
-
const secondaryGroup =
|
|
5947
|
+
const primaryGroup = options.grouping[0] ?? 3;
|
|
5948
|
+
const secondaryGroup = options.grouping[1] ?? primaryGroup;
|
|
6080
5949
|
if (section.dec_fractions) fraction = roundedNumber ? roundedNumber.fraction : String(legacyRound(numericValue, section.frac_max)).split(".")[1] || "";
|
|
6081
5950
|
const fixedSlash = !section.error && (section.num_p.includes("0") || section.den_p.includes("0"));
|
|
6082
5951
|
let haveFraction = fixedSlash;
|
|
@@ -6753,7 +6622,7 @@ function dateToSerial(date, options) {
|
|
|
6753
6622
|
let timestamp = null;
|
|
6754
6623
|
if (Array.isArray(date)) {
|
|
6755
6624
|
const [year, month, day, hours, minutes, seconds] = date;
|
|
6756
|
-
timestamp = dateUTC(year, month == null ? 0 : month - 1, day
|
|
6625
|
+
timestamp = dateUTC(year, month == null ? 0 : month - 1, day ?? 1, hours || 0, minutes || 0, seconds || 0);
|
|
6757
6626
|
} else if (date instanceof Date) {
|
|
6758
6627
|
timestamp = date.getTime();
|
|
6759
6628
|
if (!(options === null || options === void 0 ? void 0 : options.ignoreTimezone)) {
|
|
@@ -7077,6 +6946,7 @@ function isValidDate(year, month, day) {
|
|
|
7077
6946
|
} else if ((month === 4 || month === 6 || month === 9 || month === 11) && day > 30 || (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) && day > 31) return false;
|
|
7078
6947
|
return true;
|
|
7079
6948
|
}
|
|
6949
|
+
const dateLocaleLookupCache = /* @__PURE__ */ new WeakMap();
|
|
7080
6950
|
const matchRec = (string, data, skipPeriod = false) => {
|
|
7081
6951
|
for (const item of data) if (string.startsWith(item[0])) {
|
|
7082
6952
|
let length = item[0].length;
|
|
@@ -7187,23 +7057,39 @@ const getLookups = (values, symbol) => {
|
|
|
7187
7057
|
lookups.sort((a, b) => b[0].length - a[0].length);
|
|
7188
7058
|
return lookups;
|
|
7189
7059
|
};
|
|
7060
|
+
const tokensMatch = (values, cachedValues) => values.length === cachedValues.length && values.every((value, index) => value === cachedValues[index]);
|
|
7061
|
+
const getDateLocaleLookups = (locale) => {
|
|
7062
|
+
let cached = dateLocaleLookupCache.get(locale);
|
|
7063
|
+
if (!cached || !tokensMatch(locale.mmmm, cached.mmmm) || !tokensMatch(locale.mmm, cached.mmm) || !tokensMatch(locale.dddd, cached.dddd) || !tokensMatch(locale.ddd, cached.ddd)) {
|
|
7064
|
+
cached = {
|
|
7065
|
+
lookups: {
|
|
7066
|
+
mon: getLookups(locale.mmmm, "F").concat(getLookups(locale.mmm, "M")),
|
|
7067
|
+
mp: locale.mmm[0].endsWith("."),
|
|
7068
|
+
day: getLookups(locale.dddd, "l").concat(getLookups(locale.ddd, "D")),
|
|
7069
|
+
dp: locale.ddd[0].endsWith(".")
|
|
7070
|
+
},
|
|
7071
|
+
mmmm: [...locale.mmmm],
|
|
7072
|
+
mmm: [...locale.mmm],
|
|
7073
|
+
dddd: [...locale.dddd],
|
|
7074
|
+
ddd: [...locale.ddd]
|
|
7075
|
+
};
|
|
7076
|
+
dateLocaleLookupCache.set(locale, cached);
|
|
7077
|
+
}
|
|
7078
|
+
return cached.lookups;
|
|
7079
|
+
};
|
|
7190
7080
|
/** Parse a date or datetime string and return its serial value and format. */
|
|
7191
7081
|
function parseDate(value, options = {}) {
|
|
7192
|
-
var _date$year, _date$day;
|
|
7193
7082
|
const l10n = getLocale(options.locale || "") || defaultLocale;
|
|
7194
7083
|
const localeData = {
|
|
7195
|
-
|
|
7196
|
-
mp: l10n.mmm[0].at(-1) === ".",
|
|
7197
|
-
day: getLookups(l10n.dddd, "l").concat(getLookups(l10n.ddd, "D")),
|
|
7198
|
-
dp: l10n.ddd[0].at(-1) === ".",
|
|
7084
|
+
...getDateLocaleLookups(l10n),
|
|
7199
7085
|
locale: options.locale
|
|
7200
7086
|
};
|
|
7201
7087
|
const date = nextToken(normDateStr(value), l10n.preferMDY ? dateTrieMD : dateTrieDM, { path: "" }, localeData);
|
|
7202
7088
|
if (!date) return null;
|
|
7203
7089
|
if (date.sep === "." && date.path.length === 3) return null;
|
|
7204
7090
|
if (date.month == null || date._mon == null) return null;
|
|
7205
|
-
const year = +(
|
|
7206
|
-
const day =
|
|
7091
|
+
const year = +(date.year ?? currentYear);
|
|
7092
|
+
const day = date.day ?? "1";
|
|
7207
7093
|
let epoch = -Infinity;
|
|
7208
7094
|
if (year < 1900) return null;
|
|
7209
7095
|
else if (year <= 1900 && date.month <= 2) epoch = 25568;
|
|
@@ -7268,8 +7154,7 @@ function parseBool(value, options = {}) {
|
|
|
7268
7154
|
}
|
|
7269
7155
|
/** Parse a spreadsheet input as a number, date, time, or boolean. */
|
|
7270
7156
|
function parseValue(value, options) {
|
|
7271
|
-
|
|
7272
|
-
return (_ref = (_ref2 = (_parseNumber = parseNumber(value, options)) !== null && _parseNumber !== void 0 ? _parseNumber : parseDate(value, options)) !== null && _ref2 !== void 0 ? _ref2 : parseTime(value, options)) !== null && _ref !== void 0 ? _ref : parseBool(value, options);
|
|
7157
|
+
return parseNumber(value, options) ?? parseDate(value, options) ?? parseTime(value, options) ?? parseBool(value, options);
|
|
7273
7158
|
}
|
|
7274
7159
|
|
|
7275
7160
|
//#endregion
|
|
@@ -7330,19 +7215,17 @@ function prepareFormatterData(pattern, shouldThrow = false) {
|
|
|
7330
7215
|
* Formats a value as a string and returns the result.
|
|
7331
7216
|
*/
|
|
7332
7217
|
function format(pattern, value, options = {}) {
|
|
7333
|
-
var _handleDates;
|
|
7334
7218
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7335
7219
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7336
|
-
return formatValue(
|
|
7220
|
+
return formatValue(dateToSerial(value, resolvedOptions) ?? value, data, resolvedOptions);
|
|
7337
7221
|
}
|
|
7338
7222
|
/**
|
|
7339
7223
|
* Find the color appropriate to a value as dictated by a format pattern.
|
|
7340
7224
|
*/
|
|
7341
7225
|
function formatColor(pattern, value, options) {
|
|
7342
|
-
var _handleDates2;
|
|
7343
7226
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7344
7227
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7345
|
-
return formatColor$1(
|
|
7228
|
+
return formatColor$1(dateToSerial(value, resolvedOptions) ?? value, data, resolvedOptions);
|
|
7346
7229
|
}
|
|
7347
7230
|
/** Determine if a given format pattern is a date pattern. */
|
|
7348
7231
|
function isDateFormat(pattern) {
|
|
@@ -7812,8 +7695,7 @@ const CURRENCY_SYMBOL_PREFIX_REG = new RegExp(`^${regexp.charset(...Array.from(n
|
|
|
7812
7695
|
* Get the numfmt parse value, and filter out the parse error.
|
|
7813
7696
|
*/
|
|
7814
7697
|
const getNumfmtParseValueFilter = (value) => {
|
|
7815
|
-
|
|
7816
|
-
const parseData = (_ref = (_parseDate = parseDate(value)) !== null && _parseDate !== void 0 ? _parseDate : parseTime(value)) !== null && _ref !== void 0 ? _ref : parseNumber(value);
|
|
7698
|
+
const parseData = parseDate(value) ?? parseTime(value) ?? parseNumber(value);
|
|
7817
7699
|
if (!parseData) return null;
|
|
7818
7700
|
const { z } = parseData;
|
|
7819
7701
|
if (z) {
|
|
@@ -8041,24 +7923,15 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8041
7923
|
const objectArray = this.getRowOrCreate(row);
|
|
8042
7924
|
objectArray[column] = value;
|
|
8043
7925
|
}
|
|
8044
|
-
|
|
8045
|
-
* !!
|
|
8046
|
-
* Please +1 ‘!’, who fell into this pit.
|
|
8047
|
-
* @deprecated use `realDelete` or `splice`
|
|
8048
|
-
*/
|
|
8049
|
-
deleteValue(row, column) {
|
|
7926
|
+
realDeleteValue(row, column) {
|
|
8050
7927
|
var _this$_matrix2;
|
|
8051
7928
|
(_this$_matrix2 = this._matrix) === null || _this$_matrix2 === void 0 || (_this$_matrix2 = _this$_matrix2[row]) === null || _this$_matrix2 === void 0 || delete _this$_matrix2[column];
|
|
8052
|
-
}
|
|
8053
|
-
realDeleteValue(row, column) {
|
|
8054
|
-
var _this$_matrix3;
|
|
8055
|
-
(_this$_matrix3 = this._matrix) === null || _this$_matrix3 === void 0 || (_this$_matrix3 = _this$_matrix3[row]) === null || _this$_matrix3 === void 0 || delete _this$_matrix3[column];
|
|
8056
7929
|
if (this.getRow(row)) {
|
|
8057
7930
|
const objectArray = this.getRow(row);
|
|
8058
7931
|
if (objectArray == null) return;
|
|
8059
7932
|
if (Object.keys(objectArray).length === 0) {
|
|
8060
|
-
var _this$
|
|
8061
|
-
(_this$
|
|
7933
|
+
var _this$_matrix3;
|
|
7934
|
+
(_this$_matrix3 = this._matrix) === null || _this$_matrix3 === void 0 || delete _this$_matrix3[row];
|
|
8062
7935
|
}
|
|
8063
7936
|
}
|
|
8064
7937
|
}
|
|
@@ -8257,23 +8130,10 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8257
8130
|
});
|
|
8258
8131
|
return array;
|
|
8259
8132
|
}
|
|
8260
|
-
/**
|
|
8261
|
-
* @deprecated Use getMatrix as a substitute.
|
|
8262
|
-
*/
|
|
8263
|
-
toJSON() {
|
|
8264
|
-
return this._matrix;
|
|
8265
|
-
}
|
|
8266
8133
|
clone() {
|
|
8267
8134
|
const json = JSON.stringify(this._matrix);
|
|
8268
8135
|
return JSON.parse(json);
|
|
8269
8136
|
}
|
|
8270
|
-
/**
|
|
8271
|
-
* @deprecated Use clone as a substitute.
|
|
8272
|
-
*/
|
|
8273
|
-
getData() {
|
|
8274
|
-
const json = JSON.stringify(this._matrix);
|
|
8275
|
-
return JSON.parse(json);
|
|
8276
|
-
}
|
|
8277
8137
|
getArrayData() {
|
|
8278
8138
|
let startRow = 0;
|
|
8279
8139
|
let startColumn = 0;
|
|
@@ -8295,7 +8155,7 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8295
8155
|
objectMatrix.setValue(rowIndex - startRow, columnIndex - startColumn, value);
|
|
8296
8156
|
});
|
|
8297
8157
|
});
|
|
8298
|
-
return objectMatrix.
|
|
8158
|
+
return objectMatrix.clone();
|
|
8299
8159
|
}
|
|
8300
8160
|
/**
|
|
8301
8161
|
* the function can only be used in all the row and column are positive integer
|
|
@@ -8441,10 +8301,6 @@ function convertCellToRange(cellInfo) {
|
|
|
8441
8301
|
endX
|
|
8442
8302
|
};
|
|
8443
8303
|
}
|
|
8444
|
-
/**
|
|
8445
|
-
* @deprecated use `convertCellToRange` instead
|
|
8446
|
-
*/
|
|
8447
|
-
const makeCellToSelection = convertCellToRange;
|
|
8448
8304
|
function makeCellRangeToRangeData(cellInfo) {
|
|
8449
8305
|
if (!cellInfo) return;
|
|
8450
8306
|
const { actualRow, actualColumn, isMerged, isMergedMainCell, startRow: mergeStartRow, startColumn: mergeStartColumn, endRow: mergeEndRow, endColumn: mergeEndColumn } = cellInfo;
|
|
@@ -8558,20 +8414,20 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8558
8414
|
["bd", () => {
|
|
8559
8415
|
var _style$bd, _style$bd3, _style$bd5, _style$bd7;
|
|
8560
8416
|
if ((_style$bd = style.bd) === null || _style$bd === void 0 ? void 0 : _style$bd.b) {
|
|
8561
|
-
var _style$bd2
|
|
8562
|
-
str += `border-bottom: ${getBorderStyle((_style$bd2 = style.bd) === null || _style$bd2 === void 0 ? void 0 : _style$bd2.b.s)} ${
|
|
8417
|
+
var _style$bd2;
|
|
8418
|
+
str += `border-bottom: ${getBorderStyle((_style$bd2 = style.bd) === null || _style$bd2 === void 0 ? void 0 : _style$bd2.b.s)} ${getColorStyle(style.bd.b.cl) ?? ""}; `;
|
|
8563
8419
|
}
|
|
8564
8420
|
if ((_style$bd3 = style.bd) === null || _style$bd3 === void 0 ? void 0 : _style$bd3.t) {
|
|
8565
|
-
var _style$bd4
|
|
8566
|
-
str += `border-top: ${getBorderStyle((_style$bd4 = style.bd) === null || _style$bd4 === void 0 ? void 0 : _style$bd4.t.s)} ${
|
|
8421
|
+
var _style$bd4;
|
|
8422
|
+
str += `border-top: ${getBorderStyle((_style$bd4 = style.bd) === null || _style$bd4 === void 0 ? void 0 : _style$bd4.t.s)} ${getColorStyle(style.bd.t.cl) ?? ""}; `;
|
|
8567
8423
|
}
|
|
8568
8424
|
if ((_style$bd5 = style.bd) === null || _style$bd5 === void 0 ? void 0 : _style$bd5.r) {
|
|
8569
|
-
var _style$bd6
|
|
8570
|
-
str += `border-right: ${getBorderStyle((_style$bd6 = style.bd) === null || _style$bd6 === void 0 ? void 0 : _style$bd6.r.s)} ${
|
|
8425
|
+
var _style$bd6;
|
|
8426
|
+
str += `border-right: ${getBorderStyle((_style$bd6 = style.bd) === null || _style$bd6 === void 0 ? void 0 : _style$bd6.r.s)} ${getColorStyle(style.bd.r.cl) ?? ""}; `;
|
|
8571
8427
|
}
|
|
8572
8428
|
if ((_style$bd7 = style.bd) === null || _style$bd7 === void 0 ? void 0 : _style$bd7.l) {
|
|
8573
|
-
var _style$bd8
|
|
8574
|
-
str += `border-left: ${getBorderStyle((_style$bd8 = style.bd) === null || _style$bd8 === void 0 ? void 0 : _style$bd8.l.s)} ${
|
|
8429
|
+
var _style$bd8;
|
|
8430
|
+
str += `border-left: ${getBorderStyle((_style$bd8 = style.bd) === null || _style$bd8 === void 0 ? void 0 : _style$bd8.l.s)} ${getColorStyle(style.bd.l.cl) ?? ""}; `;
|
|
8575
8431
|
}
|
|
8576
8432
|
}],
|
|
8577
8433
|
["cl", () => {
|
|
@@ -8988,8 +8844,7 @@ function parseDateString(input, isUTC) {
|
|
|
8988
8844
|
return new Date(text);
|
|
8989
8845
|
}
|
|
8990
8846
|
function normalizeUnit(unit) {
|
|
8991
|
-
|
|
8992
|
-
return (_UNIT_ALIASES$unit = UNIT_ALIASES[unit]) !== null && _UNIT_ALIASES$unit !== void 0 ? _UNIT_ALIASES$unit : UNIT_ALIASES[String(unit).toLowerCase()];
|
|
8847
|
+
return UNIT_ALIASES[unit] ?? UNIT_ALIASES[String(unit).toLowerCase()];
|
|
8993
8848
|
}
|
|
8994
8849
|
function daysInMonth(year, month, isUTC) {
|
|
8995
8850
|
return isUTC ? new Date(Date.UTC(year, month, 0)).getUTCDate() : new Date(year, month, 0).getDate();
|
|
@@ -9108,10 +8963,7 @@ function ordinal(value) {
|
|
|
9108
8963
|
}
|
|
9109
8964
|
}
|
|
9110
8965
|
function replaceLocalizedTokens(template) {
|
|
9111
|
-
return template.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g, (token) =>
|
|
9112
|
-
var _LOCALIZED_FORMAT_MAP;
|
|
9113
|
-
return (_LOCALIZED_FORMAT_MAP = LOCALIZED_FORMAT_MAP[token]) !== null && _LOCALIZED_FORMAT_MAP !== void 0 ? _LOCALIZED_FORMAT_MAP : token;
|
|
9114
|
-
});
|
|
8966
|
+
return template.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g, (token) => LOCALIZED_FORMAT_MAP[token] ?? token);
|
|
9115
8967
|
}
|
|
9116
8968
|
function formatDate(date, template, isUTC) {
|
|
9117
8969
|
const parts = getDateParts(date, isUTC);
|
|
@@ -9153,13 +9005,7 @@ function formatDate(date, template, isUTC) {
|
|
|
9153
9005
|
const escapedBlocks = [];
|
|
9154
9006
|
return replaceLocalizedTokens(template.replace(/\[([^\]]+)]/g, (_, value) => {
|
|
9155
9007
|
return `\u0000${escapedBlocks.push(value) - 1}\u0000`;
|
|
9156
|
-
})).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g, (token) =>
|
|
9157
|
-
var _tokenMap$token;
|
|
9158
|
-
return (_tokenMap$token = tokenMap[token]) !== null && _tokenMap$token !== void 0 ? _tokenMap$token : token;
|
|
9159
|
-
}).replace(/\u0000(\d+)\u0000/g, (_, indexText) => {
|
|
9160
|
-
var _escapedBlocks$Number;
|
|
9161
|
-
return (_escapedBlocks$Number = escapedBlocks[Number(indexText)]) !== null && _escapedBlocks$Number !== void 0 ? _escapedBlocks$Number : "";
|
|
9162
|
-
});
|
|
9008
|
+
})).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g, (token) => tokenMap[token] ?? token).replace(/\u0000(\d+)\u0000/g, (_, indexText) => escapedBlocks[Number(indexText)] ?? "");
|
|
9163
9009
|
}
|
|
9164
9010
|
function createDateKit(input) {
|
|
9165
9011
|
return new DateKitImpl(toDate(input, false), false);
|
|
@@ -9328,7 +9174,10 @@ function mergeLocales(...locales) {
|
|
|
9328
9174
|
|
|
9329
9175
|
//#endregion
|
|
9330
9176
|
//#region src/shared/lru/lru-map.ts
|
|
9331
|
-
let _Symbol$iterator
|
|
9177
|
+
let _Symbol$iterator;
|
|
9178
|
+
let _Symbol$iterator2;
|
|
9179
|
+
let _Symbol$iterator3;
|
|
9180
|
+
let _Symbol$iterator4;
|
|
9332
9181
|
const NEWER = Symbol("newer");
|
|
9333
9182
|
const OLDER = Symbol("older");
|
|
9334
9183
|
_Symbol$iterator = Symbol.iterator;
|
|
@@ -9833,6 +9682,11 @@ let CustomRangeType = /* @__PURE__ */ function(CustomRangeType) {
|
|
|
9833
9682
|
CustomRangeType[CustomRangeType["DELTED"] = 9999] = "DELTED";
|
|
9834
9683
|
return CustomRangeType;
|
|
9835
9684
|
}({});
|
|
9685
|
+
let DocxBreakType = /* @__PURE__ */ function(DocxBreakType) {
|
|
9686
|
+
DocxBreakType["COLUMN"] = "column";
|
|
9687
|
+
DocxBreakType["TEXT_WRAPPING"] = "textWrapping";
|
|
9688
|
+
return DocxBreakType;
|
|
9689
|
+
}({});
|
|
9836
9690
|
let CustomDecorationType = /* @__PURE__ */ function(CustomDecorationType) {
|
|
9837
9691
|
CustomDecorationType[CustomDecorationType["COMMENT"] = 0] = "COMMENT";
|
|
9838
9692
|
CustomDecorationType[CustomDecorationType["DELETED"] = 9999] = "DELETED";
|
|
@@ -9865,9 +9719,10 @@ let GridType = /* @__PURE__ */ function(GridType) {
|
|
|
9865
9719
|
let SectionType = /* @__PURE__ */ function(SectionType) {
|
|
9866
9720
|
SectionType[SectionType["SECTION_TYPE_UNSPECIFIED"] = 0] = "SECTION_TYPE_UNSPECIFIED";
|
|
9867
9721
|
SectionType[SectionType["CONTINUOUS"] = 1] = "CONTINUOUS";
|
|
9868
|
-
SectionType[SectionType["
|
|
9869
|
-
SectionType[SectionType["
|
|
9870
|
-
SectionType[SectionType["
|
|
9722
|
+
SectionType[SectionType["NEXT_COLUMN"] = 2] = "NEXT_COLUMN";
|
|
9723
|
+
SectionType[SectionType["NEXT_PAGE"] = 3] = "NEXT_PAGE";
|
|
9724
|
+
SectionType[SectionType["EVEN_PAGE"] = 4] = "EVEN_PAGE";
|
|
9725
|
+
SectionType[SectionType["ODD_PAGE"] = 5] = "ODD_PAGE";
|
|
9871
9726
|
return SectionType;
|
|
9872
9727
|
}({});
|
|
9873
9728
|
/**
|
|
@@ -9912,15 +9767,25 @@ let WrapTextType = /* @__PURE__ */ function(WrapTextType) {
|
|
|
9912
9767
|
return WrapTextType;
|
|
9913
9768
|
}({});
|
|
9914
9769
|
/**
|
|
9915
|
-
*
|
|
9770
|
+
* Controls how a positioned object participates in document text layout.
|
|
9771
|
+
*
|
|
9772
|
+
* `WRAP_NONE` does not by itself determine whether the object is in front of or behind text. Drawing data uses
|
|
9773
|
+
* `behindDoc` for that stacking choice.
|
|
9916
9774
|
*/
|
|
9917
9775
|
let PositionedObjectLayoutType = /* @__PURE__ */ function(PositionedObjectLayoutType) {
|
|
9776
|
+
/** Places the object in the text flow like a character and lets it affect the containing line's metrics. */
|
|
9918
9777
|
PositionedObjectLayoutType[PositionedObjectLayoutType["INLINE"] = 0] = "INLINE";
|
|
9778
|
+
/** Floats the object without reflowing text. The object and text can overlap. */
|
|
9919
9779
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_NONE"] = 1] = "WRAP_NONE";
|
|
9780
|
+
/** Floats the object and wraps text around the custom polygon defined by its wrap path. */
|
|
9920
9781
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_POLYGON"] = 2] = "WRAP_POLYGON";
|
|
9782
|
+
/** Floats the object and wraps text around its rectangular bounds. */
|
|
9921
9783
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_SQUARE"] = 3] = "WRAP_SQUARE";
|
|
9784
|
+
/** Floats the object and allows text to flow through eligible open regions in its wrap contour. */
|
|
9922
9785
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_THROUGH"] = 4] = "WRAP_THROUGH";
|
|
9786
|
+
/** Floats the object and wraps text closely around its contour instead of its rectangular bounds. */
|
|
9923
9787
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_TIGHT"] = 5] = "WRAP_TIGHT";
|
|
9788
|
+
/** Floats the object in a horizontal band, leaving text only above and below it. */
|
|
9924
9789
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_TOP_AND_BOTTOM"] = 6] = "WRAP_TOP_AND_BOTTOM";
|
|
9925
9790
|
return PositionedObjectLayoutType;
|
|
9926
9791
|
}({});
|
|
@@ -10558,6 +10423,8 @@ const MODERN_DOCUMENT_WIDTH = {
|
|
|
10558
10423
|
["wide"]: PAGE_SIZE["A3"].width
|
|
10559
10424
|
};
|
|
10560
10425
|
const MODERN_DOCUMENT_DEFAULT_MARGIN = 50 / .75;
|
|
10426
|
+
/** Default margin for a paginated Traditional document, in 96-DPI layout pixels. */
|
|
10427
|
+
const TRADITIONAL_DOCUMENT_DEFAULT_MARGIN = 72;
|
|
10561
10428
|
|
|
10562
10429
|
//#endregion
|
|
10563
10430
|
//#region src/sheets/range.ts
|
|
@@ -10746,7 +10613,7 @@ var Range = class Range {
|
|
|
10746
10613
|
*/
|
|
10747
10614
|
getObjectValues(options = {}) {
|
|
10748
10615
|
const { startRow, endRow, startColumn, endColumn } = this._range;
|
|
10749
|
-
const values = this._worksheet.getCellMatrix().getFragment(startRow, endRow, startColumn, endColumn).
|
|
10616
|
+
const values = this._worksheet.getCellMatrix().getFragment(startRow, endRow, startColumn, endColumn).clone();
|
|
10750
10617
|
if (options.isIncludeStyle) {
|
|
10751
10618
|
const style = this._deps.getStyles();
|
|
10752
10619
|
for (let r = 0; r <= endRow - startRow; r++) for (let c = 0; c <= endColumn - startColumn; c++) {
|
|
@@ -10797,8 +10664,8 @@ var Range = class Range {
|
|
|
10797
10664
|
* Returns the underline of the cells in the range.
|
|
10798
10665
|
*/
|
|
10799
10666
|
getUnderline() {
|
|
10800
|
-
var
|
|
10801
|
-
const { p } =
|
|
10667
|
+
var _p$body;
|
|
10668
|
+
const { p } = this.getValue() ?? {};
|
|
10802
10669
|
if (p && Array.isArray((_p$body = p.body) === null || _p$body === void 0 ? void 0 : _p$body.textRuns) && p.body.textRuns.length > 0) return isAllFormatInTextRuns("ul", p.body) === 1 ? { s: 1 } : { s: 0 };
|
|
10803
10670
|
return this.getUnderlines()[0][0];
|
|
10804
10671
|
}
|
|
@@ -10818,8 +10685,8 @@ var Range = class Range {
|
|
|
10818
10685
|
* Returns the strikeThrough of the cells in the range.
|
|
10819
10686
|
*/
|
|
10820
10687
|
getStrikeThrough() {
|
|
10821
|
-
var
|
|
10822
|
-
const { p } =
|
|
10688
|
+
var _p$body2;
|
|
10689
|
+
const { p } = this.getValue() ?? {};
|
|
10823
10690
|
if (p && Array.isArray((_p$body2 = p.body) === null || _p$body2 === void 0 ? void 0 : _p$body2.textRuns) && p.body.textRuns.length > 0) return isAllFormatInTextRuns("st", p.body) === 1 ? { s: 1 } : { s: 0 };
|
|
10824
10691
|
return this.getStrikeThroughs()[0][0];
|
|
10825
10692
|
}
|
|
@@ -10833,8 +10700,8 @@ var Range = class Range {
|
|
|
10833
10700
|
* Returns the font size in point size of the cell in the top-left corner of the range.
|
|
10834
10701
|
*/
|
|
10835
10702
|
getFontSize() {
|
|
10836
|
-
var _this$
|
|
10837
|
-
const p = ((_this$
|
|
10703
|
+
var _this$getValue, _p$body3;
|
|
10704
|
+
const p = ((_this$getValue = this.getValue()) === null || _this$getValue === void 0 ? void 0 : _this$getValue.p) || {};
|
|
10838
10705
|
if (p && Array.isArray((_p$body3 = p.body) === null || _p$body3 === void 0 ? void 0 : _p$body3.textRuns) && p.body.textRuns.length > 0) if (p.body.textRuns.some((textRun) => {
|
|
10839
10706
|
var _textRun$ts;
|
|
10840
10707
|
return (textRun === null || textRun === void 0 || (_textRun$ts = textRun.ts) === null || _textRun$ts === void 0 ? void 0 : _textRun$ts.fs) != null;
|
|
@@ -10864,8 +10731,8 @@ var Range = class Range {
|
|
|
10864
10731
|
* Returns the font style ('italic' or 'normal') of the cell in the top-left corner of the range.
|
|
10865
10732
|
*/
|
|
10866
10733
|
getFontStyle() {
|
|
10867
|
-
var
|
|
10868
|
-
const { p } =
|
|
10734
|
+
var _p$body4;
|
|
10735
|
+
const { p } = this.getValue() ?? {};
|
|
10869
10736
|
if (p && Array.isArray((_p$body4 = p.body) === null || _p$body4 === void 0 ? void 0 : _p$body4.textRuns) && p.body.textRuns.length > 0) return isAllFormatInTextRuns("it", p.body) === 1 ? 1 : 0;
|
|
10870
10737
|
return this._getFontStyles()[0][0];
|
|
10871
10738
|
}
|
|
@@ -10882,8 +10749,8 @@ var Range = class Range {
|
|
|
10882
10749
|
* otherwise return FontWeight.NORMAL.
|
|
10883
10750
|
*/
|
|
10884
10751
|
getFontWeight() {
|
|
10885
|
-
var
|
|
10886
|
-
const { p } =
|
|
10752
|
+
var _p$body5;
|
|
10753
|
+
const { p } = this.getValue() ?? {};
|
|
10887
10754
|
if (p && Array.isArray((_p$body5 = p.body) === null || _p$body5 === void 0 ? void 0 : _p$body5.textRuns) && p.body.textRuns.length > 0) return isAllFormatInTextRuns("bl", p.body) === 1 ? 1 : 0;
|
|
10888
10755
|
return this._getFontWeights()[0][0];
|
|
10889
10756
|
}
|
|
@@ -11502,52 +11369,6 @@ var Rectangle = class Rectangle {
|
|
|
11502
11369
|
}).length > 0);
|
|
11503
11370
|
}
|
|
11504
11371
|
/**
|
|
11505
|
-
* Gets the intersection range between two ranges
|
|
11506
|
-
* @param src
|
|
11507
|
-
* @param target
|
|
11508
|
-
* @deprecated use `getIntersectRange` instead
|
|
11509
|
-
* @example
|
|
11510
|
-
* ```typescript
|
|
11511
|
-
* const range1 = { startRow: 0, startColumn: 0, endRow: 2, endColumn: 2 };
|
|
11512
|
-
* const range2 = { startRow: 1, startColumn: 1, endRow: 3, endColumn: 3 };
|
|
11513
|
-
* const intersection = Rectangle.getIntersects(range1, range2);
|
|
11514
|
-
* // intersection = { startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
|
|
11515
|
-
* ```
|
|
11516
|
-
*/
|
|
11517
|
-
static getIntersects(src, target) {
|
|
11518
|
-
const currentStartRow = src.startRow;
|
|
11519
|
-
const currentEndRow = src.endRow;
|
|
11520
|
-
const currentStartColumn = src.startColumn;
|
|
11521
|
-
const currentEndColumn = src.endColumn;
|
|
11522
|
-
const incomingStartRow = target.startRow;
|
|
11523
|
-
const incomingEndRow = target.endRow;
|
|
11524
|
-
const incomingStartColumn = target.startColumn;
|
|
11525
|
-
const incomingEndColumn = target.endColumn;
|
|
11526
|
-
let startColumn;
|
|
11527
|
-
let startRow;
|
|
11528
|
-
let endColumn;
|
|
11529
|
-
let endRow;
|
|
11530
|
-
if (incomingStartRow <= currentEndRow) if (incomingStartRow >= currentStartRow) startRow = incomingStartRow;
|
|
11531
|
-
else startRow = currentStartRow;
|
|
11532
|
-
else return null;
|
|
11533
|
-
if (incomingEndRow >= currentStartRow) if (incomingEndRow >= currentEndRow) endRow = currentEndRow;
|
|
11534
|
-
else endRow = incomingEndRow;
|
|
11535
|
-
else return null;
|
|
11536
|
-
if (incomingStartColumn <= currentEndColumn) if (incomingStartColumn > currentStartColumn) startColumn = incomingStartColumn;
|
|
11537
|
-
else startColumn = currentStartColumn;
|
|
11538
|
-
else return null;
|
|
11539
|
-
if (incomingEndColumn >= currentStartColumn) if (incomingEndColumn >= currentEndColumn) endColumn = currentEndColumn;
|
|
11540
|
-
else endColumn = incomingEndColumn;
|
|
11541
|
-
else return null;
|
|
11542
|
-
return {
|
|
11543
|
-
startRow,
|
|
11544
|
-
endRow,
|
|
11545
|
-
startColumn,
|
|
11546
|
-
endColumn,
|
|
11547
|
-
rangeType: 0
|
|
11548
|
-
};
|
|
11549
|
-
}
|
|
11550
|
-
/**
|
|
11551
11372
|
* Checks if one range completely contains another range
|
|
11552
11373
|
* @param src
|
|
11553
11374
|
* @param target
|
|
@@ -12104,7 +11925,6 @@ function ABCToNumber(a) {
|
|
|
12104
11925
|
const orderA = "A".charCodeAt(0);
|
|
12105
11926
|
"Z".charCodeAt(0);
|
|
12106
11927
|
const order_a = "a".charCodeAt(0);
|
|
12107
|
-
"z".charCodeAt(0);
|
|
12108
11928
|
/**
|
|
12109
11929
|
* column subscript number to letters
|
|
12110
11930
|
* @param n number
|
|
@@ -12201,26 +12021,25 @@ let BaseFieldType = /* @__PURE__ */ function(BaseFieldType) {
|
|
|
12201
12021
|
BaseFieldType["Checkbox"] = "checkbox";
|
|
12202
12022
|
BaseFieldType["Link"] = "link";
|
|
12203
12023
|
BaseFieldType["Formula"] = "formula";
|
|
12204
|
-
BaseFieldType["Lookup"] = "lookup";
|
|
12205
|
-
BaseFieldType["Flow"] = "flow";
|
|
12206
|
-
BaseFieldType["Button"] = "button";
|
|
12207
12024
|
BaseFieldType["Numbering"] = "numbering";
|
|
12208
12025
|
BaseFieldType["Phone"] = "phone";
|
|
12209
12026
|
BaseFieldType["Email"] = "email";
|
|
12210
|
-
BaseFieldType["Location"] = "location";
|
|
12211
|
-
BaseFieldType["Barcode"] = "barcode";
|
|
12212
12027
|
BaseFieldType["Progress"] = "progress";
|
|
12213
12028
|
BaseFieldType["Currency"] = "currency";
|
|
12214
12029
|
BaseFieldType["Rating"] = "rating";
|
|
12215
|
-
BaseFieldType["
|
|
12030
|
+
BaseFieldType["RecordLink"] = "recordLink";
|
|
12216
12031
|
BaseFieldType["RecordId"] = "recordId";
|
|
12217
12032
|
BaseFieldType["CreatedBy"] = "createdBy";
|
|
12218
12033
|
BaseFieldType["UpdatedBy"] = "updatedBy";
|
|
12219
12034
|
BaseFieldType["CreatedAt"] = "createdAt";
|
|
12220
12035
|
BaseFieldType["UpdatedAt"] = "updatedAt";
|
|
12221
|
-
BaseFieldType["Summary"] = "summary";
|
|
12222
12036
|
return BaseFieldType;
|
|
12223
12037
|
}({});
|
|
12038
|
+
/** Semantic roles supported by Base RecordLink fields. */
|
|
12039
|
+
let BaseRecordLinkRole = /* @__PURE__ */ function(BaseRecordLinkRole) {
|
|
12040
|
+
BaseRecordLinkRole["Parent"] = "parent";
|
|
12041
|
+
return BaseRecordLinkRole;
|
|
12042
|
+
}({});
|
|
12224
12043
|
let BaseViewType = /* @__PURE__ */ function(BaseViewType) {
|
|
12225
12044
|
BaseViewType["Grid"] = "grid";
|
|
12226
12045
|
BaseViewType["Kanban"] = "kanban";
|
|
@@ -12229,6 +12048,56 @@ let BaseViewType = /* @__PURE__ */ function(BaseViewType) {
|
|
|
12229
12048
|
BaseViewType["Gallery"] = "gallery";
|
|
12230
12049
|
return BaseViewType;
|
|
12231
12050
|
}({});
|
|
12051
|
+
/** Where a Base conditional color is painted when its condition matches. */
|
|
12052
|
+
const BaseConditionalColorTarget = {
|
|
12053
|
+
/** Paint only the cell in the rule's field. */
|
|
12054
|
+
CELL: "cell",
|
|
12055
|
+
/** Paint the complete record row. */
|
|
12056
|
+
ROW: "row",
|
|
12057
|
+
/** Paint the rule's field column unconditionally; operator, operand, and date mode are ignored. */
|
|
12058
|
+
COLUMN: "column"
|
|
12059
|
+
};
|
|
12060
|
+
/**
|
|
12061
|
+
* Operators supported by Base conditional coloring rules.
|
|
12062
|
+
*
|
|
12063
|
+
* Text, select, person, and similar fields support equality, containment, and
|
|
12064
|
+
* empty checks. Number, currency, progress, and rating fields support equality,
|
|
12065
|
+
* numeric comparison, and empty checks. Date-like fields support equality,
|
|
12066
|
+
* before/after, and empty checks. Checkbox fields support equality only.
|
|
12067
|
+
*/
|
|
12068
|
+
const BaseConditionalColorOperator = {
|
|
12069
|
+
IS: "is",
|
|
12070
|
+
IS_NOT: "isNot",
|
|
12071
|
+
CONTAINS: "contains",
|
|
12072
|
+
NOT_CONTAINS: "notContains",
|
|
12073
|
+
IS_EMPTY: "isEmpty",
|
|
12074
|
+
IS_NOT_EMPTY: "isNotEmpty",
|
|
12075
|
+
GREATER_THAN: "greaterThan",
|
|
12076
|
+
LESS_THAN: "lessThan",
|
|
12077
|
+
BEFORE: "before",
|
|
12078
|
+
AFTER: "after"
|
|
12079
|
+
};
|
|
12080
|
+
/**
|
|
12081
|
+
* Relative or exact date windows supported by date conditional coloring rules.
|
|
12082
|
+
*
|
|
12083
|
+
* With `IS`, dates inside the selected window match. `IS_NOT` matches dates
|
|
12084
|
+
* outside it, `BEFORE` matches dates before its start, and `AFTER` matches
|
|
12085
|
+
* dates after its end. Relative windows do not use an operand; `EXACT` does.
|
|
12086
|
+
*/
|
|
12087
|
+
const BaseConditionalDateMode = {
|
|
12088
|
+
EXACT: "exact",
|
|
12089
|
+
TODAY: "today",
|
|
12090
|
+
TOMORROW: "tomorrow",
|
|
12091
|
+
YESTERDAY: "yesterday",
|
|
12092
|
+
THIS_WEEK: "thisWeek",
|
|
12093
|
+
LAST_WEEK: "lastWeek",
|
|
12094
|
+
THIS_MONTH: "thisMonth",
|
|
12095
|
+
LAST_MONTH: "lastMonth",
|
|
12096
|
+
PAST_7_DAYS: "past7",
|
|
12097
|
+
NEXT_7_DAYS: "next7",
|
|
12098
|
+
PAST_30_DAYS: "past30",
|
|
12099
|
+
NEXT_30_DAYS: "next30"
|
|
12100
|
+
};
|
|
12232
12101
|
let BaseFilterOperator = /* @__PURE__ */ function(BaseFilterOperator) {
|
|
12233
12102
|
BaseFilterOperator["IS"] = "is";
|
|
12234
12103
|
BaseFilterOperator["IS_NOT"] = "isNot";
|
|
@@ -12254,18 +12123,58 @@ let BaseSortDirection = /* @__PURE__ */ function(BaseSortDirection) {
|
|
|
12254
12123
|
BaseSortDirection["DESC"] = "desc";
|
|
12255
12124
|
return BaseSortDirection;
|
|
12256
12125
|
}({});
|
|
12126
|
+
/** Why a stored Parent link cannot participate in the effective hierarchy. */
|
|
12127
|
+
let BaseHierarchyInvalidReason = /* @__PURE__ */ function(BaseHierarchyInvalidReason) {
|
|
12128
|
+
BaseHierarchyInvalidReason["MissingParent"] = "missingParent";
|
|
12129
|
+
BaseHierarchyInvalidReason["SelfParent"] = "selfParent";
|
|
12130
|
+
BaseHierarchyInvalidReason["Cycle"] = "cycle";
|
|
12131
|
+
BaseHierarchyInvalidReason["MaxDepth"] = "maxDepth";
|
|
12132
|
+
return BaseHierarchyInvalidReason;
|
|
12133
|
+
}({});
|
|
12134
|
+
|
|
12135
|
+
//#endregion
|
|
12136
|
+
//#region src/bases/record-identity.ts
|
|
12137
|
+
const BASE_RECORD_ID_FIELD_ID = "__record_id";
|
|
12138
|
+
const BASE_RECORD_ID_FIELD_NAME = "record-id";
|
|
12139
|
+
const BASE_RECORD_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
12140
|
+
function createBaseRecordIdField() {
|
|
12141
|
+
return {
|
|
12142
|
+
id: BASE_RECORD_ID_FIELD_ID,
|
|
12143
|
+
name: BASE_RECORD_ID_FIELD_NAME,
|
|
12144
|
+
type: "recordId",
|
|
12145
|
+
config: {},
|
|
12146
|
+
system: true,
|
|
12147
|
+
readonly: true
|
|
12148
|
+
};
|
|
12149
|
+
}
|
|
12150
|
+
function isValidBaseRecordId(recordId) {
|
|
12151
|
+
return BASE_RECORD_ID_PATTERN.test(recordId);
|
|
12152
|
+
}
|
|
12153
|
+
function isBaseRecordIdFieldName(name) {
|
|
12154
|
+
return name.trim().toLowerCase() === BASE_RECORD_ID_FIELD_NAME;
|
|
12155
|
+
}
|
|
12156
|
+
function assertBaseTableRecordIdentity(table) {
|
|
12157
|
+
const recordIdField = table.fields[BASE_RECORD_ID_FIELD_ID];
|
|
12158
|
+
const recordIdFields = Object.values(table.fields).filter((field) => field.type === "recordId");
|
|
12159
|
+
if (!recordIdField || recordIdFields.length !== 1 || recordIdField.type !== "recordId" || recordIdField.name !== "record-id" || recordIdField.system !== true || recordIdField.readonly !== true || table.fieldOrder[0] !== "__record_id" || table.primaryFieldId === "__record_id" || !table.fields[table.primaryFieldId]) throw new Error(`[BaseDataModel]: table "${table.id}" has an invalid record-id system field.`);
|
|
12160
|
+
const conflictingField = Object.values(table.fields).find((field) => {
|
|
12161
|
+
return field.id !== "__record_id" && isBaseRecordIdFieldName(field.name);
|
|
12162
|
+
});
|
|
12163
|
+
if (conflictingField) throw new Error(`[BaseDataModel]: field name "${conflictingField.name}" is reserved for the record-id system field.`);
|
|
12164
|
+
for (const [recordKey, record] of Object.entries(table.records)) if (record.id !== recordKey || !isValidBaseRecordId(record.id) || record.values["__record_id"] !== record.id) throw new Error(`[BaseDataModel]: record "${recordKey}" has an invalid record-id projection.`);
|
|
12165
|
+
}
|
|
12257
12166
|
|
|
12258
12167
|
//#endregion
|
|
12259
12168
|
//#region src/bases/empty-snapshot.ts
|
|
12260
12169
|
function createDefaultBaseTableSnapshot(options) {
|
|
12261
|
-
|
|
12262
|
-
const
|
|
12263
|
-
const
|
|
12264
|
-
const
|
|
12265
|
-
const
|
|
12170
|
+
const now = options.now ?? Date.now();
|
|
12171
|
+
const primaryFieldId = options.primaryFieldId ?? generateRandomId(6);
|
|
12172
|
+
const gridViewId = options.gridViewId ?? generateRandomId(6);
|
|
12173
|
+
const recordCount = options.recordCount ?? 0;
|
|
12174
|
+
const recordIdField = createBaseRecordIdField();
|
|
12266
12175
|
const primaryField = {
|
|
12267
12176
|
id: primaryFieldId,
|
|
12268
|
-
name:
|
|
12177
|
+
name: options.primaryFieldName ?? "Name",
|
|
12269
12178
|
type: "text",
|
|
12270
12179
|
config: { placeholder: "bases.fieldConfig.textPlaceholder" }
|
|
12271
12180
|
};
|
|
@@ -12278,7 +12187,7 @@ function createDefaultBaseTableSnapshot(options) {
|
|
|
12278
12187
|
const recordId = `${options.id}-record-${index + 1}`;
|
|
12279
12188
|
records[recordId] = {
|
|
12280
12189
|
id: recordId,
|
|
12281
|
-
values: {},
|
|
12190
|
+
values: { [BASE_RECORD_ID_FIELD_ID]: recordId },
|
|
12282
12191
|
orderKey: String(index + 1).padStart(4, "0"),
|
|
12283
12192
|
createdAt: now,
|
|
12284
12193
|
updatedAt: now
|
|
@@ -12286,29 +12195,41 @@ function createDefaultBaseTableSnapshot(options) {
|
|
|
12286
12195
|
recordOrder.push(recordId);
|
|
12287
12196
|
rowIndex[recordId] = index;
|
|
12288
12197
|
rowId[index] = recordId;
|
|
12289
|
-
cellData[index] = {
|
|
12198
|
+
cellData[index] = { 0: {
|
|
12199
|
+
v: recordId,
|
|
12200
|
+
t: 1
|
|
12201
|
+
} };
|
|
12290
12202
|
}
|
|
12291
12203
|
const gridView = {
|
|
12292
12204
|
id: gridViewId,
|
|
12293
12205
|
tableId: options.id,
|
|
12294
12206
|
name: "Grid",
|
|
12295
12207
|
type: "grid",
|
|
12296
|
-
fieldOrder: [primaryFieldId],
|
|
12297
|
-
fieldSettings: {},
|
|
12208
|
+
fieldOrder: [BASE_RECORD_ID_FIELD_ID, primaryFieldId],
|
|
12209
|
+
fieldSettings: { [BASE_RECORD_ID_FIELD_ID]: { hidden: true } },
|
|
12298
12210
|
config: { frozenFieldCount: 1 }
|
|
12299
12211
|
};
|
|
12300
12212
|
return {
|
|
12301
12213
|
id: options.id,
|
|
12302
12214
|
name: options.name,
|
|
12303
12215
|
primaryFieldId,
|
|
12304
|
-
fieldOrder: [primaryFieldId],
|
|
12305
|
-
fields: {
|
|
12216
|
+
fieldOrder: [BASE_RECORD_ID_FIELD_ID, primaryFieldId],
|
|
12217
|
+
fields: {
|
|
12218
|
+
[BASE_RECORD_ID_FIELD_ID]: recordIdField,
|
|
12219
|
+
[primaryFieldId]: primaryField
|
|
12220
|
+
},
|
|
12306
12221
|
records,
|
|
12307
12222
|
recordOrder,
|
|
12308
12223
|
rowIndex,
|
|
12309
12224
|
rowId,
|
|
12310
|
-
colIndex: {
|
|
12311
|
-
|
|
12225
|
+
colIndex: {
|
|
12226
|
+
[BASE_RECORD_ID_FIELD_ID]: 0,
|
|
12227
|
+
[primaryFieldId]: 1
|
|
12228
|
+
},
|
|
12229
|
+
colId: {
|
|
12230
|
+
0: BASE_RECORD_ID_FIELD_ID,
|
|
12231
|
+
1: primaryFieldId
|
|
12232
|
+
},
|
|
12312
12233
|
cellData,
|
|
12313
12234
|
resources: {
|
|
12314
12235
|
attachmentSets: {},
|
|
@@ -12326,13 +12247,13 @@ function getEmptySnapshot(unitId = generateRandomId(), name = "", locale = "zhCN
|
|
|
12326
12247
|
name,
|
|
12327
12248
|
locale,
|
|
12328
12249
|
appVersion: version,
|
|
12329
|
-
schemaVersion:
|
|
12250
|
+
schemaVersion: 2,
|
|
12330
12251
|
tableOrder: [tableId],
|
|
12331
12252
|
tables: { [tableId]: createDefaultBaseTableSnapshot({
|
|
12332
12253
|
id: tableId,
|
|
12333
12254
|
name: "Table 1",
|
|
12334
12255
|
now,
|
|
12335
|
-
recordCount:
|
|
12256
|
+
recordCount: 0
|
|
12336
12257
|
}) },
|
|
12337
12258
|
createdAt: now,
|
|
12338
12259
|
updatedAt: now
|
|
@@ -12386,8 +12307,7 @@ var BaseDataModel = class extends UnitModel {
|
|
|
12386
12307
|
this._name$.next(snapshot.name);
|
|
12387
12308
|
}
|
|
12388
12309
|
getRev() {
|
|
12389
|
-
|
|
12390
|
-
return (_this$_snapshot$rev = this._snapshot.rev) !== null && _this$_snapshot$rev !== void 0 ? _this$_snapshot$rev : 1;
|
|
12310
|
+
return this._snapshot.rev ?? 1;
|
|
12391
12311
|
}
|
|
12392
12312
|
incrementRev() {
|
|
12393
12313
|
this._snapshot.rev = this.getRev() + 1;
|
|
@@ -12401,27 +12321,28 @@ var BaseDataModel = class extends UnitModel {
|
|
|
12401
12321
|
}
|
|
12402
12322
|
};
|
|
12403
12323
|
function normalizeBaseSnapshot(snapshot) {
|
|
12404
|
-
var _snapshot$tables;
|
|
12405
12324
|
delete snapshot.compress;
|
|
12406
12325
|
delete snapshot.kind;
|
|
12407
|
-
Object.values(
|
|
12326
|
+
Object.values(snapshot.tables ?? {}).forEach((table) => {
|
|
12327
|
+
assertBaseTableRecordIdentity(table);
|
|
12408
12328
|
normalizeBaseTable(table);
|
|
12329
|
+
assertMaterializedRecordIdentity(table);
|
|
12409
12330
|
});
|
|
12410
12331
|
return snapshot;
|
|
12411
12332
|
}
|
|
12412
12333
|
function isNormalizedBaseSnapshot(snapshot) {
|
|
12413
|
-
|
|
12414
|
-
return Object.values((_snapshot$tables2 = snapshot.tables) !== null && _snapshot$tables2 !== void 0 ? _snapshot$tables2 : {}).every((table) => isNormalizedBaseTable(table));
|
|
12334
|
+
return Object.values(snapshot.tables ?? {}).every((table) => isNormalizedBaseTable(table));
|
|
12415
12335
|
}
|
|
12416
12336
|
function isNormalizedBaseTable(table) {
|
|
12417
|
-
|
|
12418
|
-
const
|
|
12419
|
-
|
|
12337
|
+
const records = table.records ?? {};
|
|
12338
|
+
const fields = table.fields ?? {};
|
|
12339
|
+
assertBaseTableRecordIdentity(table);
|
|
12420
12340
|
if (!Array.isArray(table.recordOrder) || !table.rowIndex || !table.rowId || !table.colIndex || !table.colId || !table.cellData || !table.resources || !table.resources.attachmentSets || !table.resources.attachments) return false;
|
|
12421
12341
|
if (Object.keys(records).length !== table.recordOrder.length) return false;
|
|
12422
12342
|
for (let index = 0; index < table.recordOrder.length; index++) {
|
|
12343
|
+
var _table$cellData$index;
|
|
12423
12344
|
const recordId = table.recordOrder[index];
|
|
12424
|
-
if (!records[recordId] || table.rowIndex[recordId] !== index || table.rowId[index] !== recordId) return false;
|
|
12345
|
+
if (!records[recordId] || table.rowIndex[recordId] !== index || table.rowId[index] !== recordId || ((_table$cellData$index = table.cellData[index]) === null || _table$cellData$index === void 0 || (_table$cellData$index = _table$cellData$index[0]) === null || _table$cellData$index === void 0 ? void 0 : _table$cellData$index.v) !== recordId) return false;
|
|
12425
12346
|
}
|
|
12426
12347
|
for (let index = 0; index < table.fieldOrder.length; index++) {
|
|
12427
12348
|
const fieldId = table.fieldOrder[index];
|
|
@@ -12431,10 +12352,9 @@ function isNormalizedBaseTable(table) {
|
|
|
12431
12352
|
return true;
|
|
12432
12353
|
}
|
|
12433
12354
|
function normalizeBaseTable(table) {
|
|
12434
|
-
var _table$records2, _table$fields2;
|
|
12435
12355
|
hydrateCompressedCellData(table);
|
|
12436
|
-
const records =
|
|
12437
|
-
const fields =
|
|
12356
|
+
const records = table.records ?? {};
|
|
12357
|
+
const fields = table.fields ?? {};
|
|
12438
12358
|
const orderedRecordIds = getOrderedRecordIds(table, records);
|
|
12439
12359
|
const orderedFieldIds = getOrderedFieldIds(table, fields);
|
|
12440
12360
|
table.recordOrder = orderedRecordIds;
|
|
@@ -12449,8 +12369,7 @@ function hydrateCompressedCellData(table) {
|
|
|
12449
12369
|
if (compressedCellData && !table.cellData) {
|
|
12450
12370
|
table.cellData = Object.create(null);
|
|
12451
12371
|
compressedCellData.forEach(([row, col, cell]) => {
|
|
12452
|
-
|
|
12453
|
-
table.cellData[row] = (_row = table.cellData[row]) !== null && _row !== void 0 ? _row : {};
|
|
12372
|
+
table.cellData[row] = table.cellData[row] ?? {};
|
|
12454
12373
|
const { c: _compressed, ...cellData } = cell;
|
|
12455
12374
|
table.cellData[row][col] = cellData;
|
|
12456
12375
|
});
|
|
@@ -12458,8 +12377,8 @@ function hydrateCompressedCellData(table) {
|
|
|
12458
12377
|
}
|
|
12459
12378
|
}
|
|
12460
12379
|
function getOrderedRecordIds(table, records) {
|
|
12461
|
-
var _table$recordOrder
|
|
12462
|
-
const orderedRecordIds = (
|
|
12380
|
+
var _table$recordOrder;
|
|
12381
|
+
const orderedRecordIds = ((_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.filter((recordId) => records[recordId])) ?? [];
|
|
12463
12382
|
const orderedRecordIdSet = new Set(orderedRecordIds);
|
|
12464
12383
|
const missingRecords = Object.values(records).filter((record) => !orderedRecordIdSet.has(record.id));
|
|
12465
12384
|
if (!missingRecords.length) return orderedRecordIds;
|
|
@@ -12479,12 +12398,10 @@ function cloneBaseTableMutableMaps(table) {
|
|
|
12479
12398
|
table.resources.attachments = { ...table.resources.attachments };
|
|
12480
12399
|
}
|
|
12481
12400
|
function normalizeExistingCellData(table, fields) {
|
|
12482
|
-
|
|
12483
|
-
Object.entries((_table$cellData = table.cellData) !== null && _table$cellData !== void 0 ? _table$cellData : {}).forEach(([rowKey, rowData]) => {
|
|
12484
|
-
var _row2;
|
|
12401
|
+
Object.entries(table.cellData ?? {}).forEach(([rowKey, rowData]) => {
|
|
12485
12402
|
const row = Number(rowKey);
|
|
12486
12403
|
table.cellData[row] = { ...rowData };
|
|
12487
|
-
Object.entries(
|
|
12404
|
+
Object.entries(table.cellData[row] ?? {}).forEach(([colKey, cell]) => {
|
|
12488
12405
|
var _table$colId;
|
|
12489
12406
|
const col = Number(colKey);
|
|
12490
12407
|
const fieldId = (_table$colId = table.colId) === null || _table$colId === void 0 ? void 0 : _table$colId[col];
|
|
@@ -12493,44 +12410,58 @@ function normalizeExistingCellData(table, fields) {
|
|
|
12493
12410
|
});
|
|
12494
12411
|
}
|
|
12495
12412
|
function rebuildRowIndexes(table, records, orderedRecordIds) {
|
|
12496
|
-
var _table$rowIndex;
|
|
12497
12413
|
orderedRecordIds.forEach((recordId, index) => {
|
|
12498
12414
|
if (table.rowIndex[recordId] == null) table.rowIndex[recordId] = index;
|
|
12499
12415
|
});
|
|
12500
|
-
Object.entries(
|
|
12416
|
+
Object.entries(table.rowIndex ?? {}).forEach(([recordId, row]) => {
|
|
12501
12417
|
if (records[recordId]) table.rowId[row] = recordId;
|
|
12502
12418
|
});
|
|
12503
12419
|
}
|
|
12504
12420
|
function rebuildColumnIndexes(table, fields, orderedFieldIds) {
|
|
12505
|
-
var _table$colIndex;
|
|
12506
12421
|
orderedFieldIds.forEach((fieldId, index) => {
|
|
12507
12422
|
if (table.colIndex[fieldId] == null) table.colIndex[fieldId] = index;
|
|
12508
12423
|
});
|
|
12509
|
-
Object.entries(
|
|
12424
|
+
Object.entries(table.colIndex ?? {}).forEach(([fieldId, col]) => {
|
|
12510
12425
|
if (fields[fieldId]) table.colId[col] = fieldId;
|
|
12511
12426
|
});
|
|
12512
12427
|
}
|
|
12513
12428
|
function hydrateRecordCellData(table, records, fields) {
|
|
12429
|
+
const rowIndex = table.rowIndex ?? {};
|
|
12430
|
+
const colIndex = table.colIndex ?? {};
|
|
12431
|
+
const cellData = table.cellData ?? {};
|
|
12432
|
+
table.rowIndex = rowIndex;
|
|
12433
|
+
table.colIndex = colIndex;
|
|
12434
|
+
table.cellData = cellData;
|
|
12514
12435
|
Object.values(records).forEach((record) => {
|
|
12515
|
-
|
|
12516
|
-
const row = table.rowIndex[record.id];
|
|
12436
|
+
const row = rowIndex[record.id];
|
|
12517
12437
|
if (row == null) return;
|
|
12518
|
-
|
|
12519
|
-
|
|
12438
|
+
cellData[row] = { ...cellData[row] };
|
|
12439
|
+
cellData[row][0] = {
|
|
12440
|
+
v: record.id,
|
|
12441
|
+
t: 1
|
|
12442
|
+
};
|
|
12443
|
+
Object.entries(record.values ?? {}).forEach(([fieldId, value]) => {
|
|
12520
12444
|
const field = fields[fieldId];
|
|
12521
12445
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") writeAttachmentResources(table, record.id, fieldId, value);
|
|
12522
|
-
const col =
|
|
12446
|
+
const col = colIndex[fieldId];
|
|
12523
12447
|
if (col == null) return;
|
|
12524
|
-
const existingCell =
|
|
12448
|
+
const existingCell = cellData[row][col];
|
|
12525
12449
|
if (existingCell != null) {
|
|
12526
|
-
|
|
12527
|
-
if (shouldRefreshCellDataFromRecord(existingCell, field, value))
|
|
12450
|
+
cellData[row][col] = normalizeBaseCellData(existingCell, field);
|
|
12451
|
+
if (shouldRefreshCellDataFromRecord(existingCell, field, value)) cellData[row][col] = toBaseCellData(value, field);
|
|
12528
12452
|
return;
|
|
12529
12453
|
}
|
|
12530
|
-
|
|
12454
|
+
cellData[row][col] = toBaseCellData(value, field);
|
|
12531
12455
|
});
|
|
12532
12456
|
});
|
|
12533
12457
|
}
|
|
12458
|
+
function assertMaterializedRecordIdentity(table) {
|
|
12459
|
+
for (const record of Object.values(table.records)) {
|
|
12460
|
+
var _table$rowIndex, _table$colIndex, _table$colId2, _table$cellData;
|
|
12461
|
+
const row = (_table$rowIndex = table.rowIndex) === null || _table$rowIndex === void 0 ? void 0 : _table$rowIndex[record.id];
|
|
12462
|
+
if (row == null || ((_table$colIndex = table.colIndex) === null || _table$colIndex === void 0 ? void 0 : _table$colIndex["__record_id"]) !== 0 || ((_table$colId2 = table.colId) === null || _table$colId2 === void 0 ? void 0 : _table$colId2[0]) !== "__record_id" || ((_table$cellData = table.cellData) === null || _table$cellData === void 0 || (_table$cellData = _table$cellData[row]) === null || _table$cellData === void 0 || (_table$cellData = _table$cellData[0]) === null || _table$cellData === void 0 ? void 0 : _table$cellData.v) !== record.id) throw new Error(`[BaseDataModel]: record "${record.id}" is missing its record-id cell projection.`);
|
|
12463
|
+
}
|
|
12464
|
+
}
|
|
12534
12465
|
function toBaseCellData(value, field) {
|
|
12535
12466
|
if (isBaseCellData(value)) {
|
|
12536
12467
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") return {
|
|
@@ -12549,10 +12480,9 @@ function toBaseCellData(value, field) {
|
|
|
12549
12480
|
t: 1
|
|
12550
12481
|
};
|
|
12551
12482
|
if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
12552
|
-
var _ref, _link$text;
|
|
12553
12483
|
const link = value;
|
|
12554
12484
|
return {
|
|
12555
|
-
v: String(
|
|
12485
|
+
v: String(link.text ?? link.url ?? ""),
|
|
12556
12486
|
t: 1
|
|
12557
12487
|
};
|
|
12558
12488
|
}
|
|
@@ -12586,8 +12516,7 @@ function writeAttachmentResources(table, recordId, fieldId, value) {
|
|
|
12586
12516
|
table.resources.attachments = { ...table.resources.attachments };
|
|
12587
12517
|
const key = `${fieldId}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${recordId}`;
|
|
12588
12518
|
table.resources.attachmentSets[key] = attachments.map((attachment, index) => {
|
|
12589
|
-
|
|
12590
|
-
const id = String((_attachment$id = attachment.id) !== null && _attachment$id !== void 0 ? _attachment$id : `${key}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${index}`);
|
|
12519
|
+
const id = String(attachment.id ?? `${key}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${index}`);
|
|
12591
12520
|
const normalizedAttachment = {
|
|
12592
12521
|
...attachment,
|
|
12593
12522
|
id
|
|
@@ -12616,6 +12545,7 @@ function normalizeAttachmentValue(value) {
|
|
|
12616
12545
|
return attachments;
|
|
12617
12546
|
}
|
|
12618
12547
|
function shouldRefreshCellDataFromRecord(cell, field, value) {
|
|
12548
|
+
if ((field === null || field === void 0 ? void 0 : field.type) === "recordId") return cell.v !== value;
|
|
12619
12549
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") return cell.v !== "";
|
|
12620
12550
|
if (isListField(field)) return Array.isArray(value) && (cell.v == null || cell.v === "");
|
|
12621
12551
|
return false;
|
|
@@ -12644,9 +12574,8 @@ function primitiveText(value) {
|
|
|
12644
12574
|
if (value == null) return "";
|
|
12645
12575
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value);
|
|
12646
12576
|
if (typeof value === "object") {
|
|
12647
|
-
var _ref2, _ref3, _record$id;
|
|
12648
12577
|
const record = value;
|
|
12649
|
-
return String(
|
|
12578
|
+
return String(record.id ?? record.name ?? record.text ?? "");
|
|
12650
12579
|
}
|
|
12651
12580
|
return String(value);
|
|
12652
12581
|
}
|
|
@@ -12658,7 +12587,7 @@ function inferPrimitiveType(value) {
|
|
|
12658
12587
|
}
|
|
12659
12588
|
function normalizeBaseCellValueType(type, value) {
|
|
12660
12589
|
if (type === 1 || type === 2 || type === 3 || type === 4 || type == null) return type;
|
|
12661
|
-
return inferPrimitiveType(value
|
|
12590
|
+
return inferPrimitiveType(value ?? null);
|
|
12662
12591
|
}
|
|
12663
12592
|
|
|
12664
12593
|
//#endregion
|
|
@@ -12828,10 +12757,7 @@ var InterceptorManager = class {
|
|
|
12828
12757
|
if (!this._interceptorsByName.has(key)) this._interceptorsByName.set(key, []);
|
|
12829
12758
|
const interceptors = this._interceptorsByName.get(key);
|
|
12830
12759
|
interceptors.push(interceptor);
|
|
12831
|
-
this._interceptorsByName.set(key, interceptors.sort((a, b) =>
|
|
12832
|
-
var _b$priority, _a$priority;
|
|
12833
|
-
return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);
|
|
12834
|
-
}));
|
|
12760
|
+
this._interceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
12835
12761
|
return () => remove(this._interceptorsByName.get(key), interceptor);
|
|
12836
12762
|
}
|
|
12837
12763
|
getInterceptPoints() {
|
|
@@ -12887,10 +12813,7 @@ var AsyncInterceptorManager = class {
|
|
|
12887
12813
|
if (!this._asyncInterceptorsByName.has(key)) this._asyncInterceptorsByName.set(key, []);
|
|
12888
12814
|
const interceptors = this._asyncInterceptorsByName.get(key);
|
|
12889
12815
|
interceptors.push(interceptor);
|
|
12890
|
-
this._asyncInterceptorsByName.set(key, interceptors.sort((a, b) =>
|
|
12891
|
-
var _b$priority2, _a$priority2;
|
|
12892
|
-
return ((_b$priority2 = b.priority) !== null && _b$priority2 !== void 0 ? _b$priority2 : 0) - ((_a$priority2 = a.priority) !== null && _a$priority2 !== void 0 ? _a$priority2 : 0);
|
|
12893
|
-
}));
|
|
12816
|
+
this._asyncInterceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
12894
12817
|
return () => remove(this._asyncInterceptorsByName.get(key), interceptor);
|
|
12895
12818
|
}
|
|
12896
12819
|
getInterceptPoints() {
|
|
@@ -12996,7 +12919,8 @@ const blackLuminance = getLuminance(black.r, black.g, black.b);
|
|
|
12996
12919
|
* @returns The inverted color.
|
|
12997
12920
|
*/
|
|
12998
12921
|
function invertNormalizedColorByHSL(color) {
|
|
12999
|
-
const
|
|
12922
|
+
const originalLuminance = getLuminance(color[0], color[1], color[2]);
|
|
12923
|
+
const originalContrast = getContrastRatio(whiteLuminance, originalLuminance);
|
|
13000
12924
|
const hsl = rgbToHsl(color);
|
|
13001
12925
|
let l = 1 - hsl[2];
|
|
13002
12926
|
let newColor, newLuminance, newContrast;
|
|
@@ -13282,10 +13206,9 @@ function createParagraphId(existingIds) {
|
|
|
13282
13206
|
return paragraphId;
|
|
13283
13207
|
}
|
|
13284
13208
|
function cloneBodyWithFreshParagraphIds(body, _scope) {
|
|
13285
|
-
var _cloned$paragraphs;
|
|
13286
13209
|
const cloned = cloneBody(body);
|
|
13287
13210
|
const existingIds = /* @__PURE__ */ new Set();
|
|
13288
|
-
for (const paragraph of
|
|
13211
|
+
for (const paragraph of cloned.paragraphs ?? []) paragraph.paragraphId = createParagraphId(existingIds);
|
|
13289
13212
|
return cloned;
|
|
13290
13213
|
}
|
|
13291
13214
|
function cloneParagraphWithId(paragraph, existingIds, preserveId) {
|
|
@@ -13479,10 +13402,6 @@ let DataStreamTreeTokenType = /* @__PURE__ */ function(DataStreamTreeTokenType)
|
|
|
13479
13402
|
DataStreamTreeTokenType["SPACE"] = " ";
|
|
13480
13403
|
return DataStreamTreeTokenType;
|
|
13481
13404
|
}({});
|
|
13482
|
-
/** Wrap your stream in a pair of custom range tokens. */
|
|
13483
|
-
function makeCustomRangeStream(stream) {
|
|
13484
|
-
return `${stream}`;
|
|
13485
|
-
}
|
|
13486
13405
|
|
|
13487
13406
|
//#endregion
|
|
13488
13407
|
//#region src/docs/data-model/text-x/build-utils/range-interval.ts
|
|
@@ -13661,13 +13580,12 @@ function normalizeTextRuns(textRuns, reserveEmptyTextRun = false) {
|
|
|
13661
13580
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13662
13581
|
*/
|
|
13663
13582
|
function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
13664
|
-
var _insertBody$textRuns;
|
|
13665
13583
|
const { textRuns } = body;
|
|
13666
13584
|
if (textRuns == null) return;
|
|
13667
13585
|
const newTextRuns = [];
|
|
13668
13586
|
const len = textRuns.length;
|
|
13669
13587
|
let hasInserted = false;
|
|
13670
|
-
const insertTextRuns =
|
|
13588
|
+
const insertTextRuns = insertBody.textRuns ?? [];
|
|
13671
13589
|
if (insertTextRuns.length) for (const insertTextRun of insertTextRuns) {
|
|
13672
13590
|
insertTextRun.st += currentIndex;
|
|
13673
13591
|
insertTextRun.ed += currentIndex;
|
|
@@ -13715,9 +13633,9 @@ function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
|
13715
13633
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13716
13634
|
*/
|
|
13717
13635
|
function insertParagraphs(body, insertBody, textLength, currentIndex, preserveMissingParagraphIds = false, originalDataStream = body.dataStream) {
|
|
13718
|
-
var _insertBody$paragraph
|
|
13636
|
+
var _insertBody$paragraph;
|
|
13719
13637
|
if (!body.paragraphs && !((_insertBody$paragraph = insertBody.paragraphs) === null || _insertBody$paragraph === void 0 ? void 0 : _insertBody$paragraph.length)) return;
|
|
13720
|
-
|
|
13638
|
+
body.paragraphs ??= [];
|
|
13721
13639
|
const { paragraphs } = body;
|
|
13722
13640
|
const { paragraphs: insertParagraphs } = insertBody;
|
|
13723
13641
|
normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, {
|
|
@@ -13750,7 +13668,6 @@ function insertParagraphs(body, insertBody, textLength, currentIndex, preserveMi
|
|
|
13750
13668
|
}
|
|
13751
13669
|
}
|
|
13752
13670
|
function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, options) {
|
|
13753
|
-
var _options$reservedPara;
|
|
13754
13671
|
if (!paragraphs || !(insertParagraphs === null || insertParagraphs === void 0 ? void 0 : insertParagraphs.length)) return;
|
|
13755
13672
|
const splitParagraph = getParagraphSplitByInsert(paragraphs, currentIndex, options.dataStream);
|
|
13756
13673
|
const firstSplitInsertIndex = splitParagraph ? getFirstInsertedParagraphIndex(insertParagraphs) : -1;
|
|
@@ -13760,12 +13677,11 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13760
13677
|
const existingParagraphIds = collectParagraphIds(paragraphs);
|
|
13761
13678
|
const preservedInsertedParagraphIds = /* @__PURE__ */ new Set();
|
|
13762
13679
|
if (splitParagraphId) existingParagraphIds.delete(splitParagraphId);
|
|
13763
|
-
for (const paragraphId of
|
|
13680
|
+
for (const paragraphId of options.reservedParagraphIds ?? []) existingParagraphIds.add(paragraphId);
|
|
13764
13681
|
let splitRemainderParagraph;
|
|
13765
13682
|
if (splitParagraphId && firstSplitInsertIndex !== -1 && !shouldPreserveExplicitSplitParagraphId) {
|
|
13766
|
-
var _options$preserveMiss;
|
|
13767
13683
|
const firstInsertParagraph = insertParagraphs[firstSplitInsertIndex];
|
|
13768
|
-
splitRemainderParagraph = firstInsertedParagraphId != null && firstInsertedParagraphId !== splitParagraphId ? cloneInsertedParagraphWithId(firstInsertParagraph, existingParagraphIds,
|
|
13684
|
+
splitRemainderParagraph = firstInsertedParagraphId != null && firstInsertedParagraphId !== splitParagraphId ? cloneInsertedParagraphWithId(firstInsertParagraph, existingParagraphIds, options.preserveMissingParagraphIds ?? false) : cloneParagraphWithId(firstInsertParagraph, existingParagraphIds, false);
|
|
13769
13685
|
if (options.freshenSplitParagraph && splitRemainderParagraph.paragraphId) splitParagraph.paragraphId = splitRemainderParagraph.paragraphId;
|
|
13770
13686
|
}
|
|
13771
13687
|
for (let i = 0, len = insertParagraphs.length; i < len; i++) {
|
|
@@ -13776,8 +13692,7 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13776
13692
|
continue;
|
|
13777
13693
|
}
|
|
13778
13694
|
if (i !== firstSplitInsertIndex || splitParagraphId == null || shouldPreserveExplicitSplitParagraphId) {
|
|
13779
|
-
|
|
13780
|
-
insertParagraphs[i] = cloneInsertedParagraphWithId(insertParagraphs[i], existingParagraphIds, (_options$preserveMiss2 = options.preserveMissingParagraphIds) !== null && _options$preserveMiss2 !== void 0 ? _options$preserveMiss2 : false);
|
|
13695
|
+
insertParagraphs[i] = cloneInsertedParagraphWithId(insertParagraphs[i], existingParagraphIds, options.preserveMissingParagraphIds ?? false);
|
|
13781
13696
|
continue;
|
|
13782
13697
|
}
|
|
13783
13698
|
insertParagraphs[i] = options.freshenSplitParagraph || firstInsertedParagraphId == null || firstInsertedParagraphId === splitParagraphId ? cloneParagraphWithId({
|
|
@@ -13786,13 +13701,13 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13786
13701
|
}, existingParagraphIds) : splitRemainderParagraph;
|
|
13787
13702
|
}
|
|
13788
13703
|
for (const insertParagraph of insertParagraphs) if (insertParagraph.paragraphId) {
|
|
13789
|
-
var _options$
|
|
13790
|
-
(_options$
|
|
13704
|
+
var _options$reservedPara;
|
|
13705
|
+
(_options$reservedPara = options.reservedParagraphIds) === null || _options$reservedPara === void 0 || _options$reservedPara.add(insertParagraph.paragraphId);
|
|
13791
13706
|
}
|
|
13792
13707
|
}
|
|
13793
13708
|
function collectParagraphIds(paragraphs) {
|
|
13794
13709
|
const paragraphIds = /* @__PURE__ */ new Set();
|
|
13795
|
-
for (const paragraph of paragraphs
|
|
13710
|
+
for (const paragraph of paragraphs ?? []) if (paragraph.paragraphId) paragraphIds.add(paragraph.paragraphId);
|
|
13796
13711
|
return paragraphIds;
|
|
13797
13712
|
}
|
|
13798
13713
|
function cloneInsertedParagraphWithId(insertParagraph, existingParagraphIds, preserveMissingParagraphIds) {
|
|
@@ -13833,9 +13748,9 @@ function getFirstInsertedParagraphIndex(insertParagraphs) {
|
|
|
13833
13748
|
return index;
|
|
13834
13749
|
}
|
|
13835
13750
|
function insertSectionBreaks(body, insertBody, textLength, currentIndex) {
|
|
13836
|
-
var _insertBody$sectionBr
|
|
13751
|
+
var _insertBody$sectionBr;
|
|
13837
13752
|
if (!body.sectionBreaks && !((_insertBody$sectionBr = insertBody.sectionBreaks) === null || _insertBody$sectionBr === void 0 ? void 0 : _insertBody$sectionBr.length)) return;
|
|
13838
|
-
|
|
13753
|
+
body.sectionBreaks ??= [];
|
|
13839
13754
|
const { sectionBreaks } = body;
|
|
13840
13755
|
const insertSectionBreaks = insertBody.sectionBreaks;
|
|
13841
13756
|
normalizeInsertedSectionIdsForDocument(sectionBreaks, insertSectionBreaks);
|
|
@@ -13862,9 +13777,8 @@ function insertSectionBreaks(body, insertBody, textLength, currentIndex) {
|
|
|
13862
13777
|
}
|
|
13863
13778
|
}
|
|
13864
13779
|
function normalizeInsertedSectionIdsForDocument(sectionBreaks, insertSectionBreaks, reservedSectionIds = /* @__PURE__ */ new Set()) {
|
|
13865
|
-
var _sectionBreaks$map;
|
|
13866
13780
|
if (!(insertSectionBreaks === null || insertSectionBreaks === void 0 ? void 0 : insertSectionBreaks.length)) return;
|
|
13867
|
-
const existingSectionIds = new Set((
|
|
13781
|
+
const existingSectionIds = new Set((sectionBreaks === null || sectionBreaks === void 0 ? void 0 : sectionBreaks.map((sectionBreak) => sectionBreak.sectionId)) ?? []);
|
|
13868
13782
|
for (const sectionId of reservedSectionIds) existingSectionIds.add(sectionId);
|
|
13869
13783
|
for (let i = 0; i < insertSectionBreaks.length; i++) {
|
|
13870
13784
|
insertSectionBreaks[i] = cloneSectionBreakWithId(insertSectionBreaks[i], existingSectionIds);
|
|
@@ -14918,7 +14832,7 @@ function updateParagraphs(body, updateBody, textLength, currentIndex, coverType)
|
|
|
14918
14832
|
if (updateStartIndex === removeStartIndex) {
|
|
14919
14833
|
splitUpdateParagraphs.push({
|
|
14920
14834
|
startIndex: updateStartIndex,
|
|
14921
|
-
paragraphId: updateParagraphId
|
|
14835
|
+
paragraphId: updateParagraphId ?? removeParagraphId,
|
|
14922
14836
|
paragraphStyle: newParagraphStyle,
|
|
14923
14837
|
bullet: newBullet
|
|
14924
14838
|
});
|
|
@@ -15188,7 +15102,7 @@ function isSegmentIntersects(start, end, start2, end2) {
|
|
|
15188
15102
|
}
|
|
15189
15103
|
function getParagraphsInRange(activeRange, paragraphs, dataStream, paragraphRanges) {
|
|
15190
15104
|
const { startOffset, endOffset } = activeRange;
|
|
15191
|
-
const fullParagraphs = paragraphRanges
|
|
15105
|
+
const fullParagraphs = paragraphRanges ?? transformParagraphs(paragraphs, dataStream);
|
|
15192
15106
|
const results = [];
|
|
15193
15107
|
let start = -1;
|
|
15194
15108
|
for (let i = 0; i < fullParagraphs.length; i++) {
|
|
@@ -15236,10 +15150,10 @@ function transformParagraphs(paragraphs, dataStream) {
|
|
|
15236
15150
|
//#endregion
|
|
15237
15151
|
//#region src/docs/data-model/text-x/build-utils/paragraph.ts
|
|
15238
15152
|
const switchParagraphBullet = (params) => {
|
|
15239
|
-
var _docDataModel$getSelf
|
|
15153
|
+
var _docDataModel$getSelf;
|
|
15240
15154
|
const { paragraphs: currentParagraphs, segmentId, document: docDataModel } = params;
|
|
15241
15155
|
let listType = params.listType;
|
|
15242
|
-
const paragraphs = (_docDataModel$getSelf =
|
|
15156
|
+
const paragraphs = ((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) ?? [];
|
|
15243
15157
|
const isAlreadyList = currentParagraphs.every((paragraph) => {
|
|
15244
15158
|
var _paragraph$bullet;
|
|
15245
15159
|
return ((_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType.indexOf(listType)) === 0;
|
|
@@ -15261,7 +15175,6 @@ const switchParagraphBullet = (params) => {
|
|
|
15261
15175
|
memoryCursor.reset();
|
|
15262
15176
|
const textX = new TextX();
|
|
15263
15177
|
for (const paragraph of currentParagraphs) {
|
|
15264
|
-
var _bullet$nestingLevel;
|
|
15265
15178
|
const { startIndex, paragraphId, paragraphStyle = {}, bullet } = paragraph;
|
|
15266
15179
|
textX.push({
|
|
15267
15180
|
t: "r",
|
|
@@ -15281,7 +15194,7 @@ const switchParagraphBullet = (params) => {
|
|
|
15281
15194
|
paragraphId,
|
|
15282
15195
|
paragraphStyle: { ...paragraphStyle },
|
|
15283
15196
|
bullet: {
|
|
15284
|
-
nestingLevel: (
|
|
15197
|
+
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15285
15198
|
textStyle: { fs: 20 },
|
|
15286
15199
|
listType,
|
|
15287
15200
|
listId
|
|
@@ -15295,9 +15208,9 @@ const switchParagraphBullet = (params) => {
|
|
|
15295
15208
|
return textX;
|
|
15296
15209
|
};
|
|
15297
15210
|
const toggleChecklistParagraph = (params) => {
|
|
15298
|
-
var _docDataModel$
|
|
15211
|
+
var _docDataModel$getSelf2;
|
|
15299
15212
|
const { paragraphIndex, segmentId, document: docDataModel } = params;
|
|
15300
|
-
const paragraphs = (_docDataModel$
|
|
15213
|
+
const paragraphs = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 || (_docDataModel$getSelf2 = _docDataModel$getSelf2.getBody()) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.paragraphs;
|
|
15301
15214
|
if (paragraphs == null) return false;
|
|
15302
15215
|
const currentParagraph = paragraphs.find((p) => p.startIndex === paragraphIndex);
|
|
15303
15216
|
if (!(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet) || currentParagraph.bullet.listType.indexOf("CHECK_LIST") === -1) return false;
|
|
@@ -15331,15 +15244,14 @@ const toggleChecklistParagraph = (params) => {
|
|
|
15331
15244
|
return textX;
|
|
15332
15245
|
};
|
|
15333
15246
|
const setParagraphBullet = (params) => {
|
|
15334
|
-
var _docDataModel$
|
|
15247
|
+
var _docDataModel$getSelf3;
|
|
15335
15248
|
const { paragraphs: currentParagraphs, listType, listId: explicitListId, segmentId, document: docDataModel } = params;
|
|
15336
|
-
if (((_docDataModel$
|
|
15337
|
-
const listId = explicitListId
|
|
15249
|
+
if (((_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 || (_docDataModel$getSelf3 = _docDataModel$getSelf3.getBody()) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.paragraphs) == null) return false;
|
|
15250
|
+
const listId = explicitListId ?? generateRandomId(6);
|
|
15338
15251
|
const memoryCursor = new MemoryCursor();
|
|
15339
15252
|
memoryCursor.reset();
|
|
15340
15253
|
const textX = new TextX();
|
|
15341
15254
|
for (const paragraph of currentParagraphs) {
|
|
15342
|
-
var _bullet$nestingLevel2;
|
|
15343
15255
|
const { startIndex, paragraphId, paragraphStyle = {}, bullet } = paragraph;
|
|
15344
15256
|
textX.push({
|
|
15345
15257
|
t: "r",
|
|
@@ -15355,7 +15267,7 @@ const setParagraphBullet = (params) => {
|
|
|
15355
15267
|
paragraphId,
|
|
15356
15268
|
paragraphStyle,
|
|
15357
15269
|
bullet: {
|
|
15358
|
-
nestingLevel: (
|
|
15270
|
+
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15359
15271
|
textStyle: (bullet === null || bullet === void 0 ? void 0 : bullet.listType) === listType ? bullet.textStyle : { fs: 20 },
|
|
15360
15272
|
listType,
|
|
15361
15273
|
listId
|
|
@@ -15390,17 +15302,15 @@ const PARAGRAPH_CONTAINER_TOKENS = /* @__PURE__ */ new Set([
|
|
|
15390
15302
|
""
|
|
15391
15303
|
]);
|
|
15392
15304
|
function getParagraphContentStartOffset(body, paragraph) {
|
|
15393
|
-
var _body$paragraphs;
|
|
15394
15305
|
let previousParagraph;
|
|
15395
|
-
for (const candidate of
|
|
15306
|
+
for (const candidate of body.paragraphs ?? []) if (candidate.startIndex < paragraph.startIndex && (!previousParagraph || candidate.startIndex > previousParagraph.startIndex)) previousParagraph = candidate;
|
|
15396
15307
|
let startOffset = previousParagraph ? previousParagraph.startIndex + 1 : 0;
|
|
15397
15308
|
while (startOffset < paragraph.startIndex && PARAGRAPH_CONTAINER_TOKENS.has(body.dataStream[startOffset])) startOffset++;
|
|
15398
15309
|
return startOffset;
|
|
15399
15310
|
}
|
|
15400
15311
|
function getParagraphContentStartOffsets(body) {
|
|
15401
|
-
var _body$paragraphs2;
|
|
15402
15312
|
const startOffsets = /* @__PURE__ */ new Map();
|
|
15403
|
-
const paragraphs = [...
|
|
15313
|
+
const paragraphs = [...body.paragraphs ?? []].sort((left, right) => left.startIndex - right.startIndex);
|
|
15404
15314
|
for (let index = 0; index < paragraphs.length; index++) {
|
|
15405
15315
|
const paragraph = paragraphs[index];
|
|
15406
15316
|
let startOffset = index > 0 ? paragraphs[index - 1].startIndex + 1 : 0;
|
|
@@ -15410,21 +15320,20 @@ function getParagraphContentStartOffsets(body) {
|
|
|
15410
15320
|
return startOffsets;
|
|
15411
15321
|
}
|
|
15412
15322
|
function getParagraphFollowingBlockOffset(body, paragraph) {
|
|
15413
|
-
|
|
15414
|
-
const containingBlock = ((_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []).find((blockRange) => {
|
|
15323
|
+
const containingBlock = (body.blockRanges ?? []).find((blockRange) => {
|
|
15415
15324
|
const interval = getBlockRangeInterval(blockRange);
|
|
15416
15325
|
return paragraph.startIndex > interval.startOffset && paragraph.startIndex < interval.endOffset - 1;
|
|
15417
15326
|
});
|
|
15418
15327
|
return containingBlock ? getBlockRangeInterval(containingBlock).endOffset : paragraph.startIndex + 1;
|
|
15419
15328
|
}
|
|
15420
15329
|
const changeParagraphBulletNestLevel = (params) => {
|
|
15421
|
-
var _docDataModel$
|
|
15330
|
+
var _docDataModel$getBody;
|
|
15422
15331
|
const { paragraphs: currentParagraphs, document: docDataModel, type } = params;
|
|
15423
15332
|
const memoryCursor = new MemoryCursor();
|
|
15424
15333
|
memoryCursor.reset();
|
|
15425
15334
|
const textX = new TextX();
|
|
15426
|
-
const customLists =
|
|
15427
|
-
const tables = (_docDataModel$getBody =
|
|
15335
|
+
const customLists = docDataModel.getSnapshot().lists ?? {};
|
|
15336
|
+
const tables = ((_docDataModel$getBody = docDataModel.getBody()) === null || _docDataModel$getBody === void 0 ? void 0 : _docDataModel$getBody.tables) ?? [];
|
|
15428
15337
|
const lists = {
|
|
15429
15338
|
...PRESET_LIST_TYPE,
|
|
15430
15339
|
...customLists
|
|
@@ -15465,13 +15374,13 @@ const changeParagraphBulletNestLevel = (params) => {
|
|
|
15465
15374
|
return textX;
|
|
15466
15375
|
};
|
|
15467
15376
|
const setParagraphStyle = (params) => {
|
|
15468
|
-
var _segment$getBody
|
|
15377
|
+
var _segment$getBody, _segment$getBody2;
|
|
15469
15378
|
const { textRanges, segmentId, document: docDataModel, style, paragraphTextRun, cursor, deleteLen, textX: _textX } = params;
|
|
15470
15379
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15471
|
-
const currentParagraphs = getParagraphsInRanges(textRanges, (
|
|
15380
|
+
const currentParagraphs = getParagraphsInRanges(textRanges, (segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) ?? [], (segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) ?? "");
|
|
15472
15381
|
const memoryCursor = new MemoryCursor();
|
|
15473
15382
|
if (cursor) memoryCursor.moveCursorTo(cursor);
|
|
15474
|
-
const textX = _textX
|
|
15383
|
+
const textX = _textX ?? new TextX();
|
|
15475
15384
|
currentParagraphs.sort((a, b) => a.startIndex - b.startIndex);
|
|
15476
15385
|
const start = Math.max(0, currentParagraphs[0].paragraphStart - 1);
|
|
15477
15386
|
if (start > memoryCursor.cursor) {
|
|
@@ -15635,8 +15544,7 @@ function getParagraphsSlice(body, startOffset, endOffset, type = 1) {
|
|
|
15635
15544
|
const sortedParagraphs = [...paragraphs].sort((a, b) => a.startIndex - b.startIndex);
|
|
15636
15545
|
const paragraphStartOffsets = getParagraphContentStartOffsets(body);
|
|
15637
15546
|
for (const paragraph of sortedParagraphs) {
|
|
15638
|
-
|
|
15639
|
-
const paragraphStart = (_paragraphStartOffset = paragraphStartOffsets.get(paragraph.startIndex)) !== null && _paragraphStartOffset !== void 0 ? _paragraphStartOffset : 0;
|
|
15547
|
+
const paragraphStart = paragraphStartOffsets.get(paragraph.startIndex) ?? 0;
|
|
15640
15548
|
const paragraphEnd = paragraph.startIndex;
|
|
15641
15549
|
if (paragraphEnd >= startOffset && paragraphEnd < endOffset || Math.max(paragraphStart, startOffset) < Math.min(paragraphEnd, endOffset)) {
|
|
15642
15550
|
const copy = Tools.deepClone(paragraph);
|
|
@@ -15787,11 +15695,11 @@ function getCustomDecorationSlice(body, startOffset, endOffset) {
|
|
|
15787
15695
|
return customDecorationSlice;
|
|
15788
15696
|
}
|
|
15789
15697
|
function composeTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
15790
|
-
if (updateDataTextRuns == null || originTextRuns == null) return updateDataTextRuns
|
|
15698
|
+
if (updateDataTextRuns == null || originTextRuns == null) return updateDataTextRuns ?? originTextRuns;
|
|
15791
15699
|
return coverTextRuns(updateDataTextRuns, originTextRuns, coverType);
|
|
15792
15700
|
}
|
|
15793
15701
|
function composeCustomRanges(updateDataCustomRanges, originCustomRanges, coverType) {
|
|
15794
|
-
if (updateDataCustomRanges == null || originCustomRanges == null) return updateDataCustomRanges
|
|
15702
|
+
if (updateDataCustomRanges == null || originCustomRanges == null) return updateDataCustomRanges ?? originCustomRanges;
|
|
15795
15703
|
if (originCustomRanges.length === 0 || updateDataCustomRanges.length === 0) return updateDataCustomRanges;
|
|
15796
15704
|
if (originCustomRanges.length > 1 || updateDataCustomRanges.length > 1) throw new Error("Cannot cover multiple customRanges");
|
|
15797
15705
|
if (coverType === 1) return [{ ...updateDataCustomRanges[0] }];
|
|
@@ -15828,7 +15736,7 @@ function composeBody(thisBody, otherBody, coverType = 0) {
|
|
|
15828
15736
|
const { startIndex: thisStart } = thisParagraph;
|
|
15829
15737
|
const { startIndex: otherStart } = otherParagraph;
|
|
15830
15738
|
if (thisStart === otherStart) {
|
|
15831
|
-
paragraphs.push(
|
|
15739
|
+
paragraphs.push((0, lodash_es.merge)(thisParagraph, otherParagraph));
|
|
15832
15740
|
thisIndex++;
|
|
15833
15741
|
otherIndex++;
|
|
15834
15742
|
} else if (thisStart < otherStart) {
|
|
@@ -16271,7 +16179,7 @@ function transformBlockRanges(thisBlockRanges, otherBlockRanges, priority) {
|
|
|
16271
16179
|
if (!otherBlockRanges.length) return [];
|
|
16272
16180
|
return otherBlockRanges.map((otherBlockRange) => {
|
|
16273
16181
|
const thisBlockRange = thisBlockRanges.find((blockRange) => blockRange.blockId === otherBlockRange.blockId);
|
|
16274
|
-
return thisBlockRange && priority ?
|
|
16182
|
+
return thisBlockRange && priority ? (0, lodash_es.merge)(otherBlockRange, thisBlockRange) : otherBlockRange;
|
|
16275
16183
|
});
|
|
16276
16184
|
}
|
|
16277
16185
|
|
|
@@ -16620,7 +16528,7 @@ const isEmptyDocument = (dataStream) => {
|
|
|
16620
16528
|
return getPlainText(dataStream).replaceAll("\r", "") === "";
|
|
16621
16529
|
};
|
|
16622
16530
|
const fromPlainText = (text) => {
|
|
16623
|
-
const dataStream = text.replace(/\n/g, "\r");
|
|
16531
|
+
const dataStream = text.replace(/\r\n?|\n/g, "\r");
|
|
16624
16532
|
const paragraphs = [];
|
|
16625
16533
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
16626
16534
|
const customRanges = [];
|
|
@@ -16696,18 +16604,16 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16696
16604
|
throw new Error("Method not implemented.");
|
|
16697
16605
|
}
|
|
16698
16606
|
constructor(snapshot) {
|
|
16699
|
-
var _this$snapshot$title;
|
|
16700
16607
|
super();
|
|
16701
16608
|
_defineProperty(this, "type", _univerjs_protocol.UniverType.UNIVER_DOC);
|
|
16702
16609
|
_defineProperty(this, "_name$", new rxjs.BehaviorSubject(""));
|
|
16703
16610
|
_defineProperty(this, "name$", this._name$.asObservable());
|
|
16704
16611
|
_defineProperty(this, "snapshot", void 0);
|
|
16705
16612
|
this.snapshot = createDocumentSnapshot(snapshot);
|
|
16706
|
-
this._name$.next(
|
|
16613
|
+
this._name$.next(this.snapshot.title ?? "No Title");
|
|
16707
16614
|
}
|
|
16708
16615
|
getRev() {
|
|
16709
|
-
|
|
16710
|
-
return (_this$snapshot$rev = this.snapshot.rev) !== null && _this$snapshot$rev !== void 0 ? _this$snapshot$rev : 1;
|
|
16616
|
+
return this.snapshot.rev ?? 1;
|
|
16711
16617
|
}
|
|
16712
16618
|
incrementRev() {
|
|
16713
16619
|
this.snapshot.rev = this.getRev() + 1;
|
|
@@ -16743,8 +16649,7 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16743
16649
|
return this.snapshot;
|
|
16744
16650
|
}
|
|
16745
16651
|
getBulletPresetList() {
|
|
16746
|
-
|
|
16747
|
-
const customLists = (_this$snapshot$lists = this.snapshot.lists) !== null && _this$snapshot$lists !== void 0 ? _this$snapshot$lists : {};
|
|
16652
|
+
const customLists = this.snapshot.lists ?? {};
|
|
16748
16653
|
return {
|
|
16749
16654
|
...PRESET_LIST_TYPE,
|
|
16750
16655
|
...customLists
|
|
@@ -16783,8 +16688,8 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16783
16688
|
const { documentStyle } = this.snapshot;
|
|
16784
16689
|
if (!documentStyle.pageSize) {
|
|
16785
16690
|
documentStyle.pageSize = {
|
|
16786
|
-
width: width
|
|
16787
|
-
height: height
|
|
16691
|
+
width: width ?? Number.POSITIVE_INFINITY,
|
|
16692
|
+
height: height ?? Number.POSITIVE_INFINITY
|
|
16788
16693
|
};
|
|
16789
16694
|
return;
|
|
16790
16695
|
}
|
|
@@ -16818,16 +16723,15 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16818
16723
|
};
|
|
16819
16724
|
var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple {
|
|
16820
16725
|
constructor(snapshot) {
|
|
16821
|
-
var _this$snapshot$id, _this$snapshot$title2;
|
|
16822
16726
|
super(Tools.isEmptyObject(snapshot) ? getEmptySnapshot$1() : snapshot);
|
|
16823
16727
|
_defineProperty(this, "_unitId", void 0);
|
|
16824
16728
|
_defineProperty(this, "headerModelMap", /* @__PURE__ */ new Map());
|
|
16825
16729
|
_defineProperty(this, "footerModelMap", /* @__PURE__ */ new Map());
|
|
16826
16730
|
_defineProperty(this, "change$", new rxjs.BehaviorSubject(0));
|
|
16827
16731
|
const UNIT_ID_LENGTH = 6;
|
|
16828
|
-
this._unitId =
|
|
16732
|
+
this._unitId = this.snapshot.id ?? generateRandomId(UNIT_ID_LENGTH);
|
|
16829
16733
|
this._initializeHeaderFooterModel();
|
|
16830
|
-
this._name$.next(
|
|
16734
|
+
this._name$.next(this.snapshot.title ?? "");
|
|
16831
16735
|
}
|
|
16832
16736
|
dispose() {
|
|
16833
16737
|
super.dispose();
|
|
@@ -16905,8 +16809,8 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
16905
16809
|
this._unitId = unitId;
|
|
16906
16810
|
}
|
|
16907
16811
|
getPlainText() {
|
|
16908
|
-
var _this$getBody
|
|
16909
|
-
return getPlainText((
|
|
16812
|
+
var _this$getBody;
|
|
16813
|
+
return getPlainText(((_this$getBody = this.getBody()) === null || _this$getBody === void 0 ? void 0 : _this$getBody.dataStream) ?? "");
|
|
16910
16814
|
}
|
|
16911
16815
|
};
|
|
16912
16816
|
|
|
@@ -16914,16 +16818,36 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
16914
16818
|
//#region src/docs/data-model/paragraph-style.ts
|
|
16915
16819
|
function _definedStyle(style) {
|
|
16916
16820
|
if (style == null) return {};
|
|
16917
|
-
|
|
16821
|
+
const definedStyle = Tools.deepClone(style);
|
|
16822
|
+
Tools.removeNull(definedStyle);
|
|
16823
|
+
return definedStyle;
|
|
16824
|
+
}
|
|
16825
|
+
function _resolveNamedParagraphStyle(styles, styleId) {
|
|
16826
|
+
if (!styles || !styleId) return {};
|
|
16827
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
16828
|
+
const resolve = (currentStyleId) => {
|
|
16829
|
+
if (visiting.has(currentStyleId)) return {};
|
|
16830
|
+
const style = styles[currentStyleId];
|
|
16831
|
+
if (!style || style.type !== 1) return {};
|
|
16832
|
+
visiting.add(currentStyleId);
|
|
16833
|
+
const base = style.basedOn ? resolve(style.basedOn) : {};
|
|
16834
|
+
visiting.delete(currentStyleId);
|
|
16835
|
+
return {
|
|
16836
|
+
...base,
|
|
16837
|
+
..._definedStyle(style.paragraphStyle)
|
|
16838
|
+
};
|
|
16839
|
+
};
|
|
16840
|
+
return resolve(styleId);
|
|
16918
16841
|
}
|
|
16919
16842
|
function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options = {}) {
|
|
16920
|
-
|
|
16843
|
+
const legacyStyle = options.useLegacyModernDefaults ?? (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 2 ? {
|
|
16844
|
+
lineSpacing: DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
|
|
16845
|
+
spaceAbove: { v: 0 },
|
|
16846
|
+
spaceBelow: { v: 12 }
|
|
16847
|
+
} : {};
|
|
16921
16848
|
const documentDefaults = {
|
|
16922
|
-
...(
|
|
16923
|
-
|
|
16924
|
-
spaceAbove: { v: 0 },
|
|
16925
|
-
spaceBelow: { v: 12 }
|
|
16926
|
-
} : {},
|
|
16849
|
+
...(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1 ? { widowControl: 1 } : {},
|
|
16850
|
+
...legacyStyle,
|
|
16927
16851
|
..._definedStyle(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.defaultParagraphStyle)
|
|
16928
16852
|
};
|
|
16929
16853
|
if (options.excludeDocumentOuterSpacing) {
|
|
@@ -16931,10 +16855,13 @@ function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options =
|
|
|
16931
16855
|
delete documentDefaults.spaceBelow;
|
|
16932
16856
|
}
|
|
16933
16857
|
const definedParagraphStyle = _definedStyle(paragraphStyle);
|
|
16934
|
-
const
|
|
16858
|
+
const referencedParagraphStyle = _resolveNamedParagraphStyle(options.styles, options.paragraphStyleId);
|
|
16859
|
+
const namedStyleType = definedParagraphStyle.namedStyleType ?? referencedParagraphStyle.namedStyleType;
|
|
16860
|
+
const namedStyle = namedStyleType == null ? null : NAMED_STYLE_SPACE_MAP[namedStyleType];
|
|
16935
16861
|
return Tools.deepClone({
|
|
16936
16862
|
...documentDefaults,
|
|
16937
16863
|
...namedStyle,
|
|
16864
|
+
...referencedParagraphStyle,
|
|
16938
16865
|
...definedParagraphStyle
|
|
16939
16866
|
});
|
|
16940
16867
|
}
|
|
@@ -17095,10 +17022,10 @@ function getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeTy
|
|
|
17095
17022
|
return relativeCustomRanges;
|
|
17096
17023
|
}
|
|
17097
17024
|
function getSelectionForAddCustomRange(range, body) {
|
|
17098
|
-
var
|
|
17099
|
-
const ranges = getIntersectingCustomRanges(range.startOffset, range.collapsed ? range.startOffset : range.endOffset - 1,
|
|
17100
|
-
const startOffset = Math.min(range.startOffset, (
|
|
17101
|
-
const endOffset = Math.max(range.endOffset, ((
|
|
17025
|
+
var _ranges$, _ranges;
|
|
17026
|
+
const ranges = getIntersectingCustomRanges(range.startOffset, range.collapsed ? range.startOffset : range.endOffset - 1, body.customRanges ?? []);
|
|
17027
|
+
const startOffset = Math.min(range.startOffset, ((_ranges$ = ranges[0]) === null || _ranges$ === void 0 ? void 0 : _ranges$.startIndex) ?? Infinity);
|
|
17028
|
+
const endOffset = Math.max(range.endOffset, (((_ranges = ranges[ranges.length - 1]) === null || _ranges === void 0 ? void 0 : _ranges.endIndex) ?? -Infinity) + 1);
|
|
17102
17029
|
return {
|
|
17103
17030
|
startOffset,
|
|
17104
17031
|
endOffset,
|
|
@@ -17109,7 +17036,7 @@ function getSelectionForAddCustomRange(range, body) {
|
|
|
17109
17036
|
//#endregion
|
|
17110
17037
|
//#region src/docs/data-model/text-x/build-utils/text-x-utils.ts
|
|
17111
17038
|
function deleteCustomRangeTextX(params) {
|
|
17112
|
-
var _documentDataModel$ge
|
|
17039
|
+
var _documentDataModel$ge;
|
|
17113
17040
|
const { rangeId, segmentId, documentDataModel, insert } = params;
|
|
17114
17041
|
const range = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customRanges) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((r) => r.rangeId === rangeId);
|
|
17115
17042
|
if (!range) return false;
|
|
@@ -17133,7 +17060,7 @@ function deleteCustomRangeTextX(params) {
|
|
|
17133
17060
|
body: insert,
|
|
17134
17061
|
len: insert.dataStream.length
|
|
17135
17062
|
});
|
|
17136
|
-
const end = endIndex + 1 + ((
|
|
17063
|
+
const end = endIndex + 1 + ((insert === null || insert === void 0 ? void 0 : insert.dataStream.length) ?? 0);
|
|
17137
17064
|
textX.selections = [{
|
|
17138
17065
|
startOffset: end,
|
|
17139
17066
|
endOffset: end,
|
|
@@ -17147,17 +17074,16 @@ function addCustomRangeTextX(param) {
|
|
|
17147
17074
|
const textX = new TextX();
|
|
17148
17075
|
let changed = false;
|
|
17149
17076
|
ranges.forEach((range) => {
|
|
17150
|
-
var _body$customRanges, _body$paragraphs, _body$customBlocks;
|
|
17151
17077
|
const actualRange = getSelectionForAddCustomRange(range, body);
|
|
17152
17078
|
if (!actualRange) return false;
|
|
17153
17079
|
if (!body) return false;
|
|
17154
17080
|
const { startOffset, endOffset } = actualRange;
|
|
17155
|
-
const customRanges =
|
|
17081
|
+
const customRanges = body.customRanges ?? [];
|
|
17156
17082
|
const addCustomRange = (startIndex, endIndex, index) => {
|
|
17157
|
-
var _relativeCustomRanges, _relativeCustomRanges2
|
|
17083
|
+
var _relativeCustomRanges, _relativeCustomRanges2;
|
|
17158
17084
|
const relativeCustomRanges = getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeType);
|
|
17159
|
-
const rangeStartIndex = Math.min((_relativeCustomRanges =
|
|
17160
|
-
const rangeEndIndex = Math.max((
|
|
17085
|
+
const rangeStartIndex = Math.min(((_relativeCustomRanges = relativeCustomRanges[0]) === null || _relativeCustomRanges === void 0 ? void 0 : _relativeCustomRanges.startIndex) ?? Infinity, startIndex);
|
|
17086
|
+
const rangeEndIndex = Math.max(((_relativeCustomRanges2 = relativeCustomRanges[relativeCustomRanges.length - 1]) === null || _relativeCustomRanges2 === void 0 ? void 0 : _relativeCustomRanges2.endIndex) ?? -Infinity, endIndex);
|
|
17161
17087
|
const customRange = {
|
|
17162
17088
|
rangeId: index ? `${rangeId}$${index}` : rangeId,
|
|
17163
17089
|
rangeType,
|
|
@@ -17181,8 +17107,8 @@ function addCustomRangeTextX(param) {
|
|
|
17181
17107
|
});
|
|
17182
17108
|
cursor = rangeEndIndex + 1;
|
|
17183
17109
|
};
|
|
17184
|
-
const relativeParagraphs = (
|
|
17185
|
-
const customBlocks = (
|
|
17110
|
+
const relativeParagraphs = (body.paragraphs ?? []).filter((p) => p.startIndex < endOffset && p.startIndex > startOffset);
|
|
17111
|
+
const customBlocks = (body.customBlocks ?? []).filter((block) => block.startIndex < endOffset && block.startIndex > startOffset);
|
|
17186
17112
|
excludePointsFromRange([startOffset, endOffset - 1], [...relativeParagraphs.map((p) => p.startIndex), ...customBlocks.map((b) => b.startIndex)]).forEach(([start, end], i) => addCustomRange(start, end, i));
|
|
17187
17113
|
changed = true;
|
|
17188
17114
|
textX.selections = [{
|
|
@@ -17212,8 +17138,7 @@ function protectDeletedColumnBoundaryTokens(body, selections, protectedOffsets)
|
|
|
17212
17138
|
}
|
|
17213
17139
|
}
|
|
17214
17140
|
function protectPartiallyDeletedBlockBoundaryTokens(body, selections, protectedOffsets) {
|
|
17215
|
-
|
|
17216
|
-
for (const blockRange of (_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []) {
|
|
17141
|
+
for (const blockRange of body.blockRanges ?? []) {
|
|
17217
17142
|
const blockInterval = getBlockRangeInterval(blockRange);
|
|
17218
17143
|
if (selections.some((selection) => selection.startOffset <= blockInterval.startOffset && selection.endOffset >= blockInterval.endOffset)) continue;
|
|
17219
17144
|
if (isOffsetDeleted(blockRange.startIndex, selections)) protectedOffsets.add(blockRange.startIndex);
|
|
@@ -17221,8 +17146,7 @@ function protectPartiallyDeletedBlockBoundaryTokens(body, selections, protectedO
|
|
|
17221
17146
|
}
|
|
17222
17147
|
}
|
|
17223
17148
|
function collectBlockTextContainers(body) {
|
|
17224
|
-
|
|
17225
|
-
const blockRanges = [...(_body$blockRanges2 = body.blockRanges) !== null && _body$blockRanges2 !== void 0 ? _body$blockRanges2 : []].sort((left, right) => left.startIndex - right.startIndex);
|
|
17149
|
+
const blockRanges = [...body.blockRanges ?? []].sort((left, right) => left.startIndex - right.startIndex);
|
|
17226
17150
|
const containers = blockRanges.map((blockRange) => {
|
|
17227
17151
|
const atomicRange = getBlockRangeInterval(blockRange);
|
|
17228
17152
|
return {
|
|
@@ -17250,8 +17174,8 @@ function collectBlockTextContainers(body) {
|
|
|
17250
17174
|
}
|
|
17251
17175
|
if (index >= 0) containers[index][key].push(offset);
|
|
17252
17176
|
};
|
|
17253
|
-
(
|
|
17254
|
-
(
|
|
17177
|
+
(body.paragraphs ?? []).forEach((paragraph) => assignPoint(paragraph.startIndex, "paragraphs"));
|
|
17178
|
+
(body.sectionBreaks ?? []).forEach((sectionBreak) => assignPoint(sectionBreak.startIndex, "sectionBreaks"));
|
|
17255
17179
|
return containers;
|
|
17256
17180
|
}
|
|
17257
17181
|
function collectStructuralTextContainers(body) {
|
|
@@ -17304,10 +17228,9 @@ function collectStructuralTextContainers(body) {
|
|
|
17304
17228
|
return containers;
|
|
17305
17229
|
}
|
|
17306
17230
|
function protectRequiredContainerChildren(container, selections, insertBody, insertOffset, protectedOffsets) {
|
|
17307
|
-
var _insertBody$dataStrea;
|
|
17308
17231
|
if (isAtomicContainerDeleted(container, selections)) return;
|
|
17309
17232
|
const insertAppliesToContainer = insertBody && isInsertInContainer(insertOffset, container);
|
|
17310
|
-
const insertDataStream = (
|
|
17233
|
+
const insertDataStream = (insertBody === null || insertBody === void 0 ? void 0 : insertBody.dataStream) ?? "";
|
|
17311
17234
|
const insertHasParagraph = insertDataStream.includes("\r");
|
|
17312
17235
|
const insertHasSectionBreak = insertDataStream.includes("\n");
|
|
17313
17236
|
if (container.require === "paragraph-or-section") {
|
|
@@ -17516,12 +17439,12 @@ const replaceSelectionTextRuns = (params) => {
|
|
|
17516
17439
|
t: "r",
|
|
17517
17440
|
body: isTextRunsEqual(textRunsSlice, oldTextRunsSlice) ? void 0 : {
|
|
17518
17441
|
textRuns: textRunsSlice === null || textRunsSlice === void 0 ? void 0 : textRunsSlice.map((textRun) => {
|
|
17519
|
-
var _textRun$ts, _textRun$
|
|
17442
|
+
var _textRun$ts, _textRun$ts2, _textRun$ts3;
|
|
17520
17443
|
return {
|
|
17521
17444
|
...textRun,
|
|
17522
17445
|
ts: {
|
|
17523
17446
|
...textRun.ts,
|
|
17524
|
-
cl: ((_textRun$ts = textRun.ts) === null || _textRun$ts === void 0 || (_textRun$ts = _textRun$ts.cl) === null || _textRun$ts === void 0 || (_textRun$ts = _textRun$ts.rgb) === null || _textRun$ts === void 0 ? void 0 : _textRun$ts.includes(".")) ? { rgb: themeService.getColorFromTheme((
|
|
17447
|
+
cl: ((_textRun$ts = textRun.ts) === null || _textRun$ts === void 0 || (_textRun$ts = _textRun$ts.cl) === null || _textRun$ts === void 0 || (_textRun$ts = _textRun$ts.rgb) === null || _textRun$ts === void 0 ? void 0 : _textRun$ts.includes(".")) ? { rgb: themeService.getColorFromTheme(((_textRun$ts2 = textRun.ts) === null || _textRun$ts2 === void 0 || (_textRun$ts2 = _textRun$ts2.cl) === null || _textRun$ts2 === void 0 ? void 0 : _textRun$ts2.rgb) ?? "") } : (_textRun$ts3 = textRun.ts) === null || _textRun$ts3 === void 0 ? void 0 : _textRun$ts3.cl
|
|
17525
17448
|
}
|
|
17526
17449
|
};
|
|
17527
17450
|
}),
|
|
@@ -17573,7 +17496,7 @@ function getCustomBlockIdsInSelections(body, selections) {
|
|
|
17573
17496
|
return customBlockIds;
|
|
17574
17497
|
}
|
|
17575
17498
|
const addDrawing = (param) => {
|
|
17576
|
-
var _documentDataModel$ge, _documentDataModel$ge2
|
|
17499
|
+
var _documentDataModel$ge, _documentDataModel$ge2;
|
|
17577
17500
|
const { selection, documentDataModel, drawings } = param;
|
|
17578
17501
|
const { collapsed, startOffset, segmentId } = selection;
|
|
17579
17502
|
const textX = new TextX();
|
|
@@ -17581,21 +17504,20 @@ const addDrawing = (param) => {
|
|
|
17581
17504
|
const rawActions = [];
|
|
17582
17505
|
const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
|
|
17583
17506
|
if (!body) return false;
|
|
17584
|
-
const drawingOrderLength = (_documentDataModel$ge2 =
|
|
17507
|
+
const drawingOrderLength = ((_documentDataModel$ge2 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.length) ?? 0;
|
|
17585
17508
|
let removeDrawingLen = 0;
|
|
17586
|
-
const insertOffset = collapsed ? normalizeDrawingInsertOffset(body, startOffset
|
|
17509
|
+
const insertOffset = collapsed ? normalizeDrawingInsertOffset(body, startOffset ?? 0) : startOffset ?? 0;
|
|
17587
17510
|
if (collapsed) {
|
|
17588
17511
|
if (insertOffset > 0) textX.push({
|
|
17589
17512
|
t: "r",
|
|
17590
17513
|
len: insertOffset
|
|
17591
17514
|
});
|
|
17592
17515
|
} else {
|
|
17593
|
-
var _documentDataModel$ge4, _documentDataModel$ge5;
|
|
17594
17516
|
const dos = deleteSelectionTextX([selection], body, 0, null, false);
|
|
17595
17517
|
textX.push(...dos);
|
|
17596
17518
|
const removedCustomBlockIds = getCustomBlockIdsInSelections(body, [selection]);
|
|
17597
|
-
const drawings =
|
|
17598
|
-
const drawingOrder =
|
|
17519
|
+
const drawings = documentDataModel.getDrawings() ?? {};
|
|
17520
|
+
const drawingOrder = documentDataModel.getDrawingsOrder() ?? [];
|
|
17599
17521
|
const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
|
|
17600
17522
|
if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
|
|
17601
17523
|
else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
|
|
@@ -17633,7 +17555,16 @@ const addDrawing = (param) => {
|
|
|
17633
17555
|
}, null);
|
|
17634
17556
|
};
|
|
17635
17557
|
function normalizeDrawingInsertOffset(body, offset) {
|
|
17636
|
-
|
|
17558
|
+
const { dataStream } = body;
|
|
17559
|
+
if (offset === 0 && dataStream[0] === "\r") return 1;
|
|
17560
|
+
if (dataStream[offset] === "\n" && dataStream[offset - 1] === "\r" && isInsideTableCell(dataStream, offset)) return offset - 1;
|
|
17561
|
+
return offset;
|
|
17562
|
+
}
|
|
17563
|
+
function isInsideTableCell(dataStream, offset) {
|
|
17564
|
+
let cellDepth = 0;
|
|
17565
|
+
for (let index = 0; index < offset; index++) if (dataStream[index] === "") cellDepth++;
|
|
17566
|
+
else if (dataStream[index] === "") cellDepth = Math.max(0, cellDepth - 1);
|
|
17567
|
+
return cellDepth > 0;
|
|
17637
17568
|
}
|
|
17638
17569
|
function buildDrawingInsertBody(body, drawings, insertOffset) {
|
|
17639
17570
|
var _body$paragraphs;
|
|
@@ -17713,8 +17644,8 @@ function collectNewStructuralStartOffsets(previousBody, nextBody) {
|
|
|
17713
17644
|
return Array.from(new Set(offsets)).sort((left, right) => left - right);
|
|
17714
17645
|
}
|
|
17715
17646
|
function collectNewStartOffsets(previousItems, nextItems, getId) {
|
|
17716
|
-
const previousIds = new Set((previousItems
|
|
17717
|
-
return (nextItems
|
|
17647
|
+
const previousIds = new Set((previousItems ?? []).map(getId));
|
|
17648
|
+
return (nextItems ?? []).filter((item) => !previousIds.has(getId(item))).map((item) => item.startIndex);
|
|
17718
17649
|
}
|
|
17719
17650
|
|
|
17720
17651
|
//#endregion
|
|
@@ -17808,8 +17739,7 @@ function normalizeBody$1(body) {
|
|
|
17808
17739
|
return body;
|
|
17809
17740
|
}
|
|
17810
17741
|
function normalizeData(data) {
|
|
17811
|
-
|
|
17812
|
-
data.body = normalizeBody$1((_data$body = data.body) !== null && _data$body !== void 0 ? _data$body : { dataStream: "" });
|
|
17742
|
+
data.body = normalizeBody$1(data.body ?? { dataStream: "" });
|
|
17813
17743
|
if (!data.drawingsOrder) data.drawingsOrder = [];
|
|
17814
17744
|
if (!data.drawings) data.drawings = {};
|
|
17815
17745
|
if (!data.documentStyle) data.documentStyle = {};
|
|
@@ -17852,8 +17782,8 @@ function normalizeRichTextParagraphStyle(style) {
|
|
|
17852
17782
|
};
|
|
17853
17783
|
}
|
|
17854
17784
|
function hasRichTextContent(data) {
|
|
17855
|
-
var _data$body
|
|
17856
|
-
return ((_data$body
|
|
17785
|
+
var _data$body;
|
|
17786
|
+
return (((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? "").replace(/\r|\n/g, "").length > 0;
|
|
17857
17787
|
}
|
|
17858
17788
|
/**
|
|
17859
17789
|
* Represents a read-only font style value object.
|
|
@@ -19256,8 +19186,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19256
19186
|
* ```
|
|
19257
19187
|
*/
|
|
19258
19188
|
toPlainText() {
|
|
19259
|
-
var _this$_data$body
|
|
19260
|
-
return BuildTextUtils.transform.getPlainText((
|
|
19189
|
+
var _this$_data$body;
|
|
19190
|
+
return BuildTextUtils.transform.getPlainText(((_this$_data$body = this._data.body) === null || _this$_data$body === void 0 ? void 0 : _this$_data$body.dataStream) ?? "").replaceAll("\r", "\n");
|
|
19261
19191
|
}
|
|
19262
19192
|
/**
|
|
19263
19193
|
* Gets the paragraph style of the current RichTextValue instance
|
|
@@ -19295,14 +19225,13 @@ var RichTextValue = class RichTextValue {
|
|
|
19295
19225
|
* ```
|
|
19296
19226
|
*/
|
|
19297
19227
|
getParagraphs() {
|
|
19298
|
-
|
|
19299
|
-
|
|
19300
|
-
|
|
19301
|
-
return paragraphs.map((paragraph) => {
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19305
|
-
});
|
|
19228
|
+
const body = this._data.body;
|
|
19229
|
+
if (!body) return [];
|
|
19230
|
+
const startOffsets = getParagraphContentStartOffsets(body);
|
|
19231
|
+
return (body.paragraphs ?? []).map((paragraph) => RichTextBuilder.create(createParagraphSnapshot(this._data, paragraph.paragraphId, {
|
|
19232
|
+
startOffset: startOffsets.get(paragraph.startIndex) ?? 0,
|
|
19233
|
+
endOffset: paragraph.startIndex
|
|
19234
|
+
})));
|
|
19306
19235
|
}
|
|
19307
19236
|
/**
|
|
19308
19237
|
* Gets the text runs of the current RichTextValue instance
|
|
@@ -19314,8 +19243,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19314
19243
|
* ```
|
|
19315
19244
|
*/
|
|
19316
19245
|
getTextRuns() {
|
|
19317
|
-
var _this$_data$
|
|
19318
|
-
return ((
|
|
19246
|
+
var _this$_data$body4;
|
|
19247
|
+
return (((_this$_data$body4 = this._data.body) === null || _this$_data$body4 === void 0 ? void 0 : _this$_data$body4.textRuns) ?? []).map((t) => ({
|
|
19319
19248
|
...t,
|
|
19320
19249
|
ts: t.ts ? TextStyleValue.create(t.ts) : null
|
|
19321
19250
|
}));
|
|
@@ -19330,8 +19259,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19330
19259
|
* ```
|
|
19331
19260
|
*/
|
|
19332
19261
|
getLinks() {
|
|
19333
|
-
var _this$_data$
|
|
19334
|
-
return (
|
|
19262
|
+
var _this$_data$body5;
|
|
19263
|
+
return ((_this$_data$body5 = this._data.body) === null || _this$_data$body5 === void 0 || (_this$_data$body5 = _this$_data$body5.customRanges) === null || _this$_data$body5 === void 0 ? void 0 : _this$_data$body5.filter((r) => r.rangeType === 0)) ?? [];
|
|
19335
19264
|
}
|
|
19336
19265
|
/**
|
|
19337
19266
|
* Gets the data of the current RichTextValue instance
|
|
@@ -19387,19 +19316,22 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19387
19316
|
* @returns {RichTextBuilder} A new RichTextBuilder instance
|
|
19388
19317
|
*/
|
|
19389
19318
|
static create(data) {
|
|
19390
|
-
return new RichTextBuilder(data
|
|
19319
|
+
return new RichTextBuilder(data ?? RichTextBuilder.newEmptyData());
|
|
19391
19320
|
}
|
|
19392
19321
|
constructor(data) {
|
|
19393
19322
|
super(data);
|
|
19394
19323
|
_defineProperty(this, "_doc", void 0);
|
|
19395
19324
|
_defineProperty(this, "_trackedRanges", /* @__PURE__ */ new Set());
|
|
19325
|
+
_defineProperty(this, "_childHandleRevision", 0);
|
|
19396
19326
|
this._doc = new DocumentDataModel(data);
|
|
19397
19327
|
}
|
|
19398
19328
|
/**
|
|
19399
19329
|
* Returns editable paragraph handles backed by this detached rich-text builder.
|
|
19400
19330
|
*
|
|
19401
|
-
* Paragraph boundaries come from the document model rather than splitting plain text.
|
|
19402
|
-
*
|
|
19331
|
+
* Paragraph boundaries come from the document model rather than splitting plain text. Handles stay aligned across
|
|
19332
|
+
* edits made through their child run handles, so callers can safely iterate from the first paragraph to the last.
|
|
19333
|
+
* Direct builder edits that change text or run boundaries invalidate previously returned paragraph and run handles;
|
|
19334
|
+
* query them again after calling methods such as `insertText()`, `setStyle()`, `setLink()`, or `delete()`.
|
|
19403
19335
|
*
|
|
19404
19336
|
* @returns Editable paragraphs in document order.
|
|
19405
19337
|
* @example
|
|
@@ -19414,14 +19346,10 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19414
19346
|
* ```
|
|
19415
19347
|
*/
|
|
19416
19348
|
getParagraphs() {
|
|
19417
|
-
var _body$paragraphs;
|
|
19418
19349
|
const body = this._data.body;
|
|
19419
19350
|
if (!body) return [];
|
|
19420
19351
|
const startOffsets = getParagraphContentStartOffsets(body);
|
|
19421
|
-
return (
|
|
19422
|
-
var _startOffsets$get;
|
|
19423
|
-
return this._createParagraphBuilder(paragraph.paragraphId, (_startOffsets$get = startOffsets.get(paragraph.startIndex)) !== null && _startOffsets$get !== void 0 ? _startOffsets$get : 0, paragraph.startIndex);
|
|
19424
|
-
});
|
|
19352
|
+
return (body.paragraphs ?? []).map((paragraph) => this._createParagraphBuilder(paragraph.paragraphId, startOffsets.get(paragraph.startIndex) ?? 0, paragraph.startIndex));
|
|
19425
19353
|
}
|
|
19426
19354
|
/**
|
|
19427
19355
|
* Returns editable text-run handles for all paragraph text in this builder.
|
|
@@ -19445,7 +19373,6 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19445
19373
|
}
|
|
19446
19374
|
/** @internal */
|
|
19447
19375
|
_createTextRunBuilders(range) {
|
|
19448
|
-
var _body$textRuns, _body$customRanges, _body$customDecoratio;
|
|
19449
19376
|
const body = this._data.body;
|
|
19450
19377
|
if (!body || range.startOffset >= range.endOffset) return [];
|
|
19451
19378
|
const boundaries = /* @__PURE__ */ new Set([range.startOffset, range.endOffset]);
|
|
@@ -19457,9 +19384,9 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19457
19384
|
boundaries.add(end);
|
|
19458
19385
|
}
|
|
19459
19386
|
};
|
|
19460
|
-
for (const textRun of
|
|
19461
|
-
for (const customRange of
|
|
19462
|
-
for (const decoration of
|
|
19387
|
+
for (const textRun of body.textRuns ?? []) addRangeBoundaries(textRun.st, textRun.ed);
|
|
19388
|
+
for (const customRange of body.customRanges ?? []) addRangeBoundaries(customRange.startIndex, customRange.endIndex + 1);
|
|
19389
|
+
for (const decoration of body.customDecorations ?? []) addRangeBoundaries(decoration.startIndex, decoration.endIndex + 1);
|
|
19463
19390
|
for (let offset = range.startOffset; offset < range.endOffset; offset++) if (NON_EDITABLE_RICH_TEXT_TOKENS.has(body.dataStream[offset])) {
|
|
19464
19391
|
boundaries.add(offset);
|
|
19465
19392
|
boundaries.add(offset + 1);
|
|
@@ -19467,12 +19394,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19467
19394
|
const offsets = [...boundaries].sort((left, right) => left - right);
|
|
19468
19395
|
const runs = [];
|
|
19469
19396
|
for (let index = 0; index < offsets.length - 1; index++) {
|
|
19470
|
-
var _body$textRuns2;
|
|
19471
19397
|
const startOffset = offsets[index];
|
|
19472
19398
|
const endOffset = offsets[index + 1];
|
|
19473
19399
|
if (startOffset >= endOffset || endOffset - startOffset === 1 && NON_EDITABLE_RICH_TEXT_TOKENS.has(body.dataStream[startOffset])) continue;
|
|
19474
|
-
const sourceRun = (
|
|
19475
|
-
runs.push(new RichTextRunBuilder(this, this._trackRange(startOffset, endOffset), sourceRun === null || sourceRun === void 0 ? void 0 : sourceRun.ts, sourceRun === null || sourceRun === void 0 ? void 0 : sourceRun.sId, Boolean(sourceRun)));
|
|
19400
|
+
const sourceRun = (body.textRuns ?? []).find((textRun) => textRun.st <= startOffset && textRun.ed >= endOffset);
|
|
19401
|
+
runs.push(new RichTextRunBuilder(this, this._trackRange(startOffset, endOffset), sourceRun === null || sourceRun === void 0 ? void 0 : sourceRun.ts, sourceRun === null || sourceRun === void 0 ? void 0 : sourceRun.sId, Boolean(sourceRun), this._childHandleRevision));
|
|
19476
19402
|
}
|
|
19477
19403
|
return runs;
|
|
19478
19404
|
}
|
|
@@ -19516,7 +19442,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19516
19442
|
this._rebaseTrackedRanges(startOffset, endOffset, text.length);
|
|
19517
19443
|
}
|
|
19518
19444
|
_createParagraphBuilder(paragraphId, startOffset, endOffset) {
|
|
19519
|
-
return new RichTextParagraphBuilder(this, paragraphId, this._trackRange(startOffset, endOffset));
|
|
19445
|
+
return new RichTextParagraphBuilder(this, paragraphId, this._trackRange(startOffset, endOffset), this._childHandleRevision);
|
|
19446
|
+
}
|
|
19447
|
+
/** @internal */
|
|
19448
|
+
_assertChildHandleRevision(revision) {
|
|
19449
|
+
if (revision !== this._childHandleRevision) throw new Error("Rich text child handle is no longer valid.");
|
|
19520
19450
|
}
|
|
19521
19451
|
_trackRange(startOffset, endOffset) {
|
|
19522
19452
|
const range = {
|
|
@@ -19543,6 +19473,10 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19543
19473
|
trackedRange.endOffset = mapEnd(trackedRange.endOffset);
|
|
19544
19474
|
}
|
|
19545
19475
|
}
|
|
19476
|
+
_invalidateChildHandles() {
|
|
19477
|
+
this._childHandleRevision++;
|
|
19478
|
+
this._trackedRanges.clear();
|
|
19479
|
+
}
|
|
19546
19480
|
/**
|
|
19547
19481
|
* Appends plain text to the rich text.
|
|
19548
19482
|
*
|
|
@@ -19583,13 +19517,12 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19583
19517
|
* ```
|
|
19584
19518
|
*/
|
|
19585
19519
|
align(alignment) {
|
|
19586
|
-
|
|
19587
|
-
const
|
|
19588
|
-
const renderConfig = (_documentStyle$render = documentStyle.renderConfig) !== null && _documentStyle$render !== void 0 ? _documentStyle$render : documentStyle.renderConfig = {};
|
|
19520
|
+
const documentStyle = this._data.documentStyle ??= {};
|
|
19521
|
+
const renderConfig = documentStyle.renderConfig ??= {};
|
|
19589
19522
|
if (alignment.horizontal !== void 0) {
|
|
19590
|
-
var _this$_data$
|
|
19523
|
+
var _this$_data$body6;
|
|
19591
19524
|
renderConfig.horizontalAlign = alignment.horizontal;
|
|
19592
|
-
for (const paragraph of (
|
|
19525
|
+
for (const paragraph of ((_this$_data$body6 = this._data.body) === null || _this$_data$body6 === void 0 ? void 0 : _this$_data$body6.paragraphs) ?? []) paragraph.paragraphStyle = {
|
|
19593
19526
|
...paragraph.paragraphStyle,
|
|
19594
19527
|
horizontalAlign: alignment.horizontal
|
|
19595
19528
|
};
|
|
@@ -19629,18 +19562,17 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19629
19562
|
* ```
|
|
19630
19563
|
*/
|
|
19631
19564
|
columns(options) {
|
|
19632
|
-
var _this$_data2, _this$_data2$body, _body$sectionBreaks, _options$spacing;
|
|
19633
19565
|
if (!Number.isInteger(options.count) || options.count < 1) throw new RangeError("Rich text column count must be a positive integer.");
|
|
19634
|
-
const body =
|
|
19635
|
-
const sectionBreaks =
|
|
19566
|
+
const body = this._data.body ??= { dataStream: "\r\n" };
|
|
19567
|
+
const sectionBreaks = body.sectionBreaks ??= [];
|
|
19636
19568
|
if (!sectionBreaks.length) {
|
|
19637
|
-
var _body$dataStream
|
|
19569
|
+
var _body$dataStream;
|
|
19638
19570
|
sectionBreaks.push({
|
|
19639
19571
|
sectionId: createSectionId(/* @__PURE__ */ new Set()),
|
|
19640
|
-
startIndex: Math.max(0, ((
|
|
19572
|
+
startIndex: Math.max(0, (((_body$dataStream = body.dataStream) === null || _body$dataStream === void 0 ? void 0 : _body$dataStream.length) ?? 0) - 1)
|
|
19641
19573
|
});
|
|
19642
19574
|
}
|
|
19643
|
-
const spacing = Math.max(0,
|
|
19575
|
+
const spacing = Math.max(0, options.spacing ?? 0);
|
|
19644
19576
|
const columns = options.count === 1 ? void 0 : Array.from({ length: options.count }, (_, index) => ({
|
|
19645
19577
|
width: 0,
|
|
19646
19578
|
paddingEnd: index === options.count - 1 ? 0 : spacing
|
|
@@ -19650,14 +19582,15 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19650
19582
|
return this;
|
|
19651
19583
|
}
|
|
19652
19584
|
/**
|
|
19653
|
-
* Appends one text span with
|
|
19585
|
+
* Appends one text span with an optional style.
|
|
19654
19586
|
*
|
|
19655
19587
|
* Prefer this method when combining multiple styles, because the style object is local to the inserted text and does
|
|
19656
19588
|
* not leak into following calls.
|
|
19657
19589
|
*
|
|
19658
19590
|
* @param text Text to append.
|
|
19659
|
-
* @param style
|
|
19660
|
-
* `color`, and `background` are supported alongside native
|
|
19591
|
+
* @param style Optional text style for this span. When omitted, the span is appended as unstyled text. Agent-friendly
|
|
19592
|
+
* aliases such as `bold`, `italic`, `fontFamily`, `fontSize`, `color`, and `background` are supported alongside native
|
|
19593
|
+
* document text style fields.
|
|
19661
19594
|
* @returns The current builder for chaining.
|
|
19662
19595
|
* @example
|
|
19663
19596
|
* ```ts
|
|
@@ -19668,18 +19601,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19668
19601
|
*/
|
|
19669
19602
|
span(text, style) {
|
|
19670
19603
|
if (!text) return this;
|
|
19671
|
-
return this.
|
|
19672
|
-
id: "d",
|
|
19673
|
-
documentStyle: {},
|
|
19674
|
-
body: {
|
|
19675
|
-
dataStream: text,
|
|
19676
|
-
textRuns: [{
|
|
19677
|
-
st: 0,
|
|
19678
|
-
ed: text.length,
|
|
19679
|
-
ts: normalizeRichTextSpanStyle(style)
|
|
19680
|
-
}]
|
|
19681
|
-
}
|
|
19682
|
-
}));
|
|
19604
|
+
return style ? this.insertText(text, normalizeRichTextSpanStyle(style)) : this.insertText(text);
|
|
19683
19605
|
}
|
|
19684
19606
|
/**
|
|
19685
19607
|
* Appends bold text.
|
|
@@ -19753,22 +19675,19 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19753
19675
|
* ```
|
|
19754
19676
|
*/
|
|
19755
19677
|
listItem(text, options = {}) {
|
|
19756
|
-
var
|
|
19757
|
-
const listType =
|
|
19758
|
-
const currentParagraph = (_this$_data$
|
|
19678
|
+
var _this$_data$body7, _options$listId, _this$_data$body8;
|
|
19679
|
+
const listType = options.type ?? "BULLET_LIST";
|
|
19680
|
+
const currentParagraph = (_this$_data$body7 = this._data.body) === null || _this$_data$body7 === void 0 || (_this$_data$body7 = _this$_data$body7.paragraphs) === null || _this$_data$body7 === void 0 ? void 0 : _this$_data$body7.slice(-1)[0];
|
|
19759
19681
|
const currentBullet = currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet;
|
|
19760
19682
|
const listId = ((_options$listId = options.listId) === null || _options$listId === void 0 ? void 0 : _options$listId.trim()) || ((currentBullet === null || currentBullet === void 0 ? void 0 : currentBullet.listType) === listType ? currentBullet.listId : generateRandomId());
|
|
19761
19683
|
if (hasRichTextContent(this._data)) this.paragraph(options.paragraphStyle);
|
|
19762
19684
|
else if (options.paragraphStyle) this.paragraph(options.paragraphStyle);
|
|
19763
|
-
const targetParagraph = (_this$_data$
|
|
19764
|
-
if (targetParagraph) {
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
nestingLevel: Math.max(0, Math.trunc((_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 0))
|
|
19770
|
-
};
|
|
19771
|
-
}
|
|
19685
|
+
const targetParagraph = (_this$_data$body8 = this._data.body) === null || _this$_data$body8 === void 0 || (_this$_data$body8 = _this$_data$body8.paragraphs) === null || _this$_data$body8 === void 0 ? void 0 : _this$_data$body8.slice(-1)[0];
|
|
19686
|
+
if (targetParagraph) targetParagraph.bullet = {
|
|
19687
|
+
listId,
|
|
19688
|
+
listType,
|
|
19689
|
+
nestingLevel: Math.max(0, Math.trunc(options.level ?? 0))
|
|
19690
|
+
};
|
|
19772
19691
|
return this.text(text);
|
|
19773
19692
|
}
|
|
19774
19693
|
/**
|
|
@@ -19789,20 +19708,20 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19789
19708
|
* ```
|
|
19790
19709
|
*/
|
|
19791
19710
|
paragraph(paragraphStyle) {
|
|
19792
|
-
var _this$_data$
|
|
19711
|
+
var _this$_data$body10, _this$_data$body11, _this$_data$body12;
|
|
19793
19712
|
const nextParagraphStyle = normalizeRichTextParagraphStyle(paragraphStyle);
|
|
19794
19713
|
if (!hasRichTextContent(this._data)) {
|
|
19795
19714
|
if (nextParagraphStyle) {
|
|
19796
|
-
var _this$_data$
|
|
19797
|
-
const firstParagraph = (_this$_data$
|
|
19715
|
+
var _this$_data$body9;
|
|
19716
|
+
const firstParagraph = (_this$_data$body9 = this._data.body) === null || _this$_data$body9 === void 0 || (_this$_data$body9 = _this$_data$body9.paragraphs) === null || _this$_data$body9 === void 0 ? void 0 : _this$_data$body9[0];
|
|
19798
19717
|
if (firstParagraph) firstParagraph.paragraphStyle = nextParagraphStyle;
|
|
19799
19718
|
}
|
|
19800
19719
|
return this;
|
|
19801
19720
|
}
|
|
19802
|
-
const currentParagraph = (_this$_data$
|
|
19721
|
+
const currentParagraph = (_this$_data$body10 = this._data.body) === null || _this$_data$body10 === void 0 || (_this$_data$body10 = _this$_data$body10.paragraphs) === null || _this$_data$body10 === void 0 ? void 0 : _this$_data$body10.slice(-1)[0];
|
|
19803
19722
|
const currentParagraphStyle = Tools.deepClone(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.paragraphStyle);
|
|
19804
19723
|
const currentParagraphBullet = Tools.deepClone(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet);
|
|
19805
|
-
const startIndex = Math.max(0, ((
|
|
19724
|
+
const startIndex = Math.max(0, (((_this$_data$body11 = this._data.body) === null || _this$_data$body11 === void 0 ? void 0 : _this$_data$body11.dataStream.length) ?? 2) - 2);
|
|
19806
19725
|
this.insertRichText(startIndex, RichTextValue.create({
|
|
19807
19726
|
id: "d",
|
|
19808
19727
|
documentStyle: {},
|
|
@@ -19816,7 +19735,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19816
19735
|
}]
|
|
19817
19736
|
}
|
|
19818
19737
|
}));
|
|
19819
|
-
const nextParagraph = (_this$_data$
|
|
19738
|
+
const nextParagraph = (_this$_data$body12 = this._data.body) === null || _this$_data$body12 === void 0 || (_this$_data$body12 = _this$_data$body12.paragraphs) === null || _this$_data$body12 === void 0 ? void 0 : _this$_data$body12.slice(-1)[0];
|
|
19820
19739
|
if (nextParagraphStyle) {
|
|
19821
19740
|
if (nextParagraph) nextParagraph.paragraphStyle = nextParagraphStyle;
|
|
19822
19741
|
} else if (nextParagraph) delete nextParagraph.paragraphStyle;
|
|
@@ -19824,24 +19743,26 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19824
19743
|
return this;
|
|
19825
19744
|
}
|
|
19826
19745
|
insertText(start, text, style) {
|
|
19827
|
-
var _this$_data$
|
|
19828
|
-
let startIndex = ((
|
|
19746
|
+
var _this$_data$body13;
|
|
19747
|
+
let startIndex = (((_this$_data$body13 = this._data.body) === null || _this$_data$body13 === void 0 ? void 0 : _this$_data$body13.dataStream.length) ?? 2) - 2;
|
|
19829
19748
|
let insertText;
|
|
19830
19749
|
let insertStyle;
|
|
19831
19750
|
if (typeof start === "string") insertText = start;
|
|
19832
19751
|
else {
|
|
19833
19752
|
startIndex = Math.min(start, startIndex);
|
|
19834
|
-
insertText = text;
|
|
19753
|
+
insertText = typeof text === "string" ? text : "";
|
|
19835
19754
|
}
|
|
19836
19755
|
if (typeof text === "object") insertStyle = text instanceof TextStyleBuilder ? text.build() : text;
|
|
19837
19756
|
else insertStyle = style instanceof TextStyleBuilder ? style.build() : style;
|
|
19838
19757
|
if (!insertText) return this;
|
|
19758
|
+
const plainTextBody = BuildTextUtils.transform.fromPlainText(insertText);
|
|
19839
19759
|
const newBody = {
|
|
19840
|
-
dataStream:
|
|
19760
|
+
dataStream: plainTextBody.dataStream,
|
|
19761
|
+
paragraphs: plainTextBody.paragraphs,
|
|
19841
19762
|
textRuns: insertStyle ? [{
|
|
19842
19763
|
ts: insertStyle,
|
|
19843
|
-
st:
|
|
19844
|
-
ed:
|
|
19764
|
+
st: 0,
|
|
19765
|
+
ed: plainTextBody.dataStream.length
|
|
19845
19766
|
}] : []
|
|
19846
19767
|
};
|
|
19847
19768
|
const textX = BuildTextUtils.selection.replace({
|
|
@@ -19855,11 +19776,12 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19855
19776
|
});
|
|
19856
19777
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19857
19778
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19779
|
+
this._invalidateChildHandles();
|
|
19858
19780
|
return this;
|
|
19859
19781
|
}
|
|
19860
19782
|
insertRichText(start, richText) {
|
|
19861
|
-
var _this$_data$
|
|
19862
|
-
let startIndex = ((
|
|
19783
|
+
var _this$_data$body14;
|
|
19784
|
+
let startIndex = (((_this$_data$body14 = this._data.body) === null || _this$_data$body14 === void 0 ? void 0 : _this$_data$body14.dataStream.length) ?? 2) - 2;
|
|
19863
19785
|
let insertText;
|
|
19864
19786
|
if (typeof start === "object") insertText = start instanceof RichTextValue ? start.getData() : start;
|
|
19865
19787
|
else {
|
|
@@ -19877,17 +19799,32 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19877
19799
|
});
|
|
19878
19800
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19879
19801
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19802
|
+
this._invalidateChildHandles();
|
|
19880
19803
|
return this;
|
|
19881
19804
|
}
|
|
19882
19805
|
delete(start, count) {
|
|
19883
|
-
|
|
19884
|
-
|
|
19806
|
+
var _this$_data$body15;
|
|
19807
|
+
const terminalTokenLength = "\r".length + "\n".length;
|
|
19808
|
+
const contentLength = Math.max(0, (((_this$_data$body15 = this._data.body) === null || _this$_data$body15 === void 0 ? void 0 : _this$_data$body15.dataStream.length) ?? terminalTokenLength) - terminalTokenLength);
|
|
19809
|
+
let startOffset;
|
|
19810
|
+
let deleteCount;
|
|
19811
|
+
if (count === void 0) {
|
|
19812
|
+
if (start < 0) throw new RangeError("Delete count cannot be negative.");
|
|
19813
|
+
deleteCount = Math.min(start, contentLength);
|
|
19814
|
+
startOffset = contentLength - deleteCount;
|
|
19815
|
+
} else {
|
|
19816
|
+
if (start < 0 || count < 0) throw new RangeError("Delete range cannot be negative.");
|
|
19817
|
+
startOffset = Math.min(start, contentLength);
|
|
19818
|
+
deleteCount = Math.min(count, contentLength - startOffset);
|
|
19819
|
+
}
|
|
19820
|
+
if (deleteCount > 0) {
|
|
19885
19821
|
const actions = BuildTextUtils.selection.delete([{
|
|
19886
|
-
startOffset
|
|
19887
|
-
endOffset:
|
|
19822
|
+
startOffset,
|
|
19823
|
+
endOffset: startOffset + deleteCount,
|
|
19888
19824
|
collapsed: true
|
|
19889
19825
|
}], this._data.body);
|
|
19890
19826
|
TextX.apply(this._doc.getBody(), actions);
|
|
19827
|
+
this._invalidateChildHandles();
|
|
19891
19828
|
}
|
|
19892
19829
|
return this;
|
|
19893
19830
|
}
|
|
@@ -19918,6 +19855,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19918
19855
|
collapsed: true
|
|
19919
19856
|
}], newBody);
|
|
19920
19857
|
TextX.apply(this._doc.getBody(), actions);
|
|
19858
|
+
this._invalidateChildHandles();
|
|
19921
19859
|
return this;
|
|
19922
19860
|
}
|
|
19923
19861
|
/**
|
|
@@ -19946,9 +19884,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19946
19884
|
});
|
|
19947
19885
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19948
19886
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19887
|
+
this._invalidateChildHandles();
|
|
19949
19888
|
return this;
|
|
19950
19889
|
}
|
|
19951
19890
|
cancelLink(start, end) {
|
|
19891
|
+
let changed = false;
|
|
19952
19892
|
if (typeof start === "string") {
|
|
19953
19893
|
const textX = BuildTextUtils.customRange.delete({
|
|
19954
19894
|
rangeId: start,
|
|
@@ -19956,6 +19896,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19956
19896
|
});
|
|
19957
19897
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19958
19898
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19899
|
+
changed = true;
|
|
19959
19900
|
} else this.slice(start, end).getLinks().forEach((l) => {
|
|
19960
19901
|
const textX = BuildTextUtils.customRange.delete({
|
|
19961
19902
|
rangeId: l.rangeId,
|
|
@@ -19963,7 +19904,9 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19963
19904
|
});
|
|
19964
19905
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19965
19906
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19907
|
+
changed = true;
|
|
19966
19908
|
});
|
|
19909
|
+
if (changed) this._invalidateChildHandles();
|
|
19967
19910
|
return this;
|
|
19968
19911
|
}
|
|
19969
19912
|
updateLink(id, url) {
|
|
@@ -19977,7 +19920,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19977
19920
|
let newBody;
|
|
19978
19921
|
let startIndex;
|
|
19979
19922
|
if (typeof start === "object") {
|
|
19980
|
-
var _this$_data$
|
|
19923
|
+
var _this$_data$body17;
|
|
19981
19924
|
newBody = {
|
|
19982
19925
|
dataStream: "\r",
|
|
19983
19926
|
paragraphs: [{
|
|
@@ -19986,7 +19929,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19986
19929
|
paragraphStyle: start.build()
|
|
19987
19930
|
}]
|
|
19988
19931
|
};
|
|
19989
|
-
startIndex = ((
|
|
19932
|
+
startIndex = (((_this$_data$body17 = this._data.body) === null || _this$_data$body17 === void 0 ? void 0 : _this$_data$body17.dataStream.length) ?? 2) - 2;
|
|
19990
19933
|
} else {
|
|
19991
19934
|
startIndex = start;
|
|
19992
19935
|
newBody = {
|
|
@@ -20036,18 +19979,21 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
20036
19979
|
*/
|
|
20037
19980
|
var RichTextParagraphBuilder = class extends RichTextValue {
|
|
20038
19981
|
/** @hideconstructor */
|
|
20039
|
-
constructor(_owner, _paragraphId, _range) {
|
|
19982
|
+
constructor(_owner, _paragraphId, _range, _revision) {
|
|
20040
19983
|
super(createParagraphSnapshot(_owner.getData(), _paragraphId, _range));
|
|
20041
19984
|
this._owner = _owner;
|
|
20042
19985
|
this._paragraphId = _paragraphId;
|
|
20043
19986
|
this._range = _range;
|
|
19987
|
+
this._revision = _revision;
|
|
20044
19988
|
}
|
|
20045
19989
|
/** Returns the persisted paragraph id. */
|
|
20046
19990
|
getId() {
|
|
19991
|
+
this._assertActive();
|
|
20047
19992
|
return this._paragraphId;
|
|
20048
19993
|
}
|
|
20049
19994
|
/** Returns the current paragraph range without its trailing paragraph marker. */
|
|
20050
19995
|
getRange() {
|
|
19996
|
+
this._assertActive();
|
|
20051
19997
|
return { ...this._range };
|
|
20052
19998
|
}
|
|
20053
19999
|
/**
|
|
@@ -20060,8 +20006,9 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20060
20006
|
* ```
|
|
20061
20007
|
*/
|
|
20062
20008
|
getText() {
|
|
20063
|
-
var _this$_owner$getData
|
|
20064
|
-
|
|
20009
|
+
var _this$_owner$getData$;
|
|
20010
|
+
this._assertActive();
|
|
20011
|
+
return (((_this$_owner$getData$ = this._owner.getData().body) === null || _this$_owner$getData$ === void 0 ? void 0 : _this$_owner$getData$.dataStream) ?? "").slice(this._range.startOffset, this._range.endOffset);
|
|
20065
20012
|
}
|
|
20066
20013
|
toPlainText() {
|
|
20067
20014
|
return this.getText();
|
|
@@ -20071,34 +20018,42 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20071
20018
|
* @returns Editable text runs in document order.
|
|
20072
20019
|
*/
|
|
20073
20020
|
getTextRuns() {
|
|
20021
|
+
this._assertActive();
|
|
20074
20022
|
return this._owner._createTextRunBuilders(this._range);
|
|
20075
20023
|
}
|
|
20076
20024
|
getParagraphStyle() {
|
|
20025
|
+
this._assertActive();
|
|
20077
20026
|
return ParagraphStyleValue.create(this._getParagraph().paragraphStyle);
|
|
20078
20027
|
}
|
|
20079
20028
|
getParagraphBullet() {
|
|
20029
|
+
this._assertActive();
|
|
20080
20030
|
return this._getParagraph().bullet;
|
|
20081
20031
|
}
|
|
20082
20032
|
getLinks() {
|
|
20083
|
-
var _this$getData$body
|
|
20084
|
-
|
|
20033
|
+
var _this$getData$body;
|
|
20034
|
+
this._assertActive();
|
|
20035
|
+
return ((_this$getData$body = this.getData().body) === null || _this$getData$body === void 0 || (_this$getData$body = _this$getData$body.customRanges) === null || _this$getData$body === void 0 ? void 0 : _this$getData$body.filter((range) => range.rangeType === 0)) ?? [];
|
|
20085
20036
|
}
|
|
20086
20037
|
/** Agent-friendly alias of `getParagraphBullet()`. */
|
|
20087
20038
|
getBullet() {
|
|
20088
20039
|
return this.getParagraphBullet();
|
|
20089
20040
|
}
|
|
20090
20041
|
getData() {
|
|
20042
|
+
this._assertActive();
|
|
20091
20043
|
return createParagraphSnapshot(this._owner.getData(), this._paragraphId, this._range);
|
|
20092
20044
|
}
|
|
20093
20045
|
copy() {
|
|
20094
20046
|
return RichTextBuilder.create(Tools.deepClone(this.getData()));
|
|
20095
20047
|
}
|
|
20096
20048
|
_getParagraph() {
|
|
20097
|
-
var _this$_owner$getData$
|
|
20098
|
-
const paragraph = (_this$_owner$getData$
|
|
20049
|
+
var _this$_owner$getData$2;
|
|
20050
|
+
const paragraph = (_this$_owner$getData$2 = this._owner.getData().body) === null || _this$_owner$getData$2 === void 0 || (_this$_owner$getData$2 = _this$_owner$getData$2.paragraphs) === null || _this$_owner$getData$2 === void 0 ? void 0 : _this$_owner$getData$2.find((item) => item.paragraphId === this._paragraphId);
|
|
20099
20051
|
if (!paragraph) throw new Error(`Rich text paragraph "${this._paragraphId}" was not found.`);
|
|
20100
20052
|
return paragraph;
|
|
20101
20053
|
}
|
|
20054
|
+
_assertActive() {
|
|
20055
|
+
this._owner._assertChildHandleRevision(this._revision);
|
|
20056
|
+
}
|
|
20102
20057
|
};
|
|
20103
20058
|
/**
|
|
20104
20059
|
* An editable text-run handle owned by a detached {@link RichTextBuilder}.
|
|
@@ -20108,38 +20063,45 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20108
20063
|
*/
|
|
20109
20064
|
var RichTextRunBuilder = class {
|
|
20110
20065
|
/** @hideconstructor */
|
|
20111
|
-
constructor(_owner, _range, _textStyle, _styleId, _hasExplicitTextStyle) {
|
|
20066
|
+
constructor(_owner, _range, _textStyle, _styleId, _hasExplicitTextStyle, _revision) {
|
|
20112
20067
|
this._owner = _owner;
|
|
20113
20068
|
this._range = _range;
|
|
20114
20069
|
this._textStyle = _textStyle;
|
|
20115
20070
|
this._styleId = _styleId;
|
|
20116
20071
|
this._hasExplicitTextStyle = _hasExplicitTextStyle;
|
|
20072
|
+
this._revision = _revision;
|
|
20117
20073
|
_defineProperty(this, "_active", true);
|
|
20118
20074
|
}
|
|
20119
20075
|
/** Inclusive start offset, kept for compatibility with existing `getTextRuns()` callers. */
|
|
20120
20076
|
get st() {
|
|
20077
|
+
this._assertActive();
|
|
20121
20078
|
return this._range.startOffset;
|
|
20122
20079
|
}
|
|
20123
20080
|
/** Exclusive end offset, automatically updated after text replacement. */
|
|
20124
20081
|
get ed() {
|
|
20082
|
+
this._assertActive();
|
|
20125
20083
|
return this._range.endOffset;
|
|
20126
20084
|
}
|
|
20127
20085
|
/** Optional persisted style id. This is not a stable run identity. */
|
|
20128
20086
|
get sId() {
|
|
20087
|
+
this._assertActive();
|
|
20129
20088
|
return this._styleId;
|
|
20130
20089
|
}
|
|
20131
20090
|
/** Existing text-style value property exposed by `getTextRuns()`. */
|
|
20132
20091
|
get ts() {
|
|
20092
|
+
this._assertActive();
|
|
20133
20093
|
return this._textStyle ? TextStyleValue.create(this._textStyle) : null;
|
|
20134
20094
|
}
|
|
20135
20095
|
/** Returns the current run range. */
|
|
20136
20096
|
getRange() {
|
|
20097
|
+
this._assertActive();
|
|
20137
20098
|
return { ...this._range };
|
|
20138
20099
|
}
|
|
20139
20100
|
/** Returns the current run text. */
|
|
20140
20101
|
getText() {
|
|
20141
|
-
var _this$_owner$getData$
|
|
20142
|
-
|
|
20102
|
+
var _this$_owner$getData$3;
|
|
20103
|
+
this._assertActive();
|
|
20104
|
+
return (((_this$_owner$getData$3 = this._owner.getData().body) === null || _this$_owner$getData$3 === void 0 ? void 0 : _this$_owner$getData$3.dataStream) ?? "").slice(this._range.startOffset, this._range.endOffset);
|
|
20143
20105
|
}
|
|
20144
20106
|
/** Returns this run's explicit text style, or `null` for an unstyled text segment. */
|
|
20145
20107
|
getTextStyle() {
|
|
@@ -20147,6 +20109,7 @@ var RichTextRunBuilder = class {
|
|
|
20147
20109
|
}
|
|
20148
20110
|
/** Returns whether this segment is backed by an explicit document text run. */
|
|
20149
20111
|
hasTextStyle() {
|
|
20112
|
+
this._assertActive();
|
|
20150
20113
|
return this._hasExplicitTextStyle;
|
|
20151
20114
|
}
|
|
20152
20115
|
/**
|
|
@@ -20174,17 +20137,21 @@ var RichTextRunBuilder = class {
|
|
|
20174
20137
|
* ```
|
|
20175
20138
|
*/
|
|
20176
20139
|
setText(text) {
|
|
20177
|
-
|
|
20140
|
+
this._assertActive();
|
|
20178
20141
|
this._owner._replaceTextRun(this._range, text, this._textStyle, this._styleId, this._hasExplicitTextStyle);
|
|
20179
20142
|
if (!text) this._active = false;
|
|
20180
20143
|
return this;
|
|
20181
20144
|
}
|
|
20145
|
+
_assertActive() {
|
|
20146
|
+
if (!this._active) throw new Error("Rich text run handle is no longer valid.");
|
|
20147
|
+
this._owner._assertChildHandleRevision(this._revision);
|
|
20148
|
+
}
|
|
20182
20149
|
};
|
|
20183
20150
|
function createParagraphSnapshot(data, paragraphId, range) {
|
|
20184
|
-
var _body$
|
|
20151
|
+
var _body$paragraphs;
|
|
20185
20152
|
const { body, ...documentData } = data;
|
|
20186
20153
|
if (!body) throw new Error("Rich text body is not available.");
|
|
20187
|
-
const paragraph = (_body$
|
|
20154
|
+
const paragraph = (_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.find((item) => item.paragraphId === paragraphId);
|
|
20188
20155
|
if (!paragraph) throw new Error(`Rich text paragraph "${paragraphId}" was not found.`);
|
|
20189
20156
|
const paragraphBody = getBodySlice(body, range.startOffset, range.endOffset);
|
|
20190
20157
|
paragraphBody.paragraphs = [{
|
|
@@ -20231,13 +20198,9 @@ function validateMinimumRootSentinels(body, issues, context) {
|
|
|
20231
20198
|
if (!body.dataStream.includes("\n")) issues.push(createIssue(context, "missing-root-section-break", "Document body must contain at least one section break sentinel."));
|
|
20232
20199
|
}
|
|
20233
20200
|
function validateParagraphMetadata(body, issues, context) {
|
|
20234
|
-
var _body$paragraphs;
|
|
20235
20201
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20236
|
-
for (const paragraph of
|
|
20237
|
-
else
|
|
20238
|
-
var _metadataCounts$get;
|
|
20239
|
-
metadataCounts.set(paragraph.startIndex, ((_metadataCounts$get = metadataCounts.get(paragraph.startIndex)) !== null && _metadataCounts$get !== void 0 ? _metadataCounts$get : 0) + 1);
|
|
20240
|
-
}
|
|
20202
|
+
for (const paragraph of body.paragraphs ?? []) if (body.dataStream[paragraph.startIndex] !== "\r") issues.push(createIssue(context, "paragraph-token-mismatch", "Paragraph metadata must point to a paragraph sentinel.", paragraph.startIndex));
|
|
20203
|
+
else metadataCounts.set(paragraph.startIndex, (metadataCounts.get(paragraph.startIndex) ?? 0) + 1);
|
|
20241
20204
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20242
20205
|
context,
|
|
20243
20206
|
duplicateCode: "duplicate-paragraph-metadata",
|
|
@@ -20245,20 +20208,13 @@ function validateParagraphMetadata(body, issues, context) {
|
|
|
20245
20208
|
}, issues);
|
|
20246
20209
|
}
|
|
20247
20210
|
function validateSectionBreakMetadata(body, issues, context) {
|
|
20248
|
-
var _body$sectionBreaks;
|
|
20249
20211
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20250
20212
|
const sectionIds = /* @__PURE__ */ new Map();
|
|
20251
|
-
for (const sectionBreak of
|
|
20213
|
+
for (const sectionBreak of body.sectionBreaks ?? []) {
|
|
20252
20214
|
if (!sectionBreak.sectionId) issues.push(createIssue(context, "missing-section-id", "Section break metadata must have a stable section id.", sectionBreak.startIndex));
|
|
20253
|
-
else
|
|
20254
|
-
var _sectionIds$get;
|
|
20255
|
-
sectionIds.set(sectionBreak.sectionId, ((_sectionIds$get = sectionIds.get(sectionBreak.sectionId)) !== null && _sectionIds$get !== void 0 ? _sectionIds$get : 0) + 1);
|
|
20256
|
-
}
|
|
20215
|
+
else sectionIds.set(sectionBreak.sectionId, (sectionIds.get(sectionBreak.sectionId) ?? 0) + 1);
|
|
20257
20216
|
if (body.dataStream[sectionBreak.startIndex] !== "\n") issues.push(createIssue(context, "section-break-token-mismatch", "Section break metadata must point to a section break sentinel.", sectionBreak.startIndex));
|
|
20258
|
-
else
|
|
20259
|
-
var _metadataCounts$get2;
|
|
20260
|
-
metadataCounts.set(sectionBreak.startIndex, ((_metadataCounts$get2 = metadataCounts.get(sectionBreak.startIndex)) !== null && _metadataCounts$get2 !== void 0 ? _metadataCounts$get2 : 0) + 1);
|
|
20261
|
-
}
|
|
20217
|
+
else metadataCounts.set(sectionBreak.startIndex, (metadataCounts.get(sectionBreak.startIndex) ?? 0) + 1);
|
|
20262
20218
|
}
|
|
20263
20219
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20264
20220
|
context,
|
|
@@ -20287,11 +20243,10 @@ function collectPairedTokenRanges(dataStream, startToken, endToken, exclusiveEnd
|
|
|
20287
20243
|
};
|
|
20288
20244
|
}
|
|
20289
20245
|
function validateTableMetadata(body, issues, context) {
|
|
20290
|
-
var _body$tables;
|
|
20291
20246
|
const pairedTables = collectPairedTokenRanges(body.dataStream, "", "", true).pairs;
|
|
20292
20247
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20293
20248
|
let previousTable;
|
|
20294
|
-
const tables = [...
|
|
20249
|
+
const tables = [...body.tables ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20295
20250
|
for (const table of tables) {
|
|
20296
20251
|
metadataStarts.add(table.startIndex);
|
|
20297
20252
|
if (!Number.isInteger(table.startIndex) || body.dataStream[table.startIndex] !== "") issues.push(createIssue(context, "table-start-token-mismatch", "Table startIndex must point to a table start sentinel.", table.startIndex));
|
|
@@ -20302,10 +20257,9 @@ function validateTableMetadata(body, issues, context) {
|
|
|
20302
20257
|
for (const startIndex of pairedTables.keys()) if (!metadataStarts.has(startIndex)) issues.push(createIssue(context, "missing-table-metadata", "Table token range must have a table metadata entry.", startIndex));
|
|
20303
20258
|
}
|
|
20304
20259
|
function validateBlockRangeMetadata(body, issues, context) {
|
|
20305
|
-
var _body$blockRanges;
|
|
20306
20260
|
const pairedBlocks = collectPairedTokenRanges(body.dataStream, "", "", false);
|
|
20307
20261
|
for (const index of [...pairedBlocks.unmatchedStarts, ...pairedBlocks.unmatchedEnds]) issues.push(createIssue(context, "unbalanced-block", "Block sentinel has no matching boundary.", index));
|
|
20308
|
-
const blockRanges = [...
|
|
20262
|
+
const blockRanges = [...body.blockRanges ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20309
20263
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20310
20264
|
let previousBlockRange;
|
|
20311
20265
|
for (let i = 0; i < blockRanges.length; i++) {
|
|
@@ -20318,10 +20272,9 @@ function validateBlockRangeMetadata(body, issues, context) {
|
|
|
20318
20272
|
for (const startIndex of pairedBlocks.pairs.keys()) if (!metadataStarts.has(startIndex)) issues.push(createIssue(context, "missing-block-range-metadata", "Block token range must have a block metadata entry.", startIndex));
|
|
20319
20273
|
}
|
|
20320
20274
|
function validateColumnGroupMetadata(body, issues, context) {
|
|
20321
|
-
var _body$columnGroups;
|
|
20322
20275
|
const pairedColumnGroups = collectPairedTokenRanges(body.dataStream, "", "", false).pairs;
|
|
20323
20276
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20324
|
-
const columnGroups = [...
|
|
20277
|
+
const columnGroups = [...body.columnGroups ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20325
20278
|
let previousColumnGroup;
|
|
20326
20279
|
for (const columnGroup of columnGroups) {
|
|
20327
20280
|
metadataStarts.add(columnGroup.startIndex);
|
|
@@ -20331,7 +20284,7 @@ function validateColumnGroupMetadata(body, issues, context) {
|
|
|
20331
20284
|
previousColumnGroup = columnGroup;
|
|
20332
20285
|
if (Array.isArray(columnGroup.columns)) {
|
|
20333
20286
|
let streamColumnCount = 0;
|
|
20334
|
-
const scanEnd = pairedEndIndex
|
|
20287
|
+
const scanEnd = pairedEndIndex ?? columnGroup.endIndex;
|
|
20335
20288
|
for (let index = columnGroup.startIndex + 1; index < scanEnd; index++) if (body.dataStream[index] === "") streamColumnCount++;
|
|
20336
20289
|
if (streamColumnCount !== columnGroup.columns.length) issues.push(createIssue(context, "column-group-column-count-mismatch", "Column group metadata column count must match the data stream.", columnGroup.startIndex));
|
|
20337
20290
|
}
|
|
@@ -20339,16 +20292,14 @@ function validateColumnGroupMetadata(body, issues, context) {
|
|
|
20339
20292
|
for (const startIndex of pairedColumnGroups.keys()) if (!metadataStarts.has(startIndex)) issues.push(createIssue(context, "missing-column-group-metadata", "Column group token range must have a metadata entry.", startIndex));
|
|
20340
20293
|
}
|
|
20341
20294
|
function validateCustomBlockMetadata(body, issues, context) {
|
|
20342
|
-
var _body$customBlocks;
|
|
20343
20295
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20344
|
-
for (const customBlock of
|
|
20345
|
-
var _metadataCounts$get3;
|
|
20296
|
+
for (const customBlock of body.customBlocks ?? []) {
|
|
20346
20297
|
const { startIndex } = customBlock;
|
|
20347
20298
|
if (!Number.isInteger(startIndex) || body.dataStream[startIndex] !== "\b") {
|
|
20348
20299
|
issues.push(createIssue(context, "custom-block-token-mismatch", "Custom block startIndex must point to a custom block sentinel.", startIndex));
|
|
20349
20300
|
continue;
|
|
20350
20301
|
}
|
|
20351
|
-
metadataCounts.set(startIndex, (
|
|
20302
|
+
metadataCounts.set(startIndex, (metadataCounts.get(startIndex) ?? 0) + 1);
|
|
20352
20303
|
}
|
|
20353
20304
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20354
20305
|
context,
|
|
@@ -20423,14 +20374,13 @@ function validateDocBodyStructure(body, context = { segmentType: "body" }) {
|
|
|
20423
20374
|
return issues;
|
|
20424
20375
|
}
|
|
20425
20376
|
function validateDocumentStructure(snapshot) {
|
|
20426
|
-
var _snapshot$headers, _snapshot$footers;
|
|
20427
20377
|
const issues = [];
|
|
20428
20378
|
if (snapshot.body) issues.push(...validateDocBodyStructure(snapshot.body, { segmentType: "body" }));
|
|
20429
|
-
for (const [headerId, header] of Object.entries(
|
|
20379
|
+
for (const [headerId, header] of Object.entries(snapshot.headers ?? {})) issues.push(...validateDocBodyStructure(header.body, {
|
|
20430
20380
|
segmentType: "header",
|
|
20431
20381
|
segmentId: headerId
|
|
20432
20382
|
}));
|
|
20433
|
-
for (const [footerId, footer] of Object.entries(
|
|
20383
|
+
for (const [footerId, footer] of Object.entries(snapshot.footers ?? {})) issues.push(...validateDocBodyStructure(footer.body, {
|
|
20434
20384
|
segmentType: "footer",
|
|
20435
20385
|
segmentId: footerId
|
|
20436
20386
|
}));
|
|
@@ -20541,10 +20491,7 @@ var EventSubject = class extends rxjs.Subject {
|
|
|
20541
20491
|
else ob = observer;
|
|
20542
20492
|
const subscription = super.subscribe(ob);
|
|
20543
20493
|
this._sortedObservers.push(ob);
|
|
20544
|
-
this._sortedObservers.sort((a, b) =>
|
|
20545
|
-
var _a$priority, _b$priority;
|
|
20546
|
-
return ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0) - ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0);
|
|
20547
|
-
});
|
|
20494
|
+
this._sortedObservers.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
20548
20495
|
subscription.add(() => this._sortedObservers = this._sortedObservers.filter((o) => o !== ob));
|
|
20549
20496
|
return subscription;
|
|
20550
20497
|
}
|
|
@@ -21046,8 +20993,6 @@ const FOCUSING_SHEET = "FOCUSING_SHEET";
|
|
|
21046
20993
|
const FOCUSING_DOC = "FOCUSING_DOC";
|
|
21047
20994
|
const FOCUSING_SLIDE = "FOCUSING_SLIDE";
|
|
21048
20995
|
const FOCUSING_BOARD = "FOCUSING_BOARD";
|
|
21049
|
-
/** @deprecated */
|
|
21050
|
-
const FOCUSING_EDITOR_BUT_HIDDEN = "FOCUSING_EDITOR_BUT_HIDDEN";
|
|
21051
20996
|
const EDITOR_ACTIVATED = "EDITOR_ACTIVATED";
|
|
21052
20997
|
const FOCUSING_EDITOR_INPUT_FORMULA = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
21053
20998
|
/** The focusing state of the formula editor (Fx bar). */
|
|
@@ -21255,13 +21200,12 @@ const getDefaultBaselineOffset = (fontSize) => ({
|
|
|
21255
21200
|
spo: fontSize
|
|
21256
21201
|
});
|
|
21257
21202
|
function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
21258
|
-
var _paddingData$t, _paddingData$r, _paddingData$b, _paddingData$l;
|
|
21259
21203
|
const contentLength = content.length;
|
|
21260
21204
|
const { textRotation, paddingData, horizontalAlign = 0, verticalAlign = 0, wrapStrategy = 0, cellValueType } = config;
|
|
21261
|
-
const marginTop = (
|
|
21262
|
-
const marginRight = (
|
|
21263
|
-
const marginBottom = (
|
|
21264
|
-
const marginLeft = (
|
|
21205
|
+
const marginTop = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.t) ?? DEFAULT_PADDING_DATA.t;
|
|
21206
|
+
const marginRight = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.r) ?? DEFAULT_PADDING_DATA.r;
|
|
21207
|
+
const marginBottom = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.b) ?? DEFAULT_PADDING_DATA.b;
|
|
21208
|
+
const marginLeft = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.l) ?? DEFAULT_PADDING_DATA.l;
|
|
21265
21209
|
const { vertexAngle, centerAngle } = convertTextRotation(textRotation);
|
|
21266
21210
|
return new DocumentDataModel({
|
|
21267
21211
|
id: "d",
|
|
@@ -21441,214 +21385,22 @@ function convertTextRotation(textRotation) {
|
|
|
21441
21385
|
}
|
|
21442
21386
|
|
|
21443
21387
|
//#endregion
|
|
21444
|
-
//#region src/sheets/
|
|
21388
|
+
//#region src/sheets/column-manager.ts
|
|
21445
21389
|
/**
|
|
21446
|
-
*
|
|
21447
|
-
* Avoids type checking overhead when we know the structure.
|
|
21390
|
+
* Manage configuration information of all columns, get column width, column length, set column width, etc.
|
|
21448
21391
|
*/
|
|
21449
|
-
|
|
21450
|
-
|
|
21451
|
-
|
|
21452
|
-
|
|
21453
|
-
|
|
21454
|
-
const result = new Array(len);
|
|
21455
|
-
for (let i = 0; i < len; i++) result[i] = cloneValue(value[i]);
|
|
21456
|
-
return result;
|
|
21392
|
+
var ColumnManager = class {
|
|
21393
|
+
constructor(_config, data) {
|
|
21394
|
+
this._config = _config;
|
|
21395
|
+
_defineProperty(this, "_columnData", {});
|
|
21396
|
+
this._columnData = data;
|
|
21457
21397
|
}
|
|
21458
|
-
|
|
21459
|
-
|
|
21460
|
-
|
|
21461
|
-
|
|
21462
|
-
|
|
21463
|
-
|
|
21464
|
-
return result;
|
|
21465
|
-
}
|
|
21466
|
-
/**
|
|
21467
|
-
* Fast clone for ICellData. Optimized for the known structure.
|
|
21468
|
-
* @param cell - The cell data to clone
|
|
21469
|
-
* @returns A deep clone of the cell data
|
|
21470
|
-
*/
|
|
21471
|
-
function cloneCellData(cell) {
|
|
21472
|
-
if (cell === null || cell === void 0) return cell;
|
|
21473
|
-
const result = {};
|
|
21474
|
-
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
21475
|
-
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
21476
|
-
else result.s = cloneValue(cell.s);
|
|
21477
|
-
if (cell.v !== void 0) result.v = cell.v;
|
|
21478
|
-
if (cell.t !== void 0) result.t = cell.t;
|
|
21479
|
-
if (cell.f !== void 0) result.f = cell.f;
|
|
21480
|
-
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
21481
|
-
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
21482
|
-
if (cell.si !== void 0) result.si = cell.si;
|
|
21483
|
-
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
21484
|
-
return result;
|
|
21485
|
-
}
|
|
21486
|
-
/**
|
|
21487
|
-
* Fast clone for ICellDataWithSpanAndDisplay. Optimized for the known structure.
|
|
21488
|
-
* This extends cloneCellData with additional span and display properties.
|
|
21489
|
-
* @param cell - The cell data with span and display info to clone
|
|
21490
|
-
* @returns A deep clone of the cell data
|
|
21491
|
-
*/
|
|
21492
|
-
function cloneCellDataWithSpanAndDisplay(cell) {
|
|
21493
|
-
if (cell === null || cell === void 0) return cell;
|
|
21494
|
-
const result = {};
|
|
21495
|
-
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
21496
|
-
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
21497
|
-
else result.s = cloneValue(cell.s);
|
|
21498
|
-
if (cell.v !== void 0) result.v = cell.v;
|
|
21499
|
-
if (cell.t !== void 0) result.t = cell.t;
|
|
21500
|
-
if (cell.f !== void 0) result.f = cell.f;
|
|
21501
|
-
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
21502
|
-
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
21503
|
-
if (cell.si !== void 0) result.si = cell.si;
|
|
21504
|
-
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
21505
|
-
if (cell.rowSpan !== void 0) result.rowSpan = cell.rowSpan;
|
|
21506
|
-
if (cell.colSpan !== void 0) result.colSpan = cell.colSpan;
|
|
21507
|
-
if (cell.displayV !== void 0) result.displayV = cell.displayV;
|
|
21508
|
-
return result;
|
|
21509
|
-
}
|
|
21510
|
-
/**
|
|
21511
|
-
* Fast clone for cell data matrix. Optimized for sparse matrix structure.
|
|
21512
|
-
* @param cellData - The cell data matrix to clone
|
|
21513
|
-
* @returns A deep clone of the cell data matrix
|
|
21514
|
-
*/
|
|
21515
|
-
function cloneCellDataMatrix(cellData) {
|
|
21516
|
-
const result = {};
|
|
21517
|
-
const rowKeys = Object.keys(cellData);
|
|
21518
|
-
for (let i = 0, rowLen = rowKeys.length; i < rowLen; i++) {
|
|
21519
|
-
const rowKey = rowKeys[i];
|
|
21520
|
-
const rowNum = Number(rowKey);
|
|
21521
|
-
const rowData = cellData[rowNum];
|
|
21522
|
-
if (rowData === void 0) continue;
|
|
21523
|
-
const clonedRow = {};
|
|
21524
|
-
const colKeys = Object.keys(rowData);
|
|
21525
|
-
for (let j = 0, colLen = colKeys.length; j < colLen; j++) {
|
|
21526
|
-
const colKey = colKeys[j];
|
|
21527
|
-
const colNum = Number(colKey);
|
|
21528
|
-
const cell = rowData[colNum];
|
|
21529
|
-
if (cell !== void 0 && cell !== null) clonedRow[colNum] = cloneCellData(cell);
|
|
21530
|
-
}
|
|
21531
|
-
result[rowNum] = clonedRow;
|
|
21532
|
-
}
|
|
21533
|
-
return result;
|
|
21534
|
-
}
|
|
21535
|
-
/**
|
|
21536
|
-
* Fast clone for row/column data arrays (sparse arrays stored as objects).
|
|
21537
|
-
* @param data - The row or column data to clone
|
|
21538
|
-
* @returns A deep clone of the row or column data
|
|
21539
|
-
*/
|
|
21540
|
-
function cloneRowColumnData(data) {
|
|
21541
|
-
const result = {};
|
|
21542
|
-
const keys = Object.keys(data);
|
|
21543
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
21544
|
-
const key = keys[i];
|
|
21545
|
-
const idx = Number(key);
|
|
21546
|
-
const item = data[idx];
|
|
21547
|
-
if (item === void 0) continue;
|
|
21548
|
-
const cloned = {};
|
|
21549
|
-
if ("h" in item && item.h !== void 0) cloned.h = item.h;
|
|
21550
|
-
if ("ia" in item && item.ia !== void 0) cloned.ia = item.ia;
|
|
21551
|
-
if ("ah" in item && item.ah !== void 0) cloned.ah = item.ah;
|
|
21552
|
-
if ("hd" in item && item.hd !== void 0) cloned.hd = item.hd;
|
|
21553
|
-
if ("w" in item && item.w !== void 0) cloned.w = item.w;
|
|
21554
|
-
if ("s" in item && item.s !== void 0) if (item.s === null || typeof item.s === "string") cloned.s = item.s;
|
|
21555
|
-
else cloned.s = cloneValue(item.s);
|
|
21556
|
-
if ("custom" in item && item.custom !== void 0) cloned.custom = item.custom === null ? null : cloneValue(item.custom);
|
|
21557
|
-
result[idx] = cloned;
|
|
21558
|
-
}
|
|
21559
|
-
return result;
|
|
21560
|
-
}
|
|
21561
|
-
/**
|
|
21562
|
-
* Fast clone for IRange array (merge data).
|
|
21563
|
-
* @param ranges - The array of ranges to clone
|
|
21564
|
-
* @returns A shallow clone of the ranges (IRange contains only primitive values)
|
|
21565
|
-
*/
|
|
21566
|
-
function cloneMergeData(ranges) {
|
|
21567
|
-
const len = ranges.length;
|
|
21568
|
-
const result = new Array(len);
|
|
21569
|
-
for (let i = 0; i < len; i++) {
|
|
21570
|
-
const range = ranges[i];
|
|
21571
|
-
result[i] = {
|
|
21572
|
-
startRow: range.startRow,
|
|
21573
|
-
startColumn: range.startColumn,
|
|
21574
|
-
endRow: range.endRow,
|
|
21575
|
-
endColumn: range.endColumn,
|
|
21576
|
-
rangeType: range.rangeType,
|
|
21577
|
-
startAbsoluteRefType: range.startAbsoluteRefType,
|
|
21578
|
-
endAbsoluteRefType: range.endAbsoluteRefType
|
|
21579
|
-
};
|
|
21580
|
-
}
|
|
21581
|
-
return result;
|
|
21582
|
-
}
|
|
21583
|
-
/**
|
|
21584
|
-
* Optimized deep clone specifically for IWorksheetData.
|
|
21585
|
-
* This is significantly faster than generic deepClone because:
|
|
21586
|
-
* 1. No recursive type checking - we know the structure
|
|
21587
|
-
* 2. Direct property access instead of Object.keys iteration for known properties
|
|
21588
|
-
* 3. Specialized handlers for cellData matrix (the largest data)
|
|
21589
|
-
* 4. Primitive values copied directly without cloning
|
|
21590
|
-
*
|
|
21591
|
-
* @param worksheet - The worksheet data to clone
|
|
21592
|
-
* @returns A deep clone of the worksheet data
|
|
21593
|
-
*/
|
|
21594
|
-
function cloneWorksheetData(worksheet) {
|
|
21595
|
-
const result = {
|
|
21596
|
-
id: worksheet.id,
|
|
21597
|
-
name: worksheet.name,
|
|
21598
|
-
tabColor: worksheet.tabColor,
|
|
21599
|
-
hidden: worksheet.hidden,
|
|
21600
|
-
rowCount: worksheet.rowCount,
|
|
21601
|
-
columnCount: worksheet.columnCount,
|
|
21602
|
-
zoomRatio: worksheet.zoomRatio,
|
|
21603
|
-
scrollTop: worksheet.scrollTop,
|
|
21604
|
-
scrollLeft: worksheet.scrollLeft,
|
|
21605
|
-
defaultColumnWidth: worksheet.defaultColumnWidth,
|
|
21606
|
-
defaultRowHeight: worksheet.defaultRowHeight,
|
|
21607
|
-
showGridlines: worksheet.showGridlines,
|
|
21608
|
-
rightToLeft: worksheet.rightToLeft,
|
|
21609
|
-
freeze: {
|
|
21610
|
-
xSplit: worksheet.freeze.xSplit,
|
|
21611
|
-
ySplit: worksheet.freeze.ySplit,
|
|
21612
|
-
startRow: worksheet.freeze.startRow,
|
|
21613
|
-
startColumn: worksheet.freeze.startColumn
|
|
21614
|
-
},
|
|
21615
|
-
rowHeader: {
|
|
21616
|
-
width: worksheet.rowHeader.width,
|
|
21617
|
-
hidden: worksheet.rowHeader.hidden
|
|
21618
|
-
},
|
|
21619
|
-
columnHeader: {
|
|
21620
|
-
height: worksheet.columnHeader.height,
|
|
21621
|
-
hidden: worksheet.columnHeader.hidden
|
|
21622
|
-
},
|
|
21623
|
-
mergeData: cloneMergeData(worksheet.mergeData),
|
|
21624
|
-
cellData: cloneCellDataMatrix(worksheet.cellData),
|
|
21625
|
-
rowData: cloneRowColumnData(worksheet.rowData),
|
|
21626
|
-
columnData: cloneRowColumnData(worksheet.columnData)
|
|
21627
|
-
};
|
|
21628
|
-
if (worksheet.gridlinesColor !== void 0) result.gridlinesColor = worksheet.gridlinesColor;
|
|
21629
|
-
if (worksheet.defaultStyle !== void 0) if (worksheet.defaultStyle === null || typeof worksheet.defaultStyle === "string") result.defaultStyle = worksheet.defaultStyle;
|
|
21630
|
-
else result.defaultStyle = cloneValue(worksheet.defaultStyle);
|
|
21631
|
-
if (worksheet.custom !== void 0) result.custom = worksheet.custom === null ? null : cloneValue(worksheet.custom);
|
|
21632
|
-
return result;
|
|
21633
|
-
}
|
|
21634
|
-
|
|
21635
|
-
//#endregion
|
|
21636
|
-
//#region src/sheets/column-manager.ts
|
|
21637
|
-
/**
|
|
21638
|
-
* Manage configuration information of all columns, get column width, column length, set column width, etc.
|
|
21639
|
-
*/
|
|
21640
|
-
var ColumnManager = class {
|
|
21641
|
-
constructor(_config, data) {
|
|
21642
|
-
this._config = _config;
|
|
21643
|
-
_defineProperty(this, "_columnData", {});
|
|
21644
|
-
this._columnData = data;
|
|
21645
|
-
}
|
|
21646
|
-
/**
|
|
21647
|
-
* Get width and hidden status of columns in the sheet
|
|
21648
|
-
* @returns {IObjectArrayPrimitiveType<Partial<IColumnData>>} Column data, including width, hidden status, etc.
|
|
21649
|
-
*/
|
|
21650
|
-
getColumnData() {
|
|
21651
|
-
return this._columnData;
|
|
21398
|
+
/**
|
|
21399
|
+
* Get width and hidden status of columns in the sheet
|
|
21400
|
+
* @returns {IObjectArrayPrimitiveType<Partial<IColumnData>>} Column data, including width, hidden status, etc.
|
|
21401
|
+
*/
|
|
21402
|
+
getColumnData() {
|
|
21403
|
+
return this._columnData;
|
|
21652
21404
|
}
|
|
21653
21405
|
getColVisible(colPos) {
|
|
21654
21406
|
const { _columnData } = this;
|
|
@@ -21748,8 +21500,7 @@ var ColumnManager = class {
|
|
|
21748
21500
|
const columnData = {};
|
|
21749
21501
|
let index = 0;
|
|
21750
21502
|
for (let i = columnPos; i < columnPos + numColumns; i++) {
|
|
21751
|
-
|
|
21752
|
-
columnData[index] = data !== null && data !== void 0 ? data : {
|
|
21503
|
+
columnData[index] = this.getColumn(i) ?? {
|
|
21753
21504
|
w: this._config.defaultColumnWidth,
|
|
21754
21505
|
hd: 0
|
|
21755
21506
|
};
|
|
@@ -21770,8 +21521,8 @@ var ColumnManager = class {
|
|
|
21770
21521
|
* @returns {number} width of column
|
|
21771
21522
|
*/
|
|
21772
21523
|
getColumnWidth(columnPos) {
|
|
21773
|
-
var _this$_columnData$col2
|
|
21774
|
-
return (_this$_columnData$col2 =
|
|
21524
|
+
var _this$_columnData$col2;
|
|
21525
|
+
return ((_this$_columnData$col2 = this._columnData[columnPos]) === null || _this$_columnData$col2 === void 0 ? void 0 : _this$_columnData$col2.w) ?? this._config.defaultColumnWidth;
|
|
21775
21526
|
}
|
|
21776
21527
|
/**
|
|
21777
21528
|
* Set the width of column
|
|
@@ -21892,8 +21643,7 @@ var RowManager = class {
|
|
|
21892
21643
|
const rowData = {};
|
|
21893
21644
|
let index = 0;
|
|
21894
21645
|
for (let i = rowPos; i < rowPos + numRows; i++) {
|
|
21895
|
-
|
|
21896
|
-
rowData[index] = data !== null && data !== void 0 ? data : {
|
|
21646
|
+
rowData[index] = this.getRow(i) ?? {
|
|
21897
21647
|
h: this._config.defaultRowHeight,
|
|
21898
21648
|
hd: 0
|
|
21899
21649
|
};
|
|
@@ -22334,8 +22084,8 @@ var SheetViewModel = class extends Disposable {
|
|
|
22334
22084
|
return this.getRawCell(row, col);
|
|
22335
22085
|
}
|
|
22336
22086
|
getRowFiltered(row) {
|
|
22337
|
-
var _this$_rowFilteredInt
|
|
22338
|
-
return (_this$_rowFilteredInt =
|
|
22087
|
+
var _this$_rowFilteredInt;
|
|
22088
|
+
return ((_this$_rowFilteredInt = this._rowFilteredInterceptor) === null || _this$_rowFilteredInt === void 0 ? void 0 : _this$_rowFilteredInt.getRowFiltered(row)) ?? false;
|
|
22339
22089
|
}
|
|
22340
22090
|
registerCellContentInterceptor(interceptor) {
|
|
22341
22091
|
if (this._cellContentInterceptor) throw new Error("[SheetViewModel]: Interceptor already registered.");
|
|
@@ -22359,9 +22109,8 @@ const DEFAULT_CELL_DOCUMENT_MODEL_OPTION = {
|
|
|
22359
22109
|
/**
|
|
22360
22110
|
* The model of a Worksheet.
|
|
22361
22111
|
*/
|
|
22362
|
-
var Worksheet = class
|
|
22112
|
+
var Worksheet = class {
|
|
22363
22113
|
constructor(unitId, snapshot, _styles) {
|
|
22364
|
-
var _this$_snapshot$id;
|
|
22365
22114
|
this.unitId = unitId;
|
|
22366
22115
|
this._styles = _styles;
|
|
22367
22116
|
_defineProperty(this, "_sheetId", void 0);
|
|
@@ -22375,7 +22124,7 @@ var Worksheet = class Worksheet {
|
|
|
22375
22124
|
_defineProperty(this, "_getCellHeight", void 0);
|
|
22376
22125
|
this._snapshot = mergeWorksheetSnapshotWithDefault(snapshot);
|
|
22377
22126
|
const { columnData, rowData, cellData } = this._snapshot;
|
|
22378
|
-
this._sheetId =
|
|
22127
|
+
this._sheetId = this._snapshot.id ?? generateRandomId(6);
|
|
22379
22128
|
this._cellData = new ObjectMatrix(cellData);
|
|
22380
22129
|
this._viewModel = new SheetViewModel((row, col) => this.getCellRaw(row, col));
|
|
22381
22130
|
this._rowManager = new RowManager(this._snapshot, this._viewModel, rowData);
|
|
@@ -22492,7 +22241,7 @@ var Worksheet = class Worksheet {
|
|
|
22492
22241
|
const colStyle = this.getColumnStyle(col);
|
|
22493
22242
|
const cell = this.getCell(row, col);
|
|
22494
22243
|
const cellStyle = this._styles.getStyleByCell(cell);
|
|
22495
|
-
return
|
|
22244
|
+
return rowPriority ?? this._isRowStylePrecedeColumnStyle ? composeStyles(defaultStyle, colStyle, rowStyle, cell === null || cell === void 0 ? void 0 : cell.themeStyle, cellStyle) : composeStyles(defaultStyle, rowStyle, colStyle, cell === null || cell === void 0 ? void 0 : cell.themeStyle, cellStyle);
|
|
22496
22245
|
}
|
|
22497
22246
|
/**
|
|
22498
22247
|
* Get the composed style of the cell. If you want to get the style of the cell without merging row style,
|
|
@@ -22510,7 +22259,7 @@ var Worksheet = class Worksheet {
|
|
|
22510
22259
|
const rowStyle = this.getRowStyle(row);
|
|
22511
22260
|
const colStyle = this.getColumnStyle(col);
|
|
22512
22261
|
const cellStyle = this._styles.getStyleByCell(cellData);
|
|
22513
|
-
return
|
|
22262
|
+
return rowPriority ?? this._isRowStylePrecedeColumnStyle ? composeStyles(defaultStyle, colStyle, rowStyle, cellData === null || cellData === void 0 ? void 0 : cellData.themeStyle, cellStyle) : composeStyles(defaultStyle, rowStyle, colStyle, cellData === null || cellData === void 0 ? void 0 : cellData.themeStyle, cellStyle);
|
|
22514
22263
|
}
|
|
22515
22264
|
/**
|
|
22516
22265
|
* Get the composed style of the cell without its own style.
|
|
@@ -22628,16 +22377,6 @@ var Worksheet = class Worksheet {
|
|
|
22628
22377
|
return this._snapshot.name;
|
|
22629
22378
|
}
|
|
22630
22379
|
/**
|
|
22631
|
-
* Returns WorkSheet Clone Object
|
|
22632
|
-
* @returns WorkSheet Clone Object
|
|
22633
|
-
* @deprecated
|
|
22634
|
-
*/
|
|
22635
|
-
clone() {
|
|
22636
|
-
const { _snapshot: _config } = this;
|
|
22637
|
-
const copy = cloneWorksheetData(_config);
|
|
22638
|
-
return new Worksheet(this.unitId, copy, this._styles);
|
|
22639
|
-
}
|
|
22640
|
-
/**
|
|
22641
22380
|
* Get the merged cell list of the sheet.
|
|
22642
22381
|
* @returns {IRange[]} merged cell list
|
|
22643
22382
|
*/
|
|
@@ -23228,14 +22967,14 @@ var Worksheet = class Worksheet {
|
|
|
23228
22967
|
};
|
|
23229
22968
|
}
|
|
23230
22969
|
_updateConfigAndGetDocumentModel(documentData, horizontalAlign, paddingData, renderConfig) {
|
|
23231
|
-
var _documentData$body
|
|
22970
|
+
var _documentData$body;
|
|
23232
22971
|
if (!renderConfig) return;
|
|
23233
22972
|
if (!((_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream)) return;
|
|
23234
22973
|
if (!documentData.documentStyle) documentData.documentStyle = {};
|
|
23235
|
-
documentData.documentStyle.marginTop =
|
|
23236
|
-
documentData.documentStyle.marginBottom =
|
|
23237
|
-
documentData.documentStyle.marginLeft =
|
|
23238
|
-
documentData.documentStyle.marginRight =
|
|
22974
|
+
documentData.documentStyle.marginTop = paddingData.t ?? 0;
|
|
22975
|
+
documentData.documentStyle.marginBottom = paddingData.b ?? 2;
|
|
22976
|
+
documentData.documentStyle.marginLeft = paddingData.l ?? 2;
|
|
22977
|
+
documentData.documentStyle.marginRight = paddingData.r ?? 2;
|
|
23239
22978
|
documentData.documentStyle.pageSize = {
|
|
23240
22979
|
width: Number.POSITIVE_INFINITY,
|
|
23241
22980
|
height: Number.POSITIVE_INFINITY
|
|
@@ -23424,10 +23163,6 @@ let Workbook = class Workbook extends UnitModel {
|
|
|
23424
23163
|
getSnapshot() {
|
|
23425
23164
|
return this._snapshot;
|
|
23426
23165
|
}
|
|
23427
|
-
/** @deprecated use use name property instead */
|
|
23428
|
-
getName() {
|
|
23429
|
-
return this._snapshot.name;
|
|
23430
|
-
}
|
|
23431
23166
|
setName(name) {
|
|
23432
23167
|
this._name$.next(name);
|
|
23433
23168
|
this._snapshot.name = name;
|
|
@@ -23436,8 +23171,7 @@ let Workbook = class Workbook extends UnitModel {
|
|
|
23436
23171
|
return this._unitId;
|
|
23437
23172
|
}
|
|
23438
23173
|
getRev() {
|
|
23439
|
-
|
|
23440
|
-
return (_this$_snapshot$rev = this._snapshot.rev) !== null && _this$_snapshot$rev !== void 0 ? _this$_snapshot$rev : 1;
|
|
23174
|
+
return this._snapshot.rev ?? 1;
|
|
23441
23175
|
}
|
|
23442
23176
|
incrementRev() {
|
|
23443
23177
|
this._snapshot.rev = this.getRev() + 1;
|
|
@@ -23721,10 +23455,7 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23721
23455
|
return this._ctorByType.get(type);
|
|
23722
23456
|
}
|
|
23723
23457
|
getCurrentTypeOfUnit$(type) {
|
|
23724
|
-
return this.currentUnits$.pipe((0, rxjs.map)((units) =>
|
|
23725
|
-
var _units$get;
|
|
23726
|
-
return (_units$get = units.get(type)) !== null && _units$get !== void 0 ? _units$get : null;
|
|
23727
|
-
}), (0, rxjs.distinctUntilChanged)());
|
|
23458
|
+
return this.currentUnits$.pipe((0, rxjs.map)((units) => units.get(type) ?? null), (0, rxjs.distinctUntilChanged)());
|
|
23728
23459
|
}
|
|
23729
23460
|
getCurrentUnitOfType(type) {
|
|
23730
23461
|
return this._currentUnits.get(type);
|
|
@@ -23747,7 +23478,6 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23747
23478
|
* @param unit The unit to be added.
|
|
23748
23479
|
*/
|
|
23749
23480
|
__addUnit(unit, options) {
|
|
23750
|
-
var _options$makeCurrent;
|
|
23751
23481
|
this._logService.debug(`[UniverInstanceService]: Adding unit with id ${unit.getUnitId()}`);
|
|
23752
23482
|
const type = unit.type;
|
|
23753
23483
|
if (!this._unitsByType.has(type)) this._unitsByType.set(type, []);
|
|
@@ -23760,7 +23490,7 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23760
23490
|
unit,
|
|
23761
23491
|
options
|
|
23762
23492
|
});
|
|
23763
|
-
if ((
|
|
23493
|
+
if ((options === null || options === void 0 ? void 0 : options.makeCurrent) ?? true) this.setCurrentUnitForType(unit.getUnitId());
|
|
23764
23494
|
}
|
|
23765
23495
|
getTypeOfUnitDisposed$(type) {
|
|
23766
23496
|
return this.unitDisposed$.pipe((0, rxjs.filter)((unit) => unit.type === type));
|
|
@@ -23772,24 +23502,10 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23772
23502
|
return unit;
|
|
23773
23503
|
}
|
|
23774
23504
|
getUnitCreateOptions(unitId) {
|
|
23775
|
-
|
|
23776
|
-
return (_this$_unitCreateOpti = this._unitCreateOptions.get(unitId)) !== null && _this$_unitCreateOpti !== void 0 ? _this$_unitCreateOpti : null;
|
|
23777
|
-
}
|
|
23778
|
-
getUniverSheetInstance(unitId) {
|
|
23779
|
-
return this.getUnit(unitId, _univerjs_protocol.UniverType.UNIVER_SHEET);
|
|
23505
|
+
return this._unitCreateOptions.get(unitId) ?? null;
|
|
23780
23506
|
}
|
|
23781
23507
|
getAllUnitsForType(type) {
|
|
23782
|
-
|
|
23783
|
-
return (_this$_unitsByType$ge = this._unitsByType.get(type)) !== null && _this$_unitsByType$ge !== void 0 ? _this$_unitsByType$ge : [];
|
|
23784
|
-
}
|
|
23785
|
-
changeDoc(unitId, doc) {
|
|
23786
|
-
const allDocs = this.getAllUnitsForType(_univerjs_protocol.UniverType.UNIVER_DOC);
|
|
23787
|
-
const oldDoc = allDocs.find((doc) => doc.getUnitId() === unitId);
|
|
23788
|
-
if (oldDoc != null) {
|
|
23789
|
-
const index = allDocs.indexOf(oldDoc);
|
|
23790
|
-
allDocs.splice(index, 1);
|
|
23791
|
-
}
|
|
23792
|
-
this.__addUnit(doc);
|
|
23508
|
+
return this._unitsByType.get(type) ?? [];
|
|
23793
23509
|
}
|
|
23794
23510
|
get focused() {
|
|
23795
23511
|
var _this$_getUnitById2;
|
|
@@ -24098,16 +23814,15 @@ var LocaleService = class extends Disposable {
|
|
|
24098
23814
|
* @param locales - Locale object
|
|
24099
23815
|
*/
|
|
24100
23816
|
load(locales) {
|
|
24101
|
-
|
|
24102
|
-
this._locales = (0, lodash_es.merge)((_this$_locales = this._locales) !== null && _this$_locales !== void 0 ? _this$_locales : {}, locales);
|
|
23817
|
+
this._locales = (0, lodash_es.merge)(this._locales ?? {}, locales);
|
|
24103
23818
|
}
|
|
24104
23819
|
setLocale(locale) {
|
|
24105
23820
|
this._currentLocale$.next(locale);
|
|
24106
23821
|
this.localeChanged$.next();
|
|
24107
23822
|
}
|
|
24108
23823
|
getLocales() {
|
|
24109
|
-
var _this$
|
|
24110
|
-
return (_this$
|
|
23824
|
+
var _this$_locales;
|
|
23825
|
+
return (_this$_locales = this._locales) === null || _this$_locales === void 0 ? void 0 : _this$_locales[this._currentLocale];
|
|
24111
23826
|
}
|
|
24112
23827
|
getCurrentLocale() {
|
|
24113
23828
|
return this._currentLocale;
|
|
@@ -24834,12 +24549,12 @@ let LocalUndoRedoService = class LocalUndoRedoService extends Disposable {
|
|
|
24834
24549
|
if (isFocusSheet) if (isFocusFormulaEditor) unitID = DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
|
|
24835
24550
|
else if (isFocusEditor) unitID = DOCS_NORMAL_EDITOR_UNIT_ID_KEY;
|
|
24836
24551
|
else {
|
|
24837
|
-
var _this$_univerInstance
|
|
24838
|
-
unitID = (_this$_univerInstance =
|
|
24552
|
+
var _this$_univerInstance;
|
|
24553
|
+
unitID = ((_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId()) ?? "";
|
|
24839
24554
|
}
|
|
24840
24555
|
else {
|
|
24841
|
-
var _this$
|
|
24842
|
-
unitID = (
|
|
24556
|
+
var _this$_univerInstance2;
|
|
24557
|
+
unitID = ((_this$_univerInstance2 = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getUnitId()) ?? "";
|
|
24843
24558
|
}
|
|
24844
24559
|
return unitID;
|
|
24845
24560
|
}
|
|
@@ -25217,6 +24932,198 @@ function delayAnimationFrame(frames = 1) {
|
|
|
25217
24932
|
});
|
|
25218
24933
|
}
|
|
25219
24934
|
|
|
24935
|
+
//#endregion
|
|
24936
|
+
//#region src/sheets/clone.ts
|
|
24937
|
+
/**
|
|
24938
|
+
* Fast clone for primitive values and simple objects.
|
|
24939
|
+
* Avoids type checking overhead when we know the structure.
|
|
24940
|
+
*/
|
|
24941
|
+
function cloneValue(value) {
|
|
24942
|
+
if (value === null || value === void 0) return value;
|
|
24943
|
+
if (typeof value !== "object") return value;
|
|
24944
|
+
if (Array.isArray(value)) {
|
|
24945
|
+
const len = value.length;
|
|
24946
|
+
const result = new Array(len);
|
|
24947
|
+
for (let i = 0; i < len; i++) result[i] = cloneValue(value[i]);
|
|
24948
|
+
return result;
|
|
24949
|
+
}
|
|
24950
|
+
const result = {};
|
|
24951
|
+
const keys = Object.keys(value);
|
|
24952
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
24953
|
+
const key = keys[i];
|
|
24954
|
+
result[key] = cloneValue(value[key]);
|
|
24955
|
+
}
|
|
24956
|
+
return result;
|
|
24957
|
+
}
|
|
24958
|
+
/**
|
|
24959
|
+
* Fast clone for ICellData. Optimized for the known structure.
|
|
24960
|
+
* @param cell - The cell data to clone
|
|
24961
|
+
* @returns A deep clone of the cell data
|
|
24962
|
+
*/
|
|
24963
|
+
function cloneCellData(cell) {
|
|
24964
|
+
if (cell === null || cell === void 0) return cell;
|
|
24965
|
+
const result = {};
|
|
24966
|
+
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
24967
|
+
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
24968
|
+
else result.s = cloneValue(cell.s);
|
|
24969
|
+
if (cell.v !== void 0) result.v = cell.v;
|
|
24970
|
+
if (cell.t !== void 0) result.t = cell.t;
|
|
24971
|
+
if (cell.f !== void 0) result.f = cell.f;
|
|
24972
|
+
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
24973
|
+
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
24974
|
+
if (cell.si !== void 0) result.si = cell.si;
|
|
24975
|
+
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
24976
|
+
return result;
|
|
24977
|
+
}
|
|
24978
|
+
/**
|
|
24979
|
+
* Fast clone for ICellDataWithSpanAndDisplay. Optimized for the known structure.
|
|
24980
|
+
* This extends cloneCellData with additional span and display properties.
|
|
24981
|
+
* @param cell - The cell data with span and display info to clone
|
|
24982
|
+
* @returns A deep clone of the cell data
|
|
24983
|
+
*/
|
|
24984
|
+
function cloneCellDataWithSpanAndDisplay(cell) {
|
|
24985
|
+
if (cell === null || cell === void 0) return cell;
|
|
24986
|
+
const result = {};
|
|
24987
|
+
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
24988
|
+
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
24989
|
+
else result.s = cloneValue(cell.s);
|
|
24990
|
+
if (cell.v !== void 0) result.v = cell.v;
|
|
24991
|
+
if (cell.t !== void 0) result.t = cell.t;
|
|
24992
|
+
if (cell.f !== void 0) result.f = cell.f;
|
|
24993
|
+
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
24994
|
+
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
24995
|
+
if (cell.si !== void 0) result.si = cell.si;
|
|
24996
|
+
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
24997
|
+
if (cell.rowSpan !== void 0) result.rowSpan = cell.rowSpan;
|
|
24998
|
+
if (cell.colSpan !== void 0) result.colSpan = cell.colSpan;
|
|
24999
|
+
if (cell.displayV !== void 0) result.displayV = cell.displayV;
|
|
25000
|
+
return result;
|
|
25001
|
+
}
|
|
25002
|
+
/**
|
|
25003
|
+
* Fast clone for cell data matrix. Optimized for sparse matrix structure.
|
|
25004
|
+
* @param cellData - The cell data matrix to clone
|
|
25005
|
+
* @returns A deep clone of the cell data matrix
|
|
25006
|
+
*/
|
|
25007
|
+
function cloneCellDataMatrix(cellData) {
|
|
25008
|
+
const result = {};
|
|
25009
|
+
const rowKeys = Object.keys(cellData);
|
|
25010
|
+
for (let i = 0, rowLen = rowKeys.length; i < rowLen; i++) {
|
|
25011
|
+
const rowKey = rowKeys[i];
|
|
25012
|
+
const rowNum = Number(rowKey);
|
|
25013
|
+
const rowData = cellData[rowNum];
|
|
25014
|
+
if (rowData === void 0) continue;
|
|
25015
|
+
const clonedRow = {};
|
|
25016
|
+
const colKeys = Object.keys(rowData);
|
|
25017
|
+
for (let j = 0, colLen = colKeys.length; j < colLen; j++) {
|
|
25018
|
+
const colKey = colKeys[j];
|
|
25019
|
+
const colNum = Number(colKey);
|
|
25020
|
+
const cell = rowData[colNum];
|
|
25021
|
+
if (cell !== void 0 && cell !== null) clonedRow[colNum] = cloneCellData(cell);
|
|
25022
|
+
}
|
|
25023
|
+
result[rowNum] = clonedRow;
|
|
25024
|
+
}
|
|
25025
|
+
return result;
|
|
25026
|
+
}
|
|
25027
|
+
/**
|
|
25028
|
+
* Fast clone for row/column data arrays (sparse arrays stored as objects).
|
|
25029
|
+
* @param data - The row or column data to clone
|
|
25030
|
+
* @returns A deep clone of the row or column data
|
|
25031
|
+
*/
|
|
25032
|
+
function cloneRowColumnData(data) {
|
|
25033
|
+
const result = {};
|
|
25034
|
+
const keys = Object.keys(data);
|
|
25035
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
25036
|
+
const key = keys[i];
|
|
25037
|
+
const idx = Number(key);
|
|
25038
|
+
const item = data[idx];
|
|
25039
|
+
if (item === void 0) continue;
|
|
25040
|
+
const cloned = {};
|
|
25041
|
+
if ("h" in item && item.h !== void 0) cloned.h = item.h;
|
|
25042
|
+
if ("ia" in item && item.ia !== void 0) cloned.ia = item.ia;
|
|
25043
|
+
if ("ah" in item && item.ah !== void 0) cloned.ah = item.ah;
|
|
25044
|
+
if ("hd" in item && item.hd !== void 0) cloned.hd = item.hd;
|
|
25045
|
+
if ("w" in item && item.w !== void 0) cloned.w = item.w;
|
|
25046
|
+
if ("s" in item && item.s !== void 0) if (item.s === null || typeof item.s === "string") cloned.s = item.s;
|
|
25047
|
+
else cloned.s = cloneValue(item.s);
|
|
25048
|
+
if ("custom" in item && item.custom !== void 0) cloned.custom = item.custom === null ? null : cloneValue(item.custom);
|
|
25049
|
+
result[idx] = cloned;
|
|
25050
|
+
}
|
|
25051
|
+
return result;
|
|
25052
|
+
}
|
|
25053
|
+
/**
|
|
25054
|
+
* Fast clone for IRange array (merge data).
|
|
25055
|
+
* @param ranges - The array of ranges to clone
|
|
25056
|
+
* @returns A shallow clone of the ranges (IRange contains only primitive values)
|
|
25057
|
+
*/
|
|
25058
|
+
function cloneMergeData(ranges) {
|
|
25059
|
+
const len = ranges.length;
|
|
25060
|
+
const result = new Array(len);
|
|
25061
|
+
for (let i = 0; i < len; i++) {
|
|
25062
|
+
const range = ranges[i];
|
|
25063
|
+
result[i] = {
|
|
25064
|
+
startRow: range.startRow,
|
|
25065
|
+
startColumn: range.startColumn,
|
|
25066
|
+
endRow: range.endRow,
|
|
25067
|
+
endColumn: range.endColumn,
|
|
25068
|
+
rangeType: range.rangeType,
|
|
25069
|
+
startAbsoluteRefType: range.startAbsoluteRefType,
|
|
25070
|
+
endAbsoluteRefType: range.endAbsoluteRefType
|
|
25071
|
+
};
|
|
25072
|
+
}
|
|
25073
|
+
return result;
|
|
25074
|
+
}
|
|
25075
|
+
/**
|
|
25076
|
+
* Optimized deep clone specifically for IWorksheetData.
|
|
25077
|
+
* This is significantly faster than generic deepClone because:
|
|
25078
|
+
* 1. No recursive type checking - we know the structure
|
|
25079
|
+
* 2. Direct property access instead of Object.keys iteration for known properties
|
|
25080
|
+
* 3. Specialized handlers for cellData matrix (the largest data)
|
|
25081
|
+
* 4. Primitive values copied directly without cloning
|
|
25082
|
+
*
|
|
25083
|
+
* @param worksheet - The worksheet data to clone
|
|
25084
|
+
* @returns A deep clone of the worksheet data
|
|
25085
|
+
*/
|
|
25086
|
+
function cloneWorksheetData(worksheet) {
|
|
25087
|
+
const result = {
|
|
25088
|
+
id: worksheet.id,
|
|
25089
|
+
name: worksheet.name,
|
|
25090
|
+
tabColor: worksheet.tabColor,
|
|
25091
|
+
hidden: worksheet.hidden,
|
|
25092
|
+
rowCount: worksheet.rowCount,
|
|
25093
|
+
columnCount: worksheet.columnCount,
|
|
25094
|
+
zoomRatio: worksheet.zoomRatio,
|
|
25095
|
+
scrollTop: worksheet.scrollTop,
|
|
25096
|
+
scrollLeft: worksheet.scrollLeft,
|
|
25097
|
+
defaultColumnWidth: worksheet.defaultColumnWidth,
|
|
25098
|
+
defaultRowHeight: worksheet.defaultRowHeight,
|
|
25099
|
+
showGridlines: worksheet.showGridlines,
|
|
25100
|
+
rightToLeft: worksheet.rightToLeft,
|
|
25101
|
+
freeze: {
|
|
25102
|
+
xSplit: worksheet.freeze.xSplit,
|
|
25103
|
+
ySplit: worksheet.freeze.ySplit,
|
|
25104
|
+
startRow: worksheet.freeze.startRow,
|
|
25105
|
+
startColumn: worksheet.freeze.startColumn
|
|
25106
|
+
},
|
|
25107
|
+
rowHeader: {
|
|
25108
|
+
width: worksheet.rowHeader.width,
|
|
25109
|
+
hidden: worksheet.rowHeader.hidden
|
|
25110
|
+
},
|
|
25111
|
+
columnHeader: {
|
|
25112
|
+
height: worksheet.columnHeader.height,
|
|
25113
|
+
hidden: worksheet.columnHeader.hidden
|
|
25114
|
+
},
|
|
25115
|
+
mergeData: cloneMergeData(worksheet.mergeData),
|
|
25116
|
+
cellData: cloneCellDataMatrix(worksheet.cellData),
|
|
25117
|
+
rowData: cloneRowColumnData(worksheet.rowData),
|
|
25118
|
+
columnData: cloneRowColumnData(worksheet.columnData)
|
|
25119
|
+
};
|
|
25120
|
+
if (worksheet.gridlinesColor !== void 0) result.gridlinesColor = worksheet.gridlinesColor;
|
|
25121
|
+
if (worksheet.defaultStyle !== void 0) if (worksheet.defaultStyle === null || typeof worksheet.defaultStyle === "string") result.defaultStyle = worksheet.defaultStyle;
|
|
25122
|
+
else result.defaultStyle = cloneValue(worksheet.defaultStyle);
|
|
25123
|
+
if (worksheet.custom !== void 0) result.custom = worksheet.custom === null ? null : cloneValue(worksheet.custom);
|
|
25124
|
+
return result;
|
|
25125
|
+
}
|
|
25126
|
+
|
|
25220
25127
|
//#endregion
|
|
25221
25128
|
//#region src/skeleton.ts
|
|
25222
25129
|
let Skeleton = class Skeleton extends Disposable {
|
|
@@ -25323,18 +25230,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25323
25230
|
this.initConfig();
|
|
25324
25231
|
}
|
|
25325
25232
|
initConfig() {
|
|
25326
|
-
|
|
25327
|
-
this.
|
|
25328
|
-
this.worksheet.setIsRowStylePrecedeColumnStyle((_this$_configService$2 = this._configService.getConfig("isRowStylePrecedeColumnStyle")) !== null && _this$_configService$2 !== void 0 ? _this$_configService$2 : false);
|
|
25233
|
+
this._skipAutoHeightForMergedCells = !(this._configService.getConfig(AUTO_HEIGHT_FOR_MERGED_CELLS) ?? false);
|
|
25234
|
+
this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig("isRowStylePrecedeColumnStyle") ?? false);
|
|
25329
25235
|
}
|
|
25330
25236
|
resetCache() {}
|
|
25331
25237
|
/**
|
|
25332
|
-
* @deprecated should never expose a property that is provided by another module!
|
|
25333
|
-
*/
|
|
25334
|
-
getWorksheetConfig() {
|
|
25335
|
-
return this._worksheetData;
|
|
25336
|
-
}
|
|
25337
|
-
/**
|
|
25338
25238
|
* Get which Workbook and Worksheet this skeleton is attached to.
|
|
25339
25239
|
* @returns [unitId, sheetId]
|
|
25340
25240
|
*/
|
|
@@ -25417,28 +25317,27 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25417
25317
|
this._updateLayout();
|
|
25418
25318
|
}
|
|
25419
25319
|
_fillDefaultGapThemeColors(config) {
|
|
25420
|
-
var _config$defaultBackgr, _config$defaultStripe;
|
|
25421
25320
|
if (config.defaultBackgroundColor && config.defaultStripeColor) return config;
|
|
25422
25321
|
const { r, g, b } = new ColorKit(this._injector.get(ThemeService).getColorFromTheme("primary.500")).toRgb();
|
|
25423
25322
|
return {
|
|
25424
25323
|
...config,
|
|
25425
|
-
defaultBackgroundColor:
|
|
25426
|
-
defaultStripeColor:
|
|
25324
|
+
defaultBackgroundColor: config.defaultBackgroundColor ?? `rgba(${r}, ${g}, ${b}, 0.025)`,
|
|
25325
|
+
defaultStripeColor: config.defaultStripeColor ?? `rgba(${r}, ${g}, ${b}, 0.08)`
|
|
25427
25326
|
};
|
|
25428
25327
|
}
|
|
25429
25328
|
/**
|
|
25430
25329
|
* Get the gap size (in px) BEFORE the given row.
|
|
25431
25330
|
*/
|
|
25432
25331
|
getRowGapSize(row) {
|
|
25433
|
-
var _this$_gapConfig$rowG
|
|
25434
|
-
return (_this$_gapConfig$rowG =
|
|
25332
|
+
var _this$_gapConfig$rowG;
|
|
25333
|
+
return ((_this$_gapConfig$rowG = this._gapConfig.rowGaps) === null || _this$_gapConfig$rowG === void 0 || (_this$_gapConfig$rowG = _this$_gapConfig$rowG[row]) === null || _this$_gapConfig$rowG === void 0 ? void 0 : _this$_gapConfig$rowG.size) ?? 0;
|
|
25435
25334
|
}
|
|
25436
25335
|
/**
|
|
25437
25336
|
* Get the gap size (in px) BEFORE the given column.
|
|
25438
25337
|
*/
|
|
25439
25338
|
getColGapSize(col) {
|
|
25440
|
-
var _this$_gapConfig$colG
|
|
25441
|
-
return (_this$_gapConfig$colG =
|
|
25339
|
+
var _this$_gapConfig$colG;
|
|
25340
|
+
return ((_this$_gapConfig$colG = this._gapConfig.colGaps) === null || _this$_gapConfig$colG === void 0 || (_this$_gapConfig$colG = _this$_gapConfig$colG[col]) === null || _this$_gapConfig$colG === void 0 ? void 0 : _this$_gapConfig$colG.size) ?? 0;
|
|
25442
25341
|
}
|
|
25443
25342
|
/**
|
|
25444
25343
|
* Returns a gap size getter object for use with coordinate utility functions.
|
|
@@ -25458,11 +25357,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25458
25357
|
const { rowGaps } = this._gapConfig;
|
|
25459
25358
|
if (!rowGaps) return -1;
|
|
25460
25359
|
for (const rowStr of Object.keys(rowGaps)) {
|
|
25461
|
-
var _rowGaps$row
|
|
25360
|
+
var _rowGaps$row;
|
|
25462
25361
|
const row = Number(rowStr);
|
|
25463
|
-
const gapSize = (
|
|
25362
|
+
const gapSize = ((_rowGaps$row = rowGaps[row]) === null || _rowGaps$row === void 0 ? void 0 : _rowGaps$row.size) ?? 0;
|
|
25464
25363
|
if (gapSize <= 0) continue;
|
|
25465
|
-
const gapStart =
|
|
25364
|
+
const gapStart = this._rowHeightAccumulation[row - 1] ?? 0;
|
|
25466
25365
|
const gapEnd = gapStart + gapSize;
|
|
25467
25366
|
if (y >= gapStart && y < gapEnd) return row;
|
|
25468
25367
|
}
|
|
@@ -25476,11 +25375,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25476
25375
|
const { colGaps } = this._gapConfig;
|
|
25477
25376
|
if (!colGaps) return -1;
|
|
25478
25377
|
for (const colStr of Object.keys(colGaps)) {
|
|
25479
|
-
var _colGaps$col
|
|
25378
|
+
var _colGaps$col;
|
|
25480
25379
|
const col = Number(colStr);
|
|
25481
|
-
const gapSize = (
|
|
25380
|
+
const gapSize = ((_colGaps$col = colGaps[col]) === null || _colGaps$col === void 0 ? void 0 : _colGaps$col.size) ?? 0;
|
|
25482
25381
|
if (gapSize <= 0) continue;
|
|
25483
|
-
const gapStart =
|
|
25382
|
+
const gapStart = this._columnWidthAccumulation[col - 1] ?? 0;
|
|
25484
25383
|
const gapEnd = gapStart + gapSize;
|
|
25485
25384
|
if (x >= gapStart && x < gapEnd) return col;
|
|
25486
25385
|
}
|
|
@@ -25491,7 +25390,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25491
25390
|
const rowHeightAccumulation = [];
|
|
25492
25391
|
const data = rowData;
|
|
25493
25392
|
for (let r = 0; r < rowCount; r++) {
|
|
25494
|
-
var _this$_gapConfig$
|
|
25393
|
+
var _this$_gapConfig$rowG2;
|
|
25495
25394
|
let rowHeight = defaultRowHeight;
|
|
25496
25395
|
if (this.worksheet.getRowFiltered(r)) rowHeight = 0;
|
|
25497
25396
|
else if (data[r] != null) {
|
|
@@ -25502,7 +25401,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25502
25401
|
else rowHeight = h;
|
|
25503
25402
|
if (rowDataItem.hd === 1) rowHeight = 0;
|
|
25504
25403
|
}
|
|
25505
|
-
const gapSize = (
|
|
25404
|
+
const gapSize = ((_this$_gapConfig$rowG2 = this._gapConfig.rowGaps) === null || _this$_gapConfig$rowG2 === void 0 || (_this$_gapConfig$rowG2 = _this$_gapConfig$rowG2[r]) === null || _this$_gapConfig$rowG2 === void 0 ? void 0 : _this$_gapConfig$rowG2.size) ?? 0;
|
|
25506
25405
|
rowTotalHeight += gapSize;
|
|
25507
25406
|
rowTotalHeight += rowHeight;
|
|
25508
25407
|
rowHeightAccumulation.push(rowTotalHeight);
|
|
@@ -25520,7 +25419,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25520
25419
|
const columnWidthAccumulation = [];
|
|
25521
25420
|
const data = columnData;
|
|
25522
25421
|
for (let c = 0; c < colCount; c++) {
|
|
25523
|
-
var _this$_gapConfig$
|
|
25422
|
+
var _this$_gapConfig$colG2;
|
|
25524
25423
|
let columnWidth = defaultColumnWidth;
|
|
25525
25424
|
if (data[c] != null) {
|
|
25526
25425
|
const columnDataItem = data[c];
|
|
@@ -25528,7 +25427,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25528
25427
|
if (columnDataItem.w != null) columnWidth = columnDataItem.w;
|
|
25529
25428
|
if (columnDataItem.hd === 1) columnWidth = 0;
|
|
25530
25429
|
}
|
|
25531
|
-
const gapSize = (
|
|
25430
|
+
const gapSize = ((_this$_gapConfig$colG2 = this._gapConfig.colGaps) === null || _this$_gapConfig$colG2 === void 0 || (_this$_gapConfig$colG2 = _this$_gapConfig$colG2[c]) === null || _this$_gapConfig$colG2 === void 0 ? void 0 : _this$_gapConfig$colG2.size) ?? 0;
|
|
25532
25431
|
columnTotalWidth += gapSize;
|
|
25533
25432
|
columnTotalWidth += columnWidth;
|
|
25534
25433
|
columnWidthAccumulation.push(columnTotalWidth);
|
|
@@ -25714,8 +25613,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25714
25613
|
offsetY = getTransformOffsetY(offsetY, scaleY, scrollXY, this.columnHeaderHeightAndMarginTop);
|
|
25715
25614
|
let row = searchArray(rowHeightAccumulation, offsetY, options === null || options === void 0 ? void 0 : options.firstMatch);
|
|
25716
25615
|
if (options === null || options === void 0 ? void 0 : options.closeFirst) {
|
|
25717
|
-
|
|
25718
|
-
if (Math.abs(rowHeightAccumulation[row] - offsetY) < Math.abs(offsetY - ((_rowHeightAccumulatio = rowHeightAccumulation[row - 1]) !== null && _rowHeightAccumulatio !== void 0 ? _rowHeightAccumulatio : 0))) row = row + 1;
|
|
25616
|
+
if (Math.abs(rowHeightAccumulation[row] - offsetY) < Math.abs(offsetY - (rowHeightAccumulation[row - 1] ?? 0))) row = row + 1;
|
|
25719
25617
|
}
|
|
25720
25618
|
return row;
|
|
25721
25619
|
}
|
|
@@ -25727,8 +25625,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25727
25625
|
const { columnWidthAccumulation } = this;
|
|
25728
25626
|
let column = searchArray(columnWidthAccumulation, offsetX, options === null || options === void 0 ? void 0 : options.firstMatch);
|
|
25729
25627
|
if (options === null || options === void 0 ? void 0 : options.closeFirst) {
|
|
25730
|
-
|
|
25731
|
-
if (Math.abs(columnWidthAccumulation[column] - offsetX) < Math.abs(offsetX - ((_columnWidthAccumulat = columnWidthAccumulation[column - 1]) !== null && _columnWidthAccumulat !== void 0 ? _columnWidthAccumulat : 0))) column = column + 1;
|
|
25628
|
+
if (Math.abs(columnWidthAccumulation[column] - offsetX) < Math.abs(offsetX - (columnWidthAccumulation[column - 1] ?? 0))) column = column + 1;
|
|
25732
25629
|
}
|
|
25733
25630
|
return column;
|
|
25734
25631
|
}
|
|
@@ -25863,14 +25760,14 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25863
25760
|
};
|
|
25864
25761
|
}
|
|
25865
25762
|
_updateConfigAndGetDocumentModel(documentData, horizontalAlign, paddingData, renderConfig) {
|
|
25866
|
-
var _documentData$body
|
|
25763
|
+
var _documentData$body;
|
|
25867
25764
|
if (!renderConfig) return;
|
|
25868
25765
|
if (!((_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream)) return;
|
|
25869
25766
|
if (!documentData.documentStyle) documentData.documentStyle = {};
|
|
25870
|
-
documentData.documentStyle.marginTop =
|
|
25871
|
-
documentData.documentStyle.marginBottom =
|
|
25872
|
-
documentData.documentStyle.marginLeft =
|
|
25873
|
-
documentData.documentStyle.marginRight =
|
|
25767
|
+
documentData.documentStyle.marginTop = paddingData.t ?? 0;
|
|
25768
|
+
documentData.documentStyle.marginBottom = paddingData.b ?? 2;
|
|
25769
|
+
documentData.documentStyle.marginLeft = paddingData.l ?? 2;
|
|
25770
|
+
documentData.documentStyle.marginRight = paddingData.r ?? 2;
|
|
25874
25771
|
documentData.documentStyle.pageSize = {
|
|
25875
25772
|
width: Number.POSITIVE_INFINITY,
|
|
25876
25773
|
height: Number.POSITIVE_INFINITY
|
|
@@ -25945,10 +25842,9 @@ function getCellCoordByIndexSimple(row, column, rowHeightAccumulation, columnWid
|
|
|
25945
25842
|
* @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
|
|
25946
25843
|
*/
|
|
25947
25844
|
function getCellWithCoordByIndexCore(row, column, rowHeightAccumulation, columnWidthAccumulation, mergeDataInfo, gapSizeGetter) {
|
|
25948
|
-
var _gapSizeGetter$row, _gapSizeGetter$col;
|
|
25949
25845
|
row = Tools.clamp(row, 0, rowHeightAccumulation.length - 1);
|
|
25950
25846
|
column = Tools.clamp(column, 0, columnWidthAccumulation.length - 1);
|
|
25951
|
-
let { startY, endY, startX, endX } = getCellCoordByIndexSimple(row, column, rowHeightAccumulation, columnWidthAccumulation, (
|
|
25847
|
+
let { startY, endY, startX, endX } = getCellCoordByIndexSimple(row, column, rowHeightAccumulation, columnWidthAccumulation, (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.row(row)) ?? 0, (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.col(column)) ?? 0);
|
|
25952
25848
|
if (!mergeDataInfo) return {
|
|
25953
25849
|
startY,
|
|
25954
25850
|
endY,
|
|
@@ -25983,9 +25879,8 @@ function getCellWithCoordByIndexCore(row, column, rowHeightAccumulation, columnW
|
|
|
25983
25879
|
const rowAccumulationCount = rowHeightAccumulation.length - 1;
|
|
25984
25880
|
const columnAccumulationCount = columnWidthAccumulation.length - 1;
|
|
25985
25881
|
if (isMerged && startRow !== -1 && startColumn !== -1) {
|
|
25986
|
-
|
|
25987
|
-
const
|
|
25988
|
-
const mergeColGapSize = (_gapSizeGetter$col2 = gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.col(startColumn)) !== null && _gapSizeGetter$col2 !== void 0 ? _gapSizeGetter$col2 : 0;
|
|
25882
|
+
const mergeRowGapSize = (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.row(startRow)) ?? 0;
|
|
25883
|
+
const mergeColGapSize = (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.col(startColumn)) ?? 0;
|
|
25989
25884
|
const mergeStartY = (rowHeightAccumulation[startRow - 1] || 0) + mergeRowGapSize;
|
|
25990
25885
|
const mergeEndY = rowHeightAccumulation[endRow] || rowHeightAccumulation[rowAccumulationCount];
|
|
25991
25886
|
const mergeStartX = (columnWidthAccumulation[startColumn - 1] || 0) + mergeColGapSize;
|
|
@@ -26440,13 +26335,12 @@ var Univer = class {
|
|
|
26440
26335
|
this._univerInstanceService.registerCtorForType(_univerjs_protocol.UniverType.UNIVER_SLIDE, SlideDataModel);
|
|
26441
26336
|
const univerInstanceService = injector.get(IUniverInstanceService);
|
|
26442
26337
|
univerInstanceService.__setCreateHandler((type, data, ctor, options) => {
|
|
26443
|
-
var _univerInstanceServic;
|
|
26444
26338
|
const isFirstTime = !this._startedTypes.has(type);
|
|
26445
26339
|
if (isFirstTime) {
|
|
26446
26340
|
this._pluginService.startPluginsForType(type);
|
|
26447
26341
|
this._startedTypes.add(type);
|
|
26448
26342
|
}
|
|
26449
|
-
const actualCtor =
|
|
26343
|
+
const actualCtor = univerInstanceService.__getCtorByType(type) ?? ctor;
|
|
26450
26344
|
if (!actualCtor) throw new Error(`[Univer]: No constructor registered for unit type ${type}.`);
|
|
26451
26345
|
const model = injector.createInstance(actualCtor, data);
|
|
26452
26346
|
univerInstanceService.__addUnit(model, options);
|
|
@@ -26549,12 +26443,19 @@ Object.defineProperty(exports, 'AuthzIoLocalService', {
|
|
|
26549
26443
|
}
|
|
26550
26444
|
});
|
|
26551
26445
|
exports.AutoFillSeries = AutoFillSeries;
|
|
26446
|
+
exports.BASE_RECORD_ID_FIELD_ID = BASE_RECORD_ID_FIELD_ID;
|
|
26447
|
+
exports.BASE_RECORD_ID_FIELD_NAME = BASE_RECORD_ID_FIELD_NAME;
|
|
26552
26448
|
exports.BORDER_KEYS = BORDER_KEYS;
|
|
26553
26449
|
exports.BORDER_STYLE_KEYS = BORDER_STYLE_KEYS;
|
|
26450
|
+
exports.BaseConditionalColorOperator = BaseConditionalColorOperator;
|
|
26451
|
+
exports.BaseConditionalColorTarget = BaseConditionalColorTarget;
|
|
26452
|
+
exports.BaseConditionalDateMode = BaseConditionalDateMode;
|
|
26554
26453
|
exports.BaseDataModel = BaseDataModel;
|
|
26555
26454
|
exports.BaseFieldType = BaseFieldType;
|
|
26556
26455
|
exports.BaseFilterConjunction = BaseFilterConjunction;
|
|
26557
26456
|
exports.BaseFilterOperator = BaseFilterOperator;
|
|
26457
|
+
exports.BaseHierarchyInvalidReason = BaseHierarchyInvalidReason;
|
|
26458
|
+
exports.BaseRecordLinkRole = BaseRecordLinkRole;
|
|
26558
26459
|
exports.BaseSortDirection = BaseSortDirection;
|
|
26559
26460
|
exports.BaseViewType = BaseViewType;
|
|
26560
26461
|
exports.BaselineOffset = BaselineOffset;
|
|
@@ -26642,6 +26543,7 @@ exports.DocumentBlockRangeType = DocumentBlockRangeType;
|
|
|
26642
26543
|
exports.DocumentBlockType = DocumentBlockType;
|
|
26643
26544
|
exports.DocumentDataModel = DocumentDataModel;
|
|
26644
26545
|
exports.DocumentFlavor = DocumentFlavor;
|
|
26546
|
+
exports.DocxBreakType = DocxBreakType;
|
|
26645
26547
|
exports.DrawingTypeEnum = DrawingTypeEnum;
|
|
26646
26548
|
exports.EDITOR_ACTIVATED = EDITOR_ACTIVATED;
|
|
26647
26549
|
exports.EXTENSION_NAMES = EXTENSION_NAMES;
|
|
@@ -26652,7 +26554,6 @@ exports.FOCUSING_BOARD = FOCUSING_BOARD;
|
|
|
26652
26554
|
exports.FOCUSING_COMMENT_EDITOR = FOCUSING_COMMENT_EDITOR;
|
|
26653
26555
|
exports.FOCUSING_COMMON_DRAWINGS = FOCUSING_COMMON_DRAWINGS;
|
|
26654
26556
|
exports.FOCUSING_DOC = FOCUSING_DOC;
|
|
26655
|
-
exports.FOCUSING_EDITOR_BUT_HIDDEN = FOCUSING_EDITOR_BUT_HIDDEN;
|
|
26656
26557
|
exports.FOCUSING_EDITOR_INPUT_FORMULA = FOCUSING_EDITOR_INPUT_FORMULA;
|
|
26657
26558
|
exports.FOCUSING_EDITOR_STANDALONE = FOCUSING_EDITOR_STANDALONE;
|
|
26658
26559
|
exports.FOCUSING_FX_BAR_EDITOR = FOCUSING_FX_BAR_EDITOR;
|
|
@@ -26885,6 +26786,7 @@ exports.Styles = Styles;
|
|
|
26885
26786
|
exports.TEXT_DECORATION_KEYS = TEXT_DECORATION_KEYS;
|
|
26886
26787
|
exports.TEXT_ROTATION_KEYS = TEXT_ROTATION_KEYS;
|
|
26887
26788
|
exports.THEME_COLORS = THEME_COLORS;
|
|
26789
|
+
exports.TRADITIONAL_DOCUMENT_DEFAULT_MARGIN = TRADITIONAL_DOCUMENT_DEFAULT_MARGIN;
|
|
26888
26790
|
exports.TabStopAlignment = TabStopAlignment;
|
|
26889
26791
|
exports.TableAlignmentType = TableAlignmentType;
|
|
26890
26792
|
exports.TableLayoutType = TableLayoutType;
|
|
@@ -26937,6 +26839,7 @@ exports.WrapTextType = WrapTextType;
|
|
|
26937
26839
|
exports.addLinkToDocumentModel = addLinkToDocumentModel;
|
|
26938
26840
|
exports.afterInitApply = afterInitApply;
|
|
26939
26841
|
exports.afterTime = afterTime;
|
|
26842
|
+
exports.assertBaseTableRecordIdentity = assertBaseTableRecordIdentity;
|
|
26940
26843
|
exports.awaitTime = awaitTime;
|
|
26941
26844
|
exports.binSearchFirstGreaterThanTarget = binSearchFirstGreaterThanTarget;
|
|
26942
26845
|
exports.binarySearchArray = binarySearchArray;
|
|
@@ -26969,6 +26872,7 @@ exports.convertObservableToBehaviorSubject = convertObservableToBehaviorSubject;
|
|
|
26969
26872
|
exports.covertCellValue = covertCellValue;
|
|
26970
26873
|
exports.covertCellValues = covertCellValues;
|
|
26971
26874
|
exports.createAsyncInterceptorKey = createAsyncInterceptorKey;
|
|
26875
|
+
exports.createBaseRecordIdField = createBaseRecordIdField;
|
|
26972
26876
|
exports.createDefaultBaseTableSnapshot = createDefaultBaseTableSnapshot;
|
|
26973
26877
|
exports.createDefaultUser = createDefaultUser;
|
|
26974
26878
|
exports.createDocumentModelWithStyle = createDocumentModelWithStyle;
|
|
@@ -27024,7 +26928,6 @@ exports.getBodySliceForSplitTextXAction = getBodySliceForSplitTextXAction;
|
|
|
27024
26928
|
exports.getBodySliceForTextXAction = getBodySliceForTextXAction;
|
|
27025
26929
|
exports.getBorderStyleType = getBorderStyleType;
|
|
27026
26930
|
exports.getCellCoordByIndexSimple = getCellCoordByIndexSimple;
|
|
27027
|
-
exports.getCellInfoInMergeData = getCellInfoInMergeData;
|
|
27028
26931
|
exports.getCellValueType = getCellValueType;
|
|
27029
26932
|
exports.getCellWithCoordByIndexCore = getCellWithCoordByIndexCore;
|
|
27030
26933
|
exports.getColorStyle = getColorStyle;
|
|
@@ -27084,6 +26987,7 @@ Object.defineProperty(exports, 'isAsyncHook', {
|
|
|
27084
26987
|
return _wendellhu_redi.isAsyncHook;
|
|
27085
26988
|
}
|
|
27086
26989
|
});
|
|
26990
|
+
exports.isBaseRecordIdFieldName = isBaseRecordIdFieldName;
|
|
27087
26991
|
exports.isBlackColor = isBlackColor;
|
|
27088
26992
|
exports.isBooleanString = isBooleanString;
|
|
27089
26993
|
exports.isCellCoverable = isCellCoverable;
|
|
@@ -27131,6 +27035,7 @@ exports.isSafeUrl = isSafeUrl;
|
|
|
27131
27035
|
exports.isSameStyleTextRun = isSameStyleTextRun;
|
|
27132
27036
|
exports.isTextFormat = isTextFormat;
|
|
27133
27037
|
exports.isUnitRangesEqual = isUnitRangesEqual;
|
|
27038
|
+
exports.isValidBaseRecordId = isValidBaseRecordId;
|
|
27134
27039
|
exports.isValidRange = isValidRange;
|
|
27135
27040
|
Object.defineProperty(exports, 'isValueDependencyItem', {
|
|
27136
27041
|
enumerable: true,
|
|
@@ -27141,8 +27046,6 @@ Object.defineProperty(exports, 'isValueDependencyItem', {
|
|
|
27141
27046
|
exports.isWhiteColor = isWhiteColor;
|
|
27142
27047
|
exports.makeArray = makeArray;
|
|
27143
27048
|
exports.makeCellRangeToRangeData = makeCellRangeToRangeData;
|
|
27144
|
-
exports.makeCellToSelection = makeCellToSelection;
|
|
27145
|
-
exports.makeCustomRangeStream = makeCustomRangeStream;
|
|
27146
27049
|
exports.mapObjectMatrix = mapObjectMatrix;
|
|
27147
27050
|
Object.defineProperty(exports, 'merge', {
|
|
27148
27051
|
enumerable: true,
|