@univerjs/core 1.5.2 → 1.6.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 +6 -6
- package/lib/cjs/index.js +1170 -778
- package/lib/es/facade.js +6 -6
- package/lib/es/index.js +1165 -779
- package/lib/facade.js +6 -6
- package/lib/index.js +1165 -779
- package/lib/types/docs/data-model/document-data-model.d.ts +1 -1
- package/lib/types/docs/data-model/index.d.ts +0 -2
- package/lib/types/docs/data-model/paragraph-style.d.ts +10 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +3 -3
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +2 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/services/instance/instance.service.d.ts +2 -0
- package/lib/types/services/locale/currency-symbol.d.ts +17 -0
- package/lib/types/services/undoredo/undoredo.service.d.ts +1 -1
- package/lib/types/shared/common.d.ts +8 -5
- package/lib/types/sheets/typedef.d.ts +4 -0
- package/lib/types/sheets/worksheet.d.ts +2 -2
- package/lib/types/types/interfaces/i-document-data.d.ts +137 -9
- package/lib/umd/index.js +26 -26
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -150,7 +150,7 @@ function installShims() {
|
|
|
150
150
|
installStringAt();
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
// \0@oxc-project+runtime@0.
|
|
153
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
|
|
154
154
|
function _typeof(o) {
|
|
155
155
|
"@babel/helpers - typeof";
|
|
156
156
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -160,7 +160,7 @@ function _typeof(o) {
|
|
|
160
160
|
}, _typeof(o);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
// \0@oxc-project+runtime@0.
|
|
163
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
|
|
164
164
|
function toPrimitive(t, e) {
|
|
165
165
|
if ("object" != _typeof(t) || !t) return t;
|
|
166
166
|
var r;
|
|
@@ -172,13 +172,13 @@ function toPrimitive(t, e) {
|
|
|
172
172
|
return ("string" === e ? String : Number)(t);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
// \0@oxc-project+runtime@0.
|
|
175
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
|
|
176
176
|
function toPropertyKey(t) {
|
|
177
177
|
var i = toPrimitive(t, "string");
|
|
178
178
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
// \0@oxc-project+runtime@0.
|
|
181
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
|
|
182
182
|
function _defineProperty(e, r, t) {
|
|
183
183
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
184
184
|
value: t,
|
|
@@ -1672,7 +1672,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1672
1672
|
|
|
1673
1673
|
// package.json
|
|
1674
1674
|
var name = "@univerjs/core";
|
|
1675
|
-
var version = "1.
|
|
1675
|
+
var version = "1.6.0";
|
|
1676
1676
|
|
|
1677
1677
|
// src/common/array.ts
|
|
1678
1678
|
/**
|
|
@@ -2010,14 +2010,14 @@ function hashLogContent(...args) {
|
|
|
2010
2010
|
return args.map((a) => JSON.stringify(a)).join("");
|
|
2011
2011
|
}
|
|
2012
2012
|
|
|
2013
|
-
// \0@oxc-project+runtime@0.
|
|
2013
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
|
|
2014
2014
|
function __decorateParam(paramIndex, decorator) {
|
|
2015
2015
|
return function(target, key) {
|
|
2016
2016
|
decorator(target, key, paramIndex);
|
|
2017
2017
|
};
|
|
2018
2018
|
}
|
|
2019
2019
|
|
|
2020
|
-
// \0@oxc-project+runtime@0.
|
|
2020
|
+
// \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
|
|
2021
2021
|
function __decorate(decorators, target, key, desc) {
|
|
2022
2022
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2023
2023
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2606,7 +2606,7 @@ const COLORS = {
|
|
|
2606
2606
|
0,
|
|
2607
2607
|
0
|
|
2608
2608
|
],
|
|
2609
|
-
|
|
2609
|
+
blanchedalmond: [
|
|
2610
2610
|
255,
|
|
2611
2611
|
235,
|
|
2612
2612
|
205
|
|
@@ -2683,7 +2683,7 @@ const COLORS = {
|
|
|
2683
2683
|
],
|
|
2684
2684
|
darkgoldenrod: [
|
|
2685
2685
|
184,
|
|
2686
|
-
|
|
2686
|
+
134,
|
|
2687
2687
|
11
|
|
2688
2688
|
],
|
|
2689
2689
|
darkgray: [
|
|
@@ -2803,7 +2803,7 @@ const COLORS = {
|
|
|
2803
2803
|
],
|
|
2804
2804
|
floralwhite: [
|
|
2805
2805
|
255,
|
|
2806
|
-
|
|
2806
|
+
250,
|
|
2807
2807
|
240
|
|
2808
2808
|
],
|
|
2809
2809
|
forestgreen: [
|
|
@@ -3051,7 +3051,7 @@ const COLORS = {
|
|
|
3051
3051
|
21,
|
|
3052
3052
|
133
|
|
3053
3053
|
],
|
|
3054
|
-
|
|
3054
|
+
midnightblue: [
|
|
3055
3055
|
25,
|
|
3056
3056
|
25,
|
|
3057
3057
|
112
|
|
@@ -3154,7 +3154,7 @@ const COLORS = {
|
|
|
3154
3154
|
plum: [
|
|
3155
3155
|
221,
|
|
3156
3156
|
160,
|
|
3157
|
-
|
|
3157
|
+
221
|
|
3158
3158
|
],
|
|
3159
3159
|
powderblue: [
|
|
3160
3160
|
176,
|
|
@@ -3232,18 +3232,18 @@ const COLORS = {
|
|
|
3232
3232
|
205
|
|
3233
3233
|
],
|
|
3234
3234
|
slategray: [
|
|
3235
|
-
|
|
3235
|
+
112,
|
|
3236
3236
|
128,
|
|
3237
3237
|
144
|
|
3238
3238
|
],
|
|
3239
3239
|
slategrey: [
|
|
3240
|
-
|
|
3240
|
+
112,
|
|
3241
3241
|
128,
|
|
3242
3242
|
144
|
|
3243
3243
|
],
|
|
3244
3244
|
snow: [
|
|
3245
3245
|
255,
|
|
3246
|
-
|
|
3246
|
+
250,
|
|
3247
3247
|
250
|
|
3248
3248
|
],
|
|
3249
3249
|
springgreen: [
|
|
@@ -3315,7 +3315,7 @@ const COLORS = {
|
|
|
3315
3315
|
yellowgreen: [
|
|
3316
3316
|
154,
|
|
3317
3317
|
205,
|
|
3318
|
-
|
|
3318
|
+
50
|
|
3319
3319
|
]
|
|
3320
3320
|
};
|
|
3321
3321
|
var ColorKit = class ColorKit {
|
|
@@ -3496,7 +3496,7 @@ const toColor = (color) => {
|
|
|
3496
3496
|
g: Math.round(colorArray[1]),
|
|
3497
3497
|
b: Math.round(colorArray[2])
|
|
3498
3498
|
};
|
|
3499
|
-
rgb.a = colorArray[3]
|
|
3499
|
+
rgb.a = colorArray[3] ?? 1;
|
|
3500
3500
|
return rgb;
|
|
3501
3501
|
}
|
|
3502
3502
|
if (parsedColor.startsWith("#")) return hexToColor(parsedColor);
|
|
@@ -5962,7 +5962,7 @@ function runPart(value, part, options, locale, decimalValue = null) {
|
|
|
5962
5962
|
haveFraction = fixedSlash;
|
|
5963
5963
|
}
|
|
5964
5964
|
} else {
|
|
5965
|
-
const fractionParts = dec2frac(decimal,
|
|
5965
|
+
const fractionParts = dec2frac(decimal, 1e400, section.den_max);
|
|
5966
5966
|
numerator += fractionParts[0];
|
|
5967
5967
|
denominator += fractionParts[1];
|
|
5968
5968
|
if (section.integer && numerator === "0") {
|
|
@@ -7059,6 +7059,7 @@ function parseNumber(value, options = {}) {
|
|
|
7059
7059
|
let sign = 1;
|
|
7060
7060
|
let format = "";
|
|
7061
7061
|
let minus = false;
|
|
7062
|
+
let plus = false;
|
|
7062
7063
|
let openParen = false;
|
|
7063
7064
|
let closeParen = false;
|
|
7064
7065
|
let percent = false;
|
|
@@ -7085,8 +7086,11 @@ function parseNumber(value, options = {}) {
|
|
|
7085
7086
|
if (currency) return null;
|
|
7086
7087
|
currency = true;
|
|
7087
7088
|
currencySymbol = char;
|
|
7089
|
+
} else if (char === "+") {
|
|
7090
|
+
if (openParen) return null;
|
|
7091
|
+
plus = true;
|
|
7088
7092
|
} else if (char === "(") {
|
|
7089
|
-
if (openParen || minus) return null;
|
|
7093
|
+
if (openParen || minus || plus) return null;
|
|
7090
7094
|
openParen = true;
|
|
7091
7095
|
sign = -1;
|
|
7092
7096
|
} else if (char === "%") {
|
|
@@ -7147,6 +7151,7 @@ function parseNumber(value, options = {}) {
|
|
|
7147
7151
|
index++;
|
|
7148
7152
|
}
|
|
7149
7153
|
if (index !== value.length) return null;
|
|
7154
|
+
if (openParen && !closeParen) return null;
|
|
7150
7155
|
let numberValue = Number.parseFloat(number + exponent);
|
|
7151
7156
|
if (!Number.isFinite(numberValue)) return null;
|
|
7152
7157
|
if (exponent) {
|
|
@@ -7994,7 +7999,11 @@ const getNumfmtParseValueFilter = (value, options = {}) => {
|
|
|
7994
7999
|
*/
|
|
7995
8000
|
if (z.includes("#,##0")) {
|
|
7996
8001
|
if (/[.,]$/.test(value)) return null;
|
|
7997
|
-
const
|
|
8002
|
+
const unwrapParens = (input) => {
|
|
8003
|
+
const trimmed = input.trim();
|
|
8004
|
+
return trimmed.startsWith("(") && trimmed.endsWith(")") ? trimmed.slice(1, -1).trim() : trimmed;
|
|
8005
|
+
};
|
|
8006
|
+
const normalized = unwrapParens(unwrapParens(value).replace(CURRENCY_SYMBOL_PREFIX_REG, "").trim());
|
|
7998
8007
|
if (normalized.includes(",")) {
|
|
7999
8008
|
if (!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(normalized)) return null;
|
|
8000
8009
|
}
|
|
@@ -8354,7 +8363,7 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8354
8363
|
const rowLength = rows.length;
|
|
8355
8364
|
const startRow = rowLength > 0 ? Number(rows[0]) : 0;
|
|
8356
8365
|
const endRow = rowLength > 0 ? Number(rows[rowLength - 1]) : 0;
|
|
8357
|
-
let startColumn = -
|
|
8366
|
+
let startColumn = -1e400;
|
|
8358
8367
|
let endColumn = 0;
|
|
8359
8368
|
for (const rowKey of rows) {
|
|
8360
8369
|
const row = this.getRow(Number(rowKey));
|
|
@@ -8363,12 +8372,12 @@ var ObjectMatrix = class ObjectMatrix {
|
|
|
8363
8372
|
if (columns.length > 0) {
|
|
8364
8373
|
const rowStartColumn = Number(columns[0]);
|
|
8365
8374
|
const rowEndColumn = Number(columns[columns.length - 1]);
|
|
8366
|
-
if (startColumn === -
|
|
8375
|
+
if (startColumn === -1e400 || rowStartColumn < startColumn) startColumn = rowStartColumn;
|
|
8367
8376
|
if (rowEndColumn > endColumn) endColumn = rowEndColumn;
|
|
8368
8377
|
}
|
|
8369
8378
|
}
|
|
8370
8379
|
}
|
|
8371
|
-
if (startColumn === -
|
|
8380
|
+
if (startColumn === -1e400) startColumn = 0;
|
|
8372
8381
|
return {
|
|
8373
8382
|
startRow,
|
|
8374
8383
|
endRow,
|
|
@@ -8644,6 +8653,7 @@ function isFormulaId(value) {
|
|
|
8644
8653
|
* @param style
|
|
8645
8654
|
* @returns
|
|
8646
8655
|
*/
|
|
8656
|
+
const TEXT_DECORATION_LINE_REGEX = /(text-decoration(?:-line)?:\s*[^;]+)(?=;)/;
|
|
8647
8657
|
function handleStyleToString(style, isCell = false) {
|
|
8648
8658
|
let str = "";
|
|
8649
8659
|
const styleMap = /* @__PURE__ */ new Map([
|
|
@@ -8666,7 +8676,7 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8666
8676
|
["ul", () => {
|
|
8667
8677
|
var _style$ul;
|
|
8668
8678
|
if ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) {
|
|
8669
|
-
if (
|
|
8679
|
+
if (TEXT_DECORATION_LINE_REGEX.test(str)) str = str.replace(TEXT_DECORATION_LINE_REGEX, (_, p1) => `${p1} underline`);
|
|
8670
8680
|
else str += "text-decoration: underline; ";
|
|
8671
8681
|
if (style.ul.cl && str.indexOf("text-decoration-color") === -1) str += `text-decoration-color: ${getColorStyle(style.ul.cl)}; `;
|
|
8672
8682
|
if (style.ul.t && str.indexOf("text-decoration-style") === -1) str += `text-decoration-style: ${style.ul.t} `;
|
|
@@ -8675,7 +8685,7 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8675
8685
|
["st", () => {
|
|
8676
8686
|
var _style$st;
|
|
8677
8687
|
if ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) {
|
|
8678
|
-
if (
|
|
8688
|
+
if (TEXT_DECORATION_LINE_REGEX.test(str)) str = str.replace(TEXT_DECORATION_LINE_REGEX, (_, p1) => `${p1} line-through`);
|
|
8679
8689
|
else str += "text-decoration-line: line-through; ";
|
|
8680
8690
|
if (style.st.cl && str.indexOf("text-decoration-color") === -1) str += `text-decoration-color: ${getColorStyle(style.st.cl)}; `;
|
|
8681
8691
|
if (style.st.t && str.indexOf("text-decoration-style") === -1) str += `text-decoration-style: ${style.st.t} `;
|
|
@@ -8684,7 +8694,7 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8684
8694
|
["ol", () => {
|
|
8685
8695
|
var _style$ol;
|
|
8686
8696
|
if ((_style$ol = style.ol) === null || _style$ol === void 0 ? void 0 : _style$ol.s) {
|
|
8687
|
-
if (
|
|
8697
|
+
if (TEXT_DECORATION_LINE_REGEX.test(str)) str = str.replace(TEXT_DECORATION_LINE_REGEX, (_, p1) => `${p1} overline`);
|
|
8688
8698
|
else str += "text-decoration-line: overline; ";
|
|
8689
8699
|
if (style.ol.cl && str.indexOf("text-decoration-color") === -1) str += `text-decoration-color: ${getColorStyle(style.ol.cl)}; `;
|
|
8690
8700
|
if (style.ol.t && str.indexOf("text-decoration-style") === -1) str += `text-decoration-style: ${style.ol.t} `;
|
|
@@ -8768,6 +8778,28 @@ function handleStyleToString(style, isCell = false) {
|
|
|
8768
8778
|
}
|
|
8769
8779
|
return str;
|
|
8770
8780
|
}
|
|
8781
|
+
/**
|
|
8782
|
+
* Mark every line a `text-decoration` value names on a style object.
|
|
8783
|
+
*
|
|
8784
|
+
* A single `text-decoration` can name several lines at once, e.g. `underline line-through`,
|
|
8785
|
+
* so every line has to be read instead of only the first one. Existing data of a line, such
|
|
8786
|
+
* as its color or line style, is kept.
|
|
8787
|
+
*/
|
|
8788
|
+
function setTextDecorationLines(style, value) {
|
|
8789
|
+
const lines = value.split(/\s+/);
|
|
8790
|
+
if (lines.includes("underline")) style.ul = {
|
|
8791
|
+
...style.ul,
|
|
8792
|
+
s: 1
|
|
8793
|
+
};
|
|
8794
|
+
if (lines.includes("line-through")) style.st = {
|
|
8795
|
+
...style.st,
|
|
8796
|
+
s: 1
|
|
8797
|
+
};
|
|
8798
|
+
if (lines.includes("overline")) style.ol = {
|
|
8799
|
+
...style.ol,
|
|
8800
|
+
s: 1
|
|
8801
|
+
};
|
|
8802
|
+
}
|
|
8771
8803
|
function getBorderStyle(type) {
|
|
8772
8804
|
let str = "";
|
|
8773
8805
|
if (type === 0) str = "none";
|
|
@@ -10510,13 +10542,13 @@ function getIntersectRange(src, target) {
|
|
|
10510
10542
|
* @returns A tuple containing the start and end of the overlap, or null if there is no overlap.
|
|
10511
10543
|
*/
|
|
10512
10544
|
function getOverlap1D(start1, end1, start2, end2) {
|
|
10513
|
-
const s1 = Number.isNaN(start1) ? -
|
|
10514
|
-
const e1 = Number.isNaN(end1) ?
|
|
10515
|
-
const s2 = Number.isNaN(start2) ? -
|
|
10516
|
-
const e2 = Number.isNaN(end2) ?
|
|
10545
|
+
const s1 = Number.isNaN(start1) ? -1e400 : start1;
|
|
10546
|
+
const e1 = Number.isNaN(end1) ? 1e400 : end1;
|
|
10547
|
+
const s2 = Number.isNaN(start2) ? -1e400 : start2;
|
|
10548
|
+
const e2 = Number.isNaN(end2) ? 1e400 : end2;
|
|
10517
10549
|
const start = Math.max(s1, s2);
|
|
10518
10550
|
const end = Math.min(e1, e2);
|
|
10519
|
-
if (start <= end) return [start === -
|
|
10551
|
+
if (start <= end) return [start === -1e400 ? NaN : start, end === 1e400 ? NaN : end];
|
|
10520
10552
|
else return null;
|
|
10521
10553
|
}
|
|
10522
10554
|
/**
|
|
@@ -12279,7 +12311,7 @@ function cloneSectionBreakWithId(sectionBreak, existingIds, preserveId = true) {
|
|
|
12279
12311
|
return cloned;
|
|
12280
12312
|
}
|
|
12281
12313
|
function isValidSectionId(value) {
|
|
12282
|
-
return typeof value === "string" && value.
|
|
12314
|
+
return typeof value === "string" && value.length > 0;
|
|
12283
12315
|
}
|
|
12284
12316
|
|
|
12285
12317
|
// src/docs/data-model/types.ts
|
|
@@ -12558,6 +12590,13 @@ let BulletAlignment = /* @__PURE__ */ function(BulletAlignment) {
|
|
|
12558
12590
|
BulletAlignment[BulletAlignment["BOTH"] = 4] = "BOTH";
|
|
12559
12591
|
return BulletAlignment;
|
|
12560
12592
|
}({});
|
|
12593
|
+
let SpecialCharacterKind = /* @__PURE__ */ function(SpecialCharacterKind) {
|
|
12594
|
+
SpecialCharacterKind["NON_BREAKING_HYPHEN"] = "nonBreakingHyphen";
|
|
12595
|
+
SpecialCharacterKind["OPTIONAL_HYPHEN"] = "optionalHyphen";
|
|
12596
|
+
SpecialCharacterKind["EM_SPACE"] = "emSpace";
|
|
12597
|
+
SpecialCharacterKind["EN_SPACE"] = "enSpace";
|
|
12598
|
+
return SpecialCharacterKind;
|
|
12599
|
+
}({});
|
|
12561
12600
|
let DocumentBlockRangeType = /* @__PURE__ */ function(DocumentBlockRangeType) {
|
|
12562
12601
|
DocumentBlockRangeType["CALLOUT"] = "callout";
|
|
12563
12602
|
DocumentBlockRangeType["QUOTE"] = "quote";
|
|
@@ -13553,8 +13592,9 @@ function normalizeTextRuns(textRuns, reserveEmptyTextRun = false) {
|
|
|
13553
13592
|
* @param currentIndex Determining the index where the content will be inserted into the current content.
|
|
13554
13593
|
*/
|
|
13555
13594
|
function insertTextRuns(body, insertBody, textLength, currentIndex) {
|
|
13556
|
-
|
|
13557
|
-
|
|
13595
|
+
var _insertBody$textRuns;
|
|
13596
|
+
const textRuns = body.textRuns ?? [];
|
|
13597
|
+
if (body.textRuns == null && !((_insertBody$textRuns = insertBody.textRuns) === null || _insertBody$textRuns === void 0 ? void 0 : _insertBody$textRuns.some((run) => run.sId || Object.keys(run.ts ?? {}).length))) return;
|
|
13558
13598
|
const newTextRuns = [];
|
|
13559
13599
|
const len = textRuns.length;
|
|
13560
13600
|
let hasInserted = false;
|
|
@@ -13640,7 +13680,7 @@ function insertParagraphs(body, insertBody, textLength, currentIndex, isUpdate =
|
|
|
13640
13680
|
}
|
|
13641
13681
|
}
|
|
13642
13682
|
function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs, currentIndex, options) {
|
|
13643
|
-
if (!paragraphs || !(insertParagraphs === null || insertParagraphs === void 0 ? void 0 : insertParagraphs.length)) return;
|
|
13683
|
+
if (!paragraphs || !(insertParagraphs === null || insertParagraphs === void 0 ? void 0 : insertParagraphs.length)) return false;
|
|
13644
13684
|
const splitParagraph = getParagraphSplitByInsert(paragraphs, currentIndex, options.dataStream);
|
|
13645
13685
|
const firstSplitInsertIndex = splitParagraph ? getFirstInsertedParagraphIndex(insertParagraphs) : -1;
|
|
13646
13686
|
const splitParagraphId = splitParagraph === null || splitParagraph === void 0 ? void 0 : splitParagraph.paragraphId;
|
|
@@ -13676,6 +13716,7 @@ function normalizeInsertedParagraphIdsForDocument(paragraphs, insertParagraphs,
|
|
|
13676
13716
|
var _options$reservedPara;
|
|
13677
13717
|
(_options$reservedPara = options.reservedParagraphIds) === null || _options$reservedPara === void 0 || _options$reservedPara.add(insertParagraph.paragraphId);
|
|
13678
13718
|
}
|
|
13719
|
+
return splitParagraph != null;
|
|
13679
13720
|
}
|
|
13680
13721
|
function collectParagraphIds(paragraphs) {
|
|
13681
13722
|
const paragraphIds = /* @__PURE__ */ new Set();
|
|
@@ -13914,7 +13955,10 @@ function mergeContinuousRanges(ranges) {
|
|
|
13914
13955
|
return mergedRanges;
|
|
13915
13956
|
}
|
|
13916
13957
|
function splitCustomRangesByIndex(customRanges, currentIndex) {
|
|
13917
|
-
const matches = customRanges.filter((range) =>
|
|
13958
|
+
const matches = customRanges.filter((range) => {
|
|
13959
|
+
var _range$properties;
|
|
13960
|
+
return range.rangeType !== 1 && range.rangeType !== 2 && range.rangeType !== 3 && !(range.rangeType === 5 && ((_range$properties = range.properties) === null || _range$properties === void 0 ? void 0 : _range$properties.kind) === "docx-permission") && range.startIndex < currentIndex && range.endIndex >= currentIndex;
|
|
13961
|
+
});
|
|
13918
13962
|
for (const matched of matches) {
|
|
13919
13963
|
const index = customRanges.indexOf(matched);
|
|
13920
13964
|
customRanges.splice(index, 1, {
|
|
@@ -13965,9 +14009,10 @@ function insertCustomRanges(body, insertBody, textLength, currentIndex) {
|
|
|
13965
14009
|
const { customRanges } = body;
|
|
13966
14010
|
splitCustomRangesByIndex(customRanges, currentIndex);
|
|
13967
14011
|
for (let i = 0, len = customRanges.length; i < len; i++) {
|
|
14012
|
+
var _customRange$properti;
|
|
13968
14013
|
const customRange = customRanges[i];
|
|
13969
14014
|
const { startIndex } = customRange;
|
|
13970
|
-
if ((customRange.rangeType === 1 || customRange.rangeType === 2 || customRange.rangeType === 3) && startIndex < currentIndex && customRange.endIndex >= currentIndex) {
|
|
14015
|
+
if ((customRange.rangeType === 1 || customRange.rangeType === 2 || customRange.rangeType === 3 || customRange.rangeType === 5 && ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.kind) === "docx-permission") && startIndex < currentIndex && customRange.endIndex >= currentIndex) {
|
|
13971
14016
|
customRange.endIndex += textLength;
|
|
13972
14017
|
continue;
|
|
13973
14018
|
}
|
|
@@ -13998,6 +14043,8 @@ function insertCustomRanges(body, insertBody, textLength, currentIndex) {
|
|
|
13998
14043
|
body.customRanges = mergeContinuousRanges(customRanges);
|
|
13999
14044
|
}
|
|
14000
14045
|
function insertCustomDecorations(body, insertBody, textLength, currentIndex) {
|
|
14046
|
+
var _insertBody$customDec;
|
|
14047
|
+
if (body.customDecorations == null && !((_insertBody$customDec = insertBody.customDecorations) === null || _insertBody$customDec === void 0 ? void 0 : _insertBody$customDec.length)) return;
|
|
14001
14048
|
if (!body.customDecorations) body.customDecorations = [];
|
|
14002
14049
|
const { customDecorations } = body;
|
|
14003
14050
|
splitCustomDecoratesByIndex(customDecorations, currentIndex);
|
|
@@ -14345,601 +14392,139 @@ function deleteCustomDecorations(body, textLength, currentIndex, needOffset = tr
|
|
|
14345
14392
|
return removeCustomDecorations;
|
|
14346
14393
|
}
|
|
14347
14394
|
|
|
14348
|
-
// src/docs/data-model/
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
* Hierarchical ordered list using `A`, `1`, and `i` markers.
|
|
14391
|
-
*/
|
|
14392
|
-
PresetListType["ORDER_LIST_4"] = "ORDER_LIST_4";
|
|
14393
|
-
/**
|
|
14394
|
-
* Zero-padded ordered list using `01`, `a`, and `i` markers.
|
|
14395
|
-
*/
|
|
14396
|
-
PresetListType["ORDER_LIST_5"] = "ORDER_LIST_5";
|
|
14397
|
-
/** Quick ordered list using closing-parenthesis markers. */
|
|
14398
|
-
PresetListType["ORDER_LIST_QUICK_2"] = "ORDER_LIST_QUICK_2";
|
|
14399
|
-
/** Quick ordered list using lowercase letter and period markers. */
|
|
14400
|
-
PresetListType["ORDER_LIST_QUICK_3"] = "ORDER_LIST_QUICK_3";
|
|
14401
|
-
/** Quick ordered list using lowercase Roman numeral markers. */
|
|
14402
|
-
PresetListType["ORDER_LIST_QUICK_4"] = "ORDER_LIST_QUICK_4";
|
|
14403
|
-
/** Quick ordered list using uppercase letter markers. */
|
|
14404
|
-
PresetListType["ORDER_LIST_QUICK_5"] = "ORDER_LIST_QUICK_5";
|
|
14405
|
-
/** Quick ordered list using uppercase Roman numeral markers. */
|
|
14406
|
-
PresetListType["ORDER_LIST_QUICK_6"] = "ORDER_LIST_QUICK_6";
|
|
14407
|
-
/** Unchecked task-list item. */
|
|
14408
|
-
PresetListType["CHECK_LIST"] = "CHECK_LIST";
|
|
14409
|
-
/** Checked task-list item. */
|
|
14410
|
-
PresetListType["CHECK_LIST_CHECKED"] = "CHECK_LIST_CHECKED";
|
|
14411
|
-
return PresetListType;
|
|
14412
|
-
}({});
|
|
14413
|
-
const orderListSymbolMap = {
|
|
14414
|
-
"a)": {
|
|
14415
|
-
glyphFormat: "%1)",
|
|
14416
|
-
glyphType: 2
|
|
14417
|
-
},
|
|
14418
|
-
"1.": {
|
|
14419
|
-
glyphFormat: "%1.",
|
|
14420
|
-
glyphType: 2
|
|
14421
|
-
},
|
|
14422
|
-
"a.": {
|
|
14423
|
-
glyphFormat: "%1.",
|
|
14424
|
-
glyphType: 5
|
|
14425
|
-
},
|
|
14426
|
-
"A.": {
|
|
14427
|
-
glyphFormat: "%1.",
|
|
14428
|
-
glyphType: 4
|
|
14429
|
-
},
|
|
14430
|
-
"i.": {
|
|
14431
|
-
glyphFormat: "%1.",
|
|
14432
|
-
glyphType: 7
|
|
14433
|
-
},
|
|
14434
|
-
"I.": {
|
|
14435
|
-
glyphFormat: "%1.",
|
|
14436
|
-
glyphType: 4
|
|
14395
|
+
// src/docs/data-model/text-x/apply-utils/update-apply.ts
|
|
14396
|
+
function updateAttribute(body, updateBody, textLength, currentIndex, coverType) {
|
|
14397
|
+
return {
|
|
14398
|
+
dataStream: "",
|
|
14399
|
+
textRuns: updateTextRuns(body, updateBody, textLength, currentIndex, coverType),
|
|
14400
|
+
paragraphs: updateParagraphs(body, updateBody, textLength, currentIndex, coverType),
|
|
14401
|
+
sectionBreaks: updateSectionBreaks(body, updateBody, textLength, currentIndex, coverType),
|
|
14402
|
+
customBlocks: updateCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
|
|
14403
|
+
docxRawCustomBlocks: updateDocxRawCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
|
|
14404
|
+
tables: updateTables(body, updateBody, textLength, currentIndex, coverType),
|
|
14405
|
+
columnGroups: updateColumnGroups(body, updateBody, textLength, currentIndex, coverType),
|
|
14406
|
+
blockRanges: updateBlockRanges(body, updateBody, textLength, currentIndex, coverType),
|
|
14407
|
+
customRanges: updateCustomRanges(body, updateBody, textLength, currentIndex, coverType),
|
|
14408
|
+
customDecorations: updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType)
|
|
14409
|
+
};
|
|
14410
|
+
}
|
|
14411
|
+
function updateTextRuns(body, updateBody, textLength, currentIndex, coverType) {
|
|
14412
|
+
const { textRuns: updateTextRuns } = updateBody;
|
|
14413
|
+
if (updateTextRuns == null || body.textRuns == null && !updateTextRuns.some((run) => run.sId || Object.keys(run.ts ?? {}).length)) return;
|
|
14414
|
+
body.textRuns ??= [];
|
|
14415
|
+
const removeTextRuns = deleteTextRuns(body, textLength, currentIndex);
|
|
14416
|
+
if (coverType !== 1) updateBody.textRuns = coverTextRuns(updateTextRuns, removeTextRuns, coverType);
|
|
14417
|
+
insertTextRuns(body, updateBody, textLength, currentIndex);
|
|
14418
|
+
return removeTextRuns;
|
|
14419
|
+
}
|
|
14420
|
+
function coverTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
14421
|
+
if (originTextRuns.length === 0) return updateDataTextRuns;
|
|
14422
|
+
updateDataTextRuns = Tools.deepClone(updateDataTextRuns);
|
|
14423
|
+
originTextRuns = Tools.deepClone(originTextRuns);
|
|
14424
|
+
const newUpdateTextRuns = [];
|
|
14425
|
+
const updateLength = updateDataTextRuns.length;
|
|
14426
|
+
const removeLength = originTextRuns.length;
|
|
14427
|
+
let updateIndex = 0;
|
|
14428
|
+
let removeIndex = 0;
|
|
14429
|
+
let pending = null;
|
|
14430
|
+
function pushPendingAndReturnStatus() {
|
|
14431
|
+
if (pending) {
|
|
14432
|
+
newUpdateTextRuns.push(pending);
|
|
14433
|
+
pending = null;
|
|
14434
|
+
return true;
|
|
14435
|
+
}
|
|
14436
|
+
return false;
|
|
14437
14437
|
}
|
|
14438
|
-
|
|
14439
|
-
const
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14438
|
+
while (updateIndex < updateLength && removeIndex < removeLength) {
|
|
14439
|
+
const { st: updateSt, ed: updateEd, ts: updateStyle } = updateDataTextRuns[updateIndex];
|
|
14440
|
+
const { st: removeSt, ed: removeEd, ts: originStyle, sId } = originTextRuns[removeIndex];
|
|
14441
|
+
let newTs;
|
|
14442
|
+
if (coverType === 0) newTs = {
|
|
14443
|
+
...originStyle,
|
|
14444
|
+
...updateStyle
|
|
14445
|
+
};
|
|
14446
|
+
else newTs = { ...updateStyle };
|
|
14447
|
+
if (updateEd < removeSt) {
|
|
14448
|
+
if (!pushPendingAndReturnStatus()) newUpdateTextRuns.push(updateDataTextRuns[updateIndex]);
|
|
14449
|
+
updateIndex++;
|
|
14450
|
+
} else if (removeEd < updateSt) {
|
|
14451
|
+
if (!pushPendingAndReturnStatus()) newUpdateTextRuns.push(originTextRuns[removeIndex]);
|
|
14452
|
+
removeIndex++;
|
|
14453
|
+
} else {
|
|
14454
|
+
const newTextRun = {
|
|
14455
|
+
st: Math.min(updateSt, removeSt),
|
|
14456
|
+
ed: Math.max(updateSt, removeSt),
|
|
14457
|
+
ts: updateSt < removeSt ? { ...updateStyle } : { ...originStyle },
|
|
14458
|
+
sId: updateSt < removeSt ? void 0 : sId
|
|
14459
|
+
};
|
|
14460
|
+
if (newTextRun.ed > newTextRun.st) newUpdateTextRuns.push(newTextRun);
|
|
14461
|
+
newUpdateTextRuns.push({
|
|
14462
|
+
st: Math.max(updateSt, removeSt),
|
|
14463
|
+
ed: Math.min(updateEd, removeEd),
|
|
14464
|
+
ts: newTs,
|
|
14465
|
+
sId
|
|
14466
|
+
});
|
|
14467
|
+
if (updateEd < removeEd) {
|
|
14468
|
+
updateIndex++;
|
|
14469
|
+
originTextRuns[removeIndex].st = updateEd;
|
|
14470
|
+
if (originTextRuns[removeIndex].st === originTextRuns[removeIndex].ed) removeIndex++;
|
|
14471
|
+
} else {
|
|
14472
|
+
removeIndex++;
|
|
14473
|
+
updateDataTextRuns[updateIndex].st = removeEd;
|
|
14474
|
+
if (updateDataTextRuns[updateIndex].st === updateDataTextRuns[updateIndex].ed) updateIndex++;
|
|
14475
|
+
}
|
|
14476
|
+
const pendingTextRun = {
|
|
14477
|
+
st: Math.min(updateEd, removeEd),
|
|
14478
|
+
ed: Math.max(updateEd, removeEd),
|
|
14479
|
+
ts: updateEd < removeEd ? { ...originStyle } : { ...updateStyle },
|
|
14480
|
+
sId: updateEd < removeEd ? sId : void 0
|
|
14481
|
+
};
|
|
14482
|
+
pending = pendingTextRun.ed > pendingTextRun.st ? pendingTextRun : null;
|
|
14452
14483
|
}
|
|
14453
|
-
}
|
|
14454
|
-
|
|
14455
|
-
const
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
};
|
|
14466
|
-
const
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
listType: "BULLET_LIST",
|
|
14498
|
-
nestingLevel: bulletListFactory([
|
|
14499
|
-
"✔",
|
|
14500
|
-
"●",
|
|
14501
|
-
"◆"
|
|
14502
|
-
])
|
|
14503
|
-
},
|
|
14504
|
-
["BULLET_LIST_3"]: {
|
|
14505
|
-
listType: "BULLET_LIST",
|
|
14506
|
-
nestingLevel: bulletListFactory([
|
|
14507
|
-
"■",
|
|
14508
|
-
"◆",
|
|
14509
|
-
"○"
|
|
14510
|
-
])
|
|
14511
|
-
},
|
|
14512
|
-
["BULLET_LIST_4"]: {
|
|
14513
|
-
listType: "BULLET_LIST",
|
|
14514
|
-
nestingLevel: bulletListFactory([
|
|
14515
|
-
"✦",
|
|
14516
|
-
"○",
|
|
14517
|
-
"■"
|
|
14518
|
-
])
|
|
14519
|
-
},
|
|
14520
|
-
["BULLET_LIST_5"]: {
|
|
14521
|
-
listType: "BULLET_LIST",
|
|
14522
|
-
nestingLevel: bulletListFactory([
|
|
14523
|
-
"➢",
|
|
14524
|
-
"○",
|
|
14525
|
-
"◆"
|
|
14526
|
-
])
|
|
14527
|
-
},
|
|
14528
|
-
["ORDER_LIST"]: {
|
|
14529
|
-
listType: "ORDER_LIST",
|
|
14530
|
-
nestingLevel: orderListFactory([
|
|
14531
|
-
{
|
|
14532
|
-
glyphFormat: "%1.",
|
|
14533
|
-
glyphType: 2
|
|
14534
|
-
},
|
|
14535
|
-
{
|
|
14536
|
-
glyphFormat: "%2.",
|
|
14537
|
-
glyphType: 5
|
|
14538
|
-
},
|
|
14539
|
-
{
|
|
14540
|
-
glyphFormat: "%3.",
|
|
14541
|
-
glyphType: 7
|
|
14542
|
-
},
|
|
14543
|
-
{
|
|
14544
|
-
glyphFormat: "%4.",
|
|
14545
|
-
glyphType: 2
|
|
14546
|
-
},
|
|
14547
|
-
{
|
|
14548
|
-
glyphFormat: "%5.",
|
|
14549
|
-
glyphType: 5
|
|
14550
|
-
},
|
|
14551
|
-
{
|
|
14552
|
-
glyphFormat: "%6.",
|
|
14553
|
-
glyphType: 7
|
|
14554
|
-
},
|
|
14555
|
-
{
|
|
14556
|
-
glyphFormat: "%7.",
|
|
14557
|
-
glyphType: 2
|
|
14558
|
-
},
|
|
14559
|
-
{
|
|
14560
|
-
glyphFormat: "%8.",
|
|
14561
|
-
glyphType: 5
|
|
14562
|
-
},
|
|
14563
|
-
{
|
|
14564
|
-
glyphFormat: "%9.",
|
|
14565
|
-
glyphType: 7
|
|
14566
|
-
}
|
|
14567
|
-
])
|
|
14568
|
-
},
|
|
14569
|
-
["ORDER_LIST_1"]: {
|
|
14570
|
-
listType: "ORDER_LIST",
|
|
14571
|
-
nestingLevel: orderListFactory([
|
|
14572
|
-
{
|
|
14573
|
-
glyphFormat: "%1)",
|
|
14574
|
-
glyphType: 2
|
|
14575
|
-
},
|
|
14576
|
-
{
|
|
14577
|
-
glyphFormat: "%2)",
|
|
14578
|
-
glyphType: 5
|
|
14579
|
-
},
|
|
14580
|
-
{
|
|
14581
|
-
glyphFormat: "%3)",
|
|
14582
|
-
glyphType: 7
|
|
14583
|
-
},
|
|
14584
|
-
{
|
|
14585
|
-
glyphFormat: "%4)",
|
|
14586
|
-
glyphType: 2
|
|
14587
|
-
},
|
|
14588
|
-
{
|
|
14589
|
-
glyphFormat: "%5)",
|
|
14590
|
-
glyphType: 5
|
|
14591
|
-
},
|
|
14592
|
-
{
|
|
14593
|
-
glyphFormat: "%6)",
|
|
14594
|
-
glyphType: 7
|
|
14595
|
-
},
|
|
14596
|
-
{
|
|
14597
|
-
glyphFormat: "%7)",
|
|
14598
|
-
glyphType: 2
|
|
14599
|
-
},
|
|
14600
|
-
{
|
|
14601
|
-
glyphFormat: "%8)",
|
|
14602
|
-
glyphType: 5
|
|
14603
|
-
},
|
|
14604
|
-
{
|
|
14605
|
-
glyphFormat: "%9)",
|
|
14606
|
-
glyphType: 7
|
|
14607
|
-
}
|
|
14608
|
-
])
|
|
14609
|
-
},
|
|
14610
|
-
["ORDER_LIST_2"]: {
|
|
14611
|
-
listType: "ORDER_LIST",
|
|
14612
|
-
nestingLevel: orderListFactory([
|
|
14613
|
-
"%1.",
|
|
14614
|
-
"%1.%2.",
|
|
14615
|
-
"%1.%2.%3.",
|
|
14616
|
-
"%1.%2.%3.%4.",
|
|
14617
|
-
"%1.%2.%3.%4.%5.",
|
|
14618
|
-
"%1.%2.%3.%4.%5.%6.",
|
|
14619
|
-
"%1.%2.%3.%4.%5.%6.%7."
|
|
14620
|
-
].map((format) => ({
|
|
14621
|
-
glyphFormat: format,
|
|
14622
|
-
glyphType: 2
|
|
14623
|
-
})))
|
|
14624
|
-
},
|
|
14625
|
-
["ORDER_LIST_3"]: {
|
|
14626
|
-
listType: "ORDER_LIST",
|
|
14627
|
-
nestingLevel: orderListFactory([
|
|
14628
|
-
{
|
|
14629
|
-
glyphFormat: "%1.",
|
|
14630
|
-
glyphType: 4
|
|
14631
|
-
},
|
|
14632
|
-
{
|
|
14633
|
-
glyphFormat: "%2.",
|
|
14634
|
-
glyphType: 5
|
|
14635
|
-
},
|
|
14636
|
-
{
|
|
14637
|
-
glyphFormat: "%3.",
|
|
14638
|
-
glyphType: 7
|
|
14639
|
-
},
|
|
14640
|
-
{
|
|
14641
|
-
glyphFormat: "%4.",
|
|
14642
|
-
glyphType: 4
|
|
14643
|
-
},
|
|
14644
|
-
{
|
|
14645
|
-
glyphFormat: "%5.",
|
|
14646
|
-
glyphType: 5
|
|
14647
|
-
},
|
|
14648
|
-
{
|
|
14649
|
-
glyphFormat: "%6.",
|
|
14650
|
-
glyphType: 7
|
|
14651
|
-
},
|
|
14652
|
-
{
|
|
14653
|
-
glyphFormat: "%7.",
|
|
14654
|
-
glyphType: 4
|
|
14655
|
-
},
|
|
14656
|
-
{
|
|
14657
|
-
glyphFormat: "%8.",
|
|
14658
|
-
glyphType: 5
|
|
14659
|
-
},
|
|
14660
|
-
{
|
|
14661
|
-
glyphFormat: "%9.",
|
|
14662
|
-
glyphType: 7
|
|
14663
|
-
}
|
|
14664
|
-
])
|
|
14665
|
-
},
|
|
14666
|
-
["ORDER_LIST_4"]: {
|
|
14667
|
-
listType: "ORDER_LIST",
|
|
14668
|
-
nestingLevel: orderListFactory([
|
|
14669
|
-
{
|
|
14670
|
-
glyphFormat: "%1.",
|
|
14671
|
-
glyphType: 4
|
|
14672
|
-
},
|
|
14673
|
-
{
|
|
14674
|
-
glyphFormat: "%2.",
|
|
14675
|
-
glyphType: 2
|
|
14676
|
-
},
|
|
14677
|
-
{
|
|
14678
|
-
glyphFormat: "%3.",
|
|
14679
|
-
glyphType: 7
|
|
14680
|
-
},
|
|
14681
|
-
{
|
|
14682
|
-
glyphFormat: "%4.",
|
|
14683
|
-
glyphType: 4
|
|
14684
|
-
},
|
|
14685
|
-
{
|
|
14686
|
-
glyphFormat: "%5.",
|
|
14687
|
-
glyphType: 2
|
|
14688
|
-
},
|
|
14689
|
-
{
|
|
14690
|
-
glyphFormat: "%6.",
|
|
14691
|
-
glyphType: 7
|
|
14692
|
-
},
|
|
14693
|
-
{
|
|
14694
|
-
glyphFormat: "%7.",
|
|
14695
|
-
glyphType: 4
|
|
14696
|
-
},
|
|
14697
|
-
{
|
|
14698
|
-
glyphFormat: "%8.",
|
|
14699
|
-
glyphType: 2
|
|
14700
|
-
},
|
|
14701
|
-
{
|
|
14702
|
-
glyphFormat: "%9.",
|
|
14703
|
-
glyphType: 7
|
|
14704
|
-
}
|
|
14705
|
-
])
|
|
14706
|
-
},
|
|
14707
|
-
["ORDER_LIST_5"]: {
|
|
14708
|
-
listType: "ORDER_LIST",
|
|
14709
|
-
nestingLevel: orderListFactory([
|
|
14710
|
-
{
|
|
14711
|
-
glyphFormat: "%1.",
|
|
14712
|
-
glyphType: 3
|
|
14713
|
-
},
|
|
14714
|
-
{
|
|
14715
|
-
glyphFormat: "%2.",
|
|
14716
|
-
glyphType: 5
|
|
14717
|
-
},
|
|
14718
|
-
{
|
|
14719
|
-
glyphFormat: "%3.",
|
|
14720
|
-
glyphType: 7
|
|
14721
|
-
},
|
|
14722
|
-
{
|
|
14723
|
-
glyphFormat: "%4.",
|
|
14724
|
-
glyphType: 3
|
|
14725
|
-
},
|
|
14726
|
-
{
|
|
14727
|
-
glyphFormat: "%5.",
|
|
14728
|
-
glyphType: 5
|
|
14729
|
-
},
|
|
14730
|
-
{
|
|
14731
|
-
glyphFormat: "%6.",
|
|
14732
|
-
glyphType: 7
|
|
14733
|
-
},
|
|
14734
|
-
{
|
|
14735
|
-
glyphFormat: "%7.",
|
|
14736
|
-
glyphType: 3
|
|
14737
|
-
},
|
|
14738
|
-
{
|
|
14739
|
-
glyphFormat: "%8.",
|
|
14740
|
-
glyphType: 5
|
|
14741
|
-
},
|
|
14742
|
-
{
|
|
14743
|
-
glyphFormat: "%9.",
|
|
14744
|
-
glyphType: 7
|
|
14745
|
-
}
|
|
14746
|
-
])
|
|
14747
|
-
},
|
|
14748
|
-
["CHECK_LIST"]: {
|
|
14749
|
-
listType: "CHECK_LIST",
|
|
14750
|
-
nestingLevel: checkListFactory("☐")
|
|
14751
|
-
},
|
|
14752
|
-
["CHECK_LIST_CHECKED"]: {
|
|
14753
|
-
listType: "CHECK_LIST_CHECKED",
|
|
14754
|
-
nestingLevel: checkListFactory("☑", { st: { s: 1 } })
|
|
14755
|
-
}
|
|
14756
|
-
};
|
|
14757
|
-
const generateOrderList = (opt) => {
|
|
14758
|
-
const { glyphFormat, glyphType } = opt;
|
|
14759
|
-
const data = Tools.deepClone(PRESET_LIST_TYPE["ORDER_LIST"]);
|
|
14760
|
-
data.nestingLevel[0].glyphFormat = glyphFormat;
|
|
14761
|
-
data.nestingLevel[0].glyphType = glyphType;
|
|
14762
|
-
return data;
|
|
14763
|
-
};
|
|
14764
|
-
const QUICK_LIST_TYPE = {
|
|
14765
|
-
["ORDER_LIST_QUICK_2"]: generateOrderList(orderListSymbolMap["a)"]),
|
|
14766
|
-
["ORDER_LIST_QUICK_3"]: generateOrderList(orderListSymbolMap["a."]),
|
|
14767
|
-
["ORDER_LIST_QUICK_4"]: generateOrderList(orderListSymbolMap["i."]),
|
|
14768
|
-
["ORDER_LIST_QUICK_6"]: generateOrderList(orderListSymbolMap["I."])
|
|
14769
|
-
};
|
|
14770
|
-
Object.assign(PRESET_LIST_TYPE, QUICK_LIST_TYPE);
|
|
14771
|
-
const QuickListTypeMap = {
|
|
14772
|
-
["1."]: "ORDER_LIST",
|
|
14773
|
-
["a)"]: "ORDER_LIST_QUICK_2",
|
|
14774
|
-
["a."]: "ORDER_LIST_QUICK_3",
|
|
14775
|
-
["i."]: "ORDER_LIST_QUICK_4",
|
|
14776
|
-
["A."]: "ORDER_LIST_3",
|
|
14777
|
-
["I."]: "ORDER_LIST_QUICK_6",
|
|
14778
|
-
["01."]: "ORDER_LIST_5",
|
|
14779
|
-
["*"]: "BULLET_LIST"
|
|
14780
|
-
};
|
|
14781
|
-
|
|
14782
|
-
// src/docs/data-model/text-x/apply-utils/update-apply.ts
|
|
14783
|
-
function updateAttribute(body, updateBody, textLength, currentIndex, coverType) {
|
|
14784
|
-
return {
|
|
14785
|
-
dataStream: "",
|
|
14786
|
-
textRuns: updateTextRuns(body, updateBody, textLength, currentIndex, coverType),
|
|
14787
|
-
paragraphs: updateParagraphs(body, updateBody, textLength, currentIndex, coverType),
|
|
14788
|
-
sectionBreaks: updateSectionBreaks(body, updateBody, textLength, currentIndex, coverType),
|
|
14789
|
-
customBlocks: updateCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
|
|
14790
|
-
docxRawCustomBlocks: updateDocxRawCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
|
|
14791
|
-
tables: updateTables(body, updateBody, textLength, currentIndex, coverType),
|
|
14792
|
-
columnGroups: updateColumnGroups(body, updateBody, textLength, currentIndex, coverType),
|
|
14793
|
-
blockRanges: updateBlockRanges(body, updateBody, textLength, currentIndex, coverType),
|
|
14794
|
-
customRanges: updateCustomRanges(body, updateBody, textLength, currentIndex, coverType),
|
|
14795
|
-
customDecorations: updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType)
|
|
14796
|
-
};
|
|
14797
|
-
}
|
|
14798
|
-
function updateTextRuns(body, updateBody, textLength, currentIndex, coverType) {
|
|
14799
|
-
const { textRuns } = body;
|
|
14800
|
-
const { textRuns: updateTextRuns } = updateBody;
|
|
14801
|
-
if (textRuns == null || updateTextRuns == null) return;
|
|
14802
|
-
const removeTextRuns = deleteTextRuns(body, textLength, currentIndex);
|
|
14803
|
-
if (coverType !== 1) updateBody.textRuns = coverTextRuns(updateTextRuns, removeTextRuns, coverType);
|
|
14804
|
-
insertTextRuns(body, updateBody, textLength, currentIndex);
|
|
14805
|
-
return removeTextRuns;
|
|
14806
|
-
}
|
|
14807
|
-
function coverTextRuns(updateDataTextRuns, originTextRuns, coverType) {
|
|
14808
|
-
if (originTextRuns.length === 0) return updateDataTextRuns;
|
|
14809
|
-
updateDataTextRuns = Tools.deepClone(updateDataTextRuns);
|
|
14810
|
-
originTextRuns = Tools.deepClone(originTextRuns);
|
|
14811
|
-
const newUpdateTextRuns = [];
|
|
14812
|
-
const updateLength = updateDataTextRuns.length;
|
|
14813
|
-
const removeLength = originTextRuns.length;
|
|
14814
|
-
let updateIndex = 0;
|
|
14815
|
-
let removeIndex = 0;
|
|
14816
|
-
let pending = null;
|
|
14817
|
-
function pushPendingAndReturnStatus() {
|
|
14818
|
-
if (pending) {
|
|
14819
|
-
newUpdateTextRuns.push(pending);
|
|
14820
|
-
pending = null;
|
|
14821
|
-
return true;
|
|
14822
|
-
}
|
|
14823
|
-
return false;
|
|
14824
|
-
}
|
|
14825
|
-
while (updateIndex < updateLength && removeIndex < removeLength) {
|
|
14826
|
-
const { st: updateSt, ed: updateEd, ts: updateStyle } = updateDataTextRuns[updateIndex];
|
|
14827
|
-
const { st: removeSt, ed: removeEd, ts: originStyle, sId } = originTextRuns[removeIndex];
|
|
14828
|
-
let newTs;
|
|
14829
|
-
if (coverType === 0) newTs = {
|
|
14830
|
-
...originStyle,
|
|
14831
|
-
...updateStyle
|
|
14832
|
-
};
|
|
14833
|
-
else newTs = { ...updateStyle };
|
|
14834
|
-
if (updateEd < removeSt) {
|
|
14835
|
-
if (!pushPendingAndReturnStatus()) newUpdateTextRuns.push(updateDataTextRuns[updateIndex]);
|
|
14836
|
-
updateIndex++;
|
|
14837
|
-
} else if (removeEd < updateSt) {
|
|
14838
|
-
if (!pushPendingAndReturnStatus()) newUpdateTextRuns.push(originTextRuns[removeIndex]);
|
|
14839
|
-
removeIndex++;
|
|
14840
|
-
} else {
|
|
14841
|
-
const newTextRun = {
|
|
14842
|
-
st: Math.min(updateSt, removeSt),
|
|
14843
|
-
ed: Math.max(updateSt, removeSt),
|
|
14844
|
-
ts: updateSt < removeSt ? { ...updateStyle } : { ...originStyle },
|
|
14845
|
-
sId: updateSt < removeSt ? void 0 : sId
|
|
14846
|
-
};
|
|
14847
|
-
if (newTextRun.ed > newTextRun.st) newUpdateTextRuns.push(newTextRun);
|
|
14848
|
-
newUpdateTextRuns.push({
|
|
14849
|
-
st: Math.max(updateSt, removeSt),
|
|
14850
|
-
ed: Math.min(updateEd, removeEd),
|
|
14851
|
-
ts: newTs,
|
|
14852
|
-
sId
|
|
14853
|
-
});
|
|
14854
|
-
if (updateEd < removeEd) {
|
|
14855
|
-
updateIndex++;
|
|
14856
|
-
originTextRuns[removeIndex].st = updateEd;
|
|
14857
|
-
if (originTextRuns[removeIndex].st === originTextRuns[removeIndex].ed) removeIndex++;
|
|
14858
|
-
} else {
|
|
14859
|
-
removeIndex++;
|
|
14860
|
-
updateDataTextRuns[updateIndex].st = removeEd;
|
|
14861
|
-
if (updateDataTextRuns[updateIndex].st === updateDataTextRuns[updateIndex].ed) updateIndex++;
|
|
14862
|
-
}
|
|
14863
|
-
const pendingTextRun = {
|
|
14864
|
-
st: Math.min(updateEd, removeEd),
|
|
14865
|
-
ed: Math.max(updateEd, removeEd),
|
|
14866
|
-
ts: updateEd < removeEd ? { ...originStyle } : { ...updateStyle },
|
|
14867
|
-
sId: updateEd < removeEd ? sId : void 0
|
|
14868
|
-
};
|
|
14869
|
-
pending = pendingTextRun.ed > pendingTextRun.st ? pendingTextRun : null;
|
|
14870
|
-
}
|
|
14871
|
-
}
|
|
14872
|
-
pushPendingAndReturnStatus();
|
|
14873
|
-
const tempTopTextRun = newUpdateTextRuns[newUpdateTextRuns.length - 1];
|
|
14874
|
-
const updateLastTextRun = updateDataTextRuns[updateLength - 1];
|
|
14875
|
-
const removeLastTextRun = originTextRuns[removeLength - 1];
|
|
14876
|
-
if (tempTopTextRun && tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed)) {
|
|
14877
|
-
if (updateLastTextRun.ed > removeLastTextRun.ed) newUpdateTextRuns.push(updateLastTextRun);
|
|
14878
|
-
else newUpdateTextRuns.push(removeLastTextRun);
|
|
14879
|
-
}
|
|
14880
|
-
return normalizeTextRuns(newUpdateTextRuns);
|
|
14881
|
-
}
|
|
14882
|
-
function updateParagraphs(body, updateBody, textLength, currentIndex, coverType) {
|
|
14883
|
-
const { paragraphs } = body;
|
|
14884
|
-
const { paragraphs: updateDataParagraphs } = updateBody;
|
|
14885
|
-
if (paragraphs == null || updateDataParagraphs == null) return;
|
|
14886
|
-
const removeParagraphs = deleteParagraphs(body, textLength, currentIndex);
|
|
14887
|
-
if (coverType !== 1) {
|
|
14888
|
-
const newUpdateParagraphs = [];
|
|
14889
|
-
for (const updateParagraph of updateDataParagraphs) {
|
|
14890
|
-
const { startIndex: updateStartIndex, paragraphId: updateParagraphId, paragraphStyle: updateParagraphStyle, bullet: updateBullet } = updateParagraph;
|
|
14891
|
-
let splitUpdateParagraphs = [];
|
|
14892
|
-
for (const removeParagraph of removeParagraphs) {
|
|
14893
|
-
const { startIndex: removeStartIndex, paragraphId: removeParagraphId, paragraphStyle: removeParagraphStyle, bullet: removeBullet } = removeParagraph;
|
|
14894
|
-
let newParagraphStyle;
|
|
14895
|
-
let newBullet;
|
|
14896
|
-
const paragraphAttributes = coverType === 0 ? {
|
|
14897
|
-
...removeParagraph,
|
|
14898
|
-
...updateParagraph
|
|
14899
|
-
} : {
|
|
14900
|
-
...updateParagraph,
|
|
14901
|
-
...removeParagraph
|
|
14902
|
-
};
|
|
14903
|
-
if (coverType === 0) {
|
|
14904
|
-
newParagraphStyle = {
|
|
14905
|
-
...removeParagraphStyle,
|
|
14906
|
-
...updateParagraphStyle
|
|
14907
|
-
};
|
|
14908
|
-
newBullet = {
|
|
14909
|
-
listId: "",
|
|
14910
|
-
listType: "BULLET_LIST",
|
|
14911
|
-
nestingLevel: 0,
|
|
14912
|
-
textStyle: {},
|
|
14913
|
-
...removeBullet,
|
|
14914
|
-
...updateBullet
|
|
14915
|
-
};
|
|
14916
|
-
} else {
|
|
14917
|
-
newParagraphStyle = {
|
|
14918
|
-
...updateParagraphStyle,
|
|
14919
|
-
...removeParagraphStyle
|
|
14920
|
-
};
|
|
14921
|
-
newBullet = {
|
|
14922
|
-
listId: "",
|
|
14923
|
-
listType: "BULLET_LIST",
|
|
14924
|
-
nestingLevel: 0,
|
|
14925
|
-
textStyle: {},
|
|
14926
|
-
...updateBullet,
|
|
14927
|
-
...removeBullet
|
|
14928
|
-
};
|
|
14929
|
-
}
|
|
14930
|
-
if (updateStartIndex === removeStartIndex) {
|
|
14931
|
-
splitUpdateParagraphs.push({
|
|
14932
|
-
...paragraphAttributes,
|
|
14933
|
-
startIndex: updateStartIndex,
|
|
14934
|
-
paragraphId: updateParagraphId ?? removeParagraphId,
|
|
14935
|
-
paragraphStyle: newParagraphStyle,
|
|
14936
|
-
bullet: removeBullet == null && updateBullet == null ? void 0 : newBullet
|
|
14937
|
-
});
|
|
14938
|
-
break;
|
|
14939
|
-
}
|
|
14940
|
-
}
|
|
14941
|
-
newUpdateParagraphs.push(...splitUpdateParagraphs);
|
|
14942
|
-
splitUpdateParagraphs = [];
|
|
14484
|
+
}
|
|
14485
|
+
pushPendingAndReturnStatus();
|
|
14486
|
+
const tempTopTextRun = newUpdateTextRuns[newUpdateTextRuns.length - 1];
|
|
14487
|
+
const updateLastTextRun = updateDataTextRuns[updateLength - 1];
|
|
14488
|
+
const removeLastTextRun = originTextRuns[removeLength - 1];
|
|
14489
|
+
if (tempTopTextRun && tempTopTextRun.ed !== Math.max(updateLastTextRun.ed, removeLastTextRun.ed)) {
|
|
14490
|
+
if (updateLastTextRun.ed > removeLastTextRun.ed) newUpdateTextRuns.push(updateLastTextRun);
|
|
14491
|
+
else newUpdateTextRuns.push(removeLastTextRun);
|
|
14492
|
+
}
|
|
14493
|
+
return normalizeTextRuns(newUpdateTextRuns);
|
|
14494
|
+
}
|
|
14495
|
+
function updateParagraphs(body, updateBody, textLength, currentIndex, coverType) {
|
|
14496
|
+
const { paragraphs } = body;
|
|
14497
|
+
const { paragraphs: updateDataParagraphs } = updateBody;
|
|
14498
|
+
if (paragraphs == null || updateDataParagraphs == null) return;
|
|
14499
|
+
const removeParagraphs = deleteParagraphs(body, textLength, currentIndex);
|
|
14500
|
+
if (coverType !== 1) {
|
|
14501
|
+
const newUpdateParagraphs = [];
|
|
14502
|
+
for (const updateParagraph of updateDataParagraphs) {
|
|
14503
|
+
const { startIndex: updateStartIndex, paragraphId: updateParagraphId } = updateParagraph;
|
|
14504
|
+
for (const removeParagraph of removeParagraphs) {
|
|
14505
|
+
if (updateStartIndex !== removeParagraph.startIndex) continue;
|
|
14506
|
+
const [lower, higher] = coverType === 0 ? [removeParagraph, updateParagraph] : [updateParagraph, removeParagraph];
|
|
14507
|
+
let bullet = lower.bullet == null ? lower.bullet : { ...lower.bullet };
|
|
14508
|
+
if (higher.bullet === null) bullet = null;
|
|
14509
|
+
else if (higher.bullet !== void 0) bullet = {
|
|
14510
|
+
...bullet,
|
|
14511
|
+
...higher.bullet
|
|
14512
|
+
};
|
|
14513
|
+
const paragraph = {
|
|
14514
|
+
...lower,
|
|
14515
|
+
...higher,
|
|
14516
|
+
startIndex: updateStartIndex,
|
|
14517
|
+
paragraphId: updateParagraphId ?? removeParagraph.paragraphId,
|
|
14518
|
+
paragraphStyle: {
|
|
14519
|
+
...lower.paragraphStyle,
|
|
14520
|
+
...higher.paragraphStyle
|
|
14521
|
+
}
|
|
14522
|
+
};
|
|
14523
|
+
if (bullet === void 0) delete paragraph.bullet;
|
|
14524
|
+
else paragraph.bullet = bullet;
|
|
14525
|
+
newUpdateParagraphs.push(paragraph);
|
|
14526
|
+
break;
|
|
14527
|
+
}
|
|
14943
14528
|
}
|
|
14944
14529
|
updateBody.paragraphs = newUpdateParagraphs;
|
|
14945
14530
|
} else for (const updateParagraph of updateDataParagraphs) {
|
|
@@ -15175,49 +14760,775 @@ function updateCustomRanges(body, updateBody, textLength, currentIndex, _coverTy
|
|
|
15175
14760
|
newCustomRanges[position] = ordered[index];
|
|
15176
14761
|
});
|
|
15177
14762
|
}
|
|
15178
|
-
body.customRanges = mergeContinuousRanges(newCustomRanges);
|
|
15179
|
-
return removeCustomRanges;
|
|
15180
|
-
}
|
|
15181
|
-
function updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType) {
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
const
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
14763
|
+
body.customRanges = mergeContinuousRanges(newCustomRanges);
|
|
14764
|
+
return removeCustomRanges;
|
|
14765
|
+
}
|
|
14766
|
+
function updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType) {
|
|
14767
|
+
var _updateBody$customDec;
|
|
14768
|
+
if (body.customDecorations == null && !((_updateBody$customDec = updateBody.customDecorations) === null || _updateBody$customDec === void 0 ? void 0 : _updateBody$customDec.length)) return;
|
|
14769
|
+
if (!body.customDecorations) body.customDecorations = [];
|
|
14770
|
+
splitCustomDecoratesByIndex(body.customDecorations, currentIndex);
|
|
14771
|
+
splitCustomDecoratesByIndex(body.customDecorations, currentIndex + textLength);
|
|
14772
|
+
const removeCustomDecorations = [];
|
|
14773
|
+
const { customDecorations } = body;
|
|
14774
|
+
const { customDecorations: updateDataCustomDecorations = [] } = updateBody;
|
|
14775
|
+
if (coverType === 1) {
|
|
14776
|
+
for (let index = 0; index < customDecorations.length; index++) {
|
|
14777
|
+
const customDecoration = customDecorations[index];
|
|
14778
|
+
const { startIndex, endIndex } = customDecoration;
|
|
14779
|
+
if (startIndex >= currentIndex && endIndex <= currentIndex + textLength - 1) removeCustomDecorations.push(customDecoration);
|
|
14780
|
+
}
|
|
14781
|
+
updateDataCustomDecorations.forEach((customDecoration) => {
|
|
14782
|
+
const { startIndex, endIndex } = customDecoration;
|
|
14783
|
+
customDecorations.push({
|
|
14784
|
+
...customDecoration,
|
|
14785
|
+
startIndex: startIndex + currentIndex,
|
|
14786
|
+
endIndex: endIndex + currentIndex
|
|
14787
|
+
});
|
|
14788
|
+
});
|
|
14789
|
+
} else for (const updateCustomDecoration of updateDataCustomDecorations) {
|
|
14790
|
+
const { id } = updateCustomDecoration;
|
|
14791
|
+
if (updateCustomDecoration.type === 9999) {
|
|
14792
|
+
const oldCustomDecorations = customDecorations.filter((d) => d.id === id);
|
|
14793
|
+
if (oldCustomDecorations.length) removeCustomDecorations.push(...oldCustomDecorations);
|
|
14794
|
+
} else customDecorations.push({
|
|
14795
|
+
...updateCustomDecoration,
|
|
14796
|
+
startIndex: updateCustomDecoration.startIndex + currentIndex,
|
|
14797
|
+
endIndex: updateCustomDecoration.endIndex + currentIndex
|
|
14798
|
+
});
|
|
14799
|
+
}
|
|
14800
|
+
for (const removeCustomDecoration of removeCustomDecorations) {
|
|
14801
|
+
const { id } = removeCustomDecoration;
|
|
14802
|
+
const index = customDecorations.findIndex((d) => d.id === id);
|
|
14803
|
+
if (index !== -1) customDecorations.splice(index, 1);
|
|
14804
|
+
}
|
|
14805
|
+
body.customDecorations = mergeContinuousDecorations(customDecorations);
|
|
14806
|
+
return removeCustomDecorations;
|
|
14807
|
+
}
|
|
14808
|
+
|
|
14809
|
+
// src/docs/data-model/paragraph-style.ts
|
|
14810
|
+
/** Resolves style numbering and partial direct overrides without changing persisted paragraph data. */
|
|
14811
|
+
function resolveDocumentParagraphBullet(document, paragraph) {
|
|
14812
|
+
var _document$documentSty;
|
|
14813
|
+
if (paragraph.bullet === null) return;
|
|
14814
|
+
const chain = [];
|
|
14815
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14816
|
+
let styleId = paragraph.styleId ?? ((_document$documentSty = document.documentStyle) === null || _document$documentSty === void 0 ? void 0 : _document$documentSty.defaultParagraphStyleId);
|
|
14817
|
+
while (styleId && !visited.has(styleId)) {
|
|
14818
|
+
var _document$styles;
|
|
14819
|
+
visited.add(styleId);
|
|
14820
|
+
const style = (_document$styles = document.styles) === null || _document$styles === void 0 ? void 0 : _document$styles[styleId];
|
|
14821
|
+
if (!style || style.type !== 1) break;
|
|
14822
|
+
chain.unshift(style);
|
|
14823
|
+
styleId = style.basedOn;
|
|
14824
|
+
}
|
|
14825
|
+
let resolved = {};
|
|
14826
|
+
for (const bullet of [...chain.map((style) => style.bullet), paragraph.bullet]) {
|
|
14827
|
+
if (bullet === null) {
|
|
14828
|
+
resolved = {};
|
|
14829
|
+
continue;
|
|
14830
|
+
}
|
|
14831
|
+
if ((bullet === null || bullet === void 0 ? void 0 : bullet.listId) != null && bullet.listId !== resolved.listId && bullet.listType == null) delete resolved.listType;
|
|
14832
|
+
resolved = {
|
|
14833
|
+
...resolved,
|
|
14834
|
+
...bullet
|
|
14835
|
+
};
|
|
14836
|
+
}
|
|
14837
|
+
const { listId, nestingLevel = 0 } = resolved;
|
|
14838
|
+
if (listId == null || listId === "0") return;
|
|
14839
|
+
const definition = Object.keys(document.lists ?? {}).find((key) => {
|
|
14840
|
+
var _document$lists;
|
|
14841
|
+
return (_document$lists = document.lists) === null || _document$lists === void 0 || (_document$lists = _document$lists[key].counterIds) === null || _document$lists === void 0 ? void 0 : _document$lists.includes(listId);
|
|
14842
|
+
});
|
|
14843
|
+
const listType = resolved.listType ?? definition ?? listId;
|
|
14844
|
+
return {
|
|
14845
|
+
...resolved,
|
|
14846
|
+
listId,
|
|
14847
|
+
listType,
|
|
14848
|
+
nestingLevel
|
|
14849
|
+
};
|
|
14850
|
+
}
|
|
14851
|
+
function _definedStyle(style) {
|
|
14852
|
+
if (style == null) return {};
|
|
14853
|
+
const definedStyle = Tools.deepClone(style);
|
|
14854
|
+
Tools.removeNull(definedStyle);
|
|
14855
|
+
for (const key of ["textStyle", "paragraphMarkTextStyle"]) {
|
|
14856
|
+
var _style$key;
|
|
14857
|
+
if (((_style$key = style[key]) === null || _style$key === void 0 ? void 0 : _style$key.eastAsiaFontTheme) === null) (definedStyle[key] ??= {}).eastAsiaFontTheme = null;
|
|
14858
|
+
}
|
|
14859
|
+
return definedStyle;
|
|
14860
|
+
}
|
|
14861
|
+
function _mergeWordLength(previous, next, relativeUnit) {
|
|
14862
|
+
if (next.u === relativeUnit) {
|
|
14863
|
+
const fallback = next.fallback ?? ((previous === null || previous === void 0 ? void 0 : previous.u) === relativeUnit ? previous.fallback : previous === null || previous === void 0 ? void 0 : previous.v);
|
|
14864
|
+
return fallback == null ? { ...next } : {
|
|
14865
|
+
...next,
|
|
14866
|
+
fallback
|
|
14867
|
+
};
|
|
14868
|
+
}
|
|
14869
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.u) === relativeUnit) return {
|
|
14870
|
+
...previous,
|
|
14871
|
+
fallback: next.v
|
|
14872
|
+
};
|
|
14873
|
+
return { ...next };
|
|
14874
|
+
}
|
|
14875
|
+
function _assignWordIndents(result, style) {
|
|
14876
|
+
for (const key of [
|
|
14877
|
+
"indentStart",
|
|
14878
|
+
"indentEnd",
|
|
14879
|
+
...["indentFirstLine", "hanging"]
|
|
14880
|
+
]) {
|
|
14881
|
+
const value = style[key];
|
|
14882
|
+
if (value == null) continue;
|
|
14883
|
+
if (key === "indentFirstLine" || key === "hanging") {
|
|
14884
|
+
var _result$opposite;
|
|
14885
|
+
const opposite = key === "hanging" ? "indentFirstLine" : "hanging";
|
|
14886
|
+
if (value.u === 2 && ((_result$opposite = result[opposite]) === null || _result$opposite === void 0 ? void 0 : _result$opposite.u) === 2) result[opposite] = {
|
|
14887
|
+
...result[opposite],
|
|
14888
|
+
v: 0
|
|
14889
|
+
};
|
|
14890
|
+
if (value.u !== 2 || value.fallback != null) {
|
|
14891
|
+
var _result$opposite2;
|
|
14892
|
+
if (((_result$opposite2 = result[opposite]) === null || _result$opposite2 === void 0 ? void 0 : _result$opposite2.u) === 2) {
|
|
14893
|
+
result[opposite] = { ...result[opposite] };
|
|
14894
|
+
delete result[opposite].fallback;
|
|
14895
|
+
} else delete result[opposite];
|
|
14896
|
+
}
|
|
14897
|
+
}
|
|
14898
|
+
result[key] = _mergeWordLength(result[key], value, 2);
|
|
14899
|
+
}
|
|
14900
|
+
}
|
|
14901
|
+
function _assignParagraphStyle(result, style, useWordIndents = false) {
|
|
14902
|
+
var _style$indentFirstLin;
|
|
14903
|
+
const zeroCharacterFirstLine = (style === null || style === void 0 || (_style$indentFirstLin = style.indentFirstLine) === null || _style$indentFirstLin === void 0 ? void 0 : _style$indentFirstLin.u) === 2 && style.indentFirstLine.v === 0;
|
|
14904
|
+
if (!useWordIndents && (style === null || style === void 0 ? void 0 : style.indentFirstLine) != null && style.hanging == null && !zeroCharacterFirstLine) delete result.hanging;
|
|
14905
|
+
else if (!useWordIndents && (style === null || style === void 0 ? void 0 : style.hanging) != null && style.indentFirstLine == null) delete result.indentFirstLine;
|
|
14906
|
+
const inheritedTabs = result.tabStops;
|
|
14907
|
+
const inheritedIndents = {
|
|
14908
|
+
indentStart: result.indentStart,
|
|
14909
|
+
indentEnd: result.indentEnd,
|
|
14910
|
+
indentFirstLine: result.indentFirstLine,
|
|
14911
|
+
hanging: result.hanging,
|
|
14912
|
+
spaceAbove: result.spaceAbove,
|
|
14913
|
+
spaceBelow: result.spaceBelow
|
|
14914
|
+
};
|
|
14915
|
+
Object.assign(result, style);
|
|
14916
|
+
if (useWordIndents && style) {
|
|
14917
|
+
Object.assign(result, inheritedIndents);
|
|
14918
|
+
_assignWordIndents(result, style);
|
|
14919
|
+
for (const key of ["spaceAbove", "spaceBelow"]) {
|
|
14920
|
+
const value = style[key];
|
|
14921
|
+
if (value != null) result[key] = _mergeWordLength(result[key], value, 1);
|
|
14922
|
+
}
|
|
14923
|
+
}
|
|
14924
|
+
if (inheritedTabs && (style === null || style === void 0 ? void 0 : style.tabStops)) {
|
|
14925
|
+
const tabs = new Map(inheritedTabs.map((tab) => [tab.offset, tab]));
|
|
14926
|
+
for (const tab of style.tabStops) tabs.set(tab.offset, tab);
|
|
14927
|
+
result.tabStops = [...tabs.values()].sort((left, right) => left.offset - right.offset);
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
function resolveDocumentTextStyle(styles, styleId) {
|
|
14931
|
+
const chain = [];
|
|
14932
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14933
|
+
let currentId = styleId;
|
|
14934
|
+
while (currentId && !visited.has(currentId)) {
|
|
14935
|
+
visited.add(currentId);
|
|
14936
|
+
const style = styles === null || styles === void 0 ? void 0 : styles[currentId];
|
|
14937
|
+
if (!style) break;
|
|
14938
|
+
chain.unshift(style.textStyle ?? {});
|
|
14939
|
+
currentId = style.basedOn ?? (style.type === 0 ? style.link : void 0);
|
|
14940
|
+
}
|
|
14941
|
+
return Object.assign({}, ...chain);
|
|
14942
|
+
}
|
|
14943
|
+
function _resolveNamedParagraphStyle(styles, styleId, useWordIndents) {
|
|
14944
|
+
if (!styles || !styleId) return {};
|
|
14945
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
14946
|
+
const resolve = (currentStyleId) => {
|
|
14947
|
+
if (visiting.has(currentStyleId)) return {};
|
|
14948
|
+
const style = styles[currentStyleId];
|
|
14949
|
+
if (!style || style.type !== 1) return {};
|
|
14950
|
+
visiting.add(currentStyleId);
|
|
14951
|
+
const base = style.basedOn ? resolve(style.basedOn) : {};
|
|
14952
|
+
visiting.delete(currentStyleId);
|
|
14953
|
+
const own = _definedStyle(style.paragraphStyle);
|
|
14954
|
+
const result = { ...base };
|
|
14955
|
+
_assignParagraphStyle(result, own, useWordIndents);
|
|
14956
|
+
const textStyle = {
|
|
14957
|
+
...base.textStyle,
|
|
14958
|
+
...style.textStyle,
|
|
14959
|
+
...own.textStyle
|
|
14960
|
+
};
|
|
14961
|
+
if (Object.keys(textStyle).length) result.textStyle = textStyle;
|
|
14962
|
+
return result;
|
|
14963
|
+
};
|
|
14964
|
+
return resolve(styleId);
|
|
14965
|
+
}
|
|
14966
|
+
function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options = {}) {
|
|
14967
|
+
var _options$lists, _options$styles;
|
|
14968
|
+
const legacyStyle = options.useLegacyModernDefaults ?? (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 2 ? {
|
|
14969
|
+
lineSpacing: DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
|
|
14970
|
+
spaceAbove: { v: 0 },
|
|
14971
|
+
spaceBelow: { v: 12 }
|
|
14972
|
+
} : {};
|
|
14973
|
+
const documentDefaults = {
|
|
14974
|
+
...(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1 ? { widowControl: 1 } : {},
|
|
14975
|
+
...legacyStyle,
|
|
14976
|
+
..._definedStyle(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.defaultParagraphStyle)
|
|
14977
|
+
};
|
|
14978
|
+
if (options.excludeDocumentOuterSpacing) {
|
|
14979
|
+
delete documentDefaults.spaceAbove;
|
|
14980
|
+
delete documentDefaults.spaceBelow;
|
|
14981
|
+
}
|
|
14982
|
+
const definedParagraphStyle = _definedStyle(paragraphStyle);
|
|
14983
|
+
const paragraphStyleId = options.paragraphStyleId ?? (definedParagraphStyle.namedStyleType == null || definedParagraphStyle.namedStyleType === 0 || definedParagraphStyle.namedStyleType === 1 ? documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.defaultParagraphStyleId : void 0);
|
|
14984
|
+
const referencedParagraphStyle = _resolveNamedParagraphStyle(options.styles, paragraphStyleId, (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1);
|
|
14985
|
+
const bullet = resolveDocumentParagraphBullet({
|
|
14986
|
+
styles: options.styles,
|
|
14987
|
+
lists: options.lists
|
|
14988
|
+
}, {
|
|
14989
|
+
styleId: paragraphStyleId,
|
|
14990
|
+
bullet: options.bullet
|
|
14991
|
+
});
|
|
14992
|
+
const listProperties = bullet && ((_options$lists = options.lists) === null || _options$lists === void 0 || (_options$lists = _options$lists[bullet.listType]) === null || _options$lists === void 0 || (_options$lists = _options$lists.nestingLevel[bullet.nestingLevel]) === null || _options$lists === void 0 ? void 0 : _options$lists.paragraphProperties);
|
|
14993
|
+
const useWordNumberingPriority = (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1;
|
|
14994
|
+
const listIndents = {};
|
|
14995
|
+
for (const key of [
|
|
14996
|
+
"indentStart",
|
|
14997
|
+
"indentEnd",
|
|
14998
|
+
"indentFirstLine",
|
|
14999
|
+
"hanging"
|
|
15000
|
+
]) {
|
|
15001
|
+
const value = listProperties === null || listProperties === void 0 ? void 0 : listProperties[key];
|
|
15002
|
+
if (useWordNumberingPriority && value != null) listIndents[key] = value;
|
|
15003
|
+
}
|
|
15004
|
+
const directNumberingIndents = useWordNumberingPriority && options.bullet != null ? listIndents : {};
|
|
15005
|
+
if (useWordNumberingPriority && options.bullet === null) Object.assign(directNumberingIndents, {
|
|
15006
|
+
indentStart: { v: 0 },
|
|
15007
|
+
indentFirstLine: { v: 0 },
|
|
15008
|
+
hanging: { v: 0 }
|
|
15009
|
+
});
|
|
15010
|
+
const namedStyleType = definedParagraphStyle.namedStyleType ?? referencedParagraphStyle.namedStyleType;
|
|
15011
|
+
const hasReferencedDefinition = paragraphStyleId != null && ((_options$styles = options.styles) === null || _options$styles === void 0 || (_options$styles = _options$styles[paragraphStyleId]) === null || _options$styles === void 0 ? void 0 : _options$styles.type) === 1;
|
|
15012
|
+
const namedStyle = namedStyleType == null || hasReferencedDefinition && referencedParagraphStyle.namedStyleType == null ? null : NAMED_STYLE_SPACE_MAP[namedStyleType];
|
|
15013
|
+
const result = {};
|
|
15014
|
+
for (const style of [
|
|
15015
|
+
documentDefaults,
|
|
15016
|
+
namedStyle,
|
|
15017
|
+
listIndents,
|
|
15018
|
+
referencedParagraphStyle,
|
|
15019
|
+
directNumberingIndents,
|
|
15020
|
+
definedParagraphStyle
|
|
15021
|
+
]) _assignParagraphStyle(result, style, useWordNumberingPriority);
|
|
15022
|
+
if (useWordNumberingPriority) {
|
|
15023
|
+
var _result$indentFirstLi, _result$hanging;
|
|
15024
|
+
if (((_result$indentFirstLi = result.indentFirstLine) === null || _result$indentFirstLi === void 0 ? void 0 : _result$indentFirstLi.u) === 2 && result.indentFirstLine.v !== 0) delete result.hanging;
|
|
15025
|
+
else if (((_result$hanging = result.hanging) === null || _result$hanging === void 0 ? void 0 : _result$hanging.u) === 2 && result.hanging.v !== 0) delete result.indentFirstLine;
|
|
15026
|
+
}
|
|
15027
|
+
const textStyle = {
|
|
15028
|
+
...documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.textStyle,
|
|
15029
|
+
...documentDefaults.textStyle,
|
|
15030
|
+
..._definedStyle(namedStyle).textStyle,
|
|
15031
|
+
...referencedParagraphStyle.textStyle,
|
|
15032
|
+
...definedParagraphStyle.textStyle
|
|
15033
|
+
};
|
|
15034
|
+
if (Object.keys(textStyle).length) result.textStyle = textStyle;
|
|
15035
|
+
if (result.paragraphMarkStyleId != null) {
|
|
15036
|
+
const markTextStyle = resolveDocumentTextStyle(options.styles, result.paragraphMarkStyleId);
|
|
15037
|
+
if (Object.keys(markTextStyle).length) result.paragraphMarkTextStyle = {
|
|
15038
|
+
...markTextStyle,
|
|
15039
|
+
...result.paragraphMarkTextStyle
|
|
15040
|
+
};
|
|
15041
|
+
}
|
|
15042
|
+
return Tools.deepClone(result);
|
|
15043
|
+
}
|
|
15044
|
+
/** Applies absolute edits while clearing Word's inherited relative components. */
|
|
15045
|
+
function getDocumentParagraphStyleForUpdate(document, paragraph, update) {
|
|
15046
|
+
var _document$documentSty2;
|
|
15047
|
+
const result = Tools.deepClone({
|
|
15048
|
+
...paragraph.paragraphStyle,
|
|
15049
|
+
...update
|
|
15050
|
+
});
|
|
15051
|
+
if (((_document$documentSty2 = document.documentStyle) === null || _document$documentSty2 === void 0 ? void 0 : _document$documentSty2.documentFlavor) !== 1) return result;
|
|
15052
|
+
const resolved = resolveDocumentParagraphStyle(document.documentStyle, paragraph.paragraphStyle, {
|
|
15053
|
+
styles: document.styles,
|
|
15054
|
+
lists: document.lists,
|
|
15055
|
+
paragraphStyleId: paragraph.styleId,
|
|
15056
|
+
bullet: paragraph.bullet
|
|
15057
|
+
});
|
|
15058
|
+
for (const key of [
|
|
15059
|
+
"indentStart",
|
|
15060
|
+
"indentEnd",
|
|
15061
|
+
"indentFirstLine",
|
|
15062
|
+
"hanging"
|
|
15063
|
+
]) {
|
|
15064
|
+
var _resolved$key;
|
|
15065
|
+
const value = update[key];
|
|
15066
|
+
const related = key === "hanging" ? resolved.indentFirstLine : resolved.hanging;
|
|
15067
|
+
const hasCharacterIndent = ((_resolved$key = resolved[key]) === null || _resolved$key === void 0 ? void 0 : _resolved$key.u) === 2 || (key === "indentFirstLine" || key === "hanging") && (related === null || related === void 0 ? void 0 : related.u) === 2;
|
|
15068
|
+
if (value != null && value.u !== 2 && hasCharacterIndent) {
|
|
15069
|
+
result[key] = {
|
|
15070
|
+
v: 0,
|
|
15071
|
+
u: 2,
|
|
15072
|
+
fallback: value.v
|
|
15073
|
+
};
|
|
15074
|
+
if (key === "indentFirstLine" && update.hanging == null) delete result.hanging;
|
|
15075
|
+
else if (key === "hanging" && update.indentFirstLine == null) delete result.indentFirstLine;
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15078
|
+
for (const key of ["spaceAbove", "spaceBelow"]) {
|
|
15079
|
+
var _resolved$key2;
|
|
15080
|
+
const value = update[key];
|
|
15081
|
+
if (value != null && value.u !== 1 && ((_resolved$key2 = resolved[key]) === null || _resolved$key2 === void 0 ? void 0 : _resolved$key2.u) === 1) result[key] = {
|
|
15082
|
+
v: 0,
|
|
15083
|
+
u: 1,
|
|
15084
|
+
fallback: value.v
|
|
15085
|
+
};
|
|
15086
|
+
}
|
|
15087
|
+
return result;
|
|
15088
|
+
}
|
|
15089
|
+
/** Resolves word splitting without materializing inherited defaults in the snapshot. */
|
|
15090
|
+
function resolveDocumentParagraphWordWrap(document, paragraph) {
|
|
15091
|
+
const { documentStyle } = document;
|
|
15092
|
+
const { wordWrap } = resolveDocumentParagraphStyle(documentStyle, paragraph === null || paragraph === void 0 ? void 0 : paragraph.paragraphStyle, {
|
|
15093
|
+
styles: document.styles,
|
|
15094
|
+
paragraphStyleId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.styleId
|
|
15095
|
+
});
|
|
15096
|
+
return wordWrap ?? 0;
|
|
15097
|
+
}
|
|
15098
|
+
|
|
15099
|
+
// src/docs/data-model/preset-list-type.ts
|
|
15100
|
+
let QuickListType = /* @__PURE__ */ function(QuickListType) {
|
|
15101
|
+
QuickListType["ORDER_LIST_QUICK_1"] = "1.";
|
|
15102
|
+
QuickListType["ORDER_LIST_QUICK_2"] = "a)";
|
|
15103
|
+
QuickListType["ORDER_LIST_QUICK_3"] = "a.";
|
|
15104
|
+
QuickListType["ORDER_LIST_QUICK_4"] = "i.";
|
|
15105
|
+
QuickListType["ORDER_LIST_QUICK_5"] = "A.";
|
|
15106
|
+
QuickListType["ORDER_LIST_QUICK_6"] = "I.";
|
|
15107
|
+
QuickListType["ORDER_LIST_QUICK_7"] = "01.";
|
|
15108
|
+
QuickListType["BULLET_LIST"] = "*";
|
|
15109
|
+
return QuickListType;
|
|
15110
|
+
}({});
|
|
15111
|
+
let PresetListType = /* @__PURE__ */ function(PresetListType) {
|
|
15112
|
+
/** Standard filled-circle bullet list. */
|
|
15113
|
+
PresetListType["BULLET_LIST"] = "BULLET_LIST";
|
|
15114
|
+
/** Decorative diamond and arrow bullet list. */
|
|
15115
|
+
PresetListType["BULLET_LIST_1"] = "BULLET_LIST_1";
|
|
15116
|
+
/** Checkmark-led bullet list for completed-item style content. */
|
|
15117
|
+
PresetListType["BULLET_LIST_2"] = "BULLET_LIST_2";
|
|
15118
|
+
/** Square and diamond bullet list. */
|
|
15119
|
+
PresetListType["BULLET_LIST_3"] = "BULLET_LIST_3";
|
|
15120
|
+
/** Star-like decorative bullet list. */
|
|
15121
|
+
PresetListType["BULLET_LIST_4"] = "BULLET_LIST_4";
|
|
15122
|
+
/** Arrow-led bullet list. */
|
|
15123
|
+
PresetListType["BULLET_LIST_5"] = "BULLET_LIST_5";
|
|
15124
|
+
/**
|
|
15125
|
+
* Hierarchical ordered list using `1`, `a`, and `i` markers.
|
|
15126
|
+
*/
|
|
15127
|
+
PresetListType["ORDER_LIST"] = "ORDER_LIST";
|
|
15128
|
+
/**
|
|
15129
|
+
* Hierarchical ordered list using `1)`, `a)`, and `i)` markers.
|
|
15130
|
+
*/
|
|
15131
|
+
PresetListType["ORDER_LIST_1"] = "ORDER_LIST_1";
|
|
15132
|
+
/**
|
|
15133
|
+
* Outline list using compound markers such as `1.`, `1.1.`, and `1.1.1.`.
|
|
15134
|
+
*/
|
|
15135
|
+
PresetListType["ORDER_LIST_2"] = "ORDER_LIST_2";
|
|
15136
|
+
/**
|
|
15137
|
+
* Hierarchical ordered list using `A`, `a`, and `i` markers.
|
|
15138
|
+
*/
|
|
15139
|
+
PresetListType["ORDER_LIST_3"] = "ORDER_LIST_3";
|
|
15140
|
+
/**
|
|
15141
|
+
* Hierarchical ordered list using `A`, `1`, and `i` markers.
|
|
15142
|
+
*/
|
|
15143
|
+
PresetListType["ORDER_LIST_4"] = "ORDER_LIST_4";
|
|
15144
|
+
/**
|
|
15145
|
+
* Zero-padded ordered list using `01`, `a`, and `i` markers.
|
|
15146
|
+
*/
|
|
15147
|
+
PresetListType["ORDER_LIST_5"] = "ORDER_LIST_5";
|
|
15148
|
+
/** Quick ordered list using closing-parenthesis markers. */
|
|
15149
|
+
PresetListType["ORDER_LIST_QUICK_2"] = "ORDER_LIST_QUICK_2";
|
|
15150
|
+
/** Quick ordered list using lowercase letter and period markers. */
|
|
15151
|
+
PresetListType["ORDER_LIST_QUICK_3"] = "ORDER_LIST_QUICK_3";
|
|
15152
|
+
/** Quick ordered list using lowercase Roman numeral markers. */
|
|
15153
|
+
PresetListType["ORDER_LIST_QUICK_4"] = "ORDER_LIST_QUICK_4";
|
|
15154
|
+
/** Quick ordered list using uppercase letter markers. */
|
|
15155
|
+
PresetListType["ORDER_LIST_QUICK_5"] = "ORDER_LIST_QUICK_5";
|
|
15156
|
+
/** Quick ordered list using uppercase Roman numeral markers. */
|
|
15157
|
+
PresetListType["ORDER_LIST_QUICK_6"] = "ORDER_LIST_QUICK_6";
|
|
15158
|
+
/** Unchecked task-list item. */
|
|
15159
|
+
PresetListType["CHECK_LIST"] = "CHECK_LIST";
|
|
15160
|
+
/** Checked task-list item. */
|
|
15161
|
+
PresetListType["CHECK_LIST_CHECKED"] = "CHECK_LIST_CHECKED";
|
|
15162
|
+
return PresetListType;
|
|
15163
|
+
}({});
|
|
15164
|
+
const orderListSymbolMap = {
|
|
15165
|
+
"a)": {
|
|
15166
|
+
glyphFormat: "%1)",
|
|
15167
|
+
glyphType: 2
|
|
15168
|
+
},
|
|
15169
|
+
"1.": {
|
|
15170
|
+
glyphFormat: "%1.",
|
|
15171
|
+
glyphType: 2
|
|
15172
|
+
},
|
|
15173
|
+
"a.": {
|
|
15174
|
+
glyphFormat: "%1.",
|
|
15175
|
+
glyphType: 5
|
|
15176
|
+
},
|
|
15177
|
+
"A.": {
|
|
15178
|
+
glyphFormat: "%1.",
|
|
15179
|
+
glyphType: 4
|
|
15180
|
+
},
|
|
15181
|
+
"i.": {
|
|
15182
|
+
glyphFormat: "%1.",
|
|
15183
|
+
glyphType: 7
|
|
15184
|
+
},
|
|
15185
|
+
"I.": {
|
|
15186
|
+
glyphFormat: "%1.",
|
|
15187
|
+
glyphType: 4
|
|
15188
|
+
}
|
|
15189
|
+
};
|
|
15190
|
+
const bulletListFactory = (symbols) => {
|
|
15191
|
+
return [
|
|
15192
|
+
...symbols,
|
|
15193
|
+
...symbols,
|
|
15194
|
+
...symbols
|
|
15195
|
+
].map((templateSymbol, i) => ({
|
|
15196
|
+
glyphFormat: ` %${i + 1}`,
|
|
15197
|
+
glyphSymbol: templateSymbol,
|
|
15198
|
+
bulletAlignment: 1,
|
|
15199
|
+
startNumber: 0,
|
|
15200
|
+
paragraphProperties: {
|
|
15201
|
+
hanging: { v: 21 },
|
|
15202
|
+
indentStart: { v: 21 * (i + 1) }
|
|
15193
15203
|
}
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15204
|
+
}));
|
|
15205
|
+
};
|
|
15206
|
+
const orderListFactory = (options) => {
|
|
15207
|
+
return options.map((format, i) => ({
|
|
15208
|
+
...format,
|
|
15209
|
+
bulletAlignment: 1,
|
|
15210
|
+
startNumber: 0,
|
|
15211
|
+
paragraphProperties: {
|
|
15212
|
+
hanging: { v: 21 },
|
|
15213
|
+
indentStart: { v: 21 * (i + 1) }
|
|
15214
|
+
}
|
|
15215
|
+
}));
|
|
15216
|
+
};
|
|
15217
|
+
const checkListFactory = (symbol, textStyle) => {
|
|
15218
|
+
return new Array(9).fill(0).map((_, i) => ({
|
|
15219
|
+
glyphFormat: ` %${i + 1}`,
|
|
15220
|
+
glyphSymbol: symbol,
|
|
15221
|
+
bulletAlignment: 1,
|
|
15222
|
+
startNumber: 0,
|
|
15223
|
+
paragraphProperties: {
|
|
15224
|
+
hanging: { v: 21 },
|
|
15225
|
+
indentStart: { v: 21 * (i + 1) },
|
|
15226
|
+
textStyle
|
|
15227
|
+
}
|
|
15228
|
+
}));
|
|
15229
|
+
};
|
|
15230
|
+
const PRESET_LIST_TYPE = {
|
|
15231
|
+
["BULLET_LIST"]: {
|
|
15232
|
+
listType: "BULLET_LIST",
|
|
15233
|
+
nestingLevel: bulletListFactory([
|
|
15234
|
+
"●",
|
|
15235
|
+
"○",
|
|
15236
|
+
"■"
|
|
15237
|
+
])
|
|
15238
|
+
},
|
|
15239
|
+
["BULLET_LIST_1"]: {
|
|
15240
|
+
listType: "BULLET_LIST",
|
|
15241
|
+
nestingLevel: bulletListFactory([
|
|
15242
|
+
"❖",
|
|
15243
|
+
"➢",
|
|
15244
|
+
"■"
|
|
15245
|
+
])
|
|
15246
|
+
},
|
|
15247
|
+
["BULLET_LIST_2"]: {
|
|
15248
|
+
listType: "BULLET_LIST",
|
|
15249
|
+
nestingLevel: bulletListFactory([
|
|
15250
|
+
"✔",
|
|
15251
|
+
"●",
|
|
15252
|
+
"◆"
|
|
15253
|
+
])
|
|
15254
|
+
},
|
|
15255
|
+
["BULLET_LIST_3"]: {
|
|
15256
|
+
listType: "BULLET_LIST",
|
|
15257
|
+
nestingLevel: bulletListFactory([
|
|
15258
|
+
"■",
|
|
15259
|
+
"◆",
|
|
15260
|
+
"○"
|
|
15261
|
+
])
|
|
15262
|
+
},
|
|
15263
|
+
["BULLET_LIST_4"]: {
|
|
15264
|
+
listType: "BULLET_LIST",
|
|
15265
|
+
nestingLevel: bulletListFactory([
|
|
15266
|
+
"✦",
|
|
15267
|
+
"○",
|
|
15268
|
+
"■"
|
|
15269
|
+
])
|
|
15270
|
+
},
|
|
15271
|
+
["BULLET_LIST_5"]: {
|
|
15272
|
+
listType: "BULLET_LIST",
|
|
15273
|
+
nestingLevel: bulletListFactory([
|
|
15274
|
+
"➢",
|
|
15275
|
+
"○",
|
|
15276
|
+
"◆"
|
|
15277
|
+
])
|
|
15278
|
+
},
|
|
15279
|
+
["ORDER_LIST"]: {
|
|
15280
|
+
listType: "ORDER_LIST",
|
|
15281
|
+
nestingLevel: orderListFactory([
|
|
15282
|
+
{
|
|
15283
|
+
glyphFormat: "%1.",
|
|
15284
|
+
glyphType: 2
|
|
15285
|
+
},
|
|
15286
|
+
{
|
|
15287
|
+
glyphFormat: "%2.",
|
|
15288
|
+
glyphType: 5
|
|
15289
|
+
},
|
|
15290
|
+
{
|
|
15291
|
+
glyphFormat: "%3.",
|
|
15292
|
+
glyphType: 7
|
|
15293
|
+
},
|
|
15294
|
+
{
|
|
15295
|
+
glyphFormat: "%4.",
|
|
15296
|
+
glyphType: 2
|
|
15297
|
+
},
|
|
15298
|
+
{
|
|
15299
|
+
glyphFormat: "%5.",
|
|
15300
|
+
glyphType: 5
|
|
15301
|
+
},
|
|
15302
|
+
{
|
|
15303
|
+
glyphFormat: "%6.",
|
|
15304
|
+
glyphType: 7
|
|
15305
|
+
},
|
|
15306
|
+
{
|
|
15307
|
+
glyphFormat: "%7.",
|
|
15308
|
+
glyphType: 2
|
|
15309
|
+
},
|
|
15310
|
+
{
|
|
15311
|
+
glyphFormat: "%8.",
|
|
15312
|
+
glyphType: 5
|
|
15313
|
+
},
|
|
15314
|
+
{
|
|
15315
|
+
glyphFormat: "%9.",
|
|
15316
|
+
glyphType: 7
|
|
15317
|
+
}
|
|
15318
|
+
])
|
|
15319
|
+
},
|
|
15320
|
+
["ORDER_LIST_1"]: {
|
|
15321
|
+
listType: "ORDER_LIST",
|
|
15322
|
+
nestingLevel: orderListFactory([
|
|
15323
|
+
{
|
|
15324
|
+
glyphFormat: "%1)",
|
|
15325
|
+
glyphType: 2
|
|
15326
|
+
},
|
|
15327
|
+
{
|
|
15328
|
+
glyphFormat: "%2)",
|
|
15329
|
+
glyphType: 5
|
|
15330
|
+
},
|
|
15331
|
+
{
|
|
15332
|
+
glyphFormat: "%3)",
|
|
15333
|
+
glyphType: 7
|
|
15334
|
+
},
|
|
15335
|
+
{
|
|
15336
|
+
glyphFormat: "%4)",
|
|
15337
|
+
glyphType: 2
|
|
15338
|
+
},
|
|
15339
|
+
{
|
|
15340
|
+
glyphFormat: "%5)",
|
|
15341
|
+
glyphType: 5
|
|
15342
|
+
},
|
|
15343
|
+
{
|
|
15344
|
+
glyphFormat: "%6)",
|
|
15345
|
+
glyphType: 7
|
|
15346
|
+
},
|
|
15347
|
+
{
|
|
15348
|
+
glyphFormat: "%7)",
|
|
15349
|
+
glyphType: 2
|
|
15350
|
+
},
|
|
15351
|
+
{
|
|
15352
|
+
glyphFormat: "%8)",
|
|
15353
|
+
glyphType: 5
|
|
15354
|
+
},
|
|
15355
|
+
{
|
|
15356
|
+
glyphFormat: "%9)",
|
|
15357
|
+
glyphType: 7
|
|
15358
|
+
}
|
|
15359
|
+
])
|
|
15360
|
+
},
|
|
15361
|
+
["ORDER_LIST_2"]: {
|
|
15362
|
+
listType: "ORDER_LIST",
|
|
15363
|
+
nestingLevel: orderListFactory([
|
|
15364
|
+
"%1.",
|
|
15365
|
+
"%1.%2.",
|
|
15366
|
+
"%1.%2.%3.",
|
|
15367
|
+
"%1.%2.%3.%4.",
|
|
15368
|
+
"%1.%2.%3.%4.%5.",
|
|
15369
|
+
"%1.%2.%3.%4.%5.%6.",
|
|
15370
|
+
"%1.%2.%3.%4.%5.%6.%7."
|
|
15371
|
+
].map((format) => ({
|
|
15372
|
+
glyphFormat: format,
|
|
15373
|
+
glyphType: 2
|
|
15374
|
+
})))
|
|
15375
|
+
},
|
|
15376
|
+
["ORDER_LIST_3"]: {
|
|
15377
|
+
listType: "ORDER_LIST",
|
|
15378
|
+
nestingLevel: orderListFactory([
|
|
15379
|
+
{
|
|
15380
|
+
glyphFormat: "%1.",
|
|
15381
|
+
glyphType: 4
|
|
15382
|
+
},
|
|
15383
|
+
{
|
|
15384
|
+
glyphFormat: "%2.",
|
|
15385
|
+
glyphType: 5
|
|
15386
|
+
},
|
|
15387
|
+
{
|
|
15388
|
+
glyphFormat: "%3.",
|
|
15389
|
+
glyphType: 7
|
|
15390
|
+
},
|
|
15391
|
+
{
|
|
15392
|
+
glyphFormat: "%4.",
|
|
15393
|
+
glyphType: 4
|
|
15394
|
+
},
|
|
15395
|
+
{
|
|
15396
|
+
glyphFormat: "%5.",
|
|
15397
|
+
glyphType: 5
|
|
15398
|
+
},
|
|
15399
|
+
{
|
|
15400
|
+
glyphFormat: "%6.",
|
|
15401
|
+
glyphType: 7
|
|
15402
|
+
},
|
|
15403
|
+
{
|
|
15404
|
+
glyphFormat: "%7.",
|
|
15405
|
+
glyphType: 4
|
|
15406
|
+
},
|
|
15407
|
+
{
|
|
15408
|
+
glyphFormat: "%8.",
|
|
15409
|
+
glyphType: 5
|
|
15410
|
+
},
|
|
15411
|
+
{
|
|
15412
|
+
glyphFormat: "%9.",
|
|
15413
|
+
glyphType: 7
|
|
15414
|
+
}
|
|
15415
|
+
])
|
|
15416
|
+
},
|
|
15417
|
+
["ORDER_LIST_4"]: {
|
|
15418
|
+
listType: "ORDER_LIST",
|
|
15419
|
+
nestingLevel: orderListFactory([
|
|
15420
|
+
{
|
|
15421
|
+
glyphFormat: "%1.",
|
|
15422
|
+
glyphType: 4
|
|
15423
|
+
},
|
|
15424
|
+
{
|
|
15425
|
+
glyphFormat: "%2.",
|
|
15426
|
+
glyphType: 2
|
|
15427
|
+
},
|
|
15428
|
+
{
|
|
15429
|
+
glyphFormat: "%3.",
|
|
15430
|
+
glyphType: 7
|
|
15431
|
+
},
|
|
15432
|
+
{
|
|
15433
|
+
glyphFormat: "%4.",
|
|
15434
|
+
glyphType: 4
|
|
15435
|
+
},
|
|
15436
|
+
{
|
|
15437
|
+
glyphFormat: "%5.",
|
|
15438
|
+
glyphType: 2
|
|
15439
|
+
},
|
|
15440
|
+
{
|
|
15441
|
+
glyphFormat: "%6.",
|
|
15442
|
+
glyphType: 7
|
|
15443
|
+
},
|
|
15444
|
+
{
|
|
15445
|
+
glyphFormat: "%7.",
|
|
15446
|
+
glyphType: 4
|
|
15447
|
+
},
|
|
15448
|
+
{
|
|
15449
|
+
glyphFormat: "%8.",
|
|
15450
|
+
glyphType: 2
|
|
15451
|
+
},
|
|
15452
|
+
{
|
|
15453
|
+
glyphFormat: "%9.",
|
|
15454
|
+
glyphType: 7
|
|
15455
|
+
}
|
|
15456
|
+
])
|
|
15457
|
+
},
|
|
15458
|
+
["ORDER_LIST_5"]: {
|
|
15459
|
+
listType: "ORDER_LIST",
|
|
15460
|
+
nestingLevel: orderListFactory([
|
|
15461
|
+
{
|
|
15462
|
+
glyphFormat: "%1.",
|
|
15463
|
+
glyphType: 3
|
|
15464
|
+
},
|
|
15465
|
+
{
|
|
15466
|
+
glyphFormat: "%2.",
|
|
15467
|
+
glyphType: 5
|
|
15468
|
+
},
|
|
15469
|
+
{
|
|
15470
|
+
glyphFormat: "%3.",
|
|
15471
|
+
glyphType: 7
|
|
15472
|
+
},
|
|
15473
|
+
{
|
|
15474
|
+
glyphFormat: "%4.",
|
|
15475
|
+
glyphType: 3
|
|
15476
|
+
},
|
|
15477
|
+
{
|
|
15478
|
+
glyphFormat: "%5.",
|
|
15479
|
+
glyphType: 5
|
|
15480
|
+
},
|
|
15481
|
+
{
|
|
15482
|
+
glyphFormat: "%6.",
|
|
15483
|
+
glyphType: 7
|
|
15484
|
+
},
|
|
15485
|
+
{
|
|
15486
|
+
glyphFormat: "%7.",
|
|
15487
|
+
glyphType: 3
|
|
15488
|
+
},
|
|
15489
|
+
{
|
|
15490
|
+
glyphFormat: "%8.",
|
|
15491
|
+
glyphType: 5
|
|
15492
|
+
},
|
|
15493
|
+
{
|
|
15494
|
+
glyphFormat: "%9.",
|
|
15495
|
+
glyphType: 7
|
|
15496
|
+
}
|
|
15497
|
+
])
|
|
15498
|
+
},
|
|
15499
|
+
["CHECK_LIST"]: {
|
|
15500
|
+
listType: "CHECK_LIST",
|
|
15501
|
+
nestingLevel: checkListFactory("☐")
|
|
15502
|
+
},
|
|
15503
|
+
["CHECK_LIST_CHECKED"]: {
|
|
15504
|
+
listType: "CHECK_LIST_CHECKED",
|
|
15505
|
+
nestingLevel: checkListFactory("☑", { st: { s: 1 } })
|
|
15217
15506
|
}
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
}
|
|
15507
|
+
};
|
|
15508
|
+
const generateOrderList = (opt) => {
|
|
15509
|
+
const { glyphFormat, glyphType } = opt;
|
|
15510
|
+
const data = Tools.deepClone(PRESET_LIST_TYPE["ORDER_LIST"]);
|
|
15511
|
+
data.nestingLevel[0].glyphFormat = glyphFormat;
|
|
15512
|
+
data.nestingLevel[0].glyphType = glyphType;
|
|
15513
|
+
return data;
|
|
15514
|
+
};
|
|
15515
|
+
const QUICK_LIST_TYPE = {
|
|
15516
|
+
["ORDER_LIST_QUICK_2"]: generateOrderList(orderListSymbolMap["a)"]),
|
|
15517
|
+
["ORDER_LIST_QUICK_3"]: generateOrderList(orderListSymbolMap["a."]),
|
|
15518
|
+
["ORDER_LIST_QUICK_4"]: generateOrderList(orderListSymbolMap["i."]),
|
|
15519
|
+
["ORDER_LIST_QUICK_6"]: generateOrderList(orderListSymbolMap["I."])
|
|
15520
|
+
};
|
|
15521
|
+
Object.assign(PRESET_LIST_TYPE, QUICK_LIST_TYPE);
|
|
15522
|
+
const QuickListTypeMap = {
|
|
15523
|
+
["1."]: "ORDER_LIST",
|
|
15524
|
+
["a)"]: "ORDER_LIST_QUICK_2",
|
|
15525
|
+
["a."]: "ORDER_LIST_QUICK_3",
|
|
15526
|
+
["i."]: "ORDER_LIST_QUICK_4",
|
|
15527
|
+
["A."]: "ORDER_LIST_3",
|
|
15528
|
+
["I."]: "ORDER_LIST_QUICK_6",
|
|
15529
|
+
["01."]: "ORDER_LIST_5",
|
|
15530
|
+
["*"]: "BULLET_LIST"
|
|
15531
|
+
};
|
|
15221
15532
|
|
|
15222
15533
|
// src/docs/data-model/text-x/build-utils/selection.ts
|
|
15223
15534
|
function makeSelection(startOffset, endOffset) {
|
|
@@ -15297,28 +15608,45 @@ const switchParagraphBullet = (params) => {
|
|
|
15297
15608
|
const { paragraphs: currentParagraphs, segmentId, document: docDataModel } = params;
|
|
15298
15609
|
let listType = params.listType;
|
|
15299
15610
|
const paragraphs = ((_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf === void 0 || (_docDataModel$getSelf = _docDataModel$getSelf.getBody()) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.paragraphs) ?? [];
|
|
15611
|
+
const snapshot = docDataModel.getSnapshot();
|
|
15300
15612
|
const isAlreadyList = currentParagraphs.every((paragraph) => {
|
|
15301
|
-
var
|
|
15302
|
-
return ((
|
|
15613
|
+
var _resolveDocumentParag;
|
|
15614
|
+
return ((_resolveDocumentParag = resolveDocumentParagraphBullet(snapshot, paragraph)) === null || _resolveDocumentParag === void 0 ? void 0 : _resolveDocumentParag.listType.indexOf(listType)) === 0;
|
|
15303
15615
|
});
|
|
15304
15616
|
let listId = generateRandomId(6);
|
|
15305
15617
|
if (currentParagraphs.length === 1) {
|
|
15306
15618
|
const curIndex = paragraphs.indexOf(currentParagraphs[0]);
|
|
15307
15619
|
const prevParagraph = paragraphs[curIndex - 1];
|
|
15308
15620
|
const nextParagraph = paragraphs[curIndex + 1];
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15621
|
+
const previousBullet = prevParagraph && resolveDocumentParagraphBullet(snapshot, prevParagraph);
|
|
15622
|
+
const nextBullet = nextParagraph && resolveDocumentParagraphBullet(snapshot, nextParagraph);
|
|
15623
|
+
if (previousBullet && previousBullet.listType.indexOf(listType) === 0) {
|
|
15624
|
+
listId = previousBullet.listId;
|
|
15625
|
+
if (listType !== "CHECK_LIST") listType = previousBullet.listType;
|
|
15626
|
+
} else if (nextBullet && nextBullet.listType.indexOf(listType) === 0) {
|
|
15627
|
+
listId = nextBullet.listId;
|
|
15628
|
+
if (listType !== "CHECK_LIST") listType = nextBullet.listType;
|
|
15315
15629
|
}
|
|
15316
15630
|
}
|
|
15317
15631
|
const memoryCursor = new MemoryCursor();
|
|
15318
15632
|
memoryCursor.reset();
|
|
15319
15633
|
const textX = new TextX();
|
|
15320
15634
|
for (const paragraph of currentParagraphs) {
|
|
15321
|
-
const { startIndex
|
|
15635
|
+
const { startIndex } = paragraph;
|
|
15636
|
+
const bullet = resolveDocumentParagraphBullet(snapshot, paragraph);
|
|
15637
|
+
const update = {
|
|
15638
|
+
...paragraph,
|
|
15639
|
+
startIndex: 0,
|
|
15640
|
+
paragraphStyle: paragraph.paragraphStyle ?? {}
|
|
15641
|
+
};
|
|
15642
|
+
if (isAlreadyList) {
|
|
15643
|
+
if (resolveDocumentParagraphBullet(snapshot, { styleId: paragraph.styleId })) update.bullet = null;
|
|
15644
|
+
else delete update.bullet;
|
|
15645
|
+
} else update.bullet = {
|
|
15646
|
+
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15647
|
+
listType,
|
|
15648
|
+
listId
|
|
15649
|
+
};
|
|
15322
15650
|
textX.push({
|
|
15323
15651
|
t: "r",
|
|
15324
15652
|
len: startIndex - memoryCursor.cursor
|
|
@@ -15328,20 +15656,7 @@ const switchParagraphBullet = (params) => {
|
|
|
15328
15656
|
len: 1,
|
|
15329
15657
|
body: {
|
|
15330
15658
|
dataStream: "",
|
|
15331
|
-
paragraphs: [
|
|
15332
|
-
paragraphId,
|
|
15333
|
-
paragraphStyle,
|
|
15334
|
-
startIndex: 0
|
|
15335
|
-
} : {
|
|
15336
|
-
startIndex: 0,
|
|
15337
|
-
paragraphId,
|
|
15338
|
-
paragraphStyle: { ...paragraphStyle },
|
|
15339
|
-
bullet: {
|
|
15340
|
-
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
15341
|
-
listType,
|
|
15342
|
-
listId
|
|
15343
|
-
}
|
|
15344
|
-
}]
|
|
15659
|
+
paragraphs: [update]
|
|
15345
15660
|
},
|
|
15346
15661
|
coverType: 1
|
|
15347
15662
|
});
|
|
@@ -15355,12 +15670,13 @@ const toggleChecklistParagraph = (params) => {
|
|
|
15355
15670
|
const paragraphs = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 || (_docDataModel$getSelf2 = _docDataModel$getSelf2.getBody()) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.paragraphs;
|
|
15356
15671
|
if (paragraphs == null) return false;
|
|
15357
15672
|
const currentParagraph = paragraphs.find((p) => p.startIndex === paragraphIndex);
|
|
15358
|
-
|
|
15673
|
+
const bullet = currentParagraph && resolveDocumentParagraphBullet(docDataModel.getSnapshot(), currentParagraph);
|
|
15674
|
+
if (!currentParagraph || !bullet || bullet.listType.indexOf("CHECK_LIST") === -1) return false;
|
|
15359
15675
|
const memoryCursor = new MemoryCursor();
|
|
15360
15676
|
memoryCursor.reset();
|
|
15361
15677
|
const textX = new TextX();
|
|
15362
15678
|
const { startIndex, paragraphStyle = {} } = currentParagraph;
|
|
15363
|
-
const listType =
|
|
15679
|
+
const listType = bullet.listType === "CHECK_LIST" ? "CHECK_LIST_CHECKED" : "CHECK_LIST";
|
|
15364
15680
|
textX.push({
|
|
15365
15681
|
t: "r",
|
|
15366
15682
|
len: startIndex - memoryCursor.cursor
|
|
@@ -15394,7 +15710,8 @@ const setParagraphBullet = (params) => {
|
|
|
15394
15710
|
memoryCursor.reset();
|
|
15395
15711
|
const textX = new TextX();
|
|
15396
15712
|
for (const paragraph of currentParagraphs) {
|
|
15397
|
-
const { startIndex,
|
|
15713
|
+
const { startIndex, paragraphStyle = {} } = paragraph;
|
|
15714
|
+
const bullet = resolveDocumentParagraphBullet(docDataModel.getSnapshot(), paragraph);
|
|
15398
15715
|
textX.push({
|
|
15399
15716
|
t: "r",
|
|
15400
15717
|
len: startIndex - memoryCursor.cursor
|
|
@@ -15405,8 +15722,8 @@ const setParagraphBullet = (params) => {
|
|
|
15405
15722
|
body: {
|
|
15406
15723
|
dataStream: "",
|
|
15407
15724
|
paragraphs: [{
|
|
15725
|
+
...paragraph,
|
|
15408
15726
|
startIndex: 0,
|
|
15409
|
-
paragraphId,
|
|
15410
15727
|
paragraphStyle,
|
|
15411
15728
|
bullet: {
|
|
15412
15729
|
nestingLevel: (bullet === null || bullet === void 0 ? void 0 : bullet.nestingLevel) ?? 0,
|
|
@@ -15481,7 +15798,8 @@ const changeParagraphBulletNestLevel = (params) => {
|
|
|
15481
15798
|
...customLists
|
|
15482
15799
|
};
|
|
15483
15800
|
for (const paragraph of currentParagraphs) {
|
|
15484
|
-
const { startIndex,
|
|
15801
|
+
const { startIndex, paragraphStyle = {} } = paragraph;
|
|
15802
|
+
const bullet = resolveDocumentParagraphBullet(docDataModel.getSnapshot(), paragraph);
|
|
15485
15803
|
const isInTable = hasParagraphInTable(paragraph, tables);
|
|
15486
15804
|
textX.push({
|
|
15487
15805
|
t: "r",
|
|
@@ -15496,11 +15814,11 @@ const changeParagraphBulletNestLevel = (params) => {
|
|
|
15496
15814
|
body: {
|
|
15497
15815
|
dataStream: "",
|
|
15498
15816
|
paragraphs: [{
|
|
15817
|
+
...paragraph,
|
|
15499
15818
|
startIndex: 0,
|
|
15500
|
-
paragraphId,
|
|
15501
15819
|
paragraphStyle: { ...paragraphStyle },
|
|
15502
15820
|
bullet: {
|
|
15503
|
-
...bullet,
|
|
15821
|
+
...paragraph.bullet,
|
|
15504
15822
|
nestingLevel: Math.max(Math.min(bullet.nestingLevel + type, maxLevel), 0)
|
|
15505
15823
|
}
|
|
15506
15824
|
}]
|
|
@@ -15963,8 +16281,8 @@ function isUselessRetainAction(action) {
|
|
|
15963
16281
|
if ((_action$rangeUpdates = action.rangeUpdates) === null || _action$rangeUpdates === void 0 ? void 0 : _action$rangeUpdates.length) return false;
|
|
15964
16282
|
const { body } = action;
|
|
15965
16283
|
if (body == null) return true;
|
|
15966
|
-
const { textRuns, paragraphs, customRanges, customBlocks, docxRawCustomBlocks, docxRawBlocks, docxExportExcludedRanges, customDecorations, tables, columnGroups, blockRanges } = body;
|
|
15967
|
-
if (textRuns == null && paragraphs == null && customRanges == null && customBlocks == null && docxRawCustomBlocks == null && docxRawBlocks == null && docxExportExcludedRanges == null && customDecorations == null && tables == null && columnGroups == null && blockRanges == null) return true;
|
|
16284
|
+
const { textRuns, paragraphs, sectionBreaks, customRanges, customBlocks, docxRawCustomBlocks, docxRawBlocks, docxExportExcludedRanges, customDecorations, tables, columnGroups, blockRanges } = body;
|
|
16285
|
+
if (textRuns == null && paragraphs == null && sectionBreaks == null && customRanges == null && customBlocks == null && docxRawCustomBlocks == null && docxRawBlocks == null && docxExportExcludedRanges == null && customDecorations == null && tables == null && columnGroups == null && blockRanges == null) return true;
|
|
15968
16286
|
return false;
|
|
15969
16287
|
}
|
|
15970
16288
|
function getRichTextEditPath(docDataModel, segmentId = "") {
|
|
@@ -16653,6 +16971,64 @@ function withoutValueRangeMetadata(actions, suppressed) {
|
|
|
16653
16971
|
};
|
|
16654
16972
|
});
|
|
16655
16973
|
}
|
|
16974
|
+
function restoreComposedFieldRanges(inserted, changes, composed) {
|
|
16975
|
+
const complete = /* @__PURE__ */ new Map();
|
|
16976
|
+
for (const actions of [inserted, changes]) for (const action of actions) {
|
|
16977
|
+
if (action.t !== "i") continue;
|
|
16978
|
+
for (const range of action.body.customRanges ?? []) if (range.rangeType === 1 && action.body.dataStream[range.startIndex] === "" && action.body.dataStream[range.endIndex] === "") complete.set(range.rangeId, (complete.get(range.rangeId) ?? 0) + 1);
|
|
16979
|
+
}
|
|
16980
|
+
if (!complete.size) return composed;
|
|
16981
|
+
const fragments = /* @__PURE__ */ new Map();
|
|
16982
|
+
let offset = 0;
|
|
16983
|
+
for (const action of composed) {
|
|
16984
|
+
if (action.t === "i") for (const range of action.body.customRanges ?? []) {
|
|
16985
|
+
if (complete.get(range.rangeId) !== 1) continue;
|
|
16986
|
+
const startIndex = offset + range.startIndex;
|
|
16987
|
+
const endIndex = offset + range.endIndex;
|
|
16988
|
+
const previous = fragments.get(range.rangeId);
|
|
16989
|
+
if (previous) {
|
|
16990
|
+
previous.range.endIndex = endIndex;
|
|
16991
|
+
previous.endToken = action.body.dataStream[range.endIndex];
|
|
16992
|
+
previous.count++;
|
|
16993
|
+
} else fragments.set(range.rangeId, {
|
|
16994
|
+
range: {
|
|
16995
|
+
...Tools.deepClone(range),
|
|
16996
|
+
startIndex,
|
|
16997
|
+
endIndex
|
|
16998
|
+
},
|
|
16999
|
+
count: 1,
|
|
17000
|
+
startToken: action.body.dataStream[range.startIndex],
|
|
17001
|
+
endToken: action.body.dataStream[range.endIndex]
|
|
17002
|
+
});
|
|
17003
|
+
}
|
|
17004
|
+
if (action.t !== "d") offset += action.len;
|
|
17005
|
+
}
|
|
17006
|
+
const restored = [...fragments.values()].filter((item) => item.count > 1 && item.startToken === "" && item.endToken === "");
|
|
17007
|
+
if (!restored.length) return composed;
|
|
17008
|
+
const updates = new Map(getRangeUpdates(composed).map((update) => [update.rangeId, update]));
|
|
17009
|
+
const ids = new Set(restored.map(({ range }) => range.rangeId));
|
|
17010
|
+
const pending = new Set(ids);
|
|
17011
|
+
const actions = composed.map((action) => {
|
|
17012
|
+
var _action$body2;
|
|
17013
|
+
if (!((_action$body2 = action.body) === null || _action$body2 === void 0 || (_action$body2 = _action$body2.customRanges) === null || _action$body2 === void 0 ? void 0 : _action$body2.some((range) => ids.has(range.rangeId)))) return action;
|
|
17014
|
+
const body = {
|
|
17015
|
+
...action.body,
|
|
17016
|
+
customRanges: action.body.customRanges.filter((range) => !ids.has(range.rangeId) || pending.delete(range.rangeId))
|
|
17017
|
+
};
|
|
17018
|
+
if (!body.customRanges.length) Reflect.deleteProperty(body, "customRanges");
|
|
17019
|
+
return {
|
|
17020
|
+
...action,
|
|
17021
|
+
body
|
|
17022
|
+
};
|
|
17023
|
+
});
|
|
17024
|
+
return appendRangeUpdates(actions, restored.map(({ range }) => updates.has(range.rangeId) ? composeRangeUpdate({
|
|
17025
|
+
rangeId: range.rangeId,
|
|
17026
|
+
range
|
|
17027
|
+
}, updates.get(range.rangeId)) : {
|
|
17028
|
+
rangeId: range.rangeId,
|
|
17029
|
+
range
|
|
17030
|
+
}));
|
|
17031
|
+
}
|
|
16656
17032
|
function insertedAnchorPriority(first, second, priority) {
|
|
16657
17033
|
if ((first === null || first === void 0 ? void 0 : first.t) !== "i" || (second === null || second === void 0 ? void 0 : second.t) !== "i") return priority === "left";
|
|
16658
17034
|
const firstText = first.body.dataStream;
|
|
@@ -16663,12 +17039,14 @@ function insertedAnchorPriority(first, second, priority) {
|
|
|
16663
17039
|
return priority === "left";
|
|
16664
17040
|
}
|
|
16665
17041
|
function normalizeInsertActionParagraphIds(body, doc, currentIndex, reservedParagraphIds) {
|
|
16666
|
-
|
|
17042
|
+
var _body$paragraphs;
|
|
17043
|
+
const splitsParagraph = normalizeInsertedParagraphIdsForDocument(doc.paragraphs, body.paragraphs, currentIndex, {
|
|
16667
17044
|
freshenSplitParagraph: false,
|
|
16668
17045
|
preserveExplicitParagraphIds: Boolean(body[PRESERVE_INSERTED_PARAGRAPH_IDS]),
|
|
16669
17046
|
reservedParagraphIds,
|
|
16670
17047
|
dataStream: doc.dataStream
|
|
16671
17048
|
});
|
|
17049
|
+
if (((_body$paragraphs = body.paragraphs) === null || _body$paragraphs === void 0 ? void 0 : _body$paragraphs.length) && !splitsParagraph) Reflect.set(body, PRESERVE_INSERTED_PARAGRAPH_IDS, true);
|
|
16672
17050
|
}
|
|
16673
17051
|
var TextX = class TextX {
|
|
16674
17052
|
constructor() {
|
|
@@ -16685,7 +17063,7 @@ var TextX = class TextX {
|
|
|
16685
17063
|
const otherText = withoutRangeUpdates(otherActions);
|
|
16686
17064
|
const updates = new Map(moveRangeUpdates(thisUpdates, otherText).map((update) => [update.rangeId, update]));
|
|
16687
17065
|
for (const update of otherUpdates) updates.set(update.rangeId, composeRangeUpdate(updates.get(update.rangeId), update));
|
|
16688
|
-
return appendRangeUpdates(TextX.compose(thisText, otherText), Array.from(updates.values()));
|
|
17066
|
+
return restoreComposedFieldRanges(thisActions, otherActions, appendRangeUpdates(TextX.compose(thisText, otherText), Array.from(updates.values())));
|
|
16689
17067
|
}
|
|
16690
17068
|
const thisIter = new ActionIterator(thisActions);
|
|
16691
17069
|
const otherIter = new ActionIterator(otherActions);
|
|
@@ -16717,7 +17095,7 @@ var TextX = class TextX {
|
|
|
16717
17095
|
else if (thisAction.t === "i" && otherAction.t === "d") {}
|
|
16718
17096
|
}
|
|
16719
17097
|
textX.trimEndUselessRetainAction();
|
|
16720
|
-
return textX.serialize();
|
|
17098
|
+
return restoreComposedFieldRanges(thisActions, otherActions, textX.serialize());
|
|
16721
17099
|
}
|
|
16722
17100
|
/**
|
|
16723
17101
|
* |(this↓ \| other→) | **insert** | **retain** | **delete** |
|
|
@@ -16783,7 +17161,10 @@ var TextX = class TextX {
|
|
|
16783
17161
|
textX.push(otherAction);
|
|
16784
17162
|
continue;
|
|
16785
17163
|
}
|
|
16786
|
-
if (thisAction.body == null || otherAction.body == null) textX.push(
|
|
17164
|
+
if (thisAction.body == null || otherAction.body == null) textX.push({
|
|
17165
|
+
...otherAction,
|
|
17166
|
+
len: length
|
|
17167
|
+
});
|
|
16787
17168
|
else {
|
|
16788
17169
|
const { coverType, body } = transformBody(thisAction, otherAction, priority === "left");
|
|
16789
17170
|
textX.push({
|
|
@@ -16890,8 +17271,8 @@ var TextX = class TextX {
|
|
|
16890
17271
|
for (const field of Object.keys(body)) if (field !== "dataStream" && field !== "paragraphs" && action.body[field] == null) Reflect.deleteProperty(body, field);
|
|
16891
17272
|
if (action.body.paragraphs == null) delete body.paragraphs;
|
|
16892
17273
|
else {
|
|
16893
|
-
var _body$
|
|
16894
|
-
const previousParagraphs = new Map((_body$
|
|
17274
|
+
var _body$paragraphs2;
|
|
17275
|
+
const previousParagraphs = new Map((_body$paragraphs2 = body.paragraphs) === null || _body$paragraphs2 === void 0 ? void 0 : _body$paragraphs2.map((paragraph) => [paragraph.startIndex, paragraph]));
|
|
16895
17276
|
action.body.paragraphs = action.body.paragraphs.map((paragraph) => {
|
|
16896
17277
|
const previous = previousParagraphs.get(paragraph.startIndex);
|
|
16897
17278
|
if (!previous || paragraph.paragraphId != null && paragraph.paragraphId !== previous.paragraphId) return paragraph;
|
|
@@ -17141,6 +17522,21 @@ const fromPlainText = (text) => {
|
|
|
17141
17522
|
};
|
|
17142
17523
|
|
|
17143
17524
|
// src/docs/data-model/document-data-model.ts
|
|
17525
|
+
/**
|
|
17526
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
17527
|
+
*
|
|
17528
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17529
|
+
* you may not use this file except in compliance with the License.
|
|
17530
|
+
* You may obtain a copy of the License at
|
|
17531
|
+
*
|
|
17532
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17533
|
+
*
|
|
17534
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17535
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17536
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17537
|
+
* See the License for the specific language governing permissions and
|
|
17538
|
+
* limitations under the License.
|
|
17539
|
+
*/
|
|
17144
17540
|
const DEFAULT_DOC = {
|
|
17145
17541
|
id: "default_doc",
|
|
17146
17542
|
documentStyle: {}
|
|
@@ -17283,6 +17679,7 @@ var DocumentDataModelSimple = class extends UnitModel {
|
|
|
17283
17679
|
this._markMutation();
|
|
17284
17680
|
return;
|
|
17285
17681
|
}
|
|
17682
|
+
if ((width === void 0 || width === documentStyle.pageSize.width) && (height === void 0 || height === documentStyle.pageSize.height)) return;
|
|
17286
17683
|
if (width !== void 0) documentStyle.pageSize.width = width;
|
|
17287
17684
|
if (height !== void 0) documentStyle.pageSize.height = height;
|
|
17288
17685
|
this._markMutation();
|
|
@@ -17391,7 +17788,7 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
17391
17788
|
if (path[0] === "notes" && typeof path[1] === "string") changedNotes.add(path[1]);
|
|
17392
17789
|
if (path[0] === "styles" || path[0] === "documentStyle") changedInheritedNoteStyles = true;
|
|
17393
17790
|
});
|
|
17394
|
-
this.snapshot = JSONX.apply(this.snapshot, actions);
|
|
17791
|
+
this.snapshot = JSONX.apply(this.snapshot, Tools.deepClone(actions));
|
|
17395
17792
|
this._markMutation();
|
|
17396
17793
|
if (changedInheritedNoteStyles || previousNotes !== this.snapshot.notes || changedNotes.size > 0) this._initializeNoteModels(changedInheritedNoteStyles ? void 0 : previousNotes, changedNotes);
|
|
17397
17794
|
if (actions === null || actions === void 0 ? void 0 : actions.some((a) => Array.isArray(a) && ((a === null || a === void 0 ? void 0 : a[0]) === "headers" || (a === null || a === void 0 ? void 0 : a[0]) === "footers"))) {
|
|
@@ -17412,12 +17809,20 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
17412
17809
|
const { headers, footers } = this.getSnapshot();
|
|
17413
17810
|
if (headers) for (const headerId in headers) {
|
|
17414
17811
|
const header = headers[headerId];
|
|
17415
|
-
this.headerModelMap.set(headerId, new DocumentDataModel(
|
|
17812
|
+
this.headerModelMap.set(headerId, new DocumentDataModel({
|
|
17813
|
+
...header,
|
|
17814
|
+
documentStyle: this.snapshot.documentStyle,
|
|
17815
|
+
styles: this.snapshot.styles
|
|
17816
|
+
}));
|
|
17416
17817
|
this.headerModelMap.get(headerId).updateDocumentId(this.getUnitId());
|
|
17417
17818
|
}
|
|
17418
17819
|
if (footers) for (const footerId in footers) {
|
|
17419
17820
|
const footer = footers[footerId];
|
|
17420
|
-
this.footerModelMap.set(footerId, new DocumentDataModel(
|
|
17821
|
+
this.footerModelMap.set(footerId, new DocumentDataModel({
|
|
17822
|
+
...footer,
|
|
17823
|
+
documentStyle: this.snapshot.documentStyle,
|
|
17824
|
+
styles: this.snapshot.styles
|
|
17825
|
+
}));
|
|
17421
17826
|
this.footerModelMap.get(footerId).updateDocumentId(this.getUnitId());
|
|
17422
17827
|
}
|
|
17423
17828
|
}
|
|
@@ -17458,66 +17863,6 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
|
|
|
17458
17863
|
}
|
|
17459
17864
|
};
|
|
17460
17865
|
|
|
17461
|
-
// src/docs/data-model/paragraph-style.ts
|
|
17462
|
-
function _definedStyle(style) {
|
|
17463
|
-
if (style == null) return {};
|
|
17464
|
-
const definedStyle = Tools.deepClone(style);
|
|
17465
|
-
Tools.removeNull(definedStyle);
|
|
17466
|
-
return definedStyle;
|
|
17467
|
-
}
|
|
17468
|
-
function _resolveNamedParagraphStyle(styles, styleId) {
|
|
17469
|
-
if (!styles || !styleId) return {};
|
|
17470
|
-
const visiting = /* @__PURE__ */ new Set();
|
|
17471
|
-
const resolve = (currentStyleId) => {
|
|
17472
|
-
if (visiting.has(currentStyleId)) return {};
|
|
17473
|
-
const style = styles[currentStyleId];
|
|
17474
|
-
if (!style || style.type !== 1) return {};
|
|
17475
|
-
visiting.add(currentStyleId);
|
|
17476
|
-
const base = style.basedOn ? resolve(style.basedOn) : {};
|
|
17477
|
-
visiting.delete(currentStyleId);
|
|
17478
|
-
return {
|
|
17479
|
-
...base,
|
|
17480
|
-
..._definedStyle(style.paragraphStyle)
|
|
17481
|
-
};
|
|
17482
|
-
};
|
|
17483
|
-
return resolve(styleId);
|
|
17484
|
-
}
|
|
17485
|
-
function resolveDocumentParagraphStyle(documentStyle, paragraphStyle, options = {}) {
|
|
17486
|
-
const legacyStyle = options.useLegacyModernDefaults ?? (documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 2 ? {
|
|
17487
|
-
lineSpacing: DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,
|
|
17488
|
-
spaceAbove: { v: 0 },
|
|
17489
|
-
spaceBelow: { v: 12 }
|
|
17490
|
-
} : {};
|
|
17491
|
-
const documentDefaults = {
|
|
17492
|
-
...(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor) === 1 ? { widowControl: 1 } : {},
|
|
17493
|
-
...legacyStyle,
|
|
17494
|
-
..._definedStyle(documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.defaultParagraphStyle)
|
|
17495
|
-
};
|
|
17496
|
-
if (options.excludeDocumentOuterSpacing) {
|
|
17497
|
-
delete documentDefaults.spaceAbove;
|
|
17498
|
-
delete documentDefaults.spaceBelow;
|
|
17499
|
-
}
|
|
17500
|
-
const definedParagraphStyle = _definedStyle(paragraphStyle);
|
|
17501
|
-
const referencedParagraphStyle = _resolveNamedParagraphStyle(options.styles, options.paragraphStyleId);
|
|
17502
|
-
const namedStyleType = definedParagraphStyle.namedStyleType ?? referencedParagraphStyle.namedStyleType;
|
|
17503
|
-
const namedStyle = namedStyleType == null ? null : NAMED_STYLE_SPACE_MAP[namedStyleType];
|
|
17504
|
-
return Tools.deepClone({
|
|
17505
|
-
...documentDefaults,
|
|
17506
|
-
...namedStyle,
|
|
17507
|
-
...referencedParagraphStyle,
|
|
17508
|
-
...definedParagraphStyle
|
|
17509
|
-
});
|
|
17510
|
-
}
|
|
17511
|
-
/** Resolves word splitting without materializing inherited defaults in the snapshot. */
|
|
17512
|
-
function resolveDocumentParagraphWordWrap(document, paragraph) {
|
|
17513
|
-
const { documentStyle } = document;
|
|
17514
|
-
const { wordWrap } = resolveDocumentParagraphStyle(documentStyle, paragraph === null || paragraph === void 0 ? void 0 : paragraph.paragraphStyle, {
|
|
17515
|
-
styles: document.styles,
|
|
17516
|
-
paragraphStyleId: paragraph === null || paragraph === void 0 ? void 0 : paragraph.styleId
|
|
17517
|
-
});
|
|
17518
|
-
return wordWrap ?? 0;
|
|
17519
|
-
}
|
|
17520
|
-
|
|
17521
17866
|
// src/docs/data-model/replacement.ts
|
|
17522
17867
|
function replaceInDocumentBody(body, query, target, caseSensitive) {
|
|
17523
17868
|
if (query === "") return body;
|
|
@@ -17536,6 +17881,7 @@ function replaceInDocumentBody(body, query, target, caseSensitive) {
|
|
|
17536
17881
|
if (index > 0) textX.retain(index);
|
|
17537
17882
|
if (target.length > 0) {
|
|
17538
17883
|
var _sliceBody$customRang;
|
|
17884
|
+
documentDataModel.getBody().customDecorations ??= [];
|
|
17539
17885
|
const sliceBody = documentDataModel.sliceBody(index, index + queryLen);
|
|
17540
17886
|
const replaceBody = { dataStream: target };
|
|
17541
17887
|
if (Array.isArray(sliceBody === null || sliceBody === void 0 ? void 0 : sliceBody.textRuns) && sliceBody.textRuns.length) replaceBody.textRuns = [{
|
|
@@ -17676,8 +18022,8 @@ function getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeTy
|
|
|
17676
18022
|
function getSelectionForAddCustomRange(range, body) {
|
|
17677
18023
|
var _ranges$, _ranges;
|
|
17678
18024
|
const ranges = getIntersectingCustomRanges(range.startOffset, range.collapsed ? range.startOffset : range.endOffset - 1, body.customRanges ?? []);
|
|
17679
|
-
const startOffset = Math.min(range.startOffset, ((_ranges$ = ranges[0]) === null || _ranges$ === void 0 ? void 0 : _ranges$.startIndex) ??
|
|
17680
|
-
const endOffset = Math.max(range.endOffset, (((_ranges = ranges[ranges.length - 1]) === null || _ranges === void 0 ? void 0 : _ranges.endIndex) ?? -
|
|
18025
|
+
const startOffset = Math.min(range.startOffset, ((_ranges$ = ranges[0]) === null || _ranges$ === void 0 ? void 0 : _ranges$.startIndex) ?? 1e400);
|
|
18026
|
+
const endOffset = Math.max(range.endOffset, (((_ranges = ranges[ranges.length - 1]) === null || _ranges === void 0 ? void 0 : _ranges.endIndex) ?? -1e400) + 1);
|
|
17681
18027
|
return {
|
|
17682
18028
|
startOffset,
|
|
17683
18029
|
endOffset,
|
|
@@ -17733,8 +18079,8 @@ function addCustomRangeTextX(param) {
|
|
|
17733
18079
|
const addCustomRange = (startIndex, endIndex, index) => {
|
|
17734
18080
|
var _relativeCustomRanges, _relativeCustomRanges2;
|
|
17735
18081
|
const relativeCustomRanges = getIntersectingCustomRanges(startIndex, endIndex, customRanges, rangeType);
|
|
17736
|
-
const rangeStartIndex = Math.min(((_relativeCustomRanges = relativeCustomRanges[0]) === null || _relativeCustomRanges === void 0 ? void 0 : _relativeCustomRanges.startIndex) ??
|
|
17737
|
-
const rangeEndIndex = Math.max(((_relativeCustomRanges2 = relativeCustomRanges[relativeCustomRanges.length - 1]) === null || _relativeCustomRanges2 === void 0 ? void 0 : _relativeCustomRanges2.endIndex) ?? -
|
|
18082
|
+
const rangeStartIndex = Math.min(((_relativeCustomRanges = relativeCustomRanges[0]) === null || _relativeCustomRanges === void 0 ? void 0 : _relativeCustomRanges.startIndex) ?? 1e400, startIndex);
|
|
18083
|
+
const rangeEndIndex = Math.max(((_relativeCustomRanges2 = relativeCustomRanges[relativeCustomRanges.length - 1]) === null || _relativeCustomRanges2 === void 0 ? void 0 : _relativeCustomRanges2.endIndex) ?? -1e400, endIndex);
|
|
17738
18084
|
const customRange = {
|
|
17739
18085
|
rangeId: index ? `${rangeId}$${index}` : rangeId,
|
|
17740
18086
|
rangeType,
|
|
@@ -24335,8 +24681,8 @@ var Worksheet = class {
|
|
|
24335
24681
|
return this._columnManager.getVisibleCols(0, columnCount - 1);
|
|
24336
24682
|
}
|
|
24337
24683
|
/**
|
|
24338
|
-
*
|
|
24339
|
-
* @returns
|
|
24684
|
+
* Get the worksheet right-to-left view flag.
|
|
24685
|
+
* @returns {BooleanNumber} `BooleanNumber.TRUE` when the flag is enabled, otherwise `BooleanNumber.FALSE`.
|
|
24340
24686
|
*/
|
|
24341
24687
|
isRightToLeft() {
|
|
24342
24688
|
const { _snapshot: _config } = this;
|
|
@@ -25362,6 +25708,32 @@ function getLifecycleStagesAndBefore(lifecycleStage) {
|
|
|
25362
25708
|
*/
|
|
25363
25709
|
const ILocalStorageService = (0, _wendellhu_redi.createIdentifier)("ILocalStorageService");
|
|
25364
25710
|
|
|
25711
|
+
// src/services/locale/currency-symbol.ts
|
|
25712
|
+
const localeCurrencySymbolMap = /* @__PURE__ */ new Map([
|
|
25713
|
+
["enUS", "$"],
|
|
25714
|
+
["ruRU", "₽"],
|
|
25715
|
+
["viVN", "₫"],
|
|
25716
|
+
["zhCN", "¥"],
|
|
25717
|
+
["zhTW", "NT$"],
|
|
25718
|
+
["zhHK", "HK$"],
|
|
25719
|
+
["frFR", "€"],
|
|
25720
|
+
["faIR", "﷼"],
|
|
25721
|
+
["koKR", "₩"],
|
|
25722
|
+
["esES", "€"],
|
|
25723
|
+
["caES", "€"],
|
|
25724
|
+
["skSK", "€"],
|
|
25725
|
+
["jaJP", "¥"],
|
|
25726
|
+
["ptBR", "R$"],
|
|
25727
|
+
["deDE", "€"],
|
|
25728
|
+
["itIT", "€"],
|
|
25729
|
+
["idID", "Rp"],
|
|
25730
|
+
["plPL", "zł"],
|
|
25731
|
+
["arSA", "﷼"]
|
|
25732
|
+
]);
|
|
25733
|
+
function getCurrencySymbolByLocale(locale) {
|
|
25734
|
+
return localeCurrencySymbolMap.get(locale) || "$";
|
|
25735
|
+
}
|
|
25736
|
+
|
|
25365
25737
|
// src/services/locale/locale.service.ts
|
|
25366
25738
|
/**
|
|
25367
25739
|
* This service provides i18n and timezone / location features to other modules.
|
|
@@ -25634,6 +26006,20 @@ let LocalUndoRedoService = class LocalUndoRedoService extends Disposable {
|
|
|
25634
26006
|
this.disposeWithMe(this._commandService.registerCommand(RedoCommand));
|
|
25635
26007
|
this.disposeWithMe(toDisposable(() => this._undoRedoStatus$.complete()));
|
|
25636
26008
|
this.disposeWithMe(toDisposable(this._univerInstanceService.focused$.subscribe(() => this._updateStatus())));
|
|
26009
|
+
this.disposeWithMe(toDisposable(this._univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
26010
|
+
const unitId = unit.getUnitId();
|
|
26011
|
+
this._undoStacks.delete(unitId);
|
|
26012
|
+
this._redoStacks.delete(unitId);
|
|
26013
|
+
this._batchingStatus.delete(unitId);
|
|
26014
|
+
this._activeGroups.delete(unitId);
|
|
26015
|
+
this._updateStatus();
|
|
26016
|
+
})));
|
|
26017
|
+
this.disposeWithMe(toDisposable(() => {
|
|
26018
|
+
this._undoStacks.clear();
|
|
26019
|
+
this._redoStacks.clear();
|
|
26020
|
+
this._batchingStatus.clear();
|
|
26021
|
+
this._activeGroups.clear();
|
|
26022
|
+
}));
|
|
25637
26023
|
}
|
|
25638
26024
|
getUndoRedoStatus(unitId) {
|
|
25639
26025
|
var _this$_undoStacks$get, _this$_redoStacks$get;
|
|
@@ -29153,6 +29539,7 @@ Object.defineProperty(exports, "SkipSelf", {
|
|
|
29153
29539
|
});
|
|
29154
29540
|
exports.SliceBodyType = SliceBodyType;
|
|
29155
29541
|
exports.SpacingRule = SpacingRule;
|
|
29542
|
+
exports.SpecialCharacterKind = SpecialCharacterKind;
|
|
29156
29543
|
exports.Styles = Styles;
|
|
29157
29544
|
exports.TEXT_DECORATION_KEYS = TEXT_DECORATION_KEYS;
|
|
29158
29545
|
exports.TEXT_ROTATION_KEYS = TEXT_ROTATION_KEYS;
|
|
@@ -29322,6 +29709,7 @@ exports.getCellValueType = getCellValueType;
|
|
|
29322
29709
|
exports.getCellWithCoordByIndexCore = getCellWithCoordByIndexCore;
|
|
29323
29710
|
exports.getColorStyle = getColorStyle;
|
|
29324
29711
|
exports.getColumnGroupRangeInterval = getColumnGroupRangeInterval;
|
|
29712
|
+
exports.getCurrencySymbolByLocale = getCurrencySymbolByLocale;
|
|
29325
29713
|
exports.getCustomBlockIdsInSelections = getCustomBlockIdsInSelections;
|
|
29326
29714
|
exports.getCustomBlockInterval = getCustomBlockInterval;
|
|
29327
29715
|
exports.getCustomBlockSlice = getCustomBlockSlice;
|
|
@@ -29332,6 +29720,7 @@ exports.getDateSystemMaxSerial = getDateSystemMaxSerial;
|
|
|
29332
29720
|
exports.getDisplayValueFromCell = getDisplayValueFromCell;
|
|
29333
29721
|
exports.getDocsEmptySnapshot = getEmptySnapshot$1;
|
|
29334
29722
|
exports.getDocsUpdateBody = getDocsUpdateBody;
|
|
29723
|
+
exports.getDocumentParagraphStyleForUpdate = getDocumentParagraphStyleForUpdate;
|
|
29335
29724
|
exports.getDrawingOrderIndex = getDrawingOrderIndex;
|
|
29336
29725
|
exports.getEmptyCell = getEmptyCell;
|
|
29337
29726
|
exports.getExclusiveRangeInterval = getExclusiveRangeInterval;
|
|
@@ -29491,8 +29880,10 @@ exports.remove = remove;
|
|
|
29491
29880
|
exports.repeatStringNumTimes = repeatStringNumTimes;
|
|
29492
29881
|
exports.replaceInDocumentBody = replaceInDocumentBody;
|
|
29493
29882
|
exports.requestImmediateMacroTask = requestImmediateMacroTask;
|
|
29883
|
+
exports.resolveDocumentParagraphBullet = resolveDocumentParagraphBullet;
|
|
29494
29884
|
exports.resolveDocumentParagraphStyle = resolveDocumentParagraphStyle;
|
|
29495
29885
|
exports.resolveDocumentParagraphWordWrap = resolveDocumentParagraphWordWrap;
|
|
29886
|
+
exports.resolveDocumentTextStyle = resolveDocumentTextStyle;
|
|
29496
29887
|
exports.resolveSectionHeaderFooterReference = resolveSectionHeaderFooterReference;
|
|
29497
29888
|
exports.resolveSectionHeaderFooterReferences = resolveSectionHeaderFooterReferences;
|
|
29498
29889
|
exports.resolveWithBasePath = resolveWithBasePath;
|
|
@@ -29516,6 +29907,7 @@ Object.defineProperty(exports, "setDependencies", {
|
|
|
29516
29907
|
return _wendellhu_redi.setDependencies;
|
|
29517
29908
|
}
|
|
29518
29909
|
});
|
|
29910
|
+
exports.setTextDecorationLines = setTextDecorationLines;
|
|
29519
29911
|
Object.defineProperty(exports, "setWith", {
|
|
29520
29912
|
enumerable: true,
|
|
29521
29913
|
get: function () {
|