@univerjs/core 1.1.0 → 1.2.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 +2 -3
- package/lib/cjs/index.js +144 -52
- package/lib/es/facade.js +2 -3
- package/lib/es/index.js +141 -53
- package/lib/facade.js +2 -3
- package/lib/index.js +141 -53
- package/lib/types/docs/data-model/text-x/utils.d.ts +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/services/instance/instance.service.d.ts +1 -1
- package/lib/types/shared/record-value.d.ts +36 -0
- package/lib/types/shared/units.d.ts +19 -0
- package/lib/types/sheets/sheet-skeleton.d.ts +6 -2
- package/lib/types/types/interfaces/i-document-data.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +6 -6
- package/package.json +5 -5
package/lib/cjs/facade.js
CHANGED
|
@@ -39,10 +39,9 @@ var FBaseInitialable = class extends _univerjs_core.Disposable {
|
|
|
39
39
|
this._injector = _injector;
|
|
40
40
|
const Ctor = this.constructor;
|
|
41
41
|
if (Boolean(Ctor[ManualInitSymbol])) return;
|
|
42
|
-
const self = this;
|
|
43
42
|
const initializers = Object.getPrototypeOf(this)[InitializerSymbol$1];
|
|
44
|
-
if (initializers) initializers.forEach(
|
|
45
|
-
fn.apply(
|
|
43
|
+
if (initializers) initializers.forEach((fn) => {
|
|
44
|
+
fn.apply(this, [_injector]);
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
/**
|
package/lib/cjs/index.js
CHANGED
|
@@ -1699,7 +1699,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1699
1699
|
//#endregion
|
|
1700
1700
|
//#region package.json
|
|
1701
1701
|
var name = "@univerjs/core";
|
|
1702
|
-
var version = "1.
|
|
1702
|
+
var version = "1.2.0";
|
|
1703
1703
|
|
|
1704
1704
|
//#endregion
|
|
1705
1705
|
//#region src/common/array.ts
|
|
@@ -5804,7 +5804,7 @@ function datePartsToExcel1900Serial(year, month, day) {
|
|
|
5804
5804
|
return unixDays + (unixDays <= -25509 ? 25568 : 25569);
|
|
5805
5805
|
}
|
|
5806
5806
|
function excelSerialToDateTimeParts(serial, options) {
|
|
5807
|
-
if (!Number.isFinite(serial) || serial < 0) return null;
|
|
5807
|
+
if (!Number.isFinite(serial) || serial < 0 || serial >= getDateSystemMaxSerial(options.dateSystem) + 1) return null;
|
|
5808
5808
|
const wholeDays = Math.floor(serial);
|
|
5809
5809
|
const excel1900Serial = options.dateSystem === "date1904" ? wholeDays + EXCEL_1904_OFFSET : wholeDays;
|
|
5810
5810
|
const [year, month, day] = toYMD(excel1900Serial, 0, true);
|
|
@@ -14963,6 +14963,13 @@ function updateParagraphs(body, updateBody, textLength, currentIndex, coverType)
|
|
|
14963
14963
|
const { startIndex: removeStartIndex, paragraphId: removeParagraphId, paragraphStyle: removeParagraphStyle, bullet: removeBullet } = removeParagraph;
|
|
14964
14964
|
let newParagraphStyle;
|
|
14965
14965
|
let newBullet;
|
|
14966
|
+
const paragraphAttributes = coverType === 0 ? {
|
|
14967
|
+
...removeParagraph,
|
|
14968
|
+
...updateParagraph
|
|
14969
|
+
} : {
|
|
14970
|
+
...updateParagraph,
|
|
14971
|
+
...removeParagraph
|
|
14972
|
+
};
|
|
14966
14973
|
if (coverType === 0) {
|
|
14967
14974
|
newParagraphStyle = {
|
|
14968
14975
|
...removeParagraphStyle,
|
|
@@ -14992,10 +14999,11 @@ function updateParagraphs(body, updateBody, textLength, currentIndex, coverType)
|
|
|
14992
14999
|
}
|
|
14993
15000
|
if (updateStartIndex === removeStartIndex) {
|
|
14994
15001
|
splitUpdateParagraphs.push({
|
|
15002
|
+
...paragraphAttributes,
|
|
14995
15003
|
startIndex: updateStartIndex,
|
|
14996
15004
|
paragraphId: updateParagraphId ?? removeParagraphId,
|
|
14997
15005
|
paragraphStyle: newParagraphStyle,
|
|
14998
|
-
bullet: newBullet
|
|
15006
|
+
bullet: removeBullet == null && updateBullet == null ? void 0 : newBullet
|
|
14999
15007
|
});
|
|
15000
15008
|
break;
|
|
15001
15009
|
}
|
|
@@ -16067,7 +16075,7 @@ var ActionIterator = class {
|
|
|
16067
16075
|
return this.peekLength() < Number.POSITIVE_INFINITY;
|
|
16068
16076
|
}
|
|
16069
16077
|
next(length) {
|
|
16070
|
-
if (
|
|
16078
|
+
if (length === void 0) length = Number.POSITIVE_INFINITY;
|
|
16071
16079
|
const nextAction = this._actions[this._index];
|
|
16072
16080
|
if (nextAction) {
|
|
16073
16081
|
const offset = this._offset;
|
|
@@ -16607,6 +16615,21 @@ function transformParagraph(originParagraph, targetParagraph, originCoverType, t
|
|
|
16607
16615
|
else if (originParagraph.bullet === void 0) paragraph.bullet = Tools.deepClone(targetParagraph.bullet);
|
|
16608
16616
|
else if (originCoverType === 1 || targetCoverType === 1) paragraph.bullet = transformType === 0 && targetParagraph.bullet ? Tools.deepClone(targetParagraph.bullet) : Tools.deepClone(originParagraph.bullet);
|
|
16609
16617
|
else if (transformType === 0 && targetParagraph.bullet !== void 0) paragraph.bullet = Tools.deepClone(targetParagraph.bullet);
|
|
16618
|
+
for (const key of [
|
|
16619
|
+
"headingCollapsed",
|
|
16620
|
+
"styleId",
|
|
16621
|
+
"sourceBullet",
|
|
16622
|
+
"directBullet"
|
|
16623
|
+
]) {
|
|
16624
|
+
const origin = originParagraph[key];
|
|
16625
|
+
const target = targetParagraph[key];
|
|
16626
|
+
let value;
|
|
16627
|
+
if (originCoverType === 1 && targetCoverType === 1) value = transformType === 1 ? origin : target;
|
|
16628
|
+
else if (origin === void 0) value = target;
|
|
16629
|
+
else if (originCoverType === 1 || targetCoverType === 1) value = transformType === 0 && target !== void 0 ? target : origin;
|
|
16630
|
+
else if (transformType === 0) value = target;
|
|
16631
|
+
if (value !== void 0) Object.assign(paragraph, { [key]: Tools.deepClone(value) });
|
|
16632
|
+
}
|
|
16610
16633
|
if (paragraph.bullet === void 0) delete paragraph.bullet;
|
|
16611
16634
|
return paragraph;
|
|
16612
16635
|
}
|
|
@@ -16944,11 +16967,7 @@ var TextX = class TextX {
|
|
|
16944
16967
|
}
|
|
16945
16968
|
if (action.t === "r" && action.body != null) {
|
|
16946
16969
|
const body = getBodySlice(doc, index, index + action.len, true);
|
|
16947
|
-
for (const field of [
|
|
16948
|
-
"tables",
|
|
16949
|
-
"columnGroups",
|
|
16950
|
-
"blockRanges"
|
|
16951
|
-
]) if (action.body[field] == null) delete body[field];
|
|
16970
|
+
for (const field of Object.keys(body)) if (field !== "dataStream" && field !== "paragraphs" && action.body[field] == null) Reflect.deleteProperty(body, field);
|
|
16952
16971
|
if (action.body.paragraphs == null) delete body.paragraphs;
|
|
16953
16972
|
else {
|
|
16954
16973
|
var _body$paragraphs;
|
|
@@ -25267,8 +25286,7 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
|
|
|
25267
25286
|
}
|
|
25268
25287
|
}
|
|
25269
25288
|
_tryResetFocusOnRemoval(unitId) {
|
|
25270
|
-
|
|
25271
|
-
if (((_this$focused3 = this.focused) === null || _this$focused3 === void 0 ? void 0 : _this$focused3.getUnitId()) === unitId) this._focused$.next(null);
|
|
25289
|
+
if (this._focused$.getValue() === unitId) this.focusUnit(null);
|
|
25272
25290
|
}
|
|
25273
25291
|
_getUnitById(unitId) {
|
|
25274
25292
|
for (const [type, units] of this._unitsByType) {
|
|
@@ -27201,6 +27219,69 @@ var RTree = class {
|
|
|
27201
27219
|
}
|
|
27202
27220
|
};
|
|
27203
27221
|
|
|
27222
|
+
//#endregion
|
|
27223
|
+
//#region src/types/enum/record-filter.ts
|
|
27224
|
+
/**
|
|
27225
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
27226
|
+
*
|
|
27227
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27228
|
+
* you may not use this file except in compliance with the License.
|
|
27229
|
+
* You may obtain a copy of the License at
|
|
27230
|
+
*
|
|
27231
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27232
|
+
*
|
|
27233
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27234
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27235
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27236
|
+
* See the License for the specific language governing permissions and
|
|
27237
|
+
* limitations under the License.
|
|
27238
|
+
*/
|
|
27239
|
+
/** Typed record identities shared by compact Table and external report filters. */
|
|
27240
|
+
let RecordValueType = /* @__PURE__ */ function(RecordValueType) {
|
|
27241
|
+
RecordValueType["Blank"] = "blank";
|
|
27242
|
+
RecordValueType["String"] = "string";
|
|
27243
|
+
RecordValueType["Number"] = "number";
|
|
27244
|
+
RecordValueType["Date"] = "date";
|
|
27245
|
+
RecordValueType["Boolean"] = "boolean";
|
|
27246
|
+
RecordValueType["Error"] = "error";
|
|
27247
|
+
return RecordValueType;
|
|
27248
|
+
}({});
|
|
27249
|
+
/** Values are wire identifiers; an absent native Table filter represents All. */
|
|
27250
|
+
let FilterSelectionMode = /* @__PURE__ */ function(FilterSelectionMode) {
|
|
27251
|
+
FilterSelectionMode["All"] = "all";
|
|
27252
|
+
FilterSelectionMode["Include"] = "include";
|
|
27253
|
+
FilterSelectionMode["Exclude"] = "exclude";
|
|
27254
|
+
return FilterSelectionMode;
|
|
27255
|
+
}({});
|
|
27256
|
+
|
|
27257
|
+
//#endregion
|
|
27258
|
+
//#region src/shared/record-value.ts
|
|
27259
|
+
function getRecordValueKey(_value) {
|
|
27260
|
+
const value = _value;
|
|
27261
|
+
if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Invalid record value.");
|
|
27262
|
+
switch (value.type) {
|
|
27263
|
+
case "blank":
|
|
27264
|
+
if ("value" in value) throw new TypeError("Blank record values cannot have a value.");
|
|
27265
|
+
return "[\"blank\"]";
|
|
27266
|
+
case "string":
|
|
27267
|
+
case "error":
|
|
27268
|
+
if (typeof value.value !== "string") throw new TypeError("Invalid record value.");
|
|
27269
|
+
return JSON.stringify([value.type, value.value]);
|
|
27270
|
+
case "boolean":
|
|
27271
|
+
if (typeof value.value !== "boolean") throw new TypeError("Invalid record value.");
|
|
27272
|
+
return JSON.stringify([value.type, value.value]);
|
|
27273
|
+
case "number":
|
|
27274
|
+
case "date":
|
|
27275
|
+
if (typeof value.value !== "number") throw new TypeError("Invalid record value.");
|
|
27276
|
+
if (!Number.isFinite(value.value)) throw new RangeError("Record numeric values must be finite.");
|
|
27277
|
+
return JSON.stringify([value.type, value.value === 0 ? 0 : value.value]);
|
|
27278
|
+
default: throw new TypeError("Unknown record value type.");
|
|
27279
|
+
}
|
|
27280
|
+
}
|
|
27281
|
+
function isRecord(value) {
|
|
27282
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27283
|
+
}
|
|
27284
|
+
|
|
27204
27285
|
//#endregion
|
|
27205
27286
|
//#region src/shared/timer.ts
|
|
27206
27287
|
/**
|
|
@@ -27247,6 +27328,32 @@ function delayAnimationFrame(frames = 1) {
|
|
|
27247
27328
|
});
|
|
27248
27329
|
}
|
|
27249
27330
|
|
|
27331
|
+
//#endregion
|
|
27332
|
+
//#region src/shared/units.ts
|
|
27333
|
+
/**
|
|
27334
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
27335
|
+
*
|
|
27336
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27337
|
+
* you may not use this file except in compliance with the License.
|
|
27338
|
+
* You may obtain a copy of the License at
|
|
27339
|
+
*
|
|
27340
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27341
|
+
*
|
|
27342
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27343
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27344
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27345
|
+
* See the License for the specific language governing permissions and
|
|
27346
|
+
* limitations under the License.
|
|
27347
|
+
*/
|
|
27348
|
+
/** English Metric Units per CSS pixel at 96 DPI. */
|
|
27349
|
+
const EMU_PER_CSS_PX = 9525;
|
|
27350
|
+
function cssPxToEmu(value) {
|
|
27351
|
+
return Math.round(value * EMU_PER_CSS_PX);
|
|
27352
|
+
}
|
|
27353
|
+
function emuToCssPx(value) {
|
|
27354
|
+
return value / EMU_PER_CSS_PX;
|
|
27355
|
+
}
|
|
27356
|
+
|
|
27250
27357
|
//#endregion
|
|
27251
27358
|
//#region src/sheets/clone.ts
|
|
27252
27359
|
/**
|
|
@@ -27473,6 +27580,21 @@ Skeleton = __decorate([__decorateParam(0, (0, _wendellhu_redi.Inject)(LocaleServ
|
|
|
27473
27580
|
//#endregion
|
|
27474
27581
|
//#region src/sheets/sheet-skeleton.ts
|
|
27475
27582
|
/**
|
|
27583
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
27584
|
+
*
|
|
27585
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27586
|
+
* you may not use this file except in compliance with the License.
|
|
27587
|
+
* You may obtain a copy of the License at
|
|
27588
|
+
*
|
|
27589
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27590
|
+
*
|
|
27591
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27592
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27593
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27594
|
+
* See the License for the specific language governing permissions and
|
|
27595
|
+
* limitations under the License.
|
|
27596
|
+
*/
|
|
27597
|
+
/**
|
|
27476
27598
|
* Reusable gap fixture for visual and integration testing.
|
|
27477
27599
|
*/
|
|
27478
27600
|
function createSheetGapTestConfig(overrides = {}) {
|
|
@@ -28070,13 +28192,14 @@ let SheetSkeleton = class SheetSkeleton extends Skeleton {
|
|
|
28070
28192
|
};
|
|
28071
28193
|
}
|
|
28072
28194
|
/**
|
|
28073
|
-
*
|
|
28195
|
+
* Coordinates include the row and column headers. Defaults to the current viewport transform;
|
|
28196
|
+
* pass unit scales and zero scroll for Sheet model coordinates.
|
|
28074
28197
|
*/
|
|
28075
|
-
getCellIndexAndOffsetByPosition(offsetX, offsetY
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
});
|
|
28198
|
+
getCellIndexAndOffsetByPosition(offsetX, offsetY, scaleX = this._scaleX, scaleY = this._scaleY, scrollXY = {
|
|
28199
|
+
x: this._scrollX,
|
|
28200
|
+
y: this._scrollY
|
|
28201
|
+
}) {
|
|
28202
|
+
const { actualRow, actualColumn, startX, startY } = this.getCellWithCoordByOffset(offsetX, offsetY, scaleX, scaleY, scrollXY);
|
|
28080
28203
|
return {
|
|
28081
28204
|
row: actualRow,
|
|
28082
28205
|
rowOffset: offsetY - startY,
|
|
@@ -28462,41 +28585,6 @@ let DataValidationType = /* @__PURE__ */ function(DataValidationType) {
|
|
|
28462
28585
|
return DataValidationType;
|
|
28463
28586
|
}({});
|
|
28464
28587
|
|
|
28465
|
-
//#endregion
|
|
28466
|
-
//#region src/types/enum/record-filter.ts
|
|
28467
|
-
/**
|
|
28468
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
28469
|
-
*
|
|
28470
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
28471
|
-
* you may not use this file except in compliance with the License.
|
|
28472
|
-
* You may obtain a copy of the License at
|
|
28473
|
-
*
|
|
28474
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28475
|
-
*
|
|
28476
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
28477
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28478
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28479
|
-
* See the License for the specific language governing permissions and
|
|
28480
|
-
* limitations under the License.
|
|
28481
|
-
*/
|
|
28482
|
-
/** Typed record identities shared by compact Table and external report filters. */
|
|
28483
|
-
let RecordValueType = /* @__PURE__ */ function(RecordValueType) {
|
|
28484
|
-
RecordValueType["Blank"] = "blank";
|
|
28485
|
-
RecordValueType["String"] = "string";
|
|
28486
|
-
RecordValueType["Number"] = "number";
|
|
28487
|
-
RecordValueType["Date"] = "date";
|
|
28488
|
-
RecordValueType["Boolean"] = "boolean";
|
|
28489
|
-
RecordValueType["Error"] = "error";
|
|
28490
|
-
return RecordValueType;
|
|
28491
|
-
}({});
|
|
28492
|
-
/** Values are wire identifiers; an absent native Table filter represents All. */
|
|
28493
|
-
let FilterSelectionMode = /* @__PURE__ */ function(FilterSelectionMode) {
|
|
28494
|
-
FilterSelectionMode["All"] = "all";
|
|
28495
|
-
FilterSelectionMode["Include"] = "include";
|
|
28496
|
-
FilterSelectionMode["Exclude"] = "exclude";
|
|
28497
|
-
return FilterSelectionMode;
|
|
28498
|
-
}({});
|
|
28499
|
-
|
|
28500
28588
|
//#endregion
|
|
28501
28589
|
//#region src/services/resource-loader/resource-loader.service.ts
|
|
28502
28590
|
let ResourceLoaderService = class ResourceLoaderService extends Disposable {
|
|
@@ -28915,6 +29003,7 @@ exports.DocumentFlavor = DocumentFlavor;
|
|
|
28915
29003
|
exports.DocxBreakType = DocxBreakType;
|
|
28916
29004
|
exports.DrawingTypeEnum = DrawingTypeEnum;
|
|
28917
29005
|
exports.EDITOR_ACTIVATED = EDITOR_ACTIVATED;
|
|
29006
|
+
exports.EMU_PER_CSS_PX = EMU_PER_CSS_PX;
|
|
28918
29007
|
exports.EXCEL_1904_OFFSET = EXCEL_1904_OFFSET;
|
|
28919
29008
|
exports.EXTENSION_NAMES = EXTENSION_NAMES;
|
|
28920
29009
|
exports.ErrorService = ErrorService;
|
|
@@ -29287,6 +29376,7 @@ exports.createRandomId = createRandomId;
|
|
|
29287
29376
|
exports.createRowColIter = createRowColIter;
|
|
29288
29377
|
exports.createSectionId = createSectionId;
|
|
29289
29378
|
exports.createSheetGapTestConfig = createSheetGapTestConfig;
|
|
29379
|
+
exports.cssPxToEmu = cssPxToEmu;
|
|
29290
29380
|
exports.currencySymbols = currencySymbols;
|
|
29291
29381
|
exports.customNameCharacterCheck = customNameCharacterCheck;
|
|
29292
29382
|
exports.dateKit = dateKit;
|
|
@@ -29301,6 +29391,7 @@ exports.dedupeBy = dedupeBy;
|
|
|
29301
29391
|
exports.deepCompare = deepCompare;
|
|
29302
29392
|
exports.delayAnimationFrame = delayAnimationFrame;
|
|
29303
29393
|
exports.deleteContent = deleteContent;
|
|
29394
|
+
exports.emuToCssPx = emuToCssPx;
|
|
29304
29395
|
exports.excelDateSerial = excelDateSerial;
|
|
29305
29396
|
exports.excelDateTimePartsToSerial = excelDateTimePartsToSerial;
|
|
29306
29397
|
exports.excelDateTimeSerial = excelDateTimeSerial;
|
|
@@ -29360,6 +29451,7 @@ exports.getParagraphContentStartOffsets = getParagraphContentStartOffsets;
|
|
|
29360
29451
|
exports.getParagraphFollowingBlockOffset = getParagraphFollowingBlockOffset;
|
|
29361
29452
|
exports.getParagraphsSlice = getParagraphsSlice;
|
|
29362
29453
|
exports.getPlainText = getPlainText;
|
|
29454
|
+
exports.getRecordValueKey = getRecordValueKey;
|
|
29363
29455
|
exports.getReverseDirection = getReverseDirection;
|
|
29364
29456
|
exports.getRichTextEditPath = getRichTextEditPath;
|
|
29365
29457
|
exports.getSdtBindingKey = getSdtBindingKey;
|
package/lib/es/facade.js
CHANGED
|
@@ -38,10 +38,9 @@ var FBaseInitialable = class extends Disposable {
|
|
|
38
38
|
this._injector = _injector;
|
|
39
39
|
const Ctor = this.constructor;
|
|
40
40
|
if (Boolean(Ctor[ManualInitSymbol])) return;
|
|
41
|
-
const self = this;
|
|
42
41
|
const initializers = Object.getPrototypeOf(this)[InitializerSymbol$1];
|
|
43
|
-
if (initializers) initializers.forEach(
|
|
44
|
-
fn.apply(
|
|
42
|
+
if (initializers) initializers.forEach((fn) => {
|
|
43
|
+
fn.apply(this, [_injector]);
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
/**
|