@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/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BehaviorSubject, Observable, ReplaySubject, Subject, Subscription, combineLatest, debounceTime, distinctUntilChanged, filter, firstValueFrom, map, merge as merge$1, of, skip, take, takeWhile, tap, timer } from "rxjs";
|
|
2
2
|
import { ObjectScope, UnitRole, UniverType as UniverInstanceType } from "@univerjs/protocol";
|
|
3
3
|
import { debounceTime as debounceTime$1, filter as filter$1, first, map as map$1 } from "rxjs/operators";
|
|
4
|
-
import { Inject,
|
|
4
|
+
import { Inject, InjectSelf, Injector, LookUp, Many, Optional, Quantity, RediError, Self, SkipSelf, WithNew, createIdentifier, forwardRef, isAsyncDependencyItem, isAsyncHook, isClassDependencyItem, isCtor, isDisposable, isFactoryDependencyItem, isValueDependencyItem, setDependencies } from "@wendellhu/redi";
|
|
5
5
|
import { debounce, get, merge, mergeWith, set } from "lodash-es";
|
|
6
6
|
import RBush, { default as RBush$1 } from "rbush";
|
|
7
7
|
import AsyncLock from "async-lock";
|
|
@@ -123,7 +123,7 @@ function installShims() {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
//#endregion
|
|
126
|
-
//#region \0@oxc-project+runtime@0.
|
|
126
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
127
127
|
function _typeof(o) {
|
|
128
128
|
"@babel/helpers - typeof";
|
|
129
129
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -134,7 +134,7 @@ function _typeof(o) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
//#endregion
|
|
137
|
-
//#region \0@oxc-project+runtime@0.
|
|
137
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
138
138
|
function toPrimitive(t, r) {
|
|
139
139
|
if ("object" != _typeof(t) || !t) return t;
|
|
140
140
|
var e = t[Symbol.toPrimitive];
|
|
@@ -147,14 +147,14 @@ function toPrimitive(t, r) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
//#endregion
|
|
150
|
-
//#region \0@oxc-project+runtime@0.
|
|
150
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
151
151
|
function toPropertyKey(t) {
|
|
152
152
|
var i = toPrimitive(t, "string");
|
|
153
153
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
//#endregion
|
|
157
|
-
//#region \0@oxc-project+runtime@0.
|
|
157
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
158
158
|
function _defineProperty(e, r, t) {
|
|
159
159
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
160
160
|
value: t,
|
|
@@ -683,76 +683,6 @@ var Tools = class Tools {
|
|
|
683
683
|
if (isIE11) return "IE11";
|
|
684
684
|
return "Unknown browser";
|
|
685
685
|
}
|
|
686
|
-
/** @deprecated This method is deprecated, please use `import { merge } from '@univerjs/core` instead */
|
|
687
|
-
static deepMerge(target, ...sources) {
|
|
688
|
-
sources.forEach((item) => item && deepItem(item));
|
|
689
|
-
function isDangerousKey(key) {
|
|
690
|
-
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
691
|
-
}
|
|
692
|
-
function deepArray(array, to) {
|
|
693
|
-
array.forEach((value, key) => {
|
|
694
|
-
if (typeof key === "string" && isDangerousKey(key)) return;
|
|
695
|
-
if (Tools.isArray(value)) {
|
|
696
|
-
var _to$key;
|
|
697
|
-
const origin = (_to$key = to[key]) !== null && _to$key !== void 0 ? _to$key : [];
|
|
698
|
-
to[key] = origin;
|
|
699
|
-
deepArray(value, origin);
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
if (Tools.isObject(value)) {
|
|
703
|
-
var _to$key2;
|
|
704
|
-
const origin = (_to$key2 = to[key]) !== null && _to$key2 !== void 0 ? _to$key2 : {};
|
|
705
|
-
to[key] = origin;
|
|
706
|
-
deepObject(value, origin);
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
to[key] = value;
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
function deepObject(object, to) {
|
|
713
|
-
Object.keys(object).forEach((key) => {
|
|
714
|
-
if (isDangerousKey(key)) return;
|
|
715
|
-
const value = object[key];
|
|
716
|
-
if (Tools.isObject(value)) {
|
|
717
|
-
var _to$key3;
|
|
718
|
-
const origin = (_to$key3 = to[key]) !== null && _to$key3 !== void 0 ? _to$key3 : {};
|
|
719
|
-
to[key] = origin;
|
|
720
|
-
deepObject(value, origin);
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
if (Tools.isArray(value)) {
|
|
724
|
-
var _to$key4;
|
|
725
|
-
const origin = (_to$key4 = to[key]) !== null && _to$key4 !== void 0 ? _to$key4 : [];
|
|
726
|
-
to[key] = origin;
|
|
727
|
-
deepArray(value, origin);
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
to[key] = value;
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function deepItem(item) {
|
|
734
|
-
Object.keys(item).forEach((key) => {
|
|
735
|
-
if (isDangerousKey(key)) return;
|
|
736
|
-
const value = item[key];
|
|
737
|
-
if (Tools.isArray(value)) {
|
|
738
|
-
var _target$key;
|
|
739
|
-
const origin = (_target$key = target[key]) !== null && _target$key !== void 0 ? _target$key : [];
|
|
740
|
-
target[key] = origin;
|
|
741
|
-
deepArray(value, origin);
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
if (Tools.isObject(value)) {
|
|
745
|
-
var _target$key2;
|
|
746
|
-
const origin = (_target$key2 = target[key]) !== null && _target$key2 !== void 0 ? _target$key2 : {};
|
|
747
|
-
target[key] = origin;
|
|
748
|
-
deepObject(value, origin);
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
target[key] = value;
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
return target;
|
|
755
|
-
}
|
|
756
686
|
static diffValue(one, two) {
|
|
757
687
|
return isValueEqual(one, two);
|
|
758
688
|
}
|
|
@@ -1539,6 +1469,8 @@ let TextDecoration = /* @__PURE__ */ function(TextDecoration) {
|
|
|
1539
1469
|
TextDecoration[TextDecoration["WAVY_DOUBLE"] = 15] = "WAVY_DOUBLE";
|
|
1540
1470
|
TextDecoration[TextDecoration["WAVY_HEAVY"] = 16] = "WAVY_HEAVY";
|
|
1541
1471
|
TextDecoration[TextDecoration["WORDS"] = 17] = "WORDS";
|
|
1472
|
+
TextDecoration[TextDecoration["SINGLE_ACCOUNTING"] = 18] = "SINGLE_ACCOUNTING";
|
|
1473
|
+
TextDecoration[TextDecoration["DOUBLE_ACCOUNTING"] = 19] = "DOUBLE_ACCOUNTING";
|
|
1542
1474
|
return TextDecoration;
|
|
1543
1475
|
}({});
|
|
1544
1476
|
/**
|
|
@@ -1652,8 +1584,6 @@ let CellValueType = /* @__PURE__ */ function(CellValueType) {
|
|
|
1652
1584
|
*/
|
|
1653
1585
|
/**
|
|
1654
1586
|
* Theme color type enum
|
|
1655
|
-
*
|
|
1656
|
-
* @deprecated
|
|
1657
1587
|
*/
|
|
1658
1588
|
let ThemeColorType = /* @__PURE__ */ function(ThemeColorType) {
|
|
1659
1589
|
/**
|
|
@@ -1681,8 +1611,6 @@ let ThemeColorType = /* @__PURE__ */ function(ThemeColorType) {
|
|
|
1681
1611
|
}({});
|
|
1682
1612
|
/**
|
|
1683
1613
|
* Preset theme names.
|
|
1684
|
-
*
|
|
1685
|
-
* @deprecated
|
|
1686
1614
|
*/
|
|
1687
1615
|
let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
1688
1616
|
ThemeColors["OFFICE"] = "Office";
|
|
@@ -1714,7 +1642,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1714
1642
|
//#endregion
|
|
1715
1643
|
//#region package.json
|
|
1716
1644
|
var name = "@univerjs/core";
|
|
1717
|
-
var version = "1.0.0-
|
|
1645
|
+
var version = "1.0.0-beta.0";
|
|
1718
1646
|
|
|
1719
1647
|
//#endregion
|
|
1720
1648
|
//#region src/common/array.ts
|
|
@@ -1923,9 +1851,8 @@ var ConfigService = class {
|
|
|
1923
1851
|
return this._config.get(id);
|
|
1924
1852
|
}
|
|
1925
1853
|
setConfig(id, value, options) {
|
|
1926
|
-
var _this$_config$get;
|
|
1927
1854
|
const { merge: isMerge = false } = options || {};
|
|
1928
|
-
let nextValue =
|
|
1855
|
+
let nextValue = this._config.get(id) ?? {};
|
|
1929
1856
|
if (isMerge) nextValue = merge(nextValue, value);
|
|
1930
1857
|
else nextValue = value;
|
|
1931
1858
|
this._config.set(id, nextValue);
|
|
@@ -1974,8 +1901,7 @@ var ContextService = class extends Disposable {
|
|
|
1974
1901
|
this._contextMap.clear();
|
|
1975
1902
|
}
|
|
1976
1903
|
getContextValue(key) {
|
|
1977
|
-
|
|
1978
|
-
return (_this$_contextMap$get = this._contextMap.get(key)) !== null && _this$_contextMap$get !== void 0 ? _this$_contextMap$get : false;
|
|
1904
|
+
return this._contextMap.get(key) ?? false;
|
|
1979
1905
|
}
|
|
1980
1906
|
setContextValue(key, value) {
|
|
1981
1907
|
this._contextMap.set(key, value);
|
|
@@ -2062,7 +1988,7 @@ function hashLogContent(...args) {
|
|
|
2062
1988
|
}
|
|
2063
1989
|
|
|
2064
1990
|
//#endregion
|
|
2065
|
-
//#region \0@oxc-project+runtime@0.
|
|
1991
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
2066
1992
|
function __decorateParam(paramIndex, decorator) {
|
|
2067
1993
|
return function(target, key) {
|
|
2068
1994
|
decorator(target, key, paramIndex);
|
|
@@ -2070,7 +1996,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
2070
1996
|
}
|
|
2071
1997
|
|
|
2072
1998
|
//#endregion
|
|
2073
|
-
//#region \0@oxc-project+runtime@0.
|
|
1999
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
2074
2000
|
function __decorate(decorators, target, key, desc) {
|
|
2075
2001
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2076
2002
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2233,7 +2159,7 @@ let CommandService = class CommandService extends Disposable {
|
|
|
2233
2159
|
params
|
|
2234
2160
|
};
|
|
2235
2161
|
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
|
|
2236
|
-
const _options = options
|
|
2162
|
+
const _options = options ?? {};
|
|
2237
2163
|
this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
|
|
2238
2164
|
if (this._disposed) {
|
|
2239
2165
|
stackItemDisposable.dispose();
|
|
@@ -2273,13 +2199,12 @@ let CommandService = class CommandService extends Disposable {
|
|
|
2273
2199
|
if (command.type === 2) {
|
|
2274
2200
|
const triggerCommand = findLast(this._commandExecutionStack, (item) => item.type === 0);
|
|
2275
2201
|
if (triggerCommand) {
|
|
2276
|
-
|
|
2277
|
-
commandInfo.params = (_commandInfo$params = commandInfo.params) !== null && _commandInfo$params !== void 0 ? _commandInfo$params : {};
|
|
2202
|
+
commandInfo.params = commandInfo.params ?? {};
|
|
2278
2203
|
commandInfo.params.trigger = triggerCommand.id;
|
|
2279
2204
|
}
|
|
2280
2205
|
}
|
|
2281
2206
|
const stackItemDisposable = this._pushCommandExecutionStack(commandInfo);
|
|
2282
|
-
const _options = options
|
|
2207
|
+
const _options = options ?? {};
|
|
2283
2208
|
this._beforeCommandExecutionListeners.forEach((listener) => listener(commandInfo, _options));
|
|
2284
2209
|
if (this._disposed) {
|
|
2285
2210
|
stackItemDisposable.dispose();
|
|
@@ -3367,18 +3292,18 @@ const COLORS = {
|
|
|
3367
3292
|
};
|
|
3368
3293
|
var ColorKit = class ColorKit {
|
|
3369
3294
|
static mix(color1, color2, amount) {
|
|
3370
|
-
var _rgb1$a, _rgb2$a;
|
|
3371
3295
|
amount = Math.min(1, Math.max(0, amount));
|
|
3372
3296
|
const rgb1 = new ColorKit(color1).toRgb();
|
|
3373
3297
|
const rgb2 = new ColorKit(color2).toRgb();
|
|
3374
|
-
const alpha1 =
|
|
3375
|
-
const alpha2 =
|
|
3376
|
-
|
|
3298
|
+
const alpha1 = rgb1.a ?? 1;
|
|
3299
|
+
const alpha2 = rgb2.a ?? 1;
|
|
3300
|
+
const rgba = {
|
|
3377
3301
|
r: (rgb2.r - rgb1.r) * amount + rgb1.r,
|
|
3378
3302
|
g: (rgb2.g - rgb1.g) * amount + rgb1.g,
|
|
3379
3303
|
b: (rgb2.b - rgb1.b) * amount + rgb1.b,
|
|
3380
3304
|
a: (alpha2 - alpha1) * amount + alpha1
|
|
3381
|
-
}
|
|
3305
|
+
};
|
|
3306
|
+
return new ColorKit(rgba);
|
|
3382
3307
|
}
|
|
3383
3308
|
static getContrastRatio(foreground, background) {
|
|
3384
3309
|
const lumA = new ColorKit(foreground).getLuminance();
|
|
@@ -3476,8 +3401,7 @@ var ColorKit = class ColorKit {
|
|
|
3476
3401
|
return (r * 299 + g * 587 + b * 114) / 1e3;
|
|
3477
3402
|
}
|
|
3478
3403
|
getAlpha() {
|
|
3479
|
-
|
|
3480
|
-
return (_this$_color$a = this._color.a) !== null && _this$_color$a !== void 0 ? _this$_color$a : 1;
|
|
3404
|
+
return this._color.a ?? 1;
|
|
3481
3405
|
}
|
|
3482
3406
|
isDark() {
|
|
3483
3407
|
return this.getBrightness() < 128;
|
|
@@ -3874,57 +3798,6 @@ let DOC_RANGE_TYPE = /* @__PURE__ */ function(DOC_RANGE_TYPE) {
|
|
|
3874
3798
|
DOC_RANGE_TYPE["TEXT"] = "TEXT";
|
|
3875
3799
|
return DOC_RANGE_TYPE;
|
|
3876
3800
|
}({});
|
|
3877
|
-
/**
|
|
3878
|
-
* Determines whether the cell(row, column) is within the range of the merged cells.
|
|
3879
|
-
* @deprecated please use worksheet.getCellInfoInMergeData instead
|
|
3880
|
-
*/
|
|
3881
|
-
function getCellInfoInMergeData(row, column, mergeData) {
|
|
3882
|
-
let isMerged = false;
|
|
3883
|
-
let isMergedMainCell = false;
|
|
3884
|
-
let newEndRow = row;
|
|
3885
|
-
let newEndColumn = column;
|
|
3886
|
-
let mergeRow = row;
|
|
3887
|
-
let mergeColumn = column;
|
|
3888
|
-
if (mergeData == null) return {
|
|
3889
|
-
actualRow: row,
|
|
3890
|
-
actualColumn: column,
|
|
3891
|
-
isMergedMainCell,
|
|
3892
|
-
isMerged,
|
|
3893
|
-
endRow: newEndRow,
|
|
3894
|
-
endColumn: newEndColumn,
|
|
3895
|
-
startRow: mergeRow,
|
|
3896
|
-
startColumn: mergeColumn
|
|
3897
|
-
};
|
|
3898
|
-
for (let i = 0; i < mergeData.length; i++) {
|
|
3899
|
-
const { startRow: startRowMarge, endRow: endRowMarge, startColumn: startColumnMarge, endColumn: endColumnMarge } = mergeData[i];
|
|
3900
|
-
if (row === startRowMarge && column === startColumnMarge) {
|
|
3901
|
-
newEndRow = endRowMarge;
|
|
3902
|
-
newEndColumn = endColumnMarge;
|
|
3903
|
-
mergeRow = startRowMarge;
|
|
3904
|
-
mergeColumn = startColumnMarge;
|
|
3905
|
-
isMergedMainCell = true;
|
|
3906
|
-
break;
|
|
3907
|
-
}
|
|
3908
|
-
if (row >= startRowMarge && row <= endRowMarge && column >= startColumnMarge && column <= endColumnMarge) {
|
|
3909
|
-
newEndRow = endRowMarge;
|
|
3910
|
-
newEndColumn = endColumnMarge;
|
|
3911
|
-
mergeRow = startRowMarge;
|
|
3912
|
-
mergeColumn = startColumnMarge;
|
|
3913
|
-
isMerged = true;
|
|
3914
|
-
break;
|
|
3915
|
-
}
|
|
3916
|
-
}
|
|
3917
|
-
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
|
-
}
|
|
3928
3801
|
let CellModeEnum = /* @__PURE__ */ function(CellModeEnum) {
|
|
3929
3802
|
CellModeEnum["Raw"] = "raw";
|
|
3930
3803
|
CellModeEnum["Intercepted"] = "intercepted";
|
|
@@ -4120,7 +3993,6 @@ const dateCodes = [
|
|
|
4120
3993
|
["hm", 9]
|
|
4121
3994
|
];
|
|
4122
3995
|
function info(partitions, currencyId = null) {
|
|
4123
|
-
var _positive$scale;
|
|
4124
3996
|
const [partPositive, partNegative] = partitions;
|
|
4125
3997
|
if (!partPositive) throw new TypeError("Cannot read properties of undefined (reading 'frac_max')");
|
|
4126
3998
|
const positive = isParsedSection$1(partPositive) ? partPositive : void 0;
|
|
@@ -4132,8 +4004,8 @@ function info(partitions, currencyId = null) {
|
|
|
4132
4004
|
isDate: isDate(partitions),
|
|
4133
4005
|
isText: isText(partitions),
|
|
4134
4006
|
isPercent: isPercent(partitions),
|
|
4135
|
-
maxDecimals: (positive === null || positive === void 0 ? void 0 : positive.general) ? 9 : fracMax
|
|
4136
|
-
scale: (
|
|
4007
|
+
maxDecimals: (positive === null || positive === void 0 ? void 0 : positive.general) ? 9 : fracMax ?? 0,
|
|
4008
|
+
scale: (positive === null || positive === void 0 ? void 0 : positive.scale) ?? 1,
|
|
4137
4009
|
color: 0,
|
|
4138
4010
|
parentheses: 0,
|
|
4139
4011
|
grouped: (positive === null || positive === void 0 ? void 0 : positive.grouping) ? 1 : 0,
|
|
@@ -4216,11 +4088,10 @@ function info(partitions, currencyId = null) {
|
|
|
4216
4088
|
return Object.freeze(output);
|
|
4217
4089
|
}
|
|
4218
4090
|
function dateInfo(partitions) {
|
|
4219
|
-
var _positive$date;
|
|
4220
4091
|
const [partPositive] = partitions;
|
|
4221
4092
|
if (!partPositive) throw new TypeError("Cannot read properties of undefined (reading 'date')");
|
|
4222
4093
|
const positive = isParsedSection$1(partPositive) ? partPositive : void 0;
|
|
4223
|
-
const date = (
|
|
4094
|
+
const date = (positive === null || positive === void 0 ? void 0 : positive.date) ?? 0;
|
|
4224
4095
|
return {
|
|
4225
4096
|
year: !!(date & 2),
|
|
4226
4097
|
month: !!(date & 4),
|
|
@@ -5796,8 +5667,7 @@ function getAbsoluteDecimal(value) {
|
|
|
5796
5667
|
} : value;
|
|
5797
5668
|
}
|
|
5798
5669
|
function getDecimalExponent(value) {
|
|
5799
|
-
|
|
5800
|
-
return (_value$exponent = value === null || value === void 0 ? void 0 : value.exponent) !== null && _value$exponent !== void 0 ? _value$exponent : 0;
|
|
5670
|
+
return (value === null || value === void 0 ? void 0 : value.exponent) ?? 0;
|
|
5801
5671
|
}
|
|
5802
5672
|
function usesShortestSignificand(value) {
|
|
5803
5673
|
return !value || value.exponent < -308;
|
|
@@ -5983,7 +5853,6 @@ function legacyRound(number, places = 0) {
|
|
|
5983
5853
|
return Math.round(number);
|
|
5984
5854
|
}
|
|
5985
5855
|
function runPart(value, part, options, locale, decimalValue = null) {
|
|
5986
|
-
var _options$grouping$, _options$grouping$2;
|
|
5987
5856
|
const section = part;
|
|
5988
5857
|
let renderValue = value;
|
|
5989
5858
|
let numericValue = value;
|
|
@@ -6046,8 +5915,8 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
6046
5915
|
const roundedInteger = Math.abs(Number.isSafeInteger(numericValue) && places === 0 ? numericValue : legacyRound(numericValue, places));
|
|
6047
5916
|
integer += roundedInteger < 1 ? "" : Math.floor(roundedInteger);
|
|
6048
5917
|
}
|
|
6049
|
-
const primaryGroup =
|
|
6050
|
-
const secondaryGroup =
|
|
5918
|
+
const primaryGroup = options.grouping[0] ?? 3;
|
|
5919
|
+
const secondaryGroup = options.grouping[1] ?? primaryGroup;
|
|
6051
5920
|
if (section.dec_fractions) fraction = roundedNumber ? roundedNumber.fraction : String(legacyRound(numericValue, section.frac_max)).split(".")[1] || "";
|
|
6052
5921
|
const fixedSlash = !section.error && (section.num_p.includes("0") || section.den_p.includes("0"));
|
|
6053
5922
|
let haveFraction = fixedSlash;
|
|
@@ -6724,7 +6593,7 @@ function dateToSerial(date, options) {
|
|
|
6724
6593
|
let timestamp = null;
|
|
6725
6594
|
if (Array.isArray(date)) {
|
|
6726
6595
|
const [year, month, day, hours, minutes, seconds] = date;
|
|
6727
|
-
timestamp = dateUTC(year, month == null ? 0 : month - 1, day
|
|
6596
|
+
timestamp = dateUTC(year, month == null ? 0 : month - 1, day ?? 1, hours || 0, minutes || 0, seconds || 0);
|
|
6728
6597
|
} else if (date instanceof Date) {
|
|
6729
6598
|
timestamp = date.getTime();
|
|
6730
6599
|
if (!(options === null || options === void 0 ? void 0 : options.ignoreTimezone)) {
|
|
@@ -7048,6 +6917,7 @@ function isValidDate(year, month, day) {
|
|
|
7048
6917
|
} 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;
|
|
7049
6918
|
return true;
|
|
7050
6919
|
}
|
|
6920
|
+
const dateLocaleLookupCache = /* @__PURE__ */ new WeakMap();
|
|
7051
6921
|
const matchRec = (string, data, skipPeriod = false) => {
|
|
7052
6922
|
for (const item of data) if (string.startsWith(item[0])) {
|
|
7053
6923
|
let length = item[0].length;
|
|
@@ -7158,23 +7028,39 @@ const getLookups = (values, symbol) => {
|
|
|
7158
7028
|
lookups.sort((a, b) => b[0].length - a[0].length);
|
|
7159
7029
|
return lookups;
|
|
7160
7030
|
};
|
|
7031
|
+
const tokensMatch = (values, cachedValues) => values.length === cachedValues.length && values.every((value, index) => value === cachedValues[index]);
|
|
7032
|
+
const getDateLocaleLookups = (locale) => {
|
|
7033
|
+
let cached = dateLocaleLookupCache.get(locale);
|
|
7034
|
+
if (!cached || !tokensMatch(locale.mmmm, cached.mmmm) || !tokensMatch(locale.mmm, cached.mmm) || !tokensMatch(locale.dddd, cached.dddd) || !tokensMatch(locale.ddd, cached.ddd)) {
|
|
7035
|
+
cached = {
|
|
7036
|
+
lookups: {
|
|
7037
|
+
mon: getLookups(locale.mmmm, "F").concat(getLookups(locale.mmm, "M")),
|
|
7038
|
+
mp: locale.mmm[0].endsWith("."),
|
|
7039
|
+
day: getLookups(locale.dddd, "l").concat(getLookups(locale.ddd, "D")),
|
|
7040
|
+
dp: locale.ddd[0].endsWith(".")
|
|
7041
|
+
},
|
|
7042
|
+
mmmm: [...locale.mmmm],
|
|
7043
|
+
mmm: [...locale.mmm],
|
|
7044
|
+
dddd: [...locale.dddd],
|
|
7045
|
+
ddd: [...locale.ddd]
|
|
7046
|
+
};
|
|
7047
|
+
dateLocaleLookupCache.set(locale, cached);
|
|
7048
|
+
}
|
|
7049
|
+
return cached.lookups;
|
|
7050
|
+
};
|
|
7161
7051
|
/** Parse a date or datetime string and return its serial value and format. */
|
|
7162
7052
|
function parseDate(value, options = {}) {
|
|
7163
|
-
var _date$year, _date$day;
|
|
7164
7053
|
const l10n = getLocale(options.locale || "") || defaultLocale;
|
|
7165
7054
|
const localeData = {
|
|
7166
|
-
|
|
7167
|
-
mp: l10n.mmm[0].at(-1) === ".",
|
|
7168
|
-
day: getLookups(l10n.dddd, "l").concat(getLookups(l10n.ddd, "D")),
|
|
7169
|
-
dp: l10n.ddd[0].at(-1) === ".",
|
|
7055
|
+
...getDateLocaleLookups(l10n),
|
|
7170
7056
|
locale: options.locale
|
|
7171
7057
|
};
|
|
7172
7058
|
const date = nextToken(normDateStr(value), l10n.preferMDY ? dateTrieMD : dateTrieDM, { path: "" }, localeData);
|
|
7173
7059
|
if (!date) return null;
|
|
7174
7060
|
if (date.sep === "." && date.path.length === 3) return null;
|
|
7175
7061
|
if (date.month == null || date._mon == null) return null;
|
|
7176
|
-
const year = +(
|
|
7177
|
-
const day =
|
|
7062
|
+
const year = +(date.year ?? currentYear);
|
|
7063
|
+
const day = date.day ?? "1";
|
|
7178
7064
|
let epoch = -Infinity;
|
|
7179
7065
|
if (year < 1900) return null;
|
|
7180
7066
|
else if (year <= 1900 && date.month <= 2) epoch = 25568;
|
|
@@ -7239,8 +7125,7 @@ function parseBool(value, options = {}) {
|
|
|
7239
7125
|
}
|
|
7240
7126
|
/** Parse a spreadsheet input as a number, date, time, or boolean. */
|
|
7241
7127
|
function parseValue(value, options) {
|
|
7242
|
-
|
|
7243
|
-
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);
|
|
7128
|
+
return parseNumber(value, options) ?? parseDate(value, options) ?? parseTime(value, options) ?? parseBool(value, options);
|
|
7244
7129
|
}
|
|
7245
7130
|
|
|
7246
7131
|
//#endregion
|
|
@@ -7301,19 +7186,17 @@ function prepareFormatterData(pattern, shouldThrow = false) {
|
|
|
7301
7186
|
* Formats a value as a string and returns the result.
|
|
7302
7187
|
*/
|
|
7303
7188
|
function format(pattern, value, options = {}) {
|
|
7304
|
-
var _handleDates;
|
|
7305
7189
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7306
7190
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7307
|
-
return formatValue(
|
|
7191
|
+
return formatValue(dateToSerial(value, resolvedOptions) ?? value, data, resolvedOptions);
|
|
7308
7192
|
}
|
|
7309
7193
|
/**
|
|
7310
7194
|
* Find the color appropriate to a value as dictated by a format pattern.
|
|
7311
7195
|
*/
|
|
7312
7196
|
function formatColor(pattern, value, options) {
|
|
7313
|
-
var _handleDates2;
|
|
7314
7197
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7315
7198
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7316
|
-
return formatColor$1(
|
|
7199
|
+
return formatColor$1(dateToSerial(value, resolvedOptions) ?? value, data, resolvedOptions);
|
|
7317
7200
|
}
|
|
7318
7201
|
/** Determine if a given format pattern is a date pattern. */
|
|
7319
7202
|
function isDateFormat(pattern) {
|
|
@@ -7783,8 +7666,7 @@ const CURRENCY_SYMBOL_PREFIX_REG = new RegExp(`^${regexp.charset(...Array.from(n
|
|
|
7783
7666
|
* Get the numfmt parse value, and filter out the parse error.
|
|
7784
7667
|
*/
|
|
7785
7668
|
const getNumfmtParseValueFilter = (value) => {
|
|
7786
|
-
|
|
7787
|
-
const parseData = (_ref = (_parseDate = parseDate(value)) !== null && _parseDate !== void 0 ? _parseDate : parseTime(value)) !== null && _ref !== void 0 ? _ref : parseNumber(value);
|
|
7669
|
+
const parseData = parseDate(value) ?? parseTime(value) ?? parseNumber(value);
|
|
7788
7670
|
if (!parseData) return null;
|
|
7789
7671
|
const { z } = parseData;
|
|
7790
7672
|
if (z) {
|
|
@@ -8012,24 +7894,15 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8012
7894
|
const objectArray = this.getRowOrCreate(row);
|
|
8013
7895
|
objectArray[column] = value;
|
|
8014
7896
|
}
|
|
8015
|
-
|
|
8016
|
-
* !!
|
|
8017
|
-
* Please +1 ‘!’, who fell into this pit.
|
|
8018
|
-
* @deprecated use `realDelete` or `splice`
|
|
8019
|
-
*/
|
|
8020
|
-
deleteValue(row, column) {
|
|
7897
|
+
realDeleteValue(row, column) {
|
|
8021
7898
|
var _this$_matrix2;
|
|
8022
7899
|
(_this$_matrix2 = this._matrix) === null || _this$_matrix2 === void 0 || (_this$_matrix2 = _this$_matrix2[row]) === null || _this$_matrix2 === void 0 || delete _this$_matrix2[column];
|
|
8023
|
-
}
|
|
8024
|
-
realDeleteValue(row, column) {
|
|
8025
|
-
var _this$_matrix3;
|
|
8026
|
-
(_this$_matrix3 = this._matrix) === null || _this$_matrix3 === void 0 || (_this$_matrix3 = _this$_matrix3[row]) === null || _this$_matrix3 === void 0 || delete _this$_matrix3[column];
|
|
8027
7900
|
if (this.getRow(row)) {
|
|
8028
7901
|
const objectArray = this.getRow(row);
|
|
8029
7902
|
if (objectArray == null) return;
|
|
8030
7903
|
if (Object.keys(objectArray).length === 0) {
|
|
8031
|
-
var _this$
|
|
8032
|
-
(_this$
|
|
7904
|
+
var _this$_matrix3;
|
|
7905
|
+
(_this$_matrix3 = this._matrix) === null || _this$_matrix3 === void 0 || delete _this$_matrix3[row];
|
|
8033
7906
|
}
|
|
8034
7907
|
}
|
|
8035
7908
|
}
|
|
@@ -8228,23 +8101,10 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8228
8101
|
});
|
|
8229
8102
|
return array;
|
|
8230
8103
|
}
|
|
8231
|
-
/**
|
|
8232
|
-
* @deprecated Use getMatrix as a substitute.
|
|
8233
|
-
*/
|
|
8234
|
-
toJSON() {
|
|
8235
|
-
return this._matrix;
|
|
8236
|
-
}
|
|
8237
8104
|
clone() {
|
|
8238
8105
|
const json = JSON.stringify(this._matrix);
|
|
8239
8106
|
return JSON.parse(json);
|
|
8240
8107
|
}
|
|
8241
|
-
/**
|
|
8242
|
-
* @deprecated Use clone as a substitute.
|
|
8243
|
-
*/
|
|
8244
|
-
getData() {
|
|
8245
|
-
const json = JSON.stringify(this._matrix);
|
|
8246
|
-
return JSON.parse(json);
|
|
8247
|
-
}
|
|
8248
8108
|
getArrayData() {
|
|
8249
8109
|
let startRow = 0;
|
|
8250
8110
|
let startColumn = 0;
|
|
@@ -8266,7 +8126,7 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8266
8126
|
objectMatrix.setValue(rowIndex - startRow, columnIndex - startColumn, value);
|
|
8267
8127
|
});
|
|
8268
8128
|
});
|
|
8269
|
-
return objectMatrix.
|
|
8129
|
+
return objectMatrix.clone();
|
|
8270
8130
|
}
|
|
8271
8131
|
/**
|
|
8272
8132
|
* the function can only be used in all the row and column are positive integer
|
|
@@ -8412,10 +8272,6 @@ function convertCellToRange(cellInfo) {
|
|
|
8412
8272
|
endX
|
|
8413
8273
|
};
|
|
8414
8274
|
}
|
|
8415
|
-
/**
|
|
8416
|
-
* @deprecated use `convertCellToRange` instead
|
|
8417
|
-
*/
|
|
8418
|
-
const makeCellToSelection = convertCellToRange;
|
|
8419
8275
|
function makeCellRangeToRangeData(cellInfo) {
|
|
8420
8276
|
if (!cellInfo) return;
|
|
8421
8277
|
const { actualRow, actualColumn, isMerged, isMergedMainCell, startRow: mergeStartRow, startColumn: mergeStartColumn, endRow: mergeEndRow, endColumn: mergeEndColumn } = cellInfo;
|
|
@@ -8529,20 +8385,20 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8529
8385
|
["bd", () => {
|
|
8530
8386
|
var _style$bd, _style$bd3, _style$bd5, _style$bd7;
|
|
8531
8387
|
if ((_style$bd = style.bd) === null || _style$bd === void 0 ? void 0 : _style$bd.b) {
|
|
8532
|
-
var _style$bd2
|
|
8533
|
-
str += `border-bottom: ${getBorderStyle((_style$bd2 = style.bd) === null || _style$bd2 === void 0 ? void 0 : _style$bd2.b.s)} ${
|
|
8388
|
+
var _style$bd2;
|
|
8389
|
+
str += `border-bottom: ${getBorderStyle((_style$bd2 = style.bd) === null || _style$bd2 === void 0 ? void 0 : _style$bd2.b.s)} ${getColorStyle(style.bd.b.cl) ?? ""}; `;
|
|
8534
8390
|
}
|
|
8535
8391
|
if ((_style$bd3 = style.bd) === null || _style$bd3 === void 0 ? void 0 : _style$bd3.t) {
|
|
8536
|
-
var _style$bd4
|
|
8537
|
-
str += `border-top: ${getBorderStyle((_style$bd4 = style.bd) === null || _style$bd4 === void 0 ? void 0 : _style$bd4.t.s)} ${
|
|
8392
|
+
var _style$bd4;
|
|
8393
|
+
str += `border-top: ${getBorderStyle((_style$bd4 = style.bd) === null || _style$bd4 === void 0 ? void 0 : _style$bd4.t.s)} ${getColorStyle(style.bd.t.cl) ?? ""}; `;
|
|
8538
8394
|
}
|
|
8539
8395
|
if ((_style$bd5 = style.bd) === null || _style$bd5 === void 0 ? void 0 : _style$bd5.r) {
|
|
8540
|
-
var _style$bd6
|
|
8541
|
-
str += `border-right: ${getBorderStyle((_style$bd6 = style.bd) === null || _style$bd6 === void 0 ? void 0 : _style$bd6.r.s)} ${
|
|
8396
|
+
var _style$bd6;
|
|
8397
|
+
str += `border-right: ${getBorderStyle((_style$bd6 = style.bd) === null || _style$bd6 === void 0 ? void 0 : _style$bd6.r.s)} ${getColorStyle(style.bd.r.cl) ?? ""}; `;
|
|
8542
8398
|
}
|
|
8543
8399
|
if ((_style$bd7 = style.bd) === null || _style$bd7 === void 0 ? void 0 : _style$bd7.l) {
|
|
8544
|
-
var _style$bd8
|
|
8545
|
-
str += `border-left: ${getBorderStyle((_style$bd8 = style.bd) === null || _style$bd8 === void 0 ? void 0 : _style$bd8.l.s)} ${
|
|
8400
|
+
var _style$bd8;
|
|
8401
|
+
str += `border-left: ${getBorderStyle((_style$bd8 = style.bd) === null || _style$bd8 === void 0 ? void 0 : _style$bd8.l.s)} ${getColorStyle(style.bd.l.cl) ?? ""}; `;
|
|
8546
8402
|
}
|
|
8547
8403
|
}],
|
|
8548
8404
|
["cl", () => {
|
|
@@ -8959,8 +8815,7 @@ function parseDateString(input, isUTC) {
|
|
|
8959
8815
|
return new Date(text);
|
|
8960
8816
|
}
|
|
8961
8817
|
function normalizeUnit(unit) {
|
|
8962
|
-
|
|
8963
|
-
return (_UNIT_ALIASES$unit = UNIT_ALIASES[unit]) !== null && _UNIT_ALIASES$unit !== void 0 ? _UNIT_ALIASES$unit : UNIT_ALIASES[String(unit).toLowerCase()];
|
|
8818
|
+
return UNIT_ALIASES[unit] ?? UNIT_ALIASES[String(unit).toLowerCase()];
|
|
8964
8819
|
}
|
|
8965
8820
|
function daysInMonth(year, month, isUTC) {
|
|
8966
8821
|
return isUTC ? new Date(Date.UTC(year, month, 0)).getUTCDate() : new Date(year, month, 0).getDate();
|
|
@@ -9079,10 +8934,7 @@ function ordinal(value) {
|
|
|
9079
8934
|
}
|
|
9080
8935
|
}
|
|
9081
8936
|
function replaceLocalizedTokens(template) {
|
|
9082
|
-
return template.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g, (token) =>
|
|
9083
|
-
var _LOCALIZED_FORMAT_MAP;
|
|
9084
|
-
return (_LOCALIZED_FORMAT_MAP = LOCALIZED_FORMAT_MAP[token]) !== null && _LOCALIZED_FORMAT_MAP !== void 0 ? _LOCALIZED_FORMAT_MAP : token;
|
|
9085
|
-
});
|
|
8937
|
+
return template.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g, (token) => LOCALIZED_FORMAT_MAP[token] ?? token);
|
|
9086
8938
|
}
|
|
9087
8939
|
function formatDate(date, template, isUTC) {
|
|
9088
8940
|
const parts = getDateParts(date, isUTC);
|
|
@@ -9124,13 +8976,7 @@ function formatDate(date, template, isUTC) {
|
|
|
9124
8976
|
const escapedBlocks = [];
|
|
9125
8977
|
return replaceLocalizedTokens(template.replace(/\[([^\]]+)]/g, (_, value) => {
|
|
9126
8978
|
return `\u0000${escapedBlocks.push(value) - 1}\u0000`;
|
|
9127
|
-
})).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) =>
|
|
9128
|
-
var _tokenMap$token;
|
|
9129
|
-
return (_tokenMap$token = tokenMap[token]) !== null && _tokenMap$token !== void 0 ? _tokenMap$token : token;
|
|
9130
|
-
}).replace(/\u0000(\d+)\u0000/g, (_, indexText) => {
|
|
9131
|
-
var _escapedBlocks$Number;
|
|
9132
|
-
return (_escapedBlocks$Number = escapedBlocks[Number(indexText)]) !== null && _escapedBlocks$Number !== void 0 ? _escapedBlocks$Number : "";
|
|
9133
|
-
});
|
|
8979
|
+
})).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)] ?? "");
|
|
9134
8980
|
}
|
|
9135
8981
|
function createDateKit(input) {
|
|
9136
8982
|
return new DateKitImpl(toDate(input, false), false);
|
|
@@ -9299,7 +9145,10 @@ function mergeLocales(...locales) {
|
|
|
9299
9145
|
|
|
9300
9146
|
//#endregion
|
|
9301
9147
|
//#region src/shared/lru/lru-map.ts
|
|
9302
|
-
let _Symbol$iterator
|
|
9148
|
+
let _Symbol$iterator;
|
|
9149
|
+
let _Symbol$iterator2;
|
|
9150
|
+
let _Symbol$iterator3;
|
|
9151
|
+
let _Symbol$iterator4;
|
|
9303
9152
|
const NEWER = Symbol("newer");
|
|
9304
9153
|
const OLDER = Symbol("older");
|
|
9305
9154
|
_Symbol$iterator = Symbol.iterator;
|
|
@@ -9804,6 +9653,11 @@ let CustomRangeType = /* @__PURE__ */ function(CustomRangeType) {
|
|
|
9804
9653
|
CustomRangeType[CustomRangeType["DELTED"] = 9999] = "DELTED";
|
|
9805
9654
|
return CustomRangeType;
|
|
9806
9655
|
}({});
|
|
9656
|
+
let DocxBreakType = /* @__PURE__ */ function(DocxBreakType) {
|
|
9657
|
+
DocxBreakType["COLUMN"] = "column";
|
|
9658
|
+
DocxBreakType["TEXT_WRAPPING"] = "textWrapping";
|
|
9659
|
+
return DocxBreakType;
|
|
9660
|
+
}({});
|
|
9807
9661
|
let CustomDecorationType = /* @__PURE__ */ function(CustomDecorationType) {
|
|
9808
9662
|
CustomDecorationType[CustomDecorationType["COMMENT"] = 0] = "COMMENT";
|
|
9809
9663
|
CustomDecorationType[CustomDecorationType["DELETED"] = 9999] = "DELETED";
|
|
@@ -9836,9 +9690,10 @@ let GridType = /* @__PURE__ */ function(GridType) {
|
|
|
9836
9690
|
let SectionType = /* @__PURE__ */ function(SectionType) {
|
|
9837
9691
|
SectionType[SectionType["SECTION_TYPE_UNSPECIFIED"] = 0] = "SECTION_TYPE_UNSPECIFIED";
|
|
9838
9692
|
SectionType[SectionType["CONTINUOUS"] = 1] = "CONTINUOUS";
|
|
9839
|
-
SectionType[SectionType["
|
|
9840
|
-
SectionType[SectionType["
|
|
9841
|
-
SectionType[SectionType["
|
|
9693
|
+
SectionType[SectionType["NEXT_COLUMN"] = 2] = "NEXT_COLUMN";
|
|
9694
|
+
SectionType[SectionType["NEXT_PAGE"] = 3] = "NEXT_PAGE";
|
|
9695
|
+
SectionType[SectionType["EVEN_PAGE"] = 4] = "EVEN_PAGE";
|
|
9696
|
+
SectionType[SectionType["ODD_PAGE"] = 5] = "ODD_PAGE";
|
|
9842
9697
|
return SectionType;
|
|
9843
9698
|
}({});
|
|
9844
9699
|
/**
|
|
@@ -9883,15 +9738,25 @@ let WrapTextType = /* @__PURE__ */ function(WrapTextType) {
|
|
|
9883
9738
|
return WrapTextType;
|
|
9884
9739
|
}({});
|
|
9885
9740
|
/**
|
|
9886
|
-
*
|
|
9741
|
+
* Controls how a positioned object participates in document text layout.
|
|
9742
|
+
*
|
|
9743
|
+
* `WRAP_NONE` does not by itself determine whether the object is in front of or behind text. Drawing data uses
|
|
9744
|
+
* `behindDoc` for that stacking choice.
|
|
9887
9745
|
*/
|
|
9888
9746
|
let PositionedObjectLayoutType = /* @__PURE__ */ function(PositionedObjectLayoutType) {
|
|
9747
|
+
/** Places the object in the text flow like a character and lets it affect the containing line's metrics. */
|
|
9889
9748
|
PositionedObjectLayoutType[PositionedObjectLayoutType["INLINE"] = 0] = "INLINE";
|
|
9749
|
+
/** Floats the object without reflowing text. The object and text can overlap. */
|
|
9890
9750
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_NONE"] = 1] = "WRAP_NONE";
|
|
9751
|
+
/** Floats the object and wraps text around the custom polygon defined by its wrap path. */
|
|
9891
9752
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_POLYGON"] = 2] = "WRAP_POLYGON";
|
|
9753
|
+
/** Floats the object and wraps text around its rectangular bounds. */
|
|
9892
9754
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_SQUARE"] = 3] = "WRAP_SQUARE";
|
|
9755
|
+
/** Floats the object and allows text to flow through eligible open regions in its wrap contour. */
|
|
9893
9756
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_THROUGH"] = 4] = "WRAP_THROUGH";
|
|
9757
|
+
/** Floats the object and wraps text closely around its contour instead of its rectangular bounds. */
|
|
9894
9758
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_TIGHT"] = 5] = "WRAP_TIGHT";
|
|
9759
|
+
/** Floats the object in a horizontal band, leaving text only above and below it. */
|
|
9895
9760
|
PositionedObjectLayoutType[PositionedObjectLayoutType["WRAP_TOP_AND_BOTTOM"] = 6] = "WRAP_TOP_AND_BOTTOM";
|
|
9896
9761
|
return PositionedObjectLayoutType;
|
|
9897
9762
|
}({});
|
|
@@ -10529,6 +10394,8 @@ const MODERN_DOCUMENT_WIDTH = {
|
|
|
10529
10394
|
["wide"]: PAGE_SIZE["A3"].width
|
|
10530
10395
|
};
|
|
10531
10396
|
const MODERN_DOCUMENT_DEFAULT_MARGIN = 50 / .75;
|
|
10397
|
+
/** Default margin for a paginated Traditional document, in 96-DPI layout pixels. */
|
|
10398
|
+
const TRADITIONAL_DOCUMENT_DEFAULT_MARGIN = 72;
|
|
10532
10399
|
|
|
10533
10400
|
//#endregion
|
|
10534
10401
|
//#region src/sheets/range.ts
|
|
@@ -10717,7 +10584,7 @@ var Range = class Range {
|
|
|
10717
10584
|
*/
|
|
10718
10585
|
getObjectValues(options = {}) {
|
|
10719
10586
|
const { startRow, endRow, startColumn, endColumn } = this._range;
|
|
10720
|
-
const values = this._worksheet.getCellMatrix().getFragment(startRow, endRow, startColumn, endColumn).
|
|
10587
|
+
const values = this._worksheet.getCellMatrix().getFragment(startRow, endRow, startColumn, endColumn).clone();
|
|
10721
10588
|
if (options.isIncludeStyle) {
|
|
10722
10589
|
const style = this._deps.getStyles();
|
|
10723
10590
|
for (let r = 0; r <= endRow - startRow; r++) for (let c = 0; c <= endColumn - startColumn; c++) {
|
|
@@ -10768,8 +10635,8 @@ var Range = class Range {
|
|
|
10768
10635
|
* Returns the underline of the cells in the range.
|
|
10769
10636
|
*/
|
|
10770
10637
|
getUnderline() {
|
|
10771
|
-
var
|
|
10772
|
-
const { p } =
|
|
10638
|
+
var _p$body;
|
|
10639
|
+
const { p } = this.getValue() ?? {};
|
|
10773
10640
|
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 };
|
|
10774
10641
|
return this.getUnderlines()[0][0];
|
|
10775
10642
|
}
|
|
@@ -10789,8 +10656,8 @@ var Range = class Range {
|
|
|
10789
10656
|
* Returns the strikeThrough of the cells in the range.
|
|
10790
10657
|
*/
|
|
10791
10658
|
getStrikeThrough() {
|
|
10792
|
-
var
|
|
10793
|
-
const { p } =
|
|
10659
|
+
var _p$body2;
|
|
10660
|
+
const { p } = this.getValue() ?? {};
|
|
10794
10661
|
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 };
|
|
10795
10662
|
return this.getStrikeThroughs()[0][0];
|
|
10796
10663
|
}
|
|
@@ -10804,8 +10671,8 @@ var Range = class Range {
|
|
|
10804
10671
|
* Returns the font size in point size of the cell in the top-left corner of the range.
|
|
10805
10672
|
*/
|
|
10806
10673
|
getFontSize() {
|
|
10807
|
-
var _this$
|
|
10808
|
-
const p = ((_this$
|
|
10674
|
+
var _this$getValue, _p$body3;
|
|
10675
|
+
const p = ((_this$getValue = this.getValue()) === null || _this$getValue === void 0 ? void 0 : _this$getValue.p) || {};
|
|
10809
10676
|
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) => {
|
|
10810
10677
|
var _textRun$ts;
|
|
10811
10678
|
return (textRun === null || textRun === void 0 || (_textRun$ts = textRun.ts) === null || _textRun$ts === void 0 ? void 0 : _textRun$ts.fs) != null;
|
|
@@ -10835,8 +10702,8 @@ var Range = class Range {
|
|
|
10835
10702
|
* Returns the font style ('italic' or 'normal') of the cell in the top-left corner of the range.
|
|
10836
10703
|
*/
|
|
10837
10704
|
getFontStyle() {
|
|
10838
|
-
var
|
|
10839
|
-
const { p } =
|
|
10705
|
+
var _p$body4;
|
|
10706
|
+
const { p } = this.getValue() ?? {};
|
|
10840
10707
|
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;
|
|
10841
10708
|
return this._getFontStyles()[0][0];
|
|
10842
10709
|
}
|
|
@@ -10853,8 +10720,8 @@ var Range = class Range {
|
|
|
10853
10720
|
* otherwise return FontWeight.NORMAL.
|
|
10854
10721
|
*/
|
|
10855
10722
|
getFontWeight() {
|
|
10856
|
-
var
|
|
10857
|
-
const { p } =
|
|
10723
|
+
var _p$body5;
|
|
10724
|
+
const { p } = this.getValue() ?? {};
|
|
10858
10725
|
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;
|
|
10859
10726
|
return this._getFontWeights()[0][0];
|
|
10860
10727
|
}
|
|
@@ -11473,52 +11340,6 @@ var Rectangle = class Rectangle {
|
|
|
11473
11340
|
}).length > 0);
|
|
11474
11341
|
}
|
|
11475
11342
|
/**
|
|
11476
|
-
* Gets the intersection range between two ranges
|
|
11477
|
-
* @param src
|
|
11478
|
-
* @param target
|
|
11479
|
-
* @deprecated use `getIntersectRange` instead
|
|
11480
|
-
* @example
|
|
11481
|
-
* ```typescript
|
|
11482
|
-
* const range1 = { startRow: 0, startColumn: 0, endRow: 2, endColumn: 2 };
|
|
11483
|
-
* const range2 = { startRow: 1, startColumn: 1, endRow: 3, endColumn: 3 };
|
|
11484
|
-
* const intersection = Rectangle.getIntersects(range1, range2);
|
|
11485
|
-
* // intersection = { startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
|
|
11486
|
-
* ```
|
|
11487
|
-
*/
|
|
11488
|
-
static getIntersects(src, target) {
|
|
11489
|
-
const currentStartRow = src.startRow;
|
|
11490
|
-
const currentEndRow = src.endRow;
|
|
11491
|
-
const currentStartColumn = src.startColumn;
|
|
11492
|
-
const currentEndColumn = src.endColumn;
|
|
11493
|
-
const incomingStartRow = target.startRow;
|
|
11494
|
-
const incomingEndRow = target.endRow;
|
|
11495
|
-
const incomingStartColumn = target.startColumn;
|
|
11496
|
-
const incomingEndColumn = target.endColumn;
|
|
11497
|
-
let startColumn;
|
|
11498
|
-
let startRow;
|
|
11499
|
-
let endColumn;
|
|
11500
|
-
let endRow;
|
|
11501
|
-
if (incomingStartRow <= currentEndRow) if (incomingStartRow >= currentStartRow) startRow = incomingStartRow;
|
|
11502
|
-
else startRow = currentStartRow;
|
|
11503
|
-
else return null;
|
|
11504
|
-
if (incomingEndRow >= currentStartRow) if (incomingEndRow >= currentEndRow) endRow = currentEndRow;
|
|
11505
|
-
else endRow = incomingEndRow;
|
|
11506
|
-
else return null;
|
|
11507
|
-
if (incomingStartColumn <= currentEndColumn) if (incomingStartColumn > currentStartColumn) startColumn = incomingStartColumn;
|
|
11508
|
-
else startColumn = currentStartColumn;
|
|
11509
|
-
else return null;
|
|
11510
|
-
if (incomingEndColumn >= currentStartColumn) if (incomingEndColumn >= currentEndColumn) endColumn = currentEndColumn;
|
|
11511
|
-
else endColumn = incomingEndColumn;
|
|
11512
|
-
else return null;
|
|
11513
|
-
return {
|
|
11514
|
-
startRow,
|
|
11515
|
-
endRow,
|
|
11516
|
-
startColumn,
|
|
11517
|
-
endColumn,
|
|
11518
|
-
rangeType: 0
|
|
11519
|
-
};
|
|
11520
|
-
}
|
|
11521
|
-
/**
|
|
11522
11343
|
* Checks if one range completely contains another range
|
|
11523
11344
|
* @param src
|
|
11524
11345
|
* @param target
|
|
@@ -12075,7 +11896,6 @@ function ABCToNumber(a) {
|
|
|
12075
11896
|
const orderA = "A".charCodeAt(0);
|
|
12076
11897
|
"Z".charCodeAt(0);
|
|
12077
11898
|
const order_a = "a".charCodeAt(0);
|
|
12078
|
-
"z".charCodeAt(0);
|
|
12079
11899
|
/**
|
|
12080
11900
|
* column subscript number to letters
|
|
12081
11901
|
* @param n number
|
|
@@ -12172,26 +11992,25 @@ let BaseFieldType = /* @__PURE__ */ function(BaseFieldType) {
|
|
|
12172
11992
|
BaseFieldType["Checkbox"] = "checkbox";
|
|
12173
11993
|
BaseFieldType["Link"] = "link";
|
|
12174
11994
|
BaseFieldType["Formula"] = "formula";
|
|
12175
|
-
BaseFieldType["Lookup"] = "lookup";
|
|
12176
|
-
BaseFieldType["Flow"] = "flow";
|
|
12177
|
-
BaseFieldType["Button"] = "button";
|
|
12178
11995
|
BaseFieldType["Numbering"] = "numbering";
|
|
12179
11996
|
BaseFieldType["Phone"] = "phone";
|
|
12180
11997
|
BaseFieldType["Email"] = "email";
|
|
12181
|
-
BaseFieldType["Location"] = "location";
|
|
12182
|
-
BaseFieldType["Barcode"] = "barcode";
|
|
12183
11998
|
BaseFieldType["Progress"] = "progress";
|
|
12184
11999
|
BaseFieldType["Currency"] = "currency";
|
|
12185
12000
|
BaseFieldType["Rating"] = "rating";
|
|
12186
|
-
BaseFieldType["
|
|
12001
|
+
BaseFieldType["RecordLink"] = "recordLink";
|
|
12187
12002
|
BaseFieldType["RecordId"] = "recordId";
|
|
12188
12003
|
BaseFieldType["CreatedBy"] = "createdBy";
|
|
12189
12004
|
BaseFieldType["UpdatedBy"] = "updatedBy";
|
|
12190
12005
|
BaseFieldType["CreatedAt"] = "createdAt";
|
|
12191
12006
|
BaseFieldType["UpdatedAt"] = "updatedAt";
|
|
12192
|
-
BaseFieldType["Summary"] = "summary";
|
|
12193
12007
|
return BaseFieldType;
|
|
12194
12008
|
}({});
|
|
12009
|
+
/** Semantic roles supported by Base RecordLink fields. */
|
|
12010
|
+
let BaseRecordLinkRole = /* @__PURE__ */ function(BaseRecordLinkRole) {
|
|
12011
|
+
BaseRecordLinkRole["Parent"] = "parent";
|
|
12012
|
+
return BaseRecordLinkRole;
|
|
12013
|
+
}({});
|
|
12195
12014
|
let BaseViewType = /* @__PURE__ */ function(BaseViewType) {
|
|
12196
12015
|
BaseViewType["Grid"] = "grid";
|
|
12197
12016
|
BaseViewType["Kanban"] = "kanban";
|
|
@@ -12200,6 +12019,56 @@ let BaseViewType = /* @__PURE__ */ function(BaseViewType) {
|
|
|
12200
12019
|
BaseViewType["Gallery"] = "gallery";
|
|
12201
12020
|
return BaseViewType;
|
|
12202
12021
|
}({});
|
|
12022
|
+
/** Where a Base conditional color is painted when its condition matches. */
|
|
12023
|
+
const BaseConditionalColorTarget = {
|
|
12024
|
+
/** Paint only the cell in the rule's field. */
|
|
12025
|
+
CELL: "cell",
|
|
12026
|
+
/** Paint the complete record row. */
|
|
12027
|
+
ROW: "row",
|
|
12028
|
+
/** Paint the rule's field column unconditionally; operator, operand, and date mode are ignored. */
|
|
12029
|
+
COLUMN: "column"
|
|
12030
|
+
};
|
|
12031
|
+
/**
|
|
12032
|
+
* Operators supported by Base conditional coloring rules.
|
|
12033
|
+
*
|
|
12034
|
+
* Text, select, person, and similar fields support equality, containment, and
|
|
12035
|
+
* empty checks. Number, currency, progress, and rating fields support equality,
|
|
12036
|
+
* numeric comparison, and empty checks. Date-like fields support equality,
|
|
12037
|
+
* before/after, and empty checks. Checkbox fields support equality only.
|
|
12038
|
+
*/
|
|
12039
|
+
const BaseConditionalColorOperator = {
|
|
12040
|
+
IS: "is",
|
|
12041
|
+
IS_NOT: "isNot",
|
|
12042
|
+
CONTAINS: "contains",
|
|
12043
|
+
NOT_CONTAINS: "notContains",
|
|
12044
|
+
IS_EMPTY: "isEmpty",
|
|
12045
|
+
IS_NOT_EMPTY: "isNotEmpty",
|
|
12046
|
+
GREATER_THAN: "greaterThan",
|
|
12047
|
+
LESS_THAN: "lessThan",
|
|
12048
|
+
BEFORE: "before",
|
|
12049
|
+
AFTER: "after"
|
|
12050
|
+
};
|
|
12051
|
+
/**
|
|
12052
|
+
* Relative or exact date windows supported by date conditional coloring rules.
|
|
12053
|
+
*
|
|
12054
|
+
* With `IS`, dates inside the selected window match. `IS_NOT` matches dates
|
|
12055
|
+
* outside it, `BEFORE` matches dates before its start, and `AFTER` matches
|
|
12056
|
+
* dates after its end. Relative windows do not use an operand; `EXACT` does.
|
|
12057
|
+
*/
|
|
12058
|
+
const BaseConditionalDateMode = {
|
|
12059
|
+
EXACT: "exact",
|
|
12060
|
+
TODAY: "today",
|
|
12061
|
+
TOMORROW: "tomorrow",
|
|
12062
|
+
YESTERDAY: "yesterday",
|
|
12063
|
+
THIS_WEEK: "thisWeek",
|
|
12064
|
+
LAST_WEEK: "lastWeek",
|
|
12065
|
+
THIS_MONTH: "thisMonth",
|
|
12066
|
+
LAST_MONTH: "lastMonth",
|
|
12067
|
+
PAST_7_DAYS: "past7",
|
|
12068
|
+
NEXT_7_DAYS: "next7",
|
|
12069
|
+
PAST_30_DAYS: "past30",
|
|
12070
|
+
NEXT_30_DAYS: "next30"
|
|
12071
|
+
};
|
|
12203
12072
|
let BaseFilterOperator = /* @__PURE__ */ function(BaseFilterOperator) {
|
|
12204
12073
|
BaseFilterOperator["IS"] = "is";
|
|
12205
12074
|
BaseFilterOperator["IS_NOT"] = "isNot";
|
|
@@ -12225,18 +12094,58 @@ let BaseSortDirection = /* @__PURE__ */ function(BaseSortDirection) {
|
|
|
12225
12094
|
BaseSortDirection["DESC"] = "desc";
|
|
12226
12095
|
return BaseSortDirection;
|
|
12227
12096
|
}({});
|
|
12097
|
+
/** Why a stored Parent link cannot participate in the effective hierarchy. */
|
|
12098
|
+
let BaseHierarchyInvalidReason = /* @__PURE__ */ function(BaseHierarchyInvalidReason) {
|
|
12099
|
+
BaseHierarchyInvalidReason["MissingParent"] = "missingParent";
|
|
12100
|
+
BaseHierarchyInvalidReason["SelfParent"] = "selfParent";
|
|
12101
|
+
BaseHierarchyInvalidReason["Cycle"] = "cycle";
|
|
12102
|
+
BaseHierarchyInvalidReason["MaxDepth"] = "maxDepth";
|
|
12103
|
+
return BaseHierarchyInvalidReason;
|
|
12104
|
+
}({});
|
|
12105
|
+
|
|
12106
|
+
//#endregion
|
|
12107
|
+
//#region src/bases/record-identity.ts
|
|
12108
|
+
const BASE_RECORD_ID_FIELD_ID = "__record_id";
|
|
12109
|
+
const BASE_RECORD_ID_FIELD_NAME = "record-id";
|
|
12110
|
+
const BASE_RECORD_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
12111
|
+
function createBaseRecordIdField() {
|
|
12112
|
+
return {
|
|
12113
|
+
id: BASE_RECORD_ID_FIELD_ID,
|
|
12114
|
+
name: BASE_RECORD_ID_FIELD_NAME,
|
|
12115
|
+
type: "recordId",
|
|
12116
|
+
config: {},
|
|
12117
|
+
system: true,
|
|
12118
|
+
readonly: true
|
|
12119
|
+
};
|
|
12120
|
+
}
|
|
12121
|
+
function isValidBaseRecordId(recordId) {
|
|
12122
|
+
return BASE_RECORD_ID_PATTERN.test(recordId);
|
|
12123
|
+
}
|
|
12124
|
+
function isBaseRecordIdFieldName(name) {
|
|
12125
|
+
return name.trim().toLowerCase() === BASE_RECORD_ID_FIELD_NAME;
|
|
12126
|
+
}
|
|
12127
|
+
function assertBaseTableRecordIdentity(table) {
|
|
12128
|
+
const recordIdField = table.fields[BASE_RECORD_ID_FIELD_ID];
|
|
12129
|
+
const recordIdFields = Object.values(table.fields).filter((field) => field.type === "recordId");
|
|
12130
|
+
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.`);
|
|
12131
|
+
const conflictingField = Object.values(table.fields).find((field) => {
|
|
12132
|
+
return field.id !== "__record_id" && isBaseRecordIdFieldName(field.name);
|
|
12133
|
+
});
|
|
12134
|
+
if (conflictingField) throw new Error(`[BaseDataModel]: field name "${conflictingField.name}" is reserved for the record-id system field.`);
|
|
12135
|
+
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.`);
|
|
12136
|
+
}
|
|
12228
12137
|
|
|
12229
12138
|
//#endregion
|
|
12230
12139
|
//#region src/bases/empty-snapshot.ts
|
|
12231
12140
|
function createDefaultBaseTableSnapshot(options) {
|
|
12232
|
-
|
|
12233
|
-
const
|
|
12234
|
-
const
|
|
12235
|
-
const
|
|
12236
|
-
const
|
|
12141
|
+
const now = options.now ?? Date.now();
|
|
12142
|
+
const primaryFieldId = options.primaryFieldId ?? generateRandomId(6);
|
|
12143
|
+
const gridViewId = options.gridViewId ?? generateRandomId(6);
|
|
12144
|
+
const recordCount = options.recordCount ?? 0;
|
|
12145
|
+
const recordIdField = createBaseRecordIdField();
|
|
12237
12146
|
const primaryField = {
|
|
12238
12147
|
id: primaryFieldId,
|
|
12239
|
-
name:
|
|
12148
|
+
name: options.primaryFieldName ?? "Name",
|
|
12240
12149
|
type: "text",
|
|
12241
12150
|
config: { placeholder: "bases.fieldConfig.textPlaceholder" }
|
|
12242
12151
|
};
|
|
@@ -12249,7 +12158,7 @@ function createDefaultBaseTableSnapshot(options) {
|
|
|
12249
12158
|
const recordId = `${options.id}-record-${index + 1}`;
|
|
12250
12159
|
records[recordId] = {
|
|
12251
12160
|
id: recordId,
|
|
12252
|
-
values: {},
|
|
12161
|
+
values: { [BASE_RECORD_ID_FIELD_ID]: recordId },
|
|
12253
12162
|
orderKey: String(index + 1).padStart(4, "0"),
|
|
12254
12163
|
createdAt: now,
|
|
12255
12164
|
updatedAt: now
|
|
@@ -12257,29 +12166,41 @@ function createDefaultBaseTableSnapshot(options) {
|
|
|
12257
12166
|
recordOrder.push(recordId);
|
|
12258
12167
|
rowIndex[recordId] = index;
|
|
12259
12168
|
rowId[index] = recordId;
|
|
12260
|
-
cellData[index] = {
|
|
12169
|
+
cellData[index] = { 0: {
|
|
12170
|
+
v: recordId,
|
|
12171
|
+
t: 1
|
|
12172
|
+
} };
|
|
12261
12173
|
}
|
|
12262
12174
|
const gridView = {
|
|
12263
12175
|
id: gridViewId,
|
|
12264
12176
|
tableId: options.id,
|
|
12265
12177
|
name: "Grid",
|
|
12266
12178
|
type: "grid",
|
|
12267
|
-
fieldOrder: [primaryFieldId],
|
|
12268
|
-
fieldSettings: {},
|
|
12179
|
+
fieldOrder: [BASE_RECORD_ID_FIELD_ID, primaryFieldId],
|
|
12180
|
+
fieldSettings: { [BASE_RECORD_ID_FIELD_ID]: { hidden: true } },
|
|
12269
12181
|
config: { frozenFieldCount: 1 }
|
|
12270
12182
|
};
|
|
12271
12183
|
return {
|
|
12272
12184
|
id: options.id,
|
|
12273
12185
|
name: options.name,
|
|
12274
12186
|
primaryFieldId,
|
|
12275
|
-
fieldOrder: [primaryFieldId],
|
|
12276
|
-
fields: {
|
|
12187
|
+
fieldOrder: [BASE_RECORD_ID_FIELD_ID, primaryFieldId],
|
|
12188
|
+
fields: {
|
|
12189
|
+
[BASE_RECORD_ID_FIELD_ID]: recordIdField,
|
|
12190
|
+
[primaryFieldId]: primaryField
|
|
12191
|
+
},
|
|
12277
12192
|
records,
|
|
12278
12193
|
recordOrder,
|
|
12279
12194
|
rowIndex,
|
|
12280
12195
|
rowId,
|
|
12281
|
-
colIndex: {
|
|
12282
|
-
|
|
12196
|
+
colIndex: {
|
|
12197
|
+
[BASE_RECORD_ID_FIELD_ID]: 0,
|
|
12198
|
+
[primaryFieldId]: 1
|
|
12199
|
+
},
|
|
12200
|
+
colId: {
|
|
12201
|
+
0: BASE_RECORD_ID_FIELD_ID,
|
|
12202
|
+
1: primaryFieldId
|
|
12203
|
+
},
|
|
12283
12204
|
cellData,
|
|
12284
12205
|
resources: {
|
|
12285
12206
|
attachmentSets: {},
|
|
@@ -12297,13 +12218,13 @@ function getEmptySnapshot(unitId = generateRandomId(), name = "", locale = "zhCN
|
|
|
12297
12218
|
name,
|
|
12298
12219
|
locale,
|
|
12299
12220
|
appVersion: version,
|
|
12300
|
-
schemaVersion:
|
|
12221
|
+
schemaVersion: 2,
|
|
12301
12222
|
tableOrder: [tableId],
|
|
12302
12223
|
tables: { [tableId]: createDefaultBaseTableSnapshot({
|
|
12303
12224
|
id: tableId,
|
|
12304
12225
|
name: "Table 1",
|
|
12305
12226
|
now,
|
|
12306
|
-
recordCount:
|
|
12227
|
+
recordCount: 0
|
|
12307
12228
|
}) },
|
|
12308
12229
|
createdAt: now,
|
|
12309
12230
|
updatedAt: now
|
|
@@ -12357,8 +12278,7 @@ var BaseDataModel = class extends UnitModel {
|
|
|
12357
12278
|
this._name$.next(snapshot.name);
|
|
12358
12279
|
}
|
|
12359
12280
|
getRev() {
|
|
12360
|
-
|
|
12361
|
-
return (_this$_snapshot$rev = this._snapshot.rev) !== null && _this$_snapshot$rev !== void 0 ? _this$_snapshot$rev : 1;
|
|
12281
|
+
return this._snapshot.rev ?? 1;
|
|
12362
12282
|
}
|
|
12363
12283
|
incrementRev() {
|
|
12364
12284
|
this._snapshot.rev = this.getRev() + 1;
|
|
@@ -12372,27 +12292,28 @@ var BaseDataModel = class extends UnitModel {
|
|
|
12372
12292
|
}
|
|
12373
12293
|
};
|
|
12374
12294
|
function normalizeBaseSnapshot(snapshot) {
|
|
12375
|
-
var _snapshot$tables;
|
|
12376
12295
|
delete snapshot.compress;
|
|
12377
12296
|
delete snapshot.kind;
|
|
12378
|
-
Object.values(
|
|
12297
|
+
Object.values(snapshot.tables ?? {}).forEach((table) => {
|
|
12298
|
+
assertBaseTableRecordIdentity(table);
|
|
12379
12299
|
normalizeBaseTable(table);
|
|
12300
|
+
assertMaterializedRecordIdentity(table);
|
|
12380
12301
|
});
|
|
12381
12302
|
return snapshot;
|
|
12382
12303
|
}
|
|
12383
12304
|
function isNormalizedBaseSnapshot(snapshot) {
|
|
12384
|
-
|
|
12385
|
-
return Object.values((_snapshot$tables2 = snapshot.tables) !== null && _snapshot$tables2 !== void 0 ? _snapshot$tables2 : {}).every((table) => isNormalizedBaseTable(table));
|
|
12305
|
+
return Object.values(snapshot.tables ?? {}).every((table) => isNormalizedBaseTable(table));
|
|
12386
12306
|
}
|
|
12387
12307
|
function isNormalizedBaseTable(table) {
|
|
12388
|
-
|
|
12389
|
-
const
|
|
12390
|
-
|
|
12308
|
+
const records = table.records ?? {};
|
|
12309
|
+
const fields = table.fields ?? {};
|
|
12310
|
+
assertBaseTableRecordIdentity(table);
|
|
12391
12311
|
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;
|
|
12392
12312
|
if (Object.keys(records).length !== table.recordOrder.length) return false;
|
|
12393
12313
|
for (let index = 0; index < table.recordOrder.length; index++) {
|
|
12314
|
+
var _table$cellData$index;
|
|
12394
12315
|
const recordId = table.recordOrder[index];
|
|
12395
|
-
if (!records[recordId] || table.rowIndex[recordId] !== index || table.rowId[index] !== recordId) return false;
|
|
12316
|
+
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;
|
|
12396
12317
|
}
|
|
12397
12318
|
for (let index = 0; index < table.fieldOrder.length; index++) {
|
|
12398
12319
|
const fieldId = table.fieldOrder[index];
|
|
@@ -12402,10 +12323,9 @@ function isNormalizedBaseTable(table) {
|
|
|
12402
12323
|
return true;
|
|
12403
12324
|
}
|
|
12404
12325
|
function normalizeBaseTable(table) {
|
|
12405
|
-
var _table$records2, _table$fields2;
|
|
12406
12326
|
hydrateCompressedCellData(table);
|
|
12407
|
-
const records =
|
|
12408
|
-
const fields =
|
|
12327
|
+
const records = table.records ?? {};
|
|
12328
|
+
const fields = table.fields ?? {};
|
|
12409
12329
|
const orderedRecordIds = getOrderedRecordIds(table, records);
|
|
12410
12330
|
const orderedFieldIds = getOrderedFieldIds(table, fields);
|
|
12411
12331
|
table.recordOrder = orderedRecordIds;
|
|
@@ -12420,8 +12340,7 @@ function hydrateCompressedCellData(table) {
|
|
|
12420
12340
|
if (compressedCellData && !table.cellData) {
|
|
12421
12341
|
table.cellData = Object.create(null);
|
|
12422
12342
|
compressedCellData.forEach(([row, col, cell]) => {
|
|
12423
|
-
|
|
12424
|
-
table.cellData[row] = (_row = table.cellData[row]) !== null && _row !== void 0 ? _row : {};
|
|
12343
|
+
table.cellData[row] = table.cellData[row] ?? {};
|
|
12425
12344
|
const { c: _compressed, ...cellData } = cell;
|
|
12426
12345
|
table.cellData[row][col] = cellData;
|
|
12427
12346
|
});
|
|
@@ -12429,8 +12348,8 @@ function hydrateCompressedCellData(table) {
|
|
|
12429
12348
|
}
|
|
12430
12349
|
}
|
|
12431
12350
|
function getOrderedRecordIds(table, records) {
|
|
12432
|
-
var _table$recordOrder
|
|
12433
|
-
const orderedRecordIds = (
|
|
12351
|
+
var _table$recordOrder;
|
|
12352
|
+
const orderedRecordIds = ((_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.filter((recordId) => records[recordId])) ?? [];
|
|
12434
12353
|
const orderedRecordIdSet = new Set(orderedRecordIds);
|
|
12435
12354
|
const missingRecords = Object.values(records).filter((record) => !orderedRecordIdSet.has(record.id));
|
|
12436
12355
|
if (!missingRecords.length) return orderedRecordIds;
|
|
@@ -12450,12 +12369,10 @@ function cloneBaseTableMutableMaps(table) {
|
|
|
12450
12369
|
table.resources.attachments = { ...table.resources.attachments };
|
|
12451
12370
|
}
|
|
12452
12371
|
function normalizeExistingCellData(table, fields) {
|
|
12453
|
-
|
|
12454
|
-
Object.entries((_table$cellData = table.cellData) !== null && _table$cellData !== void 0 ? _table$cellData : {}).forEach(([rowKey, rowData]) => {
|
|
12455
|
-
var _row2;
|
|
12372
|
+
Object.entries(table.cellData ?? {}).forEach(([rowKey, rowData]) => {
|
|
12456
12373
|
const row = Number(rowKey);
|
|
12457
12374
|
table.cellData[row] = { ...rowData };
|
|
12458
|
-
Object.entries(
|
|
12375
|
+
Object.entries(table.cellData[row] ?? {}).forEach(([colKey, cell]) => {
|
|
12459
12376
|
var _table$colId;
|
|
12460
12377
|
const col = Number(colKey);
|
|
12461
12378
|
const fieldId = (_table$colId = table.colId) === null || _table$colId === void 0 ? void 0 : _table$colId[col];
|
|
@@ -12464,44 +12381,58 @@ function normalizeExistingCellData(table, fields) {
|
|
|
12464
12381
|
});
|
|
12465
12382
|
}
|
|
12466
12383
|
function rebuildRowIndexes(table, records, orderedRecordIds) {
|
|
12467
|
-
var _table$rowIndex;
|
|
12468
12384
|
orderedRecordIds.forEach((recordId, index) => {
|
|
12469
12385
|
if (table.rowIndex[recordId] == null) table.rowIndex[recordId] = index;
|
|
12470
12386
|
});
|
|
12471
|
-
Object.entries(
|
|
12387
|
+
Object.entries(table.rowIndex ?? {}).forEach(([recordId, row]) => {
|
|
12472
12388
|
if (records[recordId]) table.rowId[row] = recordId;
|
|
12473
12389
|
});
|
|
12474
12390
|
}
|
|
12475
12391
|
function rebuildColumnIndexes(table, fields, orderedFieldIds) {
|
|
12476
|
-
var _table$colIndex;
|
|
12477
12392
|
orderedFieldIds.forEach((fieldId, index) => {
|
|
12478
12393
|
if (table.colIndex[fieldId] == null) table.colIndex[fieldId] = index;
|
|
12479
12394
|
});
|
|
12480
|
-
Object.entries(
|
|
12395
|
+
Object.entries(table.colIndex ?? {}).forEach(([fieldId, col]) => {
|
|
12481
12396
|
if (fields[fieldId]) table.colId[col] = fieldId;
|
|
12482
12397
|
});
|
|
12483
12398
|
}
|
|
12484
12399
|
function hydrateRecordCellData(table, records, fields) {
|
|
12400
|
+
const rowIndex = table.rowIndex ?? {};
|
|
12401
|
+
const colIndex = table.colIndex ?? {};
|
|
12402
|
+
const cellData = table.cellData ?? {};
|
|
12403
|
+
table.rowIndex = rowIndex;
|
|
12404
|
+
table.colIndex = colIndex;
|
|
12405
|
+
table.cellData = cellData;
|
|
12485
12406
|
Object.values(records).forEach((record) => {
|
|
12486
|
-
|
|
12487
|
-
const row = table.rowIndex[record.id];
|
|
12407
|
+
const row = rowIndex[record.id];
|
|
12488
12408
|
if (row == null) return;
|
|
12489
|
-
|
|
12490
|
-
|
|
12409
|
+
cellData[row] = { ...cellData[row] };
|
|
12410
|
+
cellData[row][0] = {
|
|
12411
|
+
v: record.id,
|
|
12412
|
+
t: 1
|
|
12413
|
+
};
|
|
12414
|
+
Object.entries(record.values ?? {}).forEach(([fieldId, value]) => {
|
|
12491
12415
|
const field = fields[fieldId];
|
|
12492
12416
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") writeAttachmentResources(table, record.id, fieldId, value);
|
|
12493
|
-
const col =
|
|
12417
|
+
const col = colIndex[fieldId];
|
|
12494
12418
|
if (col == null) return;
|
|
12495
|
-
const existingCell =
|
|
12419
|
+
const existingCell = cellData[row][col];
|
|
12496
12420
|
if (existingCell != null) {
|
|
12497
|
-
|
|
12498
|
-
if (shouldRefreshCellDataFromRecord(existingCell, field, value))
|
|
12421
|
+
cellData[row][col] = normalizeBaseCellData(existingCell, field);
|
|
12422
|
+
if (shouldRefreshCellDataFromRecord(existingCell, field, value)) cellData[row][col] = toBaseCellData(value, field);
|
|
12499
12423
|
return;
|
|
12500
12424
|
}
|
|
12501
|
-
|
|
12425
|
+
cellData[row][col] = toBaseCellData(value, field);
|
|
12502
12426
|
});
|
|
12503
12427
|
});
|
|
12504
12428
|
}
|
|
12429
|
+
function assertMaterializedRecordIdentity(table) {
|
|
12430
|
+
for (const record of Object.values(table.records)) {
|
|
12431
|
+
var _table$rowIndex, _table$colIndex, _table$colId2, _table$cellData;
|
|
12432
|
+
const row = (_table$rowIndex = table.rowIndex) === null || _table$rowIndex === void 0 ? void 0 : _table$rowIndex[record.id];
|
|
12433
|
+
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.`);
|
|
12434
|
+
}
|
|
12435
|
+
}
|
|
12505
12436
|
function toBaseCellData(value, field) {
|
|
12506
12437
|
if (isBaseCellData(value)) {
|
|
12507
12438
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") return {
|
|
@@ -12520,10 +12451,9 @@ function toBaseCellData(value, field) {
|
|
|
12520
12451
|
t: 1
|
|
12521
12452
|
};
|
|
12522
12453
|
if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
12523
|
-
var _ref, _link$text;
|
|
12524
12454
|
const link = value;
|
|
12525
12455
|
return {
|
|
12526
|
-
v: String(
|
|
12456
|
+
v: String(link.text ?? link.url ?? ""),
|
|
12527
12457
|
t: 1
|
|
12528
12458
|
};
|
|
12529
12459
|
}
|
|
@@ -12557,8 +12487,7 @@ function writeAttachmentResources(table, recordId, fieldId, value) {
|
|
|
12557
12487
|
table.resources.attachments = { ...table.resources.attachments };
|
|
12558
12488
|
const key = `${fieldId}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${recordId}`;
|
|
12559
12489
|
table.resources.attachmentSets[key] = attachments.map((attachment, index) => {
|
|
12560
|
-
|
|
12561
|
-
const id = String((_attachment$id = attachment.id) !== null && _attachment$id !== void 0 ? _attachment$id : `${key}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${index}`);
|
|
12490
|
+
const id = String(attachment.id ?? `${key}${BASE_ATTACHMENT_RESOURCE_KEY_SEPARATOR}${index}`);
|
|
12562
12491
|
const normalizedAttachment = {
|
|
12563
12492
|
...attachment,
|
|
12564
12493
|
id
|
|
@@ -12587,6 +12516,7 @@ function normalizeAttachmentValue(value) {
|
|
|
12587
12516
|
return attachments;
|
|
12588
12517
|
}
|
|
12589
12518
|
function shouldRefreshCellDataFromRecord(cell, field, value) {
|
|
12519
|
+
if ((field === null || field === void 0 ? void 0 : field.type) === "recordId") return cell.v !== value;
|
|
12590
12520
|
if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") return cell.v !== "";
|
|
12591
12521
|
if (isListField(field)) return Array.isArray(value) && (cell.v == null || cell.v === "");
|
|
12592
12522
|
return false;
|
|
@@ -12615,9 +12545,8 @@ function primitiveText(value) {
|
|
|
12615
12545
|
if (value == null) return "";
|
|
12616
12546
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value);
|
|
12617
12547
|
if (typeof value === "object") {
|
|
12618
|
-
var _ref2, _ref3, _record$id;
|
|
12619
12548
|
const record = value;
|
|
12620
|
-
return String(
|
|
12549
|
+
return String(record.id ?? record.name ?? record.text ?? "");
|
|
12621
12550
|
}
|
|
12622
12551
|
return String(value);
|
|
12623
12552
|
}
|
|
@@ -12629,7 +12558,7 @@ function inferPrimitiveType(value) {
|
|
|
12629
12558
|
}
|
|
12630
12559
|
function normalizeBaseCellValueType(type, value) {
|
|
12631
12560
|
if (type === 1 || type === 2 || type === 3 || type === 4 || type == null) return type;
|
|
12632
|
-
return inferPrimitiveType(value
|
|
12561
|
+
return inferPrimitiveType(value ?? null);
|
|
12633
12562
|
}
|
|
12634
12563
|
|
|
12635
12564
|
//#endregion
|
|
@@ -12799,10 +12728,7 @@ var InterceptorManager = class {
|
|
|
12799
12728
|
if (!this._interceptorsByName.has(key)) this._interceptorsByName.set(key, []);
|
|
12800
12729
|
const interceptors = this._interceptorsByName.get(key);
|
|
12801
12730
|
interceptors.push(interceptor);
|
|
12802
|
-
this._interceptorsByName.set(key, interceptors.sort((a, b) =>
|
|
12803
|
-
var _b$priority, _a$priority;
|
|
12804
|
-
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);
|
|
12805
|
-
}));
|
|
12731
|
+
this._interceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
12806
12732
|
return () => remove(this._interceptorsByName.get(key), interceptor);
|
|
12807
12733
|
}
|
|
12808
12734
|
getInterceptPoints() {
|
|
@@ -12858,10 +12784,7 @@ var AsyncInterceptorManager = class {
|
|
|
12858
12784
|
if (!this._asyncInterceptorsByName.has(key)) this._asyncInterceptorsByName.set(key, []);
|
|
12859
12785
|
const interceptors = this._asyncInterceptorsByName.get(key);
|
|
12860
12786
|
interceptors.push(interceptor);
|
|
12861
|
-
this._asyncInterceptorsByName.set(key, interceptors.sort((a, b) =>
|
|
12862
|
-
var _b$priority2, _a$priority2;
|
|
12863
|
-
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);
|
|
12864
|
-
}));
|
|
12787
|
+
this._asyncInterceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
12865
12788
|
return () => remove(this._asyncInterceptorsByName.get(key), interceptor);
|
|
12866
12789
|
}
|
|
12867
12790
|
getInterceptPoints() {
|
|
@@ -12967,7 +12890,8 @@ const blackLuminance = getLuminance(black.r, black.g, black.b);
|
|
|
12967
12890
|
* @returns The inverted color.
|
|
12968
12891
|
*/
|
|
12969
12892
|
function invertNormalizedColorByHSL(color) {
|
|
12970
|
-
const
|
|
12893
|
+
const originalLuminance = getLuminance(color[0], color[1], color[2]);
|
|
12894
|
+
const originalContrast = getContrastRatio(whiteLuminance, originalLuminance);
|
|
12971
12895
|
const hsl = rgbToHsl(color);
|
|
12972
12896
|
let l = 1 - hsl[2];
|
|
12973
12897
|
let newColor, newLuminance, newContrast;
|
|
@@ -13253,10 +13177,9 @@ function createParagraphId(existingIds) {
|
|
|
13253
13177
|
return paragraphId;
|
|
13254
13178
|
}
|
|
13255
13179
|
function cloneBodyWithFreshParagraphIds(body, _scope) {
|
|
13256
|
-
var _cloned$paragraphs;
|
|
13257
13180
|
const cloned = cloneBody(body);
|
|
13258
13181
|
const existingIds = /* @__PURE__ */ new Set();
|
|
13259
|
-
for (const paragraph of
|
|
13182
|
+
for (const paragraph of cloned.paragraphs ?? []) paragraph.paragraphId = createParagraphId(existingIds);
|
|
13260
13183
|
return cloned;
|
|
13261
13184
|
}
|
|
13262
13185
|
function cloneParagraphWithId(paragraph, existingIds, preserveId) {
|
|
@@ -13450,10 +13373,6 @@ let DataStreamTreeTokenType = /* @__PURE__ */ function(DataStreamTreeTokenType)
|
|
|
13450
13373
|
DataStreamTreeTokenType["SPACE"] = " ";
|
|
13451
13374
|
return DataStreamTreeTokenType;
|
|
13452
13375
|
}({});
|
|
13453
|
-
/** Wrap your stream in a pair of custom range tokens. */
|
|
13454
|
-
function makeCustomRangeStream(stream) {
|
|
13455
|
-
return `${stream}`;
|
|
13456
|
-
}
|
|
13457
13376
|
|
|
13458
13377
|
//#endregion
|
|
13459
13378
|
//#region src/docs/data-model/text-x/build-utils/range-interval.ts
|
|
@@ -13632,13 +13551,12 @@ function normalizeTextRuns(textRuns, reserveEmptyTextRun = false) {
|
|
|
13632
13551
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13633
13552
|
*/
|
|
13634
13553
|
function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
13635
|
-
var _insertBody$textRuns;
|
|
13636
13554
|
const { textRuns } = body;
|
|
13637
13555
|
if (textRuns == null) return;
|
|
13638
13556
|
const newTextRuns = [];
|
|
13639
13557
|
const len = textRuns.length;
|
|
13640
13558
|
let hasInserted = false;
|
|
13641
|
-
const insertTextRuns =
|
|
13559
|
+
const insertTextRuns = insertBody.textRuns ?? [];
|
|
13642
13560
|
if (insertTextRuns.length) for (const insertTextRun of insertTextRuns) {
|
|
13643
13561
|
insertTextRun.st += currentIndex;
|
|
13644
13562
|
insertTextRun.ed += currentIndex;
|
|
@@ -13686,9 +13604,9 @@ function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
|
13686
13604
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13687
13605
|
*/
|
|
13688
13606
|
function insertParagraphs(body, insertBody, textLength, currentIndex, preserveMissingParagraphIds = false, originalDataStream = body.dataStream) {
|
|
13689
|
-
var _insertBody$paragraph
|
|
13607
|
+
var _insertBody$paragraph;
|
|
13690
13608
|
if (!body.paragraphs && !((_insertBody$paragraph = insertBody.paragraphs) === null || _insertBody$paragraph === void 0 ? void 0 : _insertBody$paragraph.length)) return;
|
|
13691
|
-
|
|
13609
|
+
body.paragraphs ??= [];
|
|
13692
13610
|
const { paragraphs } = body;
|
|
13693
13611
|
const { paragraphs: insertParagraphs } = insertBody;
|
|
13694
13612
|
normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, {
|
|
@@ -13721,7 +13639,6 @@ function insertParagraphs(body, insertBody, textLength, currentIndex, preserveMi
|
|
|
13721
13639
|
}
|
|
13722
13640
|
}
|
|
13723
13641
|
function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, options) {
|
|
13724
|
-
var _options$reservedPara;
|
|
13725
13642
|
if (!paragraphs || !(insertParagraphs === null || insertParagraphs === void 0 ? void 0 : insertParagraphs.length)) return;
|
|
13726
13643
|
const splitParagraph = getParagraphSplitByInsert(paragraphs, currentIndex, options.dataStream);
|
|
13727
13644
|
const firstSplitInsertIndex = splitParagraph ? getFirstInsertedParagraphIndex(insertParagraphs) : -1;
|
|
@@ -13731,12 +13648,11 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13731
13648
|
const existingParagraphIds = collectParagraphIds(paragraphs);
|
|
13732
13649
|
const preservedInsertedParagraphIds = /* @__PURE__ */ new Set();
|
|
13733
13650
|
if (splitParagraphId) existingParagraphIds.delete(splitParagraphId);
|
|
13734
|
-
for (const paragraphId of
|
|
13651
|
+
for (const paragraphId of options.reservedParagraphIds ?? []) existingParagraphIds.add(paragraphId);
|
|
13735
13652
|
let splitRemainderParagraph;
|
|
13736
13653
|
if (splitParagraphId && firstSplitInsertIndex !== -1 && !shouldPreserveExplicitSplitParagraphId) {
|
|
13737
|
-
var _options$preserveMiss;
|
|
13738
13654
|
const firstInsertParagraph = insertParagraphs[firstSplitInsertIndex];
|
|
13739
|
-
splitRemainderParagraph = firstInsertedParagraphId != null && firstInsertedParagraphId !== splitParagraphId ? cloneInsertedParagraphWithId(firstInsertParagraph, existingParagraphIds,
|
|
13655
|
+
splitRemainderParagraph = firstInsertedParagraphId != null && firstInsertedParagraphId !== splitParagraphId ? cloneInsertedParagraphWithId(firstInsertParagraph, existingParagraphIds, options.preserveMissingParagraphIds ?? false) : cloneParagraphWithId(firstInsertParagraph, existingParagraphIds, false);
|
|
13740
13656
|
if (options.freshenSplitParagraph && splitRemainderParagraph.paragraphId) splitParagraph.paragraphId = splitRemainderParagraph.paragraphId;
|
|
13741
13657
|
}
|
|
13742
13658
|
for (let i = 0, len = insertParagraphs.length; i < len; i++) {
|
|
@@ -13747,8 +13663,7 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13747
13663
|
continue;
|
|
13748
13664
|
}
|
|
13749
13665
|
if (i !== firstSplitInsertIndex || splitParagraphId == null || shouldPreserveExplicitSplitParagraphId) {
|
|
13750
|
-
|
|
13751
|
-
insertParagraphs[i] = cloneInsertedParagraphWithId(insertParagraphs[i], existingParagraphIds, (_options$preserveMiss2 = options.preserveMissingParagraphIds) !== null && _options$preserveMiss2 !== void 0 ? _options$preserveMiss2 : false);
|
|
13666
|
+
insertParagraphs[i] = cloneInsertedParagraphWithId(insertParagraphs[i], existingParagraphIds, options.preserveMissingParagraphIds ?? false);
|
|
13752
13667
|
continue;
|
|
13753
13668
|
}
|
|
13754
13669
|
insertParagraphs[i] = options.freshenSplitParagraph || firstInsertedParagraphId == null || firstInsertedParagraphId === splitParagraphId ? cloneParagraphWithId({
|
|
@@ -13757,13 +13672,13 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13757
13672
|
}, existingParagraphIds) : splitRemainderParagraph;
|
|
13758
13673
|
}
|
|
13759
13674
|
for (const insertParagraph of insertParagraphs) if (insertParagraph.paragraphId) {
|
|
13760
|
-
var _options$
|
|
13761
|
-
(_options$
|
|
13675
|
+
var _options$reservedPara;
|
|
13676
|
+
(_options$reservedPara = options.reservedParagraphIds) === null || _options$reservedPara === void 0 || _options$reservedPara.add(insertParagraph.paragraphId);
|
|
13762
13677
|
}
|
|
13763
13678
|
}
|
|
13764
13679
|
function collectParagraphIds(paragraphs) {
|
|
13765
13680
|
const paragraphIds = /* @__PURE__ */ new Set();
|
|
13766
|
-
for (const paragraph of paragraphs
|
|
13681
|
+
for (const paragraph of paragraphs ?? []) if (paragraph.paragraphId) paragraphIds.add(paragraph.paragraphId);
|
|
13767
13682
|
return paragraphIds;
|
|
13768
13683
|
}
|
|
13769
13684
|
function cloneInsertedParagraphWithId(insertParagraph, existingParagraphIds, preserveMissingParagraphIds) {
|
|
@@ -13804,9 +13719,9 @@ function getFirstInsertedParagraphIndex(insertParagraphs) {
|
|
|
13804
13719
|
return index;
|
|
13805
13720
|
}
|
|
13806
13721
|
function insertSectionBreaks(body, insertBody, textLength, currentIndex) {
|
|
13807
|
-
var _insertBody$sectionBr
|
|
13722
|
+
var _insertBody$sectionBr;
|
|
13808
13723
|
if (!body.sectionBreaks && !((_insertBody$sectionBr = insertBody.sectionBreaks) === null || _insertBody$sectionBr === void 0 ? void 0 : _insertBody$sectionBr.length)) return;
|
|
13809
|
-
|
|
13724
|
+
body.sectionBreaks ??= [];
|
|
13810
13725
|
const { sectionBreaks } = body;
|
|
13811
13726
|
const insertSectionBreaks = insertBody.sectionBreaks;
|
|
13812
13727
|
normalizeInsertedSectionIdsForDocument(sectionBreaks, insertSectionBreaks);
|
|
@@ -13833,9 +13748,8 @@ function insertSectionBreaks(body, insertBody, textLength, currentIndex) {
|
|
|
13833
13748
|
}
|
|
13834
13749
|
}
|
|
13835
13750
|
function normalizeInsertedSectionIdsForDocument(sectionBreaks, insertSectionBreaks, reservedSectionIds = /* @__PURE__ */ new Set()) {
|
|
13836
|
-
var _sectionBreaks$map;
|
|
13837
13751
|
if (!(insertSectionBreaks === null || insertSectionBreaks === void 0 ? void 0 : insertSectionBreaks.length)) return;
|
|
13838
|
-
const existingSectionIds = new Set((
|
|
13752
|
+
const existingSectionIds = new Set((sectionBreaks === null || sectionBreaks === void 0 ? void 0 : sectionBreaks.map((sectionBreak) => sectionBreak.sectionId)) ?? []);
|
|
13839
13753
|
for (const sectionId of reservedSectionIds) existingSectionIds.add(sectionId);
|
|
13840
13754
|
for (let i = 0; i < insertSectionBreaks.length; i++) {
|
|
13841
13755
|
insertSectionBreaks[i] = cloneSectionBreakWithId(insertSectionBreaks[i], existingSectionIds);
|
|
@@ -14889,7 +14803,7 @@ function updateParagraphs(body, updateBody, textLength, currentIndex, coverType)
|
|
|
14889
14803
|
if (updateStartIndex === removeStartIndex) {
|
|
14890
14804
|
splitUpdateParagraphs.push({
|
|
14891
14805
|
startIndex: updateStartIndex,
|
|
14892
|
-
paragraphId: updateParagraphId
|
|
14806
|
+
paragraphId: updateParagraphId ?? removeParagraphId,
|
|
14893
14807
|
paragraphStyle: newParagraphStyle,
|
|
14894
14808
|
bullet: newBullet
|
|
14895
14809
|
});
|
|
@@ -15159,7 +15073,7 @@ function isSegmentIntersects(start, end, start2, end2) {
|
|
|
15159
15073
|
}
|
|
15160
15074
|
function getParagraphsInRange(activeRange, paragraphs, dataStream, paragraphRanges) {
|
|
15161
15075
|
const { startOffset, endOffset } = activeRange;
|
|
15162
|
-
const fullParagraphs = paragraphRanges
|
|
15076
|
+
const fullParagraphs = paragraphRanges ?? transformParagraphs(paragraphs, dataStream);
|
|
15163
15077
|
const results = [];
|
|
15164
15078
|
let start = -1;
|
|
15165
15079
|
for (let i = 0; i < fullParagraphs.length; i++) {
|
|
@@ -15207,10 +15121,10 @@ function transformParagraphs(paragraphs, dataStream) {
|
|
|
15207
15121
|
//#endregion
|
|
15208
15122
|
//#region src/docs/data-model/text-x/build-utils/paragraph.ts
|
|
15209
15123
|
const switchParagraphBullet = (params) => {
|
|
15210
|
-
var _docDataModel$getSelf
|
|
15124
|
+
var _docDataModel$getSelf;
|
|
15211
15125
|
const { paragraphs: currentParagraphs, segmentId, document: docDataModel } = params;
|
|
15212
15126
|
let listType = params.listType;
|
|
15213
|
-
const paragraphs = (_docDataModel$getSelf =
|
|
15127
|
+
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) ?? [];
|
|
15214
15128
|
const isAlreadyList = currentParagraphs.every((paragraph) => {
|
|
15215
15129
|
var _paragraph$bullet;
|
|
15216
15130
|
return ((_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType.indexOf(listType)) === 0;
|
|
@@ -15232,7 +15146,6 @@ const switchParagraphBullet = (params) => {
|
|
|
15232
15146
|
memoryCursor.reset();
|
|
15233
15147
|
const textX = new TextX();
|
|
15234
15148
|
for (const paragraph of currentParagraphs) {
|
|
15235
|
-
var _bullet$nestingLevel;
|
|
15236
15149
|
const { startIndex, paragraphId, paragraphStyle = {}, bullet } = paragraph;
|
|
15237
15150
|
textX.push({
|
|
15238
15151
|
t: "r",
|
|
@@ -15252,7 +15165,7 @@ const switchParagraphBullet = (params) => {
|
|
|
15252
15165
|
paragraphId,
|
|
15253
15166
|
paragraphStyle: { ...paragraphStyle },
|
|
15254
15167
|
bullet: {
|
|
15255
|
-
nestingLevel: (
|
|
15168
|
+
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15256
15169
|
textStyle: { fs: 20 },
|
|
15257
15170
|
listType,
|
|
15258
15171
|
listId
|
|
@@ -15266,9 +15179,9 @@ const switchParagraphBullet = (params) => {
|
|
|
15266
15179
|
return textX;
|
|
15267
15180
|
};
|
|
15268
15181
|
const toggleChecklistParagraph = (params) => {
|
|
15269
|
-
var _docDataModel$
|
|
15182
|
+
var _docDataModel$getSelf2;
|
|
15270
15183
|
const { paragraphIndex, segmentId, document: docDataModel } = params;
|
|
15271
|
-
const paragraphs = (_docDataModel$
|
|
15184
|
+
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;
|
|
15272
15185
|
if (paragraphs == null) return false;
|
|
15273
15186
|
const currentParagraph = paragraphs.find((p) => p.startIndex === paragraphIndex);
|
|
15274
15187
|
if (!(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet) || currentParagraph.bullet.listType.indexOf("CHECK_LIST") === -1) return false;
|
|
@@ -15302,15 +15215,14 @@ const toggleChecklistParagraph = (params) => {
|
|
|
15302
15215
|
return textX;
|
|
15303
15216
|
};
|
|
15304
15217
|
const setParagraphBullet = (params) => {
|
|
15305
|
-
var _docDataModel$
|
|
15218
|
+
var _docDataModel$getSelf3;
|
|
15306
15219
|
const { paragraphs: currentParagraphs, listType, listId: explicitListId, segmentId, document: docDataModel } = params;
|
|
15307
|
-
if (((_docDataModel$
|
|
15308
|
-
const listId = explicitListId
|
|
15220
|
+
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;
|
|
15221
|
+
const listId = explicitListId ?? generateRandomId(6);
|
|
15309
15222
|
const memoryCursor = new MemoryCursor();
|
|
15310
15223
|
memoryCursor.reset();
|
|
15311
15224
|
const textX = new TextX();
|
|
15312
15225
|
for (const paragraph of currentParagraphs) {
|
|
15313
|
-
var _bullet$nestingLevel2;
|
|
15314
15226
|
const { startIndex, paragraphId, paragraphStyle = {}, bullet } = paragraph;
|
|
15315
15227
|
textX.push({
|
|
15316
15228
|
t: "r",
|
|
@@ -15326,7 +15238,7 @@ const setParagraphBullet = (params) => {
|
|
|
15326
15238
|
paragraphId,
|
|
15327
15239
|
paragraphStyle,
|
|
15328
15240
|
bullet: {
|
|
15329
|
-
nestingLevel: (
|
|
15241
|
+
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15330
15242
|
textStyle: (bullet === null || bullet === void 0 ? void 0 : bullet.listType) === listType ? bullet.textStyle : { fs: 20 },
|
|
15331
15243
|
listType,
|
|
15332
15244
|
listId
|
|
@@ -15361,17 +15273,15 @@ const PARAGRAPH_CONTAINER_TOKENS = /* @__PURE__ */ new Set([
|
|
|
15361
15273
|
""
|
|
15362
15274
|
]);
|
|
15363
15275
|
function getParagraphContentStartOffset(body, paragraph) {
|
|
15364
|
-
var _body$paragraphs;
|
|
15365
15276
|
let previousParagraph;
|
|
15366
|
-
for (const candidate of
|
|
15277
|
+
for (const candidate of body.paragraphs ?? []) if (candidate.startIndex < paragraph.startIndex && (!previousParagraph || candidate.startIndex > previousParagraph.startIndex)) previousParagraph = candidate;
|
|
15367
15278
|
let startOffset = previousParagraph ? previousParagraph.startIndex + 1 : 0;
|
|
15368
15279
|
while (startOffset < paragraph.startIndex && PARAGRAPH_CONTAINER_TOKENS.has(body.dataStream[startOffset])) startOffset++;
|
|
15369
15280
|
return startOffset;
|
|
15370
15281
|
}
|
|
15371
15282
|
function getParagraphContentStartOffsets(body) {
|
|
15372
|
-
var _body$paragraphs2;
|
|
15373
15283
|
const startOffsets = /* @__PURE__ */ new Map();
|
|
15374
|
-
const paragraphs = [...
|
|
15284
|
+
const paragraphs = [...body.paragraphs ?? []].sort((left, right) => left.startIndex - right.startIndex);
|
|
15375
15285
|
for (let index = 0; index < paragraphs.length; index++) {
|
|
15376
15286
|
const paragraph = paragraphs[index];
|
|
15377
15287
|
let startOffset = index > 0 ? paragraphs[index - 1].startIndex + 1 : 0;
|
|
@@ -15381,21 +15291,20 @@ function getParagraphContentStartOffsets(body) {
|
|
|
15381
15291
|
return startOffsets;
|
|
15382
15292
|
}
|
|
15383
15293
|
function getParagraphFollowingBlockOffset(body, paragraph) {
|
|
15384
|
-
|
|
15385
|
-
const containingBlock = ((_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []).find((blockRange) => {
|
|
15294
|
+
const containingBlock = (body.blockRanges ?? []).find((blockRange) => {
|
|
15386
15295
|
const interval = getBlockRangeInterval(blockRange);
|
|
15387
15296
|
return paragraph.startIndex > interval.startOffset && paragraph.startIndex < interval.endOffset - 1;
|
|
15388
15297
|
});
|
|
15389
15298
|
return containingBlock ? getBlockRangeInterval(containingBlock).endOffset : paragraph.startIndex + 1;
|
|
15390
15299
|
}
|
|
15391
15300
|
const changeParagraphBulletNestLevel = (params) => {
|
|
15392
|
-
var _docDataModel$
|
|
15301
|
+
var _docDataModel$getBody;
|
|
15393
15302
|
const { paragraphs: currentParagraphs, document: docDataModel, type } = params;
|
|
15394
15303
|
const memoryCursor = new MemoryCursor();
|
|
15395
15304
|
memoryCursor.reset();
|
|
15396
15305
|
const textX = new TextX();
|
|
15397
|
-
const customLists =
|
|
15398
|
-
const tables = (_docDataModel$getBody =
|
|
15306
|
+
const customLists = docDataModel.getSnapshot().lists ?? {};
|
|
15307
|
+
const tables = ((_docDataModel$getBody = docDataModel.getBody()) === null || _docDataModel$getBody === void 0 ? void 0 : _docDataModel$getBody.tables) ?? [];
|
|
15399
15308
|
const lists = {
|
|
15400
15309
|
...PRESET_LIST_TYPE,
|
|
15401
15310
|
...customLists
|
|
@@ -15436,13 +15345,13 @@ const changeParagraphBulletNestLevel = (params) => {
|
|
|
15436
15345
|
return textX;
|
|
15437
15346
|
};
|
|
15438
15347
|
const setParagraphStyle = (params) => {
|
|
15439
|
-
var _segment$getBody
|
|
15348
|
+
var _segment$getBody, _segment$getBody2;
|
|
15440
15349
|
const { textRanges, segmentId, document: docDataModel, style, paragraphTextRun, cursor, deleteLen, textX: _textX } = params;
|
|
15441
15350
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15442
|
-
const currentParagraphs = getParagraphsInRanges(textRanges, (
|
|
15351
|
+
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) ?? "");
|
|
15443
15352
|
const memoryCursor = new MemoryCursor();
|
|
15444
15353
|
if (cursor) memoryCursor.moveCursorTo(cursor);
|
|
15445
|
-
const textX = _textX
|
|
15354
|
+
const textX = _textX ?? new TextX();
|
|
15446
15355
|
currentParagraphs.sort((a, b) => a.startIndex - b.startIndex);
|
|
15447
15356
|
const start = Math.max(0, currentParagraphs[0].paragraphStart - 1);
|
|
15448
15357
|
if (start > memoryCursor.cursor) {
|
|
@@ -15606,8 +15515,7 @@ function getParagraphsSlice(body, startOffset, endOffset, type = 1) {
|
|
|
15606
15515
|
const sortedParagraphs = [...paragraphs].sort((a, b) => a.startIndex - b.startIndex);
|
|
15607
15516
|
const paragraphStartOffsets = getParagraphContentStartOffsets(body);
|
|
15608
15517
|
for (const paragraph of sortedParagraphs) {
|
|
15609
|
-
|
|
15610
|
-
const paragraphStart = (_paragraphStartOffset = paragraphStartOffsets.get(paragraph.startIndex)) !== null && _paragraphStartOffset !== void 0 ? _paragraphStartOffset : 0;
|
|
15518
|
+
const paragraphStart = paragraphStartOffsets.get(paragraph.startIndex) ?? 0;
|
|
15611
15519
|
const paragraphEnd = paragraph.startIndex;
|
|
15612
15520
|
if (paragraphEnd >= startOffset && paragraphEnd < endOffset || Math.max(paragraphStart, startOffset) < Math.min(paragraphEnd, endOffset)) {
|
|
15613
15521
|
const copy = Tools.deepClone(paragraph);
|
|
@@ -15758,11 +15666,11 @@ function getCustomDecorationSlice(body, startOffset, endOffset) {
|
|
|
15758
15666
|
return customDecorationSlice;
|
|
15759
15667
|
}
|
|
15760
15668
|
function composeTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
15761
|
-
if (updateDataTextRuns == null || originTextRuns == null) return updateDataTextRuns
|
|
15669
|
+
if (updateDataTextRuns == null || originTextRuns == null) return updateDataTextRuns ?? originTextRuns;
|
|
15762
15670
|
return coverTextRuns(updateDataTextRuns, originTextRuns, coverType);
|
|
15763
15671
|
}
|
|
15764
15672
|
function composeCustomRanges(updateDataCustomRanges, originCustomRanges, coverType) {
|
|
15765
|
-
if (updateDataCustomRanges == null || originCustomRanges == null) return updateDataCustomRanges
|
|
15673
|
+
if (updateDataCustomRanges == null || originCustomRanges == null) return updateDataCustomRanges ?? originCustomRanges;
|
|
15766
15674
|
if (originCustomRanges.length === 0 || updateDataCustomRanges.length === 0) return updateDataCustomRanges;
|
|
15767
15675
|
if (originCustomRanges.length > 1 || updateDataCustomRanges.length > 1) throw new Error("Cannot cover multiple customRanges");
|
|
15768
15676
|
if (coverType === 1) return [{ ...updateDataCustomRanges[0] }];
|
|
@@ -15799,7 +15707,7 @@ function composeBody(thisBody, otherBody, coverType = 0) {
|
|
|
15799
15707
|
const { startIndex: thisStart } = thisParagraph;
|
|
15800
15708
|
const { startIndex: otherStart } = otherParagraph;
|
|
15801
15709
|
if (thisStart === otherStart) {
|
|
15802
|
-
paragraphs.push(
|
|
15710
|
+
paragraphs.push(merge(thisParagraph, otherParagraph));
|
|
15803
15711
|
thisIndex++;
|
|
15804
15712
|
otherIndex++;
|
|
15805
15713
|
} else if (thisStart < otherStart) {
|
|
@@ -16242,7 +16150,7 @@ function transformBlockRanges(thisBlockRanges, otherBlockRanges, priority) {
|
|
|
16242
16150
|
if (!otherBlockRanges.length) return [];
|
|
16243
16151
|
return otherBlockRanges.map((otherBlockRange) => {
|
|
16244
16152
|
const thisBlockRange = thisBlockRanges.find((blockRange) => blockRange.blockId === otherBlockRange.blockId);
|
|
16245
|
-
return thisBlockRange && priority ?
|
|
16153
|
+
return thisBlockRange && priority ? merge(otherBlockRange, thisBlockRange) : otherBlockRange;
|
|
16246
16154
|
});
|
|
16247
16155
|
}
|
|
16248
16156
|
|
|
@@ -16591,7 +16499,7 @@ const isEmptyDocument = (dataStream) => {
|
|
|
16591
16499
|
return getPlainText(dataStream).replaceAll("\r", "") === "";
|
|
16592
16500
|
};
|
|
16593
16501
|
const fromPlainText = (text) => {
|
|
16594
|
-
const dataStream = text.replace(/\n/g, "\r");
|
|
16502
|
+
const dataStream = text.replace(/\r\n?|\n/g, "\r");
|
|
16595
16503
|
const paragraphs = [];
|
|
16596
16504
|
const existingParagraphIds = /* @__PURE__ */ new Set();
|
|
16597
16505
|
const customRanges = [];
|
|
@@ -16667,18 +16575,16 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16667
16575
|
throw new Error("Method not implemented.");
|
|
16668
16576
|
}
|
|
16669
16577
|
constructor(snapshot) {
|
|
16670
|
-
var _this$snapshot$title;
|
|
16671
16578
|
super();
|
|
16672
16579
|
_defineProperty(this, "type", UniverInstanceType.UNIVER_DOC);
|
|
16673
16580
|
_defineProperty(this, "_name$", new BehaviorSubject(""));
|
|
16674
16581
|
_defineProperty(this, "name$", this._name$.asObservable());
|
|
16675
16582
|
_defineProperty(this, "snapshot", void 0);
|
|
16676
16583
|
this.snapshot = createDocumentSnapshot(snapshot);
|
|
16677
|
-
this._name$.next(
|
|
16584
|
+
this._name$.next(this.snapshot.title ?? "No Title");
|
|
16678
16585
|
}
|
|
16679
16586
|
getRev() {
|
|
16680
|
-
|
|
16681
|
-
return (_this$snapshot$rev = this.snapshot.rev) !== null && _this$snapshot$rev !== void 0 ? _this$snapshot$rev : 1;
|
|
16587
|
+
return this.snapshot.rev ?? 1;
|
|
16682
16588
|
}
|
|
16683
16589
|
incrementRev() {
|
|
16684
16590
|
this.snapshot.rev = this.getRev() + 1;
|
|
@@ -16714,8 +16620,7 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16714
16620
|
return this.snapshot;
|
|
16715
16621
|
}
|
|
16716
16622
|
getBulletPresetList() {
|
|
16717
|
-
|
|
16718
|
-
const customLists = (_this$snapshot$lists = this.snapshot.lists) !== null && _this$snapshot$lists !== void 0 ? _this$snapshot$lists : {};
|
|
16623
|
+
const customLists = this.snapshot.lists ?? {};
|
|
16719
16624
|
return {
|
|
16720
16625
|
...PRESET_LIST_TYPE,
|
|
16721
16626
|
...customLists
|
|
@@ -16754,8 +16659,8 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16754
16659
|
const { documentStyle } = this.snapshot;
|
|
16755
16660
|
if (!documentStyle.pageSize) {
|
|
16756
16661
|
documentStyle.pageSize = {
|
|
16757
|
-
width: width
|
|
16758
|
-
height: height
|
|
16662
|
+
width: width ?? Number.POSITIVE_INFINITY,
|
|
16663
|
+
height: height ?? Number.POSITIVE_INFINITY
|
|
16759
16664
|
};
|
|
16760
16665
|
return;
|
|
16761
16666
|
}
|
|
@@ -16789,16 +16694,15 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
16789
16694
|
};
|
|
16790
16695
|
var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple {
|
|
16791
16696
|
constructor(snapshot) {
|
|
16792
|
-
var _this$snapshot$id, _this$snapshot$title2;
|
|
16793
16697
|
super(Tools.isEmptyObject(snapshot) ? getEmptySnapshot$1() : snapshot);
|
|
16794
16698
|
_defineProperty(this, "_unitId", void 0);
|
|
16795
16699
|
_defineProperty(this, "headerModelMap", /* @__PURE__ */ new Map());
|
|
16796
16700
|
_defineProperty(this, "footerModelMap", /* @__PURE__ */ new Map());
|
|
16797
16701
|
_defineProperty(this, "change$", new BehaviorSubject(0));
|
|
16798
16702
|
const UNIT_ID_LENGTH = 6;
|
|
16799
|
-
this._unitId =
|
|
16703
|
+
this._unitId = this.snapshot.id ?? generateRandomId(UNIT_ID_LENGTH);
|
|
16800
16704
|
this._initializeHeaderFooterModel();
|
|
16801
|
-
this._name$.next(
|
|
16705
|
+
this._name$.next(this.snapshot.title ?? "");
|
|
16802
16706
|
}
|
|
16803
16707
|
dispose() {
|
|
16804
16708
|
super.dispose();
|
|
@@ -16876,8 +16780,8 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
16876
16780
|
this._unitId = unitId;
|
|
16877
16781
|
}
|
|
16878
16782
|
getPlainText() {
|
|
16879
|
-
var _this$getBody
|
|
16880
|
-
return getPlainText((
|
|
16783
|
+
var _this$getBody;
|
|
16784
|
+
return getPlainText(((_this$getBody = this.getBody()) === null || _this$getBody === void 0 ? void 0 : _this$getBody.dataStream) ?? "");
|
|
16881
16785
|
}
|
|
16882
16786
|
};
|
|
16883
16787
|
|
|
@@ -16885,16 +16789,36 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
16885
16789
|
//#region src/docs/data-model/paragraph-style.ts
|
|
16886
16790
|
function _definedStyle(style) {
|
|
16887
16791
|
if (style == null) return {};
|
|
16888
|
-
|
|
16792
|
+
const definedStyle = Tools.deepClone(style);
|
|
16793
|
+
Tools.removeNull(definedStyle);
|
|
16794
|
+
return definedStyle;
|
|
16795
|
+
}
|
|
16796
|
+
function _resolveNamedParagraphStyle(styles, styleId) {
|
|
16797
|
+
if (!styles || !styleId) return {};
|
|
16798
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
16799
|
+
const resolve = (currentStyleId) => {
|
|
16800
|
+
if (visiting.has(currentStyleId)) return {};
|
|
16801
|
+
const style = styles[currentStyleId];
|
|
16802
|
+
if (!style || style.type !== 1) return {};
|
|
16803
|
+
visiting.add(currentStyleId);
|
|
16804
|
+
const base = style.basedOn ? resolve(style.basedOn) : {};
|
|
16805
|
+
visiting.delete(currentStyleId);
|
|
16806
|
+
return {
|
|
16807
|
+
...base,
|
|
16808
|
+
..._definedStyle(style.paragraphStyle)
|
|
16809
|
+
};
|
|
16810
|
+
};
|
|
16811
|
+
return resolve(styleId);
|
|
16889
16812
|
}
|
|
16890
16813
|
function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options = {}) {
|
|
16891
|
-
|
|
16814
|
+
const legacyStyle = options.useLegacyModernDefaults ?? (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 2 ? {
|
|
16815
|
+
lineSpacing: DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
|
|
16816
|
+
spaceAbove: { v: 0 },
|
|
16817
|
+
spaceBelow: { v: 12 }
|
|
16818
|
+
} : {};
|
|
16892
16819
|
const documentDefaults = {
|
|
16893
|
-
...(
|
|
16894
|
-
|
|
16895
|
-
spaceAbove: { v: 0 },
|
|
16896
|
-
spaceBelow: { v: 12 }
|
|
16897
|
-
} : {},
|
|
16820
|
+
...(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1 ? { widowControl: 1 } : {},
|
|
16821
|
+
...legacyStyle,
|
|
16898
16822
|
..._definedStyle(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.defaultParagraphStyle)
|
|
16899
16823
|
};
|
|
16900
16824
|
if (options.excludeDocumentOuterSpacing) {
|
|
@@ -16902,10 +16826,13 @@ function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options =
|
|
|
16902
16826
|
delete documentDefaults.spaceBelow;
|
|
16903
16827
|
}
|
|
16904
16828
|
const definedParagraphStyle = _definedStyle(paragraphStyle);
|
|
16905
|
-
const
|
|
16829
|
+
const referencedParagraphStyle = _resolveNamedParagraphStyle(options.styles, options.paragraphStyleId);
|
|
16830
|
+
const namedStyleType = definedParagraphStyle.namedStyleType ?? referencedParagraphStyle.namedStyleType;
|
|
16831
|
+
const namedStyle = namedStyleType == null ? null : NAMED_STYLE_SPACE_MAP[namedStyleType];
|
|
16906
16832
|
return Tools.deepClone({
|
|
16907
16833
|
...documentDefaults,
|
|
16908
16834
|
...namedStyle,
|
|
16835
|
+
...referencedParagraphStyle,
|
|
16909
16836
|
...definedParagraphStyle
|
|
16910
16837
|
});
|
|
16911
16838
|
}
|
|
@@ -17066,10 +16993,10 @@ function getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeTy
|
|
|
17066
16993
|
return relativeCustomRanges;
|
|
17067
16994
|
}
|
|
17068
16995
|
function getSelectionForAddCustomRange(range, body) {
|
|
17069
|
-
var
|
|
17070
|
-
const ranges = getIntersectingCustomRanges(range.startOffset, range.collapsed ? range.startOffset : range.endOffset - 1,
|
|
17071
|
-
const startOffset = Math.min(range.startOffset, (
|
|
17072
|
-
const endOffset = Math.max(range.endOffset, ((
|
|
16996
|
+
var _ranges$, _ranges;
|
|
16997
|
+
const ranges = getIntersectingCustomRanges(range.startOffset, range.collapsed ? range.startOffset : range.endOffset - 1, body.customRanges ?? []);
|
|
16998
|
+
const startOffset = Math.min(range.startOffset, ((_ranges$ = ranges[0]) === null || _ranges$ === void 0 ? void 0 : _ranges$.startIndex) ?? Infinity);
|
|
16999
|
+
const endOffset = Math.max(range.endOffset, (((_ranges = ranges[ranges.length - 1]) === null || _ranges === void 0 ? void 0 : _ranges.endIndex) ?? -Infinity) + 1);
|
|
17073
17000
|
return {
|
|
17074
17001
|
startOffset,
|
|
17075
17002
|
endOffset,
|
|
@@ -17080,7 +17007,7 @@ function getSelectionForAddCustomRange(range, body) {
|
|
|
17080
17007
|
//#endregion
|
|
17081
17008
|
//#region src/docs/data-model/text-x/build-utils/text-x-utils.ts
|
|
17082
17009
|
function deleteCustomRangeTextX(params) {
|
|
17083
|
-
var _documentDataModel$ge
|
|
17010
|
+
var _documentDataModel$ge;
|
|
17084
17011
|
const { rangeId, segmentId, documentDataModel, insert } = params;
|
|
17085
17012
|
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);
|
|
17086
17013
|
if (!range) return false;
|
|
@@ -17104,7 +17031,7 @@ function deleteCustomRangeTextX(params) {
|
|
|
17104
17031
|
body: insert,
|
|
17105
17032
|
len: insert.dataStream.length
|
|
17106
17033
|
});
|
|
17107
|
-
const end = endIndex + 1 + ((
|
|
17034
|
+
const end = endIndex + 1 + ((insert === null || insert === void 0 ? void 0 : insert.dataStream.length) ?? 0);
|
|
17108
17035
|
textX.selections = [{
|
|
17109
17036
|
startOffset: end,
|
|
17110
17037
|
endOffset: end,
|
|
@@ -17118,17 +17045,16 @@ function addCustomRangeTextX(param) {
|
|
|
17118
17045
|
const textX = new TextX();
|
|
17119
17046
|
let changed = false;
|
|
17120
17047
|
ranges.forEach((range) => {
|
|
17121
|
-
var _body$customRanges, _body$paragraphs, _body$customBlocks;
|
|
17122
17048
|
const actualRange = getSelectionForAddCustomRange(range, body);
|
|
17123
17049
|
if (!actualRange) return false;
|
|
17124
17050
|
if (!body) return false;
|
|
17125
17051
|
const { startOffset, endOffset } = actualRange;
|
|
17126
|
-
const customRanges =
|
|
17052
|
+
const customRanges = body.customRanges ?? [];
|
|
17127
17053
|
const addCustomRange = (startIndex, endIndex, index) => {
|
|
17128
|
-
var _relativeCustomRanges, _relativeCustomRanges2
|
|
17054
|
+
var _relativeCustomRanges, _relativeCustomRanges2;
|
|
17129
17055
|
const relativeCustomRanges = getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeType);
|
|
17130
|
-
const rangeStartIndex = Math.min((_relativeCustomRanges =
|
|
17131
|
-
const rangeEndIndex = Math.max((
|
|
17056
|
+
const rangeStartIndex = Math.min(((_relativeCustomRanges = relativeCustomRanges[0]) === null || _relativeCustomRanges === void 0 ? void 0 : _relativeCustomRanges.startIndex) ?? Infinity, startIndex);
|
|
17057
|
+
const rangeEndIndex = Math.max(((_relativeCustomRanges2 = relativeCustomRanges[relativeCustomRanges.length - 1]) === null || _relativeCustomRanges2 === void 0 ? void 0 : _relativeCustomRanges2.endIndex) ?? -Infinity, endIndex);
|
|
17132
17058
|
const customRange = {
|
|
17133
17059
|
rangeId: index ? `${rangeId}$${index}` : rangeId,
|
|
17134
17060
|
rangeType,
|
|
@@ -17152,8 +17078,8 @@ function addCustomRangeTextX(param) {
|
|
|
17152
17078
|
});
|
|
17153
17079
|
cursor = rangeEndIndex + 1;
|
|
17154
17080
|
};
|
|
17155
|
-
const relativeParagraphs = (
|
|
17156
|
-
const customBlocks = (
|
|
17081
|
+
const relativeParagraphs = (body.paragraphs ?? []).filter((p) => p.startIndex < endOffset && p.startIndex > startOffset);
|
|
17082
|
+
const customBlocks = (body.customBlocks ?? []).filter((block) => block.startIndex < endOffset && block.startIndex > startOffset);
|
|
17157
17083
|
excludePointsFromRange([startOffset, endOffset - 1], [...relativeParagraphs.map((p) => p.startIndex), ...customBlocks.map((b) => b.startIndex)]).forEach(([start, end], i) => addCustomRange(start, end, i));
|
|
17158
17084
|
changed = true;
|
|
17159
17085
|
textX.selections = [{
|
|
@@ -17183,8 +17109,7 @@ function protectDeletedColumnBoundaryTokens(body, selections, protectedOffsets)
|
|
|
17183
17109
|
}
|
|
17184
17110
|
}
|
|
17185
17111
|
function protectPartiallyDeletedBlockBoundaryTokens(body, selections, protectedOffsets) {
|
|
17186
|
-
|
|
17187
|
-
for (const blockRange of (_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []) {
|
|
17112
|
+
for (const blockRange of body.blockRanges ?? []) {
|
|
17188
17113
|
const blockInterval = getBlockRangeInterval(blockRange);
|
|
17189
17114
|
if (selections.some((selection) => selection.startOffset <= blockInterval.startOffset && selection.endOffset >= blockInterval.endOffset)) continue;
|
|
17190
17115
|
if (isOffsetDeleted(blockRange.startIndex, selections)) protectedOffsets.add(blockRange.startIndex);
|
|
@@ -17192,8 +17117,7 @@ function protectPartiallyDeletedBlockBoundaryTokens(body, selections, protectedO
|
|
|
17192
17117
|
}
|
|
17193
17118
|
}
|
|
17194
17119
|
function collectBlockTextContainers(body) {
|
|
17195
|
-
|
|
17196
|
-
const blockRanges = [...(_body$blockRanges2 = body.blockRanges) !== null && _body$blockRanges2 !== void 0 ? _body$blockRanges2 : []].sort((left, right) => left.startIndex - right.startIndex);
|
|
17120
|
+
const blockRanges = [...body.blockRanges ?? []].sort((left, right) => left.startIndex - right.startIndex);
|
|
17197
17121
|
const containers = blockRanges.map((blockRange) => {
|
|
17198
17122
|
const atomicRange = getBlockRangeInterval(blockRange);
|
|
17199
17123
|
return {
|
|
@@ -17221,8 +17145,8 @@ function collectBlockTextContainers(body) {
|
|
|
17221
17145
|
}
|
|
17222
17146
|
if (index >= 0) containers[index][key].push(offset);
|
|
17223
17147
|
};
|
|
17224
|
-
(
|
|
17225
|
-
(
|
|
17148
|
+
(body.paragraphs ?? []).forEach((paragraph) => assignPoint(paragraph.startIndex, "paragraphs"));
|
|
17149
|
+
(body.sectionBreaks ?? []).forEach((sectionBreak) => assignPoint(sectionBreak.startIndex, "sectionBreaks"));
|
|
17226
17150
|
return containers;
|
|
17227
17151
|
}
|
|
17228
17152
|
function collectStructuralTextContainers(body) {
|
|
@@ -17275,10 +17199,9 @@ function collectStructuralTextContainers(body) {
|
|
|
17275
17199
|
return containers;
|
|
17276
17200
|
}
|
|
17277
17201
|
function protectRequiredContainerChildren(container, selections, insertBody, insertOffset, protectedOffsets) {
|
|
17278
|
-
var _insertBody$dataStrea;
|
|
17279
17202
|
if (isAtomicContainerDeleted(container, selections)) return;
|
|
17280
17203
|
const insertAppliesToContainer = insertBody && isInsertInContainer(insertOffset, container);
|
|
17281
|
-
const insertDataStream = (
|
|
17204
|
+
const insertDataStream = (insertBody === null || insertBody === void 0 ? void 0 : insertBody.dataStream) ?? "";
|
|
17282
17205
|
const insertHasParagraph = insertDataStream.includes("\r");
|
|
17283
17206
|
const insertHasSectionBreak = insertDataStream.includes("\n");
|
|
17284
17207
|
if (container.require === "paragraph-or-section") {
|
|
@@ -17487,12 +17410,12 @@ const replaceSelectionTextRuns = (params) => {
|
|
|
17487
17410
|
t: "r",
|
|
17488
17411
|
body: isTextRunsEqual(textRunsSlice, oldTextRunsSlice) ? void 0 : {
|
|
17489
17412
|
textRuns: textRunsSlice === null || textRunsSlice === void 0 ? void 0 : textRunsSlice.map((textRun) => {
|
|
17490
|
-
var _textRun$ts, _textRun$
|
|
17413
|
+
var _textRun$ts, _textRun$ts2, _textRun$ts3;
|
|
17491
17414
|
return {
|
|
17492
17415
|
...textRun,
|
|
17493
17416
|
ts: {
|
|
17494
17417
|
...textRun.ts,
|
|
17495
|
-
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((
|
|
17418
|
+
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
|
|
17496
17419
|
}
|
|
17497
17420
|
};
|
|
17498
17421
|
}),
|
|
@@ -17544,7 +17467,7 @@ function getCustomBlockIdsInSelections(body, selections) {
|
|
|
17544
17467
|
return customBlockIds;
|
|
17545
17468
|
}
|
|
17546
17469
|
const addDrawing = (param) => {
|
|
17547
|
-
var _documentDataModel$ge, _documentDataModel$ge2
|
|
17470
|
+
var _documentDataModel$ge, _documentDataModel$ge2;
|
|
17548
17471
|
const { selection, documentDataModel, drawings } = param;
|
|
17549
17472
|
const { collapsed, startOffset, segmentId } = selection;
|
|
17550
17473
|
const textX = new TextX();
|
|
@@ -17552,21 +17475,20 @@ const addDrawing = (param) => {
|
|
|
17552
17475
|
const rawActions = [];
|
|
17553
17476
|
const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
|
|
17554
17477
|
if (!body) return false;
|
|
17555
|
-
const drawingOrderLength = (_documentDataModel$ge2 =
|
|
17478
|
+
const drawingOrderLength = ((_documentDataModel$ge2 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.length) ?? 0;
|
|
17556
17479
|
let removeDrawingLen = 0;
|
|
17557
|
-
const insertOffset = collapsed ? normalizeDrawingInsertOffset(body, startOffset
|
|
17480
|
+
const insertOffset = collapsed ? normalizeDrawingInsertOffset(body, startOffset ?? 0) : startOffset ?? 0;
|
|
17558
17481
|
if (collapsed) {
|
|
17559
17482
|
if (insertOffset > 0) textX.push({
|
|
17560
17483
|
t: "r",
|
|
17561
17484
|
len: insertOffset
|
|
17562
17485
|
});
|
|
17563
17486
|
} else {
|
|
17564
|
-
var _documentDataModel$ge4, _documentDataModel$ge5;
|
|
17565
17487
|
const dos = deleteSelectionTextX([selection], body, 0, null, false);
|
|
17566
17488
|
textX.push(...dos);
|
|
17567
17489
|
const removedCustomBlockIds = getCustomBlockIdsInSelections(body, [selection]);
|
|
17568
|
-
const drawings =
|
|
17569
|
-
const drawingOrder =
|
|
17490
|
+
const drawings = documentDataModel.getDrawings() ?? {};
|
|
17491
|
+
const drawingOrder = documentDataModel.getDrawingsOrder() ?? [];
|
|
17570
17492
|
const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
|
|
17571
17493
|
if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
|
|
17572
17494
|
else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
|
|
@@ -17604,7 +17526,16 @@ const addDrawing = (param) => {
|
|
|
17604
17526
|
}, null);
|
|
17605
17527
|
};
|
|
17606
17528
|
function normalizeDrawingInsertOffset(body, offset) {
|
|
17607
|
-
|
|
17529
|
+
const { dataStream } = body;
|
|
17530
|
+
if (offset === 0 && dataStream[0] === "\r") return 1;
|
|
17531
|
+
if (dataStream[offset] === "\n" && dataStream[offset - 1] === "\r" && isInsideTableCell(dataStream, offset)) return offset - 1;
|
|
17532
|
+
return offset;
|
|
17533
|
+
}
|
|
17534
|
+
function isInsideTableCell(dataStream, offset) {
|
|
17535
|
+
let cellDepth = 0;
|
|
17536
|
+
for (let index = 0; index < offset; index++) if (dataStream[index] === "") cellDepth++;
|
|
17537
|
+
else if (dataStream[index] === "") cellDepth = Math.max(0, cellDepth - 1);
|
|
17538
|
+
return cellDepth > 0;
|
|
17608
17539
|
}
|
|
17609
17540
|
function buildDrawingInsertBody(body, drawings, insertOffset) {
|
|
17610
17541
|
var _body$paragraphs;
|
|
@@ -17684,8 +17615,8 @@ function collectNewStructuralStartOffsets(previousBody, nextBody) {
|
|
|
17684
17615
|
return Array.from(new Set(offsets)).sort((left, right) => left - right);
|
|
17685
17616
|
}
|
|
17686
17617
|
function collectNewStartOffsets(previousItems, nextItems, getId) {
|
|
17687
|
-
const previousIds = new Set((previousItems
|
|
17688
|
-
return (nextItems
|
|
17618
|
+
const previousIds = new Set((previousItems ?? []).map(getId));
|
|
17619
|
+
return (nextItems ?? []).filter((item) => !previousIds.has(getId(item))).map((item) => item.startIndex);
|
|
17689
17620
|
}
|
|
17690
17621
|
|
|
17691
17622
|
//#endregion
|
|
@@ -17779,8 +17710,7 @@ function normalizeBody$1(body) {
|
|
|
17779
17710
|
return body;
|
|
17780
17711
|
}
|
|
17781
17712
|
function normalizeData(data) {
|
|
17782
|
-
|
|
17783
|
-
data.body = normalizeBody$1((_data$body = data.body) !== null && _data$body !== void 0 ? _data$body : { dataStream: "" });
|
|
17713
|
+
data.body = normalizeBody$1(data.body ?? { dataStream: "" });
|
|
17784
17714
|
if (!data.drawingsOrder) data.drawingsOrder = [];
|
|
17785
17715
|
if (!data.drawings) data.drawings = {};
|
|
17786
17716
|
if (!data.documentStyle) data.documentStyle = {};
|
|
@@ -17823,8 +17753,8 @@ function normalizeRichTextParagraphStyle(style) {
|
|
|
17823
17753
|
};
|
|
17824
17754
|
}
|
|
17825
17755
|
function hasRichTextContent(data) {
|
|
17826
|
-
var _data$body
|
|
17827
|
-
return ((_data$body
|
|
17756
|
+
var _data$body;
|
|
17757
|
+
return (((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? "").replace(/\r|\n/g, "").length > 0;
|
|
17828
17758
|
}
|
|
17829
17759
|
/**
|
|
17830
17760
|
* Represents a read-only font style value object.
|
|
@@ -19227,8 +19157,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19227
19157
|
* ```
|
|
19228
19158
|
*/
|
|
19229
19159
|
toPlainText() {
|
|
19230
|
-
var _this$_data$body
|
|
19231
|
-
return BuildTextUtils.transform.getPlainText((
|
|
19160
|
+
var _this$_data$body;
|
|
19161
|
+
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");
|
|
19232
19162
|
}
|
|
19233
19163
|
/**
|
|
19234
19164
|
* Gets the paragraph style of the current RichTextValue instance
|
|
@@ -19266,14 +19196,13 @@ var RichTextValue = class RichTextValue {
|
|
|
19266
19196
|
* ```
|
|
19267
19197
|
*/
|
|
19268
19198
|
getParagraphs() {
|
|
19269
|
-
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
return paragraphs.map((paragraph) => {
|
|
19273
|
-
|
|
19274
|
-
|
|
19275
|
-
|
|
19276
|
-
});
|
|
19199
|
+
const body = this._data.body;
|
|
19200
|
+
if (!body) return [];
|
|
19201
|
+
const startOffsets = getParagraphContentStartOffsets(body);
|
|
19202
|
+
return (body.paragraphs ?? []).map((paragraph) => RichTextBuilder.create(createParagraphSnapshot(this._data, paragraph.paragraphId, {
|
|
19203
|
+
startOffset: startOffsets.get(paragraph.startIndex) ?? 0,
|
|
19204
|
+
endOffset: paragraph.startIndex
|
|
19205
|
+
})));
|
|
19277
19206
|
}
|
|
19278
19207
|
/**
|
|
19279
19208
|
* Gets the text runs of the current RichTextValue instance
|
|
@@ -19285,8 +19214,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19285
19214
|
* ```
|
|
19286
19215
|
*/
|
|
19287
19216
|
getTextRuns() {
|
|
19288
|
-
var _this$_data$
|
|
19289
|
-
return ((
|
|
19217
|
+
var _this$_data$body4;
|
|
19218
|
+
return (((_this$_data$body4 = this._data.body) === null || _this$_data$body4 === void 0 ? void 0 : _this$_data$body4.textRuns) ?? []).map((t) => ({
|
|
19290
19219
|
...t,
|
|
19291
19220
|
ts: t.ts ? TextStyleValue.create(t.ts) : null
|
|
19292
19221
|
}));
|
|
@@ -19301,8 +19230,8 @@ var RichTextValue = class RichTextValue {
|
|
|
19301
19230
|
* ```
|
|
19302
19231
|
*/
|
|
19303
19232
|
getLinks() {
|
|
19304
|
-
var _this$_data$
|
|
19305
|
-
return (
|
|
19233
|
+
var _this$_data$body5;
|
|
19234
|
+
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)) ?? [];
|
|
19306
19235
|
}
|
|
19307
19236
|
/**
|
|
19308
19237
|
* Gets the data of the current RichTextValue instance
|
|
@@ -19358,19 +19287,22 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19358
19287
|
* @returns {RichTextBuilder} A new RichTextBuilder instance
|
|
19359
19288
|
*/
|
|
19360
19289
|
static create(data) {
|
|
19361
|
-
return new RichTextBuilder(data
|
|
19290
|
+
return new RichTextBuilder(data ?? RichTextBuilder.newEmptyData());
|
|
19362
19291
|
}
|
|
19363
19292
|
constructor(data) {
|
|
19364
19293
|
super(data);
|
|
19365
19294
|
_defineProperty(this, "_doc", void 0);
|
|
19366
19295
|
_defineProperty(this, "_trackedRanges", /* @__PURE__ */ new Set());
|
|
19296
|
+
_defineProperty(this, "_childHandleRevision", 0);
|
|
19367
19297
|
this._doc = new DocumentDataModel(data);
|
|
19368
19298
|
}
|
|
19369
19299
|
/**
|
|
19370
19300
|
* Returns editable paragraph handles backed by this detached rich-text builder.
|
|
19371
19301
|
*
|
|
19372
|
-
* Paragraph boundaries come from the document model rather than splitting plain text.
|
|
19373
|
-
*
|
|
19302
|
+
* Paragraph boundaries come from the document model rather than splitting plain text. Handles stay aligned across
|
|
19303
|
+
* edits made through their child run handles, so callers can safely iterate from the first paragraph to the last.
|
|
19304
|
+
* Direct builder edits that change text or run boundaries invalidate previously returned paragraph and run handles;
|
|
19305
|
+
* query them again after calling methods such as `insertText()`, `setStyle()`, `setLink()`, or `delete()`.
|
|
19374
19306
|
*
|
|
19375
19307
|
* @returns Editable paragraphs in document order.
|
|
19376
19308
|
* @example
|
|
@@ -19385,14 +19317,10 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19385
19317
|
* ```
|
|
19386
19318
|
*/
|
|
19387
19319
|
getParagraphs() {
|
|
19388
|
-
var _body$paragraphs;
|
|
19389
19320
|
const body = this._data.body;
|
|
19390
19321
|
if (!body) return [];
|
|
19391
19322
|
const startOffsets = getParagraphContentStartOffsets(body);
|
|
19392
|
-
return (
|
|
19393
|
-
var _startOffsets$get;
|
|
19394
|
-
return this._createParagraphBuilder(paragraph.paragraphId, (_startOffsets$get = startOffsets.get(paragraph.startIndex)) !== null && _startOffsets$get !== void 0 ? _startOffsets$get : 0, paragraph.startIndex);
|
|
19395
|
-
});
|
|
19323
|
+
return (body.paragraphs ?? []).map((paragraph) => this._createParagraphBuilder(paragraph.paragraphId, startOffsets.get(paragraph.startIndex) ?? 0, paragraph.startIndex));
|
|
19396
19324
|
}
|
|
19397
19325
|
/**
|
|
19398
19326
|
* Returns editable text-run handles for all paragraph text in this builder.
|
|
@@ -19416,7 +19344,6 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19416
19344
|
}
|
|
19417
19345
|
/** @internal */
|
|
19418
19346
|
_createTextRunBuilders(range) {
|
|
19419
|
-
var _body$textRuns, _body$customRanges, _body$customDecoratio;
|
|
19420
19347
|
const body = this._data.body;
|
|
19421
19348
|
if (!body || range.startOffset >= range.endOffset) return [];
|
|
19422
19349
|
const boundaries = /* @__PURE__ */ new Set([range.startOffset, range.endOffset]);
|
|
@@ -19428,9 +19355,9 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19428
19355
|
boundaries.add(end);
|
|
19429
19356
|
}
|
|
19430
19357
|
};
|
|
19431
|
-
for (const textRun of
|
|
19432
|
-
for (const customRange of
|
|
19433
|
-
for (const decoration of
|
|
19358
|
+
for (const textRun of body.textRuns ?? []) addRangeBoundaries(textRun.st, textRun.ed);
|
|
19359
|
+
for (const customRange of body.customRanges ?? []) addRangeBoundaries(customRange.startIndex, customRange.endIndex + 1);
|
|
19360
|
+
for (const decoration of body.customDecorations ?? []) addRangeBoundaries(decoration.startIndex, decoration.endIndex + 1);
|
|
19434
19361
|
for (let offset = range.startOffset; offset < range.endOffset; offset++) if (NON_EDITABLE_RICH_TEXT_TOKENS.has(body.dataStream[offset])) {
|
|
19435
19362
|
boundaries.add(offset);
|
|
19436
19363
|
boundaries.add(offset + 1);
|
|
@@ -19438,12 +19365,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19438
19365
|
const offsets = [...boundaries].sort((left, right) => left - right);
|
|
19439
19366
|
const runs = [];
|
|
19440
19367
|
for (let index = 0; index < offsets.length - 1; index++) {
|
|
19441
|
-
var _body$textRuns2;
|
|
19442
19368
|
const startOffset = offsets[index];
|
|
19443
19369
|
const endOffset = offsets[index + 1];
|
|
19444
19370
|
if (startOffset >= endOffset || endOffset - startOffset === 1 && NON_EDITABLE_RICH_TEXT_TOKENS.has(body.dataStream[startOffset])) continue;
|
|
19445
|
-
const sourceRun = (
|
|
19446
|
-
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)));
|
|
19371
|
+
const sourceRun = (body.textRuns ?? []).find((textRun) => textRun.st <= startOffset && textRun.ed >= endOffset);
|
|
19372
|
+
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));
|
|
19447
19373
|
}
|
|
19448
19374
|
return runs;
|
|
19449
19375
|
}
|
|
@@ -19487,7 +19413,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19487
19413
|
this._rebaseTrackedRanges(startOffset, endOffset, text.length);
|
|
19488
19414
|
}
|
|
19489
19415
|
_createParagraphBuilder(paragraphId, startOffset, endOffset) {
|
|
19490
|
-
return new RichTextParagraphBuilder(this, paragraphId, this._trackRange(startOffset, endOffset));
|
|
19416
|
+
return new RichTextParagraphBuilder(this, paragraphId, this._trackRange(startOffset, endOffset), this._childHandleRevision);
|
|
19417
|
+
}
|
|
19418
|
+
/** @internal */
|
|
19419
|
+
_assertChildHandleRevision(revision) {
|
|
19420
|
+
if (revision !== this._childHandleRevision) throw new Error("Rich text child handle is no longer valid.");
|
|
19491
19421
|
}
|
|
19492
19422
|
_trackRange(startOffset, endOffset) {
|
|
19493
19423
|
const range = {
|
|
@@ -19514,6 +19444,10 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19514
19444
|
trackedRange.endOffset = mapEnd(trackedRange.endOffset);
|
|
19515
19445
|
}
|
|
19516
19446
|
}
|
|
19447
|
+
_invalidateChildHandles() {
|
|
19448
|
+
this._childHandleRevision++;
|
|
19449
|
+
this._trackedRanges.clear();
|
|
19450
|
+
}
|
|
19517
19451
|
/**
|
|
19518
19452
|
* Appends plain text to the rich text.
|
|
19519
19453
|
*
|
|
@@ -19554,13 +19488,12 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19554
19488
|
* ```
|
|
19555
19489
|
*/
|
|
19556
19490
|
align(alignment) {
|
|
19557
|
-
|
|
19558
|
-
const
|
|
19559
|
-
const renderConfig = (_documentStyle$render = documentStyle.renderConfig) !== null && _documentStyle$render !== void 0 ? _documentStyle$render : documentStyle.renderConfig = {};
|
|
19491
|
+
const documentStyle = this._data.documentStyle ??= {};
|
|
19492
|
+
const renderConfig = documentStyle.renderConfig ??= {};
|
|
19560
19493
|
if (alignment.horizontal !== void 0) {
|
|
19561
|
-
var _this$_data$
|
|
19494
|
+
var _this$_data$body6;
|
|
19562
19495
|
renderConfig.horizontalAlign = alignment.horizontal;
|
|
19563
|
-
for (const paragraph of (
|
|
19496
|
+
for (const paragraph of ((_this$_data$body6 = this._data.body) === null || _this$_data$body6 === void 0 ? void 0 : _this$_data$body6.paragraphs) ?? []) paragraph.paragraphStyle = {
|
|
19564
19497
|
...paragraph.paragraphStyle,
|
|
19565
19498
|
horizontalAlign: alignment.horizontal
|
|
19566
19499
|
};
|
|
@@ -19600,18 +19533,17 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19600
19533
|
* ```
|
|
19601
19534
|
*/
|
|
19602
19535
|
columns(options) {
|
|
19603
|
-
var _this$_data2, _this$_data2$body, _body$sectionBreaks, _options$spacing;
|
|
19604
19536
|
if (!Number.isInteger(options.count) || options.count < 1) throw new RangeError("Rich text column count must be a positive integer.");
|
|
19605
|
-
const body =
|
|
19606
|
-
const sectionBreaks =
|
|
19537
|
+
const body = this._data.body ??= { dataStream: "\r\n" };
|
|
19538
|
+
const sectionBreaks = body.sectionBreaks ??= [];
|
|
19607
19539
|
if (!sectionBreaks.length) {
|
|
19608
|
-
var _body$dataStream
|
|
19540
|
+
var _body$dataStream;
|
|
19609
19541
|
sectionBreaks.push({
|
|
19610
19542
|
sectionId: createSectionId(/* @__PURE__ */ new Set()),
|
|
19611
|
-
startIndex: Math.max(0, ((
|
|
19543
|
+
startIndex: Math.max(0, (((_body$dataStream = body.dataStream) === null || _body$dataStream === void 0 ? void 0 : _body$dataStream.length) ?? 0) - 1)
|
|
19612
19544
|
});
|
|
19613
19545
|
}
|
|
19614
|
-
const spacing = Math.max(0,
|
|
19546
|
+
const spacing = Math.max(0, options.spacing ?? 0);
|
|
19615
19547
|
const columns = options.count === 1 ? void 0 : Array.from({ length: options.count }, (_, index) => ({
|
|
19616
19548
|
width: 0,
|
|
19617
19549
|
paddingEnd: index === options.count - 1 ? 0 : spacing
|
|
@@ -19621,14 +19553,15 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19621
19553
|
return this;
|
|
19622
19554
|
}
|
|
19623
19555
|
/**
|
|
19624
|
-
* Appends one text span with
|
|
19556
|
+
* Appends one text span with an optional style.
|
|
19625
19557
|
*
|
|
19626
19558
|
* Prefer this method when combining multiple styles, because the style object is local to the inserted text and does
|
|
19627
19559
|
* not leak into following calls.
|
|
19628
19560
|
*
|
|
19629
19561
|
* @param text Text to append.
|
|
19630
|
-
* @param style
|
|
19631
|
-
* `color`, and `background` are supported alongside native
|
|
19562
|
+
* @param style Optional text style for this span. When omitted, the span is appended as unstyled text. Agent-friendly
|
|
19563
|
+
* aliases such as `bold`, `italic`, `fontFamily`, `fontSize`, `color`, and `background` are supported alongside native
|
|
19564
|
+
* document text style fields.
|
|
19632
19565
|
* @returns The current builder for chaining.
|
|
19633
19566
|
* @example
|
|
19634
19567
|
* ```ts
|
|
@@ -19639,18 +19572,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19639
19572
|
*/
|
|
19640
19573
|
span(text, style) {
|
|
19641
19574
|
if (!text) return this;
|
|
19642
|
-
return this.
|
|
19643
|
-
id: "d",
|
|
19644
|
-
documentStyle: {},
|
|
19645
|
-
body: {
|
|
19646
|
-
dataStream: text,
|
|
19647
|
-
textRuns: [{
|
|
19648
|
-
st: 0,
|
|
19649
|
-
ed: text.length,
|
|
19650
|
-
ts: normalizeRichTextSpanStyle(style)
|
|
19651
|
-
}]
|
|
19652
|
-
}
|
|
19653
|
-
}));
|
|
19575
|
+
return style ? this.insertText(text, normalizeRichTextSpanStyle(style)) : this.insertText(text);
|
|
19654
19576
|
}
|
|
19655
19577
|
/**
|
|
19656
19578
|
* Appends bold text.
|
|
@@ -19724,22 +19646,19 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19724
19646
|
* ```
|
|
19725
19647
|
*/
|
|
19726
19648
|
listItem(text, options = {}) {
|
|
19727
|
-
var
|
|
19728
|
-
const listType =
|
|
19729
|
-
const currentParagraph = (_this$_data$
|
|
19649
|
+
var _this$_data$body7, _options$listId, _this$_data$body8;
|
|
19650
|
+
const listType = options.type ?? "BULLET_LIST";
|
|
19651
|
+
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];
|
|
19730
19652
|
const currentBullet = currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet;
|
|
19731
19653
|
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());
|
|
19732
19654
|
if (hasRichTextContent(this._data)) this.paragraph(options.paragraphStyle);
|
|
19733
19655
|
else if (options.paragraphStyle) this.paragraph(options.paragraphStyle);
|
|
19734
|
-
const targetParagraph = (_this$_data$
|
|
19735
|
-
if (targetParagraph) {
|
|
19736
|
-
|
|
19737
|
-
|
|
19738
|
-
|
|
19739
|
-
|
|
19740
|
-
nestingLevel: Math.max(0, Math.trunc((_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 0))
|
|
19741
|
-
};
|
|
19742
|
-
}
|
|
19656
|
+
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];
|
|
19657
|
+
if (targetParagraph) targetParagraph.bullet = {
|
|
19658
|
+
listId,
|
|
19659
|
+
listType,
|
|
19660
|
+
nestingLevel: Math.max(0, Math.trunc(options.level ?? 0))
|
|
19661
|
+
};
|
|
19743
19662
|
return this.text(text);
|
|
19744
19663
|
}
|
|
19745
19664
|
/**
|
|
@@ -19760,20 +19679,20 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19760
19679
|
* ```
|
|
19761
19680
|
*/
|
|
19762
19681
|
paragraph(paragraphStyle) {
|
|
19763
|
-
var _this$_data$
|
|
19682
|
+
var _this$_data$body10, _this$_data$body11, _this$_data$body12;
|
|
19764
19683
|
const nextParagraphStyle = normalizeRichTextParagraphStyle(paragraphStyle);
|
|
19765
19684
|
if (!hasRichTextContent(this._data)) {
|
|
19766
19685
|
if (nextParagraphStyle) {
|
|
19767
|
-
var _this$_data$
|
|
19768
|
-
const firstParagraph = (_this$_data$
|
|
19686
|
+
var _this$_data$body9;
|
|
19687
|
+
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];
|
|
19769
19688
|
if (firstParagraph) firstParagraph.paragraphStyle = nextParagraphStyle;
|
|
19770
19689
|
}
|
|
19771
19690
|
return this;
|
|
19772
19691
|
}
|
|
19773
|
-
const currentParagraph = (_this$_data$
|
|
19692
|
+
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];
|
|
19774
19693
|
const currentParagraphStyle = Tools.deepClone(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.paragraphStyle);
|
|
19775
19694
|
const currentParagraphBullet = Tools.deepClone(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet);
|
|
19776
|
-
const startIndex = Math.max(0, ((
|
|
19695
|
+
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);
|
|
19777
19696
|
this.insertRichText(startIndex, RichTextValue.create({
|
|
19778
19697
|
id: "d",
|
|
19779
19698
|
documentStyle: {},
|
|
@@ -19787,7 +19706,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19787
19706
|
}]
|
|
19788
19707
|
}
|
|
19789
19708
|
}));
|
|
19790
|
-
const nextParagraph = (_this$_data$
|
|
19709
|
+
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];
|
|
19791
19710
|
if (nextParagraphStyle) {
|
|
19792
19711
|
if (nextParagraph) nextParagraph.paragraphStyle = nextParagraphStyle;
|
|
19793
19712
|
} else if (nextParagraph) delete nextParagraph.paragraphStyle;
|
|
@@ -19795,24 +19714,26 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19795
19714
|
return this;
|
|
19796
19715
|
}
|
|
19797
19716
|
insertText(start, text, style) {
|
|
19798
|
-
var _this$_data$
|
|
19799
|
-
let startIndex = ((
|
|
19717
|
+
var _this$_data$body13;
|
|
19718
|
+
let startIndex = (((_this$_data$body13 = this._data.body) === null || _this$_data$body13 === void 0 ? void 0 : _this$_data$body13.dataStream.length) ?? 2) - 2;
|
|
19800
19719
|
let insertText;
|
|
19801
19720
|
let insertStyle;
|
|
19802
19721
|
if (typeof start === "string") insertText = start;
|
|
19803
19722
|
else {
|
|
19804
19723
|
startIndex = Math.min(start, startIndex);
|
|
19805
|
-
insertText = text;
|
|
19724
|
+
insertText = typeof text === "string" ? text : "";
|
|
19806
19725
|
}
|
|
19807
19726
|
if (typeof text === "object") insertStyle = text instanceof TextStyleBuilder ? text.build() : text;
|
|
19808
19727
|
else insertStyle = style instanceof TextStyleBuilder ? style.build() : style;
|
|
19809
19728
|
if (!insertText) return this;
|
|
19729
|
+
const plainTextBody = BuildTextUtils.transform.fromPlainText(insertText);
|
|
19810
19730
|
const newBody = {
|
|
19811
|
-
dataStream:
|
|
19731
|
+
dataStream: plainTextBody.dataStream,
|
|
19732
|
+
paragraphs: plainTextBody.paragraphs,
|
|
19812
19733
|
textRuns: insertStyle ? [{
|
|
19813
19734
|
ts: insertStyle,
|
|
19814
|
-
st:
|
|
19815
|
-
ed:
|
|
19735
|
+
st: 0,
|
|
19736
|
+
ed: plainTextBody.dataStream.length
|
|
19816
19737
|
}] : []
|
|
19817
19738
|
};
|
|
19818
19739
|
const textX = BuildTextUtils.selection.replace({
|
|
@@ -19826,11 +19747,12 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19826
19747
|
});
|
|
19827
19748
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19828
19749
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19750
|
+
this._invalidateChildHandles();
|
|
19829
19751
|
return this;
|
|
19830
19752
|
}
|
|
19831
19753
|
insertRichText(start, richText) {
|
|
19832
|
-
var _this$_data$
|
|
19833
|
-
let startIndex = ((
|
|
19754
|
+
var _this$_data$body14;
|
|
19755
|
+
let startIndex = (((_this$_data$body14 = this._data.body) === null || _this$_data$body14 === void 0 ? void 0 : _this$_data$body14.dataStream.length) ?? 2) - 2;
|
|
19834
19756
|
let insertText;
|
|
19835
19757
|
if (typeof start === "object") insertText = start instanceof RichTextValue ? start.getData() : start;
|
|
19836
19758
|
else {
|
|
@@ -19848,17 +19770,32 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19848
19770
|
});
|
|
19849
19771
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19850
19772
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19773
|
+
this._invalidateChildHandles();
|
|
19851
19774
|
return this;
|
|
19852
19775
|
}
|
|
19853
19776
|
delete(start, count) {
|
|
19854
|
-
|
|
19855
|
-
|
|
19777
|
+
var _this$_data$body15;
|
|
19778
|
+
const terminalTokenLength = "\r".length + "\n".length;
|
|
19779
|
+
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);
|
|
19780
|
+
let startOffset;
|
|
19781
|
+
let deleteCount;
|
|
19782
|
+
if (count === void 0) {
|
|
19783
|
+
if (start < 0) throw new RangeError("Delete count cannot be negative.");
|
|
19784
|
+
deleteCount = Math.min(start, contentLength);
|
|
19785
|
+
startOffset = contentLength - deleteCount;
|
|
19786
|
+
} else {
|
|
19787
|
+
if (start < 0 || count < 0) throw new RangeError("Delete range cannot be negative.");
|
|
19788
|
+
startOffset = Math.min(start, contentLength);
|
|
19789
|
+
deleteCount = Math.min(count, contentLength - startOffset);
|
|
19790
|
+
}
|
|
19791
|
+
if (deleteCount > 0) {
|
|
19856
19792
|
const actions = BuildTextUtils.selection.delete([{
|
|
19857
|
-
startOffset
|
|
19858
|
-
endOffset:
|
|
19793
|
+
startOffset,
|
|
19794
|
+
endOffset: startOffset + deleteCount,
|
|
19859
19795
|
collapsed: true
|
|
19860
19796
|
}], this._data.body);
|
|
19861
19797
|
TextX.apply(this._doc.getBody(), actions);
|
|
19798
|
+
this._invalidateChildHandles();
|
|
19862
19799
|
}
|
|
19863
19800
|
return this;
|
|
19864
19801
|
}
|
|
@@ -19889,6 +19826,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19889
19826
|
collapsed: true
|
|
19890
19827
|
}], newBody);
|
|
19891
19828
|
TextX.apply(this._doc.getBody(), actions);
|
|
19829
|
+
this._invalidateChildHandles();
|
|
19892
19830
|
return this;
|
|
19893
19831
|
}
|
|
19894
19832
|
/**
|
|
@@ -19917,9 +19855,11 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19917
19855
|
});
|
|
19918
19856
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19919
19857
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19858
|
+
this._invalidateChildHandles();
|
|
19920
19859
|
return this;
|
|
19921
19860
|
}
|
|
19922
19861
|
cancelLink(start, end) {
|
|
19862
|
+
let changed = false;
|
|
19923
19863
|
if (typeof start === "string") {
|
|
19924
19864
|
const textX = BuildTextUtils.customRange.delete({
|
|
19925
19865
|
rangeId: start,
|
|
@@ -19927,6 +19867,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19927
19867
|
});
|
|
19928
19868
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19929
19869
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19870
|
+
changed = true;
|
|
19930
19871
|
} else this.slice(start, end).getLinks().forEach((l) => {
|
|
19931
19872
|
const textX = BuildTextUtils.customRange.delete({
|
|
19932
19873
|
rangeId: l.rangeId,
|
|
@@ -19934,7 +19875,9 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19934
19875
|
});
|
|
19935
19876
|
if (!textX) throw new Error("Insert text failed, please check.");
|
|
19936
19877
|
TextX.apply(this._doc.getBody(), textX.serialize());
|
|
19878
|
+
changed = true;
|
|
19937
19879
|
});
|
|
19880
|
+
if (changed) this._invalidateChildHandles();
|
|
19938
19881
|
return this;
|
|
19939
19882
|
}
|
|
19940
19883
|
updateLink(id, url) {
|
|
@@ -19948,7 +19891,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19948
19891
|
let newBody;
|
|
19949
19892
|
let startIndex;
|
|
19950
19893
|
if (typeof start === "object") {
|
|
19951
|
-
var _this$_data$
|
|
19894
|
+
var _this$_data$body17;
|
|
19952
19895
|
newBody = {
|
|
19953
19896
|
dataStream: "\r",
|
|
19954
19897
|
paragraphs: [{
|
|
@@ -19957,7 +19900,7 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
19957
19900
|
paragraphStyle: start.build()
|
|
19958
19901
|
}]
|
|
19959
19902
|
};
|
|
19960
|
-
startIndex = ((
|
|
19903
|
+
startIndex = (((_this$_data$body17 = this._data.body) === null || _this$_data$body17 === void 0 ? void 0 : _this$_data$body17.dataStream.length) ?? 2) - 2;
|
|
19961
19904
|
} else {
|
|
19962
19905
|
startIndex = start;
|
|
19963
19906
|
newBody = {
|
|
@@ -20007,18 +19950,21 @@ var RichTextBuilder = class RichTextBuilder extends RichTextValue {
|
|
|
20007
19950
|
*/
|
|
20008
19951
|
var RichTextParagraphBuilder = class extends RichTextValue {
|
|
20009
19952
|
/** @hideconstructor */
|
|
20010
|
-
constructor(_owner, _paragraphId, _range) {
|
|
19953
|
+
constructor(_owner, _paragraphId, _range, _revision) {
|
|
20011
19954
|
super(createParagraphSnapshot(_owner.getData(), _paragraphId, _range));
|
|
20012
19955
|
this._owner = _owner;
|
|
20013
19956
|
this._paragraphId = _paragraphId;
|
|
20014
19957
|
this._range = _range;
|
|
19958
|
+
this._revision = _revision;
|
|
20015
19959
|
}
|
|
20016
19960
|
/** Returns the persisted paragraph id. */
|
|
20017
19961
|
getId() {
|
|
19962
|
+
this._assertActive();
|
|
20018
19963
|
return this._paragraphId;
|
|
20019
19964
|
}
|
|
20020
19965
|
/** Returns the current paragraph range without its trailing paragraph marker. */
|
|
20021
19966
|
getRange() {
|
|
19967
|
+
this._assertActive();
|
|
20022
19968
|
return { ...this._range };
|
|
20023
19969
|
}
|
|
20024
19970
|
/**
|
|
@@ -20031,8 +19977,9 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20031
19977
|
* ```
|
|
20032
19978
|
*/
|
|
20033
19979
|
getText() {
|
|
20034
|
-
var _this$_owner$getData
|
|
20035
|
-
|
|
19980
|
+
var _this$_owner$getData$;
|
|
19981
|
+
this._assertActive();
|
|
19982
|
+
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);
|
|
20036
19983
|
}
|
|
20037
19984
|
toPlainText() {
|
|
20038
19985
|
return this.getText();
|
|
@@ -20042,34 +19989,42 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20042
19989
|
* @returns Editable text runs in document order.
|
|
20043
19990
|
*/
|
|
20044
19991
|
getTextRuns() {
|
|
19992
|
+
this._assertActive();
|
|
20045
19993
|
return this._owner._createTextRunBuilders(this._range);
|
|
20046
19994
|
}
|
|
20047
19995
|
getParagraphStyle() {
|
|
19996
|
+
this._assertActive();
|
|
20048
19997
|
return ParagraphStyleValue.create(this._getParagraph().paragraphStyle);
|
|
20049
19998
|
}
|
|
20050
19999
|
getParagraphBullet() {
|
|
20000
|
+
this._assertActive();
|
|
20051
20001
|
return this._getParagraph().bullet;
|
|
20052
20002
|
}
|
|
20053
20003
|
getLinks() {
|
|
20054
|
-
var _this$getData$body
|
|
20055
|
-
|
|
20004
|
+
var _this$getData$body;
|
|
20005
|
+
this._assertActive();
|
|
20006
|
+
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)) ?? [];
|
|
20056
20007
|
}
|
|
20057
20008
|
/** Agent-friendly alias of `getParagraphBullet()`. */
|
|
20058
20009
|
getBullet() {
|
|
20059
20010
|
return this.getParagraphBullet();
|
|
20060
20011
|
}
|
|
20061
20012
|
getData() {
|
|
20013
|
+
this._assertActive();
|
|
20062
20014
|
return createParagraphSnapshot(this._owner.getData(), this._paragraphId, this._range);
|
|
20063
20015
|
}
|
|
20064
20016
|
copy() {
|
|
20065
20017
|
return RichTextBuilder.create(Tools.deepClone(this.getData()));
|
|
20066
20018
|
}
|
|
20067
20019
|
_getParagraph() {
|
|
20068
|
-
var _this$_owner$getData$
|
|
20069
|
-
const paragraph = (_this$_owner$getData$
|
|
20020
|
+
var _this$_owner$getData$2;
|
|
20021
|
+
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);
|
|
20070
20022
|
if (!paragraph) throw new Error(`Rich text paragraph "${this._paragraphId}" was not found.`);
|
|
20071
20023
|
return paragraph;
|
|
20072
20024
|
}
|
|
20025
|
+
_assertActive() {
|
|
20026
|
+
this._owner._assertChildHandleRevision(this._revision);
|
|
20027
|
+
}
|
|
20073
20028
|
};
|
|
20074
20029
|
/**
|
|
20075
20030
|
* An editable text-run handle owned by a detached {@link RichTextBuilder}.
|
|
@@ -20079,38 +20034,45 @@ var RichTextParagraphBuilder = class extends RichTextValue {
|
|
|
20079
20034
|
*/
|
|
20080
20035
|
var RichTextRunBuilder = class {
|
|
20081
20036
|
/** @hideconstructor */
|
|
20082
|
-
constructor(_owner, _range, _textStyle, _styleId, _hasExplicitTextStyle) {
|
|
20037
|
+
constructor(_owner, _range, _textStyle, _styleId, _hasExplicitTextStyle, _revision) {
|
|
20083
20038
|
this._owner = _owner;
|
|
20084
20039
|
this._range = _range;
|
|
20085
20040
|
this._textStyle = _textStyle;
|
|
20086
20041
|
this._styleId = _styleId;
|
|
20087
20042
|
this._hasExplicitTextStyle = _hasExplicitTextStyle;
|
|
20043
|
+
this._revision = _revision;
|
|
20088
20044
|
_defineProperty(this, "_active", true);
|
|
20089
20045
|
}
|
|
20090
20046
|
/** Inclusive start offset, kept for compatibility with existing `getTextRuns()` callers. */
|
|
20091
20047
|
get st() {
|
|
20048
|
+
this._assertActive();
|
|
20092
20049
|
return this._range.startOffset;
|
|
20093
20050
|
}
|
|
20094
20051
|
/** Exclusive end offset, automatically updated after text replacement. */
|
|
20095
20052
|
get ed() {
|
|
20053
|
+
this._assertActive();
|
|
20096
20054
|
return this._range.endOffset;
|
|
20097
20055
|
}
|
|
20098
20056
|
/** Optional persisted style id. This is not a stable run identity. */
|
|
20099
20057
|
get sId() {
|
|
20058
|
+
this._assertActive();
|
|
20100
20059
|
return this._styleId;
|
|
20101
20060
|
}
|
|
20102
20061
|
/** Existing text-style value property exposed by `getTextRuns()`. */
|
|
20103
20062
|
get ts() {
|
|
20063
|
+
this._assertActive();
|
|
20104
20064
|
return this._textStyle ? TextStyleValue.create(this._textStyle) : null;
|
|
20105
20065
|
}
|
|
20106
20066
|
/** Returns the current run range. */
|
|
20107
20067
|
getRange() {
|
|
20068
|
+
this._assertActive();
|
|
20108
20069
|
return { ...this._range };
|
|
20109
20070
|
}
|
|
20110
20071
|
/** Returns the current run text. */
|
|
20111
20072
|
getText() {
|
|
20112
|
-
var _this$_owner$getData$
|
|
20113
|
-
|
|
20073
|
+
var _this$_owner$getData$3;
|
|
20074
|
+
this._assertActive();
|
|
20075
|
+
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);
|
|
20114
20076
|
}
|
|
20115
20077
|
/** Returns this run's explicit text style, or `null` for an unstyled text segment. */
|
|
20116
20078
|
getTextStyle() {
|
|
@@ -20118,6 +20080,7 @@ var RichTextRunBuilder = class {
|
|
|
20118
20080
|
}
|
|
20119
20081
|
/** Returns whether this segment is backed by an explicit document text run. */
|
|
20120
20082
|
hasTextStyle() {
|
|
20083
|
+
this._assertActive();
|
|
20121
20084
|
return this._hasExplicitTextStyle;
|
|
20122
20085
|
}
|
|
20123
20086
|
/**
|
|
@@ -20145,17 +20108,21 @@ var RichTextRunBuilder = class {
|
|
|
20145
20108
|
* ```
|
|
20146
20109
|
*/
|
|
20147
20110
|
setText(text) {
|
|
20148
|
-
|
|
20111
|
+
this._assertActive();
|
|
20149
20112
|
this._owner._replaceTextRun(this._range, text, this._textStyle, this._styleId, this._hasExplicitTextStyle);
|
|
20150
20113
|
if (!text) this._active = false;
|
|
20151
20114
|
return this;
|
|
20152
20115
|
}
|
|
20116
|
+
_assertActive() {
|
|
20117
|
+
if (!this._active) throw new Error("Rich text run handle is no longer valid.");
|
|
20118
|
+
this._owner._assertChildHandleRevision(this._revision);
|
|
20119
|
+
}
|
|
20153
20120
|
};
|
|
20154
20121
|
function createParagraphSnapshot(data, paragraphId, range) {
|
|
20155
|
-
var _body$
|
|
20122
|
+
var _body$paragraphs;
|
|
20156
20123
|
const { body, ...documentData } = data;
|
|
20157
20124
|
if (!body) throw new Error("Rich text body is not available.");
|
|
20158
|
-
const paragraph = (_body$
|
|
20125
|
+
const paragraph = (_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.find((item) => item.paragraphId === paragraphId);
|
|
20159
20126
|
if (!paragraph) throw new Error(`Rich text paragraph "${paragraphId}" was not found.`);
|
|
20160
20127
|
const paragraphBody = getBodySlice(body, range.startOffset, range.endOffset);
|
|
20161
20128
|
paragraphBody.paragraphs = [{
|
|
@@ -20202,13 +20169,9 @@ function validateMinimumRootSentinels(body, issues, context) {
|
|
|
20202
20169
|
if (!body.dataStream.includes("\n")) issues.push(createIssue(context, "missing-root-section-break", "Document body must contain at least one section break sentinel."));
|
|
20203
20170
|
}
|
|
20204
20171
|
function validateParagraphMetadata(body, issues, context) {
|
|
20205
|
-
var _body$paragraphs;
|
|
20206
20172
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20207
|
-
for (const paragraph of
|
|
20208
|
-
else
|
|
20209
|
-
var _metadataCounts$get;
|
|
20210
|
-
metadataCounts.set(paragraph.startIndex, ((_metadataCounts$get = metadataCounts.get(paragraph.startIndex)) !== null && _metadataCounts$get !== void 0 ? _metadataCounts$get : 0) + 1);
|
|
20211
|
-
}
|
|
20173
|
+
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));
|
|
20174
|
+
else metadataCounts.set(paragraph.startIndex, (metadataCounts.get(paragraph.startIndex) ?? 0) + 1);
|
|
20212
20175
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20213
20176
|
context,
|
|
20214
20177
|
duplicateCode: "duplicate-paragraph-metadata",
|
|
@@ -20216,20 +20179,13 @@ function validateParagraphMetadata(body, issues, context) {
|
|
|
20216
20179
|
}, issues);
|
|
20217
20180
|
}
|
|
20218
20181
|
function validateSectionBreakMetadata(body, issues, context) {
|
|
20219
|
-
var _body$sectionBreaks;
|
|
20220
20182
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20221
20183
|
const sectionIds = /* @__PURE__ */ new Map();
|
|
20222
|
-
for (const sectionBreak of
|
|
20184
|
+
for (const sectionBreak of body.sectionBreaks ?? []) {
|
|
20223
20185
|
if (!sectionBreak.sectionId) issues.push(createIssue(context, "missing-section-id", "Section break metadata must have a stable section id.", sectionBreak.startIndex));
|
|
20224
|
-
else
|
|
20225
|
-
var _sectionIds$get;
|
|
20226
|
-
sectionIds.set(sectionBreak.sectionId, ((_sectionIds$get = sectionIds.get(sectionBreak.sectionId)) !== null && _sectionIds$get !== void 0 ? _sectionIds$get : 0) + 1);
|
|
20227
|
-
}
|
|
20186
|
+
else sectionIds.set(sectionBreak.sectionId, (sectionIds.get(sectionBreak.sectionId) ?? 0) + 1);
|
|
20228
20187
|
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));
|
|
20229
|
-
else
|
|
20230
|
-
var _metadataCounts$get2;
|
|
20231
|
-
metadataCounts.set(sectionBreak.startIndex, ((_metadataCounts$get2 = metadataCounts.get(sectionBreak.startIndex)) !== null && _metadataCounts$get2 !== void 0 ? _metadataCounts$get2 : 0) + 1);
|
|
20232
|
-
}
|
|
20188
|
+
else metadataCounts.set(sectionBreak.startIndex, (metadataCounts.get(sectionBreak.startIndex) ?? 0) + 1);
|
|
20233
20189
|
}
|
|
20234
20190
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20235
20191
|
context,
|
|
@@ -20258,11 +20214,10 @@ function collectPairedTokenRanges(dataStream, startToken, endToken, exclusiveEnd
|
|
|
20258
20214
|
};
|
|
20259
20215
|
}
|
|
20260
20216
|
function validateTableMetadata(body, issues, context) {
|
|
20261
|
-
var _body$tables;
|
|
20262
20217
|
const pairedTables = collectPairedTokenRanges(body.dataStream, "", "", true).pairs;
|
|
20263
20218
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20264
20219
|
let previousTable;
|
|
20265
|
-
const tables = [...
|
|
20220
|
+
const tables = [...body.tables ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20266
20221
|
for (const table of tables) {
|
|
20267
20222
|
metadataStarts.add(table.startIndex);
|
|
20268
20223
|
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));
|
|
@@ -20273,10 +20228,9 @@ function validateTableMetadata(body, issues, context) {
|
|
|
20273
20228
|
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));
|
|
20274
20229
|
}
|
|
20275
20230
|
function validateBlockRangeMetadata(body, issues, context) {
|
|
20276
|
-
var _body$blockRanges;
|
|
20277
20231
|
const pairedBlocks = collectPairedTokenRanges(body.dataStream, "", "", false);
|
|
20278
20232
|
for (const index of [...pairedBlocks.unmatchedStarts, ...pairedBlocks.unmatchedEnds]) issues.push(createIssue(context, "unbalanced-block", "Block sentinel has no matching boundary.", index));
|
|
20279
|
-
const blockRanges = [...
|
|
20233
|
+
const blockRanges = [...body.blockRanges ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20280
20234
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20281
20235
|
let previousBlockRange;
|
|
20282
20236
|
for (let i = 0; i < blockRanges.length; i++) {
|
|
@@ -20289,10 +20243,9 @@ function validateBlockRangeMetadata(body, issues, context) {
|
|
|
20289
20243
|
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));
|
|
20290
20244
|
}
|
|
20291
20245
|
function validateColumnGroupMetadata(body, issues, context) {
|
|
20292
|
-
var _body$columnGroups;
|
|
20293
20246
|
const pairedColumnGroups = collectPairedTokenRanges(body.dataStream, "", "", false).pairs;
|
|
20294
20247
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20295
|
-
const columnGroups = [...
|
|
20248
|
+
const columnGroups = [...body.columnGroups ?? []].sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20296
20249
|
let previousColumnGroup;
|
|
20297
20250
|
for (const columnGroup of columnGroups) {
|
|
20298
20251
|
metadataStarts.add(columnGroup.startIndex);
|
|
@@ -20302,7 +20255,7 @@ function validateColumnGroupMetadata(body, issues, context) {
|
|
|
20302
20255
|
previousColumnGroup = columnGroup;
|
|
20303
20256
|
if (Array.isArray(columnGroup.columns)) {
|
|
20304
20257
|
let streamColumnCount = 0;
|
|
20305
|
-
const scanEnd = pairedEndIndex
|
|
20258
|
+
const scanEnd = pairedEndIndex ?? columnGroup.endIndex;
|
|
20306
20259
|
for (let index = columnGroup.startIndex + 1; index < scanEnd; index++) if (body.dataStream[index] === "") streamColumnCount++;
|
|
20307
20260
|
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));
|
|
20308
20261
|
}
|
|
@@ -20310,16 +20263,14 @@ function validateColumnGroupMetadata(body, issues, context) {
|
|
|
20310
20263
|
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));
|
|
20311
20264
|
}
|
|
20312
20265
|
function validateCustomBlockMetadata(body, issues, context) {
|
|
20313
|
-
var _body$customBlocks;
|
|
20314
20266
|
const metadataCounts = /* @__PURE__ */ new Map();
|
|
20315
|
-
for (const customBlock of
|
|
20316
|
-
var _metadataCounts$get3;
|
|
20267
|
+
for (const customBlock of body.customBlocks ?? []) {
|
|
20317
20268
|
const { startIndex } = customBlock;
|
|
20318
20269
|
if (!Number.isInteger(startIndex) || body.dataStream[startIndex] !== "\b") {
|
|
20319
20270
|
issues.push(createIssue(context, "custom-block-token-mismatch", "Custom block startIndex must point to a custom block sentinel.", startIndex));
|
|
20320
20271
|
continue;
|
|
20321
20272
|
}
|
|
20322
|
-
metadataCounts.set(startIndex, (
|
|
20273
|
+
metadataCounts.set(startIndex, (metadataCounts.get(startIndex) ?? 0) + 1);
|
|
20323
20274
|
}
|
|
20324
20275
|
validatePointMetadataDuplicates(metadataCounts, {
|
|
20325
20276
|
context,
|
|
@@ -20394,14 +20345,13 @@ function validateDocBodyStructure(body, context = { segmentType: "body" }) {
|
|
|
20394
20345
|
return issues;
|
|
20395
20346
|
}
|
|
20396
20347
|
function validateDocumentStructure(snapshot) {
|
|
20397
|
-
var _snapshot$headers, _snapshot$footers;
|
|
20398
20348
|
const issues = [];
|
|
20399
20349
|
if (snapshot.body) issues.push(...validateDocBodyStructure(snapshot.body, { segmentType: "body" }));
|
|
20400
|
-
for (const [headerId, header] of Object.entries(
|
|
20350
|
+
for (const [headerId, header] of Object.entries(snapshot.headers ?? {})) issues.push(...validateDocBodyStructure(header.body, {
|
|
20401
20351
|
segmentType: "header",
|
|
20402
20352
|
segmentId: headerId
|
|
20403
20353
|
}));
|
|
20404
|
-
for (const [footerId, footer] of Object.entries(
|
|
20354
|
+
for (const [footerId, footer] of Object.entries(snapshot.footers ?? {})) issues.push(...validateDocBodyStructure(footer.body, {
|
|
20405
20355
|
segmentType: "footer",
|
|
20406
20356
|
segmentId: footerId
|
|
20407
20357
|
}));
|
|
@@ -20512,10 +20462,7 @@ var EventSubject = class extends Subject {
|
|
|
20512
20462
|
else ob = observer;
|
|
20513
20463
|
const subscription = super.subscribe(ob);
|
|
20514
20464
|
this._sortedObservers.push(ob);
|
|
20515
|
-
this._sortedObservers.sort((a, b) =>
|
|
20516
|
-
var _a$priority, _b$priority;
|
|
20517
|
-
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);
|
|
20518
|
-
});
|
|
20465
|
+
this._sortedObservers.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
20519
20466
|
subscription.add(() => this._sortedObservers = this._sortedObservers.filter((o) => o !== ob));
|
|
20520
20467
|
return subscription;
|
|
20521
20468
|
}
|
|
@@ -21017,8 +20964,6 @@ const FOCUSING_SHEET = "FOCUSING_SHEET";
|
|
|
21017
20964
|
const FOCUSING_DOC = "FOCUSING_DOC";
|
|
21018
20965
|
const FOCUSING_SLIDE = "FOCUSING_SLIDE";
|
|
21019
20966
|
const FOCUSING_BOARD = "FOCUSING_BOARD";
|
|
21020
|
-
/** @deprecated */
|
|
21021
|
-
const FOCUSING_EDITOR_BUT_HIDDEN = "FOCUSING_EDITOR_BUT_HIDDEN";
|
|
21022
20967
|
const EDITOR_ACTIVATED = "EDITOR_ACTIVATED";
|
|
21023
20968
|
const FOCUSING_EDITOR_INPUT_FORMULA = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
21024
20969
|
/** The focusing state of the formula editor (Fx bar). */
|
|
@@ -21226,13 +21171,12 @@ const getDefaultBaselineOffset = (fontSize) => ({
|
|
|
21226
21171
|
spo: fontSize
|
|
21227
21172
|
});
|
|
21228
21173
|
function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
21229
|
-
var _paddingData$t, _paddingData$r, _paddingData$b, _paddingData$l;
|
|
21230
21174
|
const contentLength = content.length;
|
|
21231
21175
|
const { textRotation, paddingData, horizontalAlign = 0, verticalAlign = 0, wrapStrategy = 0, cellValueType } = config;
|
|
21232
|
-
const marginTop = (
|
|
21233
|
-
const marginRight = (
|
|
21234
|
-
const marginBottom = (
|
|
21235
|
-
const marginLeft = (
|
|
21176
|
+
const marginTop = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.t) ?? DEFAULT_PADDING_DATA.t;
|
|
21177
|
+
const marginRight = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.r) ?? DEFAULT_PADDING_DATA.r;
|
|
21178
|
+
const marginBottom = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.b) ?? DEFAULT_PADDING_DATA.b;
|
|
21179
|
+
const marginLeft = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.l) ?? DEFAULT_PADDING_DATA.l;
|
|
21236
21180
|
const { vertexAngle, centerAngle } = convertTextRotation(textRotation);
|
|
21237
21181
|
return new DocumentDataModel({
|
|
21238
21182
|
id: "d",
|
|
@@ -21412,214 +21356,22 @@ function convertTextRotation(textRotation) {
|
|
|
21412
21356
|
}
|
|
21413
21357
|
|
|
21414
21358
|
//#endregion
|
|
21415
|
-
//#region src/sheets/
|
|
21359
|
+
//#region src/sheets/column-manager.ts
|
|
21416
21360
|
/**
|
|
21417
|
-
*
|
|
21418
|
-
* Avoids type checking overhead when we know the structure.
|
|
21361
|
+
* Manage configuration information of all columns, get column width, column length, set column width, etc.
|
|
21419
21362
|
*/
|
|
21420
|
-
|
|
21421
|
-
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
const result = new Array(len);
|
|
21426
|
-
for (let i = 0; i < len; i++) result[i] = cloneValue(value[i]);
|
|
21427
|
-
return result;
|
|
21363
|
+
var ColumnManager = class {
|
|
21364
|
+
constructor(_config, data) {
|
|
21365
|
+
this._config = _config;
|
|
21366
|
+
_defineProperty(this, "_columnData", {});
|
|
21367
|
+
this._columnData = data;
|
|
21428
21368
|
}
|
|
21429
|
-
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
21434
|
-
|
|
21435
|
-
return result;
|
|
21436
|
-
}
|
|
21437
|
-
/**
|
|
21438
|
-
* Fast clone for ICellData. Optimized for the known structure.
|
|
21439
|
-
* @param cell - The cell data to clone
|
|
21440
|
-
* @returns A deep clone of the cell data
|
|
21441
|
-
*/
|
|
21442
|
-
function cloneCellData(cell) {
|
|
21443
|
-
if (cell === null || cell === void 0) return cell;
|
|
21444
|
-
const result = {};
|
|
21445
|
-
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
21446
|
-
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
21447
|
-
else result.s = cloneValue(cell.s);
|
|
21448
|
-
if (cell.v !== void 0) result.v = cell.v;
|
|
21449
|
-
if (cell.t !== void 0) result.t = cell.t;
|
|
21450
|
-
if (cell.f !== void 0) result.f = cell.f;
|
|
21451
|
-
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
21452
|
-
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
21453
|
-
if (cell.si !== void 0) result.si = cell.si;
|
|
21454
|
-
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
21455
|
-
return result;
|
|
21456
|
-
}
|
|
21457
|
-
/**
|
|
21458
|
-
* Fast clone for ICellDataWithSpanAndDisplay. Optimized for the known structure.
|
|
21459
|
-
* This extends cloneCellData with additional span and display properties.
|
|
21460
|
-
* @param cell - The cell data with span and display info to clone
|
|
21461
|
-
* @returns A deep clone of the cell data
|
|
21462
|
-
*/
|
|
21463
|
-
function cloneCellDataWithSpanAndDisplay(cell) {
|
|
21464
|
-
if (cell === null || cell === void 0) return cell;
|
|
21465
|
-
const result = {};
|
|
21466
|
-
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
21467
|
-
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
21468
|
-
else result.s = cloneValue(cell.s);
|
|
21469
|
-
if (cell.v !== void 0) result.v = cell.v;
|
|
21470
|
-
if (cell.t !== void 0) result.t = cell.t;
|
|
21471
|
-
if (cell.f !== void 0) result.f = cell.f;
|
|
21472
|
-
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
21473
|
-
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
21474
|
-
if (cell.si !== void 0) result.si = cell.si;
|
|
21475
|
-
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
21476
|
-
if (cell.rowSpan !== void 0) result.rowSpan = cell.rowSpan;
|
|
21477
|
-
if (cell.colSpan !== void 0) result.colSpan = cell.colSpan;
|
|
21478
|
-
if (cell.displayV !== void 0) result.displayV = cell.displayV;
|
|
21479
|
-
return result;
|
|
21480
|
-
}
|
|
21481
|
-
/**
|
|
21482
|
-
* Fast clone for cell data matrix. Optimized for sparse matrix structure.
|
|
21483
|
-
* @param cellData - The cell data matrix to clone
|
|
21484
|
-
* @returns A deep clone of the cell data matrix
|
|
21485
|
-
*/
|
|
21486
|
-
function cloneCellDataMatrix(cellData) {
|
|
21487
|
-
const result = {};
|
|
21488
|
-
const rowKeys = Object.keys(cellData);
|
|
21489
|
-
for (let i = 0, rowLen = rowKeys.length; i < rowLen; i++) {
|
|
21490
|
-
const rowKey = rowKeys[i];
|
|
21491
|
-
const rowNum = Number(rowKey);
|
|
21492
|
-
const rowData = cellData[rowNum];
|
|
21493
|
-
if (rowData === void 0) continue;
|
|
21494
|
-
const clonedRow = {};
|
|
21495
|
-
const colKeys = Object.keys(rowData);
|
|
21496
|
-
for (let j = 0, colLen = colKeys.length; j < colLen; j++) {
|
|
21497
|
-
const colKey = colKeys[j];
|
|
21498
|
-
const colNum = Number(colKey);
|
|
21499
|
-
const cell = rowData[colNum];
|
|
21500
|
-
if (cell !== void 0 && cell !== null) clonedRow[colNum] = cloneCellData(cell);
|
|
21501
|
-
}
|
|
21502
|
-
result[rowNum] = clonedRow;
|
|
21503
|
-
}
|
|
21504
|
-
return result;
|
|
21505
|
-
}
|
|
21506
|
-
/**
|
|
21507
|
-
* Fast clone for row/column data arrays (sparse arrays stored as objects).
|
|
21508
|
-
* @param data - The row or column data to clone
|
|
21509
|
-
* @returns A deep clone of the row or column data
|
|
21510
|
-
*/
|
|
21511
|
-
function cloneRowColumnData(data) {
|
|
21512
|
-
const result = {};
|
|
21513
|
-
const keys = Object.keys(data);
|
|
21514
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
21515
|
-
const key = keys[i];
|
|
21516
|
-
const idx = Number(key);
|
|
21517
|
-
const item = data[idx];
|
|
21518
|
-
if (item === void 0) continue;
|
|
21519
|
-
const cloned = {};
|
|
21520
|
-
if ("h" in item && item.h !== void 0) cloned.h = item.h;
|
|
21521
|
-
if ("ia" in item && item.ia !== void 0) cloned.ia = item.ia;
|
|
21522
|
-
if ("ah" in item && item.ah !== void 0) cloned.ah = item.ah;
|
|
21523
|
-
if ("hd" in item && item.hd !== void 0) cloned.hd = item.hd;
|
|
21524
|
-
if ("w" in item && item.w !== void 0) cloned.w = item.w;
|
|
21525
|
-
if ("s" in item && item.s !== void 0) if (item.s === null || typeof item.s === "string") cloned.s = item.s;
|
|
21526
|
-
else cloned.s = cloneValue(item.s);
|
|
21527
|
-
if ("custom" in item && item.custom !== void 0) cloned.custom = item.custom === null ? null : cloneValue(item.custom);
|
|
21528
|
-
result[idx] = cloned;
|
|
21529
|
-
}
|
|
21530
|
-
return result;
|
|
21531
|
-
}
|
|
21532
|
-
/**
|
|
21533
|
-
* Fast clone for IRange array (merge data).
|
|
21534
|
-
* @param ranges - The array of ranges to clone
|
|
21535
|
-
* @returns A shallow clone of the ranges (IRange contains only primitive values)
|
|
21536
|
-
*/
|
|
21537
|
-
function cloneMergeData(ranges) {
|
|
21538
|
-
const len = ranges.length;
|
|
21539
|
-
const result = new Array(len);
|
|
21540
|
-
for (let i = 0; i < len; i++) {
|
|
21541
|
-
const range = ranges[i];
|
|
21542
|
-
result[i] = {
|
|
21543
|
-
startRow: range.startRow,
|
|
21544
|
-
startColumn: range.startColumn,
|
|
21545
|
-
endRow: range.endRow,
|
|
21546
|
-
endColumn: range.endColumn,
|
|
21547
|
-
rangeType: range.rangeType,
|
|
21548
|
-
startAbsoluteRefType: range.startAbsoluteRefType,
|
|
21549
|
-
endAbsoluteRefType: range.endAbsoluteRefType
|
|
21550
|
-
};
|
|
21551
|
-
}
|
|
21552
|
-
return result;
|
|
21553
|
-
}
|
|
21554
|
-
/**
|
|
21555
|
-
* Optimized deep clone specifically for IWorksheetData.
|
|
21556
|
-
* This is significantly faster than generic deepClone because:
|
|
21557
|
-
* 1. No recursive type checking - we know the structure
|
|
21558
|
-
* 2. Direct property access instead of Object.keys iteration for known properties
|
|
21559
|
-
* 3. Specialized handlers for cellData matrix (the largest data)
|
|
21560
|
-
* 4. Primitive values copied directly without cloning
|
|
21561
|
-
*
|
|
21562
|
-
* @param worksheet - The worksheet data to clone
|
|
21563
|
-
* @returns A deep clone of the worksheet data
|
|
21564
|
-
*/
|
|
21565
|
-
function cloneWorksheetData(worksheet) {
|
|
21566
|
-
const result = {
|
|
21567
|
-
id: worksheet.id,
|
|
21568
|
-
name: worksheet.name,
|
|
21569
|
-
tabColor: worksheet.tabColor,
|
|
21570
|
-
hidden: worksheet.hidden,
|
|
21571
|
-
rowCount: worksheet.rowCount,
|
|
21572
|
-
columnCount: worksheet.columnCount,
|
|
21573
|
-
zoomRatio: worksheet.zoomRatio,
|
|
21574
|
-
scrollTop: worksheet.scrollTop,
|
|
21575
|
-
scrollLeft: worksheet.scrollLeft,
|
|
21576
|
-
defaultColumnWidth: worksheet.defaultColumnWidth,
|
|
21577
|
-
defaultRowHeight: worksheet.defaultRowHeight,
|
|
21578
|
-
showGridlines: worksheet.showGridlines,
|
|
21579
|
-
rightToLeft: worksheet.rightToLeft,
|
|
21580
|
-
freeze: {
|
|
21581
|
-
xSplit: worksheet.freeze.xSplit,
|
|
21582
|
-
ySplit: worksheet.freeze.ySplit,
|
|
21583
|
-
startRow: worksheet.freeze.startRow,
|
|
21584
|
-
startColumn: worksheet.freeze.startColumn
|
|
21585
|
-
},
|
|
21586
|
-
rowHeader: {
|
|
21587
|
-
width: worksheet.rowHeader.width,
|
|
21588
|
-
hidden: worksheet.rowHeader.hidden
|
|
21589
|
-
},
|
|
21590
|
-
columnHeader: {
|
|
21591
|
-
height: worksheet.columnHeader.height,
|
|
21592
|
-
hidden: worksheet.columnHeader.hidden
|
|
21593
|
-
},
|
|
21594
|
-
mergeData: cloneMergeData(worksheet.mergeData),
|
|
21595
|
-
cellData: cloneCellDataMatrix(worksheet.cellData),
|
|
21596
|
-
rowData: cloneRowColumnData(worksheet.rowData),
|
|
21597
|
-
columnData: cloneRowColumnData(worksheet.columnData)
|
|
21598
|
-
};
|
|
21599
|
-
if (worksheet.gridlinesColor !== void 0) result.gridlinesColor = worksheet.gridlinesColor;
|
|
21600
|
-
if (worksheet.defaultStyle !== void 0) if (worksheet.defaultStyle === null || typeof worksheet.defaultStyle === "string") result.defaultStyle = worksheet.defaultStyle;
|
|
21601
|
-
else result.defaultStyle = cloneValue(worksheet.defaultStyle);
|
|
21602
|
-
if (worksheet.custom !== void 0) result.custom = worksheet.custom === null ? null : cloneValue(worksheet.custom);
|
|
21603
|
-
return result;
|
|
21604
|
-
}
|
|
21605
|
-
|
|
21606
|
-
//#endregion
|
|
21607
|
-
//#region src/sheets/column-manager.ts
|
|
21608
|
-
/**
|
|
21609
|
-
* Manage configuration information of all columns, get column width, column length, set column width, etc.
|
|
21610
|
-
*/
|
|
21611
|
-
var ColumnManager = class {
|
|
21612
|
-
constructor(_config, data) {
|
|
21613
|
-
this._config = _config;
|
|
21614
|
-
_defineProperty(this, "_columnData", {});
|
|
21615
|
-
this._columnData = data;
|
|
21616
|
-
}
|
|
21617
|
-
/**
|
|
21618
|
-
* Get width and hidden status of columns in the sheet
|
|
21619
|
-
* @returns {IObjectArrayPrimitiveType<Partial<IColumnData>>} Column data, including width, hidden status, etc.
|
|
21620
|
-
*/
|
|
21621
|
-
getColumnData() {
|
|
21622
|
-
return this._columnData;
|
|
21369
|
+
/**
|
|
21370
|
+
* Get width and hidden status of columns in the sheet
|
|
21371
|
+
* @returns {IObjectArrayPrimitiveType<Partial<IColumnData>>} Column data, including width, hidden status, etc.
|
|
21372
|
+
*/
|
|
21373
|
+
getColumnData() {
|
|
21374
|
+
return this._columnData;
|
|
21623
21375
|
}
|
|
21624
21376
|
getColVisible(colPos) {
|
|
21625
21377
|
const { _columnData } = this;
|
|
@@ -21719,8 +21471,7 @@ var ColumnManager = class {
|
|
|
21719
21471
|
const columnData = {};
|
|
21720
21472
|
let index = 0;
|
|
21721
21473
|
for (let i = columnPos; i < columnPos + numColumns; i++) {
|
|
21722
|
-
|
|
21723
|
-
columnData[index] = data !== null && data !== void 0 ? data : {
|
|
21474
|
+
columnData[index] = this.getColumn(i) ?? {
|
|
21724
21475
|
w: this._config.defaultColumnWidth,
|
|
21725
21476
|
hd: 0
|
|
21726
21477
|
};
|
|
@@ -21741,8 +21492,8 @@ var ColumnManager = class {
|
|
|
21741
21492
|
* @returns {number} width of column
|
|
21742
21493
|
*/
|
|
21743
21494
|
getColumnWidth(columnPos) {
|
|
21744
|
-
var _this$_columnData$col2
|
|
21745
|
-
return (_this$_columnData$col2 =
|
|
21495
|
+
var _this$_columnData$col2;
|
|
21496
|
+
return ((_this$_columnData$col2 = this._columnData[columnPos]) === null || _this$_columnData$col2 === void 0 ? void 0 : _this$_columnData$col2.w) ?? this._config.defaultColumnWidth;
|
|
21746
21497
|
}
|
|
21747
21498
|
/**
|
|
21748
21499
|
* Set the width of column
|
|
@@ -21863,8 +21614,7 @@ var RowManager = class {
|
|
|
21863
21614
|
const rowData = {};
|
|
21864
21615
|
let index = 0;
|
|
21865
21616
|
for (let i = rowPos; i < rowPos + numRows; i++) {
|
|
21866
|
-
|
|
21867
|
-
rowData[index] = data !== null && data !== void 0 ? data : {
|
|
21617
|
+
rowData[index] = this.getRow(i) ?? {
|
|
21868
21618
|
h: this._config.defaultRowHeight,
|
|
21869
21619
|
hd: 0
|
|
21870
21620
|
};
|
|
@@ -22305,8 +22055,8 @@ var SheetViewModel = class extends Disposable {
|
|
|
22305
22055
|
return this.getRawCell(row, col);
|
|
22306
22056
|
}
|
|
22307
22057
|
getRowFiltered(row) {
|
|
22308
|
-
var _this$_rowFilteredInt
|
|
22309
|
-
return (_this$_rowFilteredInt =
|
|
22058
|
+
var _this$_rowFilteredInt;
|
|
22059
|
+
return ((_this$_rowFilteredInt = this._rowFilteredInterceptor) === null || _this$_rowFilteredInt === void 0 ? void 0 : _this$_rowFilteredInt.getRowFiltered(row)) ?? false;
|
|
22310
22060
|
}
|
|
22311
22061
|
registerCellContentInterceptor(interceptor) {
|
|
22312
22062
|
if (this._cellContentInterceptor) throw new Error("[SheetViewModel]: Interceptor already registered.");
|
|
@@ -22330,9 +22080,8 @@ const DEFAULT_CELL_DOCUMENT_MODEL_OPTION = {
|
|
|
22330
22080
|
/**
|
|
22331
22081
|
* The model of a Worksheet.
|
|
22332
22082
|
*/
|
|
22333
|
-
var Worksheet = class
|
|
22083
|
+
var Worksheet = class {
|
|
22334
22084
|
constructor(unitId, snapshot, _styles) {
|
|
22335
|
-
var _this$_snapshot$id;
|
|
22336
22085
|
this.unitId = unitId;
|
|
22337
22086
|
this._styles = _styles;
|
|
22338
22087
|
_defineProperty(this, "_sheetId", void 0);
|
|
@@ -22346,7 +22095,7 @@ var Worksheet = class Worksheet {
|
|
|
22346
22095
|
_defineProperty(this, "_getCellHeight", void 0);
|
|
22347
22096
|
this._snapshot = mergeWorksheetSnapshotWithDefault(snapshot);
|
|
22348
22097
|
const { columnData, rowData, cellData } = this._snapshot;
|
|
22349
|
-
this._sheetId =
|
|
22098
|
+
this._sheetId = this._snapshot.id ?? generateRandomId(6);
|
|
22350
22099
|
this._cellData = new ObjectMatrix(cellData);
|
|
22351
22100
|
this._viewModel = new SheetViewModel((row, col) => this.getCellRaw(row, col));
|
|
22352
22101
|
this._rowManager = new RowManager(this._snapshot, this._viewModel, rowData);
|
|
@@ -22463,7 +22212,7 @@ var Worksheet = class Worksheet {
|
|
|
22463
22212
|
const colStyle = this.getColumnStyle(col);
|
|
22464
22213
|
const cell = this.getCell(row, col);
|
|
22465
22214
|
const cellStyle = this._styles.getStyleByCell(cell);
|
|
22466
|
-
return
|
|
22215
|
+
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);
|
|
22467
22216
|
}
|
|
22468
22217
|
/**
|
|
22469
22218
|
* Get the composed style of the cell. If you want to get the style of the cell without merging row style,
|
|
@@ -22481,7 +22230,7 @@ var Worksheet = class Worksheet {
|
|
|
22481
22230
|
const rowStyle = this.getRowStyle(row);
|
|
22482
22231
|
const colStyle = this.getColumnStyle(col);
|
|
22483
22232
|
const cellStyle = this._styles.getStyleByCell(cellData);
|
|
22484
|
-
return
|
|
22233
|
+
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);
|
|
22485
22234
|
}
|
|
22486
22235
|
/**
|
|
22487
22236
|
* Get the composed style of the cell without its own style.
|
|
@@ -22599,16 +22348,6 @@ var Worksheet = class Worksheet {
|
|
|
22599
22348
|
return this._snapshot.name;
|
|
22600
22349
|
}
|
|
22601
22350
|
/**
|
|
22602
|
-
* Returns WorkSheet Clone Object
|
|
22603
|
-
* @returns WorkSheet Clone Object
|
|
22604
|
-
* @deprecated
|
|
22605
|
-
*/
|
|
22606
|
-
clone() {
|
|
22607
|
-
const { _snapshot: _config } = this;
|
|
22608
|
-
const copy = cloneWorksheetData(_config);
|
|
22609
|
-
return new Worksheet(this.unitId, copy, this._styles);
|
|
22610
|
-
}
|
|
22611
|
-
/**
|
|
22612
22351
|
* Get the merged cell list of the sheet.
|
|
22613
22352
|
* @returns {IRange[]} merged cell list
|
|
22614
22353
|
*/
|
|
@@ -23199,14 +22938,14 @@ var Worksheet = class Worksheet {
|
|
|
23199
22938
|
};
|
|
23200
22939
|
}
|
|
23201
22940
|
_updateConfigAndGetDocumentModel(documentData, horizontalAlign, paddingData, renderConfig) {
|
|
23202
|
-
var _documentData$body
|
|
22941
|
+
var _documentData$body;
|
|
23203
22942
|
if (!renderConfig) return;
|
|
23204
22943
|
if (!((_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream)) return;
|
|
23205
22944
|
if (!documentData.documentStyle) documentData.documentStyle = {};
|
|
23206
|
-
documentData.documentStyle.marginTop =
|
|
23207
|
-
documentData.documentStyle.marginBottom =
|
|
23208
|
-
documentData.documentStyle.marginLeft =
|
|
23209
|
-
documentData.documentStyle.marginRight =
|
|
22945
|
+
documentData.documentStyle.marginTop = paddingData.t ?? 0;
|
|
22946
|
+
documentData.documentStyle.marginBottom = paddingData.b ?? 2;
|
|
22947
|
+
documentData.documentStyle.marginLeft = paddingData.l ?? 2;
|
|
22948
|
+
documentData.documentStyle.marginRight = paddingData.r ?? 2;
|
|
23210
22949
|
documentData.documentStyle.pageSize = {
|
|
23211
22950
|
width: Number.POSITIVE_INFINITY,
|
|
23212
22951
|
height: Number.POSITIVE_INFINITY
|
|
@@ -23395,10 +23134,6 @@ let Workbook = class Workbook extends UnitModel {
|
|
|
23395
23134
|
getSnapshot() {
|
|
23396
23135
|
return this._snapshot;
|
|
23397
23136
|
}
|
|
23398
|
-
/** @deprecated use use name property instead */
|
|
23399
|
-
getName() {
|
|
23400
|
-
return this._snapshot.name;
|
|
23401
|
-
}
|
|
23402
23137
|
setName(name) {
|
|
23403
23138
|
this._name$.next(name);
|
|
23404
23139
|
this._snapshot.name = name;
|
|
@@ -23407,8 +23142,7 @@ let Workbook = class Workbook extends UnitModel {
|
|
|
23407
23142
|
return this._unitId;
|
|
23408
23143
|
}
|
|
23409
23144
|
getRev() {
|
|
23410
|
-
|
|
23411
|
-
return (_this$_snapshot$rev = this._snapshot.rev) !== null && _this$_snapshot$rev !== void 0 ? _this$_snapshot$rev : 1;
|
|
23145
|
+
return this._snapshot.rev ?? 1;
|
|
23412
23146
|
}
|
|
23413
23147
|
incrementRev() {
|
|
23414
23148
|
this._snapshot.rev = this.getRev() + 1;
|
|
@@ -23692,10 +23426,7 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23692
23426
|
return this._ctorByType.get(type);
|
|
23693
23427
|
}
|
|
23694
23428
|
getCurrentTypeOfUnit$(type) {
|
|
23695
|
-
return this.currentUnits$.pipe(map((units) =>
|
|
23696
|
-
var _units$get;
|
|
23697
|
-
return (_units$get = units.get(type)) !== null && _units$get !== void 0 ? _units$get : null;
|
|
23698
|
-
}), distinctUntilChanged());
|
|
23429
|
+
return this.currentUnits$.pipe(map((units) => units.get(type) ?? null), distinctUntilChanged());
|
|
23699
23430
|
}
|
|
23700
23431
|
getCurrentUnitOfType(type) {
|
|
23701
23432
|
return this._currentUnits.get(type);
|
|
@@ -23718,7 +23449,6 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23718
23449
|
* @param unit The unit to be added.
|
|
23719
23450
|
*/
|
|
23720
23451
|
__addUnit(unit, options) {
|
|
23721
|
-
var _options$makeCurrent;
|
|
23722
23452
|
this._logService.debug(`[UniverInstanceService]: Adding unit with id ${unit.getUnitId()}`);
|
|
23723
23453
|
const type = unit.type;
|
|
23724
23454
|
if (!this._unitsByType.has(type)) this._unitsByType.set(type, []);
|
|
@@ -23731,7 +23461,7 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23731
23461
|
unit,
|
|
23732
23462
|
options
|
|
23733
23463
|
});
|
|
23734
|
-
if ((
|
|
23464
|
+
if ((options === null || options === void 0 ? void 0 : options.makeCurrent) ?? true) this.setCurrentUnitForType(unit.getUnitId());
|
|
23735
23465
|
}
|
|
23736
23466
|
getTypeOfUnitDisposed$(type) {
|
|
23737
23467
|
return this.unitDisposed$.pipe(filter((unit) => unit.type === type));
|
|
@@ -23743,24 +23473,10 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
23743
23473
|
return unit;
|
|
23744
23474
|
}
|
|
23745
23475
|
getUnitCreateOptions(unitId) {
|
|
23746
|
-
|
|
23747
|
-
return (_this$_unitCreateOpti = this._unitCreateOptions.get(unitId)) !== null && _this$_unitCreateOpti !== void 0 ? _this$_unitCreateOpti : null;
|
|
23748
|
-
}
|
|
23749
|
-
getUniverSheetInstance(unitId) {
|
|
23750
|
-
return this.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
23476
|
+
return this._unitCreateOptions.get(unitId) ?? null;
|
|
23751
23477
|
}
|
|
23752
23478
|
getAllUnitsForType(type) {
|
|
23753
|
-
|
|
23754
|
-
return (_this$_unitsByType$ge = this._unitsByType.get(type)) !== null && _this$_unitsByType$ge !== void 0 ? _this$_unitsByType$ge : [];
|
|
23755
|
-
}
|
|
23756
|
-
changeDoc(unitId, doc) {
|
|
23757
|
-
const allDocs = this.getAllUnitsForType(UniverInstanceType.UNIVER_DOC);
|
|
23758
|
-
const oldDoc = allDocs.find((doc) => doc.getUnitId() === unitId);
|
|
23759
|
-
if (oldDoc != null) {
|
|
23760
|
-
const index = allDocs.indexOf(oldDoc);
|
|
23761
|
-
allDocs.splice(index, 1);
|
|
23762
|
-
}
|
|
23763
|
-
this.__addUnit(doc);
|
|
23479
|
+
return this._unitsByType.get(type) ?? [];
|
|
23764
23480
|
}
|
|
23765
23481
|
get focused() {
|
|
23766
23482
|
var _this$_getUnitById2;
|
|
@@ -24069,16 +23785,15 @@ var LocaleService = class extends Disposable {
|
|
|
24069
23785
|
* @param locales - Locale object
|
|
24070
23786
|
*/
|
|
24071
23787
|
load(locales) {
|
|
24072
|
-
|
|
24073
|
-
this._locales = merge((_this$_locales = this._locales) !== null && _this$_locales !== void 0 ? _this$_locales : {}, locales);
|
|
23788
|
+
this._locales = merge(this._locales ?? {}, locales);
|
|
24074
23789
|
}
|
|
24075
23790
|
setLocale(locale) {
|
|
24076
23791
|
this._currentLocale$.next(locale);
|
|
24077
23792
|
this.localeChanged$.next();
|
|
24078
23793
|
}
|
|
24079
23794
|
getLocales() {
|
|
24080
|
-
var _this$
|
|
24081
|
-
return (_this$
|
|
23795
|
+
var _this$_locales;
|
|
23796
|
+
return (_this$_locales = this._locales) === null || _this$_locales === void 0 ? void 0 : _this$_locales[this._currentLocale];
|
|
24082
23797
|
}
|
|
24083
23798
|
getCurrentLocale() {
|
|
24084
23799
|
return this._currentLocale;
|
|
@@ -24125,11 +23840,11 @@ let MentionIOLocalService = class MentionIOLocalService {
|
|
|
24125
23840
|
};
|
|
24126
23841
|
}
|
|
24127
23842
|
};
|
|
24128
|
-
MentionIOLocalService = __decorate([__decorateParam(0, Inject
|
|
23843
|
+
MentionIOLocalService = __decorate([__decorateParam(0, Inject(UserManagerService))], MentionIOLocalService);
|
|
24129
23844
|
|
|
24130
23845
|
//#endregion
|
|
24131
23846
|
//#region src/services/mention-io/type.ts
|
|
24132
|
-
const IMentionIOService = createIdentifier
|
|
23847
|
+
const IMentionIOService = createIdentifier("univer.service.mention-io");
|
|
24133
23848
|
|
|
24134
23849
|
//#endregion
|
|
24135
23850
|
//#region src/services/permission/type.ts
|
|
@@ -24805,12 +24520,12 @@ let LocalUndoRedoService = class LocalUndoRedoService extends Disposable {
|
|
|
24805
24520
|
if (isFocusSheet) if (isFocusFormulaEditor) unitID = DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
|
|
24806
24521
|
else if (isFocusEditor) unitID = DOCS_NORMAL_EDITOR_UNIT_ID_KEY;
|
|
24807
24522
|
else {
|
|
24808
|
-
var _this$_univerInstance
|
|
24809
|
-
unitID = (_this$_univerInstance =
|
|
24523
|
+
var _this$_univerInstance;
|
|
24524
|
+
unitID = ((_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId()) ?? "";
|
|
24810
24525
|
}
|
|
24811
24526
|
else {
|
|
24812
|
-
var _this$
|
|
24813
|
-
unitID = (
|
|
24527
|
+
var _this$_univerInstance2;
|
|
24528
|
+
unitID = ((_this$_univerInstance2 = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getUnitId()) ?? "";
|
|
24814
24529
|
}
|
|
24815
24530
|
return unitID;
|
|
24816
24531
|
}
|
|
@@ -25188,6 +24903,198 @@ function delayAnimationFrame(frames = 1) {
|
|
|
25188
24903
|
});
|
|
25189
24904
|
}
|
|
25190
24905
|
|
|
24906
|
+
//#endregion
|
|
24907
|
+
//#region src/sheets/clone.ts
|
|
24908
|
+
/**
|
|
24909
|
+
* Fast clone for primitive values and simple objects.
|
|
24910
|
+
* Avoids type checking overhead when we know the structure.
|
|
24911
|
+
*/
|
|
24912
|
+
function cloneValue(value) {
|
|
24913
|
+
if (value === null || value === void 0) return value;
|
|
24914
|
+
if (typeof value !== "object") return value;
|
|
24915
|
+
if (Array.isArray(value)) {
|
|
24916
|
+
const len = value.length;
|
|
24917
|
+
const result = new Array(len);
|
|
24918
|
+
for (let i = 0; i < len; i++) result[i] = cloneValue(value[i]);
|
|
24919
|
+
return result;
|
|
24920
|
+
}
|
|
24921
|
+
const result = {};
|
|
24922
|
+
const keys = Object.keys(value);
|
|
24923
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
24924
|
+
const key = keys[i];
|
|
24925
|
+
result[key] = cloneValue(value[key]);
|
|
24926
|
+
}
|
|
24927
|
+
return result;
|
|
24928
|
+
}
|
|
24929
|
+
/**
|
|
24930
|
+
* Fast clone for ICellData. Optimized for the known structure.
|
|
24931
|
+
* @param cell - The cell data to clone
|
|
24932
|
+
* @returns A deep clone of the cell data
|
|
24933
|
+
*/
|
|
24934
|
+
function cloneCellData(cell) {
|
|
24935
|
+
if (cell === null || cell === void 0) return cell;
|
|
24936
|
+
const result = {};
|
|
24937
|
+
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
24938
|
+
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
24939
|
+
else result.s = cloneValue(cell.s);
|
|
24940
|
+
if (cell.v !== void 0) result.v = cell.v;
|
|
24941
|
+
if (cell.t !== void 0) result.t = cell.t;
|
|
24942
|
+
if (cell.f !== void 0) result.f = cell.f;
|
|
24943
|
+
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
24944
|
+
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
24945
|
+
if (cell.si !== void 0) result.si = cell.si;
|
|
24946
|
+
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
24947
|
+
return result;
|
|
24948
|
+
}
|
|
24949
|
+
/**
|
|
24950
|
+
* Fast clone for ICellDataWithSpanAndDisplay. Optimized for the known structure.
|
|
24951
|
+
* This extends cloneCellData with additional span and display properties.
|
|
24952
|
+
* @param cell - The cell data with span and display info to clone
|
|
24953
|
+
* @returns A deep clone of the cell data
|
|
24954
|
+
*/
|
|
24955
|
+
function cloneCellDataWithSpanAndDisplay(cell) {
|
|
24956
|
+
if (cell === null || cell === void 0) return cell;
|
|
24957
|
+
const result = {};
|
|
24958
|
+
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
24959
|
+
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
24960
|
+
else result.s = cloneValue(cell.s);
|
|
24961
|
+
if (cell.v !== void 0) result.v = cell.v;
|
|
24962
|
+
if (cell.t !== void 0) result.t = cell.t;
|
|
24963
|
+
if (cell.f !== void 0) result.f = cell.f;
|
|
24964
|
+
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
24965
|
+
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
24966
|
+
if (cell.si !== void 0) result.si = cell.si;
|
|
24967
|
+
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
24968
|
+
if (cell.rowSpan !== void 0) result.rowSpan = cell.rowSpan;
|
|
24969
|
+
if (cell.colSpan !== void 0) result.colSpan = cell.colSpan;
|
|
24970
|
+
if (cell.displayV !== void 0) result.displayV = cell.displayV;
|
|
24971
|
+
return result;
|
|
24972
|
+
}
|
|
24973
|
+
/**
|
|
24974
|
+
* Fast clone for cell data matrix. Optimized for sparse matrix structure.
|
|
24975
|
+
* @param cellData - The cell data matrix to clone
|
|
24976
|
+
* @returns A deep clone of the cell data matrix
|
|
24977
|
+
*/
|
|
24978
|
+
function cloneCellDataMatrix(cellData) {
|
|
24979
|
+
const result = {};
|
|
24980
|
+
const rowKeys = Object.keys(cellData);
|
|
24981
|
+
for (let i = 0, rowLen = rowKeys.length; i < rowLen; i++) {
|
|
24982
|
+
const rowKey = rowKeys[i];
|
|
24983
|
+
const rowNum = Number(rowKey);
|
|
24984
|
+
const rowData = cellData[rowNum];
|
|
24985
|
+
if (rowData === void 0) continue;
|
|
24986
|
+
const clonedRow = {};
|
|
24987
|
+
const colKeys = Object.keys(rowData);
|
|
24988
|
+
for (let j = 0, colLen = colKeys.length; j < colLen; j++) {
|
|
24989
|
+
const colKey = colKeys[j];
|
|
24990
|
+
const colNum = Number(colKey);
|
|
24991
|
+
const cell = rowData[colNum];
|
|
24992
|
+
if (cell !== void 0 && cell !== null) clonedRow[colNum] = cloneCellData(cell);
|
|
24993
|
+
}
|
|
24994
|
+
result[rowNum] = clonedRow;
|
|
24995
|
+
}
|
|
24996
|
+
return result;
|
|
24997
|
+
}
|
|
24998
|
+
/**
|
|
24999
|
+
* Fast clone for row/column data arrays (sparse arrays stored as objects).
|
|
25000
|
+
* @param data - The row or column data to clone
|
|
25001
|
+
* @returns A deep clone of the row or column data
|
|
25002
|
+
*/
|
|
25003
|
+
function cloneRowColumnData(data) {
|
|
25004
|
+
const result = {};
|
|
25005
|
+
const keys = Object.keys(data);
|
|
25006
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
25007
|
+
const key = keys[i];
|
|
25008
|
+
const idx = Number(key);
|
|
25009
|
+
const item = data[idx];
|
|
25010
|
+
if (item === void 0) continue;
|
|
25011
|
+
const cloned = {};
|
|
25012
|
+
if ("h" in item && item.h !== void 0) cloned.h = item.h;
|
|
25013
|
+
if ("ia" in item && item.ia !== void 0) cloned.ia = item.ia;
|
|
25014
|
+
if ("ah" in item && item.ah !== void 0) cloned.ah = item.ah;
|
|
25015
|
+
if ("hd" in item && item.hd !== void 0) cloned.hd = item.hd;
|
|
25016
|
+
if ("w" in item && item.w !== void 0) cloned.w = item.w;
|
|
25017
|
+
if ("s" in item && item.s !== void 0) if (item.s === null || typeof item.s === "string") cloned.s = item.s;
|
|
25018
|
+
else cloned.s = cloneValue(item.s);
|
|
25019
|
+
if ("custom" in item && item.custom !== void 0) cloned.custom = item.custom === null ? null : cloneValue(item.custom);
|
|
25020
|
+
result[idx] = cloned;
|
|
25021
|
+
}
|
|
25022
|
+
return result;
|
|
25023
|
+
}
|
|
25024
|
+
/**
|
|
25025
|
+
* Fast clone for IRange array (merge data).
|
|
25026
|
+
* @param ranges - The array of ranges to clone
|
|
25027
|
+
* @returns A shallow clone of the ranges (IRange contains only primitive values)
|
|
25028
|
+
*/
|
|
25029
|
+
function cloneMergeData(ranges) {
|
|
25030
|
+
const len = ranges.length;
|
|
25031
|
+
const result = new Array(len);
|
|
25032
|
+
for (let i = 0; i < len; i++) {
|
|
25033
|
+
const range = ranges[i];
|
|
25034
|
+
result[i] = {
|
|
25035
|
+
startRow: range.startRow,
|
|
25036
|
+
startColumn: range.startColumn,
|
|
25037
|
+
endRow: range.endRow,
|
|
25038
|
+
endColumn: range.endColumn,
|
|
25039
|
+
rangeType: range.rangeType,
|
|
25040
|
+
startAbsoluteRefType: range.startAbsoluteRefType,
|
|
25041
|
+
endAbsoluteRefType: range.endAbsoluteRefType
|
|
25042
|
+
};
|
|
25043
|
+
}
|
|
25044
|
+
return result;
|
|
25045
|
+
}
|
|
25046
|
+
/**
|
|
25047
|
+
* Optimized deep clone specifically for IWorksheetData.
|
|
25048
|
+
* This is significantly faster than generic deepClone because:
|
|
25049
|
+
* 1. No recursive type checking - we know the structure
|
|
25050
|
+
* 2. Direct property access instead of Object.keys iteration for known properties
|
|
25051
|
+
* 3. Specialized handlers for cellData matrix (the largest data)
|
|
25052
|
+
* 4. Primitive values copied directly without cloning
|
|
25053
|
+
*
|
|
25054
|
+
* @param worksheet - The worksheet data to clone
|
|
25055
|
+
* @returns A deep clone of the worksheet data
|
|
25056
|
+
*/
|
|
25057
|
+
function cloneWorksheetData(worksheet) {
|
|
25058
|
+
const result = {
|
|
25059
|
+
id: worksheet.id,
|
|
25060
|
+
name: worksheet.name,
|
|
25061
|
+
tabColor: worksheet.tabColor,
|
|
25062
|
+
hidden: worksheet.hidden,
|
|
25063
|
+
rowCount: worksheet.rowCount,
|
|
25064
|
+
columnCount: worksheet.columnCount,
|
|
25065
|
+
zoomRatio: worksheet.zoomRatio,
|
|
25066
|
+
scrollTop: worksheet.scrollTop,
|
|
25067
|
+
scrollLeft: worksheet.scrollLeft,
|
|
25068
|
+
defaultColumnWidth: worksheet.defaultColumnWidth,
|
|
25069
|
+
defaultRowHeight: worksheet.defaultRowHeight,
|
|
25070
|
+
showGridlines: worksheet.showGridlines,
|
|
25071
|
+
rightToLeft: worksheet.rightToLeft,
|
|
25072
|
+
freeze: {
|
|
25073
|
+
xSplit: worksheet.freeze.xSplit,
|
|
25074
|
+
ySplit: worksheet.freeze.ySplit,
|
|
25075
|
+
startRow: worksheet.freeze.startRow,
|
|
25076
|
+
startColumn: worksheet.freeze.startColumn
|
|
25077
|
+
},
|
|
25078
|
+
rowHeader: {
|
|
25079
|
+
width: worksheet.rowHeader.width,
|
|
25080
|
+
hidden: worksheet.rowHeader.hidden
|
|
25081
|
+
},
|
|
25082
|
+
columnHeader: {
|
|
25083
|
+
height: worksheet.columnHeader.height,
|
|
25084
|
+
hidden: worksheet.columnHeader.hidden
|
|
25085
|
+
},
|
|
25086
|
+
mergeData: cloneMergeData(worksheet.mergeData),
|
|
25087
|
+
cellData: cloneCellDataMatrix(worksheet.cellData),
|
|
25088
|
+
rowData: cloneRowColumnData(worksheet.rowData),
|
|
25089
|
+
columnData: cloneRowColumnData(worksheet.columnData)
|
|
25090
|
+
};
|
|
25091
|
+
if (worksheet.gridlinesColor !== void 0) result.gridlinesColor = worksheet.gridlinesColor;
|
|
25092
|
+
if (worksheet.defaultStyle !== void 0) if (worksheet.defaultStyle === null || typeof worksheet.defaultStyle === "string") result.defaultStyle = worksheet.defaultStyle;
|
|
25093
|
+
else result.defaultStyle = cloneValue(worksheet.defaultStyle);
|
|
25094
|
+
if (worksheet.custom !== void 0) result.custom = worksheet.custom === null ? null : cloneValue(worksheet.custom);
|
|
25095
|
+
return result;
|
|
25096
|
+
}
|
|
25097
|
+
|
|
25191
25098
|
//#endregion
|
|
25192
25099
|
//#region src/skeleton.ts
|
|
25193
25100
|
let Skeleton = class Skeleton extends Disposable {
|
|
@@ -25213,7 +25120,7 @@ let Skeleton = class Skeleton extends Disposable {
|
|
|
25213
25120
|
}
|
|
25214
25121
|
_localeInitial() {}
|
|
25215
25122
|
};
|
|
25216
|
-
Skeleton = __decorate([__decorateParam(0, Inject
|
|
25123
|
+
Skeleton = __decorate([__decorateParam(0, Inject(LocaleService))], Skeleton);
|
|
25217
25124
|
|
|
25218
25125
|
//#endregion
|
|
25219
25126
|
//#region src/sheets/sheet-skeleton.ts
|
|
@@ -25294,18 +25201,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25294
25201
|
this.initConfig();
|
|
25295
25202
|
}
|
|
25296
25203
|
initConfig() {
|
|
25297
|
-
|
|
25298
|
-
this.
|
|
25299
|
-
this.worksheet.setIsRowStylePrecedeColumnStyle((_this$_configService$2 = this._configService.getConfig("isRowStylePrecedeColumnStyle")) !== null && _this$_configService$2 !== void 0 ? _this$_configService$2 : false);
|
|
25204
|
+
this._skipAutoHeightForMergedCells = !(this._configService.getConfig(AUTO_HEIGHT_FOR_MERGED_CELLS) ?? false);
|
|
25205
|
+
this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig("isRowStylePrecedeColumnStyle") ?? false);
|
|
25300
25206
|
}
|
|
25301
25207
|
resetCache() {}
|
|
25302
25208
|
/**
|
|
25303
|
-
* @deprecated should never expose a property that is provided by another module!
|
|
25304
|
-
*/
|
|
25305
|
-
getWorksheetConfig() {
|
|
25306
|
-
return this._worksheetData;
|
|
25307
|
-
}
|
|
25308
|
-
/**
|
|
25309
25209
|
* Get which Workbook and Worksheet this skeleton is attached to.
|
|
25310
25210
|
* @returns [unitId, sheetId]
|
|
25311
25211
|
*/
|
|
@@ -25388,28 +25288,27 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25388
25288
|
this._updateLayout();
|
|
25389
25289
|
}
|
|
25390
25290
|
_fillDefaultGapThemeColors(config) {
|
|
25391
|
-
var _config$defaultBackgr, _config$defaultStripe;
|
|
25392
25291
|
if (config.defaultBackgroundColor && config.defaultStripeColor) return config;
|
|
25393
25292
|
const { r, g, b } = new ColorKit(this._injector.get(ThemeService).getColorFromTheme("primary.500")).toRgb();
|
|
25394
25293
|
return {
|
|
25395
25294
|
...config,
|
|
25396
|
-
defaultBackgroundColor:
|
|
25397
|
-
defaultStripeColor:
|
|
25295
|
+
defaultBackgroundColor: config.defaultBackgroundColor ?? `rgba(${r}, ${g}, ${b}, 0.025)`,
|
|
25296
|
+
defaultStripeColor: config.defaultStripeColor ?? `rgba(${r}, ${g}, ${b}, 0.08)`
|
|
25398
25297
|
};
|
|
25399
25298
|
}
|
|
25400
25299
|
/**
|
|
25401
25300
|
* Get the gap size (in px) BEFORE the given row.
|
|
25402
25301
|
*/
|
|
25403
25302
|
getRowGapSize(row) {
|
|
25404
|
-
var _this$_gapConfig$rowG
|
|
25405
|
-
return (_this$_gapConfig$rowG =
|
|
25303
|
+
var _this$_gapConfig$rowG;
|
|
25304
|
+
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;
|
|
25406
25305
|
}
|
|
25407
25306
|
/**
|
|
25408
25307
|
* Get the gap size (in px) BEFORE the given column.
|
|
25409
25308
|
*/
|
|
25410
25309
|
getColGapSize(col) {
|
|
25411
|
-
var _this$_gapConfig$colG
|
|
25412
|
-
return (_this$_gapConfig$colG =
|
|
25310
|
+
var _this$_gapConfig$colG;
|
|
25311
|
+
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;
|
|
25413
25312
|
}
|
|
25414
25313
|
/**
|
|
25415
25314
|
* Returns a gap size getter object for use with coordinate utility functions.
|
|
@@ -25429,11 +25328,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25429
25328
|
const { rowGaps } = this._gapConfig;
|
|
25430
25329
|
if (!rowGaps) return -1;
|
|
25431
25330
|
for (const rowStr of Object.keys(rowGaps)) {
|
|
25432
|
-
var _rowGaps$row
|
|
25331
|
+
var _rowGaps$row;
|
|
25433
25332
|
const row = Number(rowStr);
|
|
25434
|
-
const gapSize = (
|
|
25333
|
+
const gapSize = ((_rowGaps$row = rowGaps[row]) === null || _rowGaps$row === void 0 ? void 0 : _rowGaps$row.size) ?? 0;
|
|
25435
25334
|
if (gapSize <= 0) continue;
|
|
25436
|
-
const gapStart =
|
|
25335
|
+
const gapStart = this._rowHeightAccumulation[row - 1] ?? 0;
|
|
25437
25336
|
const gapEnd = gapStart + gapSize;
|
|
25438
25337
|
if (y >= gapStart && y < gapEnd) return row;
|
|
25439
25338
|
}
|
|
@@ -25447,11 +25346,11 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25447
25346
|
const { colGaps } = this._gapConfig;
|
|
25448
25347
|
if (!colGaps) return -1;
|
|
25449
25348
|
for (const colStr of Object.keys(colGaps)) {
|
|
25450
|
-
var _colGaps$col
|
|
25349
|
+
var _colGaps$col;
|
|
25451
25350
|
const col = Number(colStr);
|
|
25452
|
-
const gapSize = (
|
|
25351
|
+
const gapSize = ((_colGaps$col = colGaps[col]) === null || _colGaps$col === void 0 ? void 0 : _colGaps$col.size) ?? 0;
|
|
25453
25352
|
if (gapSize <= 0) continue;
|
|
25454
|
-
const gapStart =
|
|
25353
|
+
const gapStart = this._columnWidthAccumulation[col - 1] ?? 0;
|
|
25455
25354
|
const gapEnd = gapStart + gapSize;
|
|
25456
25355
|
if (x >= gapStart && x < gapEnd) return col;
|
|
25457
25356
|
}
|
|
@@ -25462,7 +25361,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25462
25361
|
const rowHeightAccumulation = [];
|
|
25463
25362
|
const data = rowData;
|
|
25464
25363
|
for (let r = 0; r < rowCount; r++) {
|
|
25465
|
-
var _this$_gapConfig$
|
|
25364
|
+
var _this$_gapConfig$rowG2;
|
|
25466
25365
|
let rowHeight = defaultRowHeight;
|
|
25467
25366
|
if (this.worksheet.getRowFiltered(r)) rowHeight = 0;
|
|
25468
25367
|
else if (data[r] != null) {
|
|
@@ -25473,7 +25372,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25473
25372
|
else rowHeight = h;
|
|
25474
25373
|
if (rowDataItem.hd === 1) rowHeight = 0;
|
|
25475
25374
|
}
|
|
25476
|
-
const gapSize = (
|
|
25375
|
+
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;
|
|
25477
25376
|
rowTotalHeight += gapSize;
|
|
25478
25377
|
rowTotalHeight += rowHeight;
|
|
25479
25378
|
rowHeightAccumulation.push(rowTotalHeight);
|
|
@@ -25491,7 +25390,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25491
25390
|
const columnWidthAccumulation = [];
|
|
25492
25391
|
const data = columnData;
|
|
25493
25392
|
for (let c = 0; c < colCount; c++) {
|
|
25494
|
-
var _this$_gapConfig$
|
|
25393
|
+
var _this$_gapConfig$colG2;
|
|
25495
25394
|
let columnWidth = defaultColumnWidth;
|
|
25496
25395
|
if (data[c] != null) {
|
|
25497
25396
|
const columnDataItem = data[c];
|
|
@@ -25499,7 +25398,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25499
25398
|
if (columnDataItem.w != null) columnWidth = columnDataItem.w;
|
|
25500
25399
|
if (columnDataItem.hd === 1) columnWidth = 0;
|
|
25501
25400
|
}
|
|
25502
|
-
const gapSize = (
|
|
25401
|
+
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;
|
|
25503
25402
|
columnTotalWidth += gapSize;
|
|
25504
25403
|
columnTotalWidth += columnWidth;
|
|
25505
25404
|
columnWidthAccumulation.push(columnTotalWidth);
|
|
@@ -25685,8 +25584,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25685
25584
|
offsetY = getTransformOffsetY(offsetY, scaleY, scrollXY, this.columnHeaderHeightAndMarginTop);
|
|
25686
25585
|
let row = searchArray(rowHeightAccumulation, offsetY, options === null || options === void 0 ? void 0 : options.firstMatch);
|
|
25687
25586
|
if (options === null || options === void 0 ? void 0 : options.closeFirst) {
|
|
25688
|
-
|
|
25689
|
-
if (Math.abs(rowHeightAccumulation[row] - offsetY) < Math.abs(offsetY - ((_rowHeightAccumulatio = rowHeightAccumulation[row - 1]) !== null && _rowHeightAccumulatio !== void 0 ? _rowHeightAccumulatio : 0))) row = row + 1;
|
|
25587
|
+
if (Math.abs(rowHeightAccumulation[row] - offsetY) < Math.abs(offsetY - (rowHeightAccumulation[row - 1] ?? 0))) row = row + 1;
|
|
25690
25588
|
}
|
|
25691
25589
|
return row;
|
|
25692
25590
|
}
|
|
@@ -25698,8 +25596,7 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25698
25596
|
const { columnWidthAccumulation } = this;
|
|
25699
25597
|
let column = searchArray(columnWidthAccumulation, offsetX, options === null || options === void 0 ? void 0 : options.firstMatch);
|
|
25700
25598
|
if (options === null || options === void 0 ? void 0 : options.closeFirst) {
|
|
25701
|
-
|
|
25702
|
-
if (Math.abs(columnWidthAccumulation[column] - offsetX) < Math.abs(offsetX - ((_columnWidthAccumulat = columnWidthAccumulation[column - 1]) !== null && _columnWidthAccumulat !== void 0 ? _columnWidthAccumulat : 0))) column = column + 1;
|
|
25599
|
+
if (Math.abs(columnWidthAccumulation[column] - offsetX) < Math.abs(offsetX - (columnWidthAccumulation[column - 1] ?? 0))) column = column + 1;
|
|
25703
25600
|
}
|
|
25704
25601
|
return column;
|
|
25705
25602
|
}
|
|
@@ -25834,14 +25731,14 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25834
25731
|
};
|
|
25835
25732
|
}
|
|
25836
25733
|
_updateConfigAndGetDocumentModel(documentData, horizontalAlign, paddingData, renderConfig) {
|
|
25837
|
-
var _documentData$body
|
|
25734
|
+
var _documentData$body;
|
|
25838
25735
|
if (!renderConfig) return;
|
|
25839
25736
|
if (!((_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream)) return;
|
|
25840
25737
|
if (!documentData.documentStyle) documentData.documentStyle = {};
|
|
25841
|
-
documentData.documentStyle.marginTop =
|
|
25842
|
-
documentData.documentStyle.marginBottom =
|
|
25843
|
-
documentData.documentStyle.marginLeft =
|
|
25844
|
-
documentData.documentStyle.marginRight =
|
|
25738
|
+
documentData.documentStyle.marginTop = paddingData.t ?? 0;
|
|
25739
|
+
documentData.documentStyle.marginBottom = paddingData.b ?? 2;
|
|
25740
|
+
documentData.documentStyle.marginLeft = paddingData.l ?? 2;
|
|
25741
|
+
documentData.documentStyle.marginRight = paddingData.r ?? 2;
|
|
25845
25742
|
documentData.documentStyle.pageSize = {
|
|
25846
25743
|
width: Number.POSITIVE_INFINITY,
|
|
25847
25744
|
height: Number.POSITIVE_INFINITY
|
|
@@ -25874,10 +25771,10 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
25874
25771
|
}
|
|
25875
25772
|
};
|
|
25876
25773
|
SheetSkeleton = __decorate([
|
|
25877
|
-
__decorateParam(2, Inject
|
|
25774
|
+
__decorateParam(2, Inject(LocaleService)),
|
|
25878
25775
|
__decorateParam(3, IContextService),
|
|
25879
25776
|
__decorateParam(4, IConfigService),
|
|
25880
|
-
__decorateParam(5, Inject
|
|
25777
|
+
__decorateParam(5, Inject(Injector))
|
|
25881
25778
|
], SheetSkeleton);
|
|
25882
25779
|
/**
|
|
25883
25780
|
* Not same as getCellWithCoordByIndex, Only the coordinates of the corresponding cells in rows and columns are considered, without taking into account the merged data.
|
|
@@ -25916,10 +25813,9 @@ function getCellCoordByIndexSimple(row, column, rowHeightAccumulation, columnWid
|
|
|
25916
25813
|
* @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
|
|
25917
25814
|
*/
|
|
25918
25815
|
function getCellWithCoordByIndexCore(row, column, rowHeightAccumulation, columnWidthAccumulation, mergeDataInfo, gapSizeGetter) {
|
|
25919
|
-
var _gapSizeGetter$row, _gapSizeGetter$col;
|
|
25920
25816
|
row = Tools.clamp(row, 0, rowHeightAccumulation.length - 1);
|
|
25921
25817
|
column = Tools.clamp(column, 0, columnWidthAccumulation.length - 1);
|
|
25922
|
-
let { startY, endY, startX, endX } = getCellCoordByIndexSimple(row, column, rowHeightAccumulation, columnWidthAccumulation, (
|
|
25818
|
+
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);
|
|
25923
25819
|
if (!mergeDataInfo) return {
|
|
25924
25820
|
startY,
|
|
25925
25821
|
endY,
|
|
@@ -25954,9 +25850,8 @@ function getCellWithCoordByIndexCore(row, column, rowHeightAccumulation, columnW
|
|
|
25954
25850
|
const rowAccumulationCount = rowHeightAccumulation.length - 1;
|
|
25955
25851
|
const columnAccumulationCount = columnWidthAccumulation.length - 1;
|
|
25956
25852
|
if (isMerged && startRow !== -1 && startColumn !== -1) {
|
|
25957
|
-
|
|
25958
|
-
const
|
|
25959
|
-
const mergeColGapSize = (_gapSizeGetter$col2 = gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.col(startColumn)) !== null && _gapSizeGetter$col2 !== void 0 ? _gapSizeGetter$col2 : 0;
|
|
25853
|
+
const mergeRowGapSize = (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.row(startRow)) ?? 0;
|
|
25854
|
+
const mergeColGapSize = (gapSizeGetter === null || gapSizeGetter === void 0 ? void 0 : gapSizeGetter.col(startColumn)) ?? 0;
|
|
25960
25855
|
const mergeStartY = (rowHeightAccumulation[startRow - 1] || 0) + mergeRowGapSize;
|
|
25961
25856
|
const mergeEndY = rowHeightAccumulation[endRow] || rowHeightAccumulation[rowAccumulationCount];
|
|
25962
25857
|
const mergeStartX = (columnWidthAccumulation[startColumn - 1] || 0) + mergeColGapSize;
|
|
@@ -26411,13 +26306,12 @@ var Univer = class {
|
|
|
26411
26306
|
this._univerInstanceService.registerCtorForType(UniverInstanceType.UNIVER_SLIDE, SlideDataModel);
|
|
26412
26307
|
const univerInstanceService = injector.get(IUniverInstanceService);
|
|
26413
26308
|
univerInstanceService.__setCreateHandler((type, data, ctor, options) => {
|
|
26414
|
-
var _univerInstanceServic;
|
|
26415
26309
|
const isFirstTime = !this._startedTypes.has(type);
|
|
26416
26310
|
if (isFirstTime) {
|
|
26417
26311
|
this._pluginService.startPluginsForType(type);
|
|
26418
26312
|
this._startedTypes.add(type);
|
|
26419
26313
|
}
|
|
26420
|
-
const actualCtor =
|
|
26314
|
+
const actualCtor = univerInstanceService.__getCtorByType(type) ?? ctor;
|
|
26421
26315
|
if (!actualCtor) throw new Error(`[Univer]: No constructor registered for unit type ${type}.`);
|
|
26422
26316
|
const model = injector.createInstance(actualCtor, data);
|
|
26423
26317
|
univerInstanceService.__addUnit(model, options);
|
|
@@ -26504,4 +26398,4 @@ function createUniverInjector(parentInjector, override) {
|
|
|
26504
26398
|
installShims();
|
|
26505
26399
|
|
|
26506
26400
|
//#endregion
|
|
26507
|
-
export { ABCToNumber, AUTO_HEIGHT_FOR_MERGED_CELLS, AbsoluteRefType, ActionIterator, AlignTypeH, AlignTypeV, ArrangeTypeEnum, AsyncInterceptorManager, AsyncLock, AuthzIoLocalService, AutoFillSeries, BORDER_KEYS, BORDER_STYLE_KEYS, BaseDataModel, BaseFieldType, BaseFilterConjunction, BaseFilterOperator, BaseSortDirection, BaseViewType, BaselineOffset, BlockType, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, BulletAlignment, COLORS, COLOR_STYLE_KEYS, COMMAND_LOG_EXECUTION_CONFIG_KEY, CanceledError, CellModeEnum, CellValueType, ColorKit, ColorType, ColumnLayoutType, ColumnResponsiveType, ColumnSeparatorType, CommandService, CommandType, CommonHideTypes, ConfigService, ContextService, CopyPasteType, CustomCommandExecutionError, CustomDecorationType, CustomRangeType, DEFAULT_CELL, DEFAULT_DOC, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_DOCUMENT_SUB_COMPONENT_ID, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_NUMBER_FORMAT, DEFAULT_RANGE, DEFAULT_RANGE_ARRAY, DEFAULT_SELECTION, DEFAULT_STYLES, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, DOCS_COMMENT_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_DRAWING_PRINTING_COMPONENT_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DataValidationErrorStyle, DataValidationImeMode, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DependentOn, DesktopLogService, DeveloperMetadataVisibility, Dimension, Direction, Disposable, DisposableCollection, DocStyleType, DocumentBlockRangeType, DocumentBlockType, DocumentDataModel, DocumentFlavor, DrawingTypeEnum, EDITOR_ACTIVATED, EXTENSION_NAMES, ErrorService, EventState, EventSubject, FOCUSING_BOARD, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC,
|
|
26401
|
+
export { ABCToNumber, AUTO_HEIGHT_FOR_MERGED_CELLS, AbsoluteRefType, ActionIterator, AlignTypeH, AlignTypeV, ArrangeTypeEnum, AsyncInterceptorManager, AsyncLock, AuthzIoLocalService, AutoFillSeries, BASE_RECORD_ID_FIELD_ID, BASE_RECORD_ID_FIELD_NAME, BORDER_KEYS, BORDER_STYLE_KEYS, BaseConditionalColorOperator, BaseConditionalColorTarget, BaseConditionalDateMode, BaseDataModel, BaseFieldType, BaseFilterConjunction, BaseFilterOperator, BaseHierarchyInvalidReason, BaseRecordLinkRole, BaseSortDirection, BaseViewType, BaselineOffset, BlockType, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, BulletAlignment, COLORS, COLOR_STYLE_KEYS, COMMAND_LOG_EXECUTION_CONFIG_KEY, CanceledError, CellModeEnum, CellValueType, ColorKit, ColorType, ColumnLayoutType, ColumnResponsiveType, ColumnSeparatorType, CommandService, CommandType, CommonHideTypes, ConfigService, ContextService, CopyPasteType, CustomCommandExecutionError, CustomDecorationType, CustomRangeType, DEFAULT_CELL, DEFAULT_DOC, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_DOCUMENT_SUB_COMPONENT_ID, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_NUMBER_FORMAT, DEFAULT_RANGE, DEFAULT_RANGE_ARRAY, DEFAULT_SELECTION, DEFAULT_STYLES, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, DOCS_COMMENT_EDITOR_UNIT_ID_KEY, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_DRAWING_PRINTING_COMPONENT_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DataValidationErrorStyle, DataValidationImeMode, DataValidationOperator, DataValidationRenderMode, DataValidationStatus, DataValidationType, DeleteDirection, DependentOn, DesktopLogService, DeveloperMetadataVisibility, Dimension, Direction, Disposable, DisposableCollection, DocStyleType, DocumentBlockRangeType, DocumentBlockType, DocumentDataModel, DocumentFlavor, DocxBreakType, DrawingTypeEnum, EDITOR_ACTIVATED, EXTENSION_NAMES, ErrorService, EventState, EventSubject, FOCUSING_BOARD, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_PANEL_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_SLIDE, FOCUSING_UNIT, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, FORMULA_EDITOR_ACTIVATED, FollowNumberWithType, FontItalic, FontStyleType, FontWeight, GridType, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, IImageIoService, ILocalStorageService, ILogService, IMentionIOService, IPermissionService, IResourceLoaderService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IURLImageService, IUndoRedoService, IUniverInstanceService, ImageCacheMap, ImageSourceType, ImageUploadStatusType, Inject, InjectSelf, Injector, InterceptorEffectEnum, InterceptorManager, InterpolationPointType, json1 as JSON1, JSONX, LOCALE_META, LRUHelper, LRUMap, LifecycleService, LifecycleStages, LifecycleUnreachableError, ListGlyphType, LocalUndoRedoService, LocaleService, LocaleType, LogLevel, LookUp, MAX_COLUMN_COUNT, MAX_ROW_COUNT, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, Many, MemoryCursor, MentionIOLocalService, MentionType, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NamedStyleType, NilCommand, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PADDING_KEYS, PAGE_SIZE, PAPER_TYPES, PARAGRAPH_ID_PREFIX, PRESERVE_INSERTED_PARAGRAPH_IDS, PRESET_LIST_TYPE, PageOrientType, PaperType, ParagraphElementType, ParagraphStyleBuilder, ParagraphStyleValue, PermissionService, PermissionStatus, Plugin, PluginService, PositionedObjectLayoutType, PresetListType, ProtectionType, Quantity, QuickListType, QuickListTypeMap, RANGE_DIRECTION, RANGE_TYPE, RBush, RCDisposable, RESTORE_INSERTED_PARAGRAPH_IDS, RGBA_PAREN, RGB_PAREN, ROTATE_BUFFER_VALUE, RTree, Range, Rectangle, RediError, RedoCommand, RedoCommandId, RefAlias, RegionService, Registry, RegistryAsMap, RelativeDate, ResourceManagerService, RichTextBuilder, RichTextParagraphBuilder, RichTextRunBuilder, RichTextValue, RxDisposable, SECTION_ID_PREFIX, SHEET_EDITOR_UNITS, STYLE_KEYS, SectionType, Self, SheetSkeleton, SheetTypes, SheetViewModel, Skeleton, SkipSelf, SliceBodyType, SpacingRule, Styles, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, THEME_COLORS, TRADITIONAL_DOCUMENT_DEFAULT_MARGIN, TabStopAlignment, TableAlignmentType, TableLayoutType, TableRowHeightRule, TableSizeType, TableTextWrapType, TestConfirmService, TextDecoration, TextDecorationBuilder, TextDirection, TextDirectionType, TextStyleBuilder, TextStyleValue, TextX, TextXActionType, ThemeColorType, ThemeColors, ThemeService, Tools, UndoCommand, UndoCommandId, UnitModel, Univer, UniverInstanceService, UniverInstanceType, UpdateDocsAttributeType, UserManagerService, VerticalAlign, VerticalAlignmentType, WithNew, Workbook, Worksheet, WrapStrategy, WrapTextType, addLinkToDocumentModel, afterInitApply, afterTime, assertBaseTableRecordIdentity, awaitTime, binSearchFirstGreaterThanTarget, binarySearchArray, bufferDebounceTime, cellToRange, characterSpacingControlType, checkForSubstrings, checkIfMove, checkParagraphHasBullet, checkParagraphHasIndent, checkParagraphHasIndentByStyle, cloneBodyWithFreshParagraphIds, cloneCellData, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneParagraphWithId, cloneSectionBreakWithId, cloneValue, cloneWorksheetData, codeToBlob, columnLabelToNumber, composeBody, composeInterceptors, composeStyles, concatMatrixArray, containsInteriorInsertionOffset, containsStreamIndex, convertCellToRange, convertObservableToBehaviorSubject, covertCellValue, covertCellValues, createAsyncInterceptorKey, createBaseRecordIdField, createDefaultBaseTableSnapshot, createDefaultUser, createDocumentModelWithStyle, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createRandomId, createRowColIter, createSectionId, createSheetGapTestConfig, currencySymbols, customNameCharacterCheck, dateKit, debounce, dedupe, dedupeBy, deepCompare, delayAnimationFrame, deleteContent, extractPureTextFromCell, forwardRef, fromCallback, fromEventSubject, generateIntervalsByPoints, generateRandomId, get, getArrayLength, getEmptySnapshot as getBasesEmptySnapshot, getBlockRangeInterval, getBodySlice, getBodySliceForSplitTextXAction, getBodySliceForTextXAction, getBorderStyleType, getCellCoordByIndexSimple, getCellValueType, getCellWithCoordByIndexCore, getColorStyle, getColumnGroupRangeInterval, getCustomBlockIdsInSelections, getCustomBlockInterval, getCustomBlockSlice, getCustomDecorationSlice, getCustomRangeInterval, getCustomRangeSlice, getDisplayValueFromCell, getEmptySnapshot$1 as getDocsEmptySnapshot, getDocsUpdateBody, getEmptyCell, getExclusiveRangeInterval, getInclusiveRangeInterval, getIntersectRange, getNumfmtParseValueFilter, getOriginCellValue, getParagraphContentStartOffset, getParagraphContentStartOffsets, getParagraphFollowingBlockOffset, getParagraphsSlice, getPlainText, getReverseDirection, getRichTextEditPath, getSectionBreakSlice, getSectionHeaderFooterReferenceKey, getEmptySnapshot$2 as getSheetsEmptySnapshot, getSingleDataStreamChange, getTableCellTokenInterval, getTableRangeInterval, getTableRowTokenInterval, getTableSlice, getTextRunSlice, getTransformOffsetX, getTransformOffsetY, getWorksheetUID, groupBy, handleStyleToString, hashAlgorithm, horizontalLineSegmentsSubtraction, insertMatrixArray, insertTextToContent, intersectsOperationalIntervals, invertColorByHSL, invertColorByMatrix, isAsyncDependencyItem, isAsyncHook, isBaseRecordIdFieldName, isBlackColor, isBooleanString, isCellCoverable, isCellV, isClassDependencyItem, isCommentEditorID, isCtor, isDefaultFormat, isDisposable, isEmptyCell, isFactoryDependencyItem, isFormulaId, isFormulaString, isICellData, isInternalEditorID, isNodeEnv, isNotNullOrUndefined, isNullCell, isNumeric, isPatternEqualWithoutDecimal, isRangesEqual, isRealNum, isSafeNumeric, isSafeUrl, isSameStyleTextRun, isTextFormat, isUnitRangesEqual, isValidBaseRecordId, isValidRange, isValueDependencyItem, isWhiteColor, makeArray, makeCellRangeToRangeData, mapObjectMatrix, merge, mergeIntervals, mergeLocales, mergeOverrideWithDependencies, mergeSets, mergeWith, mergeWorksheetSnapshotWithDefault, mixinClass, moveMatrixArray, moveRangeByOffset, nameCharacterCheck, noop, normalizeBody, normalizeInsertedSectionIdsForDocument, normalizeTextRuns, normalizeUrl, numberToABC, numberToListABC, api_exports as numfmt, queryObjectMatrix, regexp, registerDependencies, remove, repeatStringNumTimes, replaceInDocumentBody, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, resolveWithBasePath, rotate, searchArray, searchInOrderedArray, selectionToArray, sequence, sequenceAsync, sequenceExecute, sequenceExecuteAsync, set, setDependencies, shallowEqual, shiftExclusiveRangeOnDelete, shiftExclusiveRangeOnInsert, shiftInclusiveRangeOnDelete, shiftInclusiveRangeOnInsert, skipParseTagNames, sliceMatrixArray, sortRules, sortRulesByDesc, sortRulesFactory, spliceArray, splitIntoGrid, takeAfter, throttle, toDisposable, touchDependencies, updateAttributeByDelete, updateAttributeByInsert, validateDocBodyStructure, validateDocumentStructure, willLoseNumericPrecision };
|