@univerjs/ui 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (34) hide show
  1. package/lib/cjs/facade.js +2 -0
  2. package/lib/cjs/index.js +657 -268
  3. package/lib/es/facade.js +2 -0
  4. package/lib/es/index.js +648 -269
  5. package/lib/facade.js +2 -0
  6. package/lib/index.css +53 -8
  7. package/lib/index.js +648 -269
  8. package/lib/types/common/menu-hidden-observable.d.ts +2 -1
  9. package/lib/types/facade/f-menu-builder.d.ts +2 -0
  10. package/lib/types/index.d.ts +12 -6
  11. package/lib/types/services/contextmenu/contextmenu.service.d.ts +6 -3
  12. package/lib/types/services/dom/canvas-dom-layer.service.d.ts +52 -1
  13. package/lib/types/services/menu/menu-manager.service.d.ts +1 -0
  14. package/lib/types/services/popup/canvas-popup.service.d.ts +2 -1
  15. package/lib/types/services/ribbon/ribbon-override.service.d.ts +42 -0
  16. package/lib/types/services/runtime-scope/ui-runtime-scope.service.d.ts +32 -0
  17. package/lib/types/services/shortcut/shortcut.service.d.ts +2 -1
  18. package/lib/types/utils/embed-boundary.d.ts +23 -0
  19. package/lib/types/utils/index.d.ts +1 -0
  20. package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +4 -0
  21. package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +4 -0
  22. package/lib/types/views/components/dom/FloatDom.d.ts +11 -0
  23. package/lib/types/views/components/dom/float-dom-layout.d.ts +35 -0
  24. package/lib/types/views/components/ribbon/Ribbon.d.ts +2 -0
  25. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +6 -1
  26. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
  27. package/lib/types/views/font-family/FontFamily.d.ts +10 -2
  28. package/lib/types/views/font-family/FontFamilyDropdown.d.ts +32 -0
  29. package/lib/types/views/font-family/FontFamilyItem.d.ts +5 -3
  30. package/lib/types/views/font-family/index.d.ts +6 -2
  31. package/lib/types/views/font-family/{interface.d.ts → use-font-list.d.ts} +6 -9
  32. package/lib/types/views/menu/mobile/MobileMenu.d.ts +2 -0
  33. package/lib/umd/index.js +15 -22
  34. package/package.json +9 -9
package/lib/cjs/index.js CHANGED
@@ -307,11 +307,11 @@ function getHeaderFooterMenuHiddenObservable(accessor) {
307
307
  return new rxjs.Observable((subscriber) => {
308
308
  const subscription = univerInstanceService.focused$.subscribe((unitId) => {
309
309
  if (unitId == null) return subscriber.next(true);
310
- const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
310
+ const docDataModel = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
311
311
  const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
312
312
  subscriber.next(documentFlavor !== _univerjs_core.DocumentFlavor.TRADITIONAL);
313
313
  });
314
- const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
314
+ const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
315
315
  if (docDataModel == null) subscriber.next(true);
316
316
  else {
317
317
  const documentFlavor = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle.documentFlavor;
@@ -625,6 +625,47 @@ function fromGlobalEvent(type, listener, options) {
625
625
  return (0, _univerjs_core.toDisposable)(() => window.removeEventListener(type, listener, options));
626
626
  }
627
627
 
628
+ //#endregion
629
+ //#region src/utils/embed-boundary.ts
630
+ /**
631
+ * Copyright 2023-present DreamNum Co., Ltd.
632
+ *
633
+ * Licensed under the Apache License, Version 2.0 (the "License");
634
+ * you may not use this file except in compliance with the License.
635
+ * You may obtain a copy of the License at
636
+ *
637
+ * http://www.apache.org/licenses/LICENSE-2.0
638
+ *
639
+ * Unless required by applicable law or agreed to in writing, software
640
+ * distributed under the License is distributed on an "AS IS" BASIS,
641
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
642
+ * See the License for the specific language governing permissions and
643
+ * limitations under the License.
644
+ */
645
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
646
+ function getEmbedBoundaryOwner(target) {
647
+ var _ref, _getAttributeValue;
648
+ if (!hasClosest(target)) return;
649
+ const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
650
+ return (_ref = (_getAttributeValue = getAttributeValue(target, "data-embed-interaction-boundary-owner")) !== null && _getAttributeValue !== void 0 ? _getAttributeValue : getAttributeValue(ownerElement, "data-embed-interaction-boundary-owner")) !== null && _ref !== void 0 ? _ref : void 0;
651
+ }
652
+ function isEmbedBoundaryTarget(target) {
653
+ return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
654
+ }
655
+ function keepInteractionInsideSameEmbedBoundary(event) {
656
+ const owner = getEmbedBoundaryOwner(event.currentTarget);
657
+ if (!owner) return;
658
+ if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
659
+ }
660
+ function hasClosest(target) {
661
+ return !!target && typeof target.closest === "function";
662
+ }
663
+ function getAttributeValue(target, name) {
664
+ var _getAttribute$call;
665
+ const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
666
+ return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
667
+ }
668
+
628
669
  //#endregion
629
670
  //#region src/services/layout/layout.service.ts
630
671
  const FOCUSING_UNIVER = "FOCUSING_UNIVER";
@@ -705,8 +746,15 @@ let DesktopLayoutService = class DesktopLayoutService extends _univerjs_core.Dis
705
746
  this.disposeWithMe((0, rxjs.fromEvent)(window, "focusin").subscribe((event) => {
706
747
  var _this$_rootContainerE;
707
748
  const target = event.target;
708
- if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item)) {
709
- queueMicrotask(() => this.focus());
749
+ if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item) && !isEmbedBoundaryTarget(target)) {
750
+ queueMicrotask(() => {
751
+ const targetUnitId = getFocusUnitIdFromElement(target);
752
+ if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
753
+ this.focus();
754
+ this._isFocused = true;
755
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
756
+ this._contextService.setContextValue(_univerjs_core.FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
757
+ });
710
758
  return;
711
759
  }
712
760
  if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
@@ -724,6 +772,9 @@ function getFocusingUniverEditorStatus() {
724
772
  var _document$activeEleme;
725
773
  return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
726
774
  }
775
+ function getFocusUnitIdFromElement(target) {
776
+ return target.dataset.uUnitId;
777
+ }
727
778
 
728
779
  //#endregion
729
780
  //#region src/services/platform/platform.service.ts
@@ -845,6 +896,7 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
845
896
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
846
897
  const binding = this._deriveBindingFromEvent(e);
847
898
  if (binding === null) return;
899
+ if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
848
900
  const shortcuts = this._shortCutMapping.get(binding);
849
901
  if (shortcuts === void 0) return;
850
902
  return Array.from(shortcuts).sort((s1, s2) => {
@@ -870,6 +922,12 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
870
922
  if (this._platformService.isMac && e.ctrlKey) binding |= 8192;
871
923
  return binding;
872
924
  }
925
+ _shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) {
926
+ if (binding !== (65 | 4096)) return false;
927
+ const target = e.target;
928
+ if (!(target instanceof HTMLElement)) return false;
929
+ return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
930
+ }
873
931
  };
874
932
  ShortcutService = __decorate([
875
933
  __decorateParam(0, _univerjs_core.ICommandService),
@@ -1051,8 +1109,9 @@ let ContextMenuGroup = /* @__PURE__ */ function(ContextMenuGroup) {
1051
1109
 
1052
1110
  //#endregion
1053
1111
  //#region src/services/menu/menu-manager.service.ts
1112
+ var _MenuManagerService;
1054
1113
  const IMenuManagerService = (0, _univerjs_core.createIdentifier)("univer.menu-manager-service");
1055
- let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposable {
1114
+ let MenuManagerService = _MenuManagerService = class MenuManagerService extends _univerjs_core.Disposable {
1056
1115
  constructor(_injector, _configService) {
1057
1116
  super();
1058
1117
  this._injector = _injector;
@@ -1186,6 +1245,21 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1186
1245
  this._menu = (0, _univerjs_core.merge)({}, this._menu, source);
1187
1246
  this.menuChanged$.next();
1188
1247
  }
1248
+ createScoped(injector) {
1249
+ const root = this;
1250
+ const createScopedBuilder = () => {
1251
+ const service = new _MenuManagerService(injector, root._configService);
1252
+ service._menu = root._menu;
1253
+ return service;
1254
+ };
1255
+ return {
1256
+ menuChanged$: root.menuChanged$,
1257
+ mergeMenu: (source, target) => root.mergeMenu(source, target),
1258
+ appendRootMenu: (source) => root.appendRootMenu(source),
1259
+ getMenuByPositionKey: (position) => createScopedBuilder().getMenuByPositionKey(position),
1260
+ getFlatMenuByPositionKey: (position) => createScopedBuilder().getFlatMenuByPositionKey(position)
1261
+ };
1262
+ }
1189
1263
  _buildMenuSchema(data) {
1190
1264
  const result = [];
1191
1265
  for (const [key, value] of Object.entries(data)) {
@@ -1225,6 +1299,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1225
1299
  * @returns Menu schema array or empty array if not found
1226
1300
  */
1227
1301
  getMenuByPositionKey(key) {
1302
+ var _findKey;
1228
1303
  const findKey = (obj) => {
1229
1304
  if (key in obj) return this._buildMenuSchema(obj[key]);
1230
1305
  for (const k in obj) {
@@ -1235,7 +1310,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1235
1310
  }
1236
1311
  }
1237
1312
  };
1238
- return findKey(this._menu);
1313
+ return (_findKey = findKey(this._menu)) !== null && _findKey !== void 0 ? _findKey : [];
1239
1314
  }
1240
1315
  /**
1241
1316
  * Get flat menu schema by position key
@@ -1257,7 +1332,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1257
1332
  return flatMenuItems(menu);
1258
1333
  }
1259
1334
  };
1260
- MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
1335
+ MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
1261
1336
  function normalizeMenuOrder(order) {
1262
1337
  return order !== null && order !== void 0 ? order : 0;
1263
1338
  }
@@ -1334,11 +1409,14 @@ const undoRedoDisableFactory$ = (accessor, isUndo) => {
1334
1409
  return undoDisable || contextService.getContextValue(_univerjs_core.EDITOR_ACTIVATED) || contextService.getContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR);
1335
1410
  }));
1336
1411
  };
1412
+ const rtlIconFactory$ = (accessor, ltrIcon, rtlIcon) => {
1413
+ return accessor.get(_univerjs_core.LocaleService).direction$.pipe((0, rxjs_operators.map)((direction) => direction === "rtl" ? rtlIcon : ltrIcon));
1414
+ };
1337
1415
  function UndoMenuItemFactory(accessor) {
1338
1416
  return {
1339
1417
  id: _univerjs_core.UndoCommand.id,
1340
1418
  type: 0,
1341
- icon: "UndoIcon",
1419
+ icon: rtlIconFactory$(accessor, "UndoIcon", "RedoIcon"),
1342
1420
  title: "ui.shortcut.undo",
1343
1421
  tooltip: "ui.shortcut.undo",
1344
1422
  disabled$: undoRedoDisableFactory$(accessor, true)
@@ -1348,7 +1426,7 @@ function RedoMenuItemFactory(accessor) {
1348
1426
  return {
1349
1427
  id: _univerjs_core.RedoCommand.id,
1350
1428
  type: 0,
1351
- icon: "RedoIcon",
1429
+ icon: rtlIconFactory$(accessor, "RedoIcon", "UndoIcon"),
1352
1430
  title: "ui.shortcut.redo",
1353
1431
  tooltip: "ui.shortcut.redo",
1354
1432
  disabled$: undoRedoDisableFactory$(accessor, false)
@@ -1469,8 +1547,15 @@ function useObservableRef(observable, defaultValue) {
1469
1547
 
1470
1548
  //#endregion
1471
1549
  //#region src/services/dom/canvas-dom-layer.service.ts
1472
- var CanvasFloatDomService = class {
1473
- constructor() {
1550
+ function shouldForwardFloatDomEvents(layer) {
1551
+ return layer.eventPassThrough !== false;
1552
+ }
1553
+ function shouldRenderFloatDomLayer(layer, currentUnitId) {
1554
+ return layer.unitId === currentUnitId || layer.preserveOnFocusChange === true;
1555
+ }
1556
+ var CanvasFloatDomService = class extends _univerjs_core.Disposable {
1557
+ constructor(..._args) {
1558
+ super(..._args);
1474
1559
  _defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
1475
1560
  _defineProperty(this, "_domLayers$", new rxjs.BehaviorSubject([]));
1476
1561
  _defineProperty(this, "domLayers$", this._domLayers$.asObservable());
@@ -1501,68 +1586,131 @@ var CanvasFloatDomService = class {
1501
1586
  this._domLayerMap.clear();
1502
1587
  this._notice();
1503
1588
  }
1589
+ dispose() {
1590
+ this._domLayerMap.clear();
1591
+ this._domLayers$.next([]);
1592
+ this._domLayers$.complete();
1593
+ super.dispose();
1594
+ }
1504
1595
  };
1596
+ var CanvasFloatDomPreviewService = class extends _univerjs_core.Disposable {
1597
+ constructor(..._args2) {
1598
+ super(..._args2);
1599
+ _defineProperty(this, "previewUpdated$", new rxjs.Subject());
1600
+ _defineProperty(this, "previewRequested$", new rxjs.Subject());
1601
+ _defineProperty(this, "_previewMap", /* @__PURE__ */ new Map());
1602
+ _defineProperty(this, "_requestMap", /* @__PURE__ */ new Map());
1603
+ }
1604
+ getPreview(id) {
1605
+ return this._previewMap.get(id);
1606
+ }
1607
+ getPendingRequests() {
1608
+ return Array.from(this._requestMap.values());
1609
+ }
1610
+ setPreview(preview) {
1611
+ this._previewMap.set(preview.id, preview);
1612
+ this._requestMap.delete(preview.id);
1613
+ this.previewUpdated$.next(preview);
1614
+ }
1615
+ removePreview(id) {
1616
+ this._previewMap.delete(id);
1617
+ this._requestMap.delete(id);
1618
+ }
1619
+ requestPreview(request) {
1620
+ this._requestMap.set(request.id, request);
1621
+ this.previewRequested$.next(request);
1622
+ }
1623
+ dispose() {
1624
+ this._previewMap.clear();
1625
+ this._requestMap.clear();
1626
+ this.previewUpdated$.complete();
1627
+ this.previewRequested$.complete();
1628
+ super.dispose();
1629
+ }
1630
+ };
1631
+
1632
+ //#endregion
1633
+ //#region src/views/components/dom/float-dom-layout.ts
1634
+ const LEGACY_WRAPPER_INSET = 2;
1635
+ const LEGACY_CONTENT_INSET = 4;
1636
+ function resolveFloatDomLayout(position, contentBox) {
1637
+ var _contentBox$wrapperIn, _contentBox$contentIn, _position$opacity;
1638
+ const wrapperInset = (_contentBox$wrapperIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) !== null && _contentBox$wrapperIn !== void 0 ? _contentBox$wrapperIn : LEGACY_WRAPPER_INSET;
1639
+ const contentInset = (_contentBox$contentIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) !== null && _contentBox$contentIn !== void 0 ? _contentBox$contentIn : LEGACY_CONTENT_INSET;
1640
+ return {
1641
+ wrapper: {
1642
+ top: position.startY,
1643
+ left: position.startX,
1644
+ width: Math.max(position.endX - position.startX - wrapperInset, 0),
1645
+ height: Math.max(position.endY - position.startY - wrapperInset, 0),
1646
+ transform: `rotate(${position.rotate}deg)`,
1647
+ opacity: (_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1
1648
+ },
1649
+ inner: {
1650
+ width: position.width - contentInset,
1651
+ height: position.height - contentInset,
1652
+ left: position.absolute.left ? 0 : "auto",
1653
+ top: position.absolute.top ? 0 : "auto",
1654
+ right: position.absolute.left ? "auto" : 0,
1655
+ bottom: position.absolute.top ? "auto" : 0
1656
+ }
1657
+ };
1658
+ }
1505
1659
 
1506
1660
  //#endregion
1507
1661
  //#region src/views/components/dom/FloatDom.tsx
1662
+ function applyFloatDomLayout(wrapper, inner, layout) {
1663
+ const { wrapper: wrapperLayout, inner: innerLayout } = layout;
1664
+ const wrapperStyle = wrapper.style;
1665
+ wrapperStyle.top = `${wrapperLayout.top}px`;
1666
+ wrapperStyle.left = `${wrapperLayout.left}px`;
1667
+ wrapperStyle.width = `${wrapperLayout.width}px`;
1668
+ wrapperStyle.height = `${wrapperLayout.height}px`;
1669
+ wrapperStyle.transform = wrapperLayout.transform;
1670
+ wrapperStyle.opacity = `${wrapperLayout.opacity}`;
1671
+ const innerStyle = inner.style;
1672
+ innerStyle.width = `${innerLayout.width}px`;
1673
+ innerStyle.height = `${innerLayout.height}px`;
1674
+ innerStyle.left = innerLayout.left === "auto" ? "auto" : `${innerLayout.left}px`;
1675
+ innerStyle.top = innerLayout.top === "auto" ? "auto" : `${innerLayout.top}px`;
1676
+ innerStyle.right = innerLayout.right === "auto" ? "auto" : `${innerLayout.right}px`;
1677
+ innerStyle.bottom = innerLayout.bottom === "auto" ? "auto" : `${innerLayout.bottom}px`;
1678
+ }
1508
1679
  const FloatDomSingle = (0, react.memo)((props) => {
1509
- var _position$startY, _position$startX;
1680
+ var _layer$contentBox, _layer$contentBox2;
1510
1681
  const { layer, id } = props;
1511
- const size$ = (0, react.useMemo)(() => layer.position$.pipe((0, rxjs.distinctUntilChanged)((prev, curr) => prev.absolute.left === curr.absolute.left && prev.absolute.top === curr.absolute.top && prev.endX - prev.startX === curr.endX - curr.startX && prev.endY - prev.startY === curr.endY - curr.startY)), [layer.position$]);
1512
1682
  const univerInstanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
1513
1683
  const position = (0, _wendellhu_redi_react_bindings.useObservable)((0, react.useMemo)(() => layer.position$.pipe((0, rxjs.first)()), [layer.position$]));
1514
1684
  const domRef = (0, react.useRef)(null);
1515
1685
  const innerDomRef = (0, react.useRef)(null);
1516
- const transformRef = (0, react.useRef)(`transform: rotate(${position === null || position === void 0 ? void 0 : position.rotate}deg) translate(${position === null || position === void 0 ? void 0 : position.startX}px, ${position === null || position === void 0 ? void 0 : position.startY}px)`);
1517
- const topRef = (0, react.useRef)((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
1518
- const leftRef = (0, react.useRef)((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
1519
- const innerStyle = (0, react.useRef)({});
1520
1686
  const Component = typeof layer.componentKey === "string" ? (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager).get(layer.componentKey) : layer.componentKey;
1521
1687
  const layerProps = (0, react.useMemo)(() => ({
1522
1688
  data: layer.data,
1523
- ...layer.props
1524
- }), [layer.data, layer.props]);
1689
+ ...layer.props,
1690
+ hostFloatDomLayout$: layer.position$
1691
+ }), [
1692
+ layer.data,
1693
+ layer.position$,
1694
+ layer.props
1695
+ ]);
1696
+ const floatDomOverflow = resolveFloatDomOverflow(layerProps);
1697
+ const wrapperInset = (_layer$contentBox = layer.contentBox) === null || _layer$contentBox === void 0 ? void 0 : _layer$contentBox.wrapperInset;
1698
+ const contentInset = (_layer$contentBox2 = layer.contentBox) === null || _layer$contentBox2 === void 0 ? void 0 : _layer$contentBox2.contentInset;
1525
1699
  (0, react.useEffect)(() => {
1526
1700
  const subscription = layer.position$.subscribe((position) => {
1527
- transformRef.current = `rotate(${position.rotate}deg)`;
1528
- topRef.current = position.startY;
1529
- leftRef.current = position.startX;
1530
- if (domRef.current) {
1531
- var _position$opacity;
1532
- domRef.current.style.transform = transformRef.current;
1533
- domRef.current.style.top = `${topRef.current}px`;
1534
- domRef.current.style.left = `${leftRef.current}px`;
1535
- domRef.current.style.opacity = `${(_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1}`;
1536
- }
1537
- });
1538
- const sizeSubscription = size$.subscribe((size) => {
1539
- if (domRef.current) {
1540
- domRef.current.style.width = `${Math.max(size.endX - size.startX - 2, 0)}px`;
1541
- domRef.current.style.height = `${Math.max(size.endY - size.startY - 2, 0)}px`;
1542
- }
1543
- if (innerDomRef.current) {
1544
- const style = {
1545
- width: `${size.width - 4}px`,
1546
- height: `${size.height - 4}px`,
1547
- left: `${size.absolute.left ? 0 : "auto"}`,
1548
- top: `${size.absolute.top ? 0 : "auto"}`,
1549
- right: `${size.absolute.left ? "auto" : 0}`,
1550
- bottom: `${size.absolute.top ? "auto" : 0}`
1551
- };
1552
- innerDomRef.current.style.width = style.width;
1553
- innerDomRef.current.style.height = style.height;
1554
- innerDomRef.current.style.left = style.left;
1555
- innerDomRef.current.style.top = style.top;
1556
- innerDomRef.current.style.right = style.right;
1557
- innerDomRef.current.style.bottom = style.bottom;
1558
- innerStyle.current = style;
1559
- }
1701
+ if (domRef.current && innerDomRef.current) applyFloatDomLayout(domRef.current, innerDomRef.current, resolveFloatDomLayout(position, {
1702
+ wrapperInset,
1703
+ contentInset
1704
+ }));
1560
1705
  });
1561
1706
  return () => {
1562
1707
  subscription.unsubscribe();
1563
- sizeSubscription.unsubscribe();
1564
1708
  };
1565
- }, [layer.position$, size$]);
1709
+ }, [
1710
+ contentInset,
1711
+ layer.position$,
1712
+ wrapperInset
1713
+ ]);
1566
1714
  const instance = univerInstanceService.getUnit(layer.unitId);
1567
1715
  const docDisabled = instance instanceof _univerjs_core.DocumentDataModel ? instance.getDisabled() : void 0;
1568
1716
  const component = (0, react.useMemo)(() => Component ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
@@ -1576,36 +1724,34 @@ const FloatDomSingle = (0, react.memo)((props) => {
1576
1724
  }
1577
1725
  }) : null, [Component, layerProps]);
1578
1726
  if (!position) return null;
1727
+ const layout = resolveFloatDomLayout(position, layer.contentBox);
1579
1728
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1580
1729
  ref: domRef,
1581
- className: "univer-z-10",
1730
+ className: "univer-absolute univer-z-10 univer-origin-center",
1582
1731
  style: {
1583
- position: "absolute",
1584
- top: topRef.current,
1585
- left: leftRef.current,
1586
- width: Math.max(position.endX - position.startX - 2, 0),
1587
- height: Math.max(position.endY - position.startY - 2, 0),
1588
- transform: transformRef.current,
1589
- overflow: "hidden",
1590
- transformOrigin: "center center"
1732
+ ...layout.wrapper,
1733
+ overflow: floatDomOverflow.outerOverflow
1591
1734
  },
1592
1735
  onPointerMove: (e) => {
1593
- layer.onPointerMove(e.nativeEvent);
1736
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
1594
1737
  },
1595
1738
  onPointerDown: (e) => {
1596
- layer.onPointerDown(e.nativeEvent);
1739
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
1597
1740
  },
1598
1741
  onPointerUp: (e) => {
1599
- layer.onPointerUp(e.nativeEvent);
1742
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
1600
1743
  },
1601
1744
  onWheel: (e) => {
1602
- layer.onWheel(e.nativeEvent);
1745
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
1603
1746
  },
1604
1747
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1605
1748
  id,
1606
1749
  ref: innerDomRef,
1607
1750
  className: "univer-absolute univer-overflow-hidden",
1608
- style: { ...innerStyle.current },
1751
+ style: {
1752
+ ...layout.inner,
1753
+ overflow: floatDomOverflow.innerOverflow
1754
+ },
1609
1755
  children: component
1610
1756
  })
1611
1757
  });
@@ -1614,9 +1760,8 @@ const FloatDom = ({ unitId }) => {
1614
1760
  var _layers$filter;
1615
1761
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
1616
1762
  const layers = (0, _wendellhu_redi_react_bindings.useObservable)((0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService).domLayers$);
1617
- const focusUnit = (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$);
1618
- const currentUnitId = unitId || focusUnit;
1619
- return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => layer[1].unitId === currentUnitId)) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1763
+ const currentUnitId = resolveFloatDomCurrentUnitId(unitId, (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$));
1764
+ return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => shouldRenderFloatDomLayer(layer[1], currentUnitId))) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1620
1765
  var _layer$1$domId;
1621
1766
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingle, {
1622
1767
  id: (_layer$1$domId = layer[1].domId) !== null && _layer$1$domId !== void 0 ? _layer$1$domId : layer[0],
@@ -1624,6 +1769,27 @@ const FloatDom = ({ unitId }) => {
1624
1769
  }, layer[0]);
1625
1770
  });
1626
1771
  };
1772
+ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
1773
+ if (typeof unitId === "string") return unitId;
1774
+ if (typeof focusedUnit === "string") return focusedUnit;
1775
+ if (focusedUnit != null && typeof focusedUnit === "object" && "getUnitId" in focusedUnit && typeof focusedUnit.getUnitId === "function") {
1776
+ const focusedUnitId = focusedUnit.getUnitId();
1777
+ return typeof focusedUnitId === "string" ? focusedUnitId : null;
1778
+ }
1779
+ return null;
1780
+ }
1781
+ function resolveFloatDomOverflow(props) {
1782
+ var _viewport$bleedWidth;
1783
+ const viewport = props.customBlockRenderViewport;
1784
+ if (!(Number.isFinite(viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) && ((_viewport$bleedWidth = viewport === null || viewport === void 0 ? void 0 : viewport.bleedWidth) !== null && _viewport$bleedWidth !== void 0 ? _viewport$bleedWidth : 0) > 0)) return {
1785
+ outerOverflow: "hidden",
1786
+ innerOverflow: "hidden"
1787
+ };
1788
+ return {
1789
+ outerOverflow: "visible",
1790
+ innerOverflow: "visible"
1791
+ };
1792
+ }
1627
1793
 
1628
1794
  //#endregion
1629
1795
  //#region src/services/popup/canvas-popup.service.ts
@@ -1930,13 +2096,41 @@ function CanvasPopup() {
1930
2096
  return (0, _wendellhu_redi_react_bindings.useObservable)(popupService.popups$, void 0, true).map((item) => {
1931
2097
  const [key, popup] = item;
1932
2098
  const Component = componentManager.get(popup.componentKey);
2099
+ const PopupComponent = Component && popup.connectorInjector ? (0, _wendellhu_redi_react_bindings.connectInjector)(Component, popup.connectorInjector) : Component;
1933
2100
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SingleCanvasPopup, {
1934
2101
  popup,
1935
- children: Component ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { popup }) : null
2102
+ children: PopupComponent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopupComponent, { popup })
1936
2103
  }, key);
1937
2104
  });
1938
2105
  }
1939
2106
 
2107
+ //#endregion
2108
+ //#region src/services/ribbon/ribbon-override.service.ts
2109
+ const IRibbonOverrideService = (0, _univerjs_core.createIdentifier)("univer.ribbon-override-service");
2110
+ var RibbonOverrideService = class extends _univerjs_core.Disposable {
2111
+ constructor(..._args) {
2112
+ super(..._args);
2113
+ _defineProperty(this, "_override$", new rxjs.BehaviorSubject(null));
2114
+ _defineProperty(this, "override$", this._override$.asObservable());
2115
+ }
2116
+ getOverride() {
2117
+ return this._override$.getValue();
2118
+ }
2119
+ activate(override) {
2120
+ this._override$.next(override);
2121
+ }
2122
+ clear(id) {
2123
+ const current = this.getOverride();
2124
+ if (!current) return;
2125
+ if (!id || current.id === id) this._override$.next(null);
2126
+ }
2127
+ dispose() {
2128
+ this._override$.next(null);
2129
+ this._override$.complete();
2130
+ super.dispose();
2131
+ }
2132
+ };
2133
+
1940
2134
  //#endregion
1941
2135
  //#region src/services/ribbon/ribbon.service.ts
1942
2136
  const IRibbonService = (0, _univerjs_core.createIdentifier)("univer.ribbon-service");
@@ -2419,39 +2613,52 @@ const TooltipWrapperContext = (0, react.createContext)({
2419
2613
  dropdownVisible: false,
2420
2614
  setDropdownVisible: (_visible) => {}
2421
2615
  });
2616
+ const ToolbarDropdownContext = (0, react.createContext)(null);
2617
+ function ToolbarDropdownProvider(props) {
2618
+ const [openDropdownKey, setOpenDropdownKey] = (0, react.useState)(null);
2619
+ const contextValue = (0, react.useMemo)(() => ({
2620
+ openDropdownKey,
2621
+ setOpenDropdownKey
2622
+ }), [openDropdownKey]);
2623
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownContext.Provider, {
2624
+ value: contextValue,
2625
+ children: props.children
2626
+ });
2627
+ }
2422
2628
  const TooltipWrapper = (0, react.forwardRef)((props, ref) => {
2423
- const { children, ...tooltipProps } = props;
2629
+ const { children, dropdownKey, ...tooltipProps } = props;
2424
2630
  const spanRef = (0, react.useRef)(null);
2425
2631
  const [tooltipVisible, setTooltipVisible] = (0, react.useState)(false);
2426
- const [dropdownVisible, setDropdownVisible] = (0, react.useState)(false);
2632
+ const [localDropdownVisible, setLocalDropdownVisible] = (0, react.useState)(false);
2633
+ const toolbarDropdownContext = (0, react.useContext)(ToolbarDropdownContext);
2634
+ const dropdownVisible = dropdownKey && toolbarDropdownContext ? toolbarDropdownContext.openDropdownKey === dropdownKey : localDropdownVisible;
2427
2635
  function handleChangeTooltipVisible(visible) {
2428
2636
  if (dropdownVisible) setTooltipVisible(false);
2429
2637
  else setTooltipVisible(visible);
2430
2638
  }
2431
- function handleChangeDropdownVisible(visible) {
2432
- setDropdownVisible(visible);
2639
+ const handleChangeDropdownVisible = (0, react.useCallback)((visible) => {
2640
+ if (dropdownKey && toolbarDropdownContext) toolbarDropdownContext.setOpenDropdownKey(visible ? dropdownKey : null);
2641
+ else setLocalDropdownVisible(visible);
2433
2642
  setTooltipVisible(false);
2434
- }
2643
+ }, [dropdownKey, toolbarDropdownContext]);
2435
2644
  const contextValue = (0, react.useMemo)(() => ({
2436
2645
  dropdownVisible,
2437
2646
  setDropdownVisible: handleChangeDropdownVisible
2438
- }), [dropdownVisible]);
2647
+ }), [dropdownVisible, handleChangeDropdownVisible]);
2439
2648
  (0, react.useImperativeHandle)(ref, () => ({ el: spanRef.current }));
2649
+ const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2650
+ ref: spanRef,
2651
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipWrapperContext.Provider, {
2652
+ value: contextValue,
2653
+ children
2654
+ })
2655
+ });
2440
2656
  return tooltipProps.title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
2441
2657
  visible: tooltipVisible,
2442
2658
  onVisibleChange: handleChangeTooltipVisible,
2443
2659
  ...tooltipProps,
2444
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2445
- ref: spanRef,
2446
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipWrapperContext.Provider, {
2447
- value: contextValue,
2448
- children
2449
- })
2450
- })
2451
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2452
- ref: spanRef,
2453
- children
2454
- });
2660
+ children: content
2661
+ }) : content;
2455
2662
  });
2456
2663
  function DropdownWrapper(props) {
2457
2664
  const { children, overlay, disabled, align = "start" } = props;
@@ -2504,6 +2711,10 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
2504
2711
  })]
2505
2712
  });
2506
2713
  }
2714
+ function getOptionKey(option) {
2715
+ var _ref, _ref2, _option$id, _option$label2;
2716
+ return String((_ref = (_ref2 = (_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : option.commandId) !== null && _ref2 !== void 0 ? _ref2 : option.value) !== null && _ref !== void 0 ? _ref : typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name);
2717
+ }
2507
2718
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
2508
2719
  const { dropdownVisible, setDropdownVisible } = (0, react.useContext)(TooltipWrapperContext);
2509
2720
  const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
@@ -2532,6 +2743,9 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2532
2743
  function handleVisibleChange(visible) {
2533
2744
  setDropdownVisible(visible);
2534
2745
  }
2746
+ function handleEmbedBoundaryFocusOutside(event) {
2747
+ keepInteractionInsideSameEmbedBoundary(event);
2748
+ }
2535
2749
  function handleOptionSelect(option) {
2536
2750
  onOptionSelect(option);
2537
2751
  setDropdownVisible(false);
@@ -2571,19 +2785,19 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2571
2785
  }, [menuItems]);
2572
2786
  if (slot) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownWrapper, {
2573
2787
  disabled,
2574
- overlay: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
2788
+ overlay: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
2575
2789
  value,
2576
2790
  option,
2577
2791
  onOptionSelect: handleOptionSelect
2578
- }, index)),
2792
+ }, getOptionKey(option))),
2579
2793
  children
2580
2794
  });
2581
2795
  if (options === null || options === void 0 ? void 0 : options.length) {
2582
2796
  const items = options.map((option) => {
2583
- var _option$label2;
2797
+ var _option$label3;
2584
2798
  return {
2585
2799
  type: "item",
2586
- className: (0, _univerjs_design.clsx)({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.hoverable) === false }),
2800
+ className: (0, _univerjs_design.clsx)({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false }),
2587
2801
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuLabel, {
2588
2802
  icon: option.icon,
2589
2803
  value,
@@ -2626,6 +2840,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2626
2840
  disabled,
2627
2841
  open: dropdownVisible,
2628
2842
  onOpenChange: handleVisibleChange,
2843
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2844
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2629
2845
  children
2630
2846
  });
2631
2847
  } else {
@@ -2660,6 +2876,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2660
2876
  disabled,
2661
2877
  open: dropdownVisible,
2662
2878
  onOpenChange: handleVisibleChange,
2879
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2880
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2663
2881
  children
2664
2882
  });
2665
2883
  }
@@ -2668,14 +2886,14 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2668
2886
  //#endregion
2669
2887
  //#region src/views/components/ribbon/ToolbarItem.tsx
2670
2888
  const toolbarDisabledClassName = "univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600";
2671
- const toolbarButtonSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", {
2889
+ const toolbarButtonSelectorRootVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 rtl:univer-pl-5 rtl:univer-pr-0 dark:hover:!univer-bg-gray-700", {
2672
2890
  variants: { disabled: {
2673
2891
  true: toolbarDisabledClassName,
2674
2892
  false: "univer-text-gray-900 dark:!univer-text-white"
2675
2893
  } },
2676
2894
  defaultVariants: { disabled: false }
2677
2895
  });
2678
- const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", {
2896
+ const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 rtl:univer-rounded-l-none rtl:univer-rounded-r dark:hover:!univer-bg-gray-600", {
2679
2897
  variants: {
2680
2898
  active: {
2681
2899
  true: "univer-bg-gray-200 dark:!univer-bg-gray-500",
@@ -2696,7 +2914,7 @@ const toolbarButtonSelectorMainVariants = (0, _univerjs_design.cva)("univer-tool
2696
2914
  disabled: false
2697
2915
  }
2698
2916
  });
2699
- const toolbarButtonSelectorTriggerVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600", {
2917
+ const toolbarButtonSelectorTriggerVariants = (0, _univerjs_design.cva)("univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 rtl:univer-left-0 rtl:univer-right-auto rtl:univer-rounded-l rtl:univer-rounded-r-none dark:hover:!univer-bg-gray-600", {
2700
2918
  variants: {
2701
2919
  disabled: {
2702
2920
  true: toolbarDisabledClassName,
@@ -2896,6 +3114,7 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
2896
3114
  ref,
2897
3115
  title: tooltipTitle,
2898
3116
  placement: "bottom",
3117
+ dropdownKey: id,
2899
3118
  children: renderItem()
2900
3119
  });
2901
3120
  });
@@ -2903,15 +3122,20 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
2903
3122
  //#endregion
2904
3123
  //#region src/views/components/ribbon/Ribbon.tsx
2905
3124
  function Ribbon(props) {
2906
- const { ribbonType, headerMenuComponents, headerMenu = true } = props;
2907
- const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
3125
+ var _ribbonOverride$ribbo;
3126
+ const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
3127
+ const defaultRibbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
3128
+ const ribbonOverrideService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonOverrideService);
2908
3129
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3130
+ const ribbonOverride = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
3131
+ const ribbonService = (_ribbonOverride$ribbo = ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) !== null && _ribbonOverride$ribbo !== void 0 ? _ribbonOverride$ribbo : defaultRibbonService;
2909
3132
  const containerRef = (0, react.useRef)(null);
2910
3133
  const toolbarItemRefs = (0, react.useRef)({});
2911
3134
  const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
2912
3135
  const activatedTab = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.activatedTab$, "ribbon.start");
2913
3136
  const collapsedIds = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.collapsedIds$, []);
2914
3137
  const fakeToolbarVisible = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.fakeToolbarVisible$, false);
3138
+ const hideToolbar = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.hideToolbar) === true;
2915
3139
  const ribbon = (0, react.useMemo)(() => {
2916
3140
  if (ribbonType === "simple") {
2917
3141
  const simpleRibbon = [{
@@ -2937,7 +3161,7 @@ function Ribbon(props) {
2937
3161
  const handleSelectTab = (0, react.useCallback)((group) => {
2938
3162
  toolbarItemRefs.current = {};
2939
3163
  ribbonService.setActivatedTab(group.key);
2940
- }, []);
3164
+ }, [ribbonService]);
2941
3165
  const activeGroup = (0, react.useMemo)(() => {
2942
3166
  var _ribbon$find$children, _ribbon$find2;
2943
3167
  const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
@@ -2965,6 +3189,13 @@ function Ribbon(props) {
2965
3189
  activatedTab
2966
3190
  ]);
2967
3191
  (0, react.useEffect)(() => {
3192
+ if (hideToolbar) {
3193
+ toolbarItemRefs.current = {};
3194
+ ribbonService.setCollapsedIds([]);
3195
+ ribbonService.setFakeToolbarVisible(false);
3196
+ return;
3197
+ }
3198
+ if (!containerRef.current) return;
2968
3199
  let timer = null;
2969
3200
  const observer = new ResizeObserver((0, _univerjs_core.throttle)((entries) => {
2970
3201
  for (const entry of entries) {
@@ -2994,7 +3225,12 @@ function Ribbon(props) {
2994
3225
  timer && cancelAnimationFrame(timer);
2995
3226
  observer.disconnect();
2996
3227
  };
2997
- }, [ribbon, activatedTab]);
3228
+ }, [
3229
+ hideToolbar,
3230
+ ribbon,
3231
+ activatedTab,
3232
+ ribbonService
3233
+ ]);
2998
3234
  const fakeToolbar = (0, react.useMemo)(() => {
2999
3235
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3000
3236
  "aria-hidden": "true",
@@ -3019,75 +3255,117 @@ function Ribbon(props) {
3019
3255
  })
3020
3256
  });
3021
3257
  }, [activeGroup.allGroups, fakeToolbarVisible]);
3022
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3023
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3024
- "data-u-comp": "ribbon-header-menu",
3025
- className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
3026
- children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClassicMenu, {
3027
- ribbon,
3028
- activatedTab,
3029
- onSelectTab: handleSelectTab
3030
- }), headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3031
- className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3032
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
3033
- })]
3034
- }),
3035
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3036
- className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3037
- "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3038
- "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3039
- }, _univerjs_design.borderBottomClassName),
3040
- children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultMenu, {
3041
- ribbon,
3042
- activatedTab,
3043
- onSelectTab: handleSelectTab
3044
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3045
- "data-u-comp": "ribbon-toolbar",
3046
- ref: containerRef,
3047
- className: (0, _univerjs_design.clsx)("univer-flex univer-overflow-hidden", _univerjs_design.divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3048
- role: "toolbar",
3049
- "aria-label": localeService.t(activatedTabTitle),
3050
- children: [activeGroup.visibleGroups.map((groupItem) => {
3051
- var _groupItem$children3, _groupItem$children4;
3052
- return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3053
- className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3054
- children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item }, child.key)))
3055
- }) }, groupItem.key);
3056
- }), collapsedIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3057
- "data-u-comp": "ribbon-toolbar-more",
3058
- className: "univer-pl-2 rtl:univer-pr-2",
3059
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
3060
- collisionPadding: {
3061
- right: 12,
3062
- left: 12
3063
- },
3064
- onOpenAutoFocus: (e) => e.preventDefault(),
3065
- overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3066
- className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3067
- children: activeGroup.hiddenGroups.map((groupItem) => {
3068
- var _groupItem$children5;
3069
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3070
- className: "univer-flex univer-items-center univer-gap-2",
3071
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3072
- className: "univer-flex univer-flex-wrap univer-gap-2",
3073
- children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...groupItem.item }, groupItem.key)
3074
- })
3075
- }, groupItem.key);
3076
- })
3077
- }),
3078
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3079
- type: "button",
3080
- className: toolbarButtonClassName,
3081
- "aria-label": localeService.t("ui.ribbon.more"),
3082
- "aria-haspopup": "true",
3083
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreVerticalIcon, {})
3258
+ const embedRibbonOverrideAttributes = ribbonOverride ? {
3259
+ "data-embed-ribbon-override": "true",
3260
+ "data-embed-id": ribbonOverride.id
3261
+ } : {};
3262
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RibbonOverrideRuntimeProvider, {
3263
+ override: ribbonOverride,
3264
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3265
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3266
+ "data-u-comp": "ribbon-header-menu",
3267
+ ...embedRibbonOverrideAttributes,
3268
+ className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", headerClassName, {
3269
+ "univer-hidden": toolbarOnly,
3270
+ "univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
3271
+ }),
3272
+ children: [
3273
+ !toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3274
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-9 univer-items-end univer-px-3", { "univer-justify-center": hideToolbar }),
3275
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3276
+ className: "univer-relative univer-inline-flex univer-h-8 univer-items-center univer-justify-center univer-rounded-t univer-bg-primary-50 univer-px-3 univer-text-sm univer-font-medium univer-text-primary-600",
3277
+ children: ribbonOverride.placeholderTitle
3084
3278
  })
3279
+ }),
3280
+ !toolbarOnly && ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClassicMenu, {
3281
+ ribbon,
3282
+ activatedTab,
3283
+ onSelectTab: handleSelectTab
3284
+ }),
3285
+ headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3286
+ className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row univer-items-center univer-gap-2 rtl:univer-left-2 rtl:univer-right-auto [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3287
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
3085
3288
  })
3289
+ ]
3290
+ }),
3291
+ !hideToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3292
+ ...embedRibbonOverrideAttributes,
3293
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3294
+ "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3295
+ "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3296
+ }, _univerjs_design.borderBottomClassName),
3297
+ children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultMenu, {
3298
+ ribbon,
3299
+ activatedTab,
3300
+ onSelectTab: handleSelectTab
3301
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3302
+ "data-u-comp": "ribbon-toolbar",
3303
+ ref: containerRef,
3304
+ className: (0, _univerjs_design.clsx)("univer-flex univer-overflow-hidden", _univerjs_design.divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3305
+ role: "toolbar",
3306
+ "aria-label": localeService.t(activatedTabTitle),
3307
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarDropdownProvider, { children: [activeGroup.visibleGroups.map((groupItem) => {
3308
+ var _groupItem$children3, _groupItem$children4;
3309
+ return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3310
+ className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3311
+ children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item }, child.key)))
3312
+ }) }, groupItem.key);
3313
+ }), collapsedIds.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3314
+ className: "univer-pl-2 rtl:univer-pr-2",
3315
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
3316
+ collisionPadding: {
3317
+ right: 12,
3318
+ left: 12
3319
+ },
3320
+ onOpenAutoFocus: (e) => e.preventDefault(),
3321
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3322
+ className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3323
+ children: activeGroup.hiddenGroups.map((groupItem) => {
3324
+ var _groupItem$children5;
3325
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3326
+ className: "univer-flex univer-items-center univer-gap-2",
3327
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3328
+ className: "univer-flex univer-flex-wrap univer-gap-2",
3329
+ children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...groupItem.item }, groupItem.key)
3330
+ })
3331
+ }, groupItem.key);
3332
+ })
3333
+ }),
3334
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3335
+ type: "button",
3336
+ className: toolbarButtonClassName,
3337
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreVerticalIcon, {})
3338
+ })
3339
+ })
3340
+ })] }, activatedTab)
3086
3341
  })]
3087
- })]
3088
- }),
3089
- fakeToolbar
3090
- ] });
3342
+ }),
3343
+ fakeToolbar
3344
+ ] })
3345
+ });
3346
+ }
3347
+ function RibbonOverrideRuntimeProvider(props) {
3348
+ var _override$portalConta;
3349
+ const { override, children } = props;
3350
+ const config = (0, react.useContext)(_univerjs_design.ConfigContext);
3351
+ const injector = override === null || override === void 0 ? void 0 : override.injector;
3352
+ const ConnectedRibbonOverrideConfigProvider = (0, react.useMemo)(() => injector ? (0, _wendellhu_redi_react_bindings.connectInjector)(RibbonOverrideConfigProvider, injector) : null, [injector]);
3353
+ if (!override || !ConnectedRibbonOverrideConfigProvider) return children;
3354
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConnectedRibbonOverrideConfigProvider, {
3355
+ locale: config.locale,
3356
+ direction: config.direction,
3357
+ mountContainer: (_override$portalConta = override.portalContainer) !== null && _override$portalConta !== void 0 ? _override$portalConta : config.mountContainer,
3358
+ children
3359
+ });
3360
+ }
3361
+ function RibbonOverrideConfigProvider(props) {
3362
+ const { children, locale, direction, mountContainer } = props;
3363
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.ConfigProvider, {
3364
+ locale,
3365
+ direction,
3366
+ mountContainer,
3367
+ children
3368
+ });
3091
3369
  }
3092
3370
 
3093
3371
  //#endregion
@@ -3143,11 +3421,11 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
3143
3421
  enable() {
3144
3422
  this.disabled = false;
3145
3423
  }
3146
- triggerContextMenu(event, menuType) {
3424
+ triggerContextMenu(event, menuType, context) {
3147
3425
  var _this$_currentHandler3;
3148
3426
  event.stopPropagation();
3149
3427
  if (this.disabled) return;
3150
- (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType);
3428
+ (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType, context);
3151
3429
  }
3152
3430
  hideContextMenu() {
3153
3431
  var _this$_currentHandler4;
@@ -3160,6 +3438,25 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
3160
3438
  }
3161
3439
  };
3162
3440
 
3441
+ //#endregion
3442
+ //#region src/services/runtime-scope/ui-runtime-scope.service.ts
3443
+ const IUIRuntimeScopeService = (0, _univerjs_core.createIdentifier)("ui.runtime-scope.service");
3444
+ var UIRuntimeScopeService = class extends _univerjs_core.Disposable {
3445
+ constructor(..._args) {
3446
+ super(..._args);
3447
+ _defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
3448
+ }
3449
+ register(scope) {
3450
+ this._scopes.set(scope.unitId, scope);
3451
+ return (0, _univerjs_core.toDisposable)(() => {
3452
+ if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
3453
+ });
3454
+ }
3455
+ get(unitId) {
3456
+ return unitId ? this._scopes.get(unitId) : void 0;
3457
+ }
3458
+ };
3459
+
3163
3460
  //#endregion
3164
3461
  //#region src/services/contextmenu/contextmenu-host.service.ts
3165
3462
  const IContextMenuHostService = (0, _univerjs_core.createIdentifier)("ui.contextmenu.host.service");
@@ -3864,9 +4161,11 @@ function getContextMenuSubmenuPanelClassName(sizeVariant) {
3864
4161
  }
3865
4162
  function ContextMenuPanel(props) {
3866
4163
  var _layoutService$rootCo, _layoutService$rootCo2;
3867
- const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
3868
- const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
3869
- const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
4164
+ const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4165
+ const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
4166
+ const rootLayoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
4167
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
4168
+ const layoutService = providedLayoutService !== null && providedLayoutService !== void 0 ? providedLayoutService : rootLayoutService;
3870
4169
  const [menuElement, setMenuElement] = (0, react.useState)(null);
3871
4170
  const [maxMenuHeight, setMaxMenuHeight] = (0, react.useState)(() => {
3872
4171
  if (typeof window === "undefined") return 240;
@@ -3969,6 +4268,7 @@ function ContextMenuPanel(props) {
3969
4268
  onWheel: (event) => event.stopPropagation(),
3970
4269
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenu, {
3971
4270
  menuSchemas: menuItems,
4271
+ menuManagerService,
3972
4272
  menuSessionVersion,
3973
4273
  submenuPortalContainer,
3974
4274
  rootMenuElement: menuElement,
@@ -3984,7 +4284,7 @@ function ContextMenuPanel(props) {
3984
4284
  });
3985
4285
  }
3986
4286
  function ContextMenuMenu(props) {
3987
- const { menuSchemas, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
4287
+ const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
3988
4288
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3989
4289
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
3990
4290
  const [activeSubmenuKey, setActiveSubmenuKey] = (0, react.useState)(null);
@@ -4030,6 +4330,7 @@ function ContextMenuMenu(props) {
4030
4330
  if (menuSchema.item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
4031
4331
  menuKey: menuSchema.key,
4032
4332
  menuItem: menuSchema.item,
4333
+ menuManagerService,
4033
4334
  menuSessionVersion,
4034
4335
  submenuPortalContainer,
4035
4336
  rootMenuElement,
@@ -4050,6 +4351,7 @@ function ContextMenuMenu(props) {
4050
4351
  children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
4051
4352
  menuKey: childSchema.key,
4052
4353
  menuItem: childSchema.item,
4354
+ menuManagerService,
4053
4355
  menuSessionVersion,
4054
4356
  submenuPortalContainer,
4055
4357
  rootMenuElement,
@@ -4071,6 +4373,7 @@ function ContextMenuMenu(props) {
4071
4373
  children: [titleNode, menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
4072
4374
  menuKey: childSchema.key,
4073
4375
  menuItem: childSchema.item,
4376
+ menuManagerService,
4074
4377
  menuSessionVersion,
4075
4378
  submenuPortalContainer,
4076
4379
  rootMenuElement,
@@ -4099,6 +4402,7 @@ function ContextMenuMenu(props) {
4099
4402
  children: [titleContent, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenuItem, {
4100
4403
  menuKey: `${menuSchema.key}-header-action`,
4101
4404
  menuItem: menuSchema.headerActionItem,
4405
+ menuManagerService,
4102
4406
  menuSessionVersion,
4103
4407
  submenuPortalContainer,
4104
4408
  rootMenuElement,
@@ -4119,10 +4423,9 @@ function ContextMenuMenu(props) {
4119
4423
  }
4120
4424
  }
4121
4425
  function ContextMenuMenuItem(props) {
4122
- const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4426
+ const { menuKey, menuItem, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4123
4427
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
4124
4428
  const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
4125
- const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
4126
4429
  const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.disabled$, false);
4127
4430
  const activated = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.activated$, false);
4128
4431
  const hidden = (0, _wendellhu_redi_react_bindings.useObservable)(menuItem.hidden$, false);
@@ -4199,7 +4502,9 @@ function ContextMenuMenuItem(props) {
4199
4502
  const submenuRect = submenuElement.getBoundingClientRect();
4200
4503
  const rightLeft = menuItemRect.right - submenuOverlapOffset;
4201
4504
  const leftLeft = menuItemRect.left - submenuRect.width + submenuOverlapOffset;
4202
- const useLeft = rightLeft + submenuRect.width + menuViewportPadding > window.innerWidth && leftLeft >= menuViewportPadding;
4505
+ const hasLeftSpace = leftLeft >= menuViewportPadding;
4506
+ const hasRightSpace = rightLeft + submenuRect.width + menuViewportPadding <= window.innerWidth;
4507
+ const useLeft = direction === "rtl" ? hasLeftSpace || !hasRightSpace : !hasRightSpace && hasLeftSpace;
4203
4508
  const left = useLeft ? leftLeft : rightLeft;
4204
4509
  setSubmenuPlacement(useLeft ? "left" : "right");
4205
4510
  const maxTop = window.innerHeight - menuViewportPadding - submenuRect.height;
@@ -4218,6 +4523,7 @@ function ContextMenuMenuItem(props) {
4218
4523
  window.removeEventListener("scroll", updateSubmenuPosition, true);
4219
4524
  };
4220
4525
  }, [
4526
+ direction,
4221
4527
  submenuVisible,
4222
4528
  hasSelectionSubmenu,
4223
4529
  hasSubItemSubmenu
@@ -4251,6 +4557,7 @@ function ContextMenuMenuItem(props) {
4251
4557
  });
4252
4558
  const canExecuteItem = menuItem.type === 0 || menuItem.type === 2;
4253
4559
  const renderAsContainer = isNonSelectableLabel(menuItem.label);
4560
+ const SubmenuAffordanceIcon = direction === "rtl" ? _univerjs_icons.MoreLeftIcon : _univerjs_icons.MoreRightIcon;
4254
4561
  const interactiveItemClassName = (0, _univerjs_design.clsx)(itemClassName, isNonHoverableLabel(menuItem.label) && "hover:univer-bg-transparent dark:hover:!univer-bg-transparent");
4255
4562
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4256
4563
  ref: menuItemElementRef,
@@ -4279,7 +4586,7 @@ function ContextMenuMenuItem(props) {
4279
4586
  children: [renderAsContainer ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4280
4587
  className: interactiveItemClassName,
4281
4588
  "aria-disabled": disabled,
4282
- children: [contentNode, hasSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: `
4589
+ children: [contentNode, hasSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubmenuAffordanceIcon, { className: `
4283
4590
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4284
4591
  univer-text-gray-400
4285
4592
  dark:!univer-text-gray-200
@@ -4322,7 +4629,7 @@ function ContextMenuMenuItem(props) {
4322
4629
  label: menuKey
4323
4630
  });
4324
4631
  },
4325
- children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: `
4632
+ children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubmenuAffordanceIcon, { className: `
4326
4633
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4327
4634
  univer-text-gray-400
4328
4635
  dark:!univer-text-gray-200
@@ -4369,7 +4676,7 @@ function ContextMenuMenuItem(props) {
4369
4676
  const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
4370
4677
  const optionSelectable = !isNonSelectableLabel(option.label);
4371
4678
  const optionHoverable = !isNonHoverableLabel(option.label);
4372
- const optionClassName = (0, _univerjs_design.clsx)(sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base dark:!univer-text-white" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
4679
+ const optionClassName = (0, _univerjs_design.clsx)(optionSelectable ? sizeVariant === "paragraph-t" ? "univer-relative univer-box-border univer-flex univer-min-h-10 univer-w-full univer-items-center univer-rounded-lg univer-border-none univer-bg-transparent univer-px-3 univer-text-left univer-text-base dark:!univer-text-white" : "univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white" : "univer-relative univer-box-border univer-block univer-w-full univer-border-none univer-bg-transparent univer-p-0", option.disabled ? "univer-cursor-not-allowed univer-opacity-60" : optionHoverable && "univer-cursor-pointer hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-600");
4373
4680
  const optionContentNode = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [optionSelectable && optionSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: (0, _univerjs_design.clsx)("univer-absolute univer-left-0 univer-text-primary-600", sizeVariant === "paragraph-t" ? "univer-size-5" : "univer-size-4") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4374
4681
  className: (0, _univerjs_design.clsx)(getContextMenuContentClassName(sizeVariant), optionSelectable && optionSelected && "univer-pl-4"),
4375
4682
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomLabel, {
@@ -4411,6 +4718,7 @@ function ContextMenuMenuItem(props) {
4411
4718
  })
4412
4719
  }), hasSubItemSubmenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuMenu, {
4413
4720
  menuSchemas: subMenuItems,
4721
+ menuManagerService,
4414
4722
  menuSessionVersion,
4415
4723
  submenuPortalContainer,
4416
4724
  rootMenuElement,
@@ -4455,7 +4763,7 @@ function useContextGroupHiddenStates$1(menuSchemas) {
4455
4763
  //#endregion
4456
4764
  //#region src/views/components/context-menu/AnchoredContextMenu.tsx
4457
4765
  function AnchoredContextMenu(props) {
4458
- const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, onRequestClose, onOptionSelect } = props;
4766
+ const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, menuManagerService, layoutService, onRequestClose, onOptionSelect } = props;
4459
4767
  const contentRef = (0, react.useRef)(null);
4460
4768
  const contextMenuHostService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuHostService);
4461
4769
  const onRequestCloseRef = (0, react.useRef)(onRequestClose);
@@ -4544,6 +4852,8 @@ function AnchoredContextMenu(props) {
4544
4852
  ref: contentRef,
4545
4853
  children: menuType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuPanel, {
4546
4854
  menuType,
4855
+ menuManagerService,
4856
+ layoutService,
4547
4857
  menuSessionVersion: menuSessionVersionRef.current,
4548
4858
  onOptionSelect
4549
4859
  })
@@ -4558,10 +4868,13 @@ function DesktopContextMenu() {
4558
4868
  const [visible, setVisible] = (0, react.useState)(false);
4559
4869
  const [menuType, setMenuType] = (0, react.useState)("");
4560
4870
  const [anchorRect, setAnchorRect] = (0, react.useState)(null);
4871
+ const [menuContext, setMenuContext] = (0, react.useState)();
4561
4872
  const visibleRef = (0, react.useRef)(visible);
4562
4873
  const contextMenuService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuService);
4563
4874
  const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
4564
- const injector = (0, _wendellhu_redi_react_bindings.useInjector)();
4875
+ const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
4876
+ const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
4877
+ const runtimeScopeService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIRuntimeScopeService);
4565
4878
  visibleRef.current = visible;
4566
4879
  (0, react.useEffect)(() => {
4567
4880
  const disposables = contextMenuService.registerContextMenuHandler({
@@ -4578,10 +4891,11 @@ function DesktopContextMenu() {
4578
4891
  };
4579
4892
  }, [contextMenuService]);
4580
4893
  /** A function to open context menu with given position and menu type. */
4581
- function handleContextMenu(event, menuType) {
4894
+ function handleContextMenu(event, menuType, context) {
4582
4895
  setVisible(false);
4583
4896
  requestAnimationFrame(() => {
4584
4897
  setMenuType(menuType);
4898
+ setMenuContext(context);
4585
4899
  setAnchorRect({
4586
4900
  left: event.clientX,
4587
4901
  top: event.clientY,
@@ -4593,18 +4907,24 @@ function DesktopContextMenu() {
4593
4907
  function handleClose() {
4594
4908
  setVisible(false);
4595
4909
  }
4910
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
4911
+ const activeMenuManagerService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService;
4912
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(_univerjs_core.ICommandService)) ? activeScope.get(_univerjs_core.ICommandService) : commandService;
4913
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
4596
4914
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnchoredContextMenu, {
4597
4915
  hostId: DESKTOP_CONTEXT_MENU_HOST_ID,
4598
4916
  visible,
4599
4917
  anchorRect,
4600
4918
  menuType,
4919
+ menuManagerService: activeMenuManagerService,
4920
+ layoutService: activeLayoutService,
4601
4921
  onRequestClose: handleClose,
4602
4922
  onOptionSelect: (params) => {
4603
4923
  const { label: id, commandId, value } = params;
4604
4924
  const rawParams = typeof params.params === "function" ? params.params() : params.params;
4605
4925
  const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
4606
- if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4607
- injector.get(ILayoutService).focus();
4926
+ if (activeCommandService) activeCommandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4927
+ activeLayoutService.focus();
4608
4928
  handleClose();
4609
4929
  }
4610
4930
  });
@@ -5180,7 +5500,9 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
5180
5500
  }));
5181
5501
  }
5182
5502
  _changeRenderUnit(rendererId, contentElement) {
5503
+ var _this$_instanceServic2;
5183
5504
  if (this._currentRenderId === rendererId) return false;
5505
+ if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
5184
5506
  const renderer = this._renderManagerService.getRenderById(rendererId);
5185
5507
  if (!renderer || !renderer.unitId || (0, _univerjs_core.isInternalEditorID)(renderer.unitId)) return false;
5186
5508
  const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderById(this._currentRenderId) : null;
@@ -5258,7 +5580,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
5258
5580
  //#endregion
5259
5581
  //#region package.json
5260
5582
  var name = "@univerjs/ui";
5261
- var version = "1.0.0-alpha.1";
5583
+ var version = "1.0.0-alpha.3";
5262
5584
 
5263
5585
  //#endregion
5264
5586
  //#region src/views/color-picker/interface.ts
@@ -20288,15 +20610,13 @@ function EmojiPicker(props) {
20288
20610
  children: [
20289
20611
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
20290
20612
  className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
20291
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
20292
- className: "univer-flex univer-h-8 univer-flex-1 univer-items-center univer-gap-1 univer-rounded-lg univer-border univer-border-solid univer-border-primary-500 univer-px-2 univer-text-gray-500 dark:!univer-border-primary-600 dark:!univer-text-gray-400",
20293
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SearchIcon, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
20294
- "aria-label": localeService.t("ui.emojiPicker.search"),
20295
- placeholder: localeService.t("ui.emojiPicker.search"),
20296
- className: "univer-min-w-0 univer-flex-1",
20297
- value: query,
20298
- onChange: setQuery
20299
- })]
20613
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
20614
+ "aria-label": localeService.t("ui.emojiPicker.search"),
20615
+ placeholder: localeService.t("ui.emojiPicker.search"),
20616
+ className: "univer-min-w-0 univer-flex-1",
20617
+ value: query,
20618
+ onChange: setQuery,
20619
+ slot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SearchIcon, { className: "univer-size-4 univer-text-gray-500 dark:!univer-text-gray-400" })
20300
20620
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
20301
20621
  type: "button",
20302
20622
  "aria-label": localeService.t("ui.emojiPicker.random"),
@@ -20330,12 +20650,12 @@ function EmojiPicker(props) {
20330
20650
  className: (0, _univerjs_design.clsx)("univer-flex univer-h-10 univer-shrink-0 univer-items-center univer-border-gray-200 univer-px-2.5 dark:!univer-border-gray-600 [&_svg]:univer-size-5", _univerjs_design.borderTopClassName),
20331
20651
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
20332
20652
  selected: !isSearching && activeTab === "recent",
20333
- title: localeService.t("ui.emojiPicker.recents"),
20653
+ titleKey: "ui.emojiPicker.recents",
20334
20654
  onClick: () => scrollToSection("recent"),
20335
20655
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RecentIcon, {})
20336
20656
  }), EMOJI_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryButton, {
20337
20657
  selected: !isSearching && activeTab === category.key,
20338
- title: localeService.t(category.titleKey),
20658
+ titleKey: category.titleKey,
20339
20659
  onClick: () => scrollToSection(category.key),
20340
20660
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CategoryIcon, { category: category.key })
20341
20661
  }, category.key))]
@@ -20376,11 +20696,12 @@ function EmojiGrid(props) {
20376
20696
  });
20377
20697
  }
20378
20698
  function CategoryButton(props) {
20699
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
20379
20700
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
20380
20701
  type: "button",
20381
- "aria-label": props.title,
20702
+ "aria-label": localeService.t(props.titleKey),
20382
20703
  "aria-selected": props.selected,
20383
- title: props.title,
20704
+ title: localeService.t(props.titleKey),
20384
20705
  className: (0, _univerjs_design.clsx)("univer-flex univer-h-[30px] univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 dark:!univer-text-gray-400", props.selected ? "univer-bg-primary-50 univer-text-primary-500 dark:!univer-bg-gray-800 dark:!univer-text-primary-400" : "hover:univer-bg-gray-50 hover:univer-text-gray-700 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300"),
20385
20706
  onClick: props.onClick,
20386
20707
  children: props.children
@@ -20558,14 +20879,10 @@ let FontService = class FontService {
20558
20879
  FontService = __decorate([__decorateParam(0, _univerjs_core.IConfigService)], FontService);
20559
20880
 
20560
20881
  //#endregion
20561
- //#region src/views/font-family/FontFamily.tsx
20562
- const FontFamily = ({ id, value, disabled$ }) => {
20563
- const disabled = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
20564
- const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
20565
- const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
20882
+ //#region src/views/font-family/use-font-list.ts
20883
+ function useFontList() {
20566
20884
  const fontService = (0, _wendellhu_redi_react_bindings.useDependency)(IFontService);
20567
- const [inputValue, setInputValue] = (0, react.useState)("");
20568
- const [fonts, setFonts] = (0, react.useState)([]);
20885
+ const [fonts, setFonts] = (0, react.useState)(() => fontService.getFonts());
20569
20886
  (0, react.useEffect)(() => {
20570
20887
  const subscription = fontService.fonts$.subscribe((fonts) => {
20571
20888
  setFonts(fonts);
@@ -20573,7 +20890,22 @@ const FontFamily = ({ id, value, disabled$ }) => {
20573
20890
  return () => {
20574
20891
  subscription.unsubscribe();
20575
20892
  };
20576
- }, []);
20893
+ }, [fontService]);
20894
+ return {
20895
+ fonts,
20896
+ fontService
20897
+ };
20898
+ }
20899
+
20900
+ //#endregion
20901
+ //#region src/views/font-family/FontFamily.tsx
20902
+ const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
20903
+ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onChange }) => {
20904
+ const disabledObservableValue = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
20905
+ const disabled = Boolean(disabledProp || disabledObservableValue);
20906
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
20907
+ const { fonts } = useFontList();
20908
+ const [draftValue, setDraftValue] = (0, react.useState)(null);
20577
20909
  const viewValue = (0, react.useMemo)(() => {
20578
20910
  if (value == null) return "";
20579
20911
  const font = fonts.find((font) => {
@@ -20586,14 +20918,12 @@ const FontFamily = ({ id, value, disabled$ }) => {
20586
20918
  fonts,
20587
20919
  localeService
20588
20920
  ]);
20589
- (0, react.useMemo)(() => {
20590
- setInputValue(viewValue);
20591
- }, [value]);
20921
+ const inputValue = draftValue !== null && draftValue !== void 0 ? draftValue : viewValue;
20592
20922
  function resetValue() {
20593
- setInputValue(viewValue);
20923
+ setDraftValue(null);
20594
20924
  }
20595
20925
  function handleChangeSelection(e) {
20596
- setInputValue(e.target.value);
20926
+ setDraftValue(e.target.value);
20597
20927
  }
20598
20928
  function handleKeyDown(e) {
20599
20929
  e.stopPropagation();
@@ -20605,7 +20935,7 @@ const FontFamily = ({ id, value, disabled$ }) => {
20605
20935
  }
20606
20936
  }
20607
20937
  function handleBlur() {
20608
- if (inputValue !== value) resetValue();
20938
+ if (draftValue !== null && inputValue !== viewValue) resetValue();
20609
20939
  }
20610
20940
  function confirm() {
20611
20941
  const font = fonts.find((item) => {
@@ -20617,11 +20947,12 @@ const FontFamily = ({ id, value, disabled$ }) => {
20617
20947
  }
20618
20948
  handleSelectFont(font.value);
20619
20949
  }
20620
- function handleSelectFont(value) {
20621
- commandService.executeCommand(id, { value });
20950
+ function handleSelectFont(nextValue) {
20951
+ resetValue();
20952
+ onChange(nextValue);
20622
20953
  }
20623
20954
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
20624
- className: "univer-w-32 univer-truncate univer-text-sm",
20955
+ className: (0, _univerjs_design.clsx)("univer-w-32 univer-truncate univer-text-sm", className),
20625
20956
  style: { fontFamily: value },
20626
20957
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
20627
20958
  className: "univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 focus:univer-outline-none dark:!univer-text-white [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm",
@@ -20637,25 +20968,16 @@ const FontFamily = ({ id, value, disabled$ }) => {
20637
20968
 
20638
20969
  //#endregion
20639
20970
  //#region src/views/font-family/FontFamilyItem.tsx
20640
- const FontFamilyItem = ({ id, value }) => {
20641
- const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
20642
- const fontService = (0, _wendellhu_redi_react_bindings.useDependency)(IFontService);
20643
- const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
20644
- const [fonts, setFonts] = (0, react.useState)([]);
20645
- (0, react.useEffect)(() => {
20646
- const subscription = fontService.fonts$.subscribe((fonts) => {
20647
- setFonts(fonts);
20648
- });
20649
- return () => {
20650
- subscription.unsubscribe();
20651
- };
20652
- }, []);
20971
+ const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
20972
+ const FontFamilyItem = ({ value, onChange }) => {
20653
20973
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
20654
- function handleSelectFont(value) {
20655
- layoutService.focus();
20656
- commandService.executeCommand(id, { value });
20974
+ const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
20975
+ const { fonts, fontService } = useFontList();
20976
+ function handleSelectFont(nextValue) {
20977
+ onChange(nextValue);
20657
20978
  }
20658
20979
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
20980
+ dir: direction,
20659
20981
  className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
20660
20982
  style: { fontFamily: value },
20661
20983
  children: fonts.map((font) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
@@ -20672,9 +20994,52 @@ const FontFamilyItem = ({ id, value }) => {
20672
20994
  };
20673
20995
 
20674
20996
  //#endregion
20675
- //#region src/views/font-family/interface.ts
20676
- const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
20677
- const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
20997
+ //#region src/views/font-family/FontFamilyDropdown.tsx
20998
+ function FontFamilyDropdown(props) {
20999
+ const { value, onChange, ariaLabel, className, disabled: disabledProp, disabled$, inputClassName, popupClassName, popupDataComponent, title, onMouseDown, onPointerDown } = props;
21000
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21001
+ const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection());
21002
+ const disabledObservableValue = (0, _wendellhu_redi_react_bindings.useObservable)(disabled$);
21003
+ const disabled = Boolean(disabledProp || disabledObservableValue);
21004
+ const [open, setOpen] = (0, react.useState)(false);
21005
+ const popupDataAttributes = popupDataComponent ? { "data-u-comp": popupDataComponent } : void 0;
21006
+ function handleChange(nextValue) {
21007
+ setOpen(false);
21008
+ onChange(nextValue);
21009
+ }
21010
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
21011
+ disabled,
21012
+ open,
21013
+ onOpenChange: setOpen,
21014
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21015
+ dir: direction,
21016
+ className: (0, _univerjs_design.clsx)("univer-max-h-72 univer-min-w-44 univer-overflow-y-auto univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900", popupClassName),
21017
+ ...popupDataAttributes,
21018
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontFamilyItem, {
21019
+ value,
21020
+ onChange: handleChange
21021
+ })
21022
+ }),
21023
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21024
+ "aria-disabled": disabled,
21025
+ "aria-expanded": open,
21026
+ "aria-label": ariaLabel,
21027
+ dir: direction,
21028
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-min-w-0 univer-cursor-default univer-items-center univer-justify-between univer-gap-1 univer-rounded-md univer-px-1.5 univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-cursor-not-allowed univer-opacity-60": disabled }, className),
21029
+ role: "combobox",
21030
+ tabIndex: disabled ? -1 : 0,
21031
+ title: typeof title === "string" ? title : void 0,
21032
+ onMouseDown,
21033
+ onPointerDown,
21034
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontFamily, {
21035
+ className: (0, _univerjs_design.clsx)("univer-min-w-0 univer-flex-1", inputClassName),
21036
+ value,
21037
+ disabled,
21038
+ onChange: handleChange
21039
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-flex-shrink-0 univer-text-xs univer-text-gray-500" })]
21040
+ })
21041
+ });
21042
+ }
20678
21043
 
20679
21044
  //#endregion
20680
21045
  //#region src/views/font-size/FontSize.tsx
@@ -20834,7 +21199,9 @@ const DRAG_COMMIT_INTERVAL = 50;
20834
21199
  function Slider(props) {
20835
21200
  var _getSliderOffset;
20836
21201
  const iconManager = (0, _wendellhu_redi_react_bindings.useDependency)(IconManager);
21202
+ const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
20837
21203
  const { value, min = 0, max = 400, disabled = false, resetPoint = 100, shortcuts, onChange } = props;
21204
+ const isRtl = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$, localeService.getDirection()) === "rtl";
20838
21205
  const sliderInnerRailRef = (0, react.useRef)(null);
20839
21206
  const isEditingZoomRef = (0, react.useRef)(false);
20840
21207
  const dragValueRef = (0, react.useRef)(value);
@@ -20878,6 +21245,7 @@ function Slider(props) {
20878
21245
  let offsetX = clientX - railRect.x;
20879
21246
  if (offsetX <= 0) offsetX = 0;
20880
21247
  else if (offsetX >= railWidth) offsetX = railWidth;
21248
+ if (isRtl) offsetX = railWidth - offsetX;
20881
21249
  const ratio = offsetX / railWidth;
20882
21250
  if (ratio <= .5) return min + ratio * (resetPoint - min) * 2;
20883
21251
  return resetPoint + (ratio - .5) * (max - resetPoint) * 2;
@@ -20996,6 +21364,7 @@ function Slider(props) {
20996
21364
  }];
20997
21365
  const visualValue = isDragging ? dragValue : value;
20998
21366
  const sliderOffset = Math.min(Math.max((_getSliderOffset = getSliderOffset(visualValue)) !== null && _getSliderOffset !== void 0 ? _getSliderOffset : 0, 0), 100);
21367
+ const handleOffset = isRtl ? 100 - sliderOffset : sliderOffset;
20999
21368
  const ReduceIcon = iconManager.get("ReduceIcon");
21000
21369
  const IncreaseIcon = iconManager.get("IncreaseIcon");
21001
21370
  const MoreDownIcon = iconManager.get("MoreDownIcon");
@@ -21022,7 +21391,7 @@ function Slider(props) {
21022
21391
  onPointerDown: handlePointerDown,
21023
21392
  children: [
21024
21393
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21025
- className: "univer-bg-primary-500/60 univer-absolute univer-left-0 univer-top-0 univer-h-full univer-rounded-full",
21394
+ className: (0, _univerjs_design.clsx)("univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full", isRtl ? "univer-right-0" : "univer-left-0"),
21026
21395
  style: { width: `${sliderOffset}%` }
21027
21396
  }),
21028
21397
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
@@ -21041,7 +21410,7 @@ function Slider(props) {
21041
21410
  "aria-valuemax": max,
21042
21411
  "aria-valuenow": visualValue,
21043
21412
  type: "button",
21044
- style: { left: `${sliderOffset}%` },
21413
+ style: { left: `${handleOffset}%` },
21045
21414
  onPointerDown: handlePointerDown
21046
21415
  })
21047
21416
  ]
@@ -21143,14 +21512,6 @@ ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)
21143
21512
  //#endregion
21144
21513
  //#region src/views/components/ribbon/MobileRibbon.tsx
21145
21514
  const toolbarScrollOffset = 168;
21146
- const nestedControlResetClassName = `
21147
- [&_button]:!univer-m-0 [&_button]:!univer-appearance-none [&_button]:!univer-border-0
21148
- [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-leading-none
21149
- [&_button]:!univer-outline-none
21150
- [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0
21151
- [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none
21152
- [&_input]:!univer-outline-none
21153
- `;
21154
21515
  function MobileRibbon(props) {
21155
21516
  var _activeGroup$children;
21156
21517
  const { headerMenuComponents, headerMenu = true } = props;
@@ -21290,7 +21651,7 @@ function MobileRibbon(props) {
21290
21651
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21291
21652
  className: (0, _univerjs_design.clsx)("univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0", { [_univerjs_design.borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
21292
21653
  children: groupItems.map((child) => child.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
21293
- className: (0, _univerjs_design.clsx)("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-rounded-md [&_button]:!univer-px-1.5", nestedControlResetClassName),
21654
+ className: (0, _univerjs_design.clsx)("[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-m-0 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-appearance-none [&_button]:!univer-rounded-md [&_button]:!univer-border-0 [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-px-1.5 [&_button]:!univer-leading-none [&_button]:!univer-outline-none [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0 [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none [&_input]:!univer-outline-none"),
21294
21655
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarItem, { ...child.item })
21295
21656
  }, child.key))
21296
21657
  }, groupItem.key);
@@ -21317,8 +21678,9 @@ function MobileRibbon(props) {
21317
21678
  //#region src/views/menu/mobile/MobileMenu.tsx
21318
21679
  function MobileMenu(props) {
21319
21680
  var _viewStack;
21320
- const { menuType, onOptionSelect, schemas: providedSchemas } = props;
21321
- const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
21681
+ const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
21682
+ const rootMenuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
21683
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
21322
21684
  const [viewStack, setViewStack] = (0, react.useState)([]);
21323
21685
  const menuSchemas = (0, react.useMemo)(() => {
21324
21686
  if (providedSchemas) return providedSchemas;
@@ -21366,6 +21728,7 @@ function MobileMenu(props) {
21366
21728
  className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
21367
21729
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSchemaList, {
21368
21730
  schemas: (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "schema" ? currentView.schemas : menuSchemas,
21731
+ menuManagerService,
21369
21732
  menuType,
21370
21733
  onExecute: onOptionSelect,
21371
21734
  onOpenView: openView
@@ -21384,7 +21747,7 @@ function MobileMenu(props) {
21384
21747
  });
21385
21748
  }
21386
21749
  function MobileSchemaList(props) {
21387
- const { schemas, menuType, onExecute, onOpenView } = props;
21750
+ const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
21388
21751
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21389
21752
  const hiddenGroupStates = useContextGroupHiddenStates(schemas);
21390
21753
  const visibleSchemas = (0, react.useMemo)(() => {
@@ -21398,6 +21761,7 @@ function MobileSchemaList(props) {
21398
21761
  var _schema$children2;
21399
21762
  if (schema.item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSchemaRow, {
21400
21763
  schema,
21764
+ menuManagerService,
21401
21765
  menuType,
21402
21766
  onExecute,
21403
21767
  onOpenView,
@@ -21411,6 +21775,7 @@ function MobileSchemaList(props) {
21411
21775
  children: localeService.t(schema.title)
21412
21776
  }), schema.children.map((childSchema, childIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSchemaRow, {
21413
21777
  schema: childSchema,
21778
+ menuManagerService,
21414
21779
  menuType,
21415
21780
  onExecute,
21416
21781
  onOpenView,
@@ -21420,9 +21785,10 @@ function MobileSchemaList(props) {
21420
21785
  }) });
21421
21786
  }
21422
21787
  function MobileSchemaRow(props) {
21423
- const { schema, menuType, onExecute, onOpenView, bordered } = props;
21788
+ const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
21424
21789
  const interaction = useMobileSchemaInteraction({
21425
21790
  schema,
21791
+ menuManagerService,
21426
21792
  menuType,
21427
21793
  onOpenView
21428
21794
  });
@@ -21497,8 +21863,7 @@ function MobileSelectionOptionRow(props) {
21497
21863
  }
21498
21864
  function useMobileSchemaInteraction(props) {
21499
21865
  var _schema$children3;
21500
- const { schema, menuType, onOpenView } = props;
21501
- const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
21866
+ const { schema, menuManagerService, menuType, onOpenView } = props;
21502
21867
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21503
21868
  const menuItem = schema.item;
21504
21869
  const selectorItem = menuItem;
@@ -21619,11 +21984,14 @@ const MOBILE_CONTEXT_MENU_HOST_ID = "mobile-context-menu";
21619
21984
  function MobileContextMenu() {
21620
21985
  const [visible, setVisible] = (0, react.useState)(false);
21621
21986
  const [menuType, setMenuType] = (0, react.useState)("");
21987
+ const [menuContext, setMenuContext] = (0, react.useState)();
21622
21988
  const visibleRef = (0, react.useRef)(visible);
21623
21989
  const contextMenuHostService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuHostService);
21624
21990
  const contextMenuService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuService);
21625
21991
  const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
21626
21992
  const layoutService = (0, _wendellhu_redi_react_bindings.useDependency)(ILayoutService);
21993
+ const menuManagerService = (0, _wendellhu_redi_react_bindings.useDependency)(IMenuManagerService);
21994
+ const runtimeScopeService = (0, _wendellhu_redi_react_bindings.useDependency)(IUIRuntimeScopeService);
21627
21995
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
21628
21996
  const direction = (0, _wendellhu_redi_react_bindings.useObservable)(localeService.direction$);
21629
21997
  const { mountContainer } = (0, react.useContext)(_univerjs_design.ConfigContext);
@@ -21647,9 +22015,10 @@ function MobileContextMenu() {
21647
22015
  contextMenuHostService.deactivateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21648
22016
  };
21649
22017
  }, [contextMenuHostService, contextMenuService]);
21650
- function handleContextMenu(_event, nextMenuType) {
22018
+ function handleContextMenu(_event, nextMenuType, context) {
21651
22019
  contextMenuHostService.activateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21652
22020
  setMenuType(nextMenuType);
22021
+ setMenuContext(context);
21653
22022
  setVisible(true);
21654
22023
  }
21655
22024
  function handleClose() {
@@ -21664,6 +22033,23 @@ function MobileContextMenu() {
21664
22033
  }
21665
22034
  }, [localeService, menuType]);
21666
22035
  if (!mountContainer || !visible) return null;
22036
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
22037
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(_univerjs_core.ICommandService)) ? activeScope.get(_univerjs_core.ICommandService) : commandService;
22038
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
22039
+ const menu = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileMenu, {
22040
+ menuType,
22041
+ menuManagerService: (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService,
22042
+ onOptionSelect: (params) => {
22043
+ var _ref, _params$commandId;
22044
+ const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
22045
+ const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
22046
+ const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
22047
+ if (!commandId) return;
22048
+ activeLayoutService.focus();
22049
+ activeCommandService.executeCommand(commandId, commandParams);
22050
+ handleClose();
22051
+ }
22052
+ });
21667
22053
  return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21668
22054
  dir: direction,
21669
22055
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
@@ -21697,19 +22083,7 @@ function MobileContextMenu() {
21697
22083
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, { className: "univer-size-4 univer-text-current" })
21698
22084
  })]
21699
22085
  })]
21700
- }), menuType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileMenu, {
21701
- menuType,
21702
- onOptionSelect: (params) => {
21703
- var _ref, _params$commandId;
21704
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
21705
- const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
21706
- const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
21707
- if (!commandId) return;
21708
- layoutService.focus();
21709
- commandService.executeCommand(commandId, commandParams);
21710
- handleClose();
21711
- }
21712
- })]
22086
+ }), menuType && menu]
21713
22087
  })]
21714
22088
  }), mountContainer);
21715
22089
  }
@@ -23074,6 +23448,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
23074
23448
  [IMenuManagerService, { useClass: MenuManagerService }],
23075
23449
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23076
23450
  [IContextMenuService, { useClass: ContextMenuService }],
23451
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23077
23452
  [IClipboardInterfaceService, {
23078
23453
  useClass: BrowserClipboardService,
23079
23454
  lazy: true
@@ -23111,6 +23486,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
23111
23486
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23112
23487
  [IFontService, { useClass: FontService }],
23113
23488
  [CanvasFloatDomService],
23489
+ [CanvasFloatDomPreviewService],
23114
23490
  [IUIController, {
23115
23491
  useFactory: (injector) => injector.createInstance(MobileUIController, this._config),
23116
23492
  deps: [_univerjs_core.Injector]
@@ -23168,11 +23544,13 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
23168
23544
  [IUIPartsService, { useClass: UIPartsService }],
23169
23545
  [ILayoutService, { useClass: DesktopLayoutService }],
23170
23546
  [IRibbonService, { useClass: DesktopRibbonService }],
23547
+ [IRibbonOverrideService, { useClass: RibbonOverrideService }],
23171
23548
  [IShortcutService, { useClass: ShortcutService }],
23172
23549
  [IPlatformService, { useClass: PlatformService }],
23173
23550
  [IMenuManagerService, { useClass: MenuManagerService }],
23174
23551
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23175
23552
  [IContextMenuService, { useClass: ContextMenuService }],
23553
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23176
23554
  [IClipboardInterfaceService, {
23177
23555
  useClass: BrowserClipboardService,
23178
23556
  lazy: true
@@ -23210,6 +23588,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
23210
23588
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23211
23589
  [IFontService, { useClass: FontService }],
23212
23590
  [CanvasFloatDomService],
23591
+ [CanvasFloatDomPreviewService],
23213
23592
  [IUIController, {
23214
23593
  useFactory: (injector) => injector.createInstance(DesktopUIController, this._config),
23215
23594
  deps: [_univerjs_core.Injector]
@@ -23923,16 +24302,16 @@ const PrintFloatDomSingle = (0, react.memo)((props) => {
23923
24302
  transform: transformRef.current
23924
24303
  },
23925
24304
  onPointerMove: (e) => {
23926
- layer.onPointerMove(e.nativeEvent);
24305
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
23927
24306
  },
23928
24307
  onPointerDown: (e) => {
23929
- layer.onPointerDown(e.nativeEvent);
24308
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
23930
24309
  },
23931
24310
  onPointerUp: (e) => {
23932
- layer.onPointerUp(e.nativeEvent);
24311
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
23933
24312
  },
23934
24313
  onWheel: (e) => {
23935
- layer.onWheel(e.nativeEvent);
24314
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
23936
24315
  },
23937
24316
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23938
24317
  ref: innerDomRef,
@@ -24037,6 +24416,7 @@ Object.defineProperty(exports, 'BrowserClipboardService', {
24037
24416
  exports.BuiltInUIPart = BuiltInUIPart;
24038
24417
  exports.COLOR_PICKER_COMPONENT = COLOR_PICKER_COMPONENT;
24039
24418
  exports.COMMON_LABEL_COMPONENT = COMMON_LABEL_COMPONENT;
24419
+ exports.CanvasFloatDomPreviewService = CanvasFloatDomPreviewService;
24040
24420
  exports.CanvasFloatDomService = CanvasFloatDomService;
24041
24421
  exports.CanvasPopup = CanvasPopup;
24042
24422
  exports.CanvasPopupService = CanvasPopupService;
@@ -24117,6 +24497,7 @@ Object.defineProperty(exports, 'DesktopUIController', {
24117
24497
  return DesktopUIController;
24118
24498
  }
24119
24499
  });
24500
+ exports.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE;
24120
24501
  exports.EMOJI_CATEGORIES = EMOJI_CATEGORIES;
24121
24502
  exports.EMOJI_PICKER_COMPONENT = EMOJI_PICKER_COMPONENT;
24122
24503
  exports.EMOJI_RECENT_LIMIT = EMOJI_RECENT_LIMIT;
@@ -24139,6 +24520,7 @@ exports.FONT_SIZE_LIST = FONT_SIZE_LIST;
24139
24520
  exports.FloatDom = FloatDom;
24140
24521
  exports.FloatDomSingle = FloatDomSingle;
24141
24522
  exports.FontFamily = FontFamily;
24523
+ exports.FontFamilyDropdown = FontFamilyDropdown;
24142
24524
  exports.FontFamilyItem = FontFamilyItem;
24143
24525
  Object.defineProperty(exports, 'FontService', {
24144
24526
  enumerable: true,
@@ -24166,11 +24548,13 @@ exports.IMenuManagerService = IMenuManagerService;
24166
24548
  exports.IMessageService = IMessageService;
24167
24549
  exports.INotificationService = INotificationService;
24168
24550
  exports.IPlatformService = IPlatformService;
24551
+ exports.IRibbonOverrideService = IRibbonOverrideService;
24169
24552
  exports.IRibbonService = IRibbonService;
24170
24553
  exports.IShortcutService = IShortcutService;
24171
24554
  exports.ISidebarService = ISidebarService;
24172
24555
  exports.IUIController = IUIController;
24173
24556
  exports.IUIPartsService = IUIPartsService;
24557
+ exports.IUIRuntimeScopeService = IUIRuntimeScopeService;
24174
24558
  Object.defineProperty(exports, 'IconManager', {
24175
24559
  enumerable: true,
24176
24560
  get: function () {
@@ -24219,6 +24603,7 @@ exports.RibbonDataGroup = RibbonDataGroup;
24219
24603
  exports.RibbonFormulasGroup = RibbonFormulasGroup;
24220
24604
  exports.RibbonInsertGroup = RibbonInsertGroup;
24221
24605
  exports.RibbonOthersGroup = RibbonOthersGroup;
24606
+ exports.RibbonOverrideService = RibbonOverrideService;
24222
24607
  exports.RibbonPosition = RibbonPosition;
24223
24608
  exports.RibbonStartGroup = RibbonStartGroup;
24224
24609
  exports.RibbonViewGroup = RibbonViewGroup;
@@ -24252,6 +24637,7 @@ exports.ToolbarButton = ToolbarButton;
24252
24637
  exports.ToolbarItem = ToolbarItem;
24253
24638
  exports.UIMenuSchema = menuSchema;
24254
24639
  exports.UIPartsService = UIPartsService;
24640
+ exports.UIRuntimeScopeService = UIRuntimeScopeService;
24255
24641
  exports.UI_PLUGIN_CONFIG_KEY = UI_PLUGIN_CONFIG_KEY;
24256
24642
  exports.UNI_DISABLE_CHANGING_FOCUS_KEY = UNI_DISABLE_CHANGING_FOCUS_KEY;
24257
24643
  exports.UndoShortcutItem = UndoShortcutItem;
@@ -24288,6 +24674,7 @@ Object.defineProperty(exports, 'connectInjector', {
24288
24674
  });
24289
24675
  exports.getAllEmojis = getAllEmojis;
24290
24676
  exports.getDefaultRecentEmojis = getDefaultRecentEmojis;
24677
+ exports.getEmbedBoundaryOwner = getEmbedBoundaryOwner;
24291
24678
  exports.getEmojiLocaleData = getEmojiLocaleData;
24292
24679
  exports.getHeaderFooterMenuHiddenObservable = getHeaderFooterMenuHiddenObservable;
24293
24680
  exports.getLocalizedEmojiTitle = getLocalizedEmojiTitle;
@@ -24302,6 +24689,8 @@ exports.handleTableColgroup = handleTableColgroup;
24302
24689
  exports.handleTableMergeData = handleTableMergeData;
24303
24690
  exports.handleTableRowGroup = handleTableRowGroup;
24304
24691
  exports.imageMimeTypeSet = imageMimeTypeSet;
24692
+ exports.isEmbedBoundaryTarget = isEmbedBoundaryTarget;
24693
+ exports.keepInteractionInsideSameEmbedBoundary = keepInteractionInsideSameEmbedBoundary;
24305
24694
  exports.mergeMenuConfigs = mergeMenuConfigs;
24306
24695
  exports.parseHtmlDocument = parseHtmlDocument;
24307
24696
  exports.parseHtmlFragment = parseHtmlFragment;