@univerjs/docs 1.0.0-beta.0 → 1.0.0-beta.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
@@ -33,31 +33,24 @@ function buildPlainTextInsertBody(dataStream, options = {}) {
33
33
  if (paragraphs.length > 0) body.paragraphs = paragraphs;
34
34
  return body;
35
35
  }
36
- function replaceBodyRange(range, insertBody, docDataModel, injector) {
36
+ function replaceBodyRange(range, insertBody, docDataModel, commandService) {
37
37
  const { startOffset, endOffset, segmentId } = range;
38
- const textX = new _univerjs_core.TextX();
39
- if (startOffset > 0) textX.push({
40
- t: _univerjs_core.TextXActionType.RETAIN,
41
- len: startOffset
42
- });
43
- if (endOffset > startOffset) textX.push({
44
- t: _univerjs_core.TextXActionType.DELETE,
45
- len: endOffset - startOffset
46
- });
47
- if (insertBody.dataStream.length > 0) textX.push({
48
- t: _univerjs_core.TextXActionType.INSERT,
49
- body: insertBody,
50
- len: insertBody.dataStream.length
51
- });
52
- const actions = _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId));
53
- const result = injector.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_docs.RichTextEditingMutation.id, {
38
+ const result = commandService.syncExecuteCommand(_univerjs_docs.InsertTextCommand.id, {
54
39
  unitId: docDataModel.getUnitId(),
40
+ body: insertBody,
41
+ range: {
42
+ startOffset,
43
+ endOffset,
44
+ collapsed: startOffset === endOffset,
45
+ segmentId
46
+ },
55
47
  segmentId,
56
- actions,
48
+ debounce: false,
57
49
  textRanges: [],
50
+ noNeedSetTextRange: true,
58
51
  isEditing: false
59
52
  });
60
- return Boolean((result === null || result === void 0 ? void 0 : result.actions) && result.actions.length > 0);
53
+ return Boolean(result);
61
54
  }
62
55
  function retainBodyRange(range, updateBody, coverType, docDataModel, injector) {
63
56
  var _updateBody$textRuns, _docDataModel$getSelf;
@@ -98,23 +91,34 @@ function stripBlockTokens(text) {
98
91
  return Array.from(text).map((char) => char === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH ? "\n" : char).filter((char) => char !== _univerjs_core.DataStreamTreeTokenType.BLOCK_START && char !== _univerjs_core.DataStreamTreeTokenType.BLOCK_END && char !== _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK).join("").replace(/\n$/, "");
99
92
  }
100
93
 
94
+ //#endregion
95
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
96
+ function __decorateParam(paramIndex, decorator) {
97
+ return function(target, key) {
98
+ decorator(target, key, paramIndex);
99
+ };
100
+ }
101
+
102
+ //#endregion
103
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
104
+ function __decorate(decorators, target, key, desc) {
105
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
106
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
107
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
108
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
109
+ }
110
+
101
111
  //#endregion
102
112
  //#region src/facade/f-document-text-range.ts
103
- /**
104
- * Facade wrapper for reading and styling a fixed document text range.
105
- *
106
- * Offsets are fixed when the wrapper is created. Create a new range after edits
107
- * that insert or remove content before it.
108
- * @hideconstructor
109
- */
110
- var FDocumentTextRange = class extends _univerjs_core_facade.FBaseInitialable {
111
- constructor(_document, _startOffset, _endOffset, _segmentId, _injector) {
113
+ let FDocumentTextRange = class FDocumentTextRange extends _univerjs_core_facade.FBaseInitialable {
114
+ constructor(_document, _startOffset, _endOffset, _segmentId, _injector, _commandService) {
112
115
  super(_injector);
113
116
  this._document = _document;
114
117
  this._startOffset = _startOffset;
115
118
  this._endOffset = _endOffset;
116
119
  this._segmentId = _segmentId;
117
120
  this._injector = _injector;
121
+ this._commandService = _commandService;
118
122
  this._validateRange();
119
123
  }
120
124
  /**
@@ -233,7 +237,7 @@ var FDocumentTextRange = class extends _univerjs_core_facade.FBaseInitialable {
233
237
  * ```
234
238
  */
235
239
  setText(text) {
236
- return replaceBodyRange(this.getRange(), buildPlainTextInsertBody(text), this._document.getDocumentDataModel(), this._injector);
240
+ return replaceBodyRange(this.getRange(), buildPlainTextInsertBody(text), this._document.getDocumentDataModel(), this._commandService);
237
241
  }
238
242
  _validateRange() {
239
243
  const bodyLength = this._document.getBody(this._segmentId).dataStream.length;
@@ -260,27 +264,11 @@ var FDocumentTextRange = class extends _univerjs_core_facade.FBaseInitialable {
260
264
  return segments;
261
265
  }
262
266
  };
267
+ FDocumentTextRange = __decorate([__decorateParam(5, _univerjs_core.ICommandService)], FDocumentTextRange);
263
268
  function isDeepEqual(left, right) {
264
269
  return JSON.stringify(left) === JSON.stringify(right);
265
270
  }
266
271
 
267
- //#endregion
268
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
269
- function __decorateParam(paramIndex, decorator) {
270
- return function(target, key) {
271
- decorator(target, key, paramIndex);
272
- };
273
- }
274
-
275
- //#endregion
276
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
277
- function __decorate(decorators, target, key, desc) {
278
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
279
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
280
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
281
- return c > 3 && r && Object.defineProperty(target, key, r), r;
282
- }
283
-
284
272
  //#endregion
285
273
  //#region src/facade/f-document-paragraph.ts
286
274
  let FDocumentParagraph = class FDocumentParagraph extends _univerjs_core_facade.FBaseInitialable {
@@ -478,7 +466,7 @@ let FDocumentParagraph = class FDocumentParagraph extends _univerjs_core_facade.
478
466
  startOffset,
479
467
  endOffset,
480
468
  segmentId: this._segmentId
481
- }, buildPlainTextInsertBody(text), this._document.getDocumentDataModel(), this._injector);
469
+ }, buildPlainTextInsertBody(text), this._document.getDocumentDataModel(), this._commandService);
482
470
  }
483
471
  /**
484
472
  * Append plain text before this paragraph's trailing paragraph break.
@@ -1336,6 +1324,24 @@ let FDocument = class FDocument extends _univerjs_core_facade.FBaseInitialable {
1336
1324
  return this._documentDataModel.getTitle() || "";
1337
1325
  }
1338
1326
  /**
1327
+ * Set the document name.
1328
+ * @param {string} name The new document name.
1329
+ * @returns {FDocument} The current document for chaining.
1330
+ *
1331
+ * @example
1332
+ * ```ts
1333
+ * const document = univerAPI.getActiveDocument();
1334
+ * document?.setName('Quarterly Report');
1335
+ * ```
1336
+ */
1337
+ setName(name) {
1338
+ this._commandService.syncExecuteCommand(_univerjs_docs.SetDocumentNameCommand.id, {
1339
+ unitId: this.id,
1340
+ name
1341
+ });
1342
+ return this;
1343
+ }
1344
+ /**
1339
1345
  * Returns the document's explicit layout flavor.
1340
1346
  *
1341
1347
  * Use this method when all three states matter. Do not infer a Traditional
@@ -1492,7 +1498,7 @@ let FDocument = class FDocument extends _univerjs_core_facade.FBaseInitialable {
1492
1498
  startOffset: index,
1493
1499
  endOffset: index,
1494
1500
  segmentId
1495
- }, buildPlainTextInsertBody(text), this._documentDataModel, this._injector);
1501
+ }, buildPlainTextInsertBody(text), this._documentDataModel, this._commandService);
1496
1502
  }
1497
1503
  /**
1498
1504
  * Returns document-level header/footer switches and margins. Margin values use 96-DPI layout pixels.
@@ -1713,7 +1719,7 @@ let FDocument = class FDocument extends _univerjs_core_facade.FBaseInitialable {
1713
1719
  }, {
1714
1720
  dataStream: _univerjs_core.DataStreamTreeTokenType.PARAGRAPH,
1715
1721
  paragraphs
1716
- }, this._documentDataModel, this._injector) ? this.getParagraph(paragraphId, segmentId) : null;
1722
+ }, this._documentDataModel, this._commandService) ? this.getParagraph(paragraphId, segmentId) : null;
1717
1723
  }
1718
1724
  /**
1719
1725
  * Get all paragraphs in the document body or header/footer body by the segment id.
@@ -1826,7 +1832,7 @@ let FDocument = class FDocument extends _univerjs_core_facade.FBaseInitialable {
1826
1832
  startOffset: offset,
1827
1833
  endOffset: offset,
1828
1834
  segmentId
1829
- }, buildPlainTextInsertBody(`${text}\r`), this._documentDataModel, this._injector)) throw new Error("Failed to insert paragraph.");
1835
+ }, buildPlainTextInsertBody(`${text}\r`), this._documentDataModel, this._commandService)) throw new Error("Failed to insert paragraph.");
1830
1836
  const { paragraphs = [] } = this.getBody(segmentId);
1831
1837
  const paragraph = paragraphs[index];
1832
1838
  if (!paragraph) throw new Error("Failed to insert paragraph.");
@@ -1868,7 +1874,7 @@ let FDocument = class FDocument extends _univerjs_core_facade.FBaseInitialable {
1868
1874
  deleteRange(range) {
1869
1875
  const normalizedRange = this._normalizeDeleteRange(range);
1870
1876
  if (normalizedRange.startOffset >= normalizedRange.endOffset) return false;
1871
- return replaceBodyRange(normalizedRange, { dataStream: "" }, this._documentDataModel, this._injector);
1877
+ return replaceBodyRange(normalizedRange, { dataStream: "" }, this._documentDataModel, this._commandService);
1872
1878
  }
1873
1879
  _createFDocumentParagraph(paragraphId, segmentId = "") {
1874
1880
  return this._injector.createInstance(FDocumentParagraph, this, paragraphId, segmentId, this._injector);
@@ -2008,6 +2014,11 @@ Object.defineProperty(exports, 'FDocumentSection', {
2008
2014
  return FDocumentSection;
2009
2015
  }
2010
2016
  });
2011
- exports.FDocumentTextRange = FDocumentTextRange;
2017
+ Object.defineProperty(exports, 'FDocumentTextRange', {
2018
+ enumerable: true,
2019
+ get: function () {
2020
+ return FDocumentTextRange;
2021
+ }
2022
+ });
2012
2023
  exports.isParagraphFacade = isParagraphFacade;
2013
2024
  exports.stripBlockTokens = stripBlockTokens;
package/lib/cjs/index.js CHANGED
@@ -349,6 +349,7 @@ const RichTextEditingMutation = {
349
349
  if (documentDataModel == null) throw new Error(`DocumentDataModel not found for unitId: ${unitId}`);
350
350
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
351
351
  const docRanges = docSelectionManagerService.getDocRanges() ?? [];
352
+ const selectionInfo = docSelectionManagerService.getSelectionInfo();
352
353
  const disabled = !!documentDataModel.getSnapshot().disabled;
353
354
  if (_univerjs_core.JSONX.isNoop(actions) || actions && actions.length === 0 || disabled) return {
354
355
  unitId,
@@ -379,11 +380,15 @@ const RichTextEditingMutation = {
379
380
  debounce,
380
381
  redoState: {
381
382
  actions,
382
- textRanges
383
+ textRanges,
384
+ options: params.options,
385
+ isEditing
383
386
  },
384
387
  undoState: {
385
388
  actions: undoActions,
386
- textRanges: prevTextRanges ?? docRanges
389
+ textRanges: prevTextRanges ?? docRanges,
390
+ options: selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.options,
391
+ isEditing: selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEditing
387
392
  },
388
393
  isCompositionEnd,
389
394
  isSync,
@@ -409,59 +414,63 @@ const InsertTextCommand = {
409
414
  handler: (accessor, params) => {
410
415
  var _docDataModel$getSelf;
411
416
  const commandService = accessor.get(_univerjs_core.ICommandService);
412
- const { range, segmentId, body, unitId, cursorOffset } = params;
417
+ const { range, segmentId, body, unitId, cursorOffset, debounce = true, textRanges, noNeedSetTextRange, isEditing } = params;
413
418
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
414
419
  const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
415
420
  if (docDataModel == null) return false;
416
421
  const activeRange = docSelectionManagerService.getActiveTextRange();
417
- const rangeSegmentId = "segmentId" in range ? range.segmentId : void 0;
422
+ const rangeSegmentId = "segmentId" in range && typeof range.segmentId === "string" ? range.segmentId : void 0;
418
423
  const targetSegmentId = segmentId ?? rangeSegmentId ?? (activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) ?? "";
419
424
  const originBody = (_docDataModel$getSelf = docDataModel.getSelfOrHeaderFooterModel(targetSegmentId)) === null || _docDataModel$getSelf === void 0 ? void 0 : _docDataModel$getSelf.getBody();
420
425
  if (originBody == null) return false;
421
426
  const { startOffset, collapsed } = range;
422
427
  const cursorMove = cursorOffset ?? body.dataStream.length;
423
- const textRanges = [{
428
+ const mutationTextRanges = textRanges ?? [{
424
429
  startOffset: startOffset + cursorMove,
425
430
  endOffset: startOffset + cursorMove,
426
- style: activeRange === null || activeRange === void 0 ? void 0 : activeRange.style,
427
431
  collapsed
428
432
  }];
429
433
  const doMutation = {
430
434
  id: RichTextEditingMutation.id,
431
435
  params: {
432
436
  unitId,
437
+ segmentId: targetSegmentId,
433
438
  actions: [],
434
- textRanges,
435
- debounce: true
439
+ textRanges: mutationTextRanges,
440
+ debounce,
441
+ noNeedSetTextRange,
442
+ isEditing
436
443
  }
437
444
  };
438
- const textX = new _univerjs_core.TextX();
439
- const jsonX = _univerjs_core.JSONX.getInstance();
440
- if (collapsed) {
441
- if (startOffset > 0) textX.push({
442
- t: _univerjs_core.TextXActionType.RETAIN,
443
- len: startOffset
444
- });
445
- textX.push({
446
- t: _univerjs_core.TextXActionType.INSERT,
447
- body,
448
- len: body.dataStream.length
449
- });
450
- } else {
451
- const dos = _univerjs_core.BuildTextUtils.selection.delete([range], originBody, 0, body);
452
- textX.push(...dos);
453
- }
454
- doMutation.params.textRanges = [{
455
- startOffset: startOffset + cursorMove,
456
- endOffset: startOffset + cursorMove,
457
- collapsed
458
- }];
459
- const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
460
- doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
445
+ doMutation.params.actions = buildInsertTextActions(docDataModel, originBody, range, body, targetSegmentId);
461
446
  const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
462
447
  return Boolean(result);
463
448
  }
464
449
  };
450
+ function buildInsertTextActions(documentDataModel, originBody, range, insertBody, segmentId) {
451
+ const { startOffset, endOffset, collapsed } = range;
452
+ const textX = new _univerjs_core.TextX();
453
+ if (collapsed) {
454
+ if (startOffset > 0) textX.push({
455
+ t: _univerjs_core.TextXActionType.RETAIN,
456
+ len: startOffset
457
+ });
458
+ textX.push({
459
+ t: _univerjs_core.TextXActionType.INSERT,
460
+ body: insertBody,
461
+ len: insertBody.dataStream.length
462
+ });
463
+ } else textX.push(..._univerjs_core.BuildTextUtils.selection.delete([range], originBody, 0, insertBody));
464
+ const textActions = _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), (0, _univerjs_core.getRichTextEditPath)(documentDataModel, segmentId));
465
+ return collapsed ? textActions : appendRemovedDrawingActions(textActions, documentDataModel, originBody, startOffset, endOffset);
466
+ }
467
+ function appendRemovedDrawingActions(textActions, documentDataModel, body, startOffset, endOffset) {
468
+ return [textActions, ..._univerjs_core.BuildTextUtils.drawing.remove(documentDataModel.getSnapshot(), [{
469
+ startOffset,
470
+ endOffset,
471
+ collapsed: false
472
+ }], body)].reduce((accumulator, action) => _univerjs_core.JSONX.compose(accumulator, action));
473
+ }
465
474
  /**
466
475
  * The command to delete text, mainly used in BACKSPACE and DELETE when collapsed is true. ONLY handle collapsed range!!!
467
476
  */
@@ -488,6 +497,7 @@ const DeleteTextCommand = {
488
497
  id: RichTextEditingMutation.id,
489
498
  params: {
490
499
  unitId,
500
+ segmentId,
491
501
  actions: [],
492
502
  textRanges: [{
493
503
  startOffset: start,
@@ -506,7 +516,7 @@ const DeleteTextCommand = {
506
516
  collapsed: false
507
517
  }], body));
508
518
  const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
509
- doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
519
+ doMutation.params.actions = appendRemovedDrawingActions(jsonX.editOp(textX.serialize(), path), docDataModel, body, start, end + 1);
510
520
  const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
511
521
  return Boolean(result);
512
522
  }
@@ -738,6 +748,53 @@ const SetDocumentDefaultParagraphStyleCommand = {
738
748
  }
739
749
  };
740
750
 
751
+ //#endregion
752
+ //#region src/commands/mutations/docs-rename.mutation.ts
753
+ const DocsRenameMutation = {
754
+ id: "doc.mutation.rename-doc",
755
+ type: _univerjs_core.CommandType.MUTATION,
756
+ handler: (accessor, params) => {
757
+ const doc = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
758
+ if (!doc) return false;
759
+ doc.setName(params.name);
760
+ return true;
761
+ }
762
+ };
763
+
764
+ //#endregion
765
+ //#region src/commands/commands/set-document-name.command.ts
766
+ const SetDocumentNameCommand = {
767
+ id: "doc.command.set-name",
768
+ type: _univerjs_core.CommandType.COMMAND,
769
+ handler: (accessor, params) => {
770
+ if (!params) return false;
771
+ const document = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
772
+ if (!document) return false;
773
+ const commandService = accessor.get(_univerjs_core.ICommandService);
774
+ const redoParams = {
775
+ unitId: params.unitId,
776
+ name: params.name
777
+ };
778
+ const undoParams = {
779
+ unitId: params.unitId,
780
+ name: document.getTitle() || ""
781
+ };
782
+ if (!commandService.syncExecuteCommand(DocsRenameMutation.id, redoParams)) return false;
783
+ accessor.get(_univerjs_core.IUndoRedoService).pushUndoRedo({
784
+ unitID: params.unitId,
785
+ redoMutations: [{
786
+ id: DocsRenameMutation.id,
787
+ params: redoParams
788
+ }],
789
+ undoMutations: [{
790
+ id: DocsRenameMutation.id,
791
+ params: undoParams
792
+ }]
793
+ });
794
+ return true;
795
+ }
796
+ };
797
+
741
798
  //#endregion
742
799
  //#region src/utils/sections.ts
743
800
  /** Returns document-level section breaks, excluding table-cell and modern-column sentinels. */
@@ -1147,7 +1204,7 @@ const InsertDocumentColumnBreakCommand = {
1147
1204
  rangeId: `docx-break-${(0, _univerjs_core.generateRandomId)()}`,
1148
1205
  rangeType: _univerjs_core.CustomRangeType.CUSTOM,
1149
1206
  wholeEntity: true,
1150
- properties: { docxBreakType: _univerjs_core.DocxBreakType.COLUMN }
1207
+ properties: { breakType: _univerjs_core.DocxBreakType.COLUMN }
1151
1208
  }]
1152
1209
  });
1153
1210
  return executeSectionTextX(context.commandService, context.documentDataModel, textX, InsertDocumentColumnBreakCommand.id);
@@ -1387,20 +1444,7 @@ function composeActions(actions) {
1387
1444
  //#endregion
1388
1445
  //#region package.json
1389
1446
  var name = "@univerjs/docs";
1390
- var version = "1.0.0-beta.0";
1391
-
1392
- //#endregion
1393
- //#region src/commands/mutations/docs-rename.mutation.ts
1394
- const DocsRenameMutation = {
1395
- id: "doc.mutation.rename-doc",
1396
- type: _univerjs_core.CommandType.MUTATION,
1397
- handler: (accessor, params) => {
1398
- const doc = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
1399
- if (!doc) return false;
1400
- doc.setName(params.name);
1401
- return true;
1402
- }
1403
- };
1447
+ var version = "1.0.0-beta.2";
1404
1448
 
1405
1449
  //#endregion
1406
1450
  //#region src/config/config.ts
@@ -1571,6 +1615,9 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
1571
1615
  this._historyStateCache.set(unitId, cache.history);
1572
1616
  this._changeStateCache.set(unitId, cache.collaboration);
1573
1617
  }
1618
+ clearHistory(unitId) {
1619
+ this._historyStateCache.delete(unitId);
1620
+ }
1574
1621
  _setChangeState(changeState) {
1575
1622
  this._cacheChangeState(changeState, "history");
1576
1623
  this._cacheChangeState(changeState, "collaboration");
@@ -1603,6 +1650,8 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
1603
1650
  if (type === "history" && (trigger === _univerjs_core.RedoCommandId || trigger === _univerjs_core.UndoCommandId)) return;
1604
1651
  const stateCache = type === "history" ? this._historyStateCache : this._changeStateCache;
1605
1652
  const cb = type === "history" ? this._pushHistory.bind(this) : this._emitChangeState.bind(this);
1653
+ const pendingStates = stateCache.get(unitId);
1654
+ if ((pendingStates === null || pendingStates === void 0 ? void 0 : pendingStates.length) && pendingStates[pendingStates.length - 1].segmentId !== changeState.segmentId) cb(unitId);
1606
1655
  if (stateCache.has(unitId)) {
1607
1656
  const cacheStates = stateCache.get(unitId);
1608
1657
  cacheStates === null || cacheStates === void 0 || cacheStates.push(changeState);
@@ -1631,12 +1680,18 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
1631
1680
  const redoParams = {
1632
1681
  unitId,
1633
1682
  actions: cacheStates.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.redoState.actions), null),
1634
- textRanges: lastState.redoState.textRanges
1683
+ textRanges: lastState.redoState.textRanges,
1684
+ segmentId: lastState.segmentId,
1685
+ options: lastState.redoState.options,
1686
+ isEditing: lastState.redoState.isEditing
1635
1687
  };
1636
1688
  const undoParams = {
1637
1689
  unitId,
1638
1690
  actions: cacheStates.reverse().reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.undoState.actions), null),
1639
- textRanges: firstState.undoState.textRanges
1691
+ textRanges: firstState.undoState.textRanges,
1692
+ segmentId: firstState.segmentId,
1693
+ options: firstState.undoState.options,
1694
+ isEditing: firstState.undoState.isEditing
1640
1695
  };
1641
1696
  undoRedoService.pushUndoRedo({
1642
1697
  unitID: unitId,
@@ -1665,12 +1720,18 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
1665
1720
  redoState: {
1666
1721
  unitId,
1667
1722
  actions: cacheStates.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.redoState.actions), null),
1668
- textRanges: lastState.redoState.textRanges
1723
+ textRanges: lastState.redoState.textRanges,
1724
+ segmentId: lastState.segmentId,
1725
+ options: lastState.redoState.options,
1726
+ isEditing: lastState.redoState.isEditing
1669
1727
  },
1670
1728
  undoState: {
1671
1729
  unitId,
1672
1730
  actions: cacheStates.reverse().reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.undoState.actions), null),
1673
- textRanges: firstState.undoState.textRanges
1731
+ textRanges: firstState.undoState.textRanges,
1732
+ segmentId: firstState.segmentId,
1733
+ options: firstState.undoState.options,
1734
+ isEditing: firstState.undoState.isEditing
1674
1735
  },
1675
1736
  segmentId,
1676
1737
  noHistory,
@@ -1783,6 +1844,7 @@ let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
1783
1844
  UpdateTextCommand,
1784
1845
  CreateHeaderFooterCommand,
1785
1846
  SetDocumentDefaultParagraphStyleCommand,
1847
+ SetDocumentNameCommand,
1786
1848
  SetSectionHeaderFooterLinkCommand,
1787
1849
  UpdateDocumentParagraphStyleCommand,
1788
1850
  UpdateDocumentSectionCommand,
@@ -2175,6 +2237,7 @@ exports.InsertDocumentSectionBreakCommand = InsertDocumentSectionBreakCommand;
2175
2237
  exports.InsertTextCommand = InsertTextCommand;
2176
2238
  exports.RichTextEditingMutation = RichTextEditingMutation;
2177
2239
  exports.SetDocumentDefaultParagraphStyleCommand = SetDocumentDefaultParagraphStyleCommand;
2240
+ exports.SetDocumentNameCommand = SetDocumentNameCommand;
2178
2241
  exports.SetSectionHeaderFooterLinkCommand = SetSectionHeaderFooterLinkCommand;
2179
2242
  exports.SetTextSelectionsOperation = SetTextSelectionsOperation;
2180
2243
  Object.defineProperty(exports, 'UniverDocsPlugin', {