@univerjs/docs 0.25.0-insiders.20260623-012b5a8 → 0.25.1

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/index.js CHANGED
@@ -13,7 +13,7 @@ const SetTextSelectionsOperation = {
13
13
  };
14
14
 
15
15
  //#endregion
16
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
16
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
17
17
  function _typeof(o) {
18
18
  "@babel/helpers - typeof";
19
19
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -24,7 +24,7 @@ function _typeof(o) {
24
24
  }
25
25
 
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
27
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
28
28
  function toPrimitive(t, r) {
29
29
  if ("object" != _typeof(t) || !t) return t;
30
30
  var e = t[Symbol.toPrimitive];
@@ -37,14 +37,14 @@ function toPrimitive(t, r) {
37
37
  }
38
38
 
39
39
  //#endregion
40
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
40
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
41
41
  function toPropertyKey(t) {
42
42
  var i = toPrimitive(t, "string");
43
43
  return "symbol" == _typeof(i) ? i : i + "";
44
44
  }
45
45
 
46
46
  //#endregion
47
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
47
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
48
48
  function _defineProperty(e, r, t) {
49
49
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
50
50
  value: t,
@@ -55,7 +55,7 @@ function _defineProperty(e, r, t) {
55
55
  }
56
56
 
57
57
  //#endregion
58
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
58
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
59
59
  function __decorateParam(paramIndex, decorator) {
60
60
  return function(target, key) {
61
61
  decorator(target, key, paramIndex);
@@ -63,7 +63,7 @@ function __decorateParam(paramIndex, decorator) {
63
63
  }
64
64
 
65
65
  //#endregion
66
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
66
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
67
67
  function __decorate(decorators, target, key, desc) {
68
68
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
69
69
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -323,16 +323,15 @@ const RichTextEditingMutationId = "doc.mutation.rich-text-editing";
323
323
  const RichTextEditingMutation = {
324
324
  id: RichTextEditingMutationId,
325
325
  type: _univerjs_core.CommandType.MUTATION,
326
- handler: (accessor, params, options) => {
326
+ handler: (accessor, params) => {
327
327
  var _renderManagerService, _docSelectionManagerS;
328
- const { unitId, segmentId = "", actions, textRanges, prevTextRanges, trigger, noHistory, isCompositionEnd, noNeedSetTextRange, debounce, isEditing = true, isSync: paramsIsSync, syncer } = params;
329
- const isSync = paramsIsSync || (options === null || options === void 0 ? void 0 : options.fromCollab) || (options === null || options === void 0 ? void 0 : options.fromChangeset);
328
+ const { unitId, segmentId = "", actions, textRanges, prevTextRanges, trigger, noHistory, isCompositionEnd, noNeedSetTextRange, debounce, isEditing = true, isSync, syncer } = params;
330
329
  const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
331
330
  const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
332
331
  const docStateEmitService = accessor.get(DocStateEmitService);
333
- const documentDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
334
- const documentViewModel = (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService).getViewModel();
335
- if (documentDataModel == null) throw new Error(`DocumentDataModel not found for unitId: ${unitId}`);
332
+ const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
333
+ const documentViewModel = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService).getViewModel();
334
+ if (documentDataModel == null || documentViewModel == null) throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${unitId}`);
336
335
  const docSelectionManagerService = accessor.get(DocSelectionManagerService);
337
336
  const docRanges = (_docSelectionManagerS = docSelectionManagerService.getDocRanges()) !== null && _docSelectionManagerS !== void 0 ? _docSelectionManagerS : [];
338
337
  const disabled = !!documentDataModel.getSnapshot().disabled;
@@ -343,7 +342,7 @@ const RichTextEditingMutation = {
343
342
  };
344
343
  const undoActions = _univerjs_core.JSONX.invertWithDoc(actions, documentDataModel.getSnapshot());
345
344
  documentDataModel.apply(actions);
346
- documentViewModel === null || documentViewModel === void 0 || documentViewModel.reset(documentDataModel);
345
+ documentViewModel.reset(documentDataModel);
347
346
  if (!noNeedSetTextRange && textRanges && trigger != null && !isSync) queueMicrotask(() => {
348
347
  docSelectionManagerService.replaceDocRanges(textRanges, {
349
348
  unitId,
@@ -378,162 +377,10 @@ const RichTextEditingMutation = {
378
377
  }
379
378
  };
380
379
 
381
- //#endregion
382
- //#region src/commands/commands/core-editing.command.ts
383
- /**
384
- * The command to insert text. The changed range could be non-collapsed, mainly use in line break and normal input.
385
- */
386
- const InsertTextCommand = {
387
- id: "doc.command.insert-text",
388
- type: _univerjs_core.CommandType.COMMAND,
389
- handler: (accessor, params) => {
390
- var _activeRange$segmentI;
391
- const commandService = accessor.get(_univerjs_core.ICommandService);
392
- const { range, segmentId, body, unitId, cursorOffset } = params;
393
- const docSelectionManagerService = accessor.get(DocSelectionManagerService);
394
- const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
395
- if (docDataModel == null) return false;
396
- const activeRange = docSelectionManagerService.getActiveTextRange();
397
- const originBody = docDataModel.getSelfOrHeaderFooterModel((_activeRange$segmentI = activeRange === null || activeRange === void 0 ? void 0 : activeRange.segmentId) !== null && _activeRange$segmentI !== void 0 ? _activeRange$segmentI : "").getBody();
398
- if (originBody == null) return false;
399
- const { startOffset, collapsed } = range;
400
- const cursorMove = cursorOffset !== null && cursorOffset !== void 0 ? cursorOffset : body.dataStream.length;
401
- const textRanges = [{
402
- startOffset: startOffset + cursorMove,
403
- endOffset: startOffset + cursorMove,
404
- style: activeRange === null || activeRange === void 0 ? void 0 : activeRange.style,
405
- collapsed
406
- }];
407
- const doMutation = {
408
- id: RichTextEditingMutation.id,
409
- params: {
410
- unitId,
411
- actions: [],
412
- textRanges,
413
- debounce: true
414
- }
415
- };
416
- const textX = new _univerjs_core.TextX();
417
- const jsonX = _univerjs_core.JSONX.getInstance();
418
- if (collapsed) {
419
- if (startOffset > 0) textX.push({
420
- t: _univerjs_core.TextXActionType.RETAIN,
421
- len: startOffset
422
- });
423
- textX.push({
424
- t: _univerjs_core.TextXActionType.INSERT,
425
- body,
426
- len: body.dataStream.length
427
- });
428
- } else {
429
- const dos = _univerjs_core.BuildTextUtils.selection.delete([range], originBody, 0, body);
430
- textX.push(...dos);
431
- }
432
- doMutation.params.textRanges = [{
433
- startOffset: startOffset + cursorMove,
434
- endOffset: startOffset + cursorMove,
435
- collapsed
436
- }];
437
- const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
438
- doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
439
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
440
- return Boolean(result);
441
- }
442
- };
443
- /**
444
- * The command to delete text, mainly used in BACKSPACE and DELETE when collapsed is true. ONLY handle collapsed range!!!
445
- */
446
- const DeleteTextCommand = {
447
- id: "doc.command.delete-text",
448
- type: _univerjs_core.CommandType.COMMAND,
449
- handler: (accessor, params) => {
450
- var _body$customRanges;
451
- const commandService = accessor.get(_univerjs_core.ICommandService);
452
- const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
453
- const { range, segmentId, unitId, direction, len = 1 } = params;
454
- const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
455
- const body = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
456
- if (docDataModel == null || body == null) return false;
457
- const { startOffset } = range;
458
- let start = direction === _univerjs_core.DeleteDirection.LEFT ? startOffset - len : startOffset;
459
- let end = direction === _univerjs_core.DeleteDirection.LEFT ? startOffset - 1 : startOffset + len - 1;
460
- const customRange = (_body$customRanges = body.customRanges) === null || _body$customRanges === void 0 ? void 0 : _body$customRanges.find((customRange) => customRange.startIndex <= start && customRange.endIndex >= end);
461
- if (customRange === null || customRange === void 0 ? void 0 : customRange.wholeEntity) {
462
- start = customRange.startIndex;
463
- end = Math.max(end, customRange.endIndex);
464
- }
465
- const doMutation = {
466
- id: RichTextEditingMutation.id,
467
- params: {
468
- unitId,
469
- actions: [],
470
- textRanges: [{
471
- startOffset: start,
472
- endOffset: start,
473
- collapsed: true
474
- }],
475
- debounce: true
476
- }
477
- };
478
- const textX = new _univerjs_core.TextX();
479
- const jsonX = _univerjs_core.JSONX.getInstance();
480
- textX.push({
481
- t: _univerjs_core.TextXActionType.RETAIN,
482
- len: start - 0
483
- });
484
- textX.push({
485
- t: _univerjs_core.TextXActionType.DELETE,
486
- len: end - start + 1
487
- });
488
- const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
489
- doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
490
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
491
- return Boolean(result);
492
- }
493
- };
494
- /**
495
- * The command to update text properties, mainly used in BACKSPACE.
496
- */
497
- const UpdateTextCommand = {
498
- id: "doc.command.update-text",
499
- type: _univerjs_core.CommandType.COMMAND,
500
- handler: (accessor, params) => {
501
- const { range, segmentId, updateBody, coverType, unitId, textRanges } = params;
502
- const commandService = accessor.get(_univerjs_core.ICommandService);
503
- const docDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getCurrentUniverDocInstance();
504
- if (docDataModel == null) return false;
505
- const doMutation = {
506
- id: RichTextEditingMutation.id,
507
- params: {
508
- unitId,
509
- actions: [],
510
- textRanges
511
- }
512
- };
513
- const textX = new _univerjs_core.TextX();
514
- const jsonX = _univerjs_core.JSONX.getInstance();
515
- const { startOffset, endOffset } = range;
516
- textX.push({
517
- t: _univerjs_core.TextXActionType.RETAIN,
518
- len: startOffset
519
- });
520
- textX.push({
521
- t: _univerjs_core.TextXActionType.RETAIN,
522
- body: updateBody,
523
- len: endOffset - startOffset,
524
- coverType
525
- });
526
- const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
527
- doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
528
- const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
529
- return Boolean(result);
530
- }
531
- };
532
-
533
380
  //#endregion
534
381
  //#region package.json
535
382
  var name = "@univerjs/docs";
536
- var version = "0.25.0-insiders.20260623-012b5a8";
383
+ var version = "0.25.1";
537
384
 
538
385
  //#endregion
539
386
  //#region src/commands/mutations/docs-rename.mutation.ts
@@ -622,192 +469,6 @@ DocCustomRangeController = __decorate([
622
469
  __decorateParam(2, _univerjs_core.IUniverInstanceService)
623
470
  ], DocCustomRangeController);
624
471
 
625
- //#endregion
626
- //#region src/services/doc-content-insert.service.ts
627
- /**
628
- * Copyright 2023-present DreamNum Co., Ltd.
629
- *
630
- * Licensed under the Apache License, Version 2.0 (the "License");
631
- * you may not use this file except in compliance with the License.
632
- * You may obtain a copy of the License at
633
- *
634
- * http://www.apache.org/licenses/LICENSE-2.0
635
- *
636
- * Unless required by applicable law or agreed to in writing, software
637
- * distributed under the License is distributed on an "AS IS" BASIS,
638
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
639
- * See the License for the specific language governing permissions and
640
- * limitations under the License.
641
- */
642
- var DocContentInsertService = class extends _univerjs_core.Disposable {
643
- constructor(..._args) {
644
- super(..._args);
645
- _defineProperty(this, "_range", null);
646
- }
647
- setInsertRange(range) {
648
- this._range = range;
649
- }
650
- consumeInsertRange(unitId) {
651
- if (!this._range) return null;
652
- if (unitId && this._range.unitId !== unitId) return null;
653
- const range = this._range;
654
- this._range = null;
655
- return range;
656
- }
657
- clearInsertRange() {
658
- this._range = null;
659
- }
660
- };
661
-
662
- //#endregion
663
- //#region src/services/doc-state-change-manager.service.ts
664
- const DEBOUNCE_DELAY = 300;
665
- const IDocStateChangeInterceptorService = (0, _univerjs_core.createIdentifier)("doc.state-change-interceptor-service");
666
- let DocStateChangeManagerService = class DocStateChangeManagerService extends _univerjs_core.RxDisposable {
667
- constructor(_undoRedoService, _commandService, _univerInstanceService, _docStateEmitService, _docStateChangeInterceptorService) {
668
- super();
669
- this._undoRedoService = _undoRedoService;
670
- this._commandService = _commandService;
671
- this._univerInstanceService = _univerInstanceService;
672
- this._docStateEmitService = _docStateEmitService;
673
- this._docStateChangeInterceptorService = _docStateChangeInterceptorService;
674
- _defineProperty(this, "_docStateChange$", new rxjs.BehaviorSubject(null));
675
- _defineProperty(this, "docStateChange$", this._docStateChange$.asObservable());
676
- _defineProperty(this, "_historyStateCache", /* @__PURE__ */ new Map());
677
- _defineProperty(this, "_changeStateCache", /* @__PURE__ */ new Map());
678
- _defineProperty(this, "_historyTimer", null);
679
- _defineProperty(this, "_changeStateCacheTimer", null);
680
- this._initialize();
681
- this._listenDocStateChange();
682
- }
683
- getStateCache(unitId) {
684
- var _this$_historyStateCa, _this$_changeStateCac;
685
- return {
686
- history: (_this$_historyStateCa = this._historyStateCache.get(unitId)) !== null && _this$_historyStateCa !== void 0 ? _this$_historyStateCa : [],
687
- collaboration: (_this$_changeStateCac = this._changeStateCache.get(unitId)) !== null && _this$_changeStateCac !== void 0 ? _this$_changeStateCac : []
688
- };
689
- }
690
- setStateCache(unitId, cache) {
691
- this._historyStateCache.set(unitId, cache.history);
692
- this._changeStateCache.set(unitId, cache.collaboration);
693
- }
694
- _setChangeState(changeState) {
695
- this._cacheChangeState(changeState, "history");
696
- this._cacheChangeState(changeState, "collaboration");
697
- }
698
- _initialize() {
699
- this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
700
- if (command.id === _univerjs_core.UndoCommandId || command.id === _univerjs_core.RedoCommandId) {
701
- const univerDoc = this._univerInstanceService.getCurrentUniverDocInstance();
702
- if (univerDoc == null) return;
703
- const unitId = univerDoc.getUnitId();
704
- this._pushHistory(unitId);
705
- this._emitChangeState(unitId);
706
- }
707
- }));
708
- }
709
- _listenDocStateChange() {
710
- this._docStateEmitService.docStateChangeParams$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((changeStateInfo) => {
711
- var _this$_docStateChange, _this$_docStateChange2;
712
- if (changeStateInfo == null) return;
713
- const interceptedChangeStateInfo = (_this$_docStateChange = (_this$_docStateChange2 = this._docStateChangeInterceptorService) === null || _this$_docStateChange2 === void 0 ? void 0 : _this$_docStateChange2.transformChangeStateInfo(changeStateInfo)) !== null && _this$_docStateChange !== void 0 ? _this$_docStateChange : changeStateInfo;
714
- if (interceptedChangeStateInfo == null) return;
715
- if (interceptedChangeStateInfo.isSync) return;
716
- const { isCompositionEnd: _isCompositionEnd, isSync: _isSync, syncer: _syncer, ...changeState } = interceptedChangeStateInfo;
717
- this._setChangeState(changeState);
718
- });
719
- }
720
- _cacheChangeState(changeState, type = "history") {
721
- const { trigger, unitId, noHistory, debounce = false } = changeState;
722
- if (noHistory || type === "history" && trigger == null) return;
723
- if (type === "history" && (trigger === _univerjs_core.RedoCommandId || trigger === _univerjs_core.UndoCommandId)) return;
724
- const stateCache = type === "history" ? this._historyStateCache : this._changeStateCache;
725
- const cb = type === "history" ? this._pushHistory.bind(this) : this._emitChangeState.bind(this);
726
- if (stateCache.has(unitId)) {
727
- const cacheStates = stateCache.get(unitId);
728
- cacheStates === null || cacheStates === void 0 || cacheStates.push(changeState);
729
- } else stateCache.set(unitId, [changeState]);
730
- if (debounce) if (type === "history") {
731
- if (this._historyTimer) clearTimeout(this._historyTimer);
732
- this._historyTimer = setTimeout(() => {
733
- cb(unitId);
734
- }, DEBOUNCE_DELAY);
735
- } else {
736
- if (this._changeStateCacheTimer) clearTimeout(this._changeStateCacheTimer);
737
- this._changeStateCacheTimer = setTimeout(() => {
738
- cb(unitId);
739
- }, DEBOUNCE_DELAY);
740
- }
741
- else cb(unitId);
742
- }
743
- _pushHistory(unitId) {
744
- const undoRedoService = this._undoRedoService;
745
- const cacheStates = this._historyStateCache.get(unitId);
746
- if (undoRedoService == null || !Array.isArray(cacheStates) || cacheStates.length === 0) return;
747
- const len = cacheStates.length;
748
- const commandId = cacheStates[0].commandId;
749
- const firstState = cacheStates[0];
750
- const lastState = cacheStates[len - 1];
751
- const redoParams = {
752
- unitId,
753
- actions: cacheStates.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.redoState.actions), null),
754
- textRanges: lastState.redoState.textRanges
755
- };
756
- const undoParams = {
757
- unitId,
758
- actions: cacheStates.reverse().reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.undoState.actions), null),
759
- textRanges: firstState.undoState.textRanges
760
- };
761
- undoRedoService.pushUndoRedo({
762
- unitID: unitId,
763
- undoMutations: [{
764
- id: commandId,
765
- params: undoParams
766
- }],
767
- redoMutations: [{
768
- id: commandId,
769
- params: redoParams
770
- }]
771
- });
772
- cacheStates.length = 0;
773
- }
774
- _emitChangeState(unitId) {
775
- const cacheStates = this._changeStateCache.get(unitId);
776
- if (!Array.isArray(cacheStates) || cacheStates.length === 0) return;
777
- const len = cacheStates.length;
778
- const { commandId, trigger, segmentId, noHistory, debounce } = cacheStates[0];
779
- const firstState = cacheStates[0];
780
- const lastState = cacheStates[len - 1];
781
- const changeState = {
782
- commandId,
783
- unitId,
784
- trigger,
785
- redoState: {
786
- unitId,
787
- actions: cacheStates.reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.redoState.actions), null),
788
- textRanges: lastState.redoState.textRanges
789
- },
790
- undoState: {
791
- unitId,
792
- actions: cacheStates.reverse().reduce((acc, cur) => _univerjs_core.JSONX.compose(acc, cur.undoState.actions), null),
793
- textRanges: firstState.undoState.textRanges
794
- },
795
- segmentId,
796
- noHistory,
797
- debounce
798
- };
799
- cacheStates.length = 0;
800
- this._docStateChange$.next(changeState);
801
- }
802
- };
803
- DocStateChangeManagerService = __decorate([
804
- __decorateParam(0, (0, _univerjs_core.Optional)(_univerjs_core.IUndoRedoService)),
805
- __decorateParam(1, _univerjs_core.ICommandService),
806
- __decorateParam(2, _univerjs_core.IUniverInstanceService),
807
- __decorateParam(3, (0, _univerjs_core.Inject)(DocStateEmitService)),
808
- __decorateParam(4, (0, _univerjs_core.Optional)(IDocStateChangeInterceptorService))
809
- ], DocStateChangeManagerService);
810
-
811
472
  //#endregion
812
473
  //#region src/plugin.ts
813
474
  let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
@@ -825,9 +486,6 @@ let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
825
486
  }
826
487
  _initializeCommands() {
827
488
  [
828
- InsertTextCommand,
829
- DeleteTextCommand,
830
- UpdateTextCommand,
831
489
  RichTextEditingMutation,
832
490
  DocsRenameMutation,
833
491
  SetTextSelectionsOperation
@@ -839,13 +497,10 @@ let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
839
497
  [
840
498
  [DocSelectionManagerService],
841
499
  [DocStateEmitService],
842
- [DocStateChangeManagerService],
843
- [DocContentInsertService],
844
500
  [DocCustomRangeController]
845
501
  ].forEach((d) => this._injector.add(d));
846
502
  }
847
503
  onReady() {
848
- this._injector.get(DocStateChangeManagerService);
849
504
  this._injector.get(DocCustomRangeController);
850
505
  }
851
506
  };
@@ -933,6 +588,25 @@ DocInterceptorService = __decorate([__decorateParam(1, (0, _univerjs_core.Inject
933
588
 
934
589
  //#endregion
935
590
  //#region src/utils/custom-range-factory.ts
591
+ /**
592
+ * @deprecated This is a duplication from docs-ui to avoid making too much breaking changes.
593
+ */
594
+ function getRichTextEditPath(docDataModel, segmentId = "") {
595
+ if (!segmentId) return ["body"];
596
+ const { headers, footers } = docDataModel.getSnapshot();
597
+ if (headers == null && footers == null) throw new Error("Document data model must have headers or footers when update by segment id");
598
+ if ((headers === null || headers === void 0 ? void 0 : headers[segmentId]) != null) return [
599
+ "headers",
600
+ segmentId,
601
+ "body"
602
+ ];
603
+ else if ((footers === null || footers === void 0 ? void 0 : footers[segmentId]) != null) return [
604
+ "footers",
605
+ segmentId,
606
+ "body"
607
+ ];
608
+ else throw new Error("Segment id not found in headers or footers");
609
+ }
936
610
  function addCustomRangeFactory(accessor, param, body) {
937
611
  const { unitId, segmentId } = param;
938
612
  const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId);
@@ -951,7 +625,7 @@ function addCustomRangeFactory(accessor, param, body) {
951
625
  body
952
626
  });
953
627
  if (!textX) return false;
954
- const path = (0, _univerjs_core.getRichTextEditPath)(documentDataModel, segmentId);
628
+ const path = getRichTextEditPath(documentDataModel, segmentId);
955
629
  doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
956
630
  return doMutation;
957
631
  }
@@ -991,7 +665,7 @@ function addCustomRangeBySelectionFactory(accessor, param) {
991
665
  },
992
666
  textX
993
667
  };
994
- const path = (0, _univerjs_core.getRichTextEditPath)(documentDataModel, segmentId);
668
+ const path = getRichTextEditPath(documentDataModel, segmentId);
995
669
  doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
996
670
  return doMutation;
997
671
  }
@@ -1016,7 +690,7 @@ function deleteCustomRangeFactory(accessor, params) {
1016
690
  segmentId
1017
691
  });
1018
692
  if (!textX) return false;
1019
- const path = (0, _univerjs_core.getRichTextEditPath)(documentDataModel, segmentId);
693
+ const path = getRichTextEditPath(documentDataModel, segmentId);
1020
694
  doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
1021
695
  doMutation.params.textRanges = textX.selections;
1022
696
  return doMutation;
@@ -1066,8 +740,6 @@ function replaceSelectionFactory(accessor, params) {
1066
740
 
1067
741
  //#endregion
1068
742
  exports.DOC_INTERCEPTOR_POINT = DOC_INTERCEPTOR_POINT;
1069
- exports.DeleteTextCommand = DeleteTextCommand;
1070
- exports.DocContentInsertService = DocContentInsertService;
1071
743
  Object.defineProperty(exports, 'DocInterceptorService', {
1072
744
  enumerable: true,
1073
745
  get: function () {
@@ -1086,15 +758,7 @@ Object.defineProperty(exports, 'DocSkeletonManagerService', {
1086
758
  return DocSkeletonManagerService;
1087
759
  }
1088
760
  });
1089
- Object.defineProperty(exports, 'DocStateChangeManagerService', {
1090
- enumerable: true,
1091
- get: function () {
1092
- return DocStateChangeManagerService;
1093
- }
1094
- });
1095
761
  exports.DocStateEmitService = DocStateEmitService;
1096
- exports.IDocStateChangeInterceptorService = IDocStateChangeInterceptorService;
1097
- exports.InsertTextCommand = InsertTextCommand;
1098
762
  exports.RichTextEditingMutation = RichTextEditingMutation;
1099
763
  exports.SetTextSelectionsOperation = SetTextSelectionsOperation;
1100
764
  Object.defineProperty(exports, 'UniverDocsPlugin', {
@@ -1103,7 +767,6 @@ Object.defineProperty(exports, 'UniverDocsPlugin', {
1103
767
  return UniverDocsPlugin;
1104
768
  }
1105
769
  });
1106
- exports.UpdateTextCommand = UpdateTextCommand;
1107
770
  exports.addCustomRangeBySelectionFactory = addCustomRangeBySelectionFactory;
1108
771
  exports.addCustomRangeFactory = addCustomRangeFactory;
1109
772
  exports.deleteCustomRangeFactory = deleteCustomRangeFactory;