@univerjs/ui 1.0.0-alpha.1 → 1.0.0-insiders.20260701-0ef51b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -628,6 +628,7 @@ function fromGlobalEvent(type, listener, options) {
628
628
  //#endregion
629
629
  //#region src/services/layout/layout.service.ts
630
630
  const FOCUSING_UNIVER = "FOCUSING_UNIVER";
631
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE$1 = "data-embed-interaction-boundary-owner";
631
632
  const givingBackFocusElements = [
632
633
  "app-layout",
633
634
  "button",
@@ -705,7 +706,7 @@ let DesktopLayoutService = class DesktopLayoutService extends _univerjs_core.Dis
705
706
  this.disposeWithMe((0, rxjs.fromEvent)(window, "focusin").subscribe((event) => {
706
707
  var _this$_rootContainerE;
707
708
  const target = event.target;
708
- if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item)) {
709
+ if (((_this$_rootContainerE = this._rootContainerElement) === null || _this$_rootContainerE === void 0 ? void 0 : _this$_rootContainerE.contains(target)) && givingBackFocusElements.some((item) => target.dataset.uComp === item) && !isEmbedOwnedFocusTarget(target)) {
709
710
  queueMicrotask(() => this.focus());
710
711
  return;
711
712
  }
@@ -724,6 +725,10 @@ function getFocusingUniverEditorStatus() {
724
725
  var _document$activeEleme;
725
726
  return ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.dataset.uComp) === "editor";
726
727
  }
728
+ function isEmbedOwnedFocusTarget(target) {
729
+ var _target$closest;
730
+ return ((_target$closest = target.closest) === null || _target$closest === void 0 ? void 0 : _target$closest.call(target, `[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE$1}]`)) != null;
731
+ }
727
732
 
728
733
  //#endregion
729
734
  //#region src/services/platform/platform.service.ts
@@ -757,6 +762,7 @@ var PlatformService = class {
757
762
 
758
763
  //#endregion
759
764
  //#region src/services/shortcut/shortcut.service.ts
765
+ const EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
760
766
  /**
761
767
  * The dependency injection identifier of the {@link IShortcutService}.
762
768
  */
@@ -845,6 +851,7 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
845
851
  if (this._layoutService && !this._layoutService.checkElementInCurrentContainers(e.target)) return;
846
852
  const binding = this._deriveBindingFromEvent(e);
847
853
  if (binding === null) return;
854
+ if (this._shouldLetEmbedTextEditorHandleNativeShortcut(e, binding)) return;
848
855
  const shortcuts = this._shortCutMapping.get(binding);
849
856
  if (shortcuts === void 0) return;
850
857
  return Array.from(shortcuts).sort((s1, s2) => {
@@ -870,6 +877,12 @@ let ShortcutService = class ShortcutService extends _univerjs_core.Disposable {
870
877
  if (this._platformService.isMac && e.ctrlKey) binding |= 8192;
871
878
  return binding;
872
879
  }
880
+ _shouldLetEmbedTextEditorHandleNativeShortcut(e, binding) {
881
+ if (binding !== (65 | 4096)) return false;
882
+ const target = e.target;
883
+ if (!(target instanceof HTMLElement)) return false;
884
+ return (target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) && target.closest(`[${EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`) != null;
885
+ }
873
886
  };
874
887
  ShortcutService = __decorate([
875
888
  __decorateParam(0, _univerjs_core.ICommandService),
@@ -1051,8 +1064,9 @@ let ContextMenuGroup = /* @__PURE__ */ function(ContextMenuGroup) {
1051
1064
 
1052
1065
  //#endregion
1053
1066
  //#region src/services/menu/menu-manager.service.ts
1067
+ var _MenuManagerService;
1054
1068
  const IMenuManagerService = (0, _univerjs_core.createIdentifier)("univer.menu-manager-service");
1055
- let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposable {
1069
+ let MenuManagerService = _MenuManagerService = class MenuManagerService extends _univerjs_core.Disposable {
1056
1070
  constructor(_injector, _configService) {
1057
1071
  super();
1058
1072
  this._injector = _injector;
@@ -1186,6 +1200,21 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1186
1200
  this._menu = (0, _univerjs_core.merge)({}, this._menu, source);
1187
1201
  this.menuChanged$.next();
1188
1202
  }
1203
+ createScoped(injector) {
1204
+ const root = this;
1205
+ const createScopedBuilder = () => {
1206
+ const service = new _MenuManagerService(injector, root._configService);
1207
+ service._menu = root._menu;
1208
+ return service;
1209
+ };
1210
+ return {
1211
+ menuChanged$: root.menuChanged$,
1212
+ mergeMenu: (source, target) => root.mergeMenu(source, target),
1213
+ appendRootMenu: (source) => root.appendRootMenu(source),
1214
+ getMenuByPositionKey: (position) => createScopedBuilder().getMenuByPositionKey(position),
1215
+ getFlatMenuByPositionKey: (position) => createScopedBuilder().getFlatMenuByPositionKey(position)
1216
+ };
1217
+ }
1189
1218
  _buildMenuSchema(data) {
1190
1219
  const result = [];
1191
1220
  for (const [key, value] of Object.entries(data)) {
@@ -1225,6 +1254,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1225
1254
  * @returns Menu schema array or empty array if not found
1226
1255
  */
1227
1256
  getMenuByPositionKey(key) {
1257
+ var _findKey;
1228
1258
  const findKey = (obj) => {
1229
1259
  if (key in obj) return this._buildMenuSchema(obj[key]);
1230
1260
  for (const k in obj) {
@@ -1235,7 +1265,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1235
1265
  }
1236
1266
  }
1237
1267
  };
1238
- return findKey(this._menu);
1268
+ return (_findKey = findKey(this._menu)) !== null && _findKey !== void 0 ? _findKey : [];
1239
1269
  }
1240
1270
  /**
1241
1271
  * Get flat menu schema by position key
@@ -1257,7 +1287,7 @@ let MenuManagerService = class MenuManagerService extends _univerjs_core.Disposa
1257
1287
  return flatMenuItems(menu);
1258
1288
  }
1259
1289
  };
1260
- MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
1290
+ MenuManagerService = _MenuManagerService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(1, _univerjs_core.IConfigService)], MenuManagerService);
1261
1291
  function normalizeMenuOrder(order) {
1262
1292
  return order !== null && order !== void 0 ? order : 0;
1263
1293
  }
@@ -1469,6 +1499,12 @@ function useObservableRef(observable, defaultValue) {
1469
1499
 
1470
1500
  //#endregion
1471
1501
  //#region src/services/dom/canvas-dom-layer.service.ts
1502
+ function shouldForwardFloatDomEvents(layer) {
1503
+ return layer.eventPassThrough !== false;
1504
+ }
1505
+ function shouldRenderFloatDomLayer(layer, currentUnitId) {
1506
+ return layer.unitId === currentUnitId || layer.preserveOnFocusChange === true;
1507
+ }
1472
1508
  var CanvasFloatDomService = class {
1473
1509
  constructor() {
1474
1510
  _defineProperty(this, "_domLayerMap", /* @__PURE__ */ new Map());
@@ -1502,6 +1538,33 @@ var CanvasFloatDomService = class {
1502
1538
  this._notice();
1503
1539
  }
1504
1540
  };
1541
+ var CanvasFloatDomPreviewService = class {
1542
+ constructor() {
1543
+ _defineProperty(this, "previewUpdated$", new rxjs.Subject());
1544
+ _defineProperty(this, "previewRequested$", new rxjs.Subject());
1545
+ _defineProperty(this, "_previewMap", /* @__PURE__ */ new Map());
1546
+ _defineProperty(this, "_requestMap", /* @__PURE__ */ new Map());
1547
+ }
1548
+ getPreview(id) {
1549
+ return this._previewMap.get(id);
1550
+ }
1551
+ getPendingRequests() {
1552
+ return Array.from(this._requestMap.values());
1553
+ }
1554
+ setPreview(preview) {
1555
+ this._previewMap.set(preview.id, preview);
1556
+ this._requestMap.delete(preview.id);
1557
+ this.previewUpdated$.next(preview);
1558
+ }
1559
+ removePreview(id) {
1560
+ this._previewMap.delete(id);
1561
+ this._requestMap.delete(id);
1562
+ }
1563
+ requestPreview(request) {
1564
+ this._requestMap.set(request.id, request);
1565
+ this.previewRequested$.next(request);
1566
+ }
1567
+ };
1505
1568
 
1506
1569
  //#endregion
1507
1570
  //#region src/views/components/dom/FloatDom.tsx
@@ -1520,8 +1583,14 @@ const FloatDomSingle = (0, react.memo)((props) => {
1520
1583
  const Component = typeof layer.componentKey === "string" ? (0, _wendellhu_redi_react_bindings.useDependency)(ComponentManager).get(layer.componentKey) : layer.componentKey;
1521
1584
  const layerProps = (0, react.useMemo)(() => ({
1522
1585
  data: layer.data,
1523
- ...layer.props
1524
- }), [layer.data, layer.props]);
1586
+ ...layer.props,
1587
+ hostFloatDomLayout$: layer.position$
1588
+ }), [
1589
+ layer.data,
1590
+ layer.position$,
1591
+ layer.props
1592
+ ]);
1593
+ const floatDomOverflow = resolveFloatDomOverflow(layerProps);
1525
1594
  (0, react.useEffect)(() => {
1526
1595
  const subscription = layer.position$.subscribe((position) => {
1527
1596
  transformRef.current = `rotate(${position.rotate}deg)`;
@@ -1586,26 +1655,29 @@ const FloatDomSingle = (0, react.memo)((props) => {
1586
1655
  width: Math.max(position.endX - position.startX - 2, 0),
1587
1656
  height: Math.max(position.endY - position.startY - 2, 0),
1588
1657
  transform: transformRef.current,
1589
- overflow: "hidden",
1658
+ overflow: floatDomOverflow.outerOverflow,
1590
1659
  transformOrigin: "center center"
1591
1660
  },
1592
1661
  onPointerMove: (e) => {
1593
- layer.onPointerMove(e.nativeEvent);
1662
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
1594
1663
  },
1595
1664
  onPointerDown: (e) => {
1596
- layer.onPointerDown(e.nativeEvent);
1665
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
1597
1666
  },
1598
1667
  onPointerUp: (e) => {
1599
- layer.onPointerUp(e.nativeEvent);
1668
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
1600
1669
  },
1601
1670
  onWheel: (e) => {
1602
- layer.onWheel(e.nativeEvent);
1671
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
1603
1672
  },
1604
1673
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1605
1674
  id,
1606
1675
  ref: innerDomRef,
1607
1676
  className: "univer-absolute univer-overflow-hidden",
1608
- style: { ...innerStyle.current },
1677
+ style: {
1678
+ ...innerStyle.current,
1679
+ overflow: floatDomOverflow.innerOverflow
1680
+ },
1609
1681
  children: component
1610
1682
  })
1611
1683
  });
@@ -1614,9 +1686,8 @@ const FloatDom = ({ unitId }) => {
1614
1686
  var _layers$filter;
1615
1687
  const instanceService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.IUniverInstanceService);
1616
1688
  const layers = (0, _wendellhu_redi_react_bindings.useObservable)((0, _wendellhu_redi_react_bindings.useDependency)(CanvasFloatDomService).domLayers$);
1617
- const focusUnit = (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$);
1618
- const currentUnitId = unitId || focusUnit;
1619
- return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => layer[1].unitId === currentUnitId)) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1689
+ const currentUnitId = resolveFloatDomCurrentUnitId(unitId, (0, _wendellhu_redi_react_bindings.useObservable)(instanceService.focused$));
1690
+ return layers === null || layers === void 0 || (_layers$filter = layers.filter((layer) => shouldRenderFloatDomLayer(layer[1], currentUnitId))) === null || _layers$filter === void 0 ? void 0 : _layers$filter.map((layer) => {
1620
1691
  var _layer$1$domId;
1621
1692
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FloatDomSingle, {
1622
1693
  id: (_layer$1$domId = layer[1].domId) !== null && _layer$1$domId !== void 0 ? _layer$1$domId : layer[0],
@@ -1624,6 +1695,27 @@ const FloatDom = ({ unitId }) => {
1624
1695
  }, layer[0]);
1625
1696
  });
1626
1697
  };
1698
+ function resolveFloatDomCurrentUnitId(unitId, focusedUnit) {
1699
+ if (typeof unitId === "string") return unitId;
1700
+ if (typeof focusedUnit === "string") return focusedUnit;
1701
+ if (focusedUnit != null && typeof focusedUnit === "object" && "getUnitId" in focusedUnit && typeof focusedUnit.getUnitId === "function") {
1702
+ const focusedUnitId = focusedUnit.getUnitId();
1703
+ return typeof focusedUnitId === "string" ? focusedUnitId : null;
1704
+ }
1705
+ return null;
1706
+ }
1707
+ function resolveFloatDomOverflow(props) {
1708
+ var _viewport$bleedWidth;
1709
+ const viewport = props.customBlockRenderViewport;
1710
+ 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 {
1711
+ outerOverflow: "hidden",
1712
+ innerOverflow: "hidden"
1713
+ };
1714
+ return {
1715
+ outerOverflow: "visible",
1716
+ innerOverflow: "visible"
1717
+ };
1718
+ }
1627
1719
 
1628
1720
  //#endregion
1629
1721
  //#region src/services/popup/canvas-popup.service.ts
@@ -1930,13 +2022,44 @@ function CanvasPopup() {
1930
2022
  return (0, _wendellhu_redi_react_bindings.useObservable)(popupService.popups$, void 0, true).map((item) => {
1931
2023
  const [key, popup] = item;
1932
2024
  const Component = componentManager.get(popup.componentKey);
2025
+ const content = Component ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { popup }) : null;
1933
2026
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SingleCanvasPopup, {
1934
2027
  popup,
1935
- children: Component ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { popup }) : null
2028
+ children: popup.injector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wendellhu_redi_react_bindings.RediProvider, {
2029
+ value: { injector: popup.injector },
2030
+ children: content
2031
+ }) : content
1936
2032
  }, key);
1937
2033
  });
1938
2034
  }
1939
2035
 
2036
+ //#endregion
2037
+ //#region src/services/ribbon/ribbon-override.service.ts
2038
+ const IRibbonOverrideService = (0, _univerjs_core.createIdentifier)("univer.ribbon-override-service");
2039
+ var RibbonOverrideService = class extends _univerjs_core.Disposable {
2040
+ constructor(..._args) {
2041
+ super(..._args);
2042
+ _defineProperty(this, "_override$", new rxjs.BehaviorSubject(null));
2043
+ _defineProperty(this, "override$", this._override$.asObservable());
2044
+ }
2045
+ getOverride() {
2046
+ return this._override$.getValue();
2047
+ }
2048
+ activate(override) {
2049
+ this._override$.next(override);
2050
+ }
2051
+ clear(id) {
2052
+ const current = this.getOverride();
2053
+ if (!current) return;
2054
+ if (!id || current.id === id) this._override$.next(null);
2055
+ }
2056
+ dispose() {
2057
+ this._override$.next(null);
2058
+ this._override$.complete();
2059
+ super.dispose();
2060
+ }
2061
+ };
2062
+
1940
2063
  //#endregion
1941
2064
  //#region src/services/ribbon/ribbon.service.ts
1942
2065
  const IRibbonService = (0, _univerjs_core.createIdentifier)("univer.ribbon-service");
@@ -2903,15 +3026,20 @@ const ToolbarItem = (0, react.forwardRef)((props, ref) => {
2903
3026
  //#endregion
2904
3027
  //#region src/views/components/ribbon/Ribbon.tsx
2905
3028
  function Ribbon(props) {
2906
- const { ribbonType, headerMenuComponents, headerMenu = true } = props;
2907
- const ribbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
3029
+ var _ribbonOverride$ribbo;
3030
+ const { ribbonType, headerMenuComponents, headerMenu = true, toolbarOnly = false } = props;
3031
+ const defaultRibbonService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonService);
3032
+ const ribbonOverrideService = (0, _wendellhu_redi_react_bindings.useDependency)(IRibbonOverrideService);
2908
3033
  const localeService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.LocaleService);
3034
+ const ribbonOverride = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonOverrideService.override$, ribbonOverrideService.getOverride());
3035
+ const ribbonService = (_ribbonOverride$ribbo = ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.ribbonService) !== null && _ribbonOverride$ribbo !== void 0 ? _ribbonOverride$ribbo : defaultRibbonService;
2909
3036
  const containerRef = (0, react.useRef)(null);
2910
3037
  const toolbarItemRefs = (0, react.useRef)({});
2911
- const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.ribbon$, []);
2912
- const activatedTab = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.activatedTab$, "ribbon.start");
2913
- const collapsedIds = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.collapsedIds$, []);
2914
- const fakeToolbarVisible = (0, _wendellhu_redi_react_bindings.useObservable)(ribbonService.fakeToolbarVisible$, false);
3038
+ const ribbonData = (0, _wendellhu_redi_react_bindings.useObservable)(() => ribbonService.ribbon$, [], void 0, [ribbonService]);
3039
+ const activatedTab = (0, _wendellhu_redi_react_bindings.useObservable)(() => ribbonService.activatedTab$, "ribbon.start", void 0, [ribbonService]);
3040
+ const collapsedIds = (0, _wendellhu_redi_react_bindings.useObservable)(() => ribbonService.collapsedIds$, [], void 0, [ribbonService]);
3041
+ const fakeToolbarVisible = (0, _wendellhu_redi_react_bindings.useObservable)(() => ribbonService.fakeToolbarVisible$, false, void 0, [ribbonService]);
3042
+ const hideToolbar = (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.hideToolbar) === true;
2915
3043
  const ribbon = (0, react.useMemo)(() => {
2916
3044
  if (ribbonType === "simple") {
2917
3045
  const simpleRibbon = [{
@@ -2937,7 +3065,7 @@ function Ribbon(props) {
2937
3065
  const handleSelectTab = (0, react.useCallback)((group) => {
2938
3066
  toolbarItemRefs.current = {};
2939
3067
  ribbonService.setActivatedTab(group.key);
2940
- }, []);
3068
+ }, [ribbonService]);
2941
3069
  const activeGroup = (0, react.useMemo)(() => {
2942
3070
  var _ribbon$find$children, _ribbon$find2;
2943
3071
  const allGroups = (_ribbon$find$children = (_ribbon$find2 = ribbon.find((group) => group.key === activatedTab)) === null || _ribbon$find2 === void 0 ? void 0 : _ribbon$find2.children) !== null && _ribbon$find$children !== void 0 ? _ribbon$find$children : [];
@@ -2965,6 +3093,13 @@ function Ribbon(props) {
2965
3093
  activatedTab
2966
3094
  ]);
2967
3095
  (0, react.useEffect)(() => {
3096
+ if (hideToolbar) {
3097
+ toolbarItemRefs.current = {};
3098
+ ribbonService.setCollapsedIds([]);
3099
+ ribbonService.setFakeToolbarVisible(false);
3100
+ return;
3101
+ }
3102
+ if (!containerRef.current) return;
2968
3103
  let timer = null;
2969
3104
  const observer = new ResizeObserver((0, _univerjs_core.throttle)((entries) => {
2970
3105
  for (const entry of entries) {
@@ -2994,7 +3129,12 @@ function Ribbon(props) {
2994
3129
  timer && cancelAnimationFrame(timer);
2995
3130
  observer.disconnect();
2996
3131
  };
2997
- }, [ribbon, activatedTab]);
3132
+ }, [
3133
+ hideToolbar,
3134
+ ribbon,
3135
+ activatedTab,
3136
+ ribbonService
3137
+ ]);
2998
3138
  const fakeToolbar = (0, react.useMemo)(() => {
2999
3139
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3000
3140
  "aria-hidden": "true",
@@ -3022,17 +3162,31 @@ function Ribbon(props) {
3022
3162
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3023
3163
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3024
3164
  "data-u-comp": "ribbon-header-menu",
3025
- className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", { "univer-h-9": ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0 }),
3026
- children: [ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClassicMenu, {
3027
- ribbon,
3028
- activatedTab,
3029
- onSelectTab: handleSelectTab
3030
- }), headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3031
- className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3032
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
3033
- })]
3165
+ className: (0, _univerjs_design.clsx)("univer-relative univer-select-none", {
3166
+ "univer-hidden": toolbarOnly,
3167
+ "univer-h-9": !toolbarOnly && (ribbonType === "classic" || headerMenuComponents && headerMenuComponents.size > 0)
3168
+ }),
3169
+ children: [
3170
+ !toolbarOnly && (ribbonOverride === null || ribbonOverride === void 0 ? void 0 : ribbonOverride.placeholderTitle) && ribbon.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3171
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-9 univer-items-end univer-px-3", { "univer-justify-center": hideToolbar }),
3172
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3173
+ 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",
3174
+ "data-u-comp": "ribbon-override-placeholder",
3175
+ children: ribbonOverride.placeholderTitle
3176
+ })
3177
+ }),
3178
+ !toolbarOnly && ribbonType === "classic" && ribbon.length >= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClassicMenu, {
3179
+ ribbon,
3180
+ activatedTab,
3181
+ onSelectTab: handleSelectTab
3182
+ }),
3183
+ headerMenu && headerMenuComponents && headerMenuComponents.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3184
+ className: "univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100",
3185
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContainer, { components: headerMenuComponents })
3186
+ })
3187
+ ]
3034
3188
  }),
3035
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3189
+ !hideToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3036
3190
  className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
3037
3191
  "univer-grid-cols-[1fr] univer-justify-center": ribbonType === "classic" || ribbon.length === 1,
3038
3192
  "univer-grid-cols-[auto,1fr]": ribbon.length > 1 && ribbonType !== "classic"
@@ -3143,11 +3297,11 @@ var ContextMenuService = class extends _univerjs_core.Disposable {
3143
3297
  enable() {
3144
3298
  this.disabled = false;
3145
3299
  }
3146
- triggerContextMenu(event, menuType) {
3300
+ triggerContextMenu(event, menuType, context) {
3147
3301
  var _this$_currentHandler3;
3148
3302
  event.stopPropagation();
3149
3303
  if (this.disabled) return;
3150
- (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType);
3304
+ (_this$_currentHandler3 = this._currentHandler) === null || _this$_currentHandler3 === void 0 || _this$_currentHandler3.handleContextMenu(event, menuType, context);
3151
3305
  }
3152
3306
  hideContextMenu() {
3153
3307
  var _this$_currentHandler4;
@@ -4455,7 +4609,7 @@ function useContextGroupHiddenStates$1(menuSchemas) {
4455
4609
  //#endregion
4456
4610
  //#region src/views/components/context-menu/AnchoredContextMenu.tsx
4457
4611
  function AnchoredContextMenu(props) {
4458
- const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, onRequestClose, onOptionSelect } = props;
4612
+ const { hostId, visible, anchorRect, menuType, anchorVertical = "bottom", menuOffset = 0, menuInjector, onRequestClose, onOptionSelect } = props;
4459
4613
  const contentRef = (0, react.useRef)(null);
4460
4614
  const contextMenuHostService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuHostService);
4461
4615
  const onRequestCloseRef = (0, react.useRef)(onRequestClose);
@@ -4542,11 +4696,18 @@ function AnchoredContextMenu(props) {
4542
4696
  placementY: anchorVertical === "top" ? "above" : "below",
4543
4697
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
4544
4698
  ref: contentRef,
4545
- children: menuType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuPanel, {
4699
+ children: menuType && (menuInjector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wendellhu_redi_react_bindings.RediProvider, {
4700
+ value: { injector: menuInjector },
4701
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuPanel, {
4702
+ menuType,
4703
+ menuSessionVersion: menuSessionVersionRef.current,
4704
+ onOptionSelect
4705
+ })
4706
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenuPanel, {
4546
4707
  menuType,
4547
4708
  menuSessionVersion: menuSessionVersionRef.current,
4548
4709
  onOptionSelect
4549
- })
4710
+ }))
4550
4711
  })
4551
4712
  });
4552
4713
  }
@@ -4558,6 +4719,7 @@ function DesktopContextMenu() {
4558
4719
  const [visible, setVisible] = (0, react.useState)(false);
4559
4720
  const [menuType, setMenuType] = (0, react.useState)("");
4560
4721
  const [anchorRect, setAnchorRect] = (0, react.useState)(null);
4722
+ const [menuContext, setMenuContext] = (0, react.useState)();
4561
4723
  const visibleRef = (0, react.useRef)(visible);
4562
4724
  const contextMenuService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuService);
4563
4725
  const commandService = (0, _wendellhu_redi_react_bindings.useDependency)(_univerjs_core.ICommandService);
@@ -4578,10 +4740,11 @@ function DesktopContextMenu() {
4578
4740
  };
4579
4741
  }, [contextMenuService]);
4580
4742
  /** A function to open context menu with given position and menu type. */
4581
- function handleContextMenu(event, menuType) {
4743
+ function handleContextMenu(event, menuType, context) {
4582
4744
  setVisible(false);
4583
4745
  requestAnimationFrame(() => {
4584
4746
  setMenuType(menuType);
4747
+ setMenuContext(context);
4585
4748
  setAnchorRect({
4586
4749
  left: event.clientX,
4587
4750
  top: event.clientY,
@@ -4598,13 +4761,16 @@ function DesktopContextMenu() {
4598
4761
  visible,
4599
4762
  anchorRect,
4600
4763
  menuType,
4764
+ menuInjector: menuContext === null || menuContext === void 0 ? void 0 : menuContext.injector,
4601
4765
  onRequestClose: handleClose,
4602
4766
  onOptionSelect: (params) => {
4603
4767
  const { label: id, commandId, value } = params;
4604
4768
  const rawParams = typeof params.params === "function" ? params.params() : params.params;
4605
4769
  const commandParams = typeof rawParams === "undefined" ? { value } : rawParams;
4606
- if (commandService) commandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4607
- injector.get(ILayoutService).focus();
4770
+ const activeInjector = menuContext === null || menuContext === void 0 ? void 0 : menuContext.injector;
4771
+ const activeCommandService = (activeInjector === null || activeInjector === void 0 ? void 0 : activeInjector.has(_univerjs_core.ICommandService)) ? activeInjector.get(_univerjs_core.ICommandService) : commandService;
4772
+ if (activeCommandService) activeCommandService.executeCommand(commandId !== null && commandId !== void 0 ? commandId : id, commandParams);
4773
+ ((activeInjector === null || activeInjector === void 0 ? void 0 : activeInjector.has(ILayoutService)) ? activeInjector.get(ILayoutService) : injector.get(ILayoutService)).focus();
4608
4774
  handleClose();
4609
4775
  }
4610
4776
  });
@@ -5180,7 +5346,9 @@ var SingleUnitUIController = class extends _univerjs_core.Disposable {
5180
5346
  }));
5181
5347
  }
5182
5348
  _changeRenderUnit(rendererId, contentElement) {
5349
+ var _this$_instanceServic2;
5183
5350
  if (this._currentRenderId === rendererId) return false;
5351
+ if ((_this$_instanceServic2 = this._instanceService.getUnitCreateOptions(rendererId)) === null || _this$_instanceServic2 === void 0 ? void 0 : _this$_instanceServic2.embeddedRender) return false;
5184
5352
  const renderer = this._renderManagerService.getRenderById(rendererId);
5185
5353
  if (!renderer || !renderer.unitId || (0, _univerjs_core.isInternalEditorID)(renderer.unitId)) return false;
5186
5354
  const currentRenderer = this._currentRenderId ? this._renderManagerService.getRenderById(this._currentRenderId) : null;
@@ -5258,7 +5426,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
5258
5426
  //#endregion
5259
5427
  //#region package.json
5260
5428
  var name = "@univerjs/ui";
5261
- var version = "1.0.0-alpha.1";
5429
+ var version = "1.0.0-insiders.20260701-0ef51b0";
5262
5430
 
5263
5431
  //#endregion
5264
5432
  //#region src/views/color-picker/interface.ts
@@ -21619,6 +21787,7 @@ const MOBILE_CONTEXT_MENU_HOST_ID = "mobile-context-menu";
21619
21787
  function MobileContextMenu() {
21620
21788
  const [visible, setVisible] = (0, react.useState)(false);
21621
21789
  const [menuType, setMenuType] = (0, react.useState)("");
21790
+ const [menuContext, setMenuContext] = (0, react.useState)();
21622
21791
  const visibleRef = (0, react.useRef)(visible);
21623
21792
  const contextMenuHostService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuHostService);
21624
21793
  const contextMenuService = (0, _wendellhu_redi_react_bindings.useDependency)(IContextMenuService);
@@ -21647,9 +21816,10 @@ function MobileContextMenu() {
21647
21816
  contextMenuHostService.deactivateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21648
21817
  };
21649
21818
  }, [contextMenuHostService, contextMenuService]);
21650
- function handleContextMenu(_event, nextMenuType) {
21819
+ function handleContextMenu(_event, nextMenuType, context) {
21651
21820
  contextMenuHostService.activateMenu(MOBILE_CONTEXT_MENU_HOST_ID);
21652
21821
  setMenuType(nextMenuType);
21822
+ setMenuContext(context);
21653
21823
  setVisible(true);
21654
21824
  }
21655
21825
  function handleClose() {
@@ -21664,6 +21834,22 @@ function MobileContextMenu() {
21664
21834
  }
21665
21835
  }, [localeService, menuType]);
21666
21836
  if (!mountContainer || !visible) return null;
21837
+ const activeInjector = menuContext === null || menuContext === void 0 ? void 0 : menuContext.injector;
21838
+ const activeCommandService = (activeInjector === null || activeInjector === void 0 ? void 0 : activeInjector.has(_univerjs_core.ICommandService)) ? activeInjector.get(_univerjs_core.ICommandService) : commandService;
21839
+ const activeLayoutService = (activeInjector === null || activeInjector === void 0 ? void 0 : activeInjector.has(ILayoutService)) ? activeInjector.get(ILayoutService) : layoutService;
21840
+ const menu = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileMenu, {
21841
+ menuType,
21842
+ onOptionSelect: (params) => {
21843
+ var _ref, _params$commandId;
21844
+ const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
21845
+ const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
21846
+ const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
21847
+ if (!commandId) return;
21848
+ activeLayoutService.focus();
21849
+ activeCommandService.executeCommand(commandId, commandParams);
21850
+ handleClose();
21851
+ }
21852
+ });
21667
21853
  return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
21668
21854
  dir: direction,
21669
21855
  className: "univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end",
@@ -21697,19 +21883,10 @@ function MobileContextMenu() {
21697
21883
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, { className: "univer-size-4 univer-text-current" })
21698
21884
  })]
21699
21885
  })]
21700
- }), menuType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileMenu, {
21701
- menuType,
21702
- onOptionSelect: (params) => {
21703
- var _ref, _params$commandId;
21704
- const commandId = (_ref = (_params$commandId = params.commandId) !== null && _params$commandId !== void 0 ? _params$commandId : params.id) !== null && _ref !== void 0 ? _ref : params.label;
21705
- const fallbackParams = typeof params.params === "function" ? params.params() : params.params;
21706
- const commandParams = typeof params.value === "undefined" ? fallbackParams : { value: params.value };
21707
- if (!commandId) return;
21708
- layoutService.focus();
21709
- commandService.executeCommand(commandId, commandParams);
21710
- handleClose();
21711
- }
21712
- })]
21886
+ }), menuType && (activeInjector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wendellhu_redi_react_bindings.RediProvider, {
21887
+ value: { injector: activeInjector },
21888
+ children: menu
21889
+ }) : menu)]
21713
21890
  })]
21714
21891
  }), mountContainer);
21715
21892
  }
@@ -23111,6 +23288,7 @@ let UniverMobileUIPlugin = class UniverMobileUIPlugin extends _univerjs_core.Plu
23111
23288
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23112
23289
  [IFontService, { useClass: FontService }],
23113
23290
  [CanvasFloatDomService],
23291
+ [CanvasFloatDomPreviewService],
23114
23292
  [IUIController, {
23115
23293
  useFactory: (injector) => injector.createInstance(MobileUIController, this._config),
23116
23294
  deps: [_univerjs_core.Injector]
@@ -23168,6 +23346,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
23168
23346
  [IUIPartsService, { useClass: UIPartsService }],
23169
23347
  [ILayoutService, { useClass: DesktopLayoutService }],
23170
23348
  [IRibbonService, { useClass: DesktopRibbonService }],
23349
+ [IRibbonOverrideService, { useClass: RibbonOverrideService }],
23171
23350
  [IShortcutService, { useClass: ShortcutService }],
23172
23351
  [IPlatformService, { useClass: PlatformService }],
23173
23352
  [IMenuManagerService, { useClass: MenuManagerService }],
@@ -23210,6 +23389,7 @@ let UniverUIPlugin = class UniverUIPlugin extends _univerjs_core.Plugin {
23210
23389
  [ICanvasPopupService, { useClass: CanvasPopupService }],
23211
23390
  [IFontService, { useClass: FontService }],
23212
23391
  [CanvasFloatDomService],
23392
+ [CanvasFloatDomPreviewService],
23213
23393
  [IUIController, {
23214
23394
  useFactory: (injector) => injector.createInstance(DesktopUIController, this._config),
23215
23395
  deps: [_univerjs_core.Injector]
@@ -23923,16 +24103,16 @@ const PrintFloatDomSingle = (0, react.memo)((props) => {
23923
24103
  transform: transformRef.current
23924
24104
  },
23925
24105
  onPointerMove: (e) => {
23926
- layer.onPointerMove(e.nativeEvent);
24106
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerMove(e.nativeEvent);
23927
24107
  },
23928
24108
  onPointerDown: (e) => {
23929
- layer.onPointerDown(e.nativeEvent);
24109
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerDown(e.nativeEvent);
23930
24110
  },
23931
24111
  onPointerUp: (e) => {
23932
- layer.onPointerUp(e.nativeEvent);
24112
+ if (shouldForwardFloatDomEvents(layer)) layer.onPointerUp(e.nativeEvent);
23933
24113
  },
23934
24114
  onWheel: (e) => {
23935
- layer.onWheel(e.nativeEvent);
24115
+ if (shouldForwardFloatDomEvents(layer)) layer.onWheel(e.nativeEvent);
23936
24116
  },
23937
24117
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23938
24118
  ref: innerDomRef,
@@ -24037,6 +24217,7 @@ Object.defineProperty(exports, 'BrowserClipboardService', {
24037
24217
  exports.BuiltInUIPart = BuiltInUIPart;
24038
24218
  exports.COLOR_PICKER_COMPONENT = COLOR_PICKER_COMPONENT;
24039
24219
  exports.COMMON_LABEL_COMPONENT = COMMON_LABEL_COMPONENT;
24220
+ exports.CanvasFloatDomPreviewService = CanvasFloatDomPreviewService;
24040
24221
  exports.CanvasFloatDomService = CanvasFloatDomService;
24041
24222
  exports.CanvasPopup = CanvasPopup;
24042
24223
  exports.CanvasPopupService = CanvasPopupService;
@@ -24166,6 +24347,7 @@ exports.IMenuManagerService = IMenuManagerService;
24166
24347
  exports.IMessageService = IMessageService;
24167
24348
  exports.INotificationService = INotificationService;
24168
24349
  exports.IPlatformService = IPlatformService;
24350
+ exports.IRibbonOverrideService = IRibbonOverrideService;
24169
24351
  exports.IRibbonService = IRibbonService;
24170
24352
  exports.IShortcutService = IShortcutService;
24171
24353
  exports.ISidebarService = ISidebarService;
@@ -24219,6 +24401,7 @@ exports.RibbonDataGroup = RibbonDataGroup;
24219
24401
  exports.RibbonFormulasGroup = RibbonFormulasGroup;
24220
24402
  exports.RibbonInsertGroup = RibbonInsertGroup;
24221
24403
  exports.RibbonOthersGroup = RibbonOthersGroup;
24404
+ exports.RibbonOverrideService = RibbonOverrideService;
24222
24405
  exports.RibbonPosition = RibbonPosition;
24223
24406
  exports.RibbonStartGroup = RibbonStartGroup;
24224
24407
  exports.RibbonViewGroup = RibbonViewGroup;