@univerjs/docs-ui 1.2.0 → 1.3.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
@@ -3272,7 +3272,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
3272
3272
  get canFocusing() {
3273
3273
  const ownerDocument = this._getOwnerDocument();
3274
3274
  const activeElement = ownerDocument.activeElement;
3275
- return !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
3275
+ return !this._isInUnfocusedFrame() && !this._shouldPreserveExternalFocus() && !this._isAnotherEditorFocused() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
3276
3276
  }
3277
3277
  cancelPointerSelection() {
3278
3278
  if (!this._onPointerEvent) return;
@@ -4003,7 +4003,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
4003
4003
  const activeRangeInstance = this._getActiveRangeInstance();
4004
4004
  const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
4005
4005
  if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
4006
- if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && this._isAnotherEditorFocused()) return;
4006
+ if (preserveFocus || this._shouldPreserveExternalFocus() || !forceFocus && (this._isInUnfocusedFrame() || this._isAnotherEditorFocused())) return;
4007
4007
  this.focus();
4008
4008
  return;
4009
4009
  }
@@ -4281,6 +4281,11 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
4281
4281
  if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
4282
4282
  return ((_this$_embedInteracti2 = this._embedInteractionBoundaryService) === null || _this$_embedInteracti2 === void 0 || (_this$_embedInteracti3 = _this$_embedInteracti2.hasRecentInteractionFor) === null || _this$_embedInteracti3 === void 0 ? void 0 : _this$_embedInteracti3.call(_this$_embedInteracti2, currentEmbedOwner, ownerDocument)) === true;
4283
4283
  }
4284
+ _isInUnfocusedFrame() {
4285
+ const ownerDocument = this._getOwnerDocument();
4286
+ const ownerWindow = ownerDocument.defaultView;
4287
+ return ownerWindow != null && ownerWindow.parent !== ownerWindow && !ownerDocument.hasFocus();
4288
+ }
4284
4289
  _isAnotherEditorFocused() {
4285
4290
  const activeElement = this._getOwnerDocument().activeElement;
4286
4291
  return activeElement instanceof HTMLElement && activeElement !== this._input && activeElement.dataset.uComp === this._input.dataset.uComp;
@@ -9033,12 +9038,11 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
9033
9038
  }
9034
9039
  }
9035
9040
  async _setClipboardData(documentList, needCache = true, plainTextList) {
9036
- var _documentList$0$body;
9037
9041
  const copyId = (0, _univerjs_core.generateRandomId)(6);
9038
- const text = (plainTextList ? plainTextList.join("\n") : documentList.length > 1 ? documentList.map((doc) => {
9042
+ const text = (plainTextList ?? documentList.map((doc) => {
9039
9043
  var _doc$body3;
9040
9044
  return ((_doc$body3 = doc.body) === null || _doc$body3 === void 0 ? void 0 : _doc$body3.dataStream) || "";
9041
- }).join("\n") : ((_documentList$0$body = documentList[0].body) === null || _documentList$0$body === void 0 ? void 0 : _documentList$0$body.dataStream) || "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
9045
+ })).join("\n").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_ROW_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.TABLE_CELL_END, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_START, "").replaceAll(_univerjs_core.DataStreamTreeTokenType.BLOCK_END, "").replaceAll("\r\n", " ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "");
9042
9046
  let html = this._umdToHtml.convert(documentList);
9043
9047
  let internalJson = "";
9044
9048
  let internalDocData = null;
@@ -9096,7 +9100,6 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
9096
9100
  const snapshot = docDataModel.getSnapshot();
9097
9101
  if (body == null) return;
9098
9102
  for (const range of allRanges) {
9099
- var _docDataModel$getSelf2, _docBody$tables;
9100
9103
  const { startOffset, endOffset, collapsed, rangeType } = range;
9101
9104
  if (collapsed || startOffset == null || endOffset == null) continue;
9102
9105
  if (rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
@@ -9106,20 +9109,9 @@ let DocClipboardService = class DocClipboardService extends _univerjs_core.Dispo
9106
9109
  plainTextResults.push(bodySlice.dataStream);
9107
9110
  continue;
9108
9111
  }
9109
- const deleteRange = {
9110
- startOffset,
9111
- endOffset,
9112
- collapsed
9113
- };
9114
- const docBody = (_docDataModel$getSelf2 = docDataModel.getSelfOrHeaderFooterModel(segmentId)) === null || _docDataModel$getSelf2 === void 0 ? void 0 : _docDataModel$getSelf2.sliceBody(deleteRange.startOffset, deleteRange.endOffset, sliceType);
9115
- if (docBody == null) continue;
9116
- if ((_docBody$tables = docBody.tables) === null || _docBody$tables === void 0 ? void 0 : _docBody$tables.length) {
9117
- var _body$tables2;
9118
- const completeTableIds = new Set((_body$tables2 = body.tables) === null || _body$tables2 === void 0 ? void 0 : _body$tables2.filter((table) => table.startIndex >= startOffset && table.endIndex <= endOffset).map((table) => table.tableId));
9119
- docBody.tables = docBody.tables.filter((table) => completeTableIds.has(table.tableId));
9120
- }
9112
+ const docBody = (0, _univerjs_core.getBodySliceForTextXAction)(body, startOffset, endOffset, false, sliceType);
9121
9113
  results.push(docBody);
9122
- plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(deleteRange.startOffset, deleteRange.endOffset, {
9114
+ plainTextResults.push((copyContentHook === null || copyContentHook === void 0 ? void 0 : copyContentHook(startOffset, endOffset, {
9123
9115
  body,
9124
9116
  segmentId,
9125
9117
  unitId: docDataModel.getUnitId()
@@ -13009,7 +13001,7 @@ let DocPageLayoutService = class DocPageLayoutService extends _univerjs_core.Dis
13009
13001
  sceneWidth = docsWidth + horizontalMargin * 2;
13010
13002
  scrollToX = 0;
13011
13003
  }
13012
- if (engineHeight > docsHeight) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
13004
+ if (engineHeight > (docsHeight + pageMarginTop * 2) * viewScale) sceneHeight = (engineHeight - pageMarginTop * 2) / viewScale;
13013
13005
  else sceneHeight = docsHeight + pageMarginTop * 2;
13014
13006
  sceneHeight = this.resolveSceneHeight(sceneHeight);
13015
13007
  scene.transformByState({
@@ -16732,6 +16724,28 @@ const DocOpenPageSettingCommand = {
16732
16724
  }
16733
16725
  };
16734
16726
 
16727
+ //#endregion
16728
+ //#region src/views/EditorColorPicker.tsx
16729
+ function EditorColorPicker(props) {
16730
+ const containerRef = (0, react.useRef)(null);
16731
+ const ColorPickerComponent = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager).get(_univerjs_ui.COLOR_PICKER_COMPONENT);
16732
+ (0, react.useEffect)(() => {
16733
+ const container = containerRef.current;
16734
+ const view = container === null || container === void 0 ? void 0 : container.ownerDocument.defaultView;
16735
+ if (!container || !view) return;
16736
+ const preserveComposition = (event) => {
16737
+ if (event.isComposing && (event.key === "Enter" || event.key === "Escape") && event.target instanceof view.HTMLInputElement && container.contains(event.target)) event.stopPropagation();
16738
+ };
16739
+ view.addEventListener("keydown", preserveComposition, true);
16740
+ return () => view.removeEventListener("keydown", preserveComposition, true);
16741
+ }, []);
16742
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
16743
+ ref: containerRef,
16744
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPickerComponent, { ...props })
16745
+ });
16746
+ }
16747
+ EditorColorPicker.componentKey = "docs.editor-color-picker";
16748
+
16735
16749
  //#endregion
16736
16750
  //#region src/views/const.ts
16737
16751
  /**
@@ -17535,7 +17549,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
17535
17549
  type: _univerjs_ui.MenuItemType.BUTTON_SELECTOR,
17536
17550
  selections: [{
17537
17551
  label: {
17538
- name: _univerjs_ui.COLOR_PICKER_COMPONENT,
17552
+ name: EditorColorPicker.componentKey,
17539
17553
  hoverable: false,
17540
17554
  selectable: false
17541
17555
  },
@@ -17964,7 +17978,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
17964
17978
  icon: "PaintBucketDoubleIcon",
17965
17979
  selections: [{
17966
17980
  label: {
17967
- name: _univerjs_ui.COLOR_PICKER_COMPONENT,
17981
+ name: EditorColorPicker.componentKey,
17968
17982
  hoverable: false,
17969
17983
  selectable: false
17970
17984
  },
@@ -21552,7 +21566,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
21552
21566
  //#endregion
21553
21567
  //#region package.json
21554
21568
  var name = "@univerjs/docs-ui";
21555
- var version = "1.2.0";
21569
+ var version = "1.3.1";
21556
21570
 
21557
21571
  //#endregion
21558
21572
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -24811,6 +24825,7 @@ let MobileComponentsController = class MobileComponentsController extends _unive
24811
24825
  }));
24812
24826
  }
24813
24827
  _registerComponents() {
24828
+ this.disposeWithMe(this._componentManager.register(EditorColorPicker.componentKey, EditorColorPicker));
24814
24829
  this.disposeWithMe(this._componentManager.register(COMPONENT_DOC_HEADER_FOOTER_PANEL, MobileHeaderFooterPanel));
24815
24830
  this.disposeWithMe(this._componentManager.register("doc_ui_paragraph-setting-panel", MobileParagraphSettings));
24816
24831
  this.disposeWithMe(this._componentManager.register(DOC_SECTION_SETTING_COMPONENT, MobileSectionSettings));
@@ -25343,8 +25358,10 @@ let DocMobileUIController = class DocMobileUIController extends _univerjs_core.D
25343
25358
  this.disposeWithMe(this._uiPartsService.registerComponent(_univerjs_ui.BuiltInUIPart.HEADER_MENU, () => (0, _univerjs_ui.connectInjector)(MobileDocEditDoneButton, this._injector)));
25344
25359
  }
25345
25360
  _initMenus() {
25361
+ const { [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: mainAreaMenu, ...rootMenus } = mobileMenuSchema;
25346
25362
  this._menuManagerService.mergeMenu(menuSchema);
25347
- this._menuManagerService.appendRootMenu(mobileMenuSchema);
25363
+ this._menuManagerService.mergeMenu({ [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: mainAreaMenu });
25364
+ this._menuManagerService.appendRootMenu(rootMenus);
25348
25365
  }
25349
25366
  _initFocusHandler() {
25350
25367
  this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, () => {}));
@@ -26152,6 +26169,9 @@ let DocResizeRenderController = class DocResizeRenderController extends _univerj
26152
26169
  this._initResize();
26153
26170
  }
26154
26171
  _initResize() {
26172
+ this.disposeWithMe(this._context.activated$.pipe((0, rxjs.observeOn)(rxjs.animationFrameScheduler)).subscribe((activated) => {
26173
+ if (activated) this._refreshLayoutAndSelection();
26174
+ }));
26155
26175
  this.disposeWithMe((0, _univerjs_core.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0, rxjs.throttleTime)(0, rxjs.animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
26156
26176
  this.disposeWithMe(this._sidebarService.sidebarOptions$.pipe((0, rxjs.observeOn)(rxjs.animationFrameScheduler)).subscribe(() => this._refreshLayoutAndSelection()));
26157
26177
  }
@@ -27409,7 +27429,7 @@ let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Dispo
27409
27429
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
27410
27430
  const { unitId, textRanges } = selection;
27411
27431
  if (unitId !== this._context.unitId) return;
27412
- if (this._suppressed || this._embedSuppressed || this._contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS)) {
27432
+ if (selection.isEditing || this._suppressed || this._embedSuppressed || this._contextService.getContextValue(_univerjs_core.FOCUSING_COMMON_DRAWINGS)) {
27413
27433
  this._hideFloatMenu();
27414
27434
  return;
27415
27435
  }
@@ -27696,6 +27716,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27696
27716
  this.disposeWithMe(this.textSelectionInner$.subscribe(() => this._syncMobileSelectionVisuals()));
27697
27717
  this._initMobileKeyboardViewport();
27698
27718
  }
27719
+ focus() {
27720
+ if ((this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) && this.isFocusing) return;
27721
+ super.focus();
27722
+ }
27699
27723
  cancelPointerSelection() {
27700
27724
  this._handleDragDisposables.dispose();
27701
27725
  super.cancelPointerSelection();
@@ -27736,10 +27760,11 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27736
27760
  }
27737
27761
  _syncMobileSelectionVisuals() {
27738
27762
  const activeRange = this._getActiveRangeInstance();
27763
+ const isInternalEditor = (0, _univerjs_core.isInternalEditorID)(this._context.unitId);
27739
27764
  this._selectionVisuals.hide();
27740
27765
  for (const range of this._rangeList) {
27741
27766
  const caret = range.getAnchor();
27742
- if (this.isEditing && range === activeRange) caret === null || caret === void 0 || caret.show();
27767
+ if ((this.isEditing || isInternalEditor) && range === activeRange) caret === null || caret === void 0 || caret.show();
27743
27768
  else caret === null || caret === void 0 || caret.hide();
27744
27769
  }
27745
27770
  if (!activeRange || activeRange.collapsed || this.isEditing) return;
@@ -27773,6 +27798,10 @@ let MobileDocSelectionRenderService = class MobileDocSelectionRenderService exte
27773
27798
  });
27774
27799
  }
27775
27800
  _handleInputBlur(event) {
27801
+ if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId)) {
27802
+ super._handleInputBlur(event);
27803
+ return;
27804
+ }
27776
27805
  if (this.isEditing) {
27777
27806
  this._pendingBlurEvent = event;
27778
27807
  return;
@@ -28520,6 +28549,20 @@ const LIST_ICON_MAP = {
28520
28549
  [_univerjs_core.PresetListType.CHECK_LIST]: "TodoListDoubleIcon",
28521
28550
  [_univerjs_core.PresetListType.CHECK_LIST_CHECKED]: "TodoListDoubleIcon"
28522
28551
  };
28552
+ const PASSIVE_PARAGRAPH_MENU_KEYS = /* @__PURE__ */ new Set([
28553
+ "ArrowLeft",
28554
+ "ArrowRight",
28555
+ "ArrowUp",
28556
+ "ArrowDown",
28557
+ "Home",
28558
+ "End",
28559
+ "PageUp",
28560
+ "PageDown",
28561
+ "Shift",
28562
+ "Control",
28563
+ "Alt",
28564
+ "Meta"
28565
+ ]);
28523
28566
  let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_core.Disposable {
28524
28567
  get activeParagraph() {
28525
28568
  var _this$_paragraphMenu;
@@ -28535,8 +28578,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28535
28578
  }
28536
28579
  setBlockMenuDragging(isDragging) {
28537
28580
  this._isBlockMenuDragging = isDragging;
28538
- if (isDragging) this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
28539
- else {
28581
+ if (isDragging) {
28582
+ this._cancelParagraphMenuHide();
28583
+ this._dragInteraction ??= this._docLayoutInteractionService.beginInteraction();
28584
+ } else {
28540
28585
  var _this$_dragInteractio;
28541
28586
  (_this$_dragInteractio = this._dragInteraction) === null || _this$_dragInteractio === void 0 || _this$_dragInteractio.dispose();
28542
28587
  this._dragInteraction = null;
@@ -28558,6 +28603,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28558
28603
  this._docLayoutInteractionService = _docLayoutInteractionService;
28559
28604
  this._contextService = _contextService;
28560
28605
  _defineProperty(this, "_paragraphMenu", null);
28606
+ _defineProperty(this, "_paragraphMenuHideTimer", null);
28561
28607
  _defineProperty(this, "_activeTarget$", new rxjs.BehaviorSubject(null));
28562
28608
  _defineProperty(this, "activeTarget$", this._activeTarget$.asObservable());
28563
28609
  _defineProperty(this, "_focusedTableMenu", null);
@@ -28583,13 +28629,6 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28583
28629
  if (this._focusedTableMenu && !this._canEditDocument(this._focusedTableMenu.target.menuRange)) this.hideFocusedTableMenu();
28584
28630
  }));
28585
28631
  }
28586
- _isCursorInActiveParagraph() {
28587
- if (!this._paragraphMenu) return false;
28588
- const activeTextRange = this._docSelectionManagerService.getActiveTextRange();
28589
- if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed)) return false;
28590
- if (!(activeTextRange === null || activeTextRange === void 0 ? void 0 : activeTextRange.collapsed) || activeTextRange.startOffset < this._paragraphMenu.paragraph.paragraphStart || activeTextRange.startOffset > this._paragraphMenu.paragraph.paragraphEnd) return false;
28591
- return true;
28592
- }
28593
28632
  _getExpandedSelectionState(ranges) {
28594
28633
  return ranges.reduce((state, range) => {
28595
28634
  if (range.rangeType === _univerjs_core.DOC_RANGE_TYPE.RECT) {
@@ -28619,6 +28658,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28619
28658
  }
28620
28659
  setParagraphMenuActive(active, focusedTable = false) {
28621
28660
  var _this$_paragraphMenu3, _this$_focusedTableMe2;
28661
+ if (active && !focusedTable) this._cancelParagraphMenuHide();
28622
28662
  const menu = focusedTable ? this._focusedTableMenu : this._paragraphMenu;
28623
28663
  if (menu) menu.active = active;
28624
28664
  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();
@@ -28633,10 +28673,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28633
28673
  var _this$_focusedTableMe3;
28634
28674
  if (this._isBlockMenuDragging) return;
28635
28675
  if ((_this$_focusedTableMe3 = this._focusedTableMenu) === null || _this$_focusedTableMe3 === void 0 ? void 0 : _this$_focusedTableMe3.active) return;
28636
- if (this._docSelectionRenderService.isOnPointerEvent) {
28637
- this.hideParagraphMenu(true);
28638
- return;
28639
- }
28676
+ if (this._docSelectionRenderService.isOnPointerEvent) return;
28640
28677
  const selectionState = this._getExpandedSelectionState(this._docSelectionManagerService.getDocRanges());
28641
28678
  if (selectionState.hasExpandedTextRange) {
28642
28679
  this.hideParagraphMenu(true);
@@ -28663,6 +28700,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28663
28700
  this.showTableMenu(tableBound);
28664
28701
  return;
28665
28702
  }
28703
+ this._scheduleParagraphMenuHide();
28704
+ return;
28666
28705
  }
28667
28706
  this.hideParagraphMenu(true);
28668
28707
  };
@@ -28677,6 +28716,9 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28677
28716
  handleHoverTarget(p ?? left, table);
28678
28717
  }));
28679
28718
  this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
28719
+ this._cancelParagraphMenuHide();
28720
+ }));
28721
+ this.disposeWithMe(this._docSelectionRenderService.movingSelection$.subscribe(() => {
28680
28722
  this.hideParagraphMenu(true);
28681
28723
  }));
28682
28724
  this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({ textRanges, rectRanges }) => {
@@ -28686,13 +28728,13 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28686
28728
  }));
28687
28729
  let lastScrollY = 0;
28688
28730
  this.disposeWithMe(this._context.scene.getViewport("viewMain").onScrollAfter$.subscribeEvent((e) => {
28689
- var _this$_paragraphMenu7;
28731
+ var _this$_paragraphMenu7, _this$_paragraphMenu8;
28690
28732
  if (lastScrollY === e.scrollY) return;
28691
28733
  lastScrollY = e.scrollY;
28692
28734
  this._focusedTableMenuDismiss$.next();
28693
28735
  if ((_this$_paragraphMenu7 = this._paragraphMenu) === null || _this$_paragraphMenu7 === void 0 ? void 0 : _this$_paragraphMenu7.blockRange) return;
28694
28736
  if (this._isBlockMenuDragging) return;
28695
- this.hideParagraphMenu(true);
28737
+ if ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.active) this.hideParagraphMenu(true);
28696
28738
  }));
28697
28739
  this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(() => {
28698
28740
  if (this._isBlockMenuDragging) return;
@@ -28702,6 +28744,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28702
28744
  if (this._isBlockMenuDragging) return;
28703
28745
  if (this._handleSlashMenuKeydown(config)) return;
28704
28746
  this._focusedTableMenuDismiss$.next();
28747
+ if (PASSIVE_PARAGRAPH_MENU_KEYS.has(config.event.key)) return;
28705
28748
  this.hideParagraphMenu(true);
28706
28749
  }));
28707
28750
  this.disposeWithMe(this._docSelectionRenderService.onInputBefore$.subscribe((config) => {
@@ -28757,10 +28800,10 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28757
28800
  return null;
28758
28801
  }
28759
28802
  _getSlashMenuParagraph(config) {
28760
- var _this$_paragraphMenu8;
28803
+ var _this$_paragraphMenu9;
28761
28804
  const activeRange = this._getCollapsedTextRange(config);
28762
28805
  const offset = activeRange === null || activeRange === void 0 ? void 0 : activeRange.startOffset;
28763
- const activeParagraph = ((_this$_paragraphMenu8 = this._paragraphMenu) === null || _this$_paragraphMenu8 === void 0 ? void 0 : _this$_paragraphMenu8.paragraph) ?? null;
28806
+ const activeParagraph = ((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.paragraph) ?? null;
28764
28807
  if (activeParagraph && offset != null && offset >= activeParagraph.paragraphStart && offset <= activeParagraph.paragraphEnd) return activeParagraph;
28765
28808
  if (activeParagraph && offset == null) return activeParagraph;
28766
28809
  if (offset == null) return null;
@@ -28781,7 +28824,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28781
28824
  }
28782
28825
  }
28783
28826
  showParagraphMenu(paragraph) {
28784
- var _this$_paragraphMenu9;
28827
+ var _this$_paragraphMenu10;
28785
28828
  if (this._hasExpandedSelection()) {
28786
28829
  this.hideParagraphMenu(true);
28787
28830
  return;
@@ -28791,8 +28834,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28791
28834
  this.hideParagraphMenu(true);
28792
28835
  return;
28793
28836
  }
28794
- if (((_this$_paragraphMenu9 = this._paragraphMenu) === null || _this$_paragraphMenu9 === void 0 ? void 0 : _this$_paragraphMenu9.target.key) === target.key) return;
28795
- this.hideParagraphMenu(true);
28837
+ this._cancelParagraphMenuHide();
28838
+ if (((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
28796
28839
  const targetParagraph = target.paragraph ?? paragraph;
28797
28840
  const blockRange = target.blockRange;
28798
28841
  const getFirstLine = () => {
@@ -28807,33 +28850,11 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28807
28850
  if (!target.cellRange) return menuAnchor;
28808
28851
  return getTableCellParagraphAnchorRect(this._docEventManagerService, latestParagraphBound, menuAnchor);
28809
28852
  };
28810
- const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
28811
- componentKey: DOC_PARAGRAPH_MENU_COMPONENT_KEY,
28812
- constrainToCanvas: true,
28813
- requiresStableLayout: false,
28814
- direction: "left-center",
28815
- onClickOutside: () => {
28816
- if (this._isSlashMenuActive) {
28817
- this.hideParagraphMenu(true);
28818
- return;
28819
- }
28820
- this._docSelectionManagerService.textSelection$.pipe((0, rxjs.first)()).subscribe(() => {
28821
- if (!this._isCursorInActiveParagraph()) this.hideParagraphMenu(true);
28822
- });
28823
- },
28824
- zIndex: 101
28825
- }, this._context.unitId);
28826
- this._paragraphMenu = {
28827
- paragraph: targetParagraph,
28828
- target,
28829
- blockRange,
28830
- disposable,
28831
- active: false
28832
- };
28833
- this._activeTarget$.next(target);
28853
+ this._showHoverMenu(targetParagraph, target, getFirstLine);
28834
28854
  }
28835
28855
  showTableMenu(tableBound, focused = false) {
28836
- var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu10;
28856
+ var _this$_focusedTableMe4, _body$tables, _this$_paragraphMenu11;
28857
+ if (!focused) this._cancelParagraphMenuHide();
28837
28858
  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;
28838
28859
  if (!focused && this._hasExpandedTextSelection()) {
28839
28860
  this.hideParagraphMenu(true);
@@ -28871,7 +28892,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28871
28892
  return;
28872
28893
  }
28873
28894
  if (!focused && this._shouldKeepCurrentCellMenuForTable(table)) return;
28874
- if (!focused && ((_this$_paragraphMenu10 = this._paragraphMenu) === null || _this$_paragraphMenu10 === void 0 ? void 0 : _this$_paragraphMenu10.target.key) === target.key) return;
28895
+ if (!focused && ((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) return;
28875
28896
  const anchorRect = getTableAnchorRect(tableBound);
28876
28897
  const paragraph = {
28877
28898
  rect: tableBound.rect,
@@ -28887,31 +28908,47 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28887
28908
  this._showFocusedTableMenu(tableBound, target);
28888
28909
  return;
28889
28910
  }
28890
- this._showHoverTableMenu(tableBound, target, paragraph);
28891
- }
28892
- _showHoverTableMenu(tableBound, target, paragraph) {
28893
- this.hideParagraphMenu(true);
28894
28911
  const getFirstLine = () => getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? tableBound);
28895
- const disposable = this._docPopupManagerService.attachPopupToRect(getFirstLine, {
28896
- componentKey: DOC_TABLE_BLOCK_MENU_COMPONENT_KEY,
28912
+ this._showHoverMenu(paragraph, target, getFirstLine);
28913
+ }
28914
+ _showHoverMenu(paragraph, target, getAnchor) {
28915
+ const menu = this._paragraphMenu;
28916
+ if ((menu === null || menu === void 0 ? void 0 : menu.active) && menu.target.kind === _univerjs_core.DocumentBlockType.TABLE !== (target.kind === _univerjs_core.DocumentBlockType.TABLE)) this.hideParagraphMenu(true);
28917
+ if (this._paragraphMenu) {
28918
+ this._paragraphMenu.paragraph = paragraph;
28919
+ this._paragraphMenu.target = target;
28920
+ this._paragraphMenu.blockRange = target.blockRange;
28921
+ this._paragraphMenu.getAnchor = getAnchor;
28922
+ this._activeTarget$.next(target);
28923
+ return;
28924
+ }
28925
+ const disposable = this._docPopupManagerService.attachPopupToRect(() => {
28926
+ var _this$_paragraphMenu12;
28927
+ return ((_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.getAnchor()) ?? getAnchor();
28928
+ }, {
28929
+ direction: target.kind === _univerjs_core.DocumentBlockType.TABLE ? "top-right" : "left-center",
28930
+ offset: target.kind === _univerjs_core.DocumentBlockType.TABLE ? [0, 0] : [8, 0],
28931
+ componentKey: DOC_PARAGRAPH_MENU_COMPONENT_KEY,
28932
+ positionChanges$: this.activeTarget$,
28897
28933
  constrainToCanvas: true,
28898
28934
  requiresStableLayout: false,
28899
- direction: "top-right",
28900
28935
  onClickOutside: () => {
28901
- this.hideParagraphMenu(true);
28936
+ if (this._isSlashMenuActive) this.hideParagraphMenu(true);
28902
28937
  },
28903
28938
  zIndex: 101
28904
28939
  }, this._context.unitId);
28905
28940
  this._paragraphMenu = {
28906
28941
  paragraph,
28907
28942
  target,
28943
+ blockRange: target.blockRange,
28908
28944
  disposable,
28909
- active: false
28945
+ active: false,
28946
+ getAnchor
28910
28947
  };
28911
28948
  this._activeTarget$.next(target);
28912
28949
  }
28913
28950
  _showFocusedTableMenu(tableBound, target) {
28914
- var _this$_focusedTableMe5, _this$_paragraphMenu11;
28951
+ var _this$_focusedTableMe5, _this$_paragraphMenu13;
28915
28952
  if (((_this$_focusedTableMe5 = this._focusedTableMenu) === null || _this$_focusedTableMe5 === void 0 ? void 0 : _this$_focusedTableMe5.target.key) === target.key) {
28916
28953
  this._focusedTableMenu.target = target;
28917
28954
  this._focusedTableMenu.bound = tableBound;
@@ -28919,7 +28956,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28919
28956
  return;
28920
28957
  }
28921
28958
  this.hideFocusedTableMenu();
28922
- if (((_this$_paragraphMenu11 = this._paragraphMenu) === null || _this$_paragraphMenu11 === void 0 ? void 0 : _this$_paragraphMenu11.target.key) === target.key) this.hideParagraphMenu(true);
28959
+ if (((_this$_paragraphMenu13 = this._paragraphMenu) === null || _this$_paragraphMenu13 === void 0 ? void 0 : _this$_paragraphMenu13.target.key) === target.key) this.hideParagraphMenu(true);
28923
28960
  const getFocusedAnchor = () => {
28924
28961
  var _this$_focusedTableMe6;
28925
28962
  return getTableAnchorRect(this._docEventManagerService.tableBounds.get(tableBound.tableId) ?? ((_this$_focusedTableMe6 = this._focusedTableMenu) === null || _this$_focusedTableMe6 === void 0 ? void 0 : _this$_focusedTableMe6.bound) ?? tableBound);
@@ -28942,8 +28979,8 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28942
28979
  this._focusedTableTarget$.next(target);
28943
28980
  }
28944
28981
  _shouldKeepCurrentCellMenuForTable(table) {
28945
- var _this$_paragraphMenu12;
28946
- const target = (_this$_paragraphMenu12 = this._paragraphMenu) === null || _this$_paragraphMenu12 === void 0 ? void 0 : _this$_paragraphMenu12.target;
28982
+ var _this$_paragraphMenu14;
28983
+ const target = (_this$_paragraphMenu14 = this._paragraphMenu) === null || _this$_paragraphMenu14 === void 0 ? void 0 : _this$_paragraphMenu14.target;
28947
28984
  if (!target || target.kind === _univerjs_core.DocumentBlockType.TABLE || !target.cellRange) return false;
28948
28985
  return target.cellRange.startOffset >= table.startIndex && target.cellRange.startOffset <= table.endIndex;
28949
28986
  }
@@ -28983,7 +29020,21 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
28983
29020
  }
28984
29021
  };
28985
29022
  }
29023
+ _cancelParagraphMenuHide() {
29024
+ if (this._paragraphMenuHideTimer != null) {
29025
+ clearTimeout(this._paragraphMenuHideTimer);
29026
+ this._paragraphMenuHideTimer = null;
29027
+ }
29028
+ }
29029
+ _scheduleParagraphMenuHide() {
29030
+ if (!this._paragraphMenu || this._paragraphMenu.active || this._paragraphMenuHideTimer != null) return;
29031
+ this._paragraphMenuHideTimer = setTimeout(() => {
29032
+ this._paragraphMenuHideTimer = null;
29033
+ this.hideParagraphMenu();
29034
+ }, 200);
29035
+ }
28986
29036
  hideParagraphMenu(force = false) {
29037
+ this._cancelParagraphMenuHide();
28987
29038
  if (this._isBlockMenuDragging) return;
28988
29039
  if (this._paragraphMenu && (this._paragraphMenu.disposable.canDispose() || force)) {
28989
29040
  this._paragraphMenu.disposable.dispose();
@@ -29009,6 +29060,7 @@ let DocParagraphMenuService = class DocParagraphMenuService extends _univerjs_co
29009
29060
  this._isBlockMenuDragging = false;
29010
29061
  this.hideFocusedTableMenu();
29011
29062
  this.hideParagraphMenu(true);
29063
+ this._activeTarget$.complete();
29012
29064
  this._focusedTableTarget$.complete();
29013
29065
  this._focusedTableMenuDismiss$.complete();
29014
29066
  (_this$_menuInteractio2 = this._menuInteraction) === null || _this$_menuInteractio2 === void 0 || _this$_menuInteractio2.dispose();
@@ -29287,6 +29339,74 @@ function getBlockRangeAnchorRect(docEventManagerService, blockRange, fallbackPar
29287
29339
  };
29288
29340
  }
29289
29341
 
29342
+ //#endregion
29343
+ //#region src/views/paragraph-menu/paragraph-menu-position.ts
29344
+ function observeParagraphMenuPosition(element, popup, targets$) {
29345
+ let anchor;
29346
+ let table = false;
29347
+ let previousPosition;
29348
+ let disposed = false;
29349
+ const previousTransition = element.style.transition;
29350
+ const updatePosition = () => {
29351
+ var _window$matchMedia, _window;
29352
+ if (disposed || !anchor || element.style.visibility === "hidden") return;
29353
+ const gap = table ? 0 : 8;
29354
+ const boundary = popup.canvasElement.getBoundingClientRect();
29355
+ const containerLeft = Math.max(boundary.left, 0);
29356
+ const containerTop = Math.max(boundary.top, 0);
29357
+ const position = _univerjs_ui.RectPopup.calcPopupPosition({
29358
+ position: {
29359
+ ...anchor,
29360
+ left: anchor.left - gap,
29361
+ right: anchor.right + gap
29362
+ },
29363
+ width: element.clientWidth,
29364
+ height: element.clientHeight,
29365
+ direction: table ? "top-right" : "left-center",
29366
+ containerLeft,
29367
+ containerTop,
29368
+ containerWidth: Math.max(0, Math.min(boundary.right, window.innerWidth) - containerLeft),
29369
+ containerHeight: Math.max(0, Math.min(boundary.bottom, window.innerHeight) - containerTop),
29370
+ boundaryInsets: popup.boundaryInsets,
29371
+ noPushMinimumGap: popup.noPushMinimumGap
29372
+ });
29373
+ if ((previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.top) === position.top && previousPosition.left === position.left && element.style.top === previousPosition.styleTop && element.style.left === previousPosition.styleLeft) return;
29374
+ element.style.transition = previousPosition && !((_window$matchMedia = (_window = window).matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-reduced-motion: reduce)").matches) ? "top 100ms ease-out, left 100ms ease-out" : "";
29375
+ element.style.top = `${position.top}px`;
29376
+ element.style.left = `${position.left}px`;
29377
+ previousPosition = {
29378
+ ...position,
29379
+ styleTop: element.style.top,
29380
+ styleLeft: element.style.left
29381
+ };
29382
+ };
29383
+ const mutationObserver = new MutationObserver(updatePosition);
29384
+ mutationObserver.observe(element, {
29385
+ attributes: true,
29386
+ attributeFilter: ["style"]
29387
+ });
29388
+ const resizeObserver = new ResizeObserver(updatePosition);
29389
+ resizeObserver.observe(element);
29390
+ resizeObserver.observe(popup.canvasElement);
29391
+ const subscription = new rxjs.Subscription();
29392
+ subscription.add(targets$.subscribe((target) => {
29393
+ table = (target === null || target === void 0 ? void 0 : target.kind) === _univerjs_core.DocumentBlockType.TABLE;
29394
+ updatePosition();
29395
+ }));
29396
+ subscription.add(popup.anchorRect$.subscribe((rect) => {
29397
+ anchor = rect;
29398
+ updatePosition();
29399
+ }));
29400
+ return () => {
29401
+ if (disposed) return;
29402
+ disposed = true;
29403
+ subscription.unsubscribe();
29404
+ mutationObserver.disconnect();
29405
+ resizeObserver.disconnect();
29406
+ element.style.transition = previousTransition;
29407
+ };
29408
+ }
29409
+
29290
29410
  //#endregion
29291
29411
  //#region src/views/ParagraphMenu.tsx
29292
29412
  function getParagraphMenuPopupDirection(anchorLeft, menuWidth = 212, viewportPadding = 8, options = {}) {
@@ -29300,26 +29420,9 @@ const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
29300
29420
  const PARAGRAPH_MENU_HOVER_HIDE_DELAY = 240;
29301
29421
  const PARAGRAPH_MENU_HOVER_BRIDGE_EDGE_OVERLAP = 12;
29302
29422
  const PARAGRAPH_MENU_HOVER_BRIDGE_VERTICAL_PADDING = 8;
29303
- function getParagraphMenuIconSizeClass(iconKey) {
29304
- return iconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4";
29305
- }
29306
29423
  function shouldExecuteParagraphMenuMove(validatorService, context) {
29307
29424
  return validatorService.canMoveBlock(context);
29308
29425
  }
29309
- function getParagraphMenuTriggerIconKey(namedStyleType) {
29310
- switch (namedStyleType) {
29311
- case _univerjs_core.NamedStyleType.HEADING_1: return "H1Icon";
29312
- case _univerjs_core.NamedStyleType.HEADING_2: return "H2Icon";
29313
- case _univerjs_core.NamedStyleType.HEADING_3: return "H3Icon";
29314
- case _univerjs_core.NamedStyleType.HEADING_4: return "H4Icon";
29315
- case _univerjs_core.NamedStyleType.HEADING_5: return "H5Icon";
29316
- case _univerjs_core.NamedStyleType.TITLE: return "TitleTypeIcon";
29317
- case _univerjs_core.NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
29318
- case _univerjs_core.NamedStyleType.NORMAL_TEXT:
29319
- case _univerjs_core.NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED:
29320
- default: return "TextTypeIcon";
29321
- }
29322
- }
29323
29426
  function createParagraphMenuHoverOpenScheduler(openMenu, delay = 800) {
29324
29427
  let openTimer = null;
29325
29428
  const cancel = () => {
@@ -29458,9 +29561,6 @@ const PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS = /* @__PURE__ */ new Set([
29458
29561
  SetInlineFormatTextBackgroundColorCommand.id,
29459
29562
  ResetInlineFormatTextBackgroundColorCommand.id
29460
29563
  ]);
29461
- function shouldRestoreParagraphMenuSelectionAfterCommand(commandId) {
29462
- return !!commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId);
29463
- }
29464
29564
  function getParagraphMenuCommand(params, targetRange) {
29465
29565
  const commandId = params.commandId ?? params.id ?? (typeof params.label === "string" ? params.label : void 0);
29466
29566
  if (commandId && targetRange && commandId in HEADING_COMMAND_VALUES) return {
@@ -29502,28 +29602,11 @@ function getParagraphMenuCommandParams(commandId, commandParams, target, unitId)
29502
29602
  blockRange: target.blockRange
29503
29603
  };
29504
29604
  }
29505
- function getParagraphMenuType(target, emptyMode) {
29506
- if ((target === null || target === void 0 ? void 0 : target.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
29507
- if (emptyMode) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
29508
- if ((target === null || target === void 0 ? void 0 : target.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
29509
- return DOC_PARAGRAPH_T_EDIT_MENU_ID;
29510
- }
29511
- function getParagraphMenuActiveItemIds(target, namedStyleType) {
29512
- if ((target === null || target === void 0 ? void 0 : target.kind) === "blockRange") {
29513
- var _target$blockRange;
29514
- const commandId = getParagraphMenuBlockRangeCommandId((_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType);
29515
- return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
29516
- }
29517
- const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
29518
- const listCommandId = (target === null || target === void 0 ? void 0 : target.icon) ? LIST_ICON_TO_COMMAND_ID[target.icon] : void 0;
29519
- if (listCommandId) activeIds.push(listCommandId);
29520
- return activeIds;
29521
- }
29522
29605
  function getParagraphMenuHiddenItemIds(menuType, target, namedStyleType) {
29523
- var _target$blockRange2;
29606
+ var _target$blockRange;
29524
29607
  if (menuType === "doc.menu.paragraph-t.insert") return [];
29525
29608
  const hiddenIds = [...getParagraphMenuHiddenHeadingCommandIds(namedStyleType)];
29526
- const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange2 = target.blockRange) === null || _target$blockRange2 === void 0 ? void 0 : _target$blockRange2.blockType : void 0;
29609
+ const blockType = (target === null || target === void 0 ? void 0 : target.kind) === "blockRange" ? (_target$blockRange = target.blockRange) === null || _target$blockRange === void 0 ? void 0 : _target$blockRange.blockType : void 0;
29527
29610
  if ((target === null || target === void 0 ? void 0 : target.kind) !== "blockRange") hiddenIds.push(DocPasteCommand.id);
29528
29611
  if (blockType === _univerjs_core.DocumentBlockRangeType.CALLOUT) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CODE), getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.QUOTE));
29529
29612
  else if (blockType === _univerjs_core.DocumentBlockRangeType.QUOTE || blockType === _univerjs_core.DocumentBlockRangeType.CODE) hiddenIds.push(getParagraphMenuBlockRangeCommandId(_univerjs_core.DocumentBlockRangeType.CALLOUT));
@@ -29787,6 +29870,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29787
29870
  const doc = univerInstanceService.getUnit(popup.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
29788
29871
  const docParagraphMenuService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocParagraphMenuService);
29789
29872
  const docEventManagerService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocEventManagerService);
29873
+ const docSelectionRenderService = renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(DocSelectionRenderService);
29790
29874
  const isFocusedTableMenu = ((_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.focusedTableMenu) === true;
29791
29875
  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$);
29792
29876
  const slashMenuRequest = (0, _univerjs_ui.useObservable)(docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.slashMenuRequest$);
@@ -29800,7 +29884,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29800
29884
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(active, isFocusedTableMenu);
29801
29885
  };
29802
29886
  const rawActiveTarget = getActiveTarget();
29803
- const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === tableBlockOnly ? rawActiveTarget : null;
29887
+ const isTableMenu = tableBlockOnly || (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table";
29888
+ const currentActiveTarget = (rawActiveTarget === null || rawActiveTarget === void 0 ? void 0 : rawActiveTarget.kind) === "table" === isTableMenu ? rawActiveTarget : null;
29804
29889
  const activeParagraphBound = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.paragraph) ?? (docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeParagraph) ?? paragraph ?? paragraphLeft;
29805
29890
  const startIndex = activeParagraphBound === null || activeParagraphBound === void 0 ? void 0 : activeParagraphBound.startIndex;
29806
29891
  const dataStream = (doc === null || doc === void 0 || (_doc$getBody = doc.getBody()) === null || _doc$getBody === void 0 ? void 0 : _doc$getBody.dataStream) ?? "";
@@ -29810,11 +29895,38 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29810
29895
  }, [doc, startIndex]);
29811
29896
  const isEmptyParagraph = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.emptyMode) ?? isEmptyParagraphMenuTarget(dataStream, activeParagraphBound);
29812
29897
  const namedStyleType = paragraphObj === null || paragraphObj === void 0 || (_paragraphObj$paragra = paragraphObj.paragraphStyle) === null || _paragraphObj$paragra === void 0 ? void 0 : _paragraphObj$paragra.namedStyleType;
29898
+ const getParagraphMenuTriggerIconKey = () => {
29899
+ switch (namedStyleType) {
29900
+ case _univerjs_core.NamedStyleType.HEADING_1: return "H1Icon";
29901
+ case _univerjs_core.NamedStyleType.HEADING_2: return "H2Icon";
29902
+ case _univerjs_core.NamedStyleType.HEADING_3: return "H3Icon";
29903
+ case _univerjs_core.NamedStyleType.HEADING_4: return "H4Icon";
29904
+ case _univerjs_core.NamedStyleType.HEADING_5: return "H5Icon";
29905
+ case _univerjs_core.NamedStyleType.TITLE: return "TitleTypeIcon";
29906
+ case _univerjs_core.NamedStyleType.SUBTITLE: return "SubtitleTypeIcon";
29907
+ default: return "TextTypeIcon";
29908
+ }
29909
+ };
29813
29910
  const isModernHeading = (doc === null || doc === void 0 ? void 0 : doc.getDocumentStyle().documentFlavor) === _univerjs_core.DocumentFlavor.MODERN && startIndex != null && (renderUnit === null || renderUnit === void 0 ? void 0 : renderUnit.with(_univerjs_docs.DocSkeletonManagerService).getViewModel().getHeadingSections().some((heading) => heading.paragraphIndex === startIndex && heading.startOffset < heading.endOffset));
29814
- const targetIconKey = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey(namedStyleType);
29911
+ const targetIconKey = isEmptyParagraph ? "IncreaseIcon" : (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ?? getParagraphMenuTriggerIconKey();
29815
29912
  const TargetIcon = iconManager.get(targetIconKey);
29816
- const paragraphMenuType = (0, react.useMemo)(() => getParagraphMenuType(currentActiveTarget, isEmptyParagraph), [currentActiveTarget, isEmptyParagraph]);
29817
- const paragraphMenuActiveItemIds = (0, react.useMemo)(() => getParagraphMenuActiveItemIds(currentActiveTarget, namedStyleType), [currentActiveTarget, namedStyleType]);
29913
+ const paragraphMenuType = (0, react.useMemo)(() => {
29914
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table") return DOC_TABLE_BLOCK_MENU_ID;
29915
+ if (isEmptyParagraph) return DOC_PARAGRAPH_T_INSERT_MENU_ID;
29916
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) === "ReduceIcon") return DOC_PARAGRAPH_T_DIVIDER_MENU_ID;
29917
+ return DOC_PARAGRAPH_T_EDIT_MENU_ID;
29918
+ }, [currentActiveTarget, isEmptyParagraph]);
29919
+ const paragraphMenuActiveItemIds = (0, react.useMemo)(() => {
29920
+ if ((currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "blockRange") {
29921
+ var _currentActiveTarget$;
29922
+ const commandId = getParagraphMenuBlockRangeCommandId((_currentActiveTarget$ = currentActiveTarget.blockRange) === null || _currentActiveTarget$ === void 0 ? void 0 : _currentActiveTarget$.blockType);
29923
+ return commandId && PARAGRAPH_MENU_BLOCK_RANGE_COMMAND_IDS.has(commandId) ? [commandId] : [];
29924
+ }
29925
+ const activeIds = [getParagraphMenuActiveHeadingCommandId(namedStyleType)];
29926
+ const listCommandId = (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.icon) ? LIST_ICON_TO_COMMAND_ID[currentActiveTarget.icon] : void 0;
29927
+ if (listCommandId) activeIds.push(listCommandId);
29928
+ return activeIds;
29929
+ }, [currentActiveTarget, namedStyleType]);
29818
29930
  const paragraphMenuHiddenItemIds = (0, react.useMemo)(() => (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.kind) === "table" ? [] : getParagraphMenuHiddenItemIds(paragraphMenuType, currentActiveTarget, namedStyleType), [
29819
29931
  currentActiveTarget,
29820
29932
  namedStyleType,
@@ -29854,6 +29966,17 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29854
29966
  if (activeElement === focusedElement || !focusedElement.isConnected && activeElement === body) layoutService.focus();
29855
29967
  }, [layoutService]);
29856
29968
  (0, react.useLayoutEffect)(() => restoreMenuFocus, [restoreMenuFocus]);
29969
+ (0, react.useLayoutEffect)(() => {
29970
+ var _anchorRef$current3;
29971
+ if (isFocusedTableMenu || !docParagraphMenuService) return;
29972
+ const popupElement = (_anchorRef$current3 = anchorRef.current) === null || _anchorRef$current3 === void 0 ? void 0 : _anchorRef$current3.closest("[data-u-comp=\"rect-popup\"]");
29973
+ if (!popupElement) return;
29974
+ return observeParagraphMenuPosition(popupElement, popup, docParagraphMenuService.activeTarget$);
29975
+ }, [
29976
+ docParagraphMenuService,
29977
+ isFocusedTableMenu,
29978
+ popup
29979
+ ]);
29857
29980
  const handleHideMenu = (0, react.useCallback)(() => {
29858
29981
  hoverOpenSchedulerRef.current.cancel();
29859
29982
  restoreMenuFocus();
@@ -29866,6 +29989,16 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29866
29989
  isFocusedTableMenu,
29867
29990
  restoreMenuFocus
29868
29991
  ]);
29992
+ (0, react.useEffect)(() => {
29993
+ if (!visible || isFocusedTableMenu || !docSelectionRenderService) return;
29994
+ const subscription = docSelectionRenderService.onSelectionStart$.pipe((0, rxjs.skip)(1)).subscribe(handleHideMenu);
29995
+ return () => subscription.unsubscribe();
29996
+ }, [
29997
+ docSelectionRenderService,
29998
+ handleHideMenu,
29999
+ isFocusedTableMenu,
30000
+ visible
30001
+ ]);
29869
30002
  (0, react.useEffect)(() => {
29870
30003
  if (!isFocusedTableMenu || !docParagraphMenuService) return;
29871
30004
  const subscription = docParagraphMenuService.focusedTableMenuDismiss$.subscribe(handleHideMenu);
@@ -29905,7 +30038,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
29905
30038
  };
29906
30039
  const handleOpenMenu = (mode = "pointer") => {
29907
30040
  clearHideTimer();
29908
- if (openMode === "slash") return;
30041
+ if (openMode === "slash" || isDraggingRef.current) return;
29909
30042
  const latestTarget = getActiveTarget();
29910
30043
  setMenuInteractionActive(true);
29911
30044
  const targetRange = latestTarget ? {
@@ -30060,7 +30193,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30060
30193
  finishParagraphMenuCommand(docParagraphMenuService, handleHideMenu);
30061
30194
  return;
30062
30195
  }
30063
- const previousTextRanges = shouldRestoreParagraphMenuSelectionAfterCommand(commandId) ? getCurrentTextRangesSnapshot() : null;
30196
+ const previousTextRanges = commandId && PARAGRAPH_MENU_RESTORE_SELECTION_COMMAND_IDS.has(commandId) ? getCurrentTextRangesSnapshot() : null;
30064
30197
  if (commandId && shouldUseInsertBelowRange(commandId, option) && (latestTarget === null || latestTarget === void 0 ? void 0 : latestTarget.moveRange)) docContentInsertService.setInsertRange({
30065
30198
  unitId: popup.unitId,
30066
30199
  startOffset: latestTarget.moveRange.endOffset,
@@ -30092,21 +30225,21 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30092
30225
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setParagraphMenuActive(false, isFocusedTableMenu);
30093
30226
  }, [docParagraphMenuService, isFocusedTableMenu]);
30094
30227
  (0, react.useEffect)(() => {
30095
- if (tableBlockOnly || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
30228
+ if (isTableMenu || !slashMenuRequest || handledSlashRequestNonceRef.current >= slashMenuRequest.nonce) return;
30096
30229
  handledSlashRequestNonceRef.current = slashMenuRequest.nonce;
30097
30230
  hoverOpenSchedulerRef.current.cancel();
30098
30231
  clearHideTimer();
30099
30232
  isMouseOver.current = false;
30100
30233
  handleOpenSlashMenu(slashMenuRequest);
30101
- }, [slashMenuRequest, tableBlockOnly]);
30234
+ }, [slashMenuRequest, isTableMenu]);
30102
30235
  if (!currentActiveTarget) return null;
30103
30236
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
30104
30237
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
30105
30238
  "data-u-comp": "paragraph-menu",
30106
- "data-u-table-menu": tableBlockOnly ? "true" : void 0,
30239
+ "data-u-table-menu": isTableMenu ? "true" : void 0,
30107
30240
  "data-u-focused-table-menu": isFocusedTableMenu ? "true" : void 0,
30108
30241
  ref: anchorRef,
30109
- className: (0, _univerjs_design.clsx)("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", {
30242
+ className: (0, _univerjs_design.clsx)("univer-inline-flex univer-h-7 univer-cursor-pointer univer-select-none 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", {
30110
30243
  "univer-mr-1": !isModernHeading,
30111
30244
  "univer-bg-gray-100 univer-shadow-md dark:!univer-bg-gray-800": visible
30112
30245
  }),
@@ -30128,7 +30261,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30128
30261
  isMouseOver.current = true;
30129
30262
  hoverOpenSchedulerRef.current.openNow();
30130
30263
  },
30131
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TargetIcon, { className: (0, _univerjs_design.clsx)(getParagraphMenuIconSizeClass(targetIconKey), "univer-shrink-0 univer-text-gray-700 dark:!univer-text-gray-0") }), (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30264
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TargetIcon, { className: (0, _univerjs_design.clsx)(targetIconKey === "TextTypeIcon" ? "univer-size-3" : "univer-size-4", "univer-shrink-0 univer-text-gray-700 dark:!univer-text-gray-0") }), !isEmptyParagraph && (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30132
30265
  type: "button",
30133
30266
  className: "univer-group univer-flex univer-h-4 univer-w-2.5 univer-cursor-grab univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 active:univer-cursor-grabbing",
30134
30267
  "aria-label": localeService.t("docs-ui.doc.blockMenu.dragBlock"),
@@ -30145,6 +30278,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30145
30278
  isMouseOver.current = true;
30146
30279
  isDraggingRef.current = true;
30147
30280
  docParagraphMenuService === null || docParagraphMenuService === void 0 || docParagraphMenuService.setBlockMenuDragging(true);
30281
+ handleHideMenu();
30148
30282
  dragRangeRef.current = moveRange;
30149
30283
  dragTargetOffsetRef.current = null;
30150
30284
  setDropRect(null);
@@ -30204,7 +30338,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30204
30338
  }),
30205
30339
  visible && hoverBridgeStyle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
30206
30340
  "aria-hidden": "true",
30207
- className: "univer-fixed univer-z-[1019] univer-bg-transparent",
30341
+ className: "univer-fixed univer-z-[1019] univer-select-none univer-bg-transparent",
30208
30342
  style: hoverBridgeStyle,
30209
30343
  onMouseEnter: (e) => {
30210
30344
  var _popup$onPointerEnter2;
@@ -30223,6 +30357,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
30223
30357
  anchorRect$,
30224
30358
  direction: menuDirection,
30225
30359
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
30360
+ className: "univer-select-none",
30226
30361
  onFocusCapture: (event) => {
30227
30362
  focusedMenuElementRef.current = event.target;
30228
30363
  },
@@ -30482,6 +30617,7 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
30482
30617
  [DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
30483
30618
  [DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
30484
30619
  [FLOAT_MENU_COMPONENT_KEY, FloatToolbar],
30620
+ [EditorColorPicker.componentKey, EditorColorPicker],
30485
30621
  [PAGE_SETTING_COMPONENT_ID, PageSettings],
30486
30622
  [DOC_LAYOUT_RECOVERY_COMPONENT, DocLayoutRecovery]
30487
30623
  ].forEach(([key, comp]) => {
@@ -32072,18 +32208,30 @@ function isSheetFormulaEditor(editorUnitId, univerInstanceService) {
32072
32208
  }
32073
32209
  function executeEditorUndoRedoCommand(options) {
32074
32210
  var _univerInstanceServic;
32075
- const { commandId, commandService, editorUnitId, univerInstanceService } = options;
32211
+ const { commandId, commandService, contextService, editorUnitId, preserveHostFocus, univerInstanceService } = options;
32076
32212
  const shouldUseSheetEditorContext = editorUnitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || editorUnitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
32077
32213
  if (isSheetFormulaEditor(editorUnitId, univerInstanceService)) return;
32078
32214
  const previousFocusedUnitId = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) ?? null;
32079
32215
  const shouldRestoreFocus = !shouldUseSheetEditorContext && previousFocusedUnitId !== null && previousFocusedUnitId !== editorUnitId;
32080
32216
  if (!shouldUseSheetEditorContext && previousFocusedUnitId !== editorUnitId) univerInstanceService.focusUnit(editorUnitId);
32081
32217
  commandService.executeCommand(commandId).finally(() => {
32082
- if (shouldRestoreFocus) univerInstanceService.focusUnit(previousFocusedUnitId);
32218
+ var _univerInstanceServic2;
32219
+ if (!shouldRestoreFocus || ((_univerInstanceServic2 = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId()) !== editorUnitId) return;
32220
+ if (!preserveHostFocus || !contextService) {
32221
+ univerInstanceService.focusUnit(previousFocusedUnitId);
32222
+ return;
32223
+ }
32224
+ const previousDisableAutoFocus = contextService.getContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY);
32225
+ contextService.setContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY, true);
32226
+ try {
32227
+ univerInstanceService.focusUnit(previousFocusedUnitId);
32228
+ } finally {
32229
+ contextService.setContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY, previousDisableAutoFocus);
32230
+ }
32083
32231
  });
32084
32232
  }
32085
32233
  function createEditorUndoRedoKeyboardConfig(options) {
32086
- const { commandService, editorUnitId, handler, keyCodes = [], univerInstanceService } = options;
32234
+ const { commandService, contextService, editorUnitId, handler, keyCodes = [], preserveHostFocus, univerInstanceService } = options;
32087
32235
  const ctrlCommand = _univerjs_ui.MetaKeys.CTRL_COMMAND;
32088
32236
  const ctrlCommandShift = _univerjs_ui.MetaKeys.CTRL_COMMAND | _univerjs_ui.MetaKeys.SHIFT;
32089
32237
  return {
@@ -32108,7 +32256,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
32108
32256
  executeEditorUndoRedoCommand({
32109
32257
  commandId: _univerjs_core.UndoCommand.id,
32110
32258
  commandService,
32259
+ contextService,
32111
32260
  editorUnitId,
32261
+ preserveHostFocus,
32112
32262
  univerInstanceService
32113
32263
  });
32114
32264
  return;
@@ -32117,7 +32267,9 @@ function createEditorUndoRedoKeyboardConfig(options) {
32117
32267
  executeEditorUndoRedoCommand({
32118
32268
  commandId: _univerjs_core.RedoCommand.id,
32119
32269
  commandService,
32270
+ contextService,
32120
32271
  editorUnitId,
32272
+ preserveHostFocus,
32121
32273
  univerInstanceService
32122
32274
  });
32123
32275
  return;
@@ -32563,6 +32715,7 @@ const useResize = (editor, isSingle = true, autoScrollbar, autoScroll, layoutSiz
32563
32715
  const RichTextEditor = (props) => {
32564
32716
  const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, preserveHostFocus, cancelDefaultResizeListener, documentLayoutSize, autoScroll = true, autoScrollbar = true, emitSelectionWhileDragging, keyboardEventsOnSelection = false, keyboardEventConfig, layoutSize, pixelRatio, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle, canvasStyle, renderConfig } = props;
32565
32717
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
32718
+ const contextService = (0, _univerjs_ui.useDependency)(_univerjs_core.IContextService);
32566
32719
  const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
32567
32720
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
32568
32721
  const onFocusChange = (0, _univerjs_ui.useEvent)(_onFocusChange);
@@ -32630,14 +32783,18 @@ const RichTextEditor = (props) => {
32630
32783
  useEditorClickOutside(editorId, sheetEmbeddingRef, onClickOutside);
32631
32784
  const resolvedKeyboardEventConfig = (0, react.useMemo)(() => createEditorUndoRedoKeyboardConfig({
32632
32785
  commandService,
32786
+ contextService,
32633
32787
  univerInstanceService,
32634
32788
  editorUnitId: editorId,
32789
+ preserveHostFocus,
32635
32790
  keyCodes: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.keyCodes,
32636
32791
  handler: keyboardEventConfig === null || keyboardEventConfig === void 0 ? void 0 : keyboardEventConfig.handler
32637
32792
  }), [
32638
32793
  commandService,
32794
+ contextService,
32639
32795
  editorId,
32640
32796
  keyboardEventConfig,
32797
+ preserveHostFocus,
32641
32798
  univerInstanceService
32642
32799
  ]);
32643
32800
  useLeftAndRightArrow(isFocusing && moveCursor, false, editor);
@@ -32942,6 +33099,7 @@ Object.defineProperty(exports, "DocsRenderService", {
32942
33099
  exports.DocsUIMenuSchema = menuSchema;
32943
33100
  exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
32944
33101
  exports.Editor = Editor;
33102
+ exports.EditorColorPicker = EditorColorPicker;
32945
33103
  Object.defineProperty(exports, "EditorService", {
32946
33104
  enumerable: true,
32947
33105
  get: function () {