@univerjs/core 1.0.0-alpha.0 → 1.0.0-alpha.2

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 CHANGED
@@ -69,7 +69,11 @@ var FBaseInitialable = class extends _univerjs_core.Disposable {
69
69
  this.prototype[InitializerSymbol$1] = initializers;
70
70
  }
71
71
  initializers.push(source.prototype._initialize);
72
- } else if (name !== "constructor") this.prototype[name] = source.prototype[name];
72
+ } else if (name !== "constructor") {
73
+ const descriptor = Object.getOwnPropertyDescriptor(source.prototype, name);
74
+ if (descriptor) Object.defineProperty(this.prototype, name, descriptor);
75
+ else this.prototype[name] = source.prototype[name];
76
+ }
73
77
  });
74
78
  Object.getOwnPropertyNames(source).forEach((name) => {
75
79
  if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];
package/lib/cjs/index.js CHANGED
@@ -640,10 +640,9 @@ function diffArrays(oneArray, twoArray) {
640
640
  }
641
641
  function diffObject(oneObject, twoObject) {
642
642
  const oneKeys = Object.keys(oneObject);
643
- const twoKeys = Object.keys(twoObject);
644
- if (oneKeys.length !== twoKeys.length) return false;
643
+ if (oneKeys.length !== Object.keys(twoObject).length) return false;
645
644
  for (const key of oneKeys) {
646
- if (!twoKeys.includes(key)) return false;
645
+ if (!Object.prototype.propertyIsEnumerable.call(twoObject, key)) return false;
647
646
  const oneValue = oneObject[key];
648
647
  const twoValue = twoObject[key];
649
648
  if (!isValueEqual(oneValue, twoValue)) return false;
@@ -787,11 +786,9 @@ var Tools = class Tools {
787
786
  return clone;
788
787
  }
789
788
  if (this.isObject(value)) {
789
+ const source = value;
790
790
  const clone = {};
791
- Object.keys(value).forEach((key) => {
792
- const item = value[key];
793
- clone[key] = Tools.deepClone(item);
794
- });
791
+ for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) clone[key] = Tools.deepClone(source[key]);
795
792
  Object.setPrototypeOf(clone, Object.getPrototypeOf(value));
796
793
  return clone;
797
794
  }
@@ -2926,6 +2923,18 @@ function generateRandomId(n = 21, alphabet) {
2926
2923
 
2927
2924
  //#endregion
2928
2925
  //#region src/types/interfaces/i-document-data.ts
2926
+ /**
2927
+ * The top-level block types in a document body.
2928
+ * These block types are used to represent the structure of the document and can be used to identify different sections or elements within the document.
2929
+ */
2930
+ let DocumentBlockType = /* @__PURE__ */ function(DocumentBlockType) {
2931
+ DocumentBlockType["PARAGRAPH"] = "paragraph";
2932
+ DocumentBlockType["BLOCK_RANGE"] = "blockRange";
2933
+ DocumentBlockType["TABLE"] = "table";
2934
+ DocumentBlockType["CUSTOM_BLOCK"] = "customBlock";
2935
+ DocumentBlockType["COLUMN_GROUP"] = "columnGroup";
2936
+ return DocumentBlockType;
2937
+ }({});
2929
2938
  let DocStyleType = /* @__PURE__ */ function(DocStyleType) {
2930
2939
  DocStyleType[DocStyleType["character"] = 0] = "character";
2931
2940
  DocStyleType[DocStyleType["paragraph"] = 1] = "paragraph";
@@ -3204,6 +3213,16 @@ let TableTextWrapType = /* @__PURE__ */ function(TableTextWrapType) {
3204
3213
  TableTextWrapType[TableTextWrapType["WRAP"] = 1] = "WRAP";
3205
3214
  return TableTextWrapType;
3206
3215
  }({});
3216
+ let ColumnLayoutType = /* @__PURE__ */ function(ColumnLayoutType) {
3217
+ ColumnLayoutType["FIXED"] = "fixed";
3218
+ ColumnLayoutType["AUTO"] = "auto";
3219
+ return ColumnLayoutType;
3220
+ }({});
3221
+ let ColumnResponsiveType = /* @__PURE__ */ function(ColumnResponsiveType) {
3222
+ ColumnResponsiveType["STACK"] = "stack";
3223
+ ColumnResponsiveType["SHRINK"] = "shrink";
3224
+ return ColumnResponsiveType;
3225
+ }({});
3207
3226
  let TableRowHeightRule = /* @__PURE__ */ function(TableRowHeightRule) {
3208
3227
  TableRowHeightRule[TableRowHeightRule["AUTO"] = 0] = "AUTO";
3209
3228
  TableRowHeightRule[TableRowHeightRule["AT_LEAST"] = 1] = "AT_LEAST";
@@ -3823,6 +3842,7 @@ function getEmptySnapshot$1(unitID = generateRandomId(6), locale = "enUS", title
3823
3842
  textRuns: [],
3824
3843
  customBlocks: [],
3825
3844
  tables: [],
3845
+ columnGroups: [],
3826
3846
  blockRanges: [],
3827
3847
  customRanges: [],
3828
3848
  customDecorations: [],
@@ -9290,7 +9310,7 @@ var RefAlias = class {
9290
9310
  setValue(key, attr, value) {
9291
9311
  const item = this.getValue(key);
9292
9312
  if (item) {
9293
- if (Object.keys(item).includes(attr)) item[attr] = value;
9313
+ if (Object.prototype.hasOwnProperty.call(item, attr)) item[attr] = value;
9294
9314
  }
9295
9315
  }
9296
9316
  deleteValue(key, keyGroup) {
@@ -9665,7 +9685,7 @@ function insertTables(body, insertBody, textLength, currentIndex) {
9665
9685
  for (let i = 0, len = tables.length; i < len; i++) {
9666
9686
  const table = tables[i];
9667
9687
  const { startIndex, endIndex } = table;
9668
- if (startIndex > currentIndex) {
9688
+ if (startIndex >= currentIndex) {
9669
9689
  table.startIndex += textLength;
9670
9690
  table.endIndex += textLength;
9671
9691
  } else if (endIndex > currentIndex) table.endIndex += textLength;
@@ -9681,6 +9701,30 @@ function insertTables(body, insertBody, textLength, currentIndex) {
9681
9701
  tables.sort(sortRulesFactory("startIndex"));
9682
9702
  }
9683
9703
  }
9704
+ function insertColumnGroups(body, insertBody, textLength, currentIndex) {
9705
+ var _insertBody$columnGro;
9706
+ if (!body.columnGroups && !((_insertBody$columnGro = insertBody.columnGroups) === null || _insertBody$columnGro === void 0 ? void 0 : _insertBody$columnGro.length)) return;
9707
+ if (!body.columnGroups) body.columnGroups = [];
9708
+ const { columnGroups } = body;
9709
+ for (let i = 0, len = columnGroups.length; i < len; i++) {
9710
+ const columnGroup = columnGroups[i];
9711
+ const { startIndex, endIndex } = columnGroup;
9712
+ if (startIndex >= currentIndex) {
9713
+ columnGroup.startIndex += textLength;
9714
+ columnGroup.endIndex += textLength;
9715
+ } else if (endIndex >= currentIndex) columnGroup.endIndex += textLength;
9716
+ }
9717
+ const insertColumnGroups = insertBody.columnGroups;
9718
+ if (insertColumnGroups) {
9719
+ for (let i = 0, len = insertColumnGroups.length; i < len; i++) {
9720
+ const columnGroup = insertColumnGroups[i];
9721
+ columnGroup.startIndex += currentIndex;
9722
+ columnGroup.endIndex += currentIndex;
9723
+ }
9724
+ columnGroups.push(...insertColumnGroups);
9725
+ columnGroups.sort(sortRulesFactory("startIndex"));
9726
+ }
9727
+ }
9684
9728
  function insertBlockRanges(body, insertBody, textLength, currentIndex) {
9685
9729
  var _insertBody$blockRang;
9686
9730
  if (!body.blockRanges && !((_insertBody$blockRang = insertBody.blockRanges) === null || _insertBody$blockRang === void 0 ? void 0 : _insertBody$blockRang.length)) return;
@@ -10012,6 +10056,39 @@ function deleteTables(body, textLength, currentIndex) {
10012
10056
  }
10013
10057
  return removeTables;
10014
10058
  }
10059
+ function deleteColumnGroups(body, textLength, currentIndex) {
10060
+ const { columnGroups } = body;
10061
+ const startIndex = currentIndex;
10062
+ const endIndex = currentIndex + textLength - 1;
10063
+ const removeColumnGroups = [];
10064
+ if (columnGroups) {
10065
+ const newColumnGroups = [];
10066
+ for (let i = 0, len = columnGroups.length; i < len; i++) {
10067
+ const columnGroup = columnGroups[i];
10068
+ const { startIndex: st, endIndex: ed } = columnGroup;
10069
+ if (startIndex <= st && endIndex >= ed) {
10070
+ removeColumnGroups.push({
10071
+ ...columnGroup,
10072
+ startIndex: st - currentIndex,
10073
+ endIndex: ed - currentIndex
10074
+ });
10075
+ continue;
10076
+ } else if (st <= startIndex && ed >= endIndex) {
10077
+ const segments = horizontalLineSegmentsSubtraction(st, ed, startIndex, endIndex);
10078
+ if (segments.length === 0) continue;
10079
+ columnGroup.startIndex = segments[0];
10080
+ columnGroup.endIndex = segments[1];
10081
+ if (columnGroup.startIndex === columnGroup.endIndex) continue;
10082
+ } else if (endIndex < st) {
10083
+ columnGroup.startIndex -= textLength;
10084
+ columnGroup.endIndex -= textLength;
10085
+ }
10086
+ newColumnGroups.push(columnGroup);
10087
+ }
10088
+ body.columnGroups = newColumnGroups;
10089
+ }
10090
+ return removeColumnGroups;
10091
+ }
10015
10092
  function deleteCustomRanges(body, textLength, currentIndex) {
10016
10093
  const { customRanges } = body;
10017
10094
  const startIndex = currentIndex;
@@ -10537,6 +10614,7 @@ function updateAttribute(body, updateBody, textLength, currentIndex, coverType)
10537
10614
  sectionBreaks: updateSectionBreaks(body, updateBody, textLength, currentIndex, coverType),
10538
10615
  customBlocks: updateCustomBlocks(body, updateBody, textLength, currentIndex, coverType),
10539
10616
  tables: updateTables(body, updateBody, textLength, currentIndex, coverType),
10617
+ columnGroups: updateColumnGroups(body, updateBody, textLength, currentIndex, coverType),
10540
10618
  blockRanges: updateBlockRanges(body, updateBody, textLength, currentIndex, coverType),
10541
10619
  customRanges: updateCustomRanges(body, updateBody, textLength, currentIndex, coverType),
10542
10620
  customDecorations: updateCustomDecorations(body, updateBody, textLength, currentIndex, coverType)
@@ -10783,6 +10861,38 @@ function updateTables(body, updateBody, textLength, currentIndex, coverType) {
10783
10861
  insertTables(body, updateBody, textLength, currentIndex);
10784
10862
  return removeTables;
10785
10863
  }
10864
+ function updateColumnGroups(body, updateBody, textLength, currentIndex, coverType) {
10865
+ const { columnGroups } = body;
10866
+ const { columnGroups: updateDataColumnGroups } = updateBody;
10867
+ if (columnGroups == null || updateDataColumnGroups == null) return;
10868
+ const removeColumnGroups = deleteColumnGroups(body, textLength, currentIndex);
10869
+ if (coverType !== 1) {
10870
+ const newUpdateColumnGroups = [];
10871
+ for (const updateColumnGroup of updateDataColumnGroups) {
10872
+ const { startIndex: updateStartIndex, endIndex: updateEndIndex } = updateColumnGroup;
10873
+ let splitUpdateColumnGroups = [];
10874
+ for (const removeColumnGroup of removeColumnGroups) {
10875
+ const { startIndex: removeStartIndex, endIndex: removeEndIndex } = removeColumnGroup;
10876
+ if (removeStartIndex >= updateStartIndex && removeEndIndex <= updateEndIndex) {
10877
+ if (coverType === 0) splitUpdateColumnGroups.push({
10878
+ ...removeColumnGroup,
10879
+ ...updateColumnGroup
10880
+ });
10881
+ else splitUpdateColumnGroups.push({
10882
+ ...updateColumnGroup,
10883
+ ...removeColumnGroup
10884
+ });
10885
+ break;
10886
+ }
10887
+ }
10888
+ newUpdateColumnGroups.push(...splitUpdateColumnGroups);
10889
+ splitUpdateColumnGroups = [];
10890
+ }
10891
+ updateBody.columnGroups = newUpdateColumnGroups;
10892
+ }
10893
+ insertColumnGroups(body, updateBody, textLength, currentIndex);
10894
+ return removeColumnGroups;
10895
+ }
10786
10896
  function updateBlockRanges(body, updateBody, textLength, currentIndex, coverType) {
10787
10897
  const { blockRanges } = body;
10788
10898
  const { blockRanges: updateDataBlockRanges } = updateBody;
@@ -10934,6 +11044,20 @@ function getBlockRangeSlice(body, startOffset, endOffset) {
10934
11044
  }
10935
11045
  return newBlockRanges;
10936
11046
  }
11047
+ function getColumnGroupSlice(body, startOffset, endOffset) {
11048
+ const { columnGroups = [] } = body;
11049
+ const newColumnGroups = [];
11050
+ for (const columnGroup of columnGroups) {
11051
+ const clonedColumnGroup = Tools.deepClone(columnGroup);
11052
+ const { startIndex, endIndex } = clonedColumnGroup;
11053
+ if (startIndex >= startOffset && endIndex < endOffset) newColumnGroups.push({
11054
+ ...clonedColumnGroup,
11055
+ startIndex: startIndex - startOffset,
11056
+ endIndex: endIndex - startOffset
11057
+ });
11058
+ }
11059
+ return newColumnGroups;
11060
+ }
10937
11061
  function getParagraphsSlice(body, startOffset, endOffset, type = 1) {
10938
11062
  const { paragraphs = [] } = body;
10939
11063
  const newParagraphs = [];
@@ -10996,6 +11120,8 @@ function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, typ
10996
11120
  if (newTables.length) docBody.tables = newTables;
10997
11121
  const newBlockRanges = getBlockRangeSlice(body, startOffset, endOffset);
10998
11122
  if (newBlockRanges.length) docBody.blockRanges = newBlockRanges;
11123
+ const newColumnGroups = getColumnGroupSlice(body, startOffset, endOffset);
11124
+ if (newColumnGroups.length) docBody.columnGroups = newColumnGroups;
10999
11125
  docBody.paragraphs = getParagraphsSlice(body, startOffset, endOffset, type);
11000
11126
  if (type === 1) {
11001
11127
  const customDecorations = getCustomDecorationSlice(body, startOffset, endOffset);
@@ -11009,7 +11135,7 @@ function getBodySlice(body, startOffset, endOffset, returnEmptyArray = true, typ
11009
11135
  return docBody;
11010
11136
  }
11011
11137
  function normalizeBody(body) {
11012
- const { dataStream, textRuns, paragraphs, customRanges, customDecorations, tables, blockRanges } = body;
11138
+ const { dataStream, textRuns, paragraphs, customRanges, customDecorations, tables, columnGroups, blockRanges } = body;
11013
11139
  let leftOffset = 0;
11014
11140
  let rightOffset = 0;
11015
11141
  customRanges === null || customRanges === void 0 || customRanges.forEach((range) => {
@@ -11040,6 +11166,10 @@ function normalizeBody(body) {
11040
11166
  table.startIndex += leftOffset;
11041
11167
  table.endIndex += rightOffset;
11042
11168
  });
11169
+ columnGroups === null || columnGroups === void 0 || columnGroups.forEach((columnGroup) => {
11170
+ columnGroup.startIndex += leftOffset;
11171
+ columnGroup.endIndex += rightOffset;
11172
+ });
11043
11173
  return {
11044
11174
  ...body,
11045
11175
  dataStream: newData,
@@ -11048,6 +11178,7 @@ function normalizeBody(body) {
11048
11178
  customRanges,
11049
11179
  customDecorations,
11050
11180
  tables,
11181
+ columnGroups,
11051
11182
  blockRanges
11052
11183
  };
11053
11184
  }
@@ -11110,8 +11241,8 @@ function composeCustomDecorations(updateDataCustomDecorations, originCustomDecor
11110
11241
  function composeBody(thisBody, otherBody, coverType = 0) {
11111
11242
  if (otherBody.dataStream !== "") throw new Error("Cannot compose other body with non-empty dataStream");
11112
11243
  const retBody = { dataStream: thisBody.dataStream };
11113
- const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations = [], blockRanges: thisBlockRanges = [] } = thisBody;
11114
- const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations = [], blockRanges: otherBlockRanges = [] } = otherBody;
11244
+ const { textRuns: thisTextRuns, paragraphs: thisParagraphs = [], customRanges: thisCustomRanges, customDecorations: thisCustomDecorations = [], columnGroups: thisColumnGroups = [], blockRanges: thisBlockRanges = [] } = thisBody;
11245
+ const { textRuns: otherTextRuns, paragraphs: otherParagraphs = [], customRanges: otherCustomRanges, customDecorations: otherCustomDecorations = [], columnGroups: otherColumnGroups = [], blockRanges: otherBlockRanges = [] } = otherBody;
11115
11246
  retBody.textRuns = composeTextRuns(otherTextRuns, thisTextRuns, coverType);
11116
11247
  retBody.customRanges = composeCustomRanges(otherCustomRanges, thisCustomRanges, coverType);
11117
11248
  const customDecorations = composeCustomDecorations(otherCustomDecorations, thisCustomDecorations, coverType);
@@ -11141,6 +11272,8 @@ function composeBody(thisBody, otherBody, coverType = 0) {
11141
11272
  if (paragraphs.length) retBody.paragraphs = paragraphs;
11142
11273
  const blockRanges = composeDocumentBlockRanges(thisBlockRanges, otherBlockRanges);
11143
11274
  if (blockRanges.length) retBody.blockRanges = blockRanges;
11275
+ const columnGroups = composeColumnGroups(thisColumnGroups, otherColumnGroups);
11276
+ if (columnGroups.length) retBody.columnGroups = columnGroups;
11144
11277
  return retBody;
11145
11278
  }
11146
11279
  function composeDocumentBlockRanges(thisRanges, otherRanges) {
@@ -11150,11 +11283,18 @@ function composeDocumentBlockRanges(thisRanges, otherRanges) {
11150
11283
  otherRanges.forEach((range) => byId.set(range.blockId, Tools.deepClone(range)));
11151
11284
  return Array.from(byId.values()).sort((left, right) => left.startIndex - right.startIndex);
11152
11285
  }
11286
+ function composeColumnGroups(thisRanges, otherRanges) {
11287
+ if (!thisRanges.length) return otherRanges;
11288
+ if (!otherRanges.length) return thisRanges;
11289
+ const byId = new Map(thisRanges.map((range) => [range.columnGroupId, Tools.deepClone(range)]));
11290
+ otherRanges.forEach((range) => byId.set(range.columnGroupId, Tools.deepClone(range)));
11291
+ return Array.from(byId.values()).sort((left, right) => left.startIndex - right.startIndex);
11292
+ }
11153
11293
  function isUselessRetainAction(action) {
11154
11294
  const { body } = action;
11155
11295
  if (body == null) return true;
11156
- const { textRuns, paragraphs, customRanges, customBlocks, customDecorations, tables, blockRanges } = body;
11157
- if (textRuns == null && paragraphs == null && customRanges == null && customBlocks == null && customDecorations == null && tables == null && blockRanges == null) return true;
11296
+ const { textRuns, paragraphs, customRanges, customBlocks, customDecorations, tables, columnGroups, blockRanges } = body;
11297
+ if (textRuns == null && paragraphs == null && customRanges == null && customBlocks == null && customDecorations == null && tables == null && columnGroups == null && blockRanges == null) return true;
11158
11298
  return false;
11159
11299
  }
11160
11300
  function getRichTextEditPath(docDataModel, segmentId = "") {
@@ -11257,6 +11397,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
11257
11397
  const removeSectionBreaks = deleteSectionBreaks(body, textLength, currentIndex);
11258
11398
  const removeCustomBlocks = deleteCustomBlocks(body, textLength, currentIndex);
11259
11399
  const removeTables = deleteTables(body, textLength, currentIndex);
11400
+ const removeColumnGroups = deleteColumnGroups(body, textLength, currentIndex);
11260
11401
  const removeBlockRanges = deleteBlockRanges(body, textLength, currentIndex);
11261
11402
  const removeCustomRanges = deleteCustomRanges(body, textLength, currentIndex);
11262
11403
  const removeCustomDecorations = deleteCustomDecorations(body, textLength, currentIndex);
@@ -11272,6 +11413,7 @@ function updateAttributeByDelete(body, textLength, currentIndex) {
11272
11413
  sectionBreaks: removeSectionBreaks,
11273
11414
  customBlocks: removeCustomBlocks,
11274
11415
  tables: removeTables,
11416
+ columnGroups: removeColumnGroups,
11275
11417
  blockRanges: removeBlockRanges,
11276
11418
  customRanges: removeCustomRanges,
11277
11419
  customDecorations: removeCustomDecorations
@@ -11287,6 +11429,7 @@ function updateAttributeByInsert(body, insertBody, textLength, currentIndex) {
11287
11429
  insertSectionBreaks(body, insertBody, textLength, currentIndex);
11288
11430
  insertCustomBlocks(body, insertBody, textLength, currentIndex);
11289
11431
  insertTables(body, insertBody, textLength, currentIndex);
11432
+ insertColumnGroups(body, insertBody, textLength, currentIndex);
11290
11433
  insertBlockRanges(body, insertBody, textLength, currentIndex);
11291
11434
  insertCustomRanges(body, insertBody, textLength, currentIndex);
11292
11435
  insertCustomDecorations(body, insertBody, textLength, currentIndex);
@@ -11898,6 +12041,8 @@ let DataStreamTreeNodeType = /* @__PURE__ */ function(DataStreamTreeNodeType) {
11898
12041
  DataStreamTreeNodeType["TABLE"] = "TABLE";
11899
12042
  DataStreamTreeNodeType["TABLE_ROW"] = "TABLE_ROW";
11900
12043
  DataStreamTreeNodeType["TABLE_CELL"] = "TABLE_CELL";
12044
+ DataStreamTreeNodeType["COLUMN_GROUP"] = "COLUMN_GROUP";
12045
+ DataStreamTreeNodeType["COLUMN"] = "COLUMN";
11901
12046
  DataStreamTreeNodeType["BLOCK"] = "BLOCK";
11902
12047
  DataStreamTreeNodeType["CUSTOM_BLOCK"] = "CUSTOM_BLOCK";
11903
12048
  return DataStreamTreeNodeType;
@@ -11911,6 +12056,10 @@ let DataStreamTreeTokenType = /* @__PURE__ */ function(DataStreamTreeTokenType)
11911
12056
  DataStreamTreeTokenType["TABLE_CELL_END"] = "";
11912
12057
  DataStreamTreeTokenType["TABLE_ROW_END"] = "";
11913
12058
  DataStreamTreeTokenType["TABLE_END"] = "";
12059
+ DataStreamTreeTokenType["COLUMN_GROUP_START"] = "";
12060
+ DataStreamTreeTokenType["COLUMN_START"] = "";
12061
+ DataStreamTreeTokenType["COLUMN_END"] = "";
12062
+ DataStreamTreeTokenType["COLUMN_GROUP_END"] = "";
11914
12063
  DataStreamTreeTokenType["BLOCK_START"] = "";
11915
12064
  DataStreamTreeTokenType["BLOCK_END"] = "";
11916
12065
  /**
@@ -12210,11 +12359,10 @@ var DocumentDataModel = class DocumentDataModel extends DocumentDataModelSimple
12210
12359
  this.change$.next(this.change$.value + 1);
12211
12360
  }
12212
12361
  getSelfOrHeaderFooterModel(segmentId) {
12213
- if (segmentId != null) {
12214
- if (this.headerModelMap.has(segmentId)) return this.headerModelMap.get(segmentId);
12215
- if (this.footerModelMap.has(segmentId)) return this.footerModelMap.get(segmentId);
12216
- }
12217
- return this;
12362
+ if (segmentId === null || segmentId === void 0 || segmentId === "") return this;
12363
+ if (this.headerModelMap.has(segmentId)) return this.headerModelMap.get(segmentId);
12364
+ if (this.footerModelMap.has(segmentId)) return this.footerModelMap.get(segmentId);
12365
+ return null;
12218
12366
  }
12219
12367
  getUnitId() {
12220
12368
  return this._unitId;
@@ -12384,7 +12532,7 @@ function getSelectionForAddCustomRange(range, body) {
12384
12532
  function deleteCustomRangeTextX(params) {
12385
12533
  var _documentDataModel$ge, _insert$dataStream$le;
12386
12534
  const { rangeId, segmentId, documentDataModel, insert } = params;
12387
- const range = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customRanges) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((r) => r.rangeId === rangeId);
12535
+ const range = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.getBody()) === null || _documentDataModel$ge === void 0 || (_documentDataModel$ge = _documentDataModel$ge.customRanges) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.find((r) => r.rangeId === rangeId);
12388
12536
  if (!range) return false;
12389
12537
  const { startIndex, endIndex } = range;
12390
12538
  const textX = new TextX();
@@ -12672,15 +12820,15 @@ function getCustomBlockIdsInSelections(body, selections) {
12672
12820
  return customBlockIds;
12673
12821
  }
12674
12822
  const addDrawing = (param) => {
12675
- var _documentDataModel$ge, _documentDataModel$ge2;
12823
+ var _documentDataModel$ge, _documentDataModel$ge2, _documentDataModel$ge3;
12676
12824
  const { selection, documentDataModel, drawings } = param;
12677
12825
  const { collapsed, startOffset, segmentId } = selection;
12678
12826
  const textX = new TextX();
12679
12827
  const jsonX = JSONX.getInstance();
12680
12828
  const rawActions = [];
12681
- const body = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
12829
+ const body = (_documentDataModel$ge = documentDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.getBody();
12682
12830
  if (!body) return false;
12683
- const drawingOrderLength = (_documentDataModel$ge = (_documentDataModel$ge2 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.length) !== null && _documentDataModel$ge !== void 0 ? _documentDataModel$ge : 0;
12831
+ const drawingOrderLength = (_documentDataModel$ge2 = (_documentDataModel$ge3 = documentDataModel.getSnapshot().drawingsOrder) === null || _documentDataModel$ge3 === void 0 ? void 0 : _documentDataModel$ge3.length) !== null && _documentDataModel$ge2 !== void 0 ? _documentDataModel$ge2 : 0;
12684
12832
  let removeDrawingLen = 0;
12685
12833
  const insertOffset = collapsed ? normalizeDrawingInsertOffset(body, startOffset !== null && startOffset !== void 0 ? startOffset : 0) : startOffset !== null && startOffset !== void 0 ? startOffset : 0;
12686
12834
  if (collapsed) {
@@ -12689,12 +12837,12 @@ const addDrawing = (param) => {
12689
12837
  len: insertOffset
12690
12838
  });
12691
12839
  } else {
12692
- var _documentDataModel$ge3, _documentDataModel$ge4;
12840
+ var _documentDataModel$ge4, _documentDataModel$ge5;
12693
12841
  const dos = deleteSelectionTextX([selection], body, 0, null, false);
12694
12842
  textX.push(...dos);
12695
12843
  const removedCustomBlockIds = getCustomBlockIdsInSelections(body, [selection]);
12696
- const drawings = (_documentDataModel$ge3 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : {};
12697
- const drawingOrder = (_documentDataModel$ge4 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : [];
12844
+ const drawings = (_documentDataModel$ge4 = documentDataModel.getDrawings()) !== null && _documentDataModel$ge4 !== void 0 ? _documentDataModel$ge4 : {};
12845
+ const drawingOrder = (_documentDataModel$ge5 = documentDataModel.getDrawingsOrder()) !== null && _documentDataModel$ge5 !== void 0 ? _documentDataModel$ge5 : [];
12698
12846
  const sortedRemovedCustomBlockIds = removedCustomBlockIds.sort((a, b) => {
12699
12847
  if (drawingOrder.indexOf(a) > drawingOrder.indexOf(b)) return -1;
12700
12848
  else if (drawingOrder.indexOf(a) < drawingOrder.indexOf(b)) return 1;
@@ -12830,7 +12978,7 @@ const switchParagraphBullet = (params) => {
12830
12978
  var _docDataModel$getSelf, _docDataModel$getSelf2;
12831
12979
  const { paragraphs: currentParagraphs, segmentId, document: docDataModel } = params;
12832
12980
  let listType = params.listType;
12833
- const paragraphs = (_docDataModel$getSelf = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.paragraphs) !== null && _docDataModel$getSelf !== void 0 ? _docDataModel$getSelf : [];
12981
+ const paragraphs = (_docDataModel$getSelf = (_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) !== null && _docDataModel$getSelf !== void 0 ? _docDataModel$getSelf : [];
12834
12982
  const isAlreadyList = currentParagraphs.every((paragraph) => {
12835
12983
  var _paragraph$bullet;
12836
12984
  return ((_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType.indexOf(listType)) === 0;
@@ -12888,7 +13036,7 @@ const switchParagraphBullet = (params) => {
12888
13036
  const toggleChecklistParagraph = (params) => {
12889
13037
  var _docDataModel$getSelf3;
12890
13038
  const { paragraphIndex, segmentId, document: docDataModel } = params;
12891
- const paragraphs = (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.paragraphs;
13039
+ const paragraphs = (_docDataModel$getSelf3 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf3 === void 0 || (_docDataModel$getSelf3 = _docDataModel$getSelf3.getBody()) === null || _docDataModel$getSelf3 === void 0 ? void 0 : _docDataModel$getSelf3.paragraphs;
12892
13040
  if (paragraphs == null) return false;
12893
13041
  const currentParagraph = paragraphs.find((p) => p.startIndex === paragraphIndex);
12894
13042
  if (!(currentParagraph === null || currentParagraph === void 0 ? void 0 : currentParagraph.bullet) || currentParagraph.bullet.listType.indexOf("CHECK_LIST") === -1) return false;
@@ -12923,9 +13071,9 @@ const toggleChecklistParagraph = (params) => {
12923
13071
  };
12924
13072
  const setParagraphBullet = (params) => {
12925
13073
  var _docDataModel$getSelf4;
12926
- const { paragraphs: currentParagraphs, listType, segmentId, document: docDataModel } = params;
12927
- if (((_docDataModel$getSelf4 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) === null || _docDataModel$getSelf4 === void 0 ? void 0 : _docDataModel$getSelf4.paragraphs) == null) return false;
12928
- const listId = generateRandomId(6);
13074
+ const { paragraphs: currentParagraphs, listType, listId: explicitListId, segmentId, document: docDataModel } = params;
13075
+ if (((_docDataModel$getSelf4 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf4 === void 0 || (_docDataModel$getSelf4 = _docDataModel$getSelf4.getBody()) === null || _docDataModel$getSelf4 === void 0 ? void 0 : _docDataModel$getSelf4.paragraphs) == null) return false;
13076
+ const listId = explicitListId !== null && explicitListId !== void 0 ? explicitListId : generateRandomId(6);
12929
13077
  const memoryCursor = new MemoryCursor();
12930
13078
  memoryCursor.reset();
12931
13079
  const textX = new TextX();
@@ -13013,7 +13161,7 @@ const setParagraphStyle = (params) => {
13013
13161
  var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2;
13014
13162
  const { textRanges, segmentId, document: docDataModel, style, paragraphTextRun, cursor, deleteLen, textX: _textX } = params;
13015
13163
  const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
13016
- const currentParagraphs = getParagraphsInRanges(textRanges, (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [], (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "");
13164
+ const currentParagraphs = getParagraphsInRanges(textRanges, (_segment$getBody$para = segment === null || segment === void 0 || (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [], (_segment$getBody$data = segment === null || segment === void 0 || (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "");
13017
13165
  const memoryCursor = new MemoryCursor();
13018
13166
  if (cursor) memoryCursor.moveCursorTo(cursor);
13019
13167
  const textX = _textX !== null && _textX !== void 0 ? _textX : new TextX();
@@ -15601,7 +15749,7 @@ const IURLImageService = (0, _wendellhu_redi.createIdentifier)("core.url-image.s
15601
15749
  //#endregion
15602
15750
  //#region package.json
15603
15751
  var name = "@univerjs/core";
15604
- var version = "1.0.0-alpha.0";
15752
+ var version = "1.0.0-alpha.2";
15605
15753
 
15606
15754
  //#endregion
15607
15755
  //#region src/sheets/empty-snapshot.ts
@@ -18228,12 +18376,6 @@ let UniverInstanceService = class UniverInstanceService extends Disposable {
18228
18376
  if (type && (unit === null || unit === void 0 ? void 0 : unit.type) !== type) return null;
18229
18377
  return unit;
18230
18378
  }
18231
- getCurrentUniverDocInstance() {
18232
- return this.getCurrentUnitOfType(_univerjs_protocol.UniverType.UNIVER_DOC);
18233
- }
18234
- getUniverDocInstance(unitId) {
18235
- return this.getUnit(unitId, _univerjs_protocol.UniverType.UNIVER_DOC);
18236
- }
18237
18379
  getUniverSheetInstance(unitId) {
18238
18380
  return this.getUnit(unitId, _univerjs_protocol.UniverType.UNIVER_SHEET);
18239
18381
  }
@@ -20958,6 +21100,8 @@ exports.CellModeEnum = CellModeEnum;
20958
21100
  exports.CellValueType = CellValueType;
20959
21101
  exports.ColorKit = ColorKit;
20960
21102
  exports.ColorType = ColorType;
21103
+ exports.ColumnLayoutType = ColumnLayoutType;
21104
+ exports.ColumnResponsiveType = ColumnResponsiveType;
20961
21105
  exports.ColumnSeparatorType = ColumnSeparatorType;
20962
21106
  Object.defineProperty(exports, 'CommandService', {
20963
21107
  enumerable: true,
@@ -21023,6 +21167,7 @@ exports.Disposable = Disposable;
21023
21167
  exports.DisposableCollection = DisposableCollection;
21024
21168
  exports.DocStyleType = DocStyleType;
21025
21169
  exports.DocumentBlockRangeType = DocumentBlockRangeType;
21170
+ exports.DocumentBlockType = DocumentBlockType;
21026
21171
  exports.DocumentDataModel = DocumentDataModel;
21027
21172
  exports.DocumentFlavor = DocumentFlavor;
21028
21173
  exports.DrawingTypeEnum = DrawingTypeEnum;
@@ -21194,6 +21339,7 @@ exports.RANGE_DIRECTION = RANGE_DIRECTION;
21194
21339
  exports.RANGE_TYPE = RANGE_TYPE;
21195
21340
  exports.RBush = rbush.default;
21196
21341
  exports.RCDisposable = RCDisposable;
21342
+ exports.RESTORE_INSERTED_PARAGRAPH_IDS = RESTORE_INSERTED_PARAGRAPH_IDS;
21197
21343
  exports.RGBA_PAREN = RGBA_PAREN;
21198
21344
  exports.RGB_PAREN = RGB_PAREN;
21199
21345
  exports.ROTATE_BUFFER_VALUE = ROTATE_BUFFER_VALUE;
package/lib/es/facade.js CHANGED
@@ -68,7 +68,11 @@ var FBaseInitialable = class extends Disposable {
68
68
  this.prototype[InitializerSymbol$1] = initializers;
69
69
  }
70
70
  initializers.push(source.prototype._initialize);
71
- } else if (name !== "constructor") this.prototype[name] = source.prototype[name];
71
+ } else if (name !== "constructor") {
72
+ const descriptor = Object.getOwnPropertyDescriptor(source.prototype, name);
73
+ if (descriptor) Object.defineProperty(this.prototype, name, descriptor);
74
+ else this.prototype[name] = source.prototype[name];
75
+ }
72
76
  });
73
77
  Object.getOwnPropertyNames(source).forEach((name) => {
74
78
  if (name !== "prototype" && name !== "name" && name !== "length") this[name] = source[name];