@univerjs/core 1.0.0-rc.0 → 1.0.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 +96 -40
- package/lib/cjs/index.js +985 -362
- package/lib/es/facade.js +97 -41
- package/lib/es/index.js +979 -362
- package/lib/facade.js +97 -41
- package/lib/index.js +979 -362
- package/lib/types/docs/data-model/text-x/action-types.d.ts +19 -1
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +2 -1
- package/lib/types/docs/data-model/text-x/custom-range-update.d.ts +30 -0
- package/lib/types/docs/data-model/text-x/structure-validator.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/text-x.d.ts +7 -3
- package/lib/types/docs/data-model/text-x/utils.d.ts +7 -1
- package/lib/types/docs/sdt-binding.d.ts +19 -0
- package/lib/types/facade/f-blob.d.ts +11 -11
- package/lib/types/facade/f-enum.d.ts +9 -1
- package/lib/types/facade/f-event-registry.d.ts +18 -6
- package/lib/types/facade/f-event.d.ts +4 -0
- package/lib/types/facade/f-univer.d.ts +43 -19
- package/lib/types/index.d.ts +2 -0
- package/lib/types/sheets/typedef.d.ts +38 -7
- package/lib/types/sheets/workbook.d.ts +1 -1
- package/lib/types/sheets/worksheet.d.ts +8 -7
- package/lib/types/types/enum/record-filter.d.ts +30 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +256 -9
- package/lib/types/types/interfaces/i-drawing.d.ts +9 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +26 -26
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
}
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
37
37
|
value: mod,
|
|
38
38
|
enumerable: true
|
|
39
39
|
}) : target, mod));
|
|
@@ -152,7 +152,7 @@ function installShims() {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
//#endregion
|
|
155
|
-
//#region \0@oxc-project+runtime@0.
|
|
155
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
156
156
|
function _typeof(o) {
|
|
157
157
|
"@babel/helpers - typeof";
|
|
158
158
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -163,7 +163,7 @@ function _typeof(o) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region \0@oxc-project+runtime@0.
|
|
166
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
167
167
|
function toPrimitive(t, r) {
|
|
168
168
|
if ("object" != _typeof(t) || !t) return t;
|
|
169
169
|
var e = t[Symbol.toPrimitive];
|
|
@@ -176,14 +176,14 @@ function toPrimitive(t, r) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
//#endregion
|
|
179
|
-
//#region \0@oxc-project+runtime@0.
|
|
179
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
180
180
|
function toPropertyKey(t) {
|
|
181
181
|
var i = toPrimitive(t, "string");
|
|
182
182
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region \0@oxc-project+runtime@0.
|
|
186
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
187
187
|
function _defineProperty(e, r, t) {
|
|
188
188
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
189
189
|
value: t,
|
|
@@ -574,12 +574,14 @@ const re_weburl = /* @__PURE__ */ new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?
|
|
|
574
574
|
function isLegalUrl(url) {
|
|
575
575
|
if (!Number.isNaN(+url)) return false;
|
|
576
576
|
if (url.startsWith("http://localhost:5173") || url.startsWith("localhost:5173")) return true;
|
|
577
|
-
if (re_weburl.test(url))
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
577
|
+
if (re_weburl.test(url)) {
|
|
578
|
+
if (hasProtocol(url)) return true;
|
|
579
|
+
else try {
|
|
580
|
+
const topLevelDomain = new URL(normalizeUrl(url)).hostname.split(".").pop();
|
|
581
|
+
if (topLevelDomain && topLevelDomainSet.has(topLevelDomain)) return true;
|
|
582
|
+
} catch {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
583
585
|
}
|
|
584
586
|
return false;
|
|
585
587
|
}
|
|
@@ -1697,7 +1699,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1697
1699
|
//#endregion
|
|
1698
1700
|
//#region package.json
|
|
1699
1701
|
var name = "@univerjs/core";
|
|
1700
|
-
var version = "1.0.0
|
|
1702
|
+
var version = "1.0.0";
|
|
1701
1703
|
|
|
1702
1704
|
//#endregion
|
|
1703
1705
|
//#region src/common/array.ts
|
|
@@ -2043,7 +2045,7 @@ function hashLogContent(...args) {
|
|
|
2043
2045
|
}
|
|
2044
2046
|
|
|
2045
2047
|
//#endregion
|
|
2046
|
-
//#region \0@oxc-project+runtime@0.
|
|
2048
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
2047
2049
|
function __decorateParam(paramIndex, decorator) {
|
|
2048
2050
|
return function(target, key) {
|
|
2049
2051
|
decorator(target, key, paramIndex);
|
|
@@ -2051,7 +2053,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
2051
2053
|
}
|
|
2052
2054
|
|
|
2053
2055
|
//#endregion
|
|
2054
|
-
//#region \0@oxc-project+runtime@0.
|
|
2056
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
2055
2057
|
function __decorate(decorators, target, key, desc) {
|
|
2056
2058
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2057
2059
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2395,10 +2397,12 @@ var MultiCommand = class {
|
|
|
2395
2397
|
}
|
|
2396
2398
|
};
|
|
2397
2399
|
function sequenceExecute(tasks, commandService, options) {
|
|
2398
|
-
|
|
2400
|
+
const taskFns = tasks.map((task) => () => commandService.syncExecuteCommand(task.id, task.params, options));
|
|
2401
|
+
return sequence(taskFns);
|
|
2399
2402
|
}
|
|
2400
2403
|
function sequenceExecuteAsync(tasks, commandService, options) {
|
|
2401
|
-
|
|
2404
|
+
const promises = tasks.map((task) => () => commandService.executeCommand(task.id, task.params, options));
|
|
2405
|
+
return sequenceAsync(promises);
|
|
2402
2406
|
}
|
|
2403
2407
|
|
|
2404
2408
|
//#endregion
|
|
@@ -3699,9 +3703,7 @@ const rgb2Hsl = (color) => {
|
|
|
3699
3703
|
case g:
|
|
3700
3704
|
h = (b - r) / d + 2;
|
|
3701
3705
|
break;
|
|
3702
|
-
default:
|
|
3703
|
-
h = (r - g) / d + 4;
|
|
3704
|
-
break;
|
|
3706
|
+
default: h = (r - g) / d + 4;
|
|
3705
3707
|
}
|
|
3706
3708
|
h /= 6;
|
|
3707
3709
|
}
|
|
@@ -3733,9 +3735,7 @@ const rgb2Hsv = (color) => {
|
|
|
3733
3735
|
case g:
|
|
3734
3736
|
h = (b - r) / d + 2;
|
|
3735
3737
|
break;
|
|
3736
|
-
default:
|
|
3737
|
-
h = (r - g) / d + 4;
|
|
3738
|
-
break;
|
|
3738
|
+
default: h = (r - g) / d + 4;
|
|
3739
3739
|
}
|
|
3740
3740
|
h /= 6;
|
|
3741
3741
|
}
|
|
@@ -3801,8 +3801,27 @@ let UpdateDocsAttributeType = /* @__PURE__ */ function(UpdateDocsAttributeType)
|
|
|
3801
3801
|
|
|
3802
3802
|
//#endregion
|
|
3803
3803
|
//#region src/sheets/typedef.ts
|
|
3804
|
+
/** Worksheet-only hiding states; row/column and cell flags still use BooleanNumber. */
|
|
3805
|
+
let WorksheetHiddenState = /* @__PURE__ */ function(WorksheetHiddenState) {
|
|
3806
|
+
/** Visible in the sheet bar. Preserves the existing hidden: 0 value. */
|
|
3807
|
+
WorksheetHiddenState[WorksheetHiddenState["VISIBLE"] = 0] = "VISIBLE";
|
|
3808
|
+
/** Hidden, and listed in the UI's Unhide dialog. Preserves hidden: 1. */
|
|
3809
|
+
WorksheetHiddenState[WorksheetHiddenState["HIDDEN"] = 1] = "HIDDEN";
|
|
3810
|
+
/** Omitted from Unhide UI; can be revealed through the API. Not an access permission. */
|
|
3811
|
+
WorksheetHiddenState[WorksheetHiddenState["VERY_HIDDEN"] = 2] = "VERY_HIDDEN";
|
|
3812
|
+
return WorksheetHiddenState;
|
|
3813
|
+
}({});
|
|
3814
|
+
/** Formula kinds from SpreadsheetML ST_CellFormulaType. */
|
|
3815
|
+
let FormulaType = /* @__PURE__ */ function(FormulaType) {
|
|
3816
|
+
FormulaType[FormulaType["NORMAL"] = 0] = "NORMAL";
|
|
3817
|
+
FormulaType[FormulaType["SHARED"] = 1] = "SHARED";
|
|
3818
|
+
FormulaType[FormulaType["ARRAY"] = 2] = "ARRAY";
|
|
3819
|
+
/** What-if analysis data table, not a structured table. */
|
|
3820
|
+
FormulaType[FormulaType["DATA_TABLE"] = 3] = "DATA_TABLE";
|
|
3821
|
+
return FormulaType;
|
|
3822
|
+
}({});
|
|
3804
3823
|
function isICellData(value) {
|
|
3805
|
-
return value && (value.s !== void 0 || value.p !== void 0 || value.v !== void 0 || value.t !== void 0 || value.f !== void 0 || value.si !== void 0 || value.custom !== void 0);
|
|
3824
|
+
return value && (value.s !== void 0 || value.p !== void 0 || value.v !== void 0 || value.t !== void 0 || value.f !== void 0 || value.ft !== void 0 || value.fd !== void 0 || value.si !== void 0 || value.custom !== void 0);
|
|
3806
3825
|
}
|
|
3807
3826
|
function getCellValueType(cell) {
|
|
3808
3827
|
if (cell.t !== void 0) return cell.t;
|
|
@@ -4017,22 +4036,6 @@ const reCurrencySymbols = new RegExp(`[${currencySymbols$1.join("")}]`);
|
|
|
4017
4036
|
|
|
4018
4037
|
//#endregion
|
|
4019
4038
|
//#region src/shared/numfmt/decimal.ts
|
|
4020
|
-
/**
|
|
4021
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4022
|
-
*
|
|
4023
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4024
|
-
* you may not use this file except in compliance with the License.
|
|
4025
|
-
* You may obtain a copy of the License at
|
|
4026
|
-
*
|
|
4027
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4028
|
-
*
|
|
4029
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4030
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4031
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4032
|
-
* See the License for the specific language governing permissions and
|
|
4033
|
-
* limitations under the License.
|
|
4034
|
-
*/
|
|
4035
|
-
const SPREADSHEET_SIGNIFICANT_DIGITS = 15;
|
|
4036
4039
|
function decimalFromNumber(value) {
|
|
4037
4040
|
if (!Number.isFinite(value)) throw new RangeError("decimalFromNumber requires a finite number");
|
|
4038
4041
|
const negative = value < 0 || Object.is(value, -0);
|
|
@@ -4041,7 +4044,7 @@ function decimalFromNumber(value) {
|
|
|
4041
4044
|
digits: "0",
|
|
4042
4045
|
exponent: 0
|
|
4043
4046
|
};
|
|
4044
|
-
const [mantissa, exponentText] = Math.abs(value).toExponential(
|
|
4047
|
+
const [mantissa, exponentText] = Math.abs(value).toExponential(14).split("e");
|
|
4045
4048
|
return {
|
|
4046
4049
|
negative,
|
|
4047
4050
|
digits: mantissa.replace(".", "").replace(/0+$/, "") || "0",
|
|
@@ -5041,7 +5044,6 @@ function minMaxPad(str, part, prefix) {
|
|
|
5041
5044
|
case "num":
|
|
5042
5045
|
part.num_max = max;
|
|
5043
5046
|
part.num_min = min;
|
|
5044
|
-
break;
|
|
5045
5047
|
}
|
|
5046
5048
|
return part;
|
|
5047
5049
|
}
|
|
@@ -5213,8 +5215,10 @@ function parseFormatSection(inputTokens) {
|
|
|
5213
5215
|
date: 1
|
|
5214
5216
|
}, outputTokens);
|
|
5215
5217
|
} else if (type === "calendar") {
|
|
5216
|
-
if (!haveLocale)
|
|
5217
|
-
|
|
5218
|
+
if (!haveLocale) {
|
|
5219
|
+
if (token.value === "B2" || token.value === "b2") part.date_system = 6;
|
|
5220
|
+
else part.date_system = 1;
|
|
5221
|
+
}
|
|
5218
5222
|
} else if (type === "datetime") {
|
|
5219
5223
|
const bit = {
|
|
5220
5224
|
type: "",
|
|
@@ -5631,13 +5635,14 @@ function general(output, part, value, locale, decimalValue = null) {
|
|
|
5631
5635
|
} else if (exponent === 10) {
|
|
5632
5636
|
const formatted = absoluteValue.toFixed(10).slice(0, 12).replace(/\.$/, "");
|
|
5633
5637
|
output.push(fixLocale(formatted, locale));
|
|
5634
|
-
} else if (Math.abs(exponent) <= 9)
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5638
|
+
} else if (Math.abs(exponent) <= 9) {
|
|
5639
|
+
if (digits.total <= 11) {
|
|
5640
|
+
const formatted = round(absoluteValue, 9).toFixed(digits.frac);
|
|
5641
|
+
output.push(fixLocale(formatted, locale));
|
|
5642
|
+
} else if (exponent === 9) output.push(Math.floor(absoluteValue));
|
|
5643
|
+
else if (exponent >= 0 && exponent < 9) output.push(fixLocale(String(round(absoluteValue, 9 - exponent)), locale));
|
|
5644
|
+
else output.push(...shortestSignificand === null ? getExp(absoluteDecimal, locale) : getShortestExp(shortestSignificand, exponent, locale));
|
|
5645
|
+
} else if (digits.total >= 12) output.push(...shortestSignificand === null ? getExp(absoluteDecimal, locale) : getShortestExp(shortestSignificand, exponent, locale));
|
|
5641
5646
|
else output.push(fixLocale(round(absoluteValue, 9).toFixed(digits.frac), locale));
|
|
5642
5647
|
}
|
|
5643
5648
|
return output;
|
|
@@ -5759,7 +5764,7 @@ const EXCEL_1904_OFFSET = 1462;
|
|
|
5759
5764
|
const EXCEL_1900_MAX_SERIAL = 2958465;
|
|
5760
5765
|
const MAX_YEAR = 9999;
|
|
5761
5766
|
function getDateSystemMaxSerial(dateSystem = "date1900") {
|
|
5762
|
-
return dateSystem === "date1904" ?
|
|
5767
|
+
return dateSystem === "date1904" ? 2957003 : EXCEL_1900_MAX_SERIAL;
|
|
5763
5768
|
}
|
|
5764
5769
|
function isLeapYear(year) {
|
|
5765
5770
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
@@ -5801,7 +5806,8 @@ function datePartsToExcel1900Serial(year, month, day) {
|
|
|
5801
5806
|
function excelSerialToDateTimeParts(serial, options) {
|
|
5802
5807
|
if (!Number.isFinite(serial) || serial < 0) return null;
|
|
5803
5808
|
const wholeDays = Math.floor(serial);
|
|
5804
|
-
const
|
|
5809
|
+
const excel1900Serial = options.dateSystem === "date1904" ? wholeDays + EXCEL_1904_OFFSET : wholeDays;
|
|
5810
|
+
const [year, month, day] = toYMD(excel1900Serial, 0, true);
|
|
5805
5811
|
if (year > MAX_YEAR) return null;
|
|
5806
5812
|
const totalSeconds = (serial - wholeDays) * DAYSIZE$1;
|
|
5807
5813
|
const wholeSeconds = Math.floor(totalSeconds);
|
|
@@ -5990,11 +5996,13 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
5990
5996
|
}
|
|
5991
5997
|
const requiresDecimalRounding = !Number.isSafeInteger(numericValue) || Boolean(section.scaleExponent);
|
|
5992
5998
|
roundedNumber = roundedNumber || (decimal && requiresDecimalRounding && !section.date && !section.fractions && !section.exponential && (section.integer || section.dec_fractions) ? roundDecimal(decimal, section.frac_max) : null);
|
|
5993
|
-
if (section.integer)
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5999
|
+
if (section.integer) {
|
|
6000
|
+
if (roundedNumber) integer = roundedNumber.integer === "0" ? "" : roundedNumber.integer;
|
|
6001
|
+
else {
|
|
6002
|
+
const places = section.fractions ? 1 : section.frac_max;
|
|
6003
|
+
const roundedInteger = Math.abs(Number.isSafeInteger(numericValue) && places === 0 ? numericValue : legacyRound(numericValue, places));
|
|
6004
|
+
integer += roundedInteger < 1 ? "" : Math.floor(roundedInteger);
|
|
6005
|
+
}
|
|
5998
6006
|
}
|
|
5999
6007
|
const primaryGroup = options.grouping[0] ?? 3;
|
|
6000
6008
|
const secondaryGroup = options.grouping[1] ?? primaryGroup;
|
|
@@ -6068,7 +6076,10 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
6068
6076
|
weekday = ((dateSystem === -1 ? 5 : 6) + date) % 7;
|
|
6069
6077
|
if (section.date_eval && dateOverflows(numericValue, date + time / DAYSIZE, options.dateSpanLarge, options.dateSystem)) {
|
|
6070
6078
|
if (options.dateErrorThrows) throw new Error("Date out of bounds");
|
|
6071
|
-
if (options.dateErrorNumber)
|
|
6079
|
+
if (options.dateErrorNumber) {
|
|
6080
|
+
const output = numericValue < 0 ? [l10n.negative] : [];
|
|
6081
|
+
return general(output, {}, numericValue, l10n, decimal).join("");
|
|
6082
|
+
}
|
|
6072
6083
|
return options.overflow;
|
|
6073
6084
|
}
|
|
6074
6085
|
}
|
|
@@ -6109,44 +6120,49 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
6109
6120
|
else if (section.den_min > 0) output.push(tokenValue.replace(/./g, questionPadding));
|
|
6110
6121
|
}
|
|
6111
6122
|
} else output.push(tokenValue.replace(/ /g, questionPadding));
|
|
6112
|
-
} else if (tokenType === "space")
|
|
6113
|
-
if (
|
|
6114
|
-
|
|
6115
|
-
|
|
6123
|
+
} else if (tokenType === "space") {
|
|
6124
|
+
if (token.rule === "num+int") {
|
|
6125
|
+
if ((haveFraction || section.num_min || section.den_min) && (integer || section.num_min)) output.push(questionPadding);
|
|
6126
|
+
} else output.push(questionPadding);
|
|
6127
|
+
} else if (tokenType === "error") output.push(options.invalid);
|
|
6116
6128
|
else if (tokenType === "point") output.push(section.date ? token.value : l10n.decimal);
|
|
6117
6129
|
else if (tokenType === "general") general(output, section, renderValue, l10n, decimal);
|
|
6118
6130
|
else if (tokenType === "exp") output.push(l10n.exponent);
|
|
6119
|
-
else if (tokenType === "minus")
|
|
6120
|
-
if (
|
|
6121
|
-
|
|
6122
|
-
if (numericValue
|
|
6123
|
-
|
|
6124
|
-
|
|
6131
|
+
else if (tokenType === "minus") {
|
|
6132
|
+
if (token.volatile && section.date) {} else if (token.volatile && roundedNumber) {
|
|
6133
|
+
if (roundedNumber.negative && !roundedNumber.zero) output.push(l10n.negative);
|
|
6134
|
+
} else if (token.volatile && (numericValue >= 0 || typeof renderValue !== "number")) {} else if (token.volatile && !section.fractions && (section.integer || section.dec_fractions)) {
|
|
6135
|
+
if (numericValue < 0 && !!integer && integer !== "0" || fraction) output.push(l10n.negative);
|
|
6136
|
+
} else output.push(l10n.negative);
|
|
6137
|
+
} else if (tokenType === "plus") output.push(l10n.positive);
|
|
6125
6138
|
else if (tokenType === "text") output.push(renderValue);
|
|
6126
6139
|
else if (tokenType === "fill") {
|
|
6127
6140
|
if (options.fillChar) output.push(options.fillChar, token.value);
|
|
6128
|
-
} else if (tokenType === "skip")
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
else if (
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
const
|
|
6139
|
-
|
|
6140
|
-
let
|
|
6141
|
-
|
|
6142
|
-
const
|
|
6143
|
-
|
|
6141
|
+
} else if (tokenType === "skip") {
|
|
6142
|
+
if (options.skipChar) output.push(options.skipChar, token.value);
|
|
6143
|
+
else output.push(options.nbsp ? "\xA0" : " ");
|
|
6144
|
+
} else if (tokenType === "div") {
|
|
6145
|
+
if (haveFraction) output.push("/");
|
|
6146
|
+
else if (section.num_min > 0 || section.den_min > 0) output.push(questionPadding);
|
|
6147
|
+
else output.push(pad$1("#", options.nbsp));
|
|
6148
|
+
} else if (tokenType === "int") {
|
|
6149
|
+
if (section.int_pattern.length === 1) {
|
|
6150
|
+
const pattern = section.int_p;
|
|
6151
|
+
const length = Math.max(section.int_min, integer.length);
|
|
6152
|
+
let digits = "";
|
|
6153
|
+
for (let index = length; index > 0; index--) {
|
|
6154
|
+
const digit = integer.charAt(integer.length - index);
|
|
6155
|
+
const patternDigit = digit ? "" : pattern.charAt(pattern.length - index) || pattern[0];
|
|
6156
|
+
let separator = "";
|
|
6157
|
+
if (section.grouping) {
|
|
6158
|
+
const groupIndex = index - 1 - primaryGroup;
|
|
6159
|
+
if (groupIndex >= 0 && !(groupIndex % secondaryGroup)) separator = digit || patternDigit === "0" ? l10n.group : pad$1("?", options.nbsp);
|
|
6160
|
+
}
|
|
6161
|
+
digits += (digit || pad$1(patternDigit, options.nbsp)) + separator;
|
|
6144
6162
|
}
|
|
6145
|
-
digits
|
|
6146
|
-
}
|
|
6147
|
-
|
|
6148
|
-
} else counter.int += digitsStart(integer, section.int_p, token.num, counter.int);
|
|
6149
|
-
else if (tokenType === "frac") {
|
|
6163
|
+
output.push(digits);
|
|
6164
|
+
} else counter.int += digitsStart(integer, section.int_p, token.num, counter.int);
|
|
6165
|
+
} else if (tokenType === "frac") {
|
|
6150
6166
|
const offset = counter.frac;
|
|
6151
6167
|
for (let index = 0; index < length; index++) output.push(fraction[index + offset] || pad$1(token.num[index], options.nbsp));
|
|
6152
6168
|
counter.frac += length;
|
|
@@ -6176,13 +6192,16 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
6176
6192
|
const shortYear = year % 100;
|
|
6177
6193
|
output.push(shortYear < 10 ? "0" : "", shortYear);
|
|
6178
6194
|
} else if (tokenType === "month") output.push(token.pad && month < 10 ? "0" : "", month);
|
|
6179
|
-
else if (tokenType === "monthname-single")
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
else
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
else if (
|
|
6195
|
+
else if (tokenType === "monthname-single") {
|
|
6196
|
+
if (section.date_system === 6) output.push(l10n.mmmm6[month - 1].charAt(0));
|
|
6197
|
+
else output.push(l10n.mmmm[month - 1].charAt(0));
|
|
6198
|
+
} else if (tokenType === "monthname-short") {
|
|
6199
|
+
if (section.date_system === 6) output.push(l10n.mmm6[month - 1]);
|
|
6200
|
+
else output.push(l10n.mmm[month - 1]);
|
|
6201
|
+
} else if (tokenType === "monthname") {
|
|
6202
|
+
if (section.date_system === 6) output.push(l10n.mmmm6[month - 1]);
|
|
6203
|
+
else output.push(l10n.mmmm[month - 1]);
|
|
6204
|
+
} else if (token.type === "weekday-short") output.push(l10n.ddd[weekday]);
|
|
6186
6205
|
else if (tokenType === "weekday") output.push(l10n.dddd[weekday]);
|
|
6187
6206
|
else if (tokenType === "day") output.push(token.pad && day < 10 ? "0" : "", day);
|
|
6188
6207
|
else if (tokenType === "hour") {
|
|
@@ -6700,7 +6719,7 @@ const tokenHandlers = [
|
|
|
6700
6719
|
],
|
|
6701
6720
|
[
|
|
6702
6721
|
TOKEN_ESCAPED,
|
|
6703
|
-
/^\\(
|
|
6722
|
+
/^\\([\s\S])/,
|
|
6704
6723
|
1
|
|
6705
6724
|
],
|
|
6706
6725
|
[
|
|
@@ -6922,11 +6941,13 @@ function parsePattern(pattern) {
|
|
|
6922
6941
|
volatile: true
|
|
6923
6942
|
}));
|
|
6924
6943
|
if (partitions.length < 3) partitions.push(clonePart(partitions[0]));
|
|
6925
|
-
if (partitions.length < 4)
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6944
|
+
if (partitions.length < 4) {
|
|
6945
|
+
if (textPartition) partitions.push(textPartition);
|
|
6946
|
+
else {
|
|
6947
|
+
const text = parseFormatSection(tokenize("@"));
|
|
6948
|
+
text.generated = true;
|
|
6949
|
+
partitions.push(text);
|
|
6950
|
+
}
|
|
6930
6951
|
}
|
|
6931
6952
|
partitions[0].condition = [">", 0];
|
|
6932
6953
|
partitions[1].condition = ["<", 0];
|
|
@@ -7431,7 +7452,7 @@ function parseTime(value, options = {}) {
|
|
|
7431
7452
|
const secondsFormat = secondsPart ? ":ss" : "";
|
|
7432
7453
|
const ampmFormat = ampm ? " AM/PM" : "";
|
|
7433
7454
|
return {
|
|
7434
|
-
v: (hours * 60 * 60 + minutes * 60 + seconds + milliseconds) /
|
|
7455
|
+
v: (hours * 60 * 60 + minutes * 60 + seconds + milliseconds) / 86400,
|
|
7435
7456
|
z: `${hourFormat}:mm${secondsFormat}${ampmFormat}`
|
|
7436
7457
|
};
|
|
7437
7458
|
}
|
|
@@ -7511,7 +7532,8 @@ function prepareFormatterData(pattern, shouldThrow = false) {
|
|
|
7511
7532
|
function format(pattern, value, options = {}) {
|
|
7512
7533
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7513
7534
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7514
|
-
|
|
7535
|
+
const normalizedValue = dateToSerial(value, resolvedOptions) ?? value;
|
|
7536
|
+
return formatValue(normalizedValue, data, resolvedOptions);
|
|
7515
7537
|
}
|
|
7516
7538
|
/**
|
|
7517
7539
|
* Find the color appropriate to a value as dictated by a format pattern.
|
|
@@ -7519,19 +7541,23 @@ function format(pattern, value, options = {}) {
|
|
|
7519
7541
|
function formatColor(pattern, value, options) {
|
|
7520
7542
|
const resolvedOptions = Object.assign({}, defaultOptions, options);
|
|
7521
7543
|
const data = prepareFormatterData(pattern, resolvedOptions.throws);
|
|
7522
|
-
|
|
7544
|
+
const normalizedValue = dateToSerial(value, resolvedOptions) ?? value;
|
|
7545
|
+
return formatColor$1(normalizedValue, data, resolvedOptions);
|
|
7523
7546
|
}
|
|
7524
7547
|
/** Determine if a given format pattern is a date pattern. */
|
|
7525
7548
|
function isDateFormat(pattern) {
|
|
7526
|
-
|
|
7549
|
+
const data = prepareFormatterData(pattern, false);
|
|
7550
|
+
return isDate(data.partitions);
|
|
7527
7551
|
}
|
|
7528
7552
|
/** Determine if a given format pattern is a percentage pattern. */
|
|
7529
7553
|
function isPercentFormat(pattern) {
|
|
7530
|
-
|
|
7554
|
+
const data = prepareFormatterData(pattern, false);
|
|
7555
|
+
return isPercent(data.partitions);
|
|
7531
7556
|
}
|
|
7532
7557
|
/** Determine if a given format pattern is a text only pattern. */
|
|
7533
7558
|
function isTextFormat$1(pattern) {
|
|
7534
|
-
|
|
7559
|
+
const data = prepareFormatterData(pattern, false);
|
|
7560
|
+
return isText(data.partitions);
|
|
7535
7561
|
}
|
|
7536
7562
|
/** Determine if a given format pattern is valid. */
|
|
7537
7563
|
function isValidFormat(pattern) {
|
|
@@ -7556,7 +7582,8 @@ function getFormatDateInfo(pattern) {
|
|
|
7556
7582
|
}
|
|
7557
7583
|
/** Completes omitted components in a calendar-date or clock pattern for editing; elapsed durations return null. */
|
|
7558
7584
|
function getDateTimeEditPattern(pattern, value) {
|
|
7559
|
-
|
|
7585
|
+
const data = prepareFormatterData(pattern, false);
|
|
7586
|
+
return createDateTimeEditPattern(data.partitions, value);
|
|
7560
7587
|
}
|
|
7561
7588
|
/** A dictionary of the types used to identify token variants. */
|
|
7562
7589
|
const tokenTypes = Object.freeze({
|
|
@@ -7807,7 +7834,8 @@ function createLiteralRegExp(value, flags) {
|
|
|
7807
7834
|
* regular-expression syntax is treated as literal text. Matching is case-insensitive.
|
|
7808
7835
|
*/
|
|
7809
7836
|
function createFromWildcard(pattern) {
|
|
7810
|
-
|
|
7837
|
+
const source = escapeRegExp$1(pattern).replace(/\\\*/g, ".*").replace(/\\\?/g, ".");
|
|
7838
|
+
return createRegExpFromSafeFragment(`^${source}$`, "i");
|
|
7811
7839
|
}
|
|
7812
7840
|
|
|
7813
7841
|
//#endregion
|
|
@@ -8061,8 +8089,10 @@ function mapObjectMatrix(o, callback) {
|
|
|
8061
8089
|
const colNumber = Number(col);
|
|
8062
8090
|
const value = columns[colNumber];
|
|
8063
8091
|
const resultValue = callback(rowNumber, colNumber, value);
|
|
8064
|
-
if (resultValue !== void 0)
|
|
8065
|
-
|
|
8092
|
+
if (resultValue !== void 0) {
|
|
8093
|
+
if (result[rowNumber]) result[rowNumber][colNumber] = resultValue;
|
|
8094
|
+
else result[rowNumber] = { [colNumber]: resultValue };
|
|
8095
|
+
}
|
|
8066
8096
|
}
|
|
8067
8097
|
}
|
|
8068
8098
|
return result;
|
|
@@ -8101,8 +8131,14 @@ function concatMatrixArray(source, target) {
|
|
|
8101
8131
|
const targetLength = targetKeys.length;
|
|
8102
8132
|
const containerArray = {};
|
|
8103
8133
|
let master = 0;
|
|
8104
|
-
for (let i = 0; i < srcLength; i++, master++)
|
|
8105
|
-
|
|
8134
|
+
for (let i = 0; i < srcLength; i++, master++) {
|
|
8135
|
+
const key = srcKeys[i];
|
|
8136
|
+
containerArray[master] = srcArray[key];
|
|
8137
|
+
}
|
|
8138
|
+
for (let i = 0; i < targetLength; i++, master++) {
|
|
8139
|
+
const key = targetKeys[i];
|
|
8140
|
+
containerArray[master] = targetArray[key];
|
|
8141
|
+
}
|
|
8106
8142
|
return containerArray;
|
|
8107
8143
|
}
|
|
8108
8144
|
function sliceMatrixArray(start, end, matrixArray) {
|
|
@@ -8320,7 +8356,8 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8320
8356
|
const row = {};
|
|
8321
8357
|
let insertColumn = 0;
|
|
8322
8358
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
8323
|
-
|
|
8359
|
+
const value = this.getValue(r, c);
|
|
8360
|
+
row[insertColumn] = value;
|
|
8324
8361
|
insertColumn++;
|
|
8325
8362
|
}
|
|
8326
8363
|
objectMatrix.setRow(insertRow, row);
|
|
@@ -8939,8 +8976,13 @@ function deepCompare(arg1, arg2) {
|
|
|
8939
8976
|
function isSameStyleTextRun(tr1, tr2) {
|
|
8940
8977
|
const ts1 = tr1.ts || {};
|
|
8941
8978
|
const ts2 = tr2.ts || {};
|
|
8942
|
-
if (tr1.sId !== tr2.sId) return false;
|
|
8943
|
-
|
|
8979
|
+
if (tr1.sId !== tr2.sId || !deepCompare(ts1, ts2)) return false;
|
|
8980
|
+
const metadataKeys = /* @__PURE__ */ new Set([...Object.keys(tr1), ...Object.keys(tr2)]);
|
|
8981
|
+
for (const key of metadataKeys) {
|
|
8982
|
+
if (key === "st" || key === "ed" || key === "ts" || key === "sId") continue;
|
|
8983
|
+
if (!deepCompare(tr1[key], tr2[key])) return false;
|
|
8984
|
+
}
|
|
8985
|
+
return true;
|
|
8944
8986
|
}
|
|
8945
8987
|
function checkForSubstrings(searchString, substrings) {
|
|
8946
8988
|
return substrings.some((substring) => searchString.indexOf(substring) > -1);
|
|
@@ -8948,7 +8990,7 @@ function checkForSubstrings(searchString, substrings) {
|
|
|
8948
8990
|
|
|
8949
8991
|
//#endregion
|
|
8950
8992
|
//#region src/shared/date-kit.ts
|
|
8951
|
-
const SECOND = 1e3
|
|
8993
|
+
const SECOND = 1e3;
|
|
8952
8994
|
const MINUTE = 60 * SECOND;
|
|
8953
8995
|
const HOUR = 60 * MINUTE;
|
|
8954
8996
|
const DAY = 24 * HOUR;
|
|
@@ -9193,9 +9235,7 @@ function setDatePart(date, isUTC, part, value) {
|
|
|
9193
9235
|
case "second":
|
|
9194
9236
|
next.setUTCSeconds(value);
|
|
9195
9237
|
break;
|
|
9196
|
-
case "millisecond":
|
|
9197
|
-
next.setUTCMilliseconds(value);
|
|
9198
|
-
break;
|
|
9238
|
+
case "millisecond": next.setUTCMilliseconds(value);
|
|
9199
9239
|
}
|
|
9200
9240
|
return next;
|
|
9201
9241
|
}
|
|
@@ -9218,9 +9258,7 @@ function setDatePart(date, isUTC, part, value) {
|
|
|
9218
9258
|
case "second":
|
|
9219
9259
|
next.setSeconds(value);
|
|
9220
9260
|
break;
|
|
9221
|
-
case "millisecond":
|
|
9222
|
-
next.setMilliseconds(value);
|
|
9223
|
-
break;
|
|
9261
|
+
case "millisecond": next.setMilliseconds(value);
|
|
9224
9262
|
}
|
|
9225
9263
|
return next;
|
|
9226
9264
|
}
|
|
@@ -9869,7 +9907,7 @@ function createIdByMathRandom(size, alphabet) {
|
|
|
9869
9907
|
}
|
|
9870
9908
|
function createIdByCrypto(size, alphabet, getCryptoRandomValues) {
|
|
9871
9909
|
const safeByteCutoff = 256 - 256 % alphabet.length;
|
|
9872
|
-
const step = Math.ceil(
|
|
9910
|
+
const step = Math.ceil(409.6 * size / safeByteCutoff);
|
|
9873
9911
|
let id = "";
|
|
9874
9912
|
while (id.length < size) {
|
|
9875
9913
|
const bytes = getCryptoRandomValues(new Uint8Array(step));
|
|
@@ -10307,7 +10345,6 @@ _defineProperty(Rectangle, "moveOffset", (range, offsetX, offsetY) => {
|
|
|
10307
10345
|
default:
|
|
10308
10346
|
_range.startRow += offsetY;
|
|
10309
10347
|
_range.startColumn += offsetX;
|
|
10310
|
-
break;
|
|
10311
10348
|
}
|
|
10312
10349
|
switch (range.endAbsoluteRefType) {
|
|
10313
10350
|
case 1:
|
|
@@ -10321,7 +10358,6 @@ _defineProperty(Rectangle, "moveOffset", (range, offsetX, offsetY) => {
|
|
|
10321
10358
|
default:
|
|
10322
10359
|
_range.endRow += offsetY;
|
|
10323
10360
|
_range.endColumn += offsetX;
|
|
10324
|
-
break;
|
|
10325
10361
|
}
|
|
10326
10362
|
return _range;
|
|
10327
10363
|
});
|
|
@@ -10429,35 +10465,6 @@ function splitIntoGrid(ranges) {
|
|
|
10429
10465
|
return result;
|
|
10430
10466
|
}
|
|
10431
10467
|
/**
|
|
10432
|
-
* Horizontal Merging
|
|
10433
|
-
* @param ranges no overlap ranges
|
|
10434
|
-
* @returns merged ranges
|
|
10435
|
-
*/
|
|
10436
|
-
function mergeHorizontalRanges(ranges) {
|
|
10437
|
-
ranges.sort((a, b) => a.startRow - b.startRow || a.startColumn - b.startColumn);
|
|
10438
|
-
const rowGroups = {};
|
|
10439
|
-
for (const range of ranges) {
|
|
10440
|
-
if (!rowGroups[range.startRow]) rowGroups[range.startRow] = [];
|
|
10441
|
-
rowGroups[range.startRow].push(range);
|
|
10442
|
-
}
|
|
10443
|
-
const mergedRanges = [];
|
|
10444
|
-
for (const row in rowGroups) {
|
|
10445
|
-
const rangesInRow = rowGroups[+row];
|
|
10446
|
-
rangesInRow.sort((a, b) => a.startColumn - b.startColumn);
|
|
10447
|
-
let currentRange = rangesInRow[0];
|
|
10448
|
-
for (let i = 1; i < rangesInRow.length; i++) {
|
|
10449
|
-
const nextRange = rangesInRow[i];
|
|
10450
|
-
if (nextRange.startColumn <= currentRange.endColumn + 1 && nextRange.startRow === currentRange.startRow && nextRange.endRow === currentRange.endRow) currentRange.endColumn = Math.max(currentRange.endColumn, nextRange.endColumn);
|
|
10451
|
-
else {
|
|
10452
|
-
mergedRanges.push(currentRange);
|
|
10453
|
-
currentRange = nextRange;
|
|
10454
|
-
}
|
|
10455
|
-
}
|
|
10456
|
-
mergedRanges.push(currentRange);
|
|
10457
|
-
}
|
|
10458
|
-
return mergedRanges;
|
|
10459
|
-
}
|
|
10460
|
-
/**
|
|
10461
10468
|
* Vertical Merging
|
|
10462
10469
|
* @param ranges no overlap ranges
|
|
10463
10470
|
* @returns merged ranges
|
|
@@ -10492,7 +10499,37 @@ function mergeVerticalRanges(ranges) {
|
|
|
10492
10499
|
* @returns ranges
|
|
10493
10500
|
*/
|
|
10494
10501
|
function mergeRanges(ranges) {
|
|
10495
|
-
|
|
10502
|
+
const events = /* @__PURE__ */ new Map();
|
|
10503
|
+
for (const range of ranges) for (const [row, add] of [[range.startRow, true], [range.endRow + 1, false]]) {
|
|
10504
|
+
const entries = events.get(row) ?? [];
|
|
10505
|
+
entries.push({
|
|
10506
|
+
range,
|
|
10507
|
+
add
|
|
10508
|
+
});
|
|
10509
|
+
events.set(row, entries);
|
|
10510
|
+
}
|
|
10511
|
+
const rows = [...events.keys()].sort((a, b) => a - b);
|
|
10512
|
+
const active = /* @__PURE__ */ new Set();
|
|
10513
|
+
const horizontalMerged = [];
|
|
10514
|
+
for (let index = 0; index < rows.length - 1; index++) {
|
|
10515
|
+
const startRow = rows[index];
|
|
10516
|
+
const endRow = rows[index + 1] - 1;
|
|
10517
|
+
for (const { range, add } of events.get(startRow)) if (add) active.add(range);
|
|
10518
|
+
else active.delete(range);
|
|
10519
|
+
const intervals = [...active].sort((a, b) => a.startColumn - b.startColumn || a.endColumn - b.endColumn);
|
|
10520
|
+
let current;
|
|
10521
|
+
for (const range of intervals) if (current && range.startColumn <= current.endColumn + 1) current.endColumn = Math.max(current.endColumn, range.endColumn);
|
|
10522
|
+
else {
|
|
10523
|
+
current = {
|
|
10524
|
+
startRow,
|
|
10525
|
+
endRow,
|
|
10526
|
+
startColumn: range.startColumn,
|
|
10527
|
+
endColumn: range.endColumn
|
|
10528
|
+
};
|
|
10529
|
+
horizontalMerged.push(current);
|
|
10530
|
+
}
|
|
10531
|
+
}
|
|
10532
|
+
return mergeVerticalRanges(horizontalMerged);
|
|
10496
10533
|
}
|
|
10497
10534
|
function multiSubtractSingleRange(ranges, toDelete) {
|
|
10498
10535
|
const res = [];
|
|
@@ -10535,10 +10572,10 @@ function getIntersectRange(src, target) {
|
|
|
10535
10572
|
* @returns A tuple containing the start and end of the overlap, or null if there is no overlap.
|
|
10536
10573
|
*/
|
|
10537
10574
|
function getOverlap1D(start1, end1, start2, end2) {
|
|
10538
|
-
const s1 = isNaN(start1) ? -Infinity : start1;
|
|
10539
|
-
const e1 = isNaN(end1) ? Infinity : end1;
|
|
10540
|
-
const s2 = isNaN(start2) ? -Infinity : start2;
|
|
10541
|
-
const e2 = isNaN(end2) ? Infinity : end2;
|
|
10575
|
+
const s1 = Number.isNaN(start1) ? -Infinity : start1;
|
|
10576
|
+
const e1 = Number.isNaN(end1) ? Infinity : end1;
|
|
10577
|
+
const s2 = Number.isNaN(start2) ? -Infinity : start2;
|
|
10578
|
+
const e2 = Number.isNaN(end2) ? Infinity : end2;
|
|
10542
10579
|
const start = Math.max(s1, s2);
|
|
10543
10580
|
const end = Math.min(e1, e2);
|
|
10544
10581
|
if (start <= end) return [start === -Infinity ? NaN : start, end === Infinity ? NaN : end];
|
|
@@ -10577,8 +10614,8 @@ function determineRangeType(srcType, targetType, startRow, endRow, startColumn,
|
|
|
10577
10614
|
* @returns The inferred rangeType.
|
|
10578
10615
|
*/
|
|
10579
10616
|
function inferRangeType(startRow, endRow, startColumn, endColumn) {
|
|
10580
|
-
const hasRow = !isNaN(startRow) && !isNaN(endRow);
|
|
10581
|
-
const hasColumn = !isNaN(startColumn) && !isNaN(endColumn);
|
|
10617
|
+
const hasRow = !Number.isNaN(startRow) && !Number.isNaN(endRow);
|
|
10618
|
+
const hasColumn = !Number.isNaN(startColumn) && !Number.isNaN(endColumn);
|
|
10582
10619
|
if (hasRow && hasColumn) return 0;
|
|
10583
10620
|
else if (hasRow) return 1;
|
|
10584
10621
|
else if (hasColumn) return 2;
|
|
@@ -11699,6 +11736,14 @@ let DrawingTypeEnum = /* @__PURE__ */ function(DrawingTypeEnum) {
|
|
|
11699
11736
|
* Block element, allows host products to place embeddable unit-backed blocks as drawing objects.
|
|
11700
11737
|
*/
|
|
11701
11738
|
DrawingTypeEnum[DrawingTypeEnum["DRAWING_BLOCK"] = 9] = "DRAWING_BLOCK";
|
|
11739
|
+
/**
|
|
11740
|
+
* Spreadsheet Slicer control.
|
|
11741
|
+
*/
|
|
11742
|
+
DrawingTypeEnum[DrawingTypeEnum["DRAWING_SLICER"] = 10] = "DRAWING_SLICER";
|
|
11743
|
+
/**
|
|
11744
|
+
* Spreadsheet Timeline control.
|
|
11745
|
+
*/
|
|
11746
|
+
DrawingTypeEnum[DrawingTypeEnum["DRAWING_TIMELINE"] = 11] = "DRAWING_TIMELINE";
|
|
11702
11747
|
return DrawingTypeEnum;
|
|
11703
11748
|
}({});
|
|
11704
11749
|
|
|
@@ -11784,6 +11829,10 @@ function throttle(fn, wait = 16) {
|
|
|
11784
11829
|
fn.apply(this, args);
|
|
11785
11830
|
}, wait);
|
|
11786
11831
|
} else {
|
|
11832
|
+
if (timer) {
|
|
11833
|
+
clearTimeout(timer);
|
|
11834
|
+
timer = null;
|
|
11835
|
+
}
|
|
11787
11836
|
lastTime = now;
|
|
11788
11837
|
fn.apply(this, args);
|
|
11789
11838
|
}
|
|
@@ -11939,9 +11988,7 @@ function rgbToHsl([r, g, b]) {
|
|
|
11939
11988
|
case g:
|
|
11940
11989
|
h = (b - r) / d + 2;
|
|
11941
11990
|
break;
|
|
11942
|
-
case b:
|
|
11943
|
-
h = (r - g) / d + 4;
|
|
11944
|
-
break;
|
|
11991
|
+
case b: h = (r - g) / d + 4;
|
|
11945
11992
|
}
|
|
11946
11993
|
h /= 6;
|
|
11947
11994
|
}
|
|
@@ -12457,8 +12504,10 @@ async function calculateDocumentStatistics(dataStream, options) {
|
|
|
12457
12504
|
let processedWordCharacters = 0;
|
|
12458
12505
|
for (const word of wordSegmenter.segment(fragment)) {
|
|
12459
12506
|
throwIfAborted(signal);
|
|
12460
|
-
if (word.isWordLike && !EAST_ASIAN_CHARACTER.test(word.segment))
|
|
12461
|
-
|
|
12507
|
+
if (word.isWordLike && !EAST_ASIAN_CHARACTER.test(word.segment)) {
|
|
12508
|
+
if (KOREAN_CHARACTER.test(word.segment)) statistics.asianCharactersAndKoreanWords += 1;
|
|
12509
|
+
else statistics.nonAsianWords += 1;
|
|
12510
|
+
}
|
|
12462
12511
|
processedWordCharacters += word.segment.length;
|
|
12463
12512
|
if (processedWordCharacters >= YIELD_INTERVAL) {
|
|
12464
12513
|
processedWordCharacters = 0;
|
|
@@ -12625,6 +12674,8 @@ let DocumentFlavor = /* @__PURE__ */ function(DocumentFlavor) {
|
|
|
12625
12674
|
DocumentFlavor[DocumentFlavor["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
12626
12675
|
DocumentFlavor[DocumentFlavor["TRADITIONAL"] = 1] = "TRADITIONAL";
|
|
12627
12676
|
DocumentFlavor[DocumentFlavor["MODERN"] = 2] = "MODERN";
|
|
12677
|
+
/** DrawingML text semantics for host-prepared shape and slide text models. */
|
|
12678
|
+
DocumentFlavor[DocumentFlavor["DRAWINGML"] = 3] = "DRAWINGML";
|
|
12628
12679
|
return DocumentFlavor;
|
|
12629
12680
|
}({});
|
|
12630
12681
|
let GridType = /* @__PURE__ */ function(GridType) {
|
|
@@ -13357,7 +13408,7 @@ function getEmptySnapshot$1(unitID = generateRandomId(6), locale = "enUS", title
|
|
|
13357
13408
|
marginBottom: 72,
|
|
13358
13409
|
marginRight: 72,
|
|
13359
13410
|
marginLeft: 72,
|
|
13360
|
-
autoHyphenation: 1,
|
|
13411
|
+
autoHyphenation: documentFlavor === 3 ? 0 : 1,
|
|
13361
13412
|
doNotHyphenateCaps: 0,
|
|
13362
13413
|
consecutiveHyphenLimit: 2,
|
|
13363
13414
|
defaultHeaderId: "",
|
|
@@ -13637,15 +13688,14 @@ function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
|
13637
13688
|
* @param textLength The length of the inserted content text.
|
|
13638
13689
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13639
13690
|
*/
|
|
13640
|
-
function insertParagraphs(body, insertBody, textLength, currentIndex,
|
|
13691
|
+
function insertParagraphs(body, insertBody, textLength, currentIndex, isUpdate = false, originalDataStream = body.dataStream) {
|
|
13641
13692
|
var _insertBody$paragraph;
|
|
13642
13693
|
if (!body.paragraphs && !((_insertBody$paragraph = insertBody.paragraphs) === null || _insertBody$paragraph === void 0 ? void 0 : _insertBody$paragraph.length)) return;
|
|
13643
13694
|
body.paragraphs ??= [];
|
|
13644
13695
|
const { paragraphs } = body;
|
|
13645
13696
|
const { paragraphs: insertParagraphs } = insertBody;
|
|
13646
|
-
normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, {
|
|
13697
|
+
if (!isUpdate) normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, {
|
|
13647
13698
|
freshenSplitParagraph: true,
|
|
13648
|
-
preserveMissingParagraphIds,
|
|
13649
13699
|
preserveExplicitSplitParagraphIds: Boolean(insertBody[RESTORE_INSERTED_PARAGRAPH_IDS]),
|
|
13650
13700
|
preserveExplicitParagraphIds: Boolean(insertBody[PRESERVE_INSERTED_PARAGRAPH_IDS]),
|
|
13651
13701
|
dataStream: originalDataStream
|
|
@@ -13700,7 +13750,7 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13700
13750
|
insertParagraphs[i] = cloneInsertedParagraphWithId(insertParagraphs[i], existingParagraphIds, options.preserveMissingParagraphIds ?? false);
|
|
13701
13751
|
continue;
|
|
13702
13752
|
}
|
|
13703
|
-
insertParagraphs[i] = options.freshenSplitParagraph
|
|
13753
|
+
insertParagraphs[i] = options.freshenSplitParagraph ? cloneParagraphWithId({
|
|
13704
13754
|
...insertParagraphs[i],
|
|
13705
13755
|
paragraphId: splitParagraphId
|
|
13706
13756
|
}, existingParagraphIds) : splitRemainderParagraph;
|
|
@@ -13922,18 +13972,19 @@ function mergeContinuousRanges(ranges) {
|
|
|
13922
13972
|
if (ranges.length <= 1) return ranges;
|
|
13923
13973
|
ranges.sort((a, b) => a.startIndex - b.startIndex);
|
|
13924
13974
|
const mergedRanges = [];
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13975
|
+
const latestById = /* @__PURE__ */ new Map();
|
|
13976
|
+
for (const range of ranges) {
|
|
13977
|
+
const nextRange = {
|
|
13978
|
+
...range,
|
|
13979
|
+
rangeId: getRootId(range.rangeId)
|
|
13980
|
+
};
|
|
13981
|
+
const currentRange = latestById.get(nextRange.rangeId);
|
|
13982
|
+
if (currentRange && nextRange.rangeType === currentRange.rangeType && shallowEqual(currentRange.properties, nextRange.properties) && currentRange.endIndex + 1 >= nextRange.startIndex) currentRange.endIndex = Math.max(currentRange.endIndex, nextRange.endIndex);
|
|
13931
13983
|
else {
|
|
13932
|
-
mergedRanges.push(
|
|
13933
|
-
|
|
13984
|
+
mergedRanges.push(nextRange);
|
|
13985
|
+
latestById.set(nextRange.rangeId, nextRange);
|
|
13934
13986
|
}
|
|
13935
13987
|
}
|
|
13936
|
-
mergedRanges.push(currentRange);
|
|
13937
13988
|
const idMap = Object.create(null);
|
|
13938
13989
|
for (let i = 0, len = mergedRanges.length; i < len; i++) {
|
|
13939
13990
|
const range = mergedRanges[i];
|
|
@@ -13946,19 +13997,19 @@ function mergeContinuousRanges(ranges) {
|
|
|
13946
13997
|
return mergedRanges;
|
|
13947
13998
|
}
|
|
13948
13999
|
function splitCustomRangesByIndex(customRanges, currentIndex) {
|
|
13949
|
-
const
|
|
13950
|
-
const
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
}
|
|
14000
|
+
const matches = customRanges.filter((range) => range.rangeType !== 1 && range.rangeType !== 2 && range.rangeType !== 3 && range.startIndex < currentIndex && range.endIndex >= currentIndex);
|
|
14001
|
+
for (const matched of matches) {
|
|
14002
|
+
const index = customRanges.indexOf(matched);
|
|
14003
|
+
customRanges.splice(index, 1, {
|
|
14004
|
+
...matched,
|
|
14005
|
+
endIndex: currentIndex - 1,
|
|
14006
|
+
properties: { ...matched.properties }
|
|
14007
|
+
}, {
|
|
14008
|
+
...matched,
|
|
14009
|
+
startIndex: currentIndex,
|
|
14010
|
+
properties: { ...matched.properties }
|
|
14011
|
+
});
|
|
14012
|
+
}
|
|
13962
14013
|
}
|
|
13963
14014
|
function mergeContinuousDecorations(ranges) {
|
|
13964
14015
|
if (ranges.length <= 1) return ranges;
|
|
@@ -13999,6 +14050,10 @@ function insertCustomRanges(body, insertBody, textLength, currentIndex) {
|
|
|
13999
14050
|
for (let i = 0, len = customRanges.length; i < len; i++) {
|
|
14000
14051
|
const customRange = customRanges[i];
|
|
14001
14052
|
const { startIndex } = customRange;
|
|
14053
|
+
if ((customRange.rangeType === 1 || customRange.rangeType === 2 || customRange.rangeType === 3) && startIndex < currentIndex && customRange.endIndex >= currentIndex) {
|
|
14054
|
+
customRange.endIndex += textLength;
|
|
14055
|
+
continue;
|
|
14056
|
+
}
|
|
14002
14057
|
if (startIndex >= currentIndex) {
|
|
14003
14058
|
customRange.startIndex += textLength;
|
|
14004
14059
|
customRange.endIndex += textLength;
|
|
@@ -14008,6 +14063,15 @@ function insertCustomRanges(body, insertBody, textLength, currentIndex) {
|
|
|
14008
14063
|
if (insertBody.customRanges) {
|
|
14009
14064
|
for (let i = 0, len = insertBody.customRanges.length; i < len; i++) {
|
|
14010
14065
|
const customRange = insertBody.customRanges[i];
|
|
14066
|
+
const existingSdt = customRange.rangeType === 2 ? customRanges.find((range) => range.rangeType === 2 && range.rangeId === customRange.rangeId) : void 0;
|
|
14067
|
+
if (existingSdt) {
|
|
14068
|
+
existingSdt.startIndex = Math.min(existingSdt.startIndex, currentIndex + customRange.startIndex);
|
|
14069
|
+
existingSdt.endIndex = Math.max(existingSdt.endIndex, currentIndex + customRange.endIndex);
|
|
14070
|
+
existingSdt.properties = Tools.deepClone(customRange.properties);
|
|
14071
|
+
existingSdt.wholeEntity = customRange.wholeEntity;
|
|
14072
|
+
customRanges.splice(customRanges.indexOf(existingSdt), 0, ...insertRanges.splice(0));
|
|
14073
|
+
continue;
|
|
14074
|
+
}
|
|
14011
14075
|
customRange.startIndex += currentIndex;
|
|
14012
14076
|
customRange.endIndex += currentIndex;
|
|
14013
14077
|
insertRanges.push(customRange);
|
|
@@ -14284,6 +14348,8 @@ function deleteCustomRanges(body, textLength, currentIndex) {
|
|
|
14284
14348
|
const { customRanges } = body;
|
|
14285
14349
|
const removeCustomRanges = [];
|
|
14286
14350
|
if (customRanges) {
|
|
14351
|
+
const originalSdtLengths = new Map(customRanges.filter((range) => range.rangeType === 2).map((range) => [range, range.endIndex - range.startIndex]));
|
|
14352
|
+
const coincidentSdts = /* @__PURE__ */ new Map();
|
|
14287
14353
|
const newCustomRanges = [];
|
|
14288
14354
|
for (let i = 0, len = customRanges.length; i < len; i++) {
|
|
14289
14355
|
const customRange = customRanges[i];
|
|
@@ -14293,8 +14359,21 @@ function deleteCustomRanges(body, textLength, currentIndex) {
|
|
|
14293
14359
|
continue;
|
|
14294
14360
|
}
|
|
14295
14361
|
Object.assign(customRange, transformed);
|
|
14362
|
+
if (customRange.rangeType === 2) {
|
|
14363
|
+
const key = `${customRange.startIndex}:${customRange.endIndex}`;
|
|
14364
|
+
const positions = coincidentSdts.get(key) ?? [];
|
|
14365
|
+
positions.push(newCustomRanges.length);
|
|
14366
|
+
coincidentSdts.set(key, positions);
|
|
14367
|
+
}
|
|
14296
14368
|
newCustomRanges.push(customRange);
|
|
14297
14369
|
}
|
|
14370
|
+
for (const positions of coincidentSdts.values()) {
|
|
14371
|
+
if (positions.length < 2) continue;
|
|
14372
|
+
const ordered = positions.map((index) => newCustomRanges[index]).sort((left, right) => originalSdtLengths.get(left) - originalSdtLengths.get(right));
|
|
14373
|
+
positions.forEach((index, offset) => {
|
|
14374
|
+
newCustomRanges[index] = ordered[offset];
|
|
14375
|
+
});
|
|
14376
|
+
}
|
|
14298
14377
|
body.customRanges = mergeContinuousRanges(newCustomRanges);
|
|
14299
14378
|
}
|
|
14300
14379
|
return removeCustomRanges;
|
|
@@ -14879,8 +14958,10 @@ function coverTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
|
14879
14958
|
const tempTopTextRun = newUpdateTextRuns[newUpdateTextRuns.length - 1];
|
|
14880
14959
|
const updateLastTextRun = updateDataTextRuns[updateLength - 1];
|
|
14881
14960
|
const removeLastTextRun = originTextRuns[removeLength - 1];
|
|
14882
|
-
if (tempTopTextRun && tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed))
|
|
14883
|
-
|
|
14961
|
+
if (tempTopTextRun && tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed)) {
|
|
14962
|
+
if (updateLastTextRun.ed > removeLastTextRun.ed) newUpdateTextRuns.push(updateLastTextRun);
|
|
14963
|
+
else newUpdateTextRuns.push(removeLastTextRun);
|
|
14964
|
+
}
|
|
14884
14965
|
return normalizeTextRuns(newUpdateTextRuns);
|
|
14885
14966
|
}
|
|
14886
14967
|
function updateParagraphs(body, updateBody, textLength, currentIndex, coverType) {
|
|
@@ -15142,12 +15223,35 @@ function updateCustomRanges(body, updateBody, textLength, currentIndex, _coverTy
|
|
|
15142
15223
|
if (!updateDataCustomRanges) return [];
|
|
15143
15224
|
updateDataCustomRanges.forEach((customRange) => {
|
|
15144
15225
|
const { startIndex, endIndex } = customRange;
|
|
15226
|
+
const existingSdt = customRange.rangeType === 2 ? newCustomRanges.find((range) => range.rangeType === 2 && range.rangeId === customRange.rangeId) : void 0;
|
|
15227
|
+
if (existingSdt) {
|
|
15228
|
+
if (startIndex > 0) existingSdt.startIndex = startIndex + currentIndex;
|
|
15229
|
+
if (endIndex < textLength - 1) existingSdt.endIndex = endIndex + currentIndex;
|
|
15230
|
+
existingSdt.properties = Tools.deepClone(customRange.properties);
|
|
15231
|
+
existingSdt.wholeEntity = customRange.wholeEntity;
|
|
15232
|
+
return;
|
|
15233
|
+
}
|
|
15145
15234
|
newCustomRanges.push({
|
|
15146
15235
|
...customRange,
|
|
15147
15236
|
startIndex: startIndex + currentIndex,
|
|
15148
15237
|
endIndex: endIndex + currentIndex
|
|
15149
15238
|
});
|
|
15150
15239
|
});
|
|
15240
|
+
const updateOrder = new Map(updateDataCustomRanges.map((range, index) => [range.rangeId, index]));
|
|
15241
|
+
const coincidentSdts = /* @__PURE__ */ new Map();
|
|
15242
|
+
newCustomRanges.forEach((range, index) => {
|
|
15243
|
+
if (range.rangeType !== 2 || !updateOrder.has(range.rangeId)) return;
|
|
15244
|
+
const key = `${range.startIndex}:${range.endIndex}`;
|
|
15245
|
+
const positions = coincidentSdts.get(key) ?? [];
|
|
15246
|
+
positions.push(index);
|
|
15247
|
+
coincidentSdts.set(key, positions);
|
|
15248
|
+
});
|
|
15249
|
+
for (const positions of coincidentSdts.values()) {
|
|
15250
|
+
const ordered = positions.map((index) => newCustomRanges[index]).sort((left, right) => updateOrder.get(left.rangeId) - updateOrder.get(right.rangeId));
|
|
15251
|
+
positions.forEach((position, index) => {
|
|
15252
|
+
newCustomRanges[position] = ordered[index];
|
|
15253
|
+
});
|
|
15254
|
+
}
|
|
15151
15255
|
body.customRanges = mergeContinuousRanges(newCustomRanges);
|
|
15152
15256
|
return removeCustomRanges;
|
|
15153
15257
|
}
|
|
@@ -15494,7 +15598,9 @@ const setParagraphStyle = (params) => {
|
|
|
15494
15598
|
var _segment$getBody, _segment$getBody2;
|
|
15495
15599
|
const { textRanges, segmentId, document: docDataModel, style, paragraphTextRun, cursor, deleteLen, textX: _textX } = params;
|
|
15496
15600
|
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
15497
|
-
const
|
|
15601
|
+
const paragraphs = (segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) ?? [];
|
|
15602
|
+
const dataStream = (segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) ?? "";
|
|
15603
|
+
const currentParagraphs = getParagraphsInRanges(textRanges, paragraphs, dataStream);
|
|
15498
15604
|
const memoryCursor = new MemoryCursor();
|
|
15499
15605
|
if (cursor) memoryCursor.moveCursorTo(cursor);
|
|
15500
15606
|
const textX = _textX ?? new TextX();
|
|
@@ -15725,6 +15831,7 @@ function getDocxExportExcludedRangeSlice(body, startOffset, endOffset) {
|
|
|
15725
15831
|
function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, type = 1, structuralRangeMode = 0) {
|
|
15726
15832
|
const { dataStream } = body;
|
|
15727
15833
|
const docBody = { dataStream: dataStream.slice(startOffset, endOffset) };
|
|
15834
|
+
if (body.renderedPageBreaks != null) docBody.renderedPageBreaks = body.renderedPageBreaks.filter((offset) => offset >= startOffset && offset < endOffset).map((offset) => offset - startOffset);
|
|
15728
15835
|
if (body["__textXPreserveParagraphIds"]) docBody[PRESERVE_INSERTED_PARAGRAPH_IDS] = true;
|
|
15729
15836
|
docBody.textRuns = getTextRunSlice(body, startOffset, endOffset, returnEmptyArray);
|
|
15730
15837
|
const newTables = getTableSlice(body, startOffset, endOffset, structuralRangeMode);
|
|
@@ -15743,7 +15850,7 @@ function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, typ
|
|
|
15743
15850
|
else if (returnEmptyArray) docBody.customDecorations = [];
|
|
15744
15851
|
}
|
|
15745
15852
|
const { customRanges } = getCustomRangeSlice(body, startOffset, endOffset);
|
|
15746
|
-
if (customRanges) docBody.customRanges = customRanges;
|
|
15853
|
+
if (customRanges) docBody.customRanges = type === 0 ? customRanges.filter((range) => range.rangeType !== 1 || docBody.dataStream[range.startIndex] === "" && docBody.dataStream[range.endIndex] === "") : customRanges;
|
|
15747
15854
|
else if (returnEmptyArray) docBody.customRanges = [];
|
|
15748
15855
|
docBody.customBlocks = getCustomBlockSlice(body, startOffset, endOffset);
|
|
15749
15856
|
if (body.docxRawCustomBlocks != null) docBody.docxRawCustomBlocks = getDocxRawCustomBlockSlice(body, startOffset, endOffset) ?? [];
|
|
@@ -15759,6 +15866,7 @@ function getBodySliceForSplitTextXAction(body, startOffset, endOffset, returnEmp
|
|
|
15759
15866
|
}
|
|
15760
15867
|
function shiftBodyMetadata(body, leftOffset, rightOffset) {
|
|
15761
15868
|
var _body$textRuns, _body$paragraphs, _body$customBlocks, _body$docxRawCustomBl, _body$docxRawBlocks, _body$docxExportExclu, _body$customRanges, _body$customDecoratio, _body$tables, _body$columnGroups;
|
|
15869
|
+
if (body.renderedPageBreaks != null) body.renderedPageBreaks = body.renderedPageBreaks.map((offset) => offset + leftOffset);
|
|
15762
15870
|
(_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 || _body$textRuns.forEach((textRun) => {
|
|
15763
15871
|
textRun.st += leftOffset;
|
|
15764
15872
|
textRun.ed += leftOffset;
|
|
@@ -15855,12 +15963,17 @@ function composeTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
|
15855
15963
|
function composeCustomRanges(updateDataCustomRanges, originCustomRanges, coverType) {
|
|
15856
15964
|
if (updateDataCustomRanges == null || originCustomRanges == null) return updateDataCustomRanges ?? originCustomRanges;
|
|
15857
15965
|
if (originCustomRanges.length === 0 || updateDataCustomRanges.length === 0) return updateDataCustomRanges;
|
|
15858
|
-
if (
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15966
|
+
if (coverType === 1) return updateDataCustomRanges.map((range) => ({ ...range }));
|
|
15967
|
+
const updates = new Map(updateDataCustomRanges.map((range) => [range.rangeId, range]));
|
|
15968
|
+
return [...originCustomRanges.filter((range) => !updateDataCustomRanges.some((update) => range.rangeType === 0 && update.rangeType === 0 && update.rangeId !== range.rangeId && update.startIndex === range.startIndex && update.endIndex === range.endIndex)).map((range) => {
|
|
15969
|
+
const update = updates.get(range.rangeId);
|
|
15970
|
+
if (update == null) return range;
|
|
15971
|
+
updates.delete(range.rangeId);
|
|
15972
|
+
return {
|
|
15973
|
+
...range,
|
|
15974
|
+
...update
|
|
15975
|
+
};
|
|
15976
|
+
}), ...updates.values()];
|
|
15864
15977
|
}
|
|
15865
15978
|
function composeCustomDecorations(updateDataCustomDecorations, originCustomDecorations, coverType) {
|
|
15866
15979
|
if (originCustomDecorations.length === 0 || updateDataCustomDecorations.length === 0) return updateDataCustomDecorations;
|
|
@@ -15874,6 +15987,7 @@ function composeCustomDecorations(updateDataCustomDecorations, originCustomDecor
|
|
|
15874
15987
|
function composeBody(thisBody, otherBody, coverType = 0) {
|
|
15875
15988
|
if (otherBody.dataStream !== "") throw new Error("Cannot compose other body with non-empty dataStream");
|
|
15876
15989
|
const retBody = { dataStream: thisBody.dataStream };
|
|
15990
|
+
if (thisBody.renderedPageBreaks != null) retBody.renderedPageBreaks = [...thisBody.renderedPageBreaks];
|
|
15877
15991
|
if (thisBody["__textXPreserveParagraphIds"] || otherBody["__textXPreserveParagraphIds"]) retBody[PRESERVE_INSERTED_PARAGRAPH_IDS] = true;
|
|
15878
15992
|
const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations = [], columnGroups: thisColumnGroups = [], blockRanges: thisBlockRanges = [] } = thisBody;
|
|
15879
15993
|
const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations = [], columnGroups: otherColumnGroups = [], blockRanges: otherBlockRanges = [] } = otherBody;
|
|
@@ -15925,6 +16039,8 @@ function composeColumnGroups(thisRanges, otherRanges) {
|
|
|
15925
16039
|
return Array.from(byId.values()).sort((left, right) => left.startIndex - right.startIndex);
|
|
15926
16040
|
}
|
|
15927
16041
|
function isUselessRetainAction(action) {
|
|
16042
|
+
var _action$rangeUpdates;
|
|
16043
|
+
if ((_action$rangeUpdates = action.rangeUpdates) === null || _action$rangeUpdates === void 0 ? void 0 : _action$rangeUpdates.length) return false;
|
|
15928
16044
|
const { body } = action;
|
|
15929
16045
|
if (body == null) return true;
|
|
15930
16046
|
const { textRuns, paragraphs, customRanges, customBlocks, docxRawCustomBlocks, docxRawBlocks, docxExportExcludedRanges, customDecorations, tables, columnGroups, blockRanges } = body;
|
|
@@ -16029,9 +16145,12 @@ var ActionIterator = class {
|
|
|
16029
16145
|
//#endregion
|
|
16030
16146
|
//#region src/docs/data-model/text-x/apply-utils/delete-apply.ts
|
|
16031
16147
|
function updateAttributeByDelete(body, textLength, currentIndex) {
|
|
16148
|
+
var _body$renderedPageBre;
|
|
16032
16149
|
const { dataStream } = body;
|
|
16033
16150
|
const startIndex = currentIndex;
|
|
16034
16151
|
const endIndex = currentIndex + textLength;
|
|
16152
|
+
const removedRenderedPageBreaks = (_body$renderedPageBre = body.renderedPageBreaks) === null || _body$renderedPageBre === void 0 ? void 0 : _body$renderedPageBre.filter((offset) => offset >= startIndex && offset < endIndex).map((offset) => offset - startIndex);
|
|
16153
|
+
if (body.renderedPageBreaks != null) body.renderedPageBreaks = body.renderedPageBreaks.filter((offset) => offset < startIndex || offset >= endIndex).map((offset) => offset >= endIndex ? offset - textLength : offset);
|
|
16035
16154
|
const removeTextRuns = deleteTextRuns(body, textLength, currentIndex);
|
|
16036
16155
|
const removeParagraphs = deleteParagraphs(body, textLength, currentIndex);
|
|
16037
16156
|
const removeSectionBreaks = deleteSectionBreaks(body, textLength, currentIndex);
|
|
@@ -16051,6 +16170,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
|
|
|
16051
16170
|
}
|
|
16052
16171
|
return {
|
|
16053
16172
|
dataStream: removeDataStream,
|
|
16173
|
+
renderedPageBreaks: removedRenderedPageBreaks,
|
|
16054
16174
|
textRuns: removeTextRuns,
|
|
16055
16175
|
paragraphs: removeParagraphs,
|
|
16056
16176
|
sectionBreaks: removeSectionBreaks,
|
|
@@ -16071,6 +16191,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
|
|
|
16071
16191
|
function updateAttributeByInsert(body, insertBody, textLength, currentIndex) {
|
|
16072
16192
|
const originalDataStream = body.dataStream;
|
|
16073
16193
|
body.dataStream = insertTextToContent(body.dataStream, currentIndex, insertBody.dataStream);
|
|
16194
|
+
if (body.renderedPageBreaks != null || insertBody.renderedPageBreaks != null) body.renderedPageBreaks = [...(body.renderedPageBreaks ?? []).map((offset) => offset >= currentIndex ? offset + textLength : offset), ...(insertBody.renderedPageBreaks ?? []).map((offset) => offset + currentIndex)].sort((left, right) => left - right);
|
|
16074
16195
|
insertTextRuns(body, insertBody, textLength, currentIndex);
|
|
16075
16196
|
insertParagraphs(body, insertBody, textLength, currentIndex, false, originalDataStream);
|
|
16076
16197
|
insertSectionBreaks(body, insertBody, textLength, currentIndex);
|
|
@@ -16085,6 +16206,220 @@ function updateAttributeByInsert(body, insertBody, textLength, currentIndex) {
|
|
|
16085
16206
|
insertCustomDecorations(body, insertBody, textLength, currentIndex);
|
|
16086
16207
|
}
|
|
16087
16208
|
|
|
16209
|
+
//#endregion
|
|
16210
|
+
//#region src/docs/data-model/text-x/custom-range-update.ts
|
|
16211
|
+
function getChangedPropertyPaths(before, after, path = []) {
|
|
16212
|
+
if (Tools.diffValue(before, after)) return [];
|
|
16213
|
+
if (after && typeof after === "object" && !Array.isArray(after) && (before == null || typeof before === "object" && !Array.isArray(before))) {
|
|
16214
|
+
const previous = before ?? {};
|
|
16215
|
+
const next = after;
|
|
16216
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(next)]));
|
|
16217
|
+
if (!keys.length && path.length) return [path];
|
|
16218
|
+
return keys.flatMap((key) => getChangedPropertyPaths(previous[key], next[key], [...path, key]));
|
|
16219
|
+
}
|
|
16220
|
+
return [path];
|
|
16221
|
+
}
|
|
16222
|
+
function validatePropertyPaths(paths) {
|
|
16223
|
+
if (!Array.isArray(paths) || paths.some((path) => !Array.isArray(path) || !path.length || path.some((key) => typeof key !== "string" || [
|
|
16224
|
+
"__proto__",
|
|
16225
|
+
"prototype",
|
|
16226
|
+
"constructor"
|
|
16227
|
+
].includes(key)))) throw new Error("Invalid custom range property paths.");
|
|
16228
|
+
}
|
|
16229
|
+
function patchRangeProperties(target, source, paths) {
|
|
16230
|
+
validatePropertyPaths(paths);
|
|
16231
|
+
const result = Tools.deepClone(target);
|
|
16232
|
+
for (const path of paths) {
|
|
16233
|
+
let current = result.properties ??= {};
|
|
16234
|
+
let value = source.properties;
|
|
16235
|
+
const parents = [];
|
|
16236
|
+
for (let index = 0; index < path.length; index++) {
|
|
16237
|
+
const key = path[index];
|
|
16238
|
+
value = value && typeof value === "object" ? value[key] : void 0;
|
|
16239
|
+
if (index === path.length - 1) {
|
|
16240
|
+
if (value === void 0) delete current[key];
|
|
16241
|
+
else current[key] = Tools.deepClone(value);
|
|
16242
|
+
} else {
|
|
16243
|
+
if (!current[key] || typeof current[key] !== "object" || Array.isArray(current[key])) current[key] = {};
|
|
16244
|
+
parents.push({
|
|
16245
|
+
object: current,
|
|
16246
|
+
key,
|
|
16247
|
+
value
|
|
16248
|
+
});
|
|
16249
|
+
current = current[key];
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
for (const parent of parents.reverse()) if (parent.value === void 0 && Object.keys(parent.object[parent.key]).length === 0) delete parent.object[parent.key];
|
|
16253
|
+
}
|
|
16254
|
+
if (source.properties === void 0 && !Object.keys(result.properties ?? {}).length) delete result.properties;
|
|
16255
|
+
return result;
|
|
16256
|
+
}
|
|
16257
|
+
function composeRangeUpdate(first, second) {
|
|
16258
|
+
if (!first || !second.propertyPaths || !second.range) return second;
|
|
16259
|
+
if (!first.range) return first;
|
|
16260
|
+
const propertyPaths = first.propertyPaths && [...first.propertyPaths, ...second.propertyPaths.filter((path) => !first.propertyPaths.some((parent) => parent.length <= path.length && parent.every((key, index) => path[index] === key)))];
|
|
16261
|
+
return {
|
|
16262
|
+
...first,
|
|
16263
|
+
range: patchRangeProperties(first.range, second.range, second.propertyPaths),
|
|
16264
|
+
propertyPaths
|
|
16265
|
+
};
|
|
16266
|
+
}
|
|
16267
|
+
function transformRangeUpdate(update, concurrent, priority) {
|
|
16268
|
+
if (!concurrent || !update.range) return [update];
|
|
16269
|
+
if (!concurrent.range) return [];
|
|
16270
|
+
if (!update.propertyPaths || !concurrent.propertyPaths) return priority === "left" ? [{
|
|
16271
|
+
...update,
|
|
16272
|
+
propertyPaths: void 0
|
|
16273
|
+
}] : [];
|
|
16274
|
+
const propertyPaths = update.propertyPaths.filter((path) => priority === "left" || !concurrent.propertyPaths.some((other) => path.slice(0, Math.min(path.length, other.length)).every((key, index) => other[index] === key))).map((path) => concurrent.propertyPaths.find((other) => other.length < path.length && other.every((key, index) => path[index] === key)) ?? path);
|
|
16275
|
+
return propertyPaths.length ? [{
|
|
16276
|
+
...update,
|
|
16277
|
+
propertyPaths
|
|
16278
|
+
}] : [];
|
|
16279
|
+
}
|
|
16280
|
+
function getRangeUpdates(actions) {
|
|
16281
|
+
const updates = /* @__PURE__ */ new Map();
|
|
16282
|
+
for (const action of actions) if (action.t === "r") for (const update of action.rangeUpdates ?? []) updates.set(update.rangeId, composeRangeUpdate(updates.get(update.rangeId), update));
|
|
16283
|
+
return updates.size ? Tools.deepClone(Array.from(updates.values())) : [];
|
|
16284
|
+
}
|
|
16285
|
+
function withoutRangeUpdates(actions) {
|
|
16286
|
+
return actions.flatMap((action) => {
|
|
16287
|
+
if (action.t === "i" && action.len > 1 && Array.from(action.body.dataStream).every((token) => token === "" || token === "")) return Array.from(action.body.dataStream, (_, index) => ({
|
|
16288
|
+
...action,
|
|
16289
|
+
len: 1,
|
|
16290
|
+
body: getBodySliceForSplitTextXAction(action.body, index, index + 1, false)
|
|
16291
|
+
}));
|
|
16292
|
+
if (action.t !== "r" || !action.rangeUpdates) return [action];
|
|
16293
|
+
const { rangeUpdates, oldRangeUpdates, ...textAction } = action;
|
|
16294
|
+
return textAction.len === 0 && !textAction.body ? [] : [textAction];
|
|
16295
|
+
});
|
|
16296
|
+
}
|
|
16297
|
+
function appendRangeUpdates(actions, updates) {
|
|
16298
|
+
return (updates === null || updates === void 0 ? void 0 : updates.length) ? [...actions, {
|
|
16299
|
+
t: "r",
|
|
16300
|
+
len: 0,
|
|
16301
|
+
rangeUpdates: updates
|
|
16302
|
+
}] : actions;
|
|
16303
|
+
}
|
|
16304
|
+
function validateRangeUpdates(updates, resultLength) {
|
|
16305
|
+
for (const { rangeId, range, nextRangeId, propertyPaths } of updates ?? []) {
|
|
16306
|
+
if (propertyPaths !== void 0) {
|
|
16307
|
+
validatePropertyPaths(propertyPaths);
|
|
16308
|
+
if (!range) throw new Error("Invalid custom range property paths.");
|
|
16309
|
+
}
|
|
16310
|
+
if (typeof rangeId !== "string" || !rangeId || nextRangeId !== void 0 && nextRangeId !== null && typeof nextRangeId !== "string" || range !== null && (range == null || typeof range !== "object" || Array.isArray(range) || range.rangeId !== rangeId || !Number.isInteger(range.startIndex) || !Number.isInteger(range.endIndex) || range.startIndex < 0 || range.endIndex < range.startIndex || range.endIndex >= resultLength)) throw new Error("Invalid custom range identity or bounds.");
|
|
16311
|
+
}
|
|
16312
|
+
}
|
|
16313
|
+
function applyRangeUpdates(doc, updates) {
|
|
16314
|
+
if (!(updates === null || updates === void 0 ? void 0 : updates.length)) return;
|
|
16315
|
+
const ranges = doc.customRanges ?? [];
|
|
16316
|
+
for (const { rangeId, range, nextRangeId, propertyPaths } of [...updates].reverse()) {
|
|
16317
|
+
const index = ranges.findIndex((item) => item.rangeId === rangeId);
|
|
16318
|
+
if (range && propertyPaths) {
|
|
16319
|
+
if (index >= 0) ranges[index] = patchRangeProperties(ranges[index], range, propertyPaths);
|
|
16320
|
+
continue;
|
|
16321
|
+
}
|
|
16322
|
+
if (range) {
|
|
16323
|
+
if (nextRangeId !== void 0) {
|
|
16324
|
+
if (index >= 0) ranges.splice(index, 1);
|
|
16325
|
+
const nextIndex = ranges.findIndex((item) => item.rangeId === nextRangeId);
|
|
16326
|
+
ranges.splice(nextIndex < 0 ? ranges.length : nextIndex, 0, Tools.deepClone(range));
|
|
16327
|
+
} else if (index >= 0) ranges[index] = Tools.deepClone(range);
|
|
16328
|
+
else ranges.push(Tools.deepClone(range));
|
|
16329
|
+
} else if (index >= 0) ranges.splice(index, 1);
|
|
16330
|
+
}
|
|
16331
|
+
doc.customRanges = ranges;
|
|
16332
|
+
}
|
|
16333
|
+
function moveRangeUpdates(updates, actions, preserveProperties = false) {
|
|
16334
|
+
return updates.map((update) => {
|
|
16335
|
+
var _body$customRanges;
|
|
16336
|
+
const { rangeId, range } = update;
|
|
16337
|
+
if (!range && preserveProperties) return update;
|
|
16338
|
+
const body = {
|
|
16339
|
+
dataStream: "",
|
|
16340
|
+
customRanges: range ? [Tools.deepClone(range)] : []
|
|
16341
|
+
};
|
|
16342
|
+
let offset = 0;
|
|
16343
|
+
for (const action of actions) {
|
|
16344
|
+
var _action$body;
|
|
16345
|
+
if (action.t === "i") {
|
|
16346
|
+
var _action$body$customRa;
|
|
16347
|
+
insertCustomRanges(body, {
|
|
16348
|
+
dataStream: "",
|
|
16349
|
+
customRanges: Tools.deepClone((_action$body$customRa = action.body.customRanges) === null || _action$body$customRa === void 0 ? void 0 : _action$body$customRa.filter((item) => item.rangeId === rangeId))
|
|
16350
|
+
}, action.len, offset);
|
|
16351
|
+
} else if (action.t === "d") {
|
|
16352
|
+
deleteCustomRanges(body, action.len, offset);
|
|
16353
|
+
continue;
|
|
16354
|
+
} else if ((_action$body = action.body) === null || _action$body === void 0 ? void 0 : _action$body.customRanges) updateAttribute(body, {
|
|
16355
|
+
dataStream: "",
|
|
16356
|
+
customRanges: Tools.deepClone(action.body.customRanges.filter((item) => item.rangeId === rangeId))
|
|
16357
|
+
}, action.len, offset, action.coverType ?? 0);
|
|
16358
|
+
offset += action.len;
|
|
16359
|
+
}
|
|
16360
|
+
const moved = (_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.find((item) => item.rangeId === rangeId);
|
|
16361
|
+
return {
|
|
16362
|
+
...update,
|
|
16363
|
+
propertyPaths: moved ? update.propertyPaths : void 0,
|
|
16364
|
+
range: moved && range && preserveProperties ? {
|
|
16365
|
+
...Tools.deepClone(range),
|
|
16366
|
+
startIndex: moved.startIndex,
|
|
16367
|
+
endIndex: moved.endIndex
|
|
16368
|
+
} : moved ?? null
|
|
16369
|
+
};
|
|
16370
|
+
});
|
|
16371
|
+
}
|
|
16372
|
+
/** A concurrent metadata payload must not resurrect an explicitly removed identity. */
|
|
16373
|
+
function reconcileRangeUpdates(actions, updates) {
|
|
16374
|
+
const byId = new Map(updates === null || updates === void 0 ? void 0 : updates.map((update) => [update.rangeId, update]));
|
|
16375
|
+
if (!byId.size) return actions;
|
|
16376
|
+
return actions.map((action) => {
|
|
16377
|
+
var _action$body2;
|
|
16378
|
+
if (!((_action$body2 = action.body) === null || _action$body2 === void 0 ? void 0 : _action$body2.customRanges)) return action;
|
|
16379
|
+
return {
|
|
16380
|
+
...action,
|
|
16381
|
+
body: {
|
|
16382
|
+
...action.body,
|
|
16383
|
+
customRanges: action.body.customRanges.flatMap((range) => {
|
|
16384
|
+
if (!byId.has(range.rangeId)) return [range];
|
|
16385
|
+
const updated = byId.get(range.rangeId);
|
|
16386
|
+
if (!updated.range) return [];
|
|
16387
|
+
return [{
|
|
16388
|
+
...updated.propertyPaths ? patchRangeProperties(range, updated.range, updated.propertyPaths) : Tools.deepClone(updated.range),
|
|
16389
|
+
startIndex: range.startIndex,
|
|
16390
|
+
endIndex: range.endIndex
|
|
16391
|
+
}];
|
|
16392
|
+
})
|
|
16393
|
+
}
|
|
16394
|
+
};
|
|
16395
|
+
});
|
|
16396
|
+
}
|
|
16397
|
+
/** Dropping a concurrent restoration also drops its delimiters, not its text. */
|
|
16398
|
+
function dropRemovedRangeAnchors(actions, suppressed, updates) {
|
|
16399
|
+
if (!suppressed.length) return appendRangeUpdates(actions, updates);
|
|
16400
|
+
const kept = [];
|
|
16401
|
+
const removed = [];
|
|
16402
|
+
let offset = 0;
|
|
16403
|
+
let deletedEnd = 0;
|
|
16404
|
+
for (const action of actions) {
|
|
16405
|
+
var _action$body3;
|
|
16406
|
+
const token = (_action$body3 = action.body) === null || _action$body3 === void 0 ? void 0 : _action$body3.dataStream;
|
|
16407
|
+
if (action.t === "i" && action.len === 1 && suppressed.some((range) => token === "" && offset === range.startIndex || token === "" && offset === range.endIndex)) {
|
|
16408
|
+
if (offset > deletedEnd) removed.push({
|
|
16409
|
+
t: "r",
|
|
16410
|
+
len: offset - deletedEnd
|
|
16411
|
+
});
|
|
16412
|
+
removed.push({
|
|
16413
|
+
t: "d",
|
|
16414
|
+
len: 1
|
|
16415
|
+
});
|
|
16416
|
+
deletedEnd = offset + 1;
|
|
16417
|
+
} else kept.push(action);
|
|
16418
|
+
if (action.t !== "d") offset += action.len;
|
|
16419
|
+
}
|
|
16420
|
+
return appendRangeUpdates(kept, moveRangeUpdates(updates, removed));
|
|
16421
|
+
}
|
|
16422
|
+
|
|
16088
16423
|
//#endregion
|
|
16089
16424
|
//#region src/docs/data-model/text-x/apply.ts
|
|
16090
16425
|
function updateApply(doc, updateBody, textLength, currentIndex, coverType = 0) {
|
|
@@ -16099,6 +16434,16 @@ function insertApply(doc, insertBody, textLength, currentIndex) {
|
|
|
16099
16434
|
updateAttributeByInsert(doc, insertBody, textLength, currentIndex);
|
|
16100
16435
|
}
|
|
16101
16436
|
function textXApply(doc, actions) {
|
|
16437
|
+
if (actions.some((action) => action.t !== "r" && action.valueRangeId !== void 0 && (typeof action.valueRangeId !== "string" || !action.valueRangeId))) throw new Error("Invalid scalar value range identity.");
|
|
16438
|
+
const updates = getRangeUpdates(actions);
|
|
16439
|
+
if (updates.length) {
|
|
16440
|
+
const resultLength = actions.reduce((length, action) => {
|
|
16441
|
+
if (action.t === "i") return length + action.len;
|
|
16442
|
+
if (action.t === "d") return length - action.len;
|
|
16443
|
+
return length;
|
|
16444
|
+
}, doc.dataStream.length);
|
|
16445
|
+
validateRangeUpdates(updates, resultLength);
|
|
16446
|
+
}
|
|
16102
16447
|
const memoryCursor = new MemoryCursor();
|
|
16103
16448
|
memoryCursor.reset();
|
|
16104
16449
|
actions.forEach((action) => {
|
|
@@ -16123,6 +16468,7 @@ function textXApply(doc, actions) {
|
|
|
16123
16468
|
default: throw new Error(`Unknown action type for action: ${action}.`);
|
|
16124
16469
|
}
|
|
16125
16470
|
});
|
|
16471
|
+
applyRangeUpdates(doc, updates);
|
|
16126
16472
|
return doc;
|
|
16127
16473
|
}
|
|
16128
16474
|
function onlyHasDataStream$1(body) {
|
|
@@ -16217,8 +16563,10 @@ function transformTextRuns(originTextRuns, targetTextRuns, originCoverType, targ
|
|
|
16217
16563
|
const tempTopTextRun = newUpdateTextRuns[newUpdateTextRuns.length - 1];
|
|
16218
16564
|
const updateLastTextRun = targetTextRuns[updateLength - 1];
|
|
16219
16565
|
const removeLastTextRun = originTextRuns[removeLength - 1];
|
|
16220
|
-
if (tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed))
|
|
16221
|
-
|
|
16566
|
+
if (tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed)) {
|
|
16567
|
+
if (updateLastTextRun.ed > removeLastTextRun.ed) newUpdateTextRuns.push(updateLastTextRun);
|
|
16568
|
+
else newUpdateTextRuns.push(removeLastTextRun);
|
|
16569
|
+
}
|
|
16222
16570
|
return normalizeTextRuns(newUpdateTextRuns, true);
|
|
16223
16571
|
}
|
|
16224
16572
|
function transformCustomRanges(originCustomRanges, targetCustomRanges, originCoverType, targetCoverType, transformType) {
|
|
@@ -16246,23 +16594,25 @@ function transformParagraph(originParagraph, targetParagraph, originCoverType, t
|
|
|
16246
16594
|
if (targetParagraph.paragraphStyle) {
|
|
16247
16595
|
paragraph.paragraphStyle = Tools.deepClone(targetParagraph.paragraphStyle);
|
|
16248
16596
|
if (originParagraph.paragraphStyle) {
|
|
16249
|
-
if (originCoverType === 1)
|
|
16250
|
-
if (
|
|
16597
|
+
if (originCoverType === 1) {
|
|
16598
|
+
if (targetCoverType === 1) {
|
|
16599
|
+
if (transformType === 1) paragraph.paragraphStyle = { ...originParagraph.paragraphStyle };
|
|
16600
|
+
} else if (transformType === 1) {
|
|
16601
|
+
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16602
|
+
for (const key of keys) if (originParagraph.paragraphStyle[key] !== void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16603
|
+
} else {
|
|
16604
|
+
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16605
|
+
for (const key of keys) if (paragraph.paragraphStyle[key] === void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16606
|
+
}
|
|
16607
|
+
} else if (targetCoverType === 1) {
|
|
16608
|
+
if (transformType === 1) {
|
|
16609
|
+
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16610
|
+
for (const key of keys) if (originParagraph.paragraphStyle[key] !== void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16611
|
+
} else {
|
|
16612
|
+
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16613
|
+
for (const key of keys) if (paragraph.paragraphStyle[key] === void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16614
|
+
}
|
|
16251
16615
|
} else if (transformType === 1) {
|
|
16252
|
-
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16253
|
-
for (const key of keys) if (originParagraph.paragraphStyle[key] !== void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16254
|
-
} else {
|
|
16255
|
-
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16256
|
-
for (const key of keys) if (paragraph.paragraphStyle[key] === void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16257
|
-
}
|
|
16258
|
-
else if (targetCoverType === 1) if (transformType === 1) {
|
|
16259
|
-
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16260
|
-
for (const key of keys) if (originParagraph.paragraphStyle[key] !== void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16261
|
-
} else {
|
|
16262
|
-
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16263
|
-
for (const key of keys) if (paragraph.paragraphStyle[key] === void 0) paragraph.paragraphStyle[key] = originParagraph.paragraphStyle[key];
|
|
16264
|
-
}
|
|
16265
|
-
else if (transformType === 1) {
|
|
16266
16616
|
const keys = Object.keys(originParagraph.paragraphStyle);
|
|
16267
16617
|
for (const key of keys) if (paragraph.paragraphStyle[key]) delete paragraph.paragraphStyle[key];
|
|
16268
16618
|
}
|
|
@@ -16357,6 +16707,33 @@ function transformBlockRanges(thisBlockRanges, otherBlockRanges, priority) {
|
|
|
16357
16707
|
function onlyHasDataStream(body) {
|
|
16358
16708
|
return Object.keys(body).length === 1;
|
|
16359
16709
|
}
|
|
16710
|
+
function getValueRangeIds(actions) {
|
|
16711
|
+
return new Set(actions.flatMap((action) => action.t !== "r" && action.valueRangeId ? [action.valueRangeId] : []));
|
|
16712
|
+
}
|
|
16713
|
+
function withoutValueRangeMetadata(actions, suppressed) {
|
|
16714
|
+
return actions.map((action) => {
|
|
16715
|
+
var _action$body, _body$customRanges;
|
|
16716
|
+
if (!((_action$body = action.body) === null || _action$body === void 0 || (_action$body = _action$body.customRanges) === null || _action$body === void 0 ? void 0 : _action$body.some((range) => suppressed.has(range.rangeId)))) return action;
|
|
16717
|
+
const body = {
|
|
16718
|
+
...action.body,
|
|
16719
|
+
customRanges: action.body.customRanges.filter((range) => !suppressed.has(range.rangeId))
|
|
16720
|
+
};
|
|
16721
|
+
if (!((_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.length)) delete body.customRanges;
|
|
16722
|
+
return {
|
|
16723
|
+
...action,
|
|
16724
|
+
body
|
|
16725
|
+
};
|
|
16726
|
+
});
|
|
16727
|
+
}
|
|
16728
|
+
function insertedAnchorPriority(first, second, priority) {
|
|
16729
|
+
if ((first === null || first === void 0 ? void 0 : first.t) !== "i" || (second === null || second === void 0 ? void 0 : second.t) !== "i") return priority === "left";
|
|
16730
|
+
const firstText = first.body.dataStream;
|
|
16731
|
+
const secondText = second.body.dataStream;
|
|
16732
|
+
if (firstText === secondText) return priority === "left";
|
|
16733
|
+
if (firstText === "" || secondText === "") return true;
|
|
16734
|
+
if (firstText === "" || secondText === "") return false;
|
|
16735
|
+
return priority === "left";
|
|
16736
|
+
}
|
|
16360
16737
|
function normalizeInsertActionParagraphIds(body, doc, currentIndex, reservedParagraphIds) {
|
|
16361
16738
|
normalizeInsertedParagraphIdsForDocument(doc.paragraphs, body.paragraphs, currentIndex, {
|
|
16362
16739
|
freshenSplitParagraph: false,
|
|
@@ -16373,6 +16750,15 @@ var TextX = class TextX {
|
|
|
16373
16750
|
return textXApply(doc, actions);
|
|
16374
16751
|
}
|
|
16375
16752
|
static compose(thisActions, otherActions) {
|
|
16753
|
+
const thisUpdates = getRangeUpdates(thisActions);
|
|
16754
|
+
const otherUpdates = getRangeUpdates(otherActions);
|
|
16755
|
+
if (thisUpdates.length || otherUpdates.length) {
|
|
16756
|
+
const thisText = withoutRangeUpdates(thisActions);
|
|
16757
|
+
const otherText = withoutRangeUpdates(otherActions);
|
|
16758
|
+
const updates = new Map(moveRangeUpdates(thisUpdates, otherText).map((update) => [update.rangeId, update]));
|
|
16759
|
+
for (const update of otherUpdates) updates.set(update.rangeId, composeRangeUpdate(updates.get(update.rangeId), update));
|
|
16760
|
+
return appendRangeUpdates(TextX.compose(thisText, otherText), Array.from(updates.values()));
|
|
16761
|
+
}
|
|
16376
16762
|
const thisIter = new ActionIterator(thisActions);
|
|
16377
16763
|
const otherIter = new ActionIterator(otherActions);
|
|
16378
16764
|
const textX = new TextX();
|
|
@@ -16382,22 +16768,24 @@ var TextX = class TextX {
|
|
|
16382
16768
|
const length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
16383
16769
|
const thisAction = thisIter.next(length);
|
|
16384
16770
|
const otherAction = otherIter.next(length);
|
|
16385
|
-
if (thisAction.t === "i" && otherAction.t === "r")
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
body: composeBody(thisAction.body, otherAction.body, otherAction.coverType)
|
|
16389
|
-
});
|
|
16390
|
-
else if (thisAction.t === "r" && otherAction.t === "r") if (thisAction.body == null && otherAction.body == null) textX.push(thisAction.len !== Number.POSITIVE_INFINITY ? thisAction : otherAction);
|
|
16391
|
-
else if (thisAction.body && otherAction.body) {
|
|
16392
|
-
const coverType = thisAction.coverType === 1 || otherAction.coverType === 1 ? 1 : 0;
|
|
16393
|
-
textX.push({
|
|
16771
|
+
if (thisAction.t === "i" && otherAction.t === "r") {
|
|
16772
|
+
if (otherAction.body == null) textX.push(thisAction);
|
|
16773
|
+
else textX.push({
|
|
16394
16774
|
...thisAction,
|
|
16395
|
-
t: "r",
|
|
16396
|
-
coverType,
|
|
16397
16775
|
body: composeBody(thisAction.body, otherAction.body, otherAction.coverType)
|
|
16398
16776
|
});
|
|
16399
|
-
} else
|
|
16400
|
-
|
|
16777
|
+
} else if (thisAction.t === "r" && otherAction.t === "r") {
|
|
16778
|
+
if (thisAction.body == null && otherAction.body == null) textX.push(thisAction.len !== Number.POSITIVE_INFINITY ? thisAction : otherAction);
|
|
16779
|
+
else if (thisAction.body && otherAction.body) {
|
|
16780
|
+
const coverType = thisAction.coverType === 1 || otherAction.coverType === 1 ? 1 : 0;
|
|
16781
|
+
textX.push({
|
|
16782
|
+
...thisAction,
|
|
16783
|
+
t: "r",
|
|
16784
|
+
coverType,
|
|
16785
|
+
body: composeBody(thisAction.body, otherAction.body, otherAction.coverType)
|
|
16786
|
+
});
|
|
16787
|
+
} else textX.push(thisAction.body ? thisAction : otherAction);
|
|
16788
|
+
} else if (thisAction.t === "r" && otherAction.t === "d") textX.push(otherAction);
|
|
16401
16789
|
else if (thisAction.t === "i" && otherAction.t === "d") {}
|
|
16402
16790
|
}
|
|
16403
16791
|
textX.trimEndUselessRetainAction();
|
|
@@ -16428,17 +16816,37 @@ var TextX = class TextX {
|
|
|
16428
16816
|
* 2) If the other body property exists, then execute the TransformBody logic to override it
|
|
16429
16817
|
*/
|
|
16430
16818
|
static transform(thisActions, otherActions, priority = "right") {
|
|
16819
|
+
const thisUpdates = getRangeUpdates(thisActions);
|
|
16820
|
+
const otherUpdates = getRangeUpdates(otherActions);
|
|
16821
|
+
if (thisUpdates.length || otherUpdates.length) {
|
|
16822
|
+
const thisText = withoutRangeUpdates(thisActions);
|
|
16823
|
+
const otherText = withoutRangeUpdates(otherActions);
|
|
16824
|
+
const otherAfterThis = TextX._transform(thisText, otherText, priority, true);
|
|
16825
|
+
const movedUpdates = moveRangeUpdates(thisUpdates, otherAfterThis, true);
|
|
16826
|
+
const updates = movedUpdates.flatMap((update) => transformRangeUpdate(update, otherUpdates.find((item) => item.rangeId === update.rangeId), priority));
|
|
16827
|
+
const suppressed = movedUpdates.flatMap((update) => update.range && otherUpdates.some((other) => other.rangeId === update.rangeId && !other.range) ? [update.range] : []);
|
|
16828
|
+
return dropRemovedRangeAnchors(reconcileRangeUpdates(TextX._transform(otherText, thisText, priority === "left" ? "right" : "left", true), otherUpdates), suppressed, updates);
|
|
16829
|
+
}
|
|
16431
16830
|
return this._transform(otherActions, thisActions, priority === "left" ? "right" : "left");
|
|
16432
16831
|
}
|
|
16433
|
-
static _transform(thisActions, otherActions, priority = "right") {
|
|
16434
|
-
const
|
|
16435
|
-
const
|
|
16832
|
+
static _transform(thisActions, otherActions, priority = "right", rangeAnchorAffinity = false) {
|
|
16833
|
+
const thisValues = getValueRangeIds(thisActions);
|
|
16834
|
+
const conflicts = new Set(Array.from(getValueRangeIds(otherActions)).filter((id) => thisValues.has(id)));
|
|
16835
|
+
const thisIter = new ActionIterator(conflicts.size && priority === "right" ? withoutValueRangeMetadata(thisActions, conflicts) : thisActions);
|
|
16836
|
+
const otherIter = new ActionIterator(conflicts.size && priority === "left" ? withoutValueRangeMetadata(otherActions, conflicts) : otherActions);
|
|
16436
16837
|
const textX = new TextX();
|
|
16437
|
-
while (thisIter.hasNext() || otherIter.hasNext()) if (thisIter.peekType() === "i" && (priority === "left" || otherIter.peekType() !== "i")) {
|
|
16838
|
+
while (thisIter.hasNext() || otherIter.hasNext()) if (thisIter.peekType() === "i" && ((rangeAnchorAffinity ? insertedAnchorPriority(thisIter.peek(), otherIter.peek(), priority) : priority === "left") || otherIter.peekType() !== "i")) {
|
|
16438
16839
|
const thisAction = thisIter.next();
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16840
|
+
if (thisAction.t === "i" && thisAction.valueRangeId && conflicts.has(thisAction.valueRangeId) && priority === "right") textX.push({
|
|
16841
|
+
t: "d",
|
|
16842
|
+
len: thisAction.len,
|
|
16843
|
+
valueRangeId: thisAction.valueRangeId
|
|
16844
|
+
});
|
|
16845
|
+
else textX.retain(thisAction.len);
|
|
16846
|
+
} else if (otherIter.peekType() === "i") {
|
|
16847
|
+
const otherAction = otherIter.next();
|
|
16848
|
+
if (otherAction.t !== "i" || !otherAction.valueRangeId || !conflicts.has(otherAction.valueRangeId) || priority !== "left") textX.push(otherAction);
|
|
16849
|
+
} else {
|
|
16442
16850
|
const length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
|
16443
16851
|
const thisAction = thisIter.next(length);
|
|
16444
16852
|
const otherAction = otherIter.next(length);
|
|
@@ -16484,11 +16892,20 @@ var TextX = class TextX {
|
|
|
16484
16892
|
return actions.length === 0;
|
|
16485
16893
|
}
|
|
16486
16894
|
static invert(actions) {
|
|
16895
|
+
if (getRangeUpdates(actions).length) {
|
|
16896
|
+
const restored = actions.flatMap((action) => {
|
|
16897
|
+
if (action.t !== "r" || !action.rangeUpdates) return [];
|
|
16898
|
+
if (!action.oldRangeUpdates) throw new Error("makeInvertible must capture custom ranges before inversion.");
|
|
16899
|
+
return action.oldRangeUpdates;
|
|
16900
|
+
});
|
|
16901
|
+
return appendRangeUpdates(TextX.invert(withoutRangeUpdates(actions)), Tools.deepClone(restored));
|
|
16902
|
+
}
|
|
16487
16903
|
const invertedActions = [];
|
|
16488
16904
|
for (const action of actions) if (action.t === "i") invertedActions.push({
|
|
16489
16905
|
t: "d",
|
|
16490
16906
|
len: action.len,
|
|
16491
|
-
body: action.body
|
|
16907
|
+
body: action.body,
|
|
16908
|
+
valueRangeId: action.valueRangeId
|
|
16492
16909
|
});
|
|
16493
16910
|
else if (action.t === "d") {
|
|
16494
16911
|
var _action$body$paragrap;
|
|
@@ -16500,7 +16917,8 @@ var TextX = class TextX {
|
|
|
16500
16917
|
invertedActions.push({
|
|
16501
16918
|
t: "i",
|
|
16502
16919
|
body: action.body,
|
|
16503
|
-
len: action.len
|
|
16920
|
+
len: action.len,
|
|
16921
|
+
valueRangeId: action.valueRangeId
|
|
16504
16922
|
});
|
|
16505
16923
|
} else if (action.body != null) {
|
|
16506
16924
|
if (action.oldBody == null) throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");
|
|
@@ -16520,6 +16938,16 @@ var TextX = class TextX {
|
|
|
16520
16938
|
const reservedParagraphIds = /* @__PURE__ */ new Set();
|
|
16521
16939
|
const reservedSectionIds = /* @__PURE__ */ new Set();
|
|
16522
16940
|
for (const action of actions) {
|
|
16941
|
+
if (action.t === "r" && action.rangeUpdates) action.oldRangeUpdates = action.rangeUpdates.map(({ rangeId, propertyPaths }) => {
|
|
16942
|
+
var _doc$customRanges, _ref;
|
|
16943
|
+
const index = ((_doc$customRanges = doc.customRanges) === null || _doc$customRanges === void 0 ? void 0 : _doc$customRanges.findIndex((range) => range.rangeId === rangeId)) ?? -1;
|
|
16944
|
+
return {
|
|
16945
|
+
rangeId,
|
|
16946
|
+
range: index < 0 ? null : Tools.deepClone(doc.customRanges[index]),
|
|
16947
|
+
nextRangeId: index < 0 ? void 0 : ((_ref = doc.customRanges[index + 1]) === null || _ref === void 0 ? void 0 : _ref.rangeId) ?? null,
|
|
16948
|
+
propertyPaths: index < 0 ? void 0 : propertyPaths
|
|
16949
|
+
};
|
|
16950
|
+
});
|
|
16523
16951
|
if (action.t === "i") {
|
|
16524
16952
|
normalizeInsertActionParagraphIds(action.body, doc, index, reservedParagraphIds);
|
|
16525
16953
|
normalizeInsertedSectionIdsForDocument(doc.sectionBreaks, action.body.sectionBreaks, reservedSectionIds);
|
|
@@ -16536,6 +16964,19 @@ var TextX = class TextX {
|
|
|
16536
16964
|
"columnGroups",
|
|
16537
16965
|
"blockRanges"
|
|
16538
16966
|
]) if (action.body[field] == null) delete body[field];
|
|
16967
|
+
if (action.body.paragraphs == null) delete body.paragraphs;
|
|
16968
|
+
else {
|
|
16969
|
+
var _body$paragraphs;
|
|
16970
|
+
const previousParagraphs = new Map((_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.map((paragraph) => [paragraph.startIndex, paragraph]));
|
|
16971
|
+
action.body.paragraphs = action.body.paragraphs.map((paragraph) => {
|
|
16972
|
+
const previous = previousParagraphs.get(paragraph.startIndex);
|
|
16973
|
+
if (!previous || paragraph.paragraphId != null && paragraph.paragraphId !== previous.paragraphId) return paragraph;
|
|
16974
|
+
const formatting = { ...paragraph };
|
|
16975
|
+
Reflect.deleteProperty(formatting, "paragraphId");
|
|
16976
|
+
Reflect.deleteProperty(previous, "paragraphId");
|
|
16977
|
+
return formatting;
|
|
16978
|
+
});
|
|
16979
|
+
}
|
|
16539
16980
|
action.oldBody = {
|
|
16540
16981
|
...body,
|
|
16541
16982
|
dataStream: ""
|
|
@@ -16547,6 +16988,28 @@ var TextX = class TextX {
|
|
|
16547
16988
|
}
|
|
16548
16989
|
return invertibleActions;
|
|
16549
16990
|
}
|
|
16991
|
+
/** Edits only changed property leaves; does not replace range identity, bounds or peer properties. */
|
|
16992
|
+
updateCustomRangeProperties(range, properties) {
|
|
16993
|
+
const propertyPaths = getChangedPropertyPaths(range.properties ?? {}, properties);
|
|
16994
|
+
if (propertyPaths.length) this.updateCustomRanges([{
|
|
16995
|
+
rangeId: range.rangeId,
|
|
16996
|
+
range: {
|
|
16997
|
+
...range,
|
|
16998
|
+
properties
|
|
16999
|
+
},
|
|
17000
|
+
propertyPaths
|
|
17001
|
+
}]);
|
|
17002
|
+
return this;
|
|
17003
|
+
}
|
|
17004
|
+
/** Updates identities after all text edits; range positions refer to the resulting document. */
|
|
17005
|
+
updateCustomRanges(updates) {
|
|
17006
|
+
this.push({
|
|
17007
|
+
t: "r",
|
|
17008
|
+
len: 0,
|
|
17009
|
+
rangeUpdates: updates
|
|
17010
|
+
});
|
|
17011
|
+
return this;
|
|
17012
|
+
}
|
|
16550
17013
|
insert(len, body) {
|
|
16551
17014
|
const insertAction = {
|
|
16552
17015
|
t: "i",
|
|
@@ -16589,9 +17052,9 @@ var TextX = class TextX {
|
|
|
16589
17052
|
let index = this._actions.length;
|
|
16590
17053
|
let lastAction = this._actions[index - 1];
|
|
16591
17054
|
const newAction = Tools.deepClone(args[0]);
|
|
16592
|
-
if (newAction.t === "r" && newAction.len === 0 && newAction.body == null) return this;
|
|
17055
|
+
if (newAction.t === "r" && newAction.len === 0 && newAction.body == null && !newAction.rangeUpdates) return this;
|
|
16593
17056
|
if (typeof lastAction === "object") {
|
|
16594
|
-
if (lastAction.t === "d" && newAction.t === "d") {
|
|
17057
|
+
if (lastAction.t === "d" && newAction.t === "d" && lastAction.valueRangeId === newAction.valueRangeId) {
|
|
16595
17058
|
lastAction.len += newAction.len;
|
|
16596
17059
|
return this;
|
|
16597
17060
|
}
|
|
@@ -16603,11 +17066,11 @@ var TextX = class TextX {
|
|
|
16603
17066
|
return this;
|
|
16604
17067
|
}
|
|
16605
17068
|
}
|
|
16606
|
-
if (lastAction.t === "r" && newAction.t === "r" && lastAction.body == null && newAction.body == null) {
|
|
17069
|
+
if (lastAction.t === "r" && newAction.t === "r" && lastAction.body == null && newAction.body == null && !lastAction.rangeUpdates && !newAction.rangeUpdates) {
|
|
16607
17070
|
lastAction.len += newAction.len;
|
|
16608
17071
|
return this;
|
|
16609
17072
|
}
|
|
16610
|
-
if (lastAction.t === "i" && onlyHasDataStream(lastAction.body) && newAction.t === "i" && onlyHasDataStream(newAction.body)) {
|
|
17073
|
+
if (lastAction.t === "i" && onlyHasDataStream(lastAction.body) && newAction.t === "i" && onlyHasDataStream(newAction.body) && lastAction.valueRangeId === newAction.valueRangeId) {
|
|
16611
17074
|
lastAction.len += newAction.len;
|
|
16612
17075
|
lastAction.body.dataStream += newAction.body.dataStream;
|
|
16613
17076
|
return this;
|
|
@@ -17408,8 +17871,10 @@ function mergeSelections(selections) {
|
|
|
17408
17871
|
}
|
|
17409
17872
|
function isIntervalCoveredBySelections(interval, selections, body, implicitTokens) {
|
|
17410
17873
|
let cursor = interval.startOffset;
|
|
17874
|
+
let intersectsSelection = false;
|
|
17411
17875
|
for (const selection of selections) {
|
|
17412
17876
|
if (selection.endOffset <= cursor || selection.startOffset >= interval.endOffset) continue;
|
|
17877
|
+
intersectsSelection = true;
|
|
17413
17878
|
const selectionStart = Math.max(selection.startOffset, interval.startOffset);
|
|
17414
17879
|
const selectionEnd = Math.min(selection.endOffset, interval.endOffset);
|
|
17415
17880
|
for (let offset = cursor; offset < selectionStart; offset++) if (!implicitTokens.has(body.dataStream[offset])) return false;
|
|
@@ -17417,7 +17882,7 @@ function isIntervalCoveredBySelections(interval, selections, body, implicitToken
|
|
|
17417
17882
|
if (cursor >= interval.endOffset) return true;
|
|
17418
17883
|
}
|
|
17419
17884
|
for (let offset = cursor; offset < interval.endOffset; offset++) if (!implicitTokens.has(body.dataStream[offset])) return false;
|
|
17420
|
-
return
|
|
17885
|
+
return intersectsSelection;
|
|
17421
17886
|
}
|
|
17422
17887
|
function addCoveredIntervals(selections, intervals, body, implicitTokens) {
|
|
17423
17888
|
const expanded = [...selections];
|
|
@@ -17604,13 +18069,14 @@ function normalizeSelectionsForStructuralSentinels(selections, body, insertBody)
|
|
|
17604
18069
|
collapsed: true
|
|
17605
18070
|
}];
|
|
17606
18071
|
}
|
|
17607
|
-
function deleteSelectionTextX(selections, body, memoryCursor = 0, insertBody = null, keepBullet = true) {
|
|
18072
|
+
function deleteSelectionTextX(selections, body, memoryCursor = 0, insertBody = null, keepBullet = true, documentFlavor) {
|
|
17608
18073
|
const normalizedSelections = normalizeSelectionsForStructuralSentinels([...selections].sort((a, b) => a.startOffset - b.startOffset), body, insertBody);
|
|
17609
18074
|
const dos = [];
|
|
17610
18075
|
const { paragraphs = [] } = body;
|
|
17611
18076
|
const paragraphInRange = paragraphs === null || paragraphs === void 0 ? void 0 : paragraphs.find((p) => p.startIndex >= normalizedSelections[0].startOffset && p.startIndex < normalizedSelections[0].endOffset);
|
|
17612
18077
|
let cursor = memoryCursor;
|
|
17613
18078
|
normalizedSelections.forEach((selection) => {
|
|
18079
|
+
var _emptiedParagraph$par;
|
|
17614
18080
|
const { startOffset, endOffset } = selection;
|
|
17615
18081
|
if (startOffset > cursor) {
|
|
17616
18082
|
dos.push({
|
|
@@ -17626,6 +18092,25 @@ function deleteSelectionTextX(selections, body, memoryCursor = 0, insertBody = n
|
|
|
17626
18092
|
});
|
|
17627
18093
|
cursor = endOffset;
|
|
17628
18094
|
}
|
|
18095
|
+
const emptiedParagraph = documentFlavor === 2 && normalizedSelections.length === 1 && !insertBody && startOffset < endOffset ? paragraphs.find((paragraph) => paragraph.startIndex === endOffset && getParagraphContentStartOffset(body, paragraph) === startOffset) : void 0;
|
|
18096
|
+
if (emptiedParagraph && ((_emptiedParagraph$par = emptiedParagraph.paragraphStyle) === null || _emptiedParagraph$par === void 0 ? void 0 : _emptiedParagraph$par.paragraphMarkTextStyle) == null) {
|
|
18097
|
+
var _body$textRuns;
|
|
18098
|
+
const textStyle = ((_body$textRuns = body.textRuns) === null || _body$textRuns === void 0 || (_body$textRuns = _body$textRuns.find((run) => run.st <= startOffset && run.ed > startOffset)) === null || _body$textRuns === void 0 ? void 0 : _body$textRuns.ts) ?? {};
|
|
18099
|
+
dos.push({
|
|
18100
|
+
t: "r",
|
|
18101
|
+
len: 1,
|
|
18102
|
+
body: {
|
|
18103
|
+
dataStream: "",
|
|
18104
|
+
textRuns: [{
|
|
18105
|
+
st: 0,
|
|
18106
|
+
ed: 1,
|
|
18107
|
+
ts: { ...textStyle }
|
|
18108
|
+
}]
|
|
18109
|
+
},
|
|
18110
|
+
coverType: 1
|
|
18111
|
+
});
|
|
18112
|
+
cursor++;
|
|
18113
|
+
}
|
|
17629
18114
|
});
|
|
17630
18115
|
if (insertBody) dos.push({
|
|
17631
18116
|
t: "i",
|
|
@@ -17829,7 +18314,13 @@ function removeDrawingReferences(documentData, selections, body = documentData.b
|
|
|
17829
18314
|
const prefix = footnote ? ["notes", segmentId] : [];
|
|
17830
18315
|
const drawings = source.drawings ?? {};
|
|
17831
18316
|
const drawingOrder = source.drawingsOrder ?? [];
|
|
17832
|
-
const
|
|
18317
|
+
const removedIds = new Set(getCustomBlockIdsInSelections(body, selections));
|
|
18318
|
+
let previousSize = -1;
|
|
18319
|
+
while (previousSize !== removedIds.size) {
|
|
18320
|
+
previousSize = removedIds.size;
|
|
18321
|
+
for (const drawing of Object.values(drawings)) if (drawing.groupId && removedIds.has(drawing.groupId)) removedIds.add(drawing.drawingId);
|
|
18322
|
+
}
|
|
18323
|
+
const blockIds = [...removedIds].sort((left, right) => drawingOrder.indexOf(right) - drawingOrder.indexOf(left));
|
|
17833
18324
|
const jsonX = JSONX.getInstance();
|
|
17834
18325
|
const actions = [];
|
|
17835
18326
|
for (const blockId of blockIds) {
|
|
@@ -20699,14 +21190,16 @@ function scanDocumentStructuralTokens(dataStream) {
|
|
|
20699
21190
|
function validateTableMetadata(body, scan, issues, context) {
|
|
20700
21191
|
const pairedTables = scan.tableRanges.pairs;
|
|
20701
21192
|
const metadataStarts = /* @__PURE__ */ new Set();
|
|
20702
|
-
|
|
21193
|
+
const parents = [];
|
|
20703
21194
|
const tables = sortStructuralRanges(body.tables ?? []);
|
|
20704
21195
|
for (const table of tables) {
|
|
20705
21196
|
metadataStarts.add(table.startIndex);
|
|
20706
21197
|
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));
|
|
20707
21198
|
if (!Number.isInteger(table.endIndex) || table.endIndex <= table.startIndex || table.endIndex > body.dataStream.length || body.dataStream[table.endIndex - 1] !== "" || pairedTables.get(table.startIndex) !== table.endIndex) issues.push(createIssue(context, "table-end-token-mismatch", "Table endIndex must be the exclusive boundary immediately after a table end sentinel.", table.endIndex));
|
|
20708
|
-
|
|
20709
|
-
|
|
21199
|
+
while (parents.length > 0 && parents[parents.length - 1].endIndex <= table.startIndex) parents.pop();
|
|
21200
|
+
const parent = parents[parents.length - 1];
|
|
21201
|
+
if (parent && (table.startIndex === parent.startIndex || table.endIndex >= parent.endIndex)) issues.push(createIssue(context, "overlapping-table", "Table ranges may nest but must not cross or duplicate.", table.startIndex));
|
|
21202
|
+
parents.push(table);
|
|
20710
21203
|
}
|
|
20711
21204
|
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));
|
|
20712
21205
|
}
|
|
@@ -20767,14 +21260,13 @@ function validateStructuralContainers(body, issues, context) {
|
|
|
20767
21260
|
const columnGroupStack = [];
|
|
20768
21261
|
const columnStack = [];
|
|
20769
21262
|
const tableStack = [];
|
|
20770
|
-
const tableRowStack = [];
|
|
20771
|
-
const tableCellStack = [];
|
|
20772
21263
|
const tokenPattern = new RegExp(DOCUMENT_STRUCTURAL_TOKEN_PATTERN_SOURCE, "g");
|
|
20773
21264
|
for (const match of body.dataStream.matchAll(tokenPattern)) {
|
|
20774
21265
|
const i = match.index;
|
|
20775
21266
|
const char = match[0];
|
|
20776
21267
|
const column = columnStack[columnStack.length - 1];
|
|
20777
|
-
const
|
|
21268
|
+
const table = tableStack[tableStack.length - 1];
|
|
21269
|
+
const cell = table === null || table === void 0 ? void 0 : table.cell;
|
|
20778
21270
|
if (char === "\r") {
|
|
20779
21271
|
if (column) column.hasChild = true;
|
|
20780
21272
|
if (cell) cell.hasParagraph = true;
|
|
@@ -20790,33 +21282,69 @@ function validateStructuralContainers(body, issues, context) {
|
|
|
20790
21282
|
const closedColumn = columnStack.pop();
|
|
20791
21283
|
if (!closedColumn) issues.push(createIssue(context, "unbalanced-column-group", "Column end token has no matching column start.", i));
|
|
20792
21284
|
else if (!closedColumn.hasChild) issues.push(createIssue(context, "empty-column", "Column must contain at least one paragraph or section child.", closedColumn.startIndex));
|
|
20793
|
-
} else if (char === "")
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
else if (char === "
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
else if (char === "
|
|
20805
|
-
|
|
20806
|
-
if (
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
|
|
20810
|
-
|
|
20811
|
-
} else
|
|
20812
|
-
|
|
20813
|
-
issues.push(createIssue(context, "
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
21285
|
+
} else if (char === "") {
|
|
21286
|
+
if (columnStack.length > 0 || columnGroupStack.length === 0) {
|
|
21287
|
+
issues.push(createIssue(context, "unbalanced-column-group", "Column group closes while a column is still open.", i));
|
|
21288
|
+
columnStack.length = 0;
|
|
21289
|
+
} else columnGroupStack.pop();
|
|
21290
|
+
} else if (char === "") {
|
|
21291
|
+
if (table && !cell) issues.push(createIssue(context, "unbalanced-table", "Nested table must be inside a parent cell.", i));
|
|
21292
|
+
tableStack.push({ inRow: false });
|
|
21293
|
+
} else if (char === "\x1B") {
|
|
21294
|
+
if (!table || table.inRow) issues.push(createIssue(context, "unbalanced-table", "Table row must start inside a table without an open row.", i));
|
|
21295
|
+
if (table) table.inRow = true;
|
|
21296
|
+
} else if (char === "") {
|
|
21297
|
+
if (!(table === null || table === void 0 ? void 0 : table.inRow) || cell) issues.push(createIssue(context, "unbalanced-table", "Table cell must start inside a row without an open cell.", i));
|
|
21298
|
+
if (table) table.cell = {
|
|
21299
|
+
startIndex: i,
|
|
21300
|
+
hasParagraph: false,
|
|
21301
|
+
hasSectionBreak: false
|
|
21302
|
+
};
|
|
21303
|
+
} else if (char === "") {
|
|
21304
|
+
if (!cell) issues.push(createIssue(context, "unbalanced-table", "Table cell end token has no matching start.", i));
|
|
21305
|
+
else if (!cell.hasParagraph || !cell.hasSectionBreak) issues.push(createIssue(context, "empty-table-cell", "Table cell must contain a paragraph and section break child.", cell.startIndex));
|
|
21306
|
+
if (table) table.cell = void 0;
|
|
21307
|
+
} else if (char === "") {
|
|
21308
|
+
if (!(table === null || table === void 0 ? void 0 : table.inRow) || cell) issues.push(createIssue(context, "unbalanced-table", "Table row closes while a cell is still open.", i));
|
|
21309
|
+
if (table) table.inRow = false;
|
|
21310
|
+
} else if (char === "") {
|
|
21311
|
+
if (!table || table.inRow || cell) issues.push(createIssue(context, "unbalanced-table", "Table closes while a row or cell is still open.", i));
|
|
21312
|
+
tableStack.pop();
|
|
21313
|
+
}
|
|
20817
21314
|
}
|
|
20818
21315
|
if (columnGroupStack.length > 0 || columnStack.length > 0) issues.push(createIssue(context, "unbalanced-column-group", "Column group or column token is not closed.", body.dataStream.length));
|
|
20819
|
-
if (tableStack.length > 0
|
|
21316
|
+
if (tableStack.length > 0) issues.push(createIssue(context, "unbalanced-table", "Table, row, or cell token is not closed.", body.dataStream.length));
|
|
21317
|
+
}
|
|
21318
|
+
function validateCustomRangeMetadata(body, issues, context) {
|
|
21319
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
21320
|
+
const starts = [];
|
|
21321
|
+
for (let index = 0; index < body.dataStream.length; index++) {
|
|
21322
|
+
const token = body.dataStream[index];
|
|
21323
|
+
if (token === "") starts.push(index);
|
|
21324
|
+
else if (token === "") {
|
|
21325
|
+
const start = starts.pop();
|
|
21326
|
+
if (start == null) issues.push(createIssue(context, "unbalanced-custom-range", "Custom range end token has no matching start.", index));
|
|
21327
|
+
else pairs.set(start, index);
|
|
21328
|
+
}
|
|
21329
|
+
}
|
|
21330
|
+
for (const start of starts) issues.push(createIssue(context, "unbalanced-custom-range", "Custom range start token has no matching end.", start));
|
|
21331
|
+
const ranges = body.customRanges ?? [];
|
|
21332
|
+
const ids = /* @__PURE__ */ new Set();
|
|
21333
|
+
for (const range of ranges) {
|
|
21334
|
+
if (ids.has(range.rangeId)) issues.push(createIssue(context, "duplicate-custom-range-id", "Custom range ids must be unique.", range.startIndex));
|
|
21335
|
+
ids.add(range.rangeId);
|
|
21336
|
+
if (range.rangeType !== 1) continue;
|
|
21337
|
+
if (body.dataStream[range.startIndex] !== "" || body.dataStream[range.endIndex] !== "" || pairs.get(range.startIndex) !== range.endIndex) issues.push(createIssue(context, "custom-range-token-mismatch", "Field metadata must point to a matching custom range token pair.", range.startIndex));
|
|
21338
|
+
}
|
|
21339
|
+
for (const [start, end] of pairs) if (!ranges.some((range) => range.startIndex === start && range.endIndex === end)) issues.push(createIssue(context, "missing-custom-range-metadata", "Custom range token pair has no metadata.", start));
|
|
21340
|
+
const sortedFields = ranges.filter((range) => range.rangeType === 1).slice().sort((left, right) => left.startIndex - right.startIndex || right.endIndex - left.endIndex);
|
|
21341
|
+
const parents = [];
|
|
21342
|
+
for (const range of sortedFields) {
|
|
21343
|
+
while (parents.length > 0 && parents[parents.length - 1].endIndex < range.startIndex) parents.pop();
|
|
21344
|
+
const parent = parents[parents.length - 1];
|
|
21345
|
+
if (parent && range.endIndex > parent.endIndex) issues.push(createIssue(context, "crossing-custom-range", "Field ranges may nest but must not cross.", range.startIndex));
|
|
21346
|
+
parents.push(range);
|
|
21347
|
+
}
|
|
20820
21348
|
}
|
|
20821
21349
|
function validateDocBodyStructure(body, context = { segmentType: "body" }) {
|
|
20822
21350
|
const issues = [];
|
|
@@ -20829,6 +21357,7 @@ function validateDocBodyStructure(body, context = { segmentType: "body" }) {
|
|
|
20829
21357
|
validateColumnGroupMetadata(body, scan, issues, context);
|
|
20830
21358
|
validateCustomBlockMetadata(body, scan, issues, context);
|
|
20831
21359
|
validateStructuralContainers(body, issues, context);
|
|
21360
|
+
validateCustomRangeMetadata(body, issues, context);
|
|
20832
21361
|
if (context.segmentType === "header" || context.segmentType === "footer") {
|
|
20833
21362
|
for (const range of body.customRanges ?? []) if (range.rangeType === 8 || range.rangeType === 9) issues.push(createIssue(context, "invalid-note-reference", "Note references are only supported in the document body.", range.startIndex));
|
|
20834
21363
|
}
|
|
@@ -20971,6 +21500,37 @@ function resolveSectionHeaderFooterReferences(documentStyle, sections, sectionIn
|
|
|
20971
21500
|
return result;
|
|
20972
21501
|
}
|
|
20973
21502
|
|
|
21503
|
+
//#endregion
|
|
21504
|
+
//#region src/docs/sdt-binding.ts
|
|
21505
|
+
function getSdtBindingKey(range) {
|
|
21506
|
+
var _range$properties;
|
|
21507
|
+
const binding = (_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.dataBinding;
|
|
21508
|
+
if (!(binding === null || binding === void 0 ? void 0 : binding.storeItemID) || !binding.xpath) return;
|
|
21509
|
+
return JSON.stringify([
|
|
21510
|
+
binding.storeItemID.toLowerCase(),
|
|
21511
|
+
binding.xpath,
|
|
21512
|
+
binding.prefixMappings ?? ""
|
|
21513
|
+
]);
|
|
21514
|
+
}
|
|
21515
|
+
/** Scalar XML values, independent of the control's display label or date format. */
|
|
21516
|
+
function getSdtBindingValue(body, range) {
|
|
21517
|
+
if (range.properties.showingPlaceholder) return "";
|
|
21518
|
+
if (range.properties.kind === "checkbox") {
|
|
21519
|
+
var _range$properties$che;
|
|
21520
|
+
return ((_range$properties$che = range.properties.checkbox) === null || _range$properties$che === void 0 ? void 0 : _range$properties$che.checked) ? "true" : "false";
|
|
21521
|
+
}
|
|
21522
|
+
const text = body.dataStream.slice(range.startIndex, range.endIndex + 1).replace(/^[\x00-\x08\x0A-\x1F]+|[\x00-\x08\x0A-\x1F]+$/g, "");
|
|
21523
|
+
if (range.properties.kind === "date") {
|
|
21524
|
+
var _range$properties$dat;
|
|
21525
|
+
return ((_range$properties$dat = range.properties.date) === null || _range$properties$dat === void 0 ? void 0 : _range$properties$dat.fullDate) ?? text;
|
|
21526
|
+
}
|
|
21527
|
+
if (range.properties.kind === "dropDownList" || range.properties.kind === "comboBox") {
|
|
21528
|
+
var _range$properties$lis;
|
|
21529
|
+
return ((_range$properties$lis = range.properties.listItems) === null || _range$properties$lis === void 0 || (_range$properties$lis = _range$properties$lis.find((item) => item.displayText === text)) === null || _range$properties$lis === void 0 ? void 0 : _range$properties$lis.value) ?? text;
|
|
21530
|
+
}
|
|
21531
|
+
return ["text", "richText"].includes(range.properties.kind) ? text : void 0;
|
|
21532
|
+
}
|
|
21533
|
+
|
|
20974
21534
|
//#endregion
|
|
20975
21535
|
//#region src/observer/observable.ts
|
|
20976
21536
|
/**
|
|
@@ -21750,7 +22310,7 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
|
21750
22310
|
const marginBottom = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.b) ?? DEFAULT_PADDING_DATA.b;
|
|
21751
22311
|
const marginLeft = (paddingData === null || paddingData === void 0 ? void 0 : paddingData.l) ?? DEFAULT_PADDING_DATA.l;
|
|
21752
22312
|
const { vertexAngle, centerAngle } = convertTextRotation(textRotation);
|
|
21753
|
-
|
|
22313
|
+
const documentData = {
|
|
21754
22314
|
id: "d",
|
|
21755
22315
|
body: {
|
|
21756
22316
|
dataStream: `${content}${"\r\n"}`,
|
|
@@ -21793,7 +22353,8 @@ function createDocumentModelWithStyle(content, textStyle, config = {}) {
|
|
|
21793
22353
|
},
|
|
21794
22354
|
drawings: {},
|
|
21795
22355
|
drawingsOrder: []
|
|
21796
|
-
}
|
|
22356
|
+
};
|
|
22357
|
+
return new DocumentDataModel(documentData);
|
|
21797
22358
|
}
|
|
21798
22359
|
function extractOtherStyle(style) {
|
|
21799
22360
|
if (!style) return {};
|
|
@@ -22045,7 +22606,8 @@ var ColumnManager = class {
|
|
|
22045
22606
|
const columnData = {};
|
|
22046
22607
|
let index = 0;
|
|
22047
22608
|
for (let i = columnPos; i < columnPos + numColumns; i++) {
|
|
22048
|
-
|
|
22609
|
+
const data = this.getColumn(i);
|
|
22610
|
+
columnData[index] = data ?? {
|
|
22049
22611
|
w: this._config.defaultColumnWidth,
|
|
22050
22612
|
hd: 0
|
|
22051
22613
|
};
|
|
@@ -22422,14 +22984,16 @@ var Range = class Range {
|
|
|
22422
22984
|
getFontSize() {
|
|
22423
22985
|
var _this$getValue, _p$body3;
|
|
22424
22986
|
const p = ((_this$getValue = this.getValue()) === null || _this$getValue === void 0 ? void 0 : _this$getValue.p) || {};
|
|
22425
|
-
if (p && Array.isArray((_p$body3 = p.body) === null || _p$body3 === void 0 ? void 0 : _p$body3.textRuns) && p.body.textRuns.length > 0)
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22987
|
+
if (p && Array.isArray((_p$body3 = p.body) === null || _p$body3 === void 0 ? void 0 : _p$body3.textRuns) && p.body.textRuns.length > 0) {
|
|
22988
|
+
if (p.body.textRuns.some((textRun) => {
|
|
22989
|
+
var _textRun$ts;
|
|
22990
|
+
return (textRun === null || textRun === void 0 || (_textRun$ts = textRun.ts) === null || _textRun$ts === void 0 ? void 0 : _textRun$ts.fs) != null;
|
|
22991
|
+
})) return Math.max(...p.body.textRuns.map((textRun) => {
|
|
22992
|
+
var _textRun$ts2;
|
|
22993
|
+
return (textRun === null || textRun === void 0 || (_textRun$ts2 = textRun.ts) === null || _textRun$ts2 === void 0 ? void 0 : _textRun$ts2.fs) || 0;
|
|
22994
|
+
}));
|
|
22995
|
+
else return this.getFontSizes()[0][0];
|
|
22996
|
+
}
|
|
22433
22997
|
return this.getFontSizes()[0][0];
|
|
22434
22998
|
}
|
|
22435
22999
|
/**
|
|
@@ -22725,7 +23289,8 @@ var RowManager = class {
|
|
|
22725
23289
|
const rowData = {};
|
|
22726
23290
|
let index = 0;
|
|
22727
23291
|
for (let i = rowPos; i < rowPos + numRows; i++) {
|
|
22728
|
-
|
|
23292
|
+
const data = this.getRow(i);
|
|
23293
|
+
rowData[index] = data ?? {
|
|
22729
23294
|
h: this._config.defaultRowHeight,
|
|
22730
23295
|
hd: 0
|
|
22731
23296
|
};
|
|
@@ -23709,13 +24274,18 @@ var Worksheet = class {
|
|
|
23709
24274
|
setColumnCount(count) {
|
|
23710
24275
|
this._snapshot.columnCount = count;
|
|
23711
24276
|
}
|
|
23712
|
-
/**
|
|
23713
|
-
* isSheetHidden
|
|
23714
|
-
* @returns hidden status of sheet
|
|
23715
|
-
*/
|
|
24277
|
+
/** Returns 0 for visible, 1 for either hidden state, preserving the existing predicate API. */
|
|
23716
24278
|
isSheetHidden() {
|
|
24279
|
+
return this._snapshot.hidden === 0 ? 0 : 1;
|
|
24280
|
+
}
|
|
24281
|
+
/** Returns the complete persisted state, including VERY_HIDDEN (2). */
|
|
24282
|
+
getHiddenState() {
|
|
23717
24283
|
return this._snapshot.hidden;
|
|
23718
24284
|
}
|
|
24285
|
+
/** Model mutation primitive. User-facing changes must go through worksheet hide/show commands. */
|
|
24286
|
+
setHiddenState(hidden) {
|
|
24287
|
+
this._snapshot.hidden = hidden;
|
|
24288
|
+
}
|
|
23719
24289
|
/**
|
|
23720
24290
|
* Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
|
|
23721
24291
|
* @returns {boolean} Gridlines Hidden Status.
|
|
@@ -24422,11 +24992,11 @@ let Workbook = class Workbook extends UnitModel {
|
|
|
24422
24992
|
const { sheetOrder } = this._snapshot;
|
|
24423
24993
|
return this._worksheets.get(sheetOrder[index]);
|
|
24424
24994
|
}
|
|
24425
|
-
getHiddenWorksheets() {
|
|
24426
|
-
return this.getSheets().filter((s) => s.
|
|
24995
|
+
getHiddenWorksheets(includeVeryHidden = true) {
|
|
24996
|
+
return this.getSheets().filter((s) => s.isSheetHidden() === 1).filter((s) => includeVeryHidden || s.getHiddenState() !== 2).map((s) => s.getConfig().id);
|
|
24427
24997
|
}
|
|
24428
24998
|
getUnhiddenWorksheets() {
|
|
24429
|
-
return this.getSheets().filter((s) => s.
|
|
24999
|
+
return this.getSheets().filter((s) => s.isSheetHidden() !== 1).map((s) => s.getConfig().id);
|
|
24430
25000
|
}
|
|
24431
25001
|
load(config) {
|
|
24432
25002
|
this._snapshot = config;
|
|
@@ -25134,20 +25704,23 @@ let LocalUndoRedoService = class LocalUndoRedoService extends Disposable {
|
|
|
25134
25704
|
redoStack.length = 0;
|
|
25135
25705
|
const activeGroup = this._activeGroups.get(unitID);
|
|
25136
25706
|
const lastItem = this._pitchUndoElement(unitID);
|
|
25137
|
-
if (activeGroup)
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
|
|
25141
|
-
|
|
25142
|
-
|
|
25143
|
-
|
|
25144
|
-
|
|
25145
|
-
|
|
25146
|
-
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
|
|
25150
|
-
|
|
25707
|
+
if (activeGroup) {
|
|
25708
|
+
if (lastItem && this._itemGroups.get(lastItem) === activeGroup.id) {
|
|
25709
|
+
if (activeGroup.mode === "replace") lastItem.redoMutations = item.redoMutations;
|
|
25710
|
+
else {
|
|
25711
|
+
lastItem.redoMutations.push(...item.redoMutations);
|
|
25712
|
+
lastItem.undoMutations.unshift(...item.undoMutations);
|
|
25713
|
+
}
|
|
25714
|
+
} else {
|
|
25715
|
+
appendNewItem(item);
|
|
25716
|
+
this._itemGroups.set(item, activeGroup.id);
|
|
25717
|
+
}
|
|
25718
|
+
} else if (this._batchingStatus.has(item.unitID)) {
|
|
25719
|
+
if (this._batchingStatus.get(item.unitID) === 0 || !lastItem) {
|
|
25720
|
+
appendNewItem(item);
|
|
25721
|
+
this._batchingStatus.set(item.unitID, 1);
|
|
25722
|
+
} else this._tryBatchingElements(lastItem, item);
|
|
25723
|
+
} else appendNewItem(item);
|
|
25151
25724
|
function appendNewItem(item) {
|
|
25152
25725
|
undoStack.push(item);
|
|
25153
25726
|
if (undoStack.length > historyLimit) undoStack.splice(0, 1);
|
|
@@ -25264,13 +25837,14 @@ let LocalUndoRedoService = class LocalUndoRedoService extends Disposable {
|
|
|
25264
25837
|
const isFocusSheet = this._contextService.getContextValue(FOCUSING_SHEET);
|
|
25265
25838
|
const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
|
|
25266
25839
|
const isFocusEditor = this._contextService.getContextValue(EDITOR_ACTIVATED);
|
|
25267
|
-
if (isFocusSheet)
|
|
25268
|
-
|
|
25269
|
-
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25273
|
-
|
|
25840
|
+
if (isFocusSheet) {
|
|
25841
|
+
if (isFocusFormulaEditor && isFocusEditor) unitID = DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
|
|
25842
|
+
else if (isFocusEditor) unitID = DOCS_NORMAL_EDITOR_UNIT_ID_KEY;
|
|
25843
|
+
else {
|
|
25844
|
+
var _this$_univerInstance;
|
|
25845
|
+
unitID = ((_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId()) ?? "";
|
|
25846
|
+
}
|
|
25847
|
+
} else {
|
|
25274
25848
|
var _this$_univerInstance2;
|
|
25275
25849
|
unitID = ((_this$_univerInstance2 = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getUnitId()) ?? "";
|
|
25276
25850
|
}
|
|
@@ -25867,12 +26441,13 @@ var PermissionService = class extends Disposable {
|
|
|
25867
26441
|
return permissionPoint;
|
|
25868
26442
|
}
|
|
25869
26443
|
composePermission$(permissionIdList) {
|
|
25870
|
-
|
|
26444
|
+
const subjectList = permissionIdList.map((id) => {
|
|
25871
26445
|
var _this$_permissionPoin;
|
|
25872
26446
|
const subject = (_this$_permissionPoin = this._permissionPointMap) === null || _this$_permissionPoin === void 0 ? void 0 : _this$_permissionPoin.get(id);
|
|
25873
26447
|
if (!subject) throw new Error(`[PermissionService]: ${id} permissionPoint does not exist!`);
|
|
25874
26448
|
return subject.asObservable();
|
|
25875
|
-
})
|
|
26449
|
+
});
|
|
26450
|
+
return (0, rxjs.combineLatest)(subjectList).pipe((0, rxjs_operators.map)((list) => {
|
|
25876
26451
|
return list;
|
|
25877
26452
|
}));
|
|
25878
26453
|
}
|
|
@@ -25997,8 +26572,10 @@ let PluginService = class PluginService {
|
|
|
25997
26572
|
this._pluginRegistry.set(ctor.pluginName, item);
|
|
25998
26573
|
this._logService.debug("[PluginService]", `Plugin "${ctor.pluginName}" registered.`);
|
|
25999
26574
|
const { type } = ctor;
|
|
26000
|
-
if (this._loadedPluginTypes.has(type))
|
|
26001
|
-
|
|
26575
|
+
if (this._loadedPluginTypes.has(type)) {
|
|
26576
|
+
if (type === _univerjs_protocol.UniverType.UNIVER_UNKNOWN) this._loadFromPlugins([item]);
|
|
26577
|
+
else this._flushType(type);
|
|
26578
|
+
}
|
|
26002
26579
|
}
|
|
26003
26580
|
startPluginsForType(type) {
|
|
26004
26581
|
if (this._loadedPluginTypes.has(type)) return;
|
|
@@ -26087,9 +26664,7 @@ let PluginService = class PluginService {
|
|
|
26087
26664
|
case 2:
|
|
26088
26665
|
p.onRendered();
|
|
26089
26666
|
break;
|
|
26090
|
-
case 3:
|
|
26091
|
-
p.onSteady();
|
|
26092
|
-
break;
|
|
26667
|
+
case 3: p.onSteady();
|
|
26093
26668
|
}
|
|
26094
26669
|
});
|
|
26095
26670
|
}
|
|
@@ -26571,12 +27146,13 @@ var RTree = class {
|
|
|
26571
27146
|
remove(search) {
|
|
26572
27147
|
const { unitId, sheetId: subUnitId, range, id } = search;
|
|
26573
27148
|
const { startRow, startColumn, endRow, endColumn } = range;
|
|
26574
|
-
if (this._enableOneCellCache)
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26578
|
-
|
|
26579
|
-
|
|
27149
|
+
if (this._enableOneCellCache) {
|
|
27150
|
+
if (startRow === endRow && startColumn === endColumn) this._removeOneCellCache(unitId, subUnitId, range.startRow, range.startColumn, id);
|
|
27151
|
+
else {
|
|
27152
|
+
this._removeCellCacheByRange(search);
|
|
27153
|
+
this._removeRTreeItem(search);
|
|
27154
|
+
}
|
|
27155
|
+
} else this._removeRTreeItem(search);
|
|
26580
27156
|
}
|
|
26581
27157
|
bulkRemove(searchList) {
|
|
26582
27158
|
for (const search of searchList) this.remove(search);
|
|
@@ -26686,11 +27262,15 @@ function cloneCellData(cell) {
|
|
|
26686
27262
|
if (cell === null || cell === void 0) return cell;
|
|
26687
27263
|
const result = {};
|
|
26688
27264
|
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
26689
|
-
if (cell.s !== void 0)
|
|
26690
|
-
|
|
27265
|
+
if (cell.s !== void 0) {
|
|
27266
|
+
if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
27267
|
+
else result.s = cloneValue(cell.s);
|
|
27268
|
+
}
|
|
26691
27269
|
if (cell.v !== void 0) result.v = cell.v;
|
|
26692
27270
|
if (cell.t !== void 0) result.t = cell.t;
|
|
26693
27271
|
if (cell.f !== void 0) result.f = cell.f;
|
|
27272
|
+
if (cell.ft !== void 0) result.ft = cell.ft;
|
|
27273
|
+
if (cell.fd !== void 0) result.fd = cell.fd;
|
|
26694
27274
|
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
26695
27275
|
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
26696
27276
|
if (cell.si !== void 0) result.si = cell.si;
|
|
@@ -26705,17 +27285,7 @@ function cloneCellData(cell) {
|
|
|
26705
27285
|
*/
|
|
26706
27286
|
function cloneCellDataWithSpanAndDisplay(cell) {
|
|
26707
27287
|
if (cell === null || cell === void 0) return cell;
|
|
26708
|
-
const result =
|
|
26709
|
-
if (cell.p !== void 0) result.p = cell.p === null ? null : cloneValue(cell.p);
|
|
26710
|
-
if (cell.s !== void 0) if (cell.s === null || typeof cell.s === "string") result.s = cell.s;
|
|
26711
|
-
else result.s = cloneValue(cell.s);
|
|
26712
|
-
if (cell.v !== void 0) result.v = cell.v;
|
|
26713
|
-
if (cell.t !== void 0) result.t = cell.t;
|
|
26714
|
-
if (cell.f !== void 0) result.f = cell.f;
|
|
26715
|
-
if (cell.ref !== void 0) result.ref = cell.ref;
|
|
26716
|
-
if (cell.xf !== void 0) result.xf = cell.xf;
|
|
26717
|
-
if (cell.si !== void 0) result.si = cell.si;
|
|
26718
|
-
if (cell.custom !== void 0) result.custom = cell.custom === null ? null : cloneValue(cell.custom);
|
|
27288
|
+
const result = cloneCellData(cell);
|
|
26719
27289
|
if (cell.rowSpan !== void 0) result.rowSpan = cell.rowSpan;
|
|
26720
27290
|
if (cell.colSpan !== void 0) result.colSpan = cell.colSpan;
|
|
26721
27291
|
if (cell.displayV !== void 0) result.displayV = cell.displayV;
|
|
@@ -26765,8 +27335,10 @@ function cloneRowColumnData(data) {
|
|
|
26765
27335
|
if ("ah" in item && item.ah !== void 0) cloned.ah = item.ah;
|
|
26766
27336
|
if ("hd" in item && item.hd !== void 0) cloned.hd = item.hd;
|
|
26767
27337
|
if ("w" in item && item.w !== void 0) cloned.w = item.w;
|
|
26768
|
-
if ("s" in item && item.s !== void 0)
|
|
26769
|
-
|
|
27338
|
+
if ("s" in item && item.s !== void 0) {
|
|
27339
|
+
if (item.s === null || typeof item.s === "string") cloned.s = item.s;
|
|
27340
|
+
else cloned.s = cloneValue(item.s);
|
|
27341
|
+
}
|
|
26770
27342
|
if ("custom" in item && item.custom !== void 0) cloned.custom = item.custom === null ? null : cloneValue(item.custom);
|
|
26771
27343
|
result[idx] = cloned;
|
|
26772
27344
|
}
|
|
@@ -26820,6 +27392,12 @@ function cloneWorksheetData(worksheet) {
|
|
|
26820
27392
|
defaultRowHeight: worksheet.defaultRowHeight,
|
|
26821
27393
|
showGridlines: worksheet.showGridlines,
|
|
26822
27394
|
rightToLeft: worksheet.rightToLeft,
|
|
27395
|
+
backgroundImage: worksheet.backgroundImage ? {
|
|
27396
|
+
source: worksheet.backgroundImage.source,
|
|
27397
|
+
imageSourceType: worksheet.backgroundImage.imageSourceType,
|
|
27398
|
+
scaleX: worksheet.backgroundImage.scaleX,
|
|
27399
|
+
scaleY: worksheet.backgroundImage.scaleY
|
|
27400
|
+
} : void 0,
|
|
26823
27401
|
freeze: {
|
|
26824
27402
|
xSplit: worksheet.freeze.xSplit,
|
|
26825
27403
|
ySplit: worksheet.freeze.ySplit,
|
|
@@ -26840,8 +27418,10 @@ function cloneWorksheetData(worksheet) {
|
|
|
26840
27418
|
columnData: cloneRowColumnData(worksheet.columnData)
|
|
26841
27419
|
};
|
|
26842
27420
|
if (worksheet.gridlinesColor !== void 0) result.gridlinesColor = worksheet.gridlinesColor;
|
|
26843
|
-
if (worksheet.defaultStyle !== void 0)
|
|
26844
|
-
|
|
27421
|
+
if (worksheet.defaultStyle !== void 0) {
|
|
27422
|
+
if (worksheet.defaultStyle === null || typeof worksheet.defaultStyle === "string") result.defaultStyle = worksheet.defaultStyle;
|
|
27423
|
+
else result.defaultStyle = cloneValue(worksheet.defaultStyle);
|
|
27424
|
+
}
|
|
26845
27425
|
if (worksheet.custom !== void 0) result.custom = worksheet.custom === null ? null : cloneValue(worksheet.custom);
|
|
26846
27426
|
return result;
|
|
26847
27427
|
}
|
|
@@ -27040,7 +27620,8 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
27040
27620
|
}
|
|
27041
27621
|
_fillDefaultGapThemeColors(config) {
|
|
27042
27622
|
if (config.defaultBackgroundColor && config.defaultStripeColor) return config;
|
|
27043
|
-
const
|
|
27623
|
+
const baseColor = this._injector.get(ThemeService).getColorFromTheme("primary.500");
|
|
27624
|
+
const { r, g, b } = new ColorKit(baseColor).toRgb();
|
|
27044
27625
|
return {
|
|
27045
27626
|
...config,
|
|
27046
27627
|
defaultBackgroundColor: config.defaultBackgroundColor ?? `rgba(${r}, ${g}, ${b}, 0.025)`,
|
|
@@ -27169,7 +27750,8 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
27169
27750
|
const columnCount = this._columnWidthAccumulation.length - 1;
|
|
27170
27751
|
for (let i = startColumn; i >= endColumn; i--) {
|
|
27171
27752
|
const column = i;
|
|
27172
|
-
|
|
27753
|
+
const cell = this.worksheet.getCell(row, column);
|
|
27754
|
+
if (!isCellCoverable(cell) && column !== startColumn || this.intersectMergeRange(row, column)) {
|
|
27173
27755
|
if (column === startColumn) return column;
|
|
27174
27756
|
return column + 1 > columnCount ? columnCount : column + 1;
|
|
27175
27757
|
}
|
|
@@ -27182,7 +27764,8 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
27182
27764
|
}
|
|
27183
27765
|
for (let i = startColumn; i <= endColumn; i++) {
|
|
27184
27766
|
const column = i;
|
|
27185
|
-
|
|
27767
|
+
const cell = this.worksheet.getCell(row, column);
|
|
27768
|
+
if (!isCellCoverable(cell) && column !== startColumn || this.intersectMergeRange(row, column)) {
|
|
27186
27769
|
if (column === startColumn) return column;
|
|
27187
27770
|
return column - 1 < 0 ? 0 : column - 1;
|
|
27188
27771
|
}
|
|
@@ -27858,6 +28441,41 @@ let DataValidationType = /* @__PURE__ */ function(DataValidationType) {
|
|
|
27858
28441
|
return DataValidationType;
|
|
27859
28442
|
}({});
|
|
27860
28443
|
|
|
28444
|
+
//#endregion
|
|
28445
|
+
//#region src/types/enum/record-filter.ts
|
|
28446
|
+
/**
|
|
28447
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
28448
|
+
*
|
|
28449
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
28450
|
+
* you may not use this file except in compliance with the License.
|
|
28451
|
+
* You may obtain a copy of the License at
|
|
28452
|
+
*
|
|
28453
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28454
|
+
*
|
|
28455
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28456
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28457
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28458
|
+
* See the License for the specific language governing permissions and
|
|
28459
|
+
* limitations under the License.
|
|
28460
|
+
*/
|
|
28461
|
+
/** Typed record identities shared by compact Table and external report filters. */
|
|
28462
|
+
let RecordValueType = /* @__PURE__ */ function(RecordValueType) {
|
|
28463
|
+
RecordValueType["Blank"] = "blank";
|
|
28464
|
+
RecordValueType["String"] = "string";
|
|
28465
|
+
RecordValueType["Number"] = "number";
|
|
28466
|
+
RecordValueType["Date"] = "date";
|
|
28467
|
+
RecordValueType["Boolean"] = "boolean";
|
|
28468
|
+
RecordValueType["Error"] = "error";
|
|
28469
|
+
return RecordValueType;
|
|
28470
|
+
}({});
|
|
28471
|
+
/** Values are wire identifiers; an absent native Table filter represents All. */
|
|
28472
|
+
let FilterSelectionMode = /* @__PURE__ */ function(FilterSelectionMode) {
|
|
28473
|
+
FilterSelectionMode["All"] = "all";
|
|
28474
|
+
FilterSelectionMode["Include"] = "include";
|
|
28475
|
+
FilterSelectionMode["Exclude"] = "exclude";
|
|
28476
|
+
return FilterSelectionMode;
|
|
28477
|
+
}({});
|
|
28478
|
+
|
|
27861
28479
|
//#endregion
|
|
27862
28480
|
//#region src/services/resource-loader/resource-loader.service.ts
|
|
27863
28481
|
let ResourceLoaderService = class ResourceLoaderService extends Disposable {
|
|
@@ -27902,11 +28520,9 @@ let ResourceLoaderService = class ResourceLoaderService extends Disposable {
|
|
|
27902
28520
|
loadHookResource(hook, workbook.getUnitId(), workbook.getSnapshot().resources, "Workbook");
|
|
27903
28521
|
});
|
|
27904
28522
|
break;
|
|
27905
|
-
case _univerjs_protocol.UniverType.UNIVER_BASE:
|
|
27906
|
-
|
|
27907
|
-
|
|
27908
|
-
});
|
|
27909
|
-
break;
|
|
28523
|
+
case _univerjs_protocol.UniverType.UNIVER_BASE: this._univerInstanceService.getAllUnitsForType(_univerjs_protocol.UniverType.UNIVER_BASE).forEach((base) => {
|
|
28524
|
+
loadHookResource(hook, base.getUnitId(), base.getSnapshot().resources, "Base");
|
|
28525
|
+
});
|
|
27910
28526
|
}
|
|
27911
28527
|
});
|
|
27912
28528
|
};
|
|
@@ -27918,7 +28534,8 @@ let ResourceLoaderService = class ResourceLoaderService extends Disposable {
|
|
|
27918
28534
|
}));
|
|
27919
28535
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_protocol.UniverType.UNIVER_DOC).subscribe((event) => {
|
|
27920
28536
|
const { unit: doc } = event;
|
|
27921
|
-
|
|
28537
|
+
const unitId = doc.getUnitId();
|
|
28538
|
+
if (!isInternalEditorID(unitId)) this._resourceManagerService.loadResources(doc.getUnitId(), doc.getSnapshot().resources);
|
|
27922
28539
|
}));
|
|
27923
28540
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_protocol.UniverType.UNIVER_SLIDE).subscribe((event) => {
|
|
27924
28541
|
const { unit: slide } = event;
|
|
@@ -28292,10 +28909,12 @@ exports.FOCUSING_UNIT = FOCUSING_UNIT;
|
|
|
28292
28909
|
exports.FOCUSING_UNIVER_EDITOR = FOCUSING_UNIVER_EDITOR;
|
|
28293
28910
|
exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE = FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE;
|
|
28294
28911
|
exports.FORMULA_EDITOR_ACTIVATED = FORMULA_EDITOR_ACTIVATED;
|
|
28912
|
+
exports.FilterSelectionMode = FilterSelectionMode;
|
|
28295
28913
|
exports.FollowNumberWithType = FollowNumberWithType;
|
|
28296
28914
|
exports.FontItalic = FontItalic;
|
|
28297
28915
|
exports.FontStyleType = FontStyleType;
|
|
28298
28916
|
exports.FontWeight = FontWeight;
|
|
28917
|
+
exports.FormulaType = FormulaType;
|
|
28299
28918
|
exports.GridType = GridType;
|
|
28300
28919
|
exports.HorizontalAlign = HorizontalAlign;
|
|
28301
28920
|
exports.IAuthzIoService = IAuthzIoService;
|
|
@@ -28455,6 +29074,7 @@ exports.RGB_PAREN = RGB_PAREN;
|
|
|
28455
29074
|
exports.ROTATE_BUFFER_VALUE = ROTATE_BUFFER_VALUE;
|
|
28456
29075
|
exports.RTree = RTree;
|
|
28457
29076
|
exports.Range = Range;
|
|
29077
|
+
exports.RecordValueType = RecordValueType;
|
|
28458
29078
|
exports.Rectangle = Rectangle;
|
|
28459
29079
|
Object.defineProperty(exports, 'RediError', {
|
|
28460
29080
|
enumerable: true,
|
|
@@ -28570,6 +29190,7 @@ Object.defineProperty(exports, 'Workbook', {
|
|
|
28570
29190
|
}
|
|
28571
29191
|
});
|
|
28572
29192
|
exports.Worksheet = Worksheet;
|
|
29193
|
+
exports.WorksheetHiddenState = WorksheetHiddenState;
|
|
28573
29194
|
exports.WrapStrategy = WrapStrategy;
|
|
28574
29195
|
exports.WrapTextType = WrapTextType;
|
|
28575
29196
|
exports.addLinkToDocumentModel = addLinkToDocumentModel;
|
|
@@ -28703,6 +29324,8 @@ exports.getParagraphsSlice = getParagraphsSlice;
|
|
|
28703
29324
|
exports.getPlainText = getPlainText;
|
|
28704
29325
|
exports.getReverseDirection = getReverseDirection;
|
|
28705
29326
|
exports.getRichTextEditPath = getRichTextEditPath;
|
|
29327
|
+
exports.getSdtBindingKey = getSdtBindingKey;
|
|
29328
|
+
exports.getSdtBindingValue = getSdtBindingValue;
|
|
28706
29329
|
exports.getSectionBreakSlice = getSectionBreakSlice;
|
|
28707
29330
|
exports.getSectionHeaderFooterReferenceKey = getSectionHeaderFooterReferenceKey;
|
|
28708
29331
|
exports.getSheetsEmptySnapshot = getEmptySnapshot$2;
|