@univerjs/ui 1.0.0-alpha.2 → 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 (28) hide show
  1. package/lib/cjs/facade.js +2 -0
  2. package/lib/cjs/index.js +567 -224
  3. package/lib/es/facade.js +2 -0
  4. package/lib/es/index.js +559 -225
  5. package/lib/facade.js +2 -0
  6. package/lib/index.css +5 -12
  7. package/lib/index.js +559 -225
  8. package/lib/types/facade/f-menu-builder.d.ts +2 -0
  9. package/lib/types/index.d.ts +6 -2
  10. package/lib/types/services/contextmenu/contextmenu.service.d.ts +6 -3
  11. package/lib/types/services/dom/canvas-dom-layer.service.d.ts +52 -1
  12. package/lib/types/services/menu/menu-manager.service.d.ts +1 -0
  13. package/lib/types/services/popup/canvas-popup.service.d.ts +2 -1
  14. package/lib/types/services/ribbon/ribbon-override.service.d.ts +42 -0
  15. package/lib/types/services/runtime-scope/ui-runtime-scope.service.d.ts +32 -0
  16. package/lib/types/services/shortcut/shortcut.service.d.ts +2 -1
  17. package/lib/types/utils/embed-boundary.d.ts +23 -0
  18. package/lib/types/utils/index.d.ts +1 -0
  19. package/lib/types/views/components/context-menu/AnchoredContextMenu.d.ts +4 -0
  20. package/lib/types/views/components/context-menu/ContextMenuPanel.d.ts +4 -0
  21. package/lib/types/views/components/dom/FloatDom.d.ts +11 -0
  22. package/lib/types/views/components/dom/float-dom-layout.d.ts +35 -0
  23. package/lib/types/views/components/ribbon/Ribbon.d.ts +2 -0
  24. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +6 -1
  25. package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
  26. package/lib/types/views/menu/mobile/MobileMenu.d.ts +2 -0
  27. package/lib/umd/index.js +15 -22
  28. package/package.json +8 -8
package/lib/es/index.js CHANGED
@@ -624,6 +624,47 @@ function fromGlobalEvent(type, listener, options) {
624
624
  return toDisposable(() => window.removeEventListener(type, listener, options));
625
625
  }
626
626
 
627
+ //#endregion
628
+ //#region src/utils/embed-boundary.ts
629
+ /**
630
+ * Copyright 2023-present DreamNum Co., Ltd.
631
+ *
632
+ * Licensed under the Apache License, Version 2.0 (the "License");
633
+ * you may not use this file except in compliance with the License.
634
+ * You may obtain a copy of the License at
635
+ *
636
+ * http://www.apache.org/licenses/LICENSE-2.0
637
+ *
638
+ * Unless required by applicable law or agreed to in writing, software
639
+ * distributed under the License is distributed on an "AS IS" BASIS,
640
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
641
+ * See the License for the specific language governing permissions and
642
+ * limitations under the License.
643
+ */
644
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
645
+ function getEmbedBoundaryOwner(target) {
646
+ var _ref, _getAttributeValue;
647
+ if (!hasClosest(target)) return;
648
+ const ownerElement = target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`);
649
+ 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;
650
+ }
651
+ function isEmbedBoundaryTarget(target) {
652
+ return hasClosest(target) && target.closest(`[${"data-embed-interaction-boundary-owner"}]`) != null;
653
+ }
654
+ function keepInteractionInsideSameEmbedBoundary(event) {
655
+ const owner = getEmbedBoundaryOwner(event.currentTarget);
656
+ if (!owner) return;
657
+ if (getEmbedBoundaryOwner(event.target) === owner) event.preventDefault();
658
+ }
659
+ function hasClosest(target) {
660
+ return !!target && typeof target.closest === "function";
661
+ }
662
+ function getAttributeValue(target, name) {
663
+ var _getAttribute$call;
664
+ const getAttribute = target === null || target === void 0 ? void 0 : target.getAttribute;
665
+ return typeof getAttribute === "function" ? (_getAttribute$call = getAttribute.call(target, name)) !== null && _getAttribute$call !== void 0 ? _getAttribute$call : void 0 : void 0;
666
+ }
667
+
627
668
  //#endregion
628
669
  //#region src/services/layout/layout.service.ts
629
670
  const FOCUSING_UNIVER = "FOCUSING_UNIVER";
@@ -704,8 +745,15 @@ let DesktopLayoutService = class DesktopLayoutService extends Disposable {
704
745
  this.disposeWithMe(fromEvent(window, "focusin").subscribe((event) => {
705
746
  var _this$_rootContainerE;
706
747
  const target = event.target;
707
- if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item)) {
708
- queueMicrotask(() => this.focus());
748
+ 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)) {
749
+ queueMicrotask(() => {
750
+ const targetUnitId = getFocusUnitIdFromElement(target);
751
+ if (targetUnitId && this._univerInstanceService.getUnit(targetUnitId)) this._univerInstanceService.focusUnit(targetUnitId);
752
+ this.focus();
753
+ this._isFocused = true;
754
+ this._contextService.setContextValue(FOCUSING_UNIVER, this._isFocused);
755
+ this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR, getFocusingUniverEditorStatus());
756
+ });
709
757
  return;
710
758
  }
711
759
  if (target && this.checkElementInCurrentContainers(target)) this._isFocused = true;
@@ -723,6 +771,9 @@ function getFocusingUniverEditorStatus() {
723
771
  var _document$activeEleme;
724
772
  return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
725
773
  }
774
+ function getFocusUnitIdFromElement(target) {
775
+ return target.dataset.uUnitId;
776
+ }
726
777
 
727
778
  //#endregion
728
779
  //#region src/services/platform/platform.service.ts
@@ -844,6 +895,7 @@ let ShortcutService = class ShortcutService extends Disposable {
844
895
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
845
896
  const binding = this._deriveBindingFromEvent(e);
846
897
  if (binding === null) return;
898
+ if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
847
899
  const shortcuts = this._shortCutMapping.get(binding);
848
900
  if (shortcuts === void 0) return;
849
901
  return Array.from(shortcuts).sort((s1, s2) => {
@@ -869,6 +921,12 @@ let ShortcutService = class ShortcutService extends Disposable {
869
921
  if (this._platformService.isMac && e.ctrlKey) binding |= 8192;
870
922
  return binding;
871
923
  }
924
+ _shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) {
925
+ if (binding !== (65 | 4096)) return false;
926
+ const target = e.target;
927
+ if (!(target instanceof HTMLElement)) return false;
928
+ return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && isEmbedBoundaryTarget(target);
929
+ }
872
930
  };
873
931
  ShortcutService = __decorate([
874
932
  __decorateParam(0, ICommandService),
@@ -1050,8 +1108,9 @@ let ContextMenuGroup = /* @__PURE__ */ function(ContextMenuGroup) {
1050
1108
 
1051
1109
  //#endregion
1052
1110
  //#region src/services/menu/menu-manager.service.ts
1111
+ var _MenuManagerService;
1053
1112
  const IMenuManagerService = createIdentifier("univer.menu-manager-service");
1054
- let MenuManagerService = class MenuManagerService extends Disposable {
1113
+ let MenuManagerService = _MenuManagerService = class MenuManagerService extends Disposable {
1055
1114
  constructor(_injector, _configService) {
1056
1115
  super();
1057
1116
  this._injector = _injector;
@@ -1185,6 +1244,21 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1185
1244
  this._menu = merge({}, this._menu, source);
1186
1245
  this.menuChanged$.next();
1187
1246
  }
1247
+ createScoped(injector) {
1248
+ const root = this;
1249
+ const createScopedBuilder = () => {
1250
+ const service = new _MenuManagerService(injector, root._configService);
1251
+ service._menu = root._menu;
1252
+ return service;
1253
+ };
1254
+ return {
1255
+ menuChanged$: root.menuChanged$,
1256
+ mergeMenu: (source, target) => root.mergeMenu(source, target),
1257
+ appendRootMenu: (source) => root.appendRootMenu(source),
1258
+ getMenuByPositionKey: (position) => createScopedBuilder().getMenuByPositionKey(position),
1259
+ getFlatMenuByPositionKey: (position) => createScopedBuilder().getFlatMenuByPositionKey(position)
1260
+ };
1261
+ }
1188
1262
  _buildMenuSchema(data) {
1189
1263
  const result = [];
1190
1264
  for (const [key, value] of Object.entries(data)) {
@@ -1224,6 +1298,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1224
1298
  * @returns Menu schema array or empty array if not found
1225
1299
  */
1226
1300
  getMenuByPositionKey(key) {
1301
+ var _findKey;
1227
1302
  const findKey = (obj) => {
1228
1303
  if (key in obj) return this._buildMenuSchema(obj[key]);
1229
1304
  for (const k in obj) {
@@ -1234,7 +1309,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1234
1309
  }
1235
1310
  }
1236
1311
  };
1237
- return findKey(this._menu);
1312
+ return (_findKey = findKey(this._menu)) !== null && _findKey !== void 0 ? _findKey : [];
1238
1313
  }
1239
1314
  /**
1240
1315
  * Get flat menu schema by position key
@@ -1256,7 +1331,7 @@ let MenuManagerService = class MenuManagerService extends Disposable {
1256
1331
  return flatMenuItems(menu);
1257
1332
  }
1258
1333
  };
1259
- MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
1334
+ MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, IConfigService)], MenuManagerService);
1260
1335
  function normalizeMenuOrder(order) {
1261
1336
  return order !== null && order !== void 0 ? order : 0;
1262
1337
  }
@@ -1333,11 +1408,14 @@ const undoRedoDisableFactory$ = (accessor, isUndo) => {
1333
1408
  return undoDisable || contextService.getContextValue(EDITOR_ACTIVATED) || contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
1334
1409
  }));
1335
1410
  };
1411
+ const rtlIconFactory$ = (accessor, ltrIcon, rtlIcon) => {
1412
+ return accessor.get(LocaleService).direction$.pipe(map$1((direction) => direction === "rtl" ? rtlIcon : ltrIcon));
1413
+ };
1336
1414
  function UndoMenuItemFactory(accessor) {
1337
1415
  return {
1338
1416
  id: UndoCommand.id,
1339
1417
  type: 0,
1340
- icon: "UndoIcon",
1418
+ icon: rtlIconFactory$(accessor, "UndoIcon", "RedoIcon"),
1341
1419
  title: "ui.shortcut.undo",
1342
1420
  tooltip: "ui.shortcut.undo",
1343
1421
  disabled$: undoRedoDisableFactory$(accessor, true)
@@ -1347,7 +1425,7 @@ function RedoMenuItemFactory(accessor) {
1347
1425
  return {
1348
1426
  id: RedoCommand.id,
1349
1427
  type: 0,
1350
- icon: "RedoIcon",
1428
+ icon: rtlIconFactory$(accessor, "RedoIcon", "UndoIcon"),
1351
1429
  title: "ui.shortcut.redo",
1352
1430
  tooltip: "ui.shortcut.redo",
1353
1431
  disabled$: undoRedoDisableFactory$(accessor, false)
@@ -1468,8 +1546,15 @@ function useObservableRef(observable, defaultValue) {
1468
1546
 
1469
1547
  //#endregion
1470
1548
  //#region src/services/dom/canvas-dom-layer.service.ts
1471
- var CanvasFloatDomService = class {
1472
- constructor() {
1549
+ function shouldForwardFloatDomEvents(layer) {
1550
+ return layer.eventPassThrough !== false;
1551
+ }
1552
+ function shouldRenderFloatDomLayer(layer, currentUnitId) {
1553
+ return layer.unitId === currentUnitId || layer.preserveOnFocusChange === true;
1554
+ }
1555
+ var CanvasFloatDomService = class extends Disposable {
1556
+ constructor(..._args) {
1557
+ super(..._args);
1473
1558
  _defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
1474
1559
  _defineProperty(this, "_domLayers$", new BehaviorSubject([]));
1475
1560
  _defineProperty(this, "domLayers$", this._domLayers$.asObservable());
@@ -1500,68 +1585,131 @@ var CanvasFloatDomService = class {
1500
1585
  this._domLayerMap.clear();
1501
1586
  this._notice();
1502
1587
  }
1588
+ dispose() {
1589
+ this._domLayerMap.clear();
1590
+ this._domLayers$.next([]);
1591
+ this._domLayers$.complete();
1592
+ super.dispose();
1593
+ }
1594
+ };
1595
+ var CanvasFloatDomPreviewService = class extends Disposable {
1596
+ constructor(..._args2) {
1597
+ super(..._args2);
1598
+ _defineProperty(this, "previewUpdated$", new Subject());
1599
+ _defineProperty(this, "previewRequested$", new Subject());
1600
+ _defineProperty(this, "_previewMap", /* @__PURE__ */ new Map());
1601
+ _defineProperty(this, "_requestMap", /* @__PURE__ */ new Map());
1602
+ }
1603
+ getPreview(id) {
1604
+ return this._previewMap.get(id);
1605
+ }
1606
+ getPendingRequests() {
1607
+ return Array.from(this._requestMap.values());
1608
+ }
1609
+ setPreview(preview) {
1610
+ this._previewMap.set(preview.id, preview);
1611
+ this._requestMap.delete(preview.id);
1612
+ this.previewUpdated$.next(preview);
1613
+ }
1614
+ removePreview(id) {
1615
+ this._previewMap.delete(id);
1616
+ this._requestMap.delete(id);
1617
+ }
1618
+ requestPreview(request) {
1619
+ this._requestMap.set(request.id, request);
1620
+ this.previewRequested$.next(request);
1621
+ }
1622
+ dispose() {
1623
+ this._previewMap.clear();
1624
+ this._requestMap.clear();
1625
+ this.previewUpdated$.complete();
1626
+ this.previewRequested$.complete();
1627
+ super.dispose();
1628
+ }
1503
1629
  };
1504
1630
 
1631
+ //#endregion
1632
+ //#region src/views/components/dom/float-dom-layout.ts
1633
+ const LEGACY_WRAPPER_INSET = 2;
1634
+ const LEGACY_CONTENT_INSET = 4;
1635
+ function resolveFloatDomLayout(position, contentBox) {
1636
+ var _contentBox$wrapperIn, _contentBox$contentIn, _position$opacity;
1637
+ const wrapperInset = (_contentBox$wrapperIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.wrapperInset) !== null && _contentBox$wrapperIn !== void 0 ? _contentBox$wrapperIn : LEGACY_WRAPPER_INSET;
1638
+ const contentInset = (_contentBox$contentIn = contentBox === null || contentBox === void 0 ? void 0 : contentBox.contentInset) !== null && _contentBox$contentIn !== void 0 ? _contentBox$contentIn : LEGACY_CONTENT_INSET;
1639
+ return {
1640
+ wrapper: {
1641
+ top: position.startY,
1642
+ left: position.startX,
1643
+ width: Math.max(position.endX - position.startX - wrapperInset, 0),
1644
+ height: Math.max(position.endY - position.startY - wrapperInset, 0),
1645
+ transform: `rotate(${position.rotate}deg)`,
1646
+ opacity: (_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1
1647
+ },
1648
+ inner: {
1649
+ width: position.width - contentInset,
1650
+ height: position.height - contentInset,
1651
+ left: position.absolute.left ? 0 : "auto",
1652
+ top: position.absolute.top ? 0 : "auto",
1653
+ right: position.absolute.left ? "auto" : 0,
1654
+ bottom: position.absolute.top ? "auto" : 0
1655
+ }
1656
+ };
1657
+ }
1658
+
1505
1659
  //#endregion
1506
1660
  //#region src/views/components/dom/FloatDom.tsx
1661
+ function applyFloatDomLayout(wrapper, inner, layout) {
1662
+ const { wrapper: wrapperLayout, inner: innerLayout } = layout;
1663
+ const wrapperStyle = wrapper.style;
1664
+ wrapperStyle.top = `${wrapperLayout.top}px`;
1665
+ wrapperStyle.left = `${wrapperLayout.left}px`;
1666
+ wrapperStyle.width = `${wrapperLayout.width}px`;
1667
+ wrapperStyle.height = `${wrapperLayout.height}px`;
1668
+ wrapperStyle.transform = wrapperLayout.transform;
1669
+ wrapperStyle.opacity = `${wrapperLayout.opacity}`;
1670
+ const innerStyle = inner.style;
1671
+ innerStyle.width = `${innerLayout.width}px`;
1672
+ innerStyle.height = `${innerLayout.height}px`;
1673
+ innerStyle.left = innerLayout.left === "auto" ? "auto" : `${innerLayout.left}px`;
1674
+ innerStyle.top = innerLayout.top === "auto" ? "auto" : `${innerLayout.top}px`;
1675
+ innerStyle.right = innerLayout.right === "auto" ? "auto" : `${innerLayout.right}px`;
1676
+ innerStyle.bottom = innerLayout.bottom === "auto" ? "auto" : `${innerLayout.bottom}px`;
1677
+ }
1507
1678
  const FloatDomSingle = memo((props) => {
1508
- var _position$startY, _position$startX;
1679
+ var _layer$contentBox, _layer$contentBox2;
1509
1680
  const { layer, id } = props;
1510
- const size$ = useMemo(() => layer.position$.pipe(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$]);
1511
1681
  const univerInstanceService = useDependency(IUniverInstanceService);
1512
1682
  const position = useObservable(useMemo(() => layer.position$.pipe(first()), [layer.position$]));
1513
1683
  const domRef = useRef(null);
1514
1684
  const innerDomRef = useRef(null);
1515
- const transformRef = 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)`);
1516
- const topRef = useRef((_position$startY = position === null || position === void 0 ? void 0 : position.startY) !== null && _position$startY !== void 0 ? _position$startY : 0);
1517
- const leftRef = useRef((_position$startX = position === null || position === void 0 ? void 0 : position.startX) !== null && _position$startX !== void 0 ? _position$startX : 0);
1518
- const innerStyle = useRef({});
1519
1685
  const Component = typeof layer.componentKey === "string" ? useDependency(ComponentManager).get(layer.componentKey) : layer.componentKey;
1520
1686
  const layerProps = useMemo(() => ({
1521
1687
  data: layer.data,
1522
- ...layer.props
1523
- }), [layer.data, layer.props]);
1688
+ ...layer.props,
1689
+ hostFloatDomLayout$: layer.position$
1690
+ }), [
1691
+ layer.data,
1692
+ layer.position$,
1693
+ layer.props
1694
+ ]);
1695
+ const floatDomOverflow = resolveFloatDomOverflow(layerProps);
1696
+ const wrapperInset = (_layer$contentBox = layer.contentBox) === null || _layer$contentBox === void 0 ? void 0 : _layer$contentBox.wrapperInset;
1697
+ const contentInset = (_layer$contentBox2 = layer.contentBox) === null || _layer$contentBox2 === void 0 ? void 0 : _layer$contentBox2.contentInset;
1524
1698
  useEffect(() => {
1525
1699
  const subscription = layer.position$.subscribe((position) => {
1526
- transformRef.current = `rotate(${position.rotate}deg)`;
1527
- topRef.current = position.startY;
1528
- leftRef.current = position.startX;
1529
- if (domRef.current) {
1530
- var _position$opacity;
1531
- domRef.current.style.transform = transformRef.current;
1532
- domRef.current.style.top = `${topRef.current}px`;
1533
- domRef.current.style.left = `${leftRef.current}px`;
1534
- domRef.current.style.opacity = `${(_position$opacity = position.opacity) !== null && _position$opacity !== void 0 ? _position$opacity : 1}`;
1535
- }
1536
- });
1537
- const sizeSubscription = size$.subscribe((size) => {
1538
- if (domRef.current) {
1539
- domRef.current.style.width = `${Math.max(size.endX - size.startX - 2, 0)}px`;
1540
- domRef.current.style.height = `${Math.max(size.endY - size.startY - 2, 0)}px`;
1541
- }
1542
- if (innerDomRef.current) {
1543
- const style = {
1544
- width: `${size.width - 4}px`,
1545
- height: `${size.height - 4}px`,
1546
- left: `${size.absolute.left ? 0 : "auto"}`,
1547
- top: `${size.absolute.top ? 0 : "auto"}`,
1548
- right: `${size.absolute.left ? "auto" : 0}`,
1549
- bottom: `${size.absolute.top ? "auto" : 0}`
1550
- };
1551
- innerDomRef.current.style.width = style.width;
1552
- innerDomRef.current.style.height = style.height;
1553
- innerDomRef.current.style.left = style.left;
1554
- innerDomRef.current.style.top = style.top;
1555
- innerDomRef.current.style.right = style.right;
1556
- innerDomRef.current.style.bottom = style.bottom;
1557
- innerStyle.current = style;
1558
- }
1700
+ if (domRef.current && innerDomRef.current) applyFloatDomLayout(domRef.current, innerDomRef.current, resolveFloatDomLayout(position, {
1701
+ wrapperInset,
1702
+ contentInset
1703
+ }));
1559
1704
  });
1560
1705
  return () => {
1561
1706
  subscription.unsubscribe();
1562
- sizeSubscription.unsubscribe();
1563
1707
  };
1564
- }, [layer.position$, size$]);
1708
+ }, [
1709
+ contentInset,
1710
+ layer.position$,
1711
+ wrapperInset
1712
+ ]);
1565
1713
  const instance = univerInstanceService.getUnit(layer.unitId);
1566
1714
  const docDisabled = instance instanceof DocumentDataModel ? instance.getDisabled() : void 0;
1567
1715
  const component = useMemo(() => Component ? /* @__PURE__ */ jsx(Component, {
@@ -1575,36 +1723,34 @@ const FloatDomSingle = memo((props) => {
1575
1723
  }
1576
1724
  }) : null, [Component, layerProps]);
1577
1725
  if (!position) return null;
1726
+ const layout = resolveFloatDomLayout(position, layer.contentBox);
1578
1727
  return /* @__PURE__ */ jsx("div", {
1579
1728
  ref: domRef,
1580
- className: "univer-z-10",
1729
+ className: "univer-absolute univer-z-10 univer-origin-center",
1581
1730
  style: {
1582
- position: "absolute",
1583
- top: topRef.current,
1584
- left: leftRef.current,
1585
- width: Math.max(position.endX - position.startX - 2, 0),
1586
- height: Math.max(position.endY - position.startY - 2, 0),
1587
- transform: transformRef.current,
1588
- overflow: "hidden",
1589
- transformOrigin: "center center"
1731
+ ...layout.wrapper,
1732
+ overflow: floatDomOverflow.outerOverflow
1590
1733
  },
1591
1734
  onPointerMove: (e) => {
1592
- layer.onPointerMove(e.nativeEvent);
1735
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
1593
1736
  },
1594
1737
  onPointerDown: (e) => {
1595
- layer.onPointerDown(e.nativeEvent);
1738
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
1596
1739
  },
1597
1740
  onPointerUp: (e) => {
1598
- layer.onPointerUp(e.nativeEvent);
1741
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
1599
1742
  },
1600
1743
  onWheel: (e) => {
1601
- layer.onWheel(e.nativeEvent);
1744
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
1602
1745
  },
1603
1746
  children: /* @__PURE__ */ jsx("div", {
1604
1747
  id,
1605
1748
  ref: innerDomRef,
1606
1749
  className: "univer-absolute univer-overflow-hidden",
1607
- style: { ...innerStyle.current },
1750
+ style: {
1751
+ ...layout.inner,
1752
+ overflow: floatDomOverflow.innerOverflow
1753
+ },
1608
1754
  children: component
1609
1755
  })
1610
1756
  });
@@ -1613,9 +1759,8 @@ const FloatDom = ({ unitId }) => {
1613
1759
  var _layers$filter;
1614
1760
  const instanceService = useDependency(IUniverInstanceService);
1615
1761
  const layers = useObservable(useDependency(CanvasFloatDomService).domLayers$);
1616
- const focusUnit = useObservable(instanceService.focused$);
1617
- const currentUnitId = unitId || focusUnit;
1618
- 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) => {
1762
+ const currentUnitId = resolveFloatDomCurrentUnitId(unitId, useObservable(instanceService.focused$));
1763
+ 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) => {
1619
1764
  var _layer$1$domId;
1620
1765
  return /* @__PURE__ */ jsx(FloatDomSingle, {
1621
1766
  id: (_layer$1$domId = layer[1].domId) !== null && _layer$1$domId !== void 0 ? _layer$1$domId : layer[0],
@@ -1623,6 +1768,27 @@ const FloatDom = ({ unitId }) => {
1623
1768
  }, layer[0]);
1624
1769
  });
1625
1770
  };
1771
+ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
1772
+ if (typeof unitId === "string") return unitId;
1773
+ if (typeof focusedUnit === "string") return focusedUnit;
1774
+ if (focusedUnit != null && typeof focusedUnit === "object" && "getUnitId" in focusedUnit && typeof focusedUnit.getUnitId === "function") {
1775
+ const focusedUnitId = focusedUnit.getUnitId();
1776
+ return typeof focusedUnitId === "string" ? focusedUnitId : null;
1777
+ }
1778
+ return null;
1779
+ }
1780
+ function resolveFloatDomOverflow(props) {
1781
+ var _viewport$bleedWidth;
1782
+ const viewport = props.customBlockRenderViewport;
1783
+ 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 {
1784
+ outerOverflow: "hidden",
1785
+ innerOverflow: "hidden"
1786
+ };
1787
+ return {
1788
+ outerOverflow: "visible",
1789
+ innerOverflow: "visible"
1790
+ };
1791
+ }
1626
1792
 
1627
1793
  //#endregion
1628
1794
  //#region src/services/popup/canvas-popup.service.ts
@@ -1929,13 +2095,41 @@ function CanvasPopup() {
1929
2095
  return useObservable(popupService.popups$, void 0, true).map((item) => {
1930
2096
  const [key, popup] = item;
1931
2097
  const Component = componentManager.get(popup.componentKey);
2098
+ const PopupComponent = Component && popup.connectorInjector ? connectInjector(Component, popup.connectorInjector) : Component;
1932
2099
  return /* @__PURE__ */ jsx(SingleCanvasPopup, {
1933
2100
  popup,
1934
- children: Component ? /* @__PURE__ */ jsx(Component, { popup }) : null
2101
+ children: PopupComponent && /* @__PURE__ */ jsx(PopupComponent, { popup })
1935
2102
  }, key);
1936
2103
  });
1937
2104
  }
1938
2105
 
2106
+ //#endregion
2107
+ //#region src/services/ribbon/ribbon-override.service.ts
2108
+ const IRibbonOverrideService = createIdentifier("univer.ribbon-override-service");
2109
+ var RibbonOverrideService = class extends Disposable {
2110
+ constructor(..._args) {
2111
+ super(..._args);
2112
+ _defineProperty(this, "_override$", new BehaviorSubject(null));
2113
+ _defineProperty(this, "override$", this._override$.asObservable());
2114
+ }
2115
+ getOverride() {
2116
+ return this._override$.getValue();
2117
+ }
2118
+ activate(override) {
2119
+ this._override$.next(override);
2120
+ }
2121
+ clear(id) {
2122
+ const current = this.getOverride();
2123
+ if (!current) return;
2124
+ if (!id || current.id === id) this._override$.next(null);
2125
+ }
2126
+ dispose() {
2127
+ this._override$.next(null);
2128
+ this._override$.complete();
2129
+ super.dispose();
2130
+ }
2131
+ };
2132
+
1939
2133
  //#endregion
1940
2134
  //#region src/services/ribbon/ribbon.service.ts
1941
2135
  const IRibbonService = createIdentifier("univer.ribbon-service");
@@ -2418,39 +2612,52 @@ const TooltipWrapperContext = createContext({
2418
2612
  dropdownVisible: false,
2419
2613
  setDropdownVisible: (_visible) => {}
2420
2614
  });
2615
+ const ToolbarDropdownContext = createContext(null);
2616
+ function ToolbarDropdownProvider(props) {
2617
+ const [openDropdownKey, setOpenDropdownKey] = useState(null);
2618
+ const contextValue = useMemo(() => ({
2619
+ openDropdownKey,
2620
+ setOpenDropdownKey
2621
+ }), [openDropdownKey]);
2622
+ return /* @__PURE__ */ jsx(ToolbarDropdownContext.Provider, {
2623
+ value: contextValue,
2624
+ children: props.children
2625
+ });
2626
+ }
2421
2627
  const TooltipWrapper = forwardRef((props, ref) => {
2422
- const { children, ...tooltipProps } = props;
2628
+ const { children, dropdownKey, ...tooltipProps } = props;
2423
2629
  const spanRef = useRef(null);
2424
2630
  const [tooltipVisible, setTooltipVisible] = useState(false);
2425
- const [dropdownVisible, setDropdownVisible] = useState(false);
2631
+ const [localDropdownVisible, setLocalDropdownVisible] = useState(false);
2632
+ const toolbarDropdownContext = useContext(ToolbarDropdownContext);
2633
+ const dropdownVisible = dropdownKey && toolbarDropdownContext ? toolbarDropdownContext.openDropdownKey === dropdownKey : localDropdownVisible;
2426
2634
  function handleChangeTooltipVisible(visible) {
2427
2635
  if (dropdownVisible) setTooltipVisible(false);
2428
2636
  else setTooltipVisible(visible);
2429
2637
  }
2430
- function handleChangeDropdownVisible(visible) {
2431
- setDropdownVisible(visible);
2638
+ const handleChangeDropdownVisible = useCallback((visible) => {
2639
+ if (dropdownKey && toolbarDropdownContext) toolbarDropdownContext.setOpenDropdownKey(visible ? dropdownKey : null);
2640
+ else setLocalDropdownVisible(visible);
2432
2641
  setTooltipVisible(false);
2433
- }
2642
+ }, [dropdownKey, toolbarDropdownContext]);
2434
2643
  const contextValue = useMemo(() => ({
2435
2644
  dropdownVisible,
2436
2645
  setDropdownVisible: handleChangeDropdownVisible
2437
- }), [dropdownVisible]);
2646
+ }), [dropdownVisible, handleChangeDropdownVisible]);
2438
2647
  useImperativeHandle(ref, () => ({ el: spanRef.current }));
2648
+ const content = /* @__PURE__ */ jsx("span", {
2649
+ ref: spanRef,
2650
+ children: /* @__PURE__ */ jsx(TooltipWrapperContext.Provider, {
2651
+ value: contextValue,
2652
+ children
2653
+ })
2654
+ });
2439
2655
  return tooltipProps.title ? /* @__PURE__ */ jsx(Tooltip, {
2440
2656
  visible: tooltipVisible,
2441
2657
  onVisibleChange: handleChangeTooltipVisible,
2442
2658
  ...tooltipProps,
2443
- children: /* @__PURE__ */ jsx("span", {
2444
- ref: spanRef,
2445
- children: /* @__PURE__ */ jsx(TooltipWrapperContext.Provider, {
2446
- value: contextValue,
2447
- children
2448
- })
2449
- })
2450
- }) : /* @__PURE__ */ jsx("span", {
2451
- ref: spanRef,
2452
- children
2453
- });
2659
+ children: content
2660
+ }) : content;
2454
2661
  });
2455
2662
  function DropdownWrapper(props) {
2456
2663
  const { children, overlay, disabled, align = "start" } = props;
@@ -2503,6 +2710,10 @@ function DropdownMenuLabel({ icon, value, option, onOptionSelect }) {
2503
2710
  })]
2504
2711
  });
2505
2712
  }
2713
+ function getOptionKey(option) {
2714
+ var _ref, _ref2, _option$id, _option$label2;
2715
+ 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);
2716
+ }
2506
2717
  function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect }) {
2507
2718
  const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
2508
2719
  const menuManagerService = useDependency(IMenuManagerService);
@@ -2531,6 +2742,9 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2531
2742
  function handleVisibleChange(visible) {
2532
2743
  setDropdownVisible(visible);
2533
2744
  }
2745
+ function handleEmbedBoundaryFocusOutside(event) {
2746
+ keepInteractionInsideSameEmbedBoundary(event);
2747
+ }
2534
2748
  function handleOptionSelect(option) {
2535
2749
  onOptionSelect(option);
2536
2750
  setDropdownVisible(false);
@@ -2570,19 +2784,19 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2570
2784
  }, [menuItems]);
2571
2785
  if (slot) return /* @__PURE__ */ jsx(DropdownWrapper, {
2572
2786
  disabled,
2573
- overlay: options.map((option, index) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
2787
+ overlay: options.map((option) => /* @__PURE__ */ jsx(DropdownMenuLabel, {
2574
2788
  value,
2575
2789
  option,
2576
2790
  onOptionSelect: handleOptionSelect
2577
- }, index)),
2791
+ }, getOptionKey(option))),
2578
2792
  children
2579
2793
  });
2580
2794
  if (options === null || options === void 0 ? void 0 : options.length) {
2581
2795
  const items = options.map((option) => {
2582
- var _option$label2;
2796
+ var _option$label3;
2583
2797
  return {
2584
2798
  type: "item",
2585
- className: clsx({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.hoverable) === false }),
2799
+ className: clsx({ "focus:univer-bg-white": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false }),
2586
2800
  children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
2587
2801
  icon: option.icon,
2588
2802
  value,
@@ -2625,6 +2839,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2625
2839
  disabled,
2626
2840
  open: dropdownVisible,
2627
2841
  onOpenChange: handleVisibleChange,
2842
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2843
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2628
2844
  children
2629
2845
  });
2630
2846
  } else {
@@ -2659,6 +2875,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
2659
2875
  disabled,
2660
2876
  open: dropdownVisible,
2661
2877
  onOpenChange: handleVisibleChange,
2878
+ onFocusOutside: handleEmbedBoundaryFocusOutside,
2879
+ onInteractOutside: handleEmbedBoundaryFocusOutside,
2662
2880
  children
2663
2881
  });
2664
2882
  }
@@ -2895,6 +3113,7 @@ const ToolbarItem = forwardRef((props, ref) => {
2895
3113
  ref,
2896
3114
  title: tooltipTitle,
2897
3115
  placement: "bottom",
3116
+ dropdownKey: id,
2898
3117
  children: renderItem()
2899
3118
  });
2900
3119
  });
@@ -2902,15 +3121,20 @@ const ToolbarItem = forwardRef((props, ref) => {
2902
3121
  //#endregion
2903
3122
  //#region src/views/components/ribbon/Ribbon.tsx
2904
3123
  function Ribbon(props) {
2905
- const { ribbonType, headerMenuComponents, headerMenu = true } = props;
2906
- const ribbonService = useDependency(IRibbonService);
3124
+ var _ribbonOverride$ribbo;
3125
+ const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false, headerClassName } = props;
3126
+ const defaultRibbonService = useDependency(IRibbonService);
3127
+ const ribbonOverrideService = useDependency(IRibbonOverrideService);
2907
3128
  const localeService = useDependency(LocaleService);
3129
+ const ribbonOverride = useObservable(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
3130
+ const ribbonService = (_ribbonOverride$ribbo = ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) !== null && _ribbonOverride$ribbo !== void 0 ? _ribbonOverride$ribbo : defaultRibbonService;
2908
3131
  const containerRef = useRef(null);
2909
3132
  const toolbarItemRefs = useRef({});
2910
3133
  const ribbonData = useObservable(ribbonService.ribbon$, []);
2911
3134
  const activatedTab = useObservable(ribbonService.activatedTab$, "ribbon.start");
2912
3135
  const collapsedIds = useObservable(ribbonService.collapsedIds$, []);
2913
3136
  const fakeToolbarVisible = useObservable(ribbonService.fakeToolbarVisible$, false);
3137
+ const hideToolbar = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.hideToolbar) === true;
2914
3138
  const ribbon = useMemo(() => {
2915
3139
  if (ribbonType === "simple") {
2916
3140
  const simpleRibbon = [{
@@ -2936,7 +3160,7 @@ function Ribbon(props) {
2936
3160
  const handleSelectTab = useCallback((group) => {
2937
3161
  toolbarItemRefs.current = {};
2938
3162
  ribbonService.setActivatedTab(group.key);
2939
- }, []);
3163
+ }, [ribbonService]);
2940
3164
  const activeGroup = useMemo(() => {
2941
3165
  var _ribbon$find$children, _ribbon$find2;
2942
3166
  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 : [];
@@ -2964,6 +3188,13 @@ function Ribbon(props) {
2964
3188
  activatedTab
2965
3189
  ]);
2966
3190
  useEffect(() => {
3191
+ if (hideToolbar) {
3192
+ toolbarItemRefs.current = {};
3193
+ ribbonService.setCollapsedIds([]);
3194
+ ribbonService.setFakeToolbarVisible(false);
3195
+ return;
3196
+ }
3197
+ if (!containerRef.current) return;
2967
3198
  let timer = null;
2968
3199
  const observer = new ResizeObserver(throttle((entries) => {
2969
3200
  for (const entry of entries) {
@@ -2993,7 +3224,12 @@ function Ribbon(props) {
2993
3224
  timer && cancelAnimationFrame(timer);
2994
3225
  observer.disconnect();
2995
3226
  };
2996
- }, [ribbon, activatedTab]);
3227
+ }, [
3228
+ hideToolbar,
3229
+ ribbon,
3230
+ activatedTab,
3231
+ ribbonService
3232
+ ]);
2997
3233
  const fakeToolbar = useMemo(() => {
2998
3234
  return /* @__PURE__ */ jsx("div", {
2999
3235
  "aria-hidden": "true",
@@ -3018,75 +3254,117 @@ function Ribbon(props) {
3018
3254
  })
3019
3255
  });
3020
3256
  }, [activeGroup.allGroups, fakeToolbarVisible]);
3021
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3022
- /* @__PURE__ */ jsxs("div", {
3023
- "data-u-comp": "ribbon-header-menu",
3024
- className: clsx("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
3025
- children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3026
- ribbon,
3027
- activatedTab,
3028
- onSelectTab: handleSelectTab
3029
- }), headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
3030
- 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",
3031
- children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
3032
- })]
3033
- }),
3034
- /* @__PURE__ */ jsxs("div", {
3035
- className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3036
- "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3037
- "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3038
- }, borderBottomClassName),
3039
- children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3040
- ribbon,
3041
- activatedTab,
3042
- onSelectTab: handleSelectTab
3043
- }), /* @__PURE__ */ jsxs("div", {
3044
- "data-u-comp": "ribbon-toolbar",
3045
- ref: containerRef,
3046
- className: clsx("univer-flex univer-overflow-hidden rtl:univer-divide-x-reverse", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3047
- role: "toolbar",
3048
- "aria-label": localeService.t(activatedTabTitle),
3049
- children: [activeGroup.visibleGroups.map((groupItem) => {
3050
- var _groupItem$children3, _groupItem$children4;
3051
- return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3052
- className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3053
- children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3054
- }) }, groupItem.key);
3055
- }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
3056
- "data-u-comp": "ribbon-toolbar-more",
3057
- className: "univer-pl-2 rtl:univer-pr-2",
3058
- children: /* @__PURE__ */ jsx(Dropdown, {
3059
- collisionPadding: {
3060
- right: 12,
3061
- left: 12
3062
- },
3063
- onOpenAutoFocus: (e) => e.preventDefault(),
3064
- overlay: /* @__PURE__ */ jsx("div", {
3065
- className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3066
- children: activeGroup.hiddenGroups.map((groupItem) => {
3067
- var _groupItem$children5;
3068
- return /* @__PURE__ */ jsx("div", {
3069
- className: "univer-flex univer-items-center univer-gap-2",
3070
- children: /* @__PURE__ */ jsx("div", {
3071
- className: "univer-flex univer-flex-wrap univer-gap-2",
3072
- children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
3073
- })
3074
- }, groupItem.key);
3075
- })
3076
- }),
3077
- children: /* @__PURE__ */ jsx("button", {
3078
- type: "button",
3079
- className: toolbarButtonClassName,
3080
- "aria-label": localeService.t("ui.ribbon.more"),
3081
- "aria-haspopup": "true",
3082
- children: /* @__PURE__ */ jsx(MoreVerticalIcon, {})
3257
+ const embedRibbonOverrideAttributes = ribbonOverride ? {
3258
+ "data-embed-ribbon-override": "true",
3259
+ "data-embed-id": ribbonOverride.id
3260
+ } : {};
3261
+ return /* @__PURE__ */ jsx(RibbonOverrideRuntimeProvider, {
3262
+ override: ribbonOverride,
3263
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
3264
+ /* @__PURE__ */ jsxs("div", {
3265
+ "data-u-comp": "ribbon-header-menu",
3266
+ ...embedRibbonOverrideAttributes,
3267
+ className: clsx("univer-relative univer-select-none", headerClassName, {
3268
+ "univer-hidden": toolbarOnly,
3269
+ "univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
3270
+ }),
3271
+ children: [
3272
+ !toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ jsx("div", {
3273
+ className: clsx("univer-flex univer-h-9 univer-items-end univer-px-3", { "univer-justify-center": hideToolbar }),
3274
+ children: /* @__PURE__ */ jsx("span", {
3275
+ 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",
3276
+ children: ribbonOverride.placeholderTitle
3083
3277
  })
3278
+ }),
3279
+ !toolbarOnly && ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ jsx(ClassicMenu, {
3280
+ ribbon,
3281
+ activatedTab,
3282
+ onSelectTab: handleSelectTab
3283
+ }),
3284
+ headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ jsx("div", {
3285
+ 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",
3286
+ children: /* @__PURE__ */ jsx(ComponentContainer, { components: headerMenuComponents })
3084
3287
  })
3288
+ ]
3289
+ }),
3290
+ !hideToolbar && /* @__PURE__ */ jsxs("div", {
3291
+ ...embedRibbonOverrideAttributes,
3292
+ className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3293
+ "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3294
+ "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
3295
+ }, borderBottomClassName),
3296
+ children: [ribbonType === "collapsed" && ribbon.length >= 1 && /* @__PURE__ */ jsx(DefaultMenu, {
3297
+ ribbon,
3298
+ activatedTab,
3299
+ onSelectTab: handleSelectTab
3300
+ }), /* @__PURE__ */ jsx("div", {
3301
+ "data-u-comp": "ribbon-toolbar",
3302
+ ref: containerRef,
3303
+ className: clsx("univer-flex univer-overflow-hidden", divideXClassName, { "univer-justify-center": ribbonType === "classic" }),
3304
+ role: "toolbar",
3305
+ "aria-label": localeService.t(activatedTabTitle),
3306
+ children: /* @__PURE__ */ jsxs(ToolbarDropdownProvider, { children: [activeGroup.visibleGroups.map((groupItem) => {
3307
+ var _groupItem$children3, _groupItem$children4;
3308
+ return (((_groupItem$children3 = groupItem.children) === null || _groupItem$children3 === void 0 ? void 0 : _groupItem$children3.length) || groupItem.item) && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
3309
+ className: "univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2 empty:univer-hidden",
3310
+ children: groupItem.children && ((_groupItem$children4 = groupItem.children) === null || _groupItem$children4 === void 0 ? void 0 : _groupItem$children4.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)))
3311
+ }) }, groupItem.key);
3312
+ }), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
3313
+ className: "univer-pl-2 rtl:univer-pr-2",
3314
+ children: /* @__PURE__ */ jsx(Dropdown, {
3315
+ collisionPadding: {
3316
+ right: 12,
3317
+ left: 12
3318
+ },
3319
+ onOpenAutoFocus: (e) => e.preventDefault(),
3320
+ overlay: /* @__PURE__ */ jsx("div", {
3321
+ className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
3322
+ children: activeGroup.hiddenGroups.map((groupItem) => {
3323
+ var _groupItem$children5;
3324
+ return /* @__PURE__ */ jsx("div", {
3325
+ className: "univer-flex univer-items-center univer-gap-2",
3326
+ children: /* @__PURE__ */ jsx("div", {
3327
+ className: "univer-flex univer-flex-wrap univer-gap-2",
3328
+ children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, { ...child.item }, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
3329
+ })
3330
+ }, groupItem.key);
3331
+ })
3332
+ }),
3333
+ children: /* @__PURE__ */ jsx("button", {
3334
+ type: "button",
3335
+ className: toolbarButtonClassName,
3336
+ children: /* @__PURE__ */ jsx(MoreVerticalIcon, {})
3337
+ })
3338
+ })
3339
+ })] }, activatedTab)
3085
3340
  })]
3086
- })]
3087
- }),
3088
- fakeToolbar
3089
- ] });
3341
+ }),
3342
+ fakeToolbar
3343
+ ] })
3344
+ });
3345
+ }
3346
+ function RibbonOverrideRuntimeProvider(props) {
3347
+ var _override$portalConta;
3348
+ const { override, children } = props;
3349
+ const config = useContext(ConfigContext);
3350
+ const injector = override === null || override === void 0 ? void 0 : override.injector;
3351
+ const ConnectedRibbonOverrideConfigProvider = useMemo(() => injector ? connectInjector(RibbonOverrideConfigProvider, injector) : null, [injector]);
3352
+ if (!override || !ConnectedRibbonOverrideConfigProvider) return children;
3353
+ return /* @__PURE__ */ jsx(ConnectedRibbonOverrideConfigProvider, {
3354
+ locale: config.locale,
3355
+ direction: config.direction,
3356
+ mountContainer: (_override$portalConta = override.portalContainer) !== null && _override$portalConta !== void 0 ? _override$portalConta : config.mountContainer,
3357
+ children
3358
+ });
3359
+ }
3360
+ function RibbonOverrideConfigProvider(props) {
3361
+ const { children, locale, direction, mountContainer } = props;
3362
+ return /* @__PURE__ */ jsx(ConfigProvider, {
3363
+ locale,
3364
+ direction,
3365
+ mountContainer,
3366
+ children
3367
+ });
3090
3368
  }
3091
3369
 
3092
3370
  //#endregion
@@ -3142,11 +3420,11 @@ var ContextMenuService = class extends Disposable {
3142
3420
  enable() {
3143
3421
  this.disabled = false;
3144
3422
  }
3145
- triggerContextMenu(event, menuType) {
3423
+ triggerContextMenu(event, menuType, context) {
3146
3424
  var _this$_currentHandler3;
3147
3425
  event.stopPropagation();
3148
3426
  if (this.disabled) return;
3149
- (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType);
3427
+ (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType, context);
3150
3428
  }
3151
3429
  hideContextMenu() {
3152
3430
  var _this$_currentHandler4;
@@ -3159,6 +3437,25 @@ var ContextMenuService = class extends Disposable {
3159
3437
  }
3160
3438
  };
3161
3439
 
3440
+ //#endregion
3441
+ //#region src/services/runtime-scope/ui-runtime-scope.service.ts
3442
+ const IUIRuntimeScopeService = createIdentifier("ui.runtime-scope.service");
3443
+ var UIRuntimeScopeService = class extends Disposable {
3444
+ constructor(..._args) {
3445
+ super(..._args);
3446
+ _defineProperty(this, "_scopes", /* @__PURE__ */ new Map());
3447
+ }
3448
+ register(scope) {
3449
+ this._scopes.set(scope.unitId, scope);
3450
+ return toDisposable(() => {
3451
+ if (this._scopes.get(scope.unitId) === scope) this._scopes.delete(scope.unitId);
3452
+ });
3453
+ }
3454
+ get(unitId) {
3455
+ return unitId ? this._scopes.get(unitId) : void 0;
3456
+ }
3457
+ };
3458
+
3162
3459
  //#endregion
3163
3460
  //#region src/services/contextmenu/contextmenu-host.service.ts
3164
3461
  const IContextMenuHostService = createIdentifier("ui.contextmenu.host.service");
@@ -3863,9 +4160,11 @@ function getContextMenuSubmenuPanelClassName(sizeVariant) {
3863
4160
  }
3864
4161
  function ContextMenuPanel(props) {
3865
4162
  var _layoutService$rootCo, _layoutService$rootCo2;
3866
- const { menuType, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
3867
- const menuManagerService = useDependency(IMenuManagerService);
3868
- const layoutService = useDependency(ILayoutService);
4163
+ const { menuType, menuManagerService: providedMenuManagerService, layoutService: providedLayoutService, menuSessionVersion = 0, className, activeItemIds, hiddenItemIds, sizeVariant = "default", autoFocus, autoFocusTarget = "first-item", suppressHoverUntilPointerMove = false, onCancel, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4164
+ const rootMenuManagerService = useDependency(IMenuManagerService);
4165
+ const rootLayoutService = useDependency(ILayoutService);
4166
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
4167
+ const layoutService = providedLayoutService !== null && providedLayoutService !== void 0 ? providedLayoutService : rootLayoutService;
3869
4168
  const [menuElement, setMenuElement] = useState(null);
3870
4169
  const [maxMenuHeight, setMaxMenuHeight] = useState(() => {
3871
4170
  if (typeof window === "undefined") return 240;
@@ -3968,6 +4267,7 @@ function ContextMenuPanel(props) {
3968
4267
  onWheel: (event) => event.stopPropagation(),
3969
4268
  children: /* @__PURE__ */ jsx(ContextMenuMenu, {
3970
4269
  menuSchemas: menuItems,
4270
+ menuManagerService,
3971
4271
  menuSessionVersion,
3972
4272
  submenuPortalContainer,
3973
4273
  rootMenuElement: menuElement,
@@ -3983,7 +4283,7 @@ function ContextMenuPanel(props) {
3983
4283
  });
3984
4284
  }
3985
4285
  function ContextMenuMenu(props) {
3986
- const { menuSchemas, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
4286
+ const { menuSchemas, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, activeItemIds, hiddenItemIds, hoverSuppressed, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect, maxMenuHeight } = props;
3987
4287
  const localeService = useDependency(LocaleService);
3988
4288
  const hiddenGroupStates = useContextGroupHiddenStates$1(menuSchemas);
3989
4289
  const [activeSubmenuKey, setActiveSubmenuKey] = useState(null);
@@ -4029,6 +4329,7 @@ function ContextMenuMenu(props) {
4029
4329
  if (menuSchema.item) return /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4030
4330
  menuKey: menuSchema.key,
4031
4331
  menuItem: menuSchema.item,
4332
+ menuManagerService,
4032
4333
  menuSessionVersion,
4033
4334
  submenuPortalContainer,
4034
4335
  rootMenuElement,
@@ -4049,6 +4350,7 @@ function ContextMenuMenu(props) {
4049
4350
  children: menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4050
4351
  menuKey: childSchema.key,
4051
4352
  menuItem: childSchema.item,
4353
+ menuManagerService,
4052
4354
  menuSessionVersion,
4053
4355
  submenuPortalContainer,
4054
4356
  rootMenuElement,
@@ -4070,6 +4372,7 @@ function ContextMenuMenu(props) {
4070
4372
  children: [titleNode, menuSchema.children.map((childSchema) => childSchema.item && /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4071
4373
  menuKey: childSchema.key,
4072
4374
  menuItem: childSchema.item,
4375
+ menuManagerService,
4073
4376
  menuSessionVersion,
4074
4377
  submenuPortalContainer,
4075
4378
  rootMenuElement,
@@ -4098,6 +4401,7 @@ function ContextMenuMenu(props) {
4098
4401
  children: [titleContent, /* @__PURE__ */ jsx(ContextMenuMenuItem, {
4099
4402
  menuKey: `${menuSchema.key}-header-action`,
4100
4403
  menuItem: menuSchema.headerActionItem,
4404
+ menuManagerService,
4101
4405
  menuSessionVersion,
4102
4406
  submenuPortalContainer,
4103
4407
  rootMenuElement,
@@ -4118,10 +4422,9 @@ function ContextMenuMenu(props) {
4118
4422
  }
4119
4423
  }
4120
4424
  function ContextMenuMenuItem(props) {
4121
- const { menuKey, menuItem, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4425
+ const { menuKey, menuItem, menuManagerService, menuSessionVersion, submenuPortalContainer, rootMenuElement, maxMenuHeight, activeSubmenuKey, setActiveSubmenuKey, activeItemIds, hiddenItemIds = [], hoverSuppressed = false, compact = false, headerAction = false, sizeVariant, onMenuPointerEnter, onMenuPointerLeave, onOptionSelect } = props;
4122
4426
  const localeService = useDependency(LocaleService);
4123
4427
  const direction = useObservable(localeService.direction$);
4124
- const menuManagerService = useDependency(IMenuManagerService);
4125
4428
  const disabled = useObservable(menuItem.disabled$, false);
4126
4429
  const activated = useObservable(menuItem.activated$, false);
4127
4430
  const hidden = useObservable(menuItem.hidden$, false);
@@ -4253,6 +4556,7 @@ function ContextMenuMenuItem(props) {
4253
4556
  });
4254
4557
  const canExecuteItem = menuItem.type === 0 || menuItem.type === 2;
4255
4558
  const renderAsContainer = isNonSelectableLabel(menuItem.label);
4559
+ const SubmenuAffordanceIcon = direction === "rtl" ? MoreLeftIcon : MoreRightIcon;
4256
4560
  const interactiveItemClassName = clsx(itemClassName, isNonHoverableLabel(menuItem.label) && "hover:univer-bg-transparent dark:hover:!univer-bg-transparent");
4257
4561
  return /* @__PURE__ */ jsxs("div", {
4258
4562
  ref: menuItemElementRef,
@@ -4281,7 +4585,7 @@ function ContextMenuMenuItem(props) {
4281
4585
  children: [renderAsContainer ? /* @__PURE__ */ jsxs("div", {
4282
4586
  className: interactiveItemClassName,
4283
4587
  "aria-disabled": disabled,
4284
- children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(MoreRightIcon, { className: `
4588
+ children: [contentNode, hasSubmenu && /* @__PURE__ */ jsx(SubmenuAffordanceIcon, { className: `
4285
4589
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4286
4590
  univer-text-gray-400
4287
4591
  dark:!univer-text-gray-200
@@ -4324,7 +4628,7 @@ function ContextMenuMenuItem(props) {
4324
4628
  label: menuKey
4325
4629
  });
4326
4630
  },
4327
- children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(MoreRightIcon, { className: `
4631
+ children: [contentNode, hasSubmenu && !compact && /* @__PURE__ */ jsx(SubmenuAffordanceIcon, { className: `
4328
4632
  ${sizeVariant === "paragraph-t" ? "univer-size-4" : "univer-size-3.5"}
4329
4633
  univer-text-gray-400
4330
4634
  dark:!univer-text-gray-200
@@ -4371,7 +4675,7 @@ function ContextMenuMenuItem(props) {
4371
4675
  const optionSelected = typeof inputValue !== "undefined" && String(inputValue) === String(option.value);
4372
4676
  const optionSelectable = !isNonSelectableLabel(option.label);
4373
4677
  const optionHoverable = !isNonHoverableLabel(option.label);
4374
- const optionClassName = 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");
4678
+ const optionClassName = 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");
4375
4679
  const optionContentNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [optionSelectable && optionSelected && /* @__PURE__ */ jsx(CheckMarkIcon, { className: clsx("univer-absolute univer-left-0 univer-text-primary-600", sizeVariant === "paragraph-t" ? "univer-size-5" : "univer-size-4") }), /* @__PURE__ */ jsx("span", {
4376
4680
  className: clsx(getContextMenuContentClassName(sizeVariant), optionSelectable && optionSelected && "univer-pl-4"),
4377
4681
  children: /* @__PURE__ */ jsx(CustomLabel, {
@@ -4413,6 +4717,7 @@ function ContextMenuMenuItem(props) {
4413
4717
  })
4414
4718
  }), hasSubItemSubmenu && /* @__PURE__ */ jsx(ContextMenuMenu, {
4415
4719
  menuSchemas: subMenuItems,
4720
+ menuManagerService,
4416
4721
  menuSessionVersion,
4417
4722
  submenuPortalContainer,
4418
4723
  rootMenuElement,
@@ -4457,7 +4762,7 @@ function useContextGroupHiddenStates$1(menuSchemas) {
4457
4762
  //#endregion
4458
4763
  //#region src/views/components/context-menu/AnchoredContextMenu.tsx
4459
4764
  function AnchoredContextMenu(props) {
4460
- const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, onRequestClose, onOptionSelect } = props;
4765
+ const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, menuManagerService, layoutService, onRequestClose, onOptionSelect } = props;
4461
4766
  const contentRef = useRef(null);
4462
4767
  const contextMenuHostService = useDependency(IContextMenuHostService);
4463
4768
  const onRequestCloseRef = useRef(onRequestClose);
@@ -4546,6 +4851,8 @@ function AnchoredContextMenu(props) {
4546
4851
  ref: contentRef,
4547
4852
  children: menuType && /* @__PURE__ */ jsx(ContextMenuPanel, {
4548
4853
  menuType,
4854
+ menuManagerService,
4855
+ layoutService,
4549
4856
  menuSessionVersion: menuSessionVersionRef.current,
4550
4857
  onOptionSelect
4551
4858
  })
@@ -4560,10 +4867,13 @@ function DesktopContextMenu() {
4560
4867
  const [visible, setVisible] = useState(false);
4561
4868
  const [menuType, setMenuType] = useState("");
4562
4869
  const [anchorRect, setAnchorRect] = useState(null);
4870
+ const [menuContext, setMenuContext] = useState();
4563
4871
  const visibleRef = useRef(visible);
4564
4872
  const contextMenuService = useDependency(IContextMenuService);
4565
4873
  const commandService = useDependency(ICommandService);
4566
- const injector = useInjector();
4874
+ const layoutService = useDependency(ILayoutService);
4875
+ const menuManagerService = useDependency(IMenuManagerService);
4876
+ const runtimeScopeService = useDependency(IUIRuntimeScopeService);
4567
4877
  visibleRef.current = visible;
4568
4878
  useEffect(() => {
4569
4879
  const disposables = contextMenuService.registerContextMenuHandler({
@@ -4580,10 +4890,11 @@ function DesktopContextMenu() {
4580
4890
  };
4581
4891
  }, [contextMenuService]);
4582
4892
  /** A function to open context menu with given position and menu type. */
4583
- function handleContextMenu(event, menuType) {
4893
+ function handleContextMenu(event, menuType, context) {
4584
4894
  setVisible(false);
4585
4895
  requestAnimationFrame(() => {
4586
4896
  setMenuType(menuType);
4897
+ setMenuContext(context);
4587
4898
  setAnchorRect({
4588
4899
  left: event.clientX,
4589
4900
  top: event.clientY,
@@ -4595,18 +4906,24 @@ function DesktopContextMenu() {
4595
4906
  function handleClose() {
4596
4907
  setVisible(false);
4597
4908
  }
4909
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
4910
+ const activeMenuManagerService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService;
4911
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ICommandService)) ? activeScope.get(ICommandService) : commandService;
4912
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
4598
4913
  return /* @__PURE__ */ jsx(AnchoredContextMenu, {
4599
4914
  hostId: DESKTOP_CONTEXT_MENU_HOST_ID,
4600
4915
  visible,
4601
4916
  anchorRect,
4602
4917
  menuType,
4918
+ menuManagerService: activeMenuManagerService,
4919
+ layoutService: activeLayoutService,
4603
4920
  onRequestClose: handleClose,
4604
4921
  onOptionSelect: (params) => {
4605
4922
  const { label: id, commandId, value } = params;
4606
4923
  const rawParams = typeof params.params === "function" ? params.params() : params.params;
4607
4924
  const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
4608
- if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4609
- injector.get(ILayoutService).focus();
4925
+ if (activeCommandService) activeCommandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4926
+ activeLayoutService.focus();
4610
4927
  handleClose();
4611
4928
  }
4612
4929
  });
@@ -5182,7 +5499,9 @@ var SingleUnitUIController = class extends Disposable {
5182
5499
  }));
5183
5500
  }
5184
5501
  _changeRenderUnit(rendererId, contentElement) {
5502
+ var _this$_instanceServic2;
5185
5503
  if (this._currentRenderId === rendererId) return false;
5504
+ if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
5186
5505
  const renderer = this._renderManagerService.getRenderById(rendererId);
5187
5506
  if (!renderer || !renderer.unitId || isInternalEditorID(renderer.unitId)) return false;
5188
5507
  const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderById(this._currentRenderId) : null;
@@ -5260,7 +5579,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
5260
5579
  //#endregion
5261
5580
  //#region package.json
5262
5581
  var name = "@univerjs/ui";
5263
- var version = "1.0.0-alpha.2";
5582
+ var version = "1.0.0-alpha.3";
5264
5583
 
5265
5584
  //#endregion
5266
5585
  //#region src/views/color-picker/interface.ts
@@ -20290,15 +20609,13 @@ function EmojiPicker(props) {
20290
20609
  children: [
20291
20610
  /* @__PURE__ */ jsxs("div", {
20292
20611
  className: "univer-flex univer-items-center univer-gap-1 univer-px-3 univer-pb-2 univer-pt-3",
20293
- children: [/* @__PURE__ */ jsxs("label", {
20294
- 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",
20295
- children: [/* @__PURE__ */ jsx(SearchIcon, {}), /* @__PURE__ */ jsx(Input, {
20296
- "aria-label": localeService.t("ui.emojiPicker.search"),
20297
- placeholder: localeService.t("ui.emojiPicker.search"),
20298
- className: "univer-min-w-0 univer-flex-1",
20299
- value: query,
20300
- onChange: setQuery
20301
- })]
20612
+ children: [/* @__PURE__ */ jsx(Input, {
20613
+ "aria-label": localeService.t("ui.emojiPicker.search"),
20614
+ placeholder: localeService.t("ui.emojiPicker.search"),
20615
+ className: "univer-min-w-0 univer-flex-1",
20616
+ value: query,
20617
+ onChange: setQuery,
20618
+ slot: /* @__PURE__ */ jsx(SearchIcon, { className: "univer-size-4 univer-text-gray-500 dark:!univer-text-gray-400" })
20302
20619
  }), /* @__PURE__ */ jsx("button", {
20303
20620
  type: "button",
20304
20621
  "aria-label": localeService.t("ui.emojiPicker.random"),
@@ -20332,12 +20649,12 @@ function EmojiPicker(props) {
20332
20649
  className: 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", borderTopClassName),
20333
20650
  children: [/* @__PURE__ */ jsx(CategoryButton, {
20334
20651
  selected: !isSearching && activeTab === "recent",
20335
- title: localeService.t("ui.emojiPicker.recents"),
20652
+ titleKey: "ui.emojiPicker.recents",
20336
20653
  onClick: () => scrollToSection("recent"),
20337
20654
  children: /* @__PURE__ */ jsx(RecentIcon, {})
20338
20655
  }), EMOJI_CATEGORIES.map((category) => /* @__PURE__ */ jsx(CategoryButton, {
20339
20656
  selected: !isSearching && activeTab === category.key,
20340
- title: localeService.t(category.titleKey),
20657
+ titleKey: category.titleKey,
20341
20658
  onClick: () => scrollToSection(category.key),
20342
20659
  children: /* @__PURE__ */ jsx(CategoryIcon, { category: category.key })
20343
20660
  }, category.key))]
@@ -20378,11 +20695,12 @@ function EmojiGrid(props) {
20378
20695
  });
20379
20696
  }
20380
20697
  function CategoryButton(props) {
20698
+ const localeService = useDependency(LocaleService);
20381
20699
  return /* @__PURE__ */ jsx("button", {
20382
20700
  type: "button",
20383
- "aria-label": props.title,
20701
+ "aria-label": localeService.t(props.titleKey),
20384
20702
  "aria-selected": props.selected,
20385
- title: props.title,
20703
+ title: localeService.t(props.titleKey),
20386
20704
  className: 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"),
20387
20705
  onClick: props.onClick,
20388
20706
  children: props.children
@@ -20652,11 +20970,13 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
20652
20970
  const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
20653
20971
  const FontFamilyItem = ({ value, onChange }) => {
20654
20972
  const localeService = useDependency(LocaleService);
20973
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
20655
20974
  const { fonts, fontService } = useFontList();
20656
20975
  function handleSelectFont(nextValue) {
20657
20976
  onChange(nextValue);
20658
20977
  }
20659
20978
  return /* @__PURE__ */ jsx("ul", {
20979
+ dir: direction,
20660
20980
  className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
20661
20981
  style: { fontFamily: value },
20662
20982
  children: fonts.map((font) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
@@ -20676,6 +20996,8 @@ const FontFamilyItem = ({ value, onChange }) => {
20676
20996
  //#region src/views/font-family/FontFamilyDropdown.tsx
20677
20997
  function FontFamilyDropdown(props) {
20678
20998
  const { value, onChange, ariaLabel, className, disabled: disabledProp, disabled$, inputClassName, popupClassName, popupDataComponent, title, onMouseDown, onPointerDown } = props;
20999
+ const localeService = useDependency(LocaleService);
21000
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
20679
21001
  const disabledObservableValue = useObservable(disabled$);
20680
21002
  const disabled = Boolean(disabledProp || disabledObservableValue);
20681
21003
  const [open, setOpen] = useState(false);
@@ -20689,6 +21011,7 @@ function FontFamilyDropdown(props) {
20689
21011
  open,
20690
21012
  onOpenChange: setOpen,
20691
21013
  overlay: /* @__PURE__ */ jsx("div", {
21014
+ dir: direction,
20692
21015
  className: 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),
20693
21016
  ...popupDataAttributes,
20694
21017
  children: /* @__PURE__ */ jsx(FontFamilyItem, {
@@ -20700,6 +21023,7 @@ function FontFamilyDropdown(props) {
20700
21023
  "aria-disabled": disabled,
20701
21024
  "aria-expanded": open,
20702
21025
  "aria-label": ariaLabel,
21026
+ dir: direction,
20703
21027
  className: 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),
20704
21028
  role: "combobox",
20705
21029
  tabIndex: disabled ? -1 : 0,
@@ -21187,14 +21511,6 @@ ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)),
21187
21511
  //#endregion
21188
21512
  //#region src/views/components/ribbon/MobileRibbon.tsx
21189
21513
  const toolbarScrollOffset = 168;
21190
- const nestedControlResetClassName = `
21191
- [&_button]:!univer-m-0 [&_button]:!univer-appearance-none [&_button]:!univer-border-0
21192
- [&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-leading-none
21193
- [&_button]:!univer-outline-none
21194
- [&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0
21195
- [&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none
21196
- [&_input]:!univer-outline-none
21197
- `;
21198
21514
  function MobileRibbon(props) {
21199
21515
  var _activeGroup$children;
21200
21516
  const { headerMenuComponents, headerMenu = true } = props;
@@ -21334,7 +21650,7 @@ function MobileRibbon(props) {
21334
21650
  return /* @__PURE__ */ jsx("div", {
21335
21651
  className: 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", { [borderRightClassName]: groupIndex !== activeGroups.length - 1 }),
21336
21652
  children: groupItems.map((child) => child.item && /* @__PURE__ */ jsx("div", {
21337
- className: 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),
21653
+ className: 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"),
21338
21654
  children: /* @__PURE__ */ jsx(ToolbarItem, { ...child.item })
21339
21655
  }, child.key))
21340
21656
  }, groupItem.key);
@@ -21361,8 +21677,9 @@ function MobileRibbon(props) {
21361
21677
  //#region src/views/menu/mobile/MobileMenu.tsx
21362
21678
  function MobileMenu(props) {
21363
21679
  var _viewStack;
21364
- const { menuType, onOptionSelect, schemas: providedSchemas } = props;
21365
- const menuManagerService = useDependency(IMenuManagerService);
21680
+ const { menuType, onOptionSelect, schemas: providedSchemas, menuManagerService: providedMenuManagerService } = props;
21681
+ const rootMenuManagerService = useDependency(IMenuManagerService);
21682
+ const menuManagerService = providedMenuManagerService !== null && providedMenuManagerService !== void 0 ? providedMenuManagerService : rootMenuManagerService;
21366
21683
  const [viewStack, setViewStack] = useState([]);
21367
21684
  const menuSchemas = useMemo(() => {
21368
21685
  if (providedSchemas) return providedSchemas;
@@ -21410,6 +21727,7 @@ function MobileMenu(props) {
21410
21727
  className: "univer-overflow-hidden univer-rounded-2xl univer-bg-white",
21411
21728
  children: /* @__PURE__ */ jsx(MobileSchemaList, {
21412
21729
  schemas: (currentView === null || currentView === void 0 ? void 0 : currentView.kind) === "schema" ? currentView.schemas : menuSchemas,
21730
+ menuManagerService,
21413
21731
  menuType,
21414
21732
  onExecute: onOptionSelect,
21415
21733
  onOpenView: openView
@@ -21428,7 +21746,7 @@ function MobileMenu(props) {
21428
21746
  });
21429
21747
  }
21430
21748
  function MobileSchemaList(props) {
21431
- const { schemas, menuType, onExecute, onOpenView } = props;
21749
+ const { schemas, menuManagerService, menuType, onExecute, onOpenView } = props;
21432
21750
  const localeService = useDependency(LocaleService);
21433
21751
  const hiddenGroupStates = useContextGroupHiddenStates(schemas);
21434
21752
  const visibleSchemas = useMemo(() => {
@@ -21442,6 +21760,7 @@ function MobileSchemaList(props) {
21442
21760
  var _schema$children2;
21443
21761
  if (schema.item) return /* @__PURE__ */ jsx(MobileSchemaRow, {
21444
21762
  schema,
21763
+ menuManagerService,
21445
21764
  menuType,
21446
21765
  onExecute,
21447
21766
  onOpenView,
@@ -21455,6 +21774,7 @@ function MobileSchemaList(props) {
21455
21774
  children: localeService.t(schema.title)
21456
21775
  }), schema.children.map((childSchema, childIndex) => /* @__PURE__ */ jsx(MobileSchemaRow, {
21457
21776
  schema: childSchema,
21777
+ menuManagerService,
21458
21778
  menuType,
21459
21779
  onExecute,
21460
21780
  onOpenView,
@@ -21464,9 +21784,10 @@ function MobileSchemaList(props) {
21464
21784
  }) });
21465
21785
  }
21466
21786
  function MobileSchemaRow(props) {
21467
- const { schema, menuType, onExecute, onOpenView, bordered } = props;
21787
+ const { schema, menuManagerService, menuType, onExecute, onOpenView, bordered } = props;
21468
21788
  const interaction = useMobileSchemaInteraction({
21469
21789
  schema,
21790
+ menuManagerService,
21470
21791
  menuType,
21471
21792
  onOpenView
21472
21793
  });
@@ -21541,8 +21862,7 @@ function MobileSelectionOptionRow(props) {
21541
21862
  }
21542
21863
  function useMobileSchemaInteraction(props) {
21543
21864
  var _schema$children3;
21544
- const { schema, menuType, onOpenView } = props;
21545
- const menuManagerService = useDependency(IMenuManagerService);
21865
+ const { schema, menuManagerService, menuType, onOpenView } = props;
21546
21866
  const localeService = useDependency(LocaleService);
21547
21867
  const menuItem = schema.item;
21548
21868
  const selectorItem = menuItem;
@@ -21663,11 +21983,14 @@ const MOBILE_CONTEXT_MENU_HOST_ID = "mobile-context-menu";
21663
21983
  function MobileContextMenu() {
21664
21984
  const [visible, setVisible] = useState(false);
21665
21985
  const [menuType, setMenuType] = useState("");
21986
+ const [menuContext, setMenuContext] = useState();
21666
21987
  const visibleRef = useRef(visible);
21667
21988
  const contextMenuHostService = useDependency(IContextMenuHostService);
21668
21989
  const contextMenuService = useDependency(IContextMenuService);
21669
21990
  const commandService = useDependency(ICommandService);
21670
21991
  const layoutService = useDependency(ILayoutService);
21992
+ const menuManagerService = useDependency(IMenuManagerService);
21993
+ const runtimeScopeService = useDependency(IUIRuntimeScopeService);
21671
21994
  const localeService = useDependency(LocaleService);
21672
21995
  const direction = useObservable(localeService.direction$);
21673
21996
  const { mountContainer } = useContext(ConfigContext);
@@ -21691,9 +22014,10 @@ function MobileContextMenu() {
21691
22014
  contextMenuHostService.deactivateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21692
22015
  };
21693
22016
  }, [contextMenuHostService, contextMenuService]);
21694
- function handleContextMenu(_event, nextMenuType) {
22017
+ function handleContextMenu(_event, nextMenuType, context) {
21695
22018
  contextMenuHostService.activateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21696
22019
  setMenuType(nextMenuType);
22020
+ setMenuContext(context);
21697
22021
  setVisible(true);
21698
22022
  }
21699
22023
  function handleClose() {
@@ -21708,6 +22032,23 @@ function MobileContextMenu() {
21708
22032
  }
21709
22033
  }, [localeService, menuType]);
21710
22034
  if (!mountContainer || !visible) return null;
22035
+ const activeScope = runtimeScopeService.get(menuContext === null || menuContext === void 0 ? void 0 : menuContext.unitId);
22036
+ const activeCommandService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ICommandService)) ? activeScope.get(ICommandService) : commandService;
22037
+ const activeLayoutService = (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(ILayoutService)) ? activeScope.get(ILayoutService) : layoutService;
22038
+ const menu = /* @__PURE__ */ jsx(MobileMenu, {
22039
+ menuType,
22040
+ menuManagerService: (activeScope === null || activeScope === void 0 ? void 0 : activeScope.has(IMenuManagerService)) ? activeScope.get(IMenuManagerService) : menuManagerService,
22041
+ onOptionSelect: (params) => {
22042
+ var _ref, _params$commandId;
22043
+ const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
22044
+ const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
22045
+ const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
22046
+ if (!commandId) return;
22047
+ activeLayoutService.focus();
22048
+ activeCommandService.executeCommand(commandId, commandParams);
22049
+ handleClose();
22050
+ }
22051
+ });
21711
22052
  return createPortal(/* @__PURE__ */ jsxs("div", {
21712
22053
  dir: direction,
21713
22054
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
@@ -21741,19 +22082,7 @@ function MobileContextMenu() {
21741
22082
  children: /* @__PURE__ */ jsx(CloseIcon, { className: "univer-size-4 univer-text-current" })
21742
22083
  })]
21743
22084
  })]
21744
- }), menuType && /* @__PURE__ */ jsx(MobileMenu, {
21745
- menuType,
21746
- onOptionSelect: (params) => {
21747
- var _ref, _params$commandId;
21748
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
21749
- const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
21750
- const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
21751
- if (!commandId) return;
21752
- layoutService.focus();
21753
- commandService.executeCommand(commandId, commandParams);
21754
- handleClose();
21755
- }
21756
- })]
22085
+ }), menuType && menu]
21757
22086
  })]
21758
22087
  }), mountContainer);
21759
22088
  }
@@ -23118,6 +23447,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23118
23447
  [IMenuManagerService, { useClass: MenuManagerService }],
23119
23448
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23120
23449
  [IContextMenuService, { useClass: ContextMenuService }],
23450
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23121
23451
  [IClipboardInterfaceService, {
23122
23452
  useClass: BrowserClipboardService,
23123
23453
  lazy: true
@@ -23155,6 +23485,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends Plugin {
23155
23485
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23156
23486
  [IFontService, { useClass: FontService }],
23157
23487
  [CanvasFloatDomService],
23488
+ [CanvasFloatDomPreviewService],
23158
23489
  [IUIController, {
23159
23490
  useFactory: (injector) => injector.createInstance(MobileUIController, this._config),
23160
23491
  deps: [Injector]
@@ -23212,11 +23543,13 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23212
23543
  [IUIPartsService, { useClass: UIPartsService }],
23213
23544
  [ILayoutService, { useClass: DesktopLayoutService }],
23214
23545
  [IRibbonService, { useClass: DesktopRibbonService }],
23546
+ [IRibbonOverrideService, { useClass: RibbonOverrideService }],
23215
23547
  [IShortcutService, { useClass: ShortcutService }],
23216
23548
  [IPlatformService, { useClass: PlatformService }],
23217
23549
  [IMenuManagerService, { useClass: MenuManagerService }],
23218
23550
  [IContextMenuHostService, { useClass: ContextMenuHostService }],
23219
23551
  [IContextMenuService, { useClass: ContextMenuService }],
23552
+ [IUIRuntimeScopeService, { useClass: UIRuntimeScopeService }],
23220
23553
  [IClipboardInterfaceService, {
23221
23554
  useClass: BrowserClipboardService,
23222
23555
  lazy: true
@@ -23254,6 +23587,7 @@ let UniverUIPlugin = class UniverUIPlugin extends Plugin {
23254
23587
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23255
23588
  [IFontService, { useClass: FontService }],
23256
23589
  [CanvasFloatDomService],
23590
+ [CanvasFloatDomPreviewService],
23257
23591
  [IUIController, {
23258
23592
  useFactory: (injector) => injector.createInstance(DesktopUIController, this._config),
23259
23593
  deps: [Injector]
@@ -23967,16 +24301,16 @@ const PrintFloatDomSingle = memo((props) => {
23967
24301
  transform: transformRef.current
23968
24302
  },
23969
24303
  onPointerMove: (e) => {
23970
- layer.onPointerMove(e.nativeEvent);
24304
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
23971
24305
  },
23972
24306
  onPointerDown: (e) => {
23973
- layer.onPointerDown(e.nativeEvent);
24307
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
23974
24308
  },
23975
24309
  onPointerUp: (e) => {
23976
- layer.onPointerUp(e.nativeEvent);
24310
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
23977
24311
  },
23978
24312
  onWheel: (e) => {
23979
- layer.onWheel(e.nativeEvent);
24313
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
23980
24314
  },
23981
24315
  children: /* @__PURE__ */ jsx("div", {
23982
24316
  ref: innerDomRef,
@@ -24071,4 +24405,4 @@ function ProgressBar(props) {
24071
24405
  }
24072
24406
 
24073
24407
  //#endregion
24074
- export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
24408
+ export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileContextMenu, MockMessageService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, ThemeSwitcherService, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoShortcutItem, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, ZIndexManager, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };