@univerjs/docs-ui 1.0.4 → 1.1.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.
Files changed (88) hide show
  1. package/lib/cjs/index.js +412 -192
  2. package/lib/cjs/locale/ar-SA.js +2 -0
  3. package/lib/cjs/locale/ca-ES.js +2 -0
  4. package/lib/cjs/locale/de-DE.js +2 -0
  5. package/lib/cjs/locale/en-US.js +2 -0
  6. package/lib/cjs/locale/es-ES.js +2 -0
  7. package/lib/cjs/locale/fa-IR.js +2 -0
  8. package/lib/cjs/locale/fr-FR.js +2 -0
  9. package/lib/cjs/locale/id-ID.js +2 -0
  10. package/lib/cjs/locale/it-IT.js +2 -0
  11. package/lib/cjs/locale/ja-JP.js +2 -0
  12. package/lib/cjs/locale/ko-KR.js +2 -0
  13. package/lib/cjs/locale/pl-PL.js +2 -0
  14. package/lib/cjs/locale/pt-BR.js +2 -0
  15. package/lib/cjs/locale/ru-RU.js +2 -0
  16. package/lib/cjs/locale/sk-SK.js +2 -0
  17. package/lib/cjs/locale/vi-VN.js +2 -0
  18. package/lib/cjs/locale/zh-CN.js +2 -0
  19. package/lib/cjs/locale/zh-HK.js +2 -0
  20. package/lib/cjs/locale/zh-TW.js +2 -0
  21. package/lib/es/index.js +391 -177
  22. package/lib/es/locale/ar-SA.js +2 -0
  23. package/lib/es/locale/ca-ES.js +2 -0
  24. package/lib/es/locale/de-DE.js +2 -0
  25. package/lib/es/locale/en-US.js +2 -0
  26. package/lib/es/locale/es-ES.js +2 -0
  27. package/lib/es/locale/fa-IR.js +2 -0
  28. package/lib/es/locale/fr-FR.js +2 -0
  29. package/lib/es/locale/id-ID.js +2 -0
  30. package/lib/es/locale/it-IT.js +2 -0
  31. package/lib/es/locale/ja-JP.js +2 -0
  32. package/lib/es/locale/ko-KR.js +2 -0
  33. package/lib/es/locale/pl-PL.js +2 -0
  34. package/lib/es/locale/pt-BR.js +2 -0
  35. package/lib/es/locale/ru-RU.js +2 -0
  36. package/lib/es/locale/sk-SK.js +2 -0
  37. package/lib/es/locale/vi-VN.js +2 -0
  38. package/lib/es/locale/zh-CN.js +2 -0
  39. package/lib/es/locale/zh-HK.js +2 -0
  40. package/lib/es/locale/zh-TW.js +2 -0
  41. package/lib/index.css +5 -4
  42. package/lib/index.js +391 -177
  43. package/lib/locale/ar-SA.js +2 -0
  44. package/lib/locale/ca-ES.js +2 -0
  45. package/lib/locale/de-DE.js +2 -0
  46. package/lib/locale/en-US.js +2 -0
  47. package/lib/locale/es-ES.js +2 -0
  48. package/lib/locale/fa-IR.js +2 -0
  49. package/lib/locale/fr-FR.js +2 -0
  50. package/lib/locale/id-ID.js +2 -0
  51. package/lib/locale/it-IT.js +2 -0
  52. package/lib/locale/ja-JP.js +2 -0
  53. package/lib/locale/ko-KR.js +2 -0
  54. package/lib/locale/pl-PL.js +2 -0
  55. package/lib/locale/pt-BR.js +2 -0
  56. package/lib/locale/ru-RU.js +2 -0
  57. package/lib/locale/sk-SK.js +2 -0
  58. package/lib/locale/vi-VN.js +2 -0
  59. package/lib/locale/zh-CN.js +2 -0
  60. package/lib/locale/zh-HK.js +2 -0
  61. package/lib/locale/zh-TW.js +2 -0
  62. package/lib/types/index.d.ts +1 -0
  63. package/lib/types/locale/en-US.d.ts +2 -0
  64. package/lib/types/menu/display.menu.d.ts +21 -0
  65. package/lib/types/services/doc-paragraph-menu.service.d.ts +11 -2
  66. package/lib/types/services/doc-zoom.d.ts +4 -1
  67. package/lib/umd/facade.js +1 -1
  68. package/lib/umd/index.js +16 -16
  69. package/lib/umd/locale/ar-SA.js +1 -1
  70. package/lib/umd/locale/ca-ES.js +1 -1
  71. package/lib/umd/locale/de-DE.js +1 -1
  72. package/lib/umd/locale/en-US.js +1 -1
  73. package/lib/umd/locale/es-ES.js +1 -1
  74. package/lib/umd/locale/fa-IR.js +1 -1
  75. package/lib/umd/locale/fr-FR.js +1 -1
  76. package/lib/umd/locale/id-ID.js +1 -1
  77. package/lib/umd/locale/it-IT.js +1 -1
  78. package/lib/umd/locale/ja-JP.js +1 -1
  79. package/lib/umd/locale/ko-KR.js +1 -1
  80. package/lib/umd/locale/pl-PL.js +1 -1
  81. package/lib/umd/locale/pt-BR.js +1 -1
  82. package/lib/umd/locale/ru-RU.js +1 -1
  83. package/lib/umd/locale/sk-SK.js +1 -1
  84. package/lib/umd/locale/vi-VN.js +1 -1
  85. package/lib/umd/locale/zh-CN.js +1 -1
  86. package/lib/umd/locale/zh-HK.js +1 -1
  87. package/lib/umd/locale/zh-TW.js +1 -1
  88. package/package.json +13 -13
package/lib/cjs/index.js CHANGED
@@ -270,7 +270,7 @@ function getCustomDecorationAtPosition(customDecorations, position) {
270
270
  }
271
271
 
272
272
  //#endregion
273
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
273
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
274
274
  function _typeof(o) {
275
275
  "@babel/helpers - typeof";
276
276
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -281,7 +281,7 @@ function _typeof(o) {
281
281
  }
282
282
 
283
283
  //#endregion
284
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
284
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
285
285
  function toPrimitive(t, r) {
286
286
  if ("object" != _typeof(t) || !t) return t;
287
287
  var e = t[Symbol.toPrimitive];
@@ -294,14 +294,14 @@ function toPrimitive(t, r) {
294
294
  }
295
295
 
296
296
  //#endregion
297
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
297
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
298
298
  function toPropertyKey(t) {
299
299
  var i = toPrimitive(t, "string");
300
300
  return "symbol" == _typeof(i) ? i : i + "";
301
301
  }
302
302
 
303
303
  //#endregion
304
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
304
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
305
305
  function _defineProperty(e, r, t) {
306
306
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
307
307
  value: t,
@@ -312,7 +312,7 @@ function _defineProperty(e, r, t) {
312
312
  }
313
313
 
314
314
  //#endregion
315
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
315
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
316
316
  function __decorateParam(paramIndex, decorator) {
317
317
  return function(target, key) {
318
318
  decorator(target, key, paramIndex);
@@ -320,7 +320,7 @@ function __decorateParam(paramIndex, decorator) {
320
320
  }
321
321
 
322
322
  //#endregion
323
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
323
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
324
324
  function __decorate(decorators, target, key, desc) {
325
325
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
326
326
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -436,8 +436,8 @@ let DocMenuStyleService = class DocMenuStyleService extends _univerjs_core.Dispo
436
436
  }));
437
437
  }
438
438
  _listenDocRangeChange() {
439
- this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(() => {
440
- this._clearStyleCache();
439
+ this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(({ options }) => {
440
+ if (!(options === null || options === void 0 ? void 0 : options.preserveInputStyle)) this._clearStyleCache();
441
441
  }));
442
442
  }
443
443
  getStyleCache() {
@@ -3458,7 +3458,12 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
3458
3458
  this._addRectRanges(rectRanges);
3459
3459
  };
3460
3460
  for (const range of ranges) {
3461
- const { startOffset, endOffset, rangeType, startNodePosition, endNodePosition } = range;
3461
+ const { rangeType } = range;
3462
+ let { startOffset, endOffset, startNodePosition, endNodePosition } = range;
3463
+ if (rangeType !== _univerjs_core.DOC_RANGE_TYPE.RECT && range.direction === _univerjs_core.RANGE_DIRECTION.BACKWARD && startOffset < endOffset) {
3464
+ [startOffset, endOffset] = [endOffset, startOffset];
3465
+ [startNodePosition, endNodePosition] = [endNodePosition, startNodePosition];
3466
+ }
3462
3467
  const rangeStyle = range.style ?? style;
3463
3468
  if (rangeType !== _univerjs_core.DOC_RANGE_TYPE.RECT && startOffset === endOffset) {
3464
3469
  const textRange = cursorConvertToTextRange(scene, {
@@ -8561,23 +8566,39 @@ function getTableClipboardBodySlice(body, range) {
8561
8566
  return getTableCellContentClipboardBodySlice(body, startOffset, endOffset);
8562
8567
  }
8563
8568
  function getTableCellContentClipboardBodySlice(body, start, end) {
8564
- var _bodySlice$textRuns, _bodySlice$tables, _bodySlice$paragraphs;
8569
+ var _bodySlice$textRuns, _bodySlice$docxExport;
8565
8570
  const bodySlice = (0, _univerjs_core.getBodySlice)(body, start, end + 2);
8566
- bodySlice.dataStream = _univerjs_core.DataStreamTreeTokenType.TABLE_START + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START + bodySlice.dataStream + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END + _univerjs_core.DataStreamTreeTokenType.TABLE_END;
8571
+ const prefix = _univerjs_core.DataStreamTreeTokenType.TABLE_START + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START;
8572
+ bodySlice.dataStream = prefix + bodySlice.dataStream + _univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END + _univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END + _univerjs_core.DataStreamTreeTokenType.TABLE_END;
8573
+ const offset = prefix.length;
8567
8574
  (_bodySlice$textRuns = bodySlice.textRuns) === null || _bodySlice$textRuns === void 0 || _bodySlice$textRuns.forEach((textRun) => {
8568
- const { st, ed } = textRun;
8569
- textRun.st = st + 3;
8570
- textRun.ed = ed + 3;
8575
+ textRun.st += offset;
8576
+ textRun.ed += offset;
8571
8577
  });
8572
- (_bodySlice$tables = bodySlice.tables) === null || _bodySlice$tables === void 0 || _bodySlice$tables.forEach((table) => {
8573
- const { startIndex, endIndex } = table;
8574
- table.startIndex = startIndex + 3;
8575
- table.endIndex = endIndex + 3;
8576
- });
8577
- (_bodySlice$paragraphs = bodySlice.paragraphs) === null || _bodySlice$paragraphs === void 0 || _bodySlice$paragraphs.forEach((paragraph) => {
8578
- const { startIndex } = paragraph;
8579
- paragraph.startIndex = startIndex + 3;
8578
+ [
8579
+ bodySlice.paragraphs,
8580
+ bodySlice.sectionBreaks,
8581
+ bodySlice.customBlocks,
8582
+ bodySlice.docxRawCustomBlocks,
8583
+ bodySlice.docxRawBlocks
8584
+ ].forEach((items) => items === null || items === void 0 ? void 0 : items.forEach((item) => {
8585
+ item.startIndex += offset;
8586
+ }));
8587
+ [
8588
+ bodySlice.tables,
8589
+ bodySlice.columnGroups,
8590
+ bodySlice.blockRanges,
8591
+ bodySlice.customRanges,
8592
+ bodySlice.customDecorations
8593
+ ].forEach((ranges) => ranges === null || ranges === void 0 ? void 0 : ranges.forEach((range) => {
8594
+ range.startIndex += offset;
8595
+ range.endIndex += offset;
8596
+ }));
8597
+ (_bodySlice$docxExport = bodySlice.docxExportExcludedRanges) === null || _bodySlice$docxExport === void 0 || _bodySlice$docxExport.forEach((range) => {
8598
+ range.start += offset;
8599
+ range.end += offset;
8580
8600
  });
8601
+ if (bodySlice.renderedPageBreaks) bodySlice.renderedPageBreaks = bodySlice.renderedPageBreaks.map((index) => index + offset);
8581
8602
  return bodySlice;
8582
8603
  }
8583
8604
  const IDocClipboardService = (0, _univerjs_core.createIdentifier)("doc.clipboard-service");
@@ -12159,6 +12180,7 @@ function getLineFontFamily(line) {
12159
12180
  function drawParagraphPlaceholders(ctx, placeholders, color = PLACEHOLDER_COLOR) {
12160
12181
  ctx.save();
12161
12182
  ctx.fillStyle = color;
12183
+ ctx.globalAlpha *= .5;
12162
12184
  ctx.textBaseline = "alphabetic";
12163
12185
  for (const placeholder of placeholders) {
12164
12186
  const clipLeft = placeholder.clipLeft ?? placeholder.x;
@@ -12782,12 +12804,35 @@ var DocLayoutInteractionService = class extends _univerjs_core.Disposable {
12782
12804
  //#region src/services/doc-zoom.ts
12783
12805
  const DEFAULT_DOC_ZOOM_RATIO = 1;
12784
12806
  const DEFAULT_MODERN_DOC_ZOOM_RATIO = 1;
12807
+ const DOC_ZOOM_SHORTCUTS = [
12808
+ 50,
12809
+ 80,
12810
+ 100,
12811
+ 130,
12812
+ 150,
12813
+ 170,
12814
+ 200,
12815
+ 400
12816
+ ];
12785
12817
  function getDocEffectiveZoomRatio(documentModel) {
12786
12818
  var _documentModel$getSet, _documentModel$getSna;
12787
12819
  const zoomRatio = (_documentModel$getSet = documentModel.getSettings()) === null || _documentModel$getSet === void 0 ? void 0 : _documentModel$getSet.zoomRatio;
12788
12820
  if (zoomRatio != null) return zoomRatio;
12789
12821
  return ((_documentModel$getSna = documentModel.getSnapshot().documentStyle) === null || _documentModel$getSna === void 0 ? void 0 : _documentModel$getSna.documentFlavor) === _univerjs_core.DocumentFlavor.MODERN ? 1 : DEFAULT_DOC_ZOOM_RATIO;
12790
12822
  }
12823
+ function getDocZoomRatio$(commandService, instanceService) {
12824
+ return instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.switchMap)((documentModel) => {
12825
+ if (!documentModel) return (0, rxjs.of)(100);
12826
+ return new rxjs.Observable((subscriber) => {
12827
+ const update = () => subscriber.next(Math.round(getDocEffectiveZoomRatio(documentModel) * 100));
12828
+ const disposable = commandService.onCommandExecuted((command) => {
12829
+ if (command.id === SetDocZoomRatioOperation.id && command.params.unitId === documentModel.getUnitId()) update();
12830
+ });
12831
+ update();
12832
+ return () => disposable.dispose();
12833
+ });
12834
+ }), (0, rxjs.distinctUntilChanged)());
12835
+ }
12791
12836
 
12792
12837
  //#endregion
12793
12838
  //#region src/services/doc-view-scale.ts
@@ -13437,11 +13482,13 @@ function doesDocMutationRequireLayout(actions, drawings) {
13437
13482
  if (!sawComponent || !drawingOnly) return true;
13438
13483
  if (transitions.size === 0) return false;
13439
13484
  for (const [drawingId, transition] of transitions) {
13440
- var _drawings$drawingId;
13441
- const currentLayoutType = drawings === null || drawings === void 0 || (_drawings$drawingId = drawings[drawingId]) === null || _drawings$drawingId === void 0 ? void 0 : _drawings$drawingId.layoutType;
13485
+ var _currentDrawing$docTr, _currentDrawing$docTr2;
13486
+ const currentDrawing = drawings === null || drawings === void 0 ? void 0 : drawings[drawingId];
13487
+ const currentLayoutType = currentDrawing === null || currentDrawing === void 0 ? void 0 : currentDrawing.layoutType;
13442
13488
  const before = transition.before ?? currentLayoutType;
13443
13489
  const after = transition.after ?? currentLayoutType;
13444
13490
  if (before == null || after == null || before !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE || after !== _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return true;
13491
+ if ((currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr = currentDrawing.docTransform) === null || _currentDrawing$docTr === void 0 ? void 0 : _currentDrawing$docTr.positionH.relativeFrom) !== _univerjs_core.ObjectRelativeFromH.PAGE || (currentDrawing === null || currentDrawing === void 0 || (_currentDrawing$docTr2 = currentDrawing.docTransform) === null || _currentDrawing$docTr2 === void 0 ? void 0 : _currentDrawing$docTr2.positionV.relativeFrom) !== _univerjs_core.ObjectRelativeFromV.PAGE) return true;
13445
13492
  }
13446
13493
  return false;
13447
13494
  }
@@ -18463,6 +18510,46 @@ function PasteRibbonMenuFactory(accessor) {
18463
18510
  };
18464
18511
  }
18465
18512
 
18513
+ //#endregion
18514
+ //#region src/menu/display.menu.ts
18515
+ const DOC_ZOOM_RATIO_MENU_ID = "doc.menu.zoom-ratio";
18516
+ function DocZoomRatioMenuItemFactory(accessor) {
18517
+ const commandService = accessor.get(_univerjs_core.ICommandService);
18518
+ const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
18519
+ return {
18520
+ id: DOC_ZOOM_RATIO_MENU_ID,
18521
+ type: _univerjs_ui.MenuItemType.SELECTOR,
18522
+ icon: "ZoomInIcon",
18523
+ tooltip: "docs-ui.toolbar.zoom",
18524
+ selectionsCommandId: SetDocZoomRatioOperation.id,
18525
+ selections: DOC_ZOOM_SHORTCUTS.map((value) => ({
18526
+ value,
18527
+ label: `${value}%`,
18528
+ params: () => {
18529
+ var _instanceService$getC;
18530
+ return {
18531
+ unitId: (_instanceService$getC = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _instanceService$getC === void 0 ? void 0 : _instanceService$getC.getUnitId(),
18532
+ zoomRatio: value / 100
18533
+ };
18534
+ }
18535
+ })),
18536
+ value$: getDocZoomRatio$(commandService, instanceService),
18537
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
18538
+ };
18539
+ }
18540
+ function DocFullscreenMenuItemFactory(accessor) {
18541
+ const root = accessor.get(_univerjs_ui.ILayoutService).rootContainerElement;
18542
+ const fullscreen$ = root ? (0, rxjs.merge)((0, rxjs.of)(null), (0, rxjs.fromEvent)(root.ownerDocument, "fullscreenchange")).pipe((0, rxjs.map)(() => root.ownerDocument.fullscreenElement === root), (0, rxjs.distinctUntilChanged)()) : (0, rxjs.of)(false);
18543
+ return {
18544
+ id: _univerjs_ui.ToggleFullscreenOperation.id,
18545
+ type: _univerjs_ui.MenuItemType.BUTTON,
18546
+ tooltip: "docs-ui.toolbar.fullscreen",
18547
+ icon: fullscreen$.pipe((0, rxjs.map)((fullscreen) => fullscreen ? "ShrinkIcon" : "ExpandIcon")),
18548
+ activated$: fullscreen$,
18549
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
18550
+ };
18551
+ }
18552
+
18466
18553
  //#endregion
18467
18554
  //#region src/views/paragraph-menu/theme-color.ts
18468
18555
  function getHighlightBackgroundColor(themeService, index) {
@@ -18871,7 +18958,7 @@ function ParagraphMenuInsertBelowSubmenuItemFactory(accessor) {
18871
18958
  return {
18872
18959
  id: DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID,
18873
18960
  type: _univerjs_ui.MenuItemType.SUBITEMS,
18874
- icon: "TextTypeIcon",
18961
+ icon: "InsertBelowDoubleIcon",
18875
18962
  title: "docs-ui.rightClick.insertBellow",
18876
18963
  tooltip: "docs-ui.rightClick.insertBellow",
18877
18964
  hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_DOC)
@@ -19089,7 +19176,8 @@ const menuSchema = {
19089
19176
  order: 0,
19090
19177
  gridLayout: {
19091
19178
  row: 2,
19092
- column: 1
19179
+ column: 1,
19180
+ width: 44
19093
19181
  },
19094
19182
  menuItemFactory: BoldMenuItemFactory
19095
19183
  },
@@ -19097,7 +19185,8 @@ const menuSchema = {
19097
19185
  order: 1,
19098
19186
  gridLayout: {
19099
19187
  row: 2,
19100
- column: 2
19188
+ column: 2,
19189
+ width: 44
19101
19190
  },
19102
19191
  menuItemFactory: ItalicMenuItemFactory
19103
19192
  },
@@ -19105,7 +19194,8 @@ const menuSchema = {
19105
19194
  order: 2,
19106
19195
  gridLayout: {
19107
19196
  row: 2,
19108
- column: 3
19197
+ column: 3,
19198
+ width: 44
19109
19199
  },
19110
19200
  menuItemFactory: UnderlineMenuItemFactory
19111
19201
  },
@@ -19113,7 +19203,8 @@ const menuSchema = {
19113
19203
  order: 3,
19114
19204
  gridLayout: {
19115
19205
  row: 2,
19116
- column: 4
19206
+ column: 4,
19207
+ width: 44
19117
19208
  },
19118
19209
  menuItemFactory: StrikeThroughMenuItemFactory
19119
19210
  },
@@ -19121,7 +19212,8 @@ const menuSchema = {
19121
19212
  order: 4,
19122
19213
  gridLayout: {
19123
19214
  row: 2,
19124
- column: 5
19215
+ column: 6,
19216
+ width: 44
19125
19217
  },
19126
19218
  menuItemFactory: SubscriptMenuItemFactory
19127
19219
  },
@@ -19129,7 +19221,8 @@ const menuSchema = {
19129
19221
  order: 5,
19130
19222
  gridLayout: {
19131
19223
  row: 2,
19132
- column: 6
19224
+ column: 5,
19225
+ width: 44
19133
19226
  },
19134
19227
  menuItemFactory: SuperscriptMenuItemFactory
19135
19228
  },
@@ -19139,7 +19232,7 @@ const menuSchema = {
19139
19232
  row: 1,
19140
19233
  column: 1,
19141
19234
  columnSpan: 2,
19142
- width: 100
19235
+ width: 96
19143
19236
  },
19144
19237
  menuItemFactory: HeadingSelectorMenuItemFactory
19145
19238
  },
@@ -19148,7 +19241,8 @@ const menuSchema = {
19148
19241
  gridLayout: {
19149
19242
  row: 1,
19150
19243
  column: 7,
19151
- width: 64
19244
+ columnSpan: 2,
19245
+ width: 96
19152
19246
  },
19153
19247
  menuItemFactory: FontSizeSelectorMenuItemFactory
19154
19248
  },
@@ -19158,7 +19252,7 @@ const menuSchema = {
19158
19252
  row: 1,
19159
19253
  column: 3,
19160
19254
  columnSpan: 4,
19161
- width: 160
19255
+ width: 200
19162
19256
  },
19163
19257
  menuItemFactory: FontFamilySelectorMenuItemFactory
19164
19258
  },
@@ -19166,7 +19260,8 @@ const menuSchema = {
19166
19260
  order: 8,
19167
19261
  gridLayout: {
19168
19262
  row: 2,
19169
- column: 7
19263
+ column: 8,
19264
+ width: 44
19170
19265
  },
19171
19266
  menuItemFactory: TextColorSelectorMenuItemFactory,
19172
19267
  [ResetInlineFormatTextColorCommand.id]: {
@@ -19178,7 +19273,8 @@ const menuSchema = {
19178
19273
  order: 9,
19179
19274
  gridLayout: {
19180
19275
  row: 2,
19181
- column: 8
19276
+ column: 7,
19277
+ width: 44
19182
19278
  },
19183
19279
  menuItemFactory: BackgroundColorSelectorMenuItemFactory,
19184
19280
  [ResetInlineFormatTextBackgroundColorCommand.id]: {
@@ -19229,16 +19325,6 @@ const menuSchema = {
19229
19325
  showLabel: true
19230
19326
  },
19231
19327
  menuItemFactory: HeaderFooterMenuItemFactory
19232
- },
19233
- [DocOpenPageSettingCommand.id]: {
19234
- order: 12,
19235
- gridLayout: {
19236
- row: 1,
19237
- column: 4,
19238
- rowSpan: 2,
19239
- showLabel: true
19240
- },
19241
- menuItemFactory: PageSettingMenuItemFactory
19242
19328
  }
19243
19329
  },
19244
19330
  [_univerjs_ui.RibbonInsertGroup.MEDIA]: {
@@ -19313,6 +19399,34 @@ const menuSchema = {
19313
19399
  menuItemFactory: SymbolPickerMenuItemFactory
19314
19400
  }
19315
19401
  },
19402
+ [_univerjs_ui.RibbonViewGroup.DISPLAY]: {
19403
+ [DocOpenPageSettingCommand.id]: {
19404
+ order: 0,
19405
+ gridLayout: {
19406
+ row: 1,
19407
+ column: 1,
19408
+ rowSpan: 2,
19409
+ showLabel: true
19410
+ },
19411
+ menuItemFactory: PageSettingMenuItemFactory
19412
+ },
19413
+ [DOC_ZOOM_RATIO_MENU_ID]: {
19414
+ order: 1,
19415
+ gridLayout: {
19416
+ row: 1,
19417
+ column: 2
19418
+ },
19419
+ menuItemFactory: DocZoomRatioMenuItemFactory
19420
+ },
19421
+ [_univerjs_ui.ToggleFullscreenOperation.id]: {
19422
+ order: 2,
19423
+ gridLayout: {
19424
+ row: 2,
19425
+ column: 2
19426
+ },
19427
+ menuItemFactory: DocFullscreenMenuItemFactory
19428
+ }
19429
+ },
19316
19430
  [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: {
19317
19431
  [_univerjs_ui.ContextMenuGroup.OTHERS]: { [OpenDocParagraphPermissionOperation.id]: {
19318
19432
  order: 10,
@@ -20031,45 +20145,23 @@ const BulletListShortCut = {
20031
20145
 
20032
20146
  //#endregion
20033
20147
  //#region src/views/count-bar/ZoomSlider.tsx
20034
- const ZOOM_MAP = [
20035
- 50,
20036
- 80,
20037
- 100,
20038
- 130,
20039
- 150,
20040
- 170,
20041
- 200,
20042
- 400
20043
- ];
20044
20148
  const DOC_ZOOM_RANGE = [10, 400];
20045
20149
  function ZoomSlider() {
20046
20150
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
20047
20151
  const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
20048
- const documentDataModel = (0, _univerjs_ui.useObservable)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.filter)((documentDataModel) => documentDataModel != null)), null, false, [univerInstanceService]);
20049
- const getCurrentZoom = (0, react.useCallback)((docModel = documentDataModel) => {
20050
- if (!docModel) return 100;
20051
- return Math.round(getDocEffectiveZoomRatio(docModel) * 100);
20052
- }, [documentDataModel]);
20053
- const [zoom, setZoom] = (0, react.useState)(100);
20054
- (0, react.useEffect)(() => setZoom(getCurrentZoom(documentDataModel)), [documentDataModel, getCurrentZoom]);
20055
- (0, react.useEffect)(() => {
20056
- return commandService.onCommandExecuted((commandInfo) => {
20057
- if (commandInfo.id === SetDocZoomRatioOperation.id) setZoom(getCurrentZoom());
20058
- }).dispose;
20059
- }, [commandService, getCurrentZoom]);
20152
+ const zoom = (0, _univerjs_ui.useObservable)(() => getDocZoomRatio$(commandService, univerInstanceService), 100, void 0, [commandService, univerInstanceService]);
20060
20153
  function handleChange(value) {
20061
- setZoom(value);
20154
+ const documentDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
20062
20155
  if (documentDataModel == null) return;
20063
- const zoomRatio = value / 100;
20064
- commandService.executeCommand(SetDocZoomRatioOperation.id, {
20156
+ return commandService.executeCommand(SetDocZoomRatioOperation.id, {
20065
20157
  unitId: documentDataModel.getUnitId(),
20066
- zoomRatio
20158
+ zoomRatio: value / 100
20067
20159
  });
20068
20160
  }
20069
20161
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.Slider, {
20070
20162
  min: DOC_ZOOM_RANGE[0],
20071
20163
  value: zoom,
20072
- shortcuts: ZOOM_MAP,
20164
+ shortcuts: DOC_ZOOM_SHORTCUTS,
20073
20165
  onChange: handleChange
20074
20166
  });
20075
20167
  }
@@ -21340,7 +21432,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
21340
21432
  //#endregion
21341
21433
  //#region package.json
21342
21434
  var name = "@univerjs/docs-ui";
21343
- var version = "1.0.4";
21435
+ var version = "1.1.0";
21344
21436
 
21345
21437
  //#endregion
21346
21438
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -24528,6 +24620,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
24528
24620
  H5Icon: _univerjs_icons.H5Icon,
24529
24621
  HeaderFooterIcon: _univerjs_icons.HeaderFooterIcon,
24530
24622
  HorizontallyIcon: _univerjs_icons.HorizontallyIcon,
24623
+ InsertBelowDoubleIcon: _univerjs_icons.InsertBelowDoubleIcon,
24531
24624
  InsertDoubleIcon: _univerjs_icons.InsertDoubleIcon,
24532
24625
  InsertRowAboveDoubleIcon: _univerjs_icons.InsertRowAboveDoubleIcon,
24533
24626
  InsertRowBelowDoubleIcon: _univerjs_icons.InsertRowBelowDoubleIcon,
@@ -24560,6 +24653,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
24560
24653
  TodoListDoubleIcon: _univerjs_icons.TodoListDoubleIcon,
24561
24654
  UnderlineIcon: _univerjs_icons.UnderlineIcon,
24562
24655
  UnorderIcon: _univerjs_icons.UnorderIcon,
24656
+ ZoomInIcon: _univerjs_icons.ZoomInIcon,
24563
24657
  DefaultTextColorIcon,
24564
24658
  HeaderTextColorIcon,
24565
24659
  MoreRightIcon: _univerjs_icons.MoreRightIcon,
@@ -28308,6 +28402,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28308
28402
  var _this$_paragraphMenu2;
28309
28403
  return ((_this$_paragraphMenu2 = this._paragraphMenu) === null || _this$_paragraphMenu2 === void 0 ? void 0 : _this$_paragraphMenu2.target) ?? null;
28310
28404
  }
28405
+ get focusedTableTarget() {
28406
+ var _this$_focusedTableMe;
28407
+ return ((_this$_focusedTableMe = this._focusedTableMenu) === null || _this$_focusedTableMe === void 0 ? void 0 : _this$_focusedTableMe.target) ?? null;
28408
+ }
28311
28409
  setBlockMenuDragging(isDragging) {
28312
28410
  this._isBlockMenuDragging = isDragging;
28313
28411
  if (isDragging) this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
@@ -28335,6 +28433,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28335
28433
  _defineProperty(this, "_paragraphMenu", null);
28336
28434
  _defineProperty(this, "_activeTarget$", new rxjs.BehaviorSubject(null));
28337
28435
  _defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
28436
+ _defineProperty(this, "_focusedTableMenu", null);
28437
+ _defineProperty(this, "_focusedTableTarget$", new rxjs.BehaviorSubject(null));
28438
+ _defineProperty(this, "focusedTableTarget$", this._focusedTableTarget$.asObservable());
28439
+ _defineProperty(this, "_focusedTableMenuDismiss$", new rxjs.Subject());
28440
+ _defineProperty(this, "focusedTableMenuDismiss$", this._focusedTableMenuDismiss$.asObservable());
28338
28441
  _defineProperty(this, "_slashMenuRequest$", new rxjs.BehaviorSubject(null));
28339
28442
  _defineProperty(this, "slashMenuRequest$", this._slashMenuRequest$.asObservable());
28340
28443
  _defineProperty(this, "_isBlockMenuDragging", false);
@@ -28350,6 +28453,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28350
28453
  this._isBlockMenuDragging = false;
28351
28454
  this.hideParagraphMenu(true);
28352
28455
  }
28456
+ if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
28353
28457
  }));
28354
28458
  }
28355
28459
  _isCursorInActiveParagraph() {
@@ -28386,9 +28490,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28386
28490
  _hasExpandedSelection() {
28387
28491
  return this._hasExpandedSelectionRanges(this._docSelectionManagerService.getDocRanges());
28388
28492
  }
28389
- setParagraphMenuActive(active) {
28390
- if (this._paragraphMenu) this._paragraphMenu.active = active;
28391
- if (active && this._paragraphMenu) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
28493
+ setParagraphMenuActive(active, focusedTable = false) {
28494
+ var _this$_paragraphMenu3, _this$_focusedTableMe2;
28495
+ const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
28496
+ if (menu) menu.active = active;
28497
+ if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.active) || ((_this$_focusedTableMe2 = this._focusedTableMenu) === null || _this$_focusedTableMe2 === void 0 ? void 0 : _this$_focusedTableMe2.active)) this._menuInteraction ??= this._docLayoutInteractionService.beginInteraction();
28392
28498
  else {
28393
28499
  var _this$_menuInteractio;
28394
28500
  (_this$_menuInteractio = this._menuInteraction) === null || _this$_menuInteractio === void 0 || _this$_menuInteractio.dispose();
@@ -28397,7 +28503,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28397
28503
  }
28398
28504
  _init() {
28399
28505
  const handleHoverTarget = (paragraph, tableBound) => {
28506
+ var _this$_focusedTableMe3;
28400
28507
  if (this._isBlockMenuDragging) return;
28508
+ if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
28401
28509
  if (this._docSelectionRenderService.isOnPointerEvent) {
28402
28510
  this.hideParagraphMenu(true);
28403
28511
  return;
@@ -28408,18 +28516,18 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28408
28516
  return;
28409
28517
  }
28410
28518
  if (selectionState.hasRectRange) {
28411
- var _this$_paragraphMenu3;
28519
+ var _this$_paragraphMenu4;
28412
28520
  if (tableBound) {
28413
28521
  this.showTableMenu(tableBound);
28414
28522
  return;
28415
28523
  }
28416
- if (((_this$_paragraphMenu3 = this._paragraphMenu) === null || _this$_paragraphMenu3 === void 0 ? void 0 : _this$_paragraphMenu3.target.kind) === _univerjs_core.DocumentBlockType.TABLE) return;
28524
+ if (((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.target.kind) === _univerjs_core.DocumentBlockType.TABLE) return;
28417
28525
  this.hideParagraphMenu(true);
28418
28526
  return;
28419
28527
  }
28420
28528
  if (this._docSkeletonManagerService.getViewModel().getEditArea() === _univerjs_engine_render.DocumentEditArea.BODY && !this._floatMenuService.floatMenu && !this._context.unit.getDisabled() && this._canEditDocument()) {
28421
- var _this$_paragraphMenu4;
28422
- if ((_this$_paragraphMenu4 = this._paragraphMenu) === null || _this$_paragraphMenu4 === void 0 ? void 0 : _this$_paragraphMenu4.active) return;
28529
+ var _this$_paragraphMenu5;
28530
+ if ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.active) return;
28423
28531
  if (paragraph) {
28424
28532
  this.showParagraphMenu(paragraph);
28425
28533
  return;
@@ -28445,16 +28553,17 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28445
28553
  this.hideParagraphMenu(true);
28446
28554
  }));
28447
28555
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
28448
- var _this$_paragraphMenu5;
28556
+ var _this$_paragraphMenu6;
28449
28557
  const selectionState = this._getExpandedSelectionState([...textRanges, ...rectRanges]);
28450
- if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu5 = this._paragraphMenu) === null || _this$_paragraphMenu5 === void 0 ? void 0 : _this$_paragraphMenu5.target.kind) !== _univerjs_core.DocumentBlockType.TABLE) this.hideParagraphMenu(true);
28558
+ if (selectionState.hasExpandedTextRange || selectionState.hasRectRange && ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.target.kind) !== _univerjs_core.DocumentBlockType.TABLE) this.hideParagraphMenu(true);
28451
28559
  }));
28452
28560
  let lastScrollY = 0;
28453
28561
  this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
28454
- var _this$_paragraphMenu6;
28562
+ var _this$_paragraphMenu7;
28455
28563
  if (lastScrollY === e.scrollY) return;
28456
28564
  lastScrollY = e.scrollY;
28457
- if ((_this$_paragraphMenu6 = this._paragraphMenu) === null || _this$_paragraphMenu6 === void 0 ? void 0 : _this$_paragraphMenu6.blockRange) return;
28565
+ this._focusedTableMenuDismiss$.next();
28566
+ if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
28458
28567
  if (this._isBlockMenuDragging) return;
28459
28568
  this.hideParagraphMenu(true);
28460
28569
  }));
@@ -28465,6 +28574,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28465
28574
  this.disposeWithMe(this._docSelectionRenderService.onKeydown$.subscribe((config) => {
28466
28575
  if (this._isBlockMenuDragging) return;
28467
28576
  if (this._handleSlashMenuKeydown(config)) return;
28577
+ this._focusedTableMenuDismiss$.next();
28468
28578
  this.hideParagraphMenu(true);
28469
28579
  }));
28470
28580
  this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
@@ -28520,10 +28630,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28520
28630
  return null;
28521
28631
  }
28522
28632
  _getSlashMenuParagraph(config) {
28523
- var _this$_paragraphMenu7;
28633
+ var _this$_paragraphMenu8;
28524
28634
  const activeRange = this._getCollapsedTextRange(config);
28525
28635
  const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
28526
- const activeParagraph = ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.paragraph) ?? null;
28636
+ const activeParagraph = ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.paragraph) ?? null;
28527
28637
  if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
28528
28638
  if (activeParagraph && offset == null) return activeParagraph;
28529
28639
  if (offset == null) return null;
@@ -28544,7 +28654,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28544
28654
  }
28545
28655
  }
28546
28656
  showParagraphMenu(paragraph) {
28547
- var _this$_paragraphMenu8;
28657
+ var _this$_paragraphMenu9;
28548
28658
  if (this._hasExpandedSelection()) {
28549
28659
  this.hideParagraphMenu(true);
28550
28660
  return;
@@ -28554,7 +28664,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28554
28664
  this.hideParagraphMenu(true);
28555
28665
  return;
28556
28666
  }
28557
- if (((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.target.key) === target.key) return;
28667
+ if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
28558
28668
  this.hideParagraphMenu(true);
28559
28669
  const targetParagraph = target.paragraph ?? paragraph;
28560
28670
  const blockRange = target.blockRange;
@@ -28589,15 +28699,19 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28589
28699
  };
28590
28700
  this._activeTarget$.next(target);
28591
28701
  }
28592
- showTableMenu(tableBound) {
28593
- var _body$tables, _this$_paragraphMenu9;
28594
- if (this._hasExpandedTextSelection()) {
28702
+ showTableMenu(tableBound, focused = false) {
28703
+ var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu10;
28704
+ if (!focused && ((_this$_focusedTableMe4 = this._focusedTableMenu) === null || _this$_focusedTableMe4 === void 0 || (_this$_focusedTableMe4 = _this$_focusedTableMe4.target.table) === null || _this$_focusedTableMe4 === void 0 ? void 0 : _this$_focusedTableMe4.tableId) === tableBound.tableId) return;
28705
+ if (!focused && this._hasExpandedTextSelection()) {
28595
28706
  this.hideParagraphMenu(true);
28596
28707
  return;
28597
28708
  }
28598
28709
  const body = this._context.unit.getBody();
28599
28710
  const table = body === null || body === void 0 || (_body$tables = body.tables) === null || _body$tables === void 0 ? void 0 : _body$tables.find((item) => item.tableId === tableBound.tableId);
28600
- if (!table) return;
28711
+ if (!table) {
28712
+ if (focused) this.hideFocusedTableMenu();
28713
+ return;
28714
+ }
28601
28715
  const target = {
28602
28716
  kind: _univerjs_core.DocumentBlockType.TABLE,
28603
28717
  key: `${_univerjs_core.DocumentBlockType.TABLE}:${table.tableId}`,
@@ -28610,17 +28724,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28610
28724
  },
28611
28725
  moveRange: {
28612
28726
  startOffset: table.startIndex,
28613
- endOffset: table.endIndex
28727
+ endOffset: table.endIndex + ((body === null || body === void 0 ? void 0 : body.dataStream[table.endIndex]) === "\r" ? 1 : 0)
28614
28728
  },
28615
28729
  emptyMode: false,
28616
28730
  draggable: true
28617
28731
  };
28618
28732
  if (!this._canEditDocument(target.menuRange)) {
28733
+ if (focused) {
28734
+ this.hideFocusedTableMenu();
28735
+ return;
28736
+ }
28619
28737
  this.hideParagraphMenu(true);
28620
28738
  return;
28621
28739
  }
28622
- if (this._shouldKeepCurrentCellMenuForTable(table)) return;
28623
- if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
28740
+ if (!focused && this._shouldKeepCurrentCellMenuForTable(table)) return;
28741
+ if (!focused && ((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
28624
28742
  const anchorRect = getTableAnchorRect(tableBound);
28625
28743
  const paragraph = {
28626
28744
  rect: tableBound.rect,
@@ -28631,8 +28749,16 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28631
28749
  pageIndex: tableBound.pageIndex,
28632
28750
  firstLine: anchorRect
28633
28751
  };
28752
+ if (focused) {
28753
+ target.paragraph = paragraph;
28754
+ this._showFocusedTableMenu(tableBound, target);
28755
+ return;
28756
+ }
28757
+ this._showHoverTableMenu(tableBound, target, paragraph);
28758
+ }
28759
+ _showHoverTableMenu(tableBound, target, paragraph) {
28634
28760
  this.hideParagraphMenu(true);
28635
- const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(table.tableId) ?? tableBound);
28761
+ const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
28636
28762
  const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
28637
28763
  componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
28638
28764
  constrainToCanvas: true,
@@ -28651,9 +28777,40 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28651
28777
  };
28652
28778
  this._activeTarget$.next(target);
28653
28779
  }
28780
+ _showFocusedTableMenu(tableBound, target) {
28781
+ var _this$_focusedTableMe5, _this$_paragraphMenu11;
28782
+ if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
28783
+ this._focusedTableMenu.target = target;
28784
+ this._focusedTableMenu.bound = tableBound;
28785
+ this._focusedTableTarget$.next(target);
28786
+ return;
28787
+ }
28788
+ this.hideFocusedTableMenu();
28789
+ if (((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) this.hideParagraphMenu(true);
28790
+ const getFocusedAnchor = () => {
28791
+ var _this$_focusedTableMe6;
28792
+ return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
28793
+ };
28794
+ const disposable = this._docPopupManagerService.attachPopupToRect(getFocusedAnchor, {
28795
+ componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
28796
+ extraProps: { focusedTableMenu: true },
28797
+ constrainToCanvas: true,
28798
+ requiresStableLayout: false,
28799
+ direction: "top-right",
28800
+ onClickOutside: () => this._focusedTableMenuDismiss$.next(),
28801
+ zIndex: 102
28802
+ }, this._context.unitId);
28803
+ this._focusedTableMenu = {
28804
+ target,
28805
+ bound: tableBound,
28806
+ disposable,
28807
+ active: false
28808
+ };
28809
+ this._focusedTableTarget$.next(target);
28810
+ }
28654
28811
  _shouldKeepCurrentCellMenuForTable(table) {
28655
- var _this$_paragraphMenu10;
28656
- const target = (_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target;
28812
+ var _this$_paragraphMenu12;
28813
+ const target = (_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.target;
28657
28814
  if (!target || target.kind === _univerjs_core.DocumentBlockType.TABLE || !target.cellRange) return false;
28658
28815
  return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
28659
28816
  }
@@ -28696,22 +28853,32 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28696
28853
  hideParagraphMenu(force = false) {
28697
28854
  if (this._isBlockMenuDragging) return;
28698
28855
  if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
28699
- var _this$_menuInteractio2;
28700
28856
  this._paragraphMenu.disposable.dispose();
28701
28857
  this._paragraphMenu = null;
28702
- (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
28703
- this._menuInteraction = null;
28858
+ this.setParagraphMenuActive(false);
28704
28859
  this._isSlashMenuActive = false;
28705
28860
  this._slashMenuRequest$.next(null);
28706
28861
  this._activeTarget$.next(null);
28707
28862
  }
28708
28863
  }
28864
+ hideFocusedTableMenu() {
28865
+ var _this$_focusedTableMe7;
28866
+ (_this$_focusedTableMe7 = this._focusedTableMenu) === null || _this$_focusedTableMe7 === void 0 || _this$_focusedTableMe7.disposable.dispose();
28867
+ this._focusedTableMenu = null;
28868
+ this._focusedTableTarget$.next(null);
28869
+ this.setParagraphMenuActive(false, true);
28870
+ }
28709
28871
  _canEditDocument(range, segmentId = "") {
28710
28872
  return (0, _univerjs_docs.canEditDocumentTargets)(this._permissionService, this._context.unitId, range ? (0, _univerjs_docs.getDocumentEditTargetObjectIds)(this._context.unit, segmentId, range) : []);
28711
28873
  }
28712
28874
  dispose() {
28713
- var _this$_menuInteractio3, _this$_dragInteractio2;
28714
- (_this$_menuInteractio3 = this._menuInteraction) === null || _this$_menuInteractio3 === void 0 || _this$_menuInteractio3.dispose();
28875
+ var _this$_menuInteractio2, _this$_dragInteractio2;
28876
+ this._isBlockMenuDragging = false;
28877
+ this.hideFocusedTableMenu();
28878
+ this.hideParagraphMenu(true);
28879
+ this._focusedTableTarget$.complete();
28880
+ this._focusedTableMenuDismiss$.complete();
28881
+ (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
28715
28882
  this._menuInteraction = null;
28716
28883
  (_this$_dragInteractio2 = this._dragInteraction) === null || _this$_dragInteractio2 === void 0 || _this$_dragInteractio2.dispose();
28717
28884
  this._dragInteraction = null;
@@ -29043,9 +29210,6 @@ function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
29043
29210
  }
29044
29211
  };
29045
29212
  }
29046
- function setParagraphMenuInteractionActive(docParagraphMenuService, active) {
29047
- docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active);
29048
- }
29049
29213
  function isEmptyParagraphMenuTarget(dataStream, paragraph) {
29050
29214
  if (!paragraph) return false;
29051
29215
  return dataStream.slice(paragraph.paragraphStart, paragraph.paragraphEnd).replace(/[\r\n]/g, "") === "";
@@ -29455,7 +29619,7 @@ function getBlockRangeClipboardTargetRange(commandId, target, paragraph) {
29455
29619
  return null;
29456
29620
  }
29457
29621
  function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29458
- var _doc$getBody, _paragraphObj$paragra;
29622
+ var _popup$extraProps, _doc$getBody, _paragraphObj$paragra;
29459
29623
  const [visible, setVisible] = (0, react.useState)(false);
29460
29624
  const [openMode, setOpenMode] = (0, react.useState)("pointer");
29461
29625
  const [anchorRect, setAnchorRect] = (0, react.useState)(null);
@@ -29464,10 +29628,12 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29464
29628
  const targetRangeRef = (0, react.useRef)(null);
29465
29629
  const dragTargetOffsetRef = (0, react.useRef)(null);
29466
29630
  const dragRangeRef = (0, react.useRef)(null);
29631
+ const dragCleanupRef = (0, react.useRef)(null);
29467
29632
  const isDraggingRef = (0, react.useRef)(false);
29468
29633
  const openMenuRef = (0, react.useRef)(() => void 0);
29469
29634
  const hoverOpenSchedulerRef = (0, react.useRef)(createParagraphMenuHoverOpenScheduler(() => openMenuRef.current()));
29470
29635
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
29636
+ const logService = (0, _univerjs_ui.useDependency)(_univerjs_core.ILogService);
29471
29637
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
29472
29638
  const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
29473
29639
  const docSelectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_docs.DocSelectionManagerService);
@@ -29488,12 +29654,20 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29488
29654
  const doc = univerInstanceService.getUnit(popup.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
29489
29655
  const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
29490
29656
  const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
29491
- const activeTarget = (0, _univerjs_ui.useObservable)(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
29657
+ const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
29658
+ const activeTarget = (0, _univerjs_ui.useObservable)(isFocusedTableMenu ? docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget$ : docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget$);
29492
29659
  const slashMenuRequest = (0, _univerjs_ui.useObservable)(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
29493
29660
  const paragraph = (0, _univerjs_ui.useObservable)(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraph$);
29494
29661
  const paragraphLeft = (0, _univerjs_ui.useObservable)(docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.hoverParagraphLeft$);
29495
- const rawActiveTarget = activeTarget ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget);
29496
- const currentActiveTarget = tableBlockOnly ? (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? rawActiveTarget : null : (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" ? null : rawActiveTarget;
29662
+ const getActiveTarget = () => {
29663
+ if (isFocusedTableMenu) return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.focusedTableTarget) ?? activeTarget;
29664
+ return (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29665
+ };
29666
+ const setMenuInteractionActive = (active) => {
29667
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
29668
+ };
29669
+ const rawActiveTarget = getActiveTarget();
29670
+ const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === tableBlockOnly ? rawActiveTarget : null;
29497
29671
  const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
29498
29672
  const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
29499
29673
  const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
@@ -29546,13 +29720,41 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29546
29720
  if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
29547
29721
  }, [layoutService]);
29548
29722
  (0, react.useLayoutEffect)(() => restoreMenuFocus, [restoreMenuFocus]);
29549
- const handleHideMenu = () => {
29723
+ const handleHideMenu = (0, react.useCallback)(() => {
29724
+ hoverOpenSchedulerRef.current.cancel();
29550
29725
  restoreMenuFocus();
29551
29726
  setVisible(false);
29552
29727
  setOpenMode("pointer");
29553
29728
  targetRangeRef.current = null;
29554
- setParagraphMenuInteractionActive(docParagraphMenuService, false);
29555
- };
29729
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
29730
+ }, [
29731
+ docParagraphMenuService,
29732
+ isFocusedTableMenu,
29733
+ restoreMenuFocus
29734
+ ]);
29735
+ (0, react.useEffect)(() => {
29736
+ if (!isFocusedTableMenu || !docParagraphMenuService) return;
29737
+ const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
29738
+ const ownerDocument = popup.canvasElement.ownerDocument;
29739
+ const handleKeydown = (event) => {
29740
+ if (event.key === "Escape") {
29741
+ event.preventDefault();
29742
+ event.stopPropagation();
29743
+ handleHideMenu();
29744
+ }
29745
+ };
29746
+ if (visible) ownerDocument.addEventListener("keydown", handleKeydown, true);
29747
+ return () => {
29748
+ subscription.unsubscribe();
29749
+ ownerDocument.removeEventListener("keydown", handleKeydown, true);
29750
+ };
29751
+ }, [
29752
+ docParagraphMenuService,
29753
+ isFocusedTableMenu,
29754
+ handleHideMenu,
29755
+ popup.canvasElement,
29756
+ visible
29757
+ ]);
29556
29758
  const clearHideTimer = () => {
29557
29759
  if (hideTimerRef.current != null) {
29558
29760
  window.clearTimeout(hideTimerRef.current);
@@ -29570,8 +29772,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29570
29772
  const handleOpenMenu = (mode = "pointer") => {
29571
29773
  clearHideTimer();
29572
29774
  if (openMode === "slash") return;
29573
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29574
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
29775
+ const latestTarget = getActiveTarget();
29776
+ setMenuInteractionActive(true);
29575
29777
  const targetRange = latestTarget ? {
29576
29778
  ...latestTarget.menuRange,
29577
29779
  segmentId: activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.segmentId
@@ -29619,7 +29821,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29619
29821
  return commandService.executeCommand(resolved.commandId, resolved.params);
29620
29822
  };
29621
29823
  const unwrapActiveBlockRange = async () => {
29622
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29824
+ const latestTarget = getActiveTarget();
29623
29825
  if (!latestTarget || latestTarget.kind !== "blockRange" || !latestTarget.blockRange || !(doc === null || doc === void 0 ? void 0 : doc.getBody())) return null;
29624
29826
  const previousBody = doc.getBody();
29625
29827
  const { body, range } = unwrapBlockRangeBody(previousBody, latestTarget.blockRange);
@@ -29642,7 +29844,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29642
29844
  return nextRange;
29643
29845
  };
29644
29846
  const executeParagraphMenuOption = async (option) => {
29645
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
29847
+ const latestTarget = getActiveTarget();
29646
29848
  const targetRange = getTargetSelectionRange(latestTarget, activeParagraphBound ?? void 0);
29647
29849
  const blockRange = getBlockSelectionRange(latestTarget, activeParagraphBound ?? void 0);
29648
29850
  const formattingRange = getParagraphFormattingRange(latestTarget, activeParagraphBound ?? void 0);
@@ -29746,31 +29948,35 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29746
29948
  const hoverBridgeStyle = visible && (menuDirection === "left" || menuDirection === "right") ? getParagraphMenuHoverBridgeStyle(anchorRect, menuDirection) : void 0;
29747
29949
  const resolvedParagraphMenuType = openMode === "slash" ? DOC_PARAGRAPH_T_INSERT_MENU_ID : paragraphMenuType;
29748
29950
  (0, react.useEffect)(() => () => {
29951
+ var _dragCleanupRef$curre;
29952
+ (_dragCleanupRef$curre = dragCleanupRef.current) === null || _dragCleanupRef$curre === void 0 || _dragCleanupRef$curre.call(dragCleanupRef);
29749
29953
  if (hideTimerRef.current != null) {
29750
29954
  window.clearTimeout(hideTimerRef.current);
29751
29955
  hideTimerRef.current = null;
29752
29956
  }
29753
29957
  hoverOpenSchedulerRef.current.cancel();
29754
- setParagraphMenuInteractionActive(docParagraphMenuService, false);
29755
- }, []);
29958
+ docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
29959
+ }, [docParagraphMenuService, isFocusedTableMenu]);
29756
29960
  (0, react.useEffect)(() => {
29757
- if (!slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
29961
+ if (tableBlockOnly || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
29758
29962
  handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
29759
29963
  hoverOpenSchedulerRef.current.cancel();
29760
29964
  clearHideTimer();
29761
29965
  isMouseOver.current = false;
29762
29966
  handleOpenSlashMenu(slashMenuRequest);
29763
- }, [slashMenuRequest]);
29967
+ }, [slashMenuRequest, tableBlockOnly]);
29764
29968
  if (!currentActiveTarget) return null;
29765
29969
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
29766
29970
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
29767
29971
  "data-u-comp": "paragraph-menu",
29972
+ "data-u-table-menu": tableBlockOnly ? "true" : void 0,
29973
+ "data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
29768
29974
  ref: anchorRef,
29769
- className: (0, _univerjs_design.clsx)("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-700 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
29975
+ className: (0, _univerjs_design.clsx)("univer-mr-1 univer-inline-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1 univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-2 univer-py-0 univer-shadow-sm univer-transition-colors hover:univer-bg-gray-50 hover:univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible }),
29770
29976
  onMouseEnter: (e) => {
29771
29977
  var _popup$onPointerEnter;
29772
29978
  (_popup$onPointerEnter = popup.onPointerEnter) === null || _popup$onPointerEnter === void 0 || _popup$onPointerEnter.call(popup, e);
29773
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
29979
+ setMenuInteractionActive(true);
29774
29980
  isMouseOver.current = true;
29775
29981
  scheduleOpenMenu();
29776
29982
  },
@@ -29792,7 +29998,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29792
29998
  title: localeService.t("docs-ui.doc.blockMenu.dragBlock"),
29793
29999
  onPointerDown: (event) => {
29794
30000
  var _event$currentTarget$, _event$currentTarget;
29795
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
30001
+ const latestTarget = getActiveTarget();
29796
30002
  const moveRange = latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange;
29797
30003
  if (!moveRange || !(latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.draggable)) return;
29798
30004
  event.preventDefault();
@@ -29820,6 +30026,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29820
30026
  window.removeEventListener("pointerup", handlePointerUp);
29821
30027
  window.removeEventListener("pointercancel", handlePointerCancel);
29822
30028
  window.removeEventListener("blur", handleWindowBlur);
30029
+ dragCleanupRef.current = null;
29823
30030
  const range = dragRangeRef.current;
29824
30031
  const targetOffset = dragTargetOffsetRef.current;
29825
30032
  dragRangeRef.current = null;
@@ -29835,7 +30042,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29835
30042
  unitId: popup.unitId,
29836
30043
  sourceRange: range,
29837
30044
  targetOffset
29838
- });
30045
+ }).catch((error) => logService.error(error));
29839
30046
  };
29840
30047
  const handlePointerUp = (upEvent) => {
29841
30048
  if (upEvent.pointerId !== pointerId) return;
@@ -29849,6 +30056,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29849
30056
  const handleWindowBlur = () => {
29850
30057
  finishDrag(false);
29851
30058
  };
30059
+ dragCleanupRef.current = () => finishDrag(false);
29852
30060
  window.addEventListener("pointermove", handlePointerMove);
29853
30061
  window.addEventListener("pointerup", handlePointerUp);
29854
30062
  window.addEventListener("pointercancel", handlePointerCancel);
@@ -29864,7 +30072,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29864
30072
  onMouseEnter: (e) => {
29865
30073
  var _popup$onPointerEnter2;
29866
30074
  (_popup$onPointerEnter2 = popup.onPointerEnter) === null || _popup$onPointerEnter2 === void 0 || _popup$onPointerEnter2.call(popup, e);
29867
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30075
+ setMenuInteractionActive(true);
29868
30076
  isMouseOver.current = true;
29869
30077
  clearHideTimer();
29870
30078
  },
@@ -29887,7 +30095,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29887
30095
  onMouseEnter: (e) => {
29888
30096
  var _popup$onPointerEnter3;
29889
30097
  (_popup$onPointerEnter3 = popup.onPointerEnter) === null || _popup$onPointerEnter3 === void 0 || _popup$onPointerEnter3.call(popup, e);
29890
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30098
+ setMenuInteractionActive(true);
29891
30099
  isMouseOver.current = true;
29892
30100
  clearHideTimer();
29893
30101
  },
@@ -29905,7 +30113,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29905
30113
  autoFocusTarget: openMode === "slash" ? "container" : void 0,
29906
30114
  suppressHoverUntilPointerMove: openMode === "slash",
29907
30115
  onMenuPointerEnter: () => {
29908
- setParagraphMenuInteractionActive(docParagraphMenuService, true);
30116
+ setMenuInteractionActive(true);
29909
30117
  isMouseOver.current = true;
29910
30118
  clearHideTimer();
29911
30119
  },
@@ -29919,7 +30127,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29919
30127
  onOptionSelect: async (params) => {
29920
30128
  const targetRange = targetRangeRef.current ?? getParagraphMenuTargetRange(activeParagraphBound);
29921
30129
  const { commandId, params: commandParams } = getParagraphMenuCommand(params, targetRange);
29922
- const latestTarget = (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) ?? activeTarget;
30130
+ const latestTarget = getActiveTarget();
29923
30131
  if ((latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.kind) === "table" && commandId && targetRange) {
29924
30132
  univerInstanceService.focusUnit(popup.unitId);
29925
30133
  const tableRange = {
@@ -30062,6 +30270,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
30062
30270
  H5Icon: _univerjs_icons.H5Icon,
30063
30271
  HeaderFooterIcon: _univerjs_icons.HeaderFooterIcon,
30064
30272
  HorizontallyIcon: _univerjs_icons.HorizontallyIcon,
30273
+ InsertBelowDoubleIcon: _univerjs_icons.InsertBelowDoubleIcon,
30065
30274
  InsertDoubleIcon: _univerjs_icons.InsertDoubleIcon,
30066
30275
  InsertRowAboveDoubleIcon: _univerjs_icons.InsertRowAboveDoubleIcon,
30067
30276
  InsertRowBelowDoubleIcon: _univerjs_icons.InsertRowBelowDoubleIcon,
@@ -30095,6 +30304,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
30095
30304
  TodoListDoubleIcon: _univerjs_icons.TodoListDoubleIcon,
30096
30305
  UnderlineIcon: _univerjs_icons.UnderlineIcon,
30097
30306
  UnorderIcon: _univerjs_icons.UnorderIcon,
30307
+ ZoomInIcon: _univerjs_icons.ZoomInIcon,
30098
30308
  DefaultTextColorIcon,
30099
30309
  HeaderTextColorIcon,
30100
30310
  MoreRightIcon: _univerjs_icons.MoreRightIcon,
@@ -31250,6 +31460,35 @@ const mobileButtonClassName = `
31250
31460
  `;
31251
31461
  const activeButtonClassName = "univer-bg-primary-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-400";
31252
31462
  function MobileRichTextToolbar({ editorId, className }) {
31463
+ function resolveToolbarState(editor, defaultTextColor) {
31464
+ var _style$ul, _style$st, _style$cl;
31465
+ const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
31466
+ const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
31467
+ const range = ranges.find((item) => item.isActive) ?? ranges[0];
31468
+ if (!body || !range) return {
31469
+ bold: false,
31470
+ italic: false,
31471
+ underline: false,
31472
+ strike: false,
31473
+ color: defaultTextColor,
31474
+ bulletList: false,
31475
+ orderList: false
31476
+ };
31477
+ const style = getStyleInTextRange(body, range, {});
31478
+ const listTypes = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
31479
+ var _paragraph$bullet;
31480
+ return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
31481
+ }).filter((listType) => typeof listType === "string");
31482
+ return {
31483
+ bold: style.bl === _univerjs_core.BooleanNumber.TRUE,
31484
+ italic: style.it === _univerjs_core.BooleanNumber.TRUE,
31485
+ underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === _univerjs_core.BooleanNumber.TRUE,
31486
+ strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === _univerjs_core.BooleanNumber.TRUE,
31487
+ color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
31488
+ bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.BULLET_LIST))),
31489
+ orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.ORDER_LIST)))
31490
+ };
31491
+ }
31253
31492
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
31254
31493
  const editorService = (0, _univerjs_ui.useDependency)(IEditorService);
31255
31494
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
@@ -31263,12 +31502,11 @@ function MobileRichTextToolbar({ editorId, className }) {
31263
31502
  return () => cancelAnimationFrame(frame);
31264
31503
  }, [editorId, editorService]);
31265
31504
  (0, react.useEffect)(() => {
31266
- if (!editor) return void 0;
31505
+ if (!editor) return;
31267
31506
  const subscription = (0, rxjs.merge)(editor.input$, editor.selectionChange$).subscribe(() => setRevision((value) => value + 1));
31268
31507
  return () => subscription.unsubscribe();
31269
31508
  }, [editor]);
31270
- const defaultTextColor = themeService.getColorFromTheme("gray.900");
31271
- const state = resolveToolbarState(editor, defaultTextColor);
31509
+ const state = resolveToolbarState(editor, themeService.getColorFromTheme("gray.900"));
31272
31510
  const colors = COLOR_TOKENS.map((token) => themeService.getColorFromTheme(token));
31273
31511
  async function execute(commandId, params) {
31274
31512
  const activeEditor = editorService.getEditor(editorId);
@@ -31367,18 +31605,23 @@ function MobileRichTextToolbar({ editorId, className }) {
31367
31605
  style: { backgroundColor: color },
31368
31606
  onClick: () => execute(SetInlineFormatTextColorCommand.id, { value: color })
31369
31607
  }, color)),
31370
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
31371
- "aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
31372
- className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-relative univer-flex univer-size-7 univer-items-center univer-justify-center univer-justify-self-center univer-overflow-hidden univer-rounded-md univer-border-2 univer-border-solid univer-border-transparent active:univer-scale-95"),
31373
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ColorWheelMultiIcon, { className: "univer-size-6" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
31608
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileDropdown, {
31609
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
31610
+ className: "univer-px-4 univer-pb-2",
31611
+ onPointerDown: (event) => event.stopPropagation(),
31612
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileColorPicker, {
31613
+ value: state.color,
31614
+ onChange: (color) => execute(SetInlineFormatTextColorCommand.id, { value: color })
31615
+ })
31616
+ }),
31617
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
31618
+ type: "button",
31619
+ variant: "text",
31620
+ size: "icon",
31374
31621
  "aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
31375
- className: "univer-absolute univer-inset-0 univer-size-full univer-cursor-pointer univer-opacity-0",
31376
- type: "color",
31377
- defaultValue: defaultTextColor,
31378
- onChange: (event) => {
31379
- execute(SetInlineFormatTextColorCommand.id, { value: event.target.value });
31380
- }
31381
- })]
31622
+ className: "univer-size-7 univer-justify-self-center",
31623
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ColorWheelMultiIcon, { className: "!univer-size-6" })
31624
+ })
31382
31625
  })
31383
31626
  ]
31384
31627
  })
@@ -31397,35 +31640,6 @@ function FormatButton(props) {
31397
31640
  })
31398
31641
  });
31399
31642
  }
31400
- function resolveToolbarState(editor, defaultTextColor) {
31401
- var _style$ul, _style$st, _style$cl;
31402
- const body = editor === null || editor === void 0 ? void 0 : editor.getDocumentData().body;
31403
- const ranges = (editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges()) ?? [];
31404
- const range = ranges.find((item) => item.isActive) ?? ranges[0];
31405
- if (!body || !range) return {
31406
- bold: false,
31407
- italic: false,
31408
- underline: false,
31409
- strike: false,
31410
- color: defaultTextColor,
31411
- bulletList: false,
31412
- orderList: false
31413
- };
31414
- const style = getStyleInTextRange(body, range, {});
31415
- const listTypes = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges([range], body.paragraphs ?? [], body.dataStream).map((paragraph) => {
31416
- var _paragraph$bullet;
31417
- return (_paragraph$bullet = paragraph.bullet) === null || _paragraph$bullet === void 0 ? void 0 : _paragraph$bullet.listType;
31418
- }).filter((listType) => typeof listType === "string");
31419
- return {
31420
- bold: style.bl === _univerjs_core.BooleanNumber.TRUE,
31421
- italic: style.it === _univerjs_core.BooleanNumber.TRUE,
31422
- underline: ((_style$ul = style.ul) === null || _style$ul === void 0 ? void 0 : _style$ul.s) === _univerjs_core.BooleanNumber.TRUE,
31423
- strike: ((_style$st = style.st) === null || _style$st === void 0 ? void 0 : _style$st.s) === _univerjs_core.BooleanNumber.TRUE,
31424
- color: ((_style$cl = style.cl) === null || _style$cl === void 0 ? void 0 : _style$cl.rgb) ?? defaultTextColor,
31425
- bulletList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.BULLET_LIST))),
31426
- orderList: Boolean(listTypes.length && listTypes.every((listType) => listType.startsWith(_univerjs_core.PresetListType.ORDER_LIST)))
31427
- };
31428
- }
31429
31643
 
31430
31644
  //#endregion
31431
31645
  //#region src/views/rich-text-editor/hooks/editor-undo-redo-keyboard.ts
@@ -32194,26 +32408,26 @@ exports.DeleteCurrentParagraphCommand = DeleteCurrentParagraphCommand;
32194
32408
  exports.DeleteCustomBlockCommand = DeleteCustomBlockCommand;
32195
32409
  exports.DeleteLeftCommand = DeleteLeftCommand;
32196
32410
  exports.DeleteRightCommand = DeleteRightCommand;
32197
- Object.defineProperty(exports, 'DocAutoFormatService', {
32411
+ Object.defineProperty(exports, "DocAutoFormatService", {
32198
32412
  enumerable: true,
32199
32413
  get: function () {
32200
32414
  return DocAutoFormatService;
32201
32415
  }
32202
32416
  });
32203
- Object.defineProperty(exports, 'DocBackScrollRenderController', {
32417
+ Object.defineProperty(exports, "DocBackScrollRenderController", {
32204
32418
  enumerable: true,
32205
32419
  get: function () {
32206
32420
  return DocBackScrollRenderController;
32207
32421
  }
32208
32422
  });
32209
- Object.defineProperty(exports, 'DocCanvasPopManagerService', {
32423
+ Object.defineProperty(exports, "DocCanvasPopManagerService", {
32210
32424
  enumerable: true,
32211
32425
  get: function () {
32212
32426
  return DocCanvasPopManagerService;
32213
32427
  }
32214
32428
  });
32215
32429
  exports.DocClipboardPasteAdapterService = DocClipboardPasteAdapterService;
32216
- Object.defineProperty(exports, 'DocContextualRibbonService', {
32430
+ Object.defineProperty(exports, "DocContextualRibbonService", {
32217
32431
  enumerable: true,
32218
32432
  get: function () {
32219
32433
  return DocContextualRibbonService;
@@ -32222,13 +32436,13 @@ Object.defineProperty(exports, 'DocContextualRibbonService', {
32222
32436
  exports.DocCopyCommand = DocCopyCommand;
32223
32437
  exports.DocCreateTableOperation = DocCreateTableOperation;
32224
32438
  exports.DocCutCommand = DocCutCommand;
32225
- Object.defineProperty(exports, 'DocEventManagerService', {
32439
+ Object.defineProperty(exports, "DocEventManagerService", {
32226
32440
  enumerable: true,
32227
32441
  get: function () {
32228
32442
  return DocEventManagerService;
32229
32443
  }
32230
32444
  });
32231
- Object.defineProperty(exports, 'DocFloatMenuService', {
32445
+ Object.defineProperty(exports, "DocFloatMenuService", {
32232
32446
  enumerable: true,
32233
32447
  get: function () {
32234
32448
  return DocFloatMenuService;
@@ -32237,25 +32451,25 @@ Object.defineProperty(exports, 'DocFloatMenuService', {
32237
32451
  exports.DocHtmlExportService = DocHtmlExportService;
32238
32452
  exports.DocIMEInputManagerService = DocIMEInputManagerService;
32239
32453
  exports.DocLayoutInteractionService = DocLayoutInteractionService;
32240
- Object.defineProperty(exports, 'DocMobileElementMenuService', {
32454
+ Object.defineProperty(exports, "DocMobileElementMenuService", {
32241
32455
  enumerable: true,
32242
32456
  get: function () {
32243
32457
  return DocMobileElementMenuService;
32244
32458
  }
32245
32459
  });
32246
- Object.defineProperty(exports, 'DocPageLayoutService', {
32460
+ Object.defineProperty(exports, "DocPageLayoutService", {
32247
32461
  enumerable: true,
32248
32462
  get: function () {
32249
32463
  return DocPageLayoutService;
32250
32464
  }
32251
32465
  });
32252
- Object.defineProperty(exports, 'DocParagraphMenuService', {
32466
+ Object.defineProperty(exports, "DocParagraphMenuService", {
32253
32467
  enumerable: true,
32254
32468
  get: function () {
32255
32469
  return DocParagraphMenuService;
32256
32470
  }
32257
32471
  });
32258
- Object.defineProperty(exports, 'DocParagraphPlaceholderRenderController', {
32472
+ Object.defineProperty(exports, "DocParagraphPlaceholderRenderController", {
32259
32473
  enumerable: true,
32260
32474
  get: function () {
32261
32475
  return DocParagraphPlaceholderRenderController;
@@ -32263,14 +32477,14 @@ Object.defineProperty(exports, 'DocParagraphPlaceholderRenderController', {
32263
32477
  });
32264
32478
  exports.DocPasteCommand = DocPasteCommand;
32265
32479
  exports.DocPrintInterceptorService = DocPrintInterceptorService;
32266
- Object.defineProperty(exports, 'DocRenderController', {
32480
+ Object.defineProperty(exports, "DocRenderController", {
32267
32481
  enumerable: true,
32268
32482
  get: function () {
32269
32483
  return DocRenderController;
32270
32484
  }
32271
32485
  });
32272
32486
  exports.DocSelectAllCommand = DocSelectAllCommand;
32273
- Object.defineProperty(exports, 'DocSelectionRenderService', {
32487
+ Object.defineProperty(exports, "DocSelectionRenderService", {
32274
32488
  enumerable: true,
32275
32489
  get: function () {
32276
32490
  return DocSelectionRenderService;
@@ -32286,19 +32500,19 @@ exports.DocTableInsertRowAboveCommand = DocTableInsertRowAboveCommand;
32286
32500
  exports.DocTableInsertRowBellowCommand = DocTableInsertRowBellowCommand;
32287
32501
  exports.DocTableInsertRowCommand = DocTableInsertRowCommand;
32288
32502
  exports.DocTableTabCommand = DocTableTabCommand;
32289
- Object.defineProperty(exports, 'DocUIController', {
32503
+ Object.defineProperty(exports, "DocUIController", {
32290
32504
  enumerable: true,
32291
32505
  get: function () {
32292
32506
  return DocUIController;
32293
32507
  }
32294
32508
  });
32295
- Object.defineProperty(exports, 'DocViewScaleService', {
32509
+ Object.defineProperty(exports, "DocViewScaleService", {
32296
32510
  enumerable: true,
32297
32511
  get: function () {
32298
32512
  return DocViewScaleService;
32299
32513
  }
32300
32514
  });
32301
- Object.defineProperty(exports, 'DocsRenderService', {
32515
+ Object.defineProperty(exports, "DocsRenderService", {
32302
32516
  enumerable: true,
32303
32517
  get: function () {
32304
32518
  return DocsRenderService;
@@ -32307,7 +32521,7 @@ Object.defineProperty(exports, 'DocsRenderService', {
32307
32521
  exports.DocsUIMenuSchema = menuSchema;
32308
32522
  exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
32309
32523
  exports.Editor = Editor;
32310
- Object.defineProperty(exports, 'EditorService', {
32524
+ Object.defineProperty(exports, "EditorService", {
32311
32525
  enumerable: true,
32312
32526
  get: function () {
32313
32527
  return EditorService;
@@ -32345,6 +32559,7 @@ exports.NodePositionConvertToRectRange = NodePositionConvertToRectRange;
32345
32559
  exports.OrderListCommand = OrderListCommand;
32346
32560
  exports.OrderListTypePicker = OrderListTypePicker;
32347
32561
  exports.ParagraphMenuInsertBelowSubmenuItemFactory = ParagraphMenuInsertBelowSubmenuItemFactory;
32562
+ exports.ParagraphSettingMenuFactory = ParagraphSettingMenuFactory;
32348
32563
  exports.PastePluginLark = LarkPastePlugin;
32349
32564
  exports.PastePluginUniver = UniverPastePlugin;
32350
32565
  exports.PastePluginWord = WordPastePlugin;
@@ -32380,13 +32595,13 @@ exports.TextColorSelectorMenuItemFactory = TextColorSelectorMenuItemFactory;
32380
32595
  exports.TextRange = TextRange;
32381
32596
  exports.ToggleCheckListCommand = ToggleCheckListCommand;
32382
32597
  exports.UnderlineMenuItemFactory = UnderlineMenuItemFactory;
32383
- Object.defineProperty(exports, 'UniverDocsMobileUIPlugin', {
32598
+ Object.defineProperty(exports, "UniverDocsMobileUIPlugin", {
32384
32599
  enumerable: true,
32385
32600
  get: function () {
32386
32601
  return UniverDocsMobileUIPlugin;
32387
32602
  }
32388
32603
  });
32389
- Object.defineProperty(exports, 'UniverDocsUIPlugin', {
32604
+ Object.defineProperty(exports, "UniverDocsUIPlugin", {
32390
32605
  enumerable: true,
32391
32606
  get: function () {
32392
32607
  return UniverDocsUIPlugin;
@@ -32414,7 +32629,12 @@ exports.drawDocCustomRangeChrome = drawDocCustomRangeChrome;
32414
32629
  exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
32415
32630
  exports.findDocRangeNodePositions = findDocRangeNodePositions;
32416
32631
  exports.genTableSource = genTableSource;
32417
- exports.generateParagraphs = _univerjs_docs.generateParagraphs;
32632
+ Object.defineProperty(exports, "generateParagraphs", {
32633
+ enumerable: true,
32634
+ get: function () {
32635
+ return _univerjs_docs.generateParagraphs;
32636
+ }
32637
+ });
32418
32638
  exports.getAnchorBounding = getAnchorBounding;
32419
32639
  exports.getCanvasOffsetByEngine = getCanvasOffsetByEngine;
32420
32640
  exports.getCommandSkeleton = getCommandSkeleton;