@univerjs/drawing-ui 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (92) hide show
  1. package/lib/cjs/index.js +1306 -854
  2. package/lib/cjs/locale/ar-SA.js +45 -0
  3. package/lib/cjs/locale/ca-ES.js +45 -0
  4. package/lib/cjs/locale/de-DE.js +45 -0
  5. package/lib/cjs/locale/en-US.js +45 -0
  6. package/lib/cjs/locale/es-ES.js +45 -0
  7. package/lib/cjs/locale/fa-IR.js +45 -0
  8. package/lib/cjs/locale/fr-FR.js +45 -0
  9. package/lib/cjs/locale/id-ID.js +45 -0
  10. package/lib/cjs/locale/it-IT.js +45 -0
  11. package/lib/cjs/locale/ja-JP.js +45 -0
  12. package/lib/cjs/locale/ko-KR.js +45 -0
  13. package/lib/cjs/locale/pl-PL.js +45 -0
  14. package/lib/cjs/locale/pt-BR.js +45 -0
  15. package/lib/cjs/locale/ru-RU.js +45 -0
  16. package/lib/cjs/locale/sk-SK.js +45 -0
  17. package/lib/cjs/locale/vi-VN.js +45 -0
  18. package/lib/cjs/locale/zh-CN.js +45 -0
  19. package/lib/cjs/locale/zh-HK.js +45 -0
  20. package/lib/cjs/locale/zh-TW.js +45 -0
  21. package/lib/es/index.js +1300 -856
  22. package/lib/es/locale/ar-SA.js +45 -0
  23. package/lib/es/locale/ca-ES.js +45 -0
  24. package/lib/es/locale/de-DE.js +45 -0
  25. package/lib/es/locale/en-US.js +45 -0
  26. package/lib/es/locale/es-ES.js +45 -0
  27. package/lib/es/locale/fa-IR.js +45 -0
  28. package/lib/es/locale/fr-FR.js +45 -0
  29. package/lib/es/locale/id-ID.js +45 -0
  30. package/lib/es/locale/it-IT.js +45 -0
  31. package/lib/es/locale/ja-JP.js +45 -0
  32. package/lib/es/locale/ko-KR.js +45 -0
  33. package/lib/es/locale/pl-PL.js +45 -0
  34. package/lib/es/locale/pt-BR.js +45 -0
  35. package/lib/es/locale/ru-RU.js +45 -0
  36. package/lib/es/locale/sk-SK.js +45 -0
  37. package/lib/es/locale/vi-VN.js +45 -0
  38. package/lib/es/locale/zh-CN.js +45 -0
  39. package/lib/es/locale/zh-HK.js +45 -0
  40. package/lib/es/locale/zh-TW.js +45 -0
  41. package/lib/index.css +299 -0
  42. package/lib/index.js +1300 -856
  43. package/lib/locale/ar-SA.js +45 -0
  44. package/lib/locale/ca-ES.js +45 -0
  45. package/lib/locale/de-DE.js +45 -0
  46. package/lib/locale/en-US.js +45 -0
  47. package/lib/locale/es-ES.js +45 -0
  48. package/lib/locale/fa-IR.js +45 -0
  49. package/lib/locale/fr-FR.js +45 -0
  50. package/lib/locale/id-ID.js +45 -0
  51. package/lib/locale/it-IT.js +45 -0
  52. package/lib/locale/ja-JP.js +45 -0
  53. package/lib/locale/ko-KR.js +45 -0
  54. package/lib/locale/pl-PL.js +45 -0
  55. package/lib/locale/pt-BR.js +45 -0
  56. package/lib/locale/ru-RU.js +45 -0
  57. package/lib/locale/sk-SK.js +45 -0
  58. package/lib/locale/vi-VN.js +45 -0
  59. package/lib/locale/zh-CN.js +45 -0
  60. package/lib/locale/zh-HK.js +45 -0
  61. package/lib/locale/zh-TW.js +45 -0
  62. package/lib/types/controllers/image-update.controller.d.ts +2 -2
  63. package/lib/types/index.d.ts +6 -1
  64. package/lib/types/locale/en-US.d.ts +45 -0
  65. package/lib/types/services/drawing-render.service.d.ts +10 -4
  66. package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +11 -3
  67. package/lib/types/views/object-list-panel/ObjectListPanelBase.d.ts +101 -0
  68. package/lib/types/views/object-list-panel/object-list-panel-layer.d.ts +21 -0
  69. package/lib/types/views/panel/DrawingCommonPanel.d.ts +1 -1
  70. package/lib/types/views/panel/DrawingTransform.d.ts +1 -1
  71. package/lib/types/views/panel/ImageCropper.d.ts +1 -1
  72. package/lib/umd/index.js +7 -1
  73. package/lib/umd/locale/ar-SA.js +1 -1
  74. package/lib/umd/locale/ca-ES.js +1 -1
  75. package/lib/umd/locale/de-DE.js +1 -1
  76. package/lib/umd/locale/en-US.js +1 -1
  77. package/lib/umd/locale/es-ES.js +1 -1
  78. package/lib/umd/locale/fa-IR.js +1 -1
  79. package/lib/umd/locale/fr-FR.js +1 -1
  80. package/lib/umd/locale/id-ID.js +1 -1
  81. package/lib/umd/locale/it-IT.js +1 -1
  82. package/lib/umd/locale/ja-JP.js +1 -1
  83. package/lib/umd/locale/ko-KR.js +1 -1
  84. package/lib/umd/locale/pl-PL.js +1 -1
  85. package/lib/umd/locale/pt-BR.js +1 -1
  86. package/lib/umd/locale/ru-RU.js +1 -1
  87. package/lib/umd/locale/sk-SK.js +1 -1
  88. package/lib/umd/locale/vi-VN.js +1 -1
  89. package/lib/umd/locale/zh-CN.js +1 -1
  90. package/lib/umd/locale/zh-HK.js +1 -1
  91. package/lib/umd/locale/zh-TW.js +1 -1
  92. package/package.json +10 -10
package/lib/cjs/index.js CHANGED
@@ -2,12 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let _univerjs_core = require("@univerjs/core");
3
3
  let _univerjs_drawing = require("@univerjs/drawing");
4
4
  let _univerjs_engine_render = require("@univerjs/engine-render");
5
- let _univerjs_icons = require("@univerjs/icons");
6
5
  let _univerjs_ui = require("@univerjs/ui");
6
+ let rxjs = require("rxjs");
7
+ let _univerjs_icons = require("@univerjs/icons");
7
8
  let _univerjs_design = require("@univerjs/design");
8
9
  let react = require("react");
9
10
  let react_jsx_runtime = require("react/jsx-runtime");
10
- let rxjs = require("rxjs");
11
11
 
12
12
  //#region src/commands/operations/drawing-align.operation.ts
13
13
  /**
@@ -361,269 +361,280 @@ function getCurrentUnitInfo(currentUniverService, propUnitId) {
361
361
  }
362
362
 
363
363
  //#endregion
364
- //#region package.json
365
- var name = "@univerjs/drawing-ui";
366
- var version = "1.0.0-alpha.2";
367
-
368
- //#endregion
369
- //#region src/config/config.ts
370
- const DRAWING_UI_PLUGIN_CONFIG_KEY = "drawing-ui.config";
371
- const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
372
- const defaultPluginConfig = {};
373
-
374
- //#endregion
375
- //#region src/views/image-popup-menu/component-name.ts
376
- /**
377
- * Copyright 2023-present DreamNum Co., Ltd.
378
- *
379
- * Licensed under the Apache License, Version 2.0 (the "License");
380
- * you may not use this file except in compliance with the License.
381
- * You may obtain a copy of the License at
382
- *
383
- * http://www.apache.org/licenses/LICENSE-2.0
384
- *
385
- * Unless required by applicable law or agreed to in writing, software
386
- * distributed under the License is distributed on an "AS IS" BASIS,
387
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
388
- * See the License for the specific language governing permissions and
389
- * limitations under the License.
390
- */
391
- const COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
392
-
393
- //#endregion
394
- //#region src/views/image-popup-menu/ImagePopupMenu.tsx
395
- function ImagePopupMenu(props) {
396
- var _popup$extraProps, _popup$extraProps2;
397
- const { popup } = props;
398
- const menuItems = popup === null || popup === void 0 || (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.menuItems;
399
- if (!menuItems) return null;
400
- if (((_popup$extraProps2 = popup.extraProps) === null || _popup$extraProps2 === void 0 ? void 0 : _popup$extraProps2.variant) === "doc-floating-toolbar" && popup.extraProps.unitId && popup.extraProps.subUnitId && popup.extraProps.drawingId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocImageFloatingToolbar, {
401
- menuItems,
402
- unitId: popup.extraProps.unitId,
403
- subUnitId: popup.extraProps.subUnitId,
404
- drawingId: popup.extraProps.drawingId
364
+ //#region src/menu/align.menu.ts
365
+ const getMenuStateByDrawingFocusChangedObservable$$1 = (accessor) => {
366
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
367
+ return new rxjs.Observable((subscriber) => {
368
+ const update = (drawings) => {
369
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
370
+ if (drawings.length < 2) return subscriber.next(true);
371
+ subscriber.next(false);
372
+ };
373
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
374
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
375
+ update(drawings);
376
+ });
377
+ update(drawingManagerService.getFocusDrawings());
378
+ return () => subscription.unsubscribe();
405
379
  });
406
- const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
407
- const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
408
- const [visible, setVisible] = (0, react.useState)(false);
409
- const [isHovered, setHovered] = (0, react.useState)(false);
410
- const handleMouseEnter = () => {
411
- setHovered(true);
380
+ };
381
+ const DRAWING_ALIGN_CONTEXT_MENU_ID = "contextMenu.drawing-align";
382
+ function DrawingAlignContextMenuItemFactory(accessor) {
383
+ return {
384
+ id: DRAWING_ALIGN_CONTEXT_MENU_ID,
385
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
386
+ icon: "HorizontallyIcon",
387
+ title: "drawing-ui.image-panel.align.title",
388
+ hidden$: getMenuStateByDrawingFocusChangedObservable$$1(accessor)
412
389
  };
413
- const handleMouseLeave = () => {
414
- setHovered(false);
390
+ }
391
+ function SetDrawingAlignLeftMenuItemFactory() {
392
+ return {
393
+ id: SetDrawingAlignLeftOperation.id,
394
+ type: _univerjs_ui.MenuItemType.BUTTON,
395
+ icon: "LeftJustifyingIcon",
396
+ title: "drawing-ui.image-panel.align.left"
415
397
  };
416
- const onVisibleChange = (visible) => {
417
- setVisible(visible);
398
+ }
399
+ function SetDrawingAlignCenterMenuItemFactory() {
400
+ return {
401
+ id: SetDrawingAlignCenterOperation.id,
402
+ type: _univerjs_ui.MenuItemType.BUTTON,
403
+ icon: "HorizontallyIcon",
404
+ title: "drawing-ui.image-panel.align.center"
418
405
  };
419
- const handleClick = (item) => {
420
- commandService.executeCommand(item.commandId, item.commandParams);
421
- setVisible(false);
406
+ }
407
+ function SetDrawingAlignRightMenuItemFactory() {
408
+ return {
409
+ id: SetDrawingAlignRightOperation.id,
410
+ type: _univerjs_ui.MenuItemType.BUTTON,
411
+ icon: "RightJustifyingIcon",
412
+ title: "drawing-ui.image-panel.align.right"
422
413
  };
423
- const showMore = visible || isHovered;
424
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
425
- onMouseEnter: handleMouseEnter,
426
- onMouseLeave: handleMouseLeave,
427
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
428
- align: "start",
429
- items: menuItems.map((item) => ({
430
- type: "item",
431
- children: localeService.t(item.label),
432
- disabled: item.disable,
433
- onSelect: () => handleClick(item)
434
- })),
435
- open: visible,
436
- onOpenChange: onVisibleChange,
437
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
438
- className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
439
- "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
440
- "univer-bg-white dark:!univer-bg-gray-900": !visible
441
- }),
442
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-white" })]
443
- })
444
- })
445
- });
446
414
  }
447
- const UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID = "doc.command.update-doc-drawing-wrapping-style";
448
- function getWrappingStyle(documentDataModel, drawingId) {
449
- var _documentDataModel$ge;
450
- const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawingId];
451
- if (!drawing) return "inline";
452
- if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return drawing.behindDoc === _univerjs_core.BooleanNumber.TRUE ? "behindText" : "inFrontOfText";
453
- if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_SQUARE) return "wrapSquare";
454
- if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return "wrapTopAndBottom";
455
- return "inline";
415
+ function SetDrawingAlignTopMenuItemFactory() {
416
+ return {
417
+ id: SetDrawingAlignTopOperation.id,
418
+ type: _univerjs_ui.MenuItemType.BUTTON,
419
+ icon: "AlignTopIcon",
420
+ title: "drawing-ui.image-panel.align.top"
421
+ };
456
422
  }
457
- function ToolbarGroup(props) {
458
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
459
- className: "univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1",
460
- children: props.children
461
- });
423
+ function SetDrawingAlignMiddleMenuItemFactory() {
424
+ return {
425
+ id: SetDrawingAlignMiddleOperation.id,
426
+ type: _univerjs_ui.MenuItemType.BUTTON,
427
+ icon: "VerticalCenterIcon",
428
+ title: "drawing-ui.image-panel.align.middle"
429
+ };
462
430
  }
463
- function ToolbarButton(props) {
464
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
465
- title: props.title,
466
- placement: "bottom",
467
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
468
- type: "button",
469
- disabled: props.disabled,
470
- onClick: props.onClick,
471
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": props.active }),
472
- children: props.children
473
- })
474
- });
431
+ function SetDrawingAlignBottomMenuItemFactory() {
432
+ return {
433
+ id: SetDrawingAlignBottomOperation.id,
434
+ type: _univerjs_ui.MenuItemType.BUTTON,
435
+ icon: "AlignBottomIcon",
436
+ title: "drawing-ui.image-panel.align.bottom"
437
+ };
475
438
  }
476
- function ToolbarDropdownButton(props) {
477
- var _props$options$find;
478
- const [open, setOpen] = (0, react.useState)(false);
479
- const activeOption = (_props$options$find = props.options.find((option) => option.value === props.value)) !== null && _props$options$find !== void 0 ? _props$options$find : props.options[0];
480
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
481
- open,
482
- onOpenChange: setOpen,
483
- overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
484
- className: "univer-min-w-32 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",
485
- children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
486
- type: "button",
487
- onClick: () => {
488
- props.onChange(option.value);
489
- setOpen(false);
490
- },
491
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800", { "univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300": option.value === props.value }),
492
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
493
- className: "univer-flex univer-size-4 univer-items-center univer-justify-center",
494
- children: option.icon
495
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
496
- className: "univer-flex-1",
497
- children: option.label
498
- })]
499
- }, option.value))
500
- }),
501
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
502
- title: props.title,
503
- placement: "bottom",
504
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
505
- type: "button",
506
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": open }),
507
- children: [activeOption.icon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-xs" })]
508
- })
509
- }) })
510
- });
439
+ function SetDrawingAlignHorizonMenuItemFactory() {
440
+ return {
441
+ id: SetDrawingAlignHorizonOperation.id,
442
+ type: _univerjs_ui.MenuItemType.BUTTON,
443
+ icon: "HorizontallyIcon",
444
+ title: "drawing-ui.image-panel.align.horizon"
445
+ };
511
446
  }
512
- function DocImageFloatingToolbar(props) {
513
- var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2;
514
- const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
515
- const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
516
- const documentDataModel = (_univerInstanceServic = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getUnit(props.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
517
- const [wrappingStyle, setWrappingStyle] = (0, react.useState)(() => getWrappingStyle(documentDataModel, props.drawingId));
518
- const [hidden, setHidden] = (0, react.useState)(false);
519
- const getMenuItem = (label) => props.menuItems.find((item) => item.label === label);
520
- const editItem = getMenuItem("drawing-ui.image-popup.edit");
521
- const cropItem = getMenuItem("drawing-ui.image-popup.crop");
522
- const deleteItem = getMenuItem("drawing-ui.image-popup.delete");
523
- const wrappingStyleOptions = [
524
- {
525
- label: localeService.t("drawing-ui.image-text-wrap.inline"),
526
- value: "inline",
527
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
528
- },
529
- {
530
- label: localeService.t("drawing-ui.image-text-wrap.square"),
531
- value: "wrapSquare",
532
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
533
- },
534
- {
535
- label: localeService.t("drawing-ui.image-text-wrap.topAndBottom"),
536
- value: "wrapTopAndBottom",
537
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
538
- },
539
- {
540
- label: localeService.t("drawing-ui.image-text-wrap.behindText"),
541
- value: "behindText",
542
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
543
- },
544
- {
545
- label: localeService.t("drawing-ui.image-text-wrap.inFrontText"),
546
- value: "inFrontOfText",
547
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
548
- }
549
- ];
550
- const executeMenuItem = (item) => {
551
- if (!item || item.disable) return;
552
- commandService.executeCommand(item.commandId, item.commandParams);
447
+ function SetDrawingAlignVerticalMenuItemFactory() {
448
+ return {
449
+ id: SetDrawingAlignVerticalOperation.id,
450
+ type: _univerjs_ui.MenuItemType.BUTTON,
451
+ icon: "VerticalCenterIcon",
452
+ title: "drawing-ui.image-panel.align.vertical"
553
453
  };
554
- const updateWrappingStyle = (value) => {
555
- setWrappingStyle(value);
556
- commandService.executeCommand(UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID, {
557
- unitId: props.unitId,
558
- subUnitId: props.subUnitId,
559
- drawings: [{
560
- unitId: props.unitId,
561
- subUnitId: props.subUnitId,
562
- drawingId: props.drawingId
563
- }],
564
- wrappingStyle: value
565
- });
566
- };
567
- if (hidden) return null;
568
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
569
- "data-u-comp": "doc-image-floating-toolbar",
570
- onMouseDown: (event) => {
571
- event.stopPropagation();
572
- event.preventDefault();
573
- },
574
- className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
575
- children: [
576
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownButton, {
577
- title: (_wrappingStyleOptions = (_wrappingStyleOptions2 = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions2 === void 0 ? void 0 : _wrappingStyleOptions2.label) !== null && _wrappingStyleOptions !== void 0 ? _wrappingStyleOptions : localeService.t("drawing-ui.image-text-wrap.inline"),
578
- value: wrappingStyle,
579
- options: wrappingStyleOptions,
580
- onChange: updateWrappingStyle
581
- }) }),
582
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Separator, { orientation: "vertical" }),
583
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarGroup, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
584
- title: editItem ? localeService.t(editItem.label) : localeService.t("drawing-ui.image-popup.edit"),
585
- disabled: !editItem || editItem.disable,
586
- onClick: () => {
587
- setHidden(true);
588
- executeMenuItem(editItem);
589
- },
590
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DocSettingIcon, {})
591
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
592
- title: cropItem ? localeService.t(cropItem.label) : localeService.t("drawing-ui.image-popup.crop"),
593
- disabled: !cropItem || cropItem.disable,
594
- onClick: () => executeMenuItem(cropItem),
595
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CropIcon, {})
596
- })] }),
597
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Separator, { orientation: "vertical" }),
598
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
599
- title: deleteItem ? localeService.t(deleteItem.label) : localeService.t("drawing-ui.image-popup.delete"),
600
- disabled: !deleteItem || deleteItem.disable,
601
- onClick: () => executeMenuItem(deleteItem),
602
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
603
- }) })
604
- ]
605
- });
606
454
  }
607
455
 
608
456
  //#endregion
609
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
610
- function __decorateParam(paramIndex, decorator) {
611
- return function(target, key) {
612
- decorator(target, key, paramIndex);
457
+ //#region src/menu/arrange.menu.ts
458
+ const DRAWING_ARRANGE_CONTEXT_MENU_ID = "contextMenu.drawing-arrange";
459
+ function DrawingArrangeContextMenuItemFactory() {
460
+ return {
461
+ id: DRAWING_ARRANGE_CONTEXT_MENU_ID,
462
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
463
+ icon: "TopmostIcon",
464
+ title: "drawing-ui.image-panel.arrange.title"
465
+ };
466
+ }
467
+ function SetDrawingArrangeFrontMenuItemFactory() {
468
+ return {
469
+ id: SetDrawingArrangeFrontOperation.id,
470
+ type: _univerjs_ui.MenuItemType.BUTTON,
471
+ icon: "TopmostIcon",
472
+ title: "drawing-ui.image-panel.arrange.front"
473
+ };
474
+ }
475
+ function SetDrawingArrangeForwardMenuItemFactory() {
476
+ return {
477
+ id: SetDrawingArrangeForwardOperation.id,
478
+ type: _univerjs_ui.MenuItemType.BUTTON,
479
+ icon: "MoveUpIcon",
480
+ title: "drawing-ui.image-panel.arrange.forward"
481
+ };
482
+ }
483
+ function SetDrawingArrangeBackMenuItemFactory() {
484
+ return {
485
+ id: SetDrawingArrangeBackOperation.id,
486
+ type: _univerjs_ui.MenuItemType.BUTTON,
487
+ icon: "BottomIcon",
488
+ title: "drawing-ui.image-panel.arrange.back"
489
+ };
490
+ }
491
+ function SetDrawingArrangeBackwardMenuItemFactory() {
492
+ return {
493
+ id: SetDrawingArrangeBackwardOperation.id,
494
+ type: _univerjs_ui.MenuItemType.BUTTON,
495
+ icon: "MoveDownIcon",
496
+ title: "drawing-ui.image-panel.arrange.backward"
613
497
  };
614
498
  }
615
499
 
616
500
  //#endregion
617
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
618
- function __decorate(decorators, target, key, desc) {
619
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
620
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
621
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
622
- return c > 3 && r && Object.defineProperty(target, key, r), r;
501
+ //#region src/menu/group.menu.ts
502
+ function getMenuStateByDrawingFocusChangedObservable$(accessor, type) {
503
+ const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
504
+ return new rxjs.Observable((subscriber) => {
505
+ const update = (drawings) => {
506
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
507
+ if (type === "group") {
508
+ if (drawings.length < 2) return subscriber.next(true);
509
+ if (!drawings.every((drawing) => (0, _univerjs_drawing.isGroupableDrawingType)(drawing.drawingType))) return subscriber.next(true);
510
+ } else if (type === "unGroup") {
511
+ if (drawings.filter((drawing) => drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP).length === 0) return subscriber.next(true);
512
+ } else if (!drawings.every((drawing) => (0, _univerjs_drawing.isGroupableDrawingType)(drawing.drawingType))) return subscriber.next(true);
513
+ subscriber.next(false);
514
+ };
515
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
516
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
517
+ update(drawings);
518
+ });
519
+ update(drawingManagerService.getFocusDrawings());
520
+ return () => subscription.unsubscribe();
521
+ });
522
+ }
523
+ const DRAWING_GROUP_CONTEXT_MENU_ID = "contextMenu.drawing-group";
524
+ function DrawingGroupContextMenuItemFactory(accessor) {
525
+ return {
526
+ id: DRAWING_GROUP_CONTEXT_MENU_ID,
527
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
528
+ icon: "GroupIcon",
529
+ title: "drawing-ui.image-panel.group.title",
530
+ hidden$: getMenuStateByDrawingFocusChangedObservable$(accessor)
531
+ };
532
+ }
533
+ function SetDrawingGroupMenuItemFactory(accessor) {
534
+ return {
535
+ id: SetDrawingGroupOperation.id,
536
+ type: _univerjs_ui.MenuItemType.BUTTON,
537
+ icon: "GroupIcon",
538
+ title: "drawing-ui.image-panel.group.group",
539
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "group")
540
+ };
541
+ }
542
+ function CancelDrawingGroupMenuItemFactory(accessor) {
543
+ return {
544
+ id: CancelDrawingGroupOperation.id,
545
+ type: _univerjs_ui.MenuItemType.BUTTON,
546
+ icon: "UngroupIcon",
547
+ title: "drawing-ui.image-panel.group.unGroup",
548
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "unGroup")
549
+ };
623
550
  }
624
551
 
625
552
  //#endregion
626
- //#region src/controllers/components.controller.ts
553
+ //#region src/menu/schema.ts
554
+ const menuSchema = { [_univerjs_ui.ContextMenuPosition.DRAWING]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: {
555
+ [DRAWING_GROUP_CONTEXT_MENU_ID]: {
556
+ order: 1,
557
+ menuItemFactory: DrawingGroupContextMenuItemFactory,
558
+ [SetDrawingGroupOperation.id]: {
559
+ order: 0,
560
+ menuItemFactory: SetDrawingGroupMenuItemFactory
561
+ },
562
+ [CancelDrawingGroupOperation.id]: {
563
+ order: 1,
564
+ menuItemFactory: CancelDrawingGroupMenuItemFactory
565
+ }
566
+ },
567
+ [DRAWING_ARRANGE_CONTEXT_MENU_ID]: {
568
+ order: 2,
569
+ menuItemFactory: DrawingArrangeContextMenuItemFactory,
570
+ [SetDrawingArrangeFrontOperation.id]: {
571
+ order: 0,
572
+ menuItemFactory: SetDrawingArrangeFrontMenuItemFactory
573
+ },
574
+ [SetDrawingArrangeForwardOperation.id]: {
575
+ order: 1,
576
+ menuItemFactory: SetDrawingArrangeForwardMenuItemFactory
577
+ },
578
+ [SetDrawingArrangeBackOperation.id]: {
579
+ order: 2,
580
+ menuItemFactory: SetDrawingArrangeBackMenuItemFactory
581
+ },
582
+ [SetDrawingArrangeBackwardOperation.id]: {
583
+ order: 3,
584
+ menuItemFactory: SetDrawingArrangeBackwardMenuItemFactory
585
+ }
586
+ },
587
+ [DRAWING_ALIGN_CONTEXT_MENU_ID]: {
588
+ order: 3,
589
+ menuItemFactory: DrawingAlignContextMenuItemFactory,
590
+ [SetDrawingAlignLeftOperation.id]: {
591
+ order: 0,
592
+ menuItemFactory: SetDrawingAlignLeftMenuItemFactory
593
+ },
594
+ [SetDrawingAlignCenterOperation.id]: {
595
+ order: 1,
596
+ menuItemFactory: SetDrawingAlignCenterMenuItemFactory
597
+ },
598
+ [SetDrawingAlignRightOperation.id]: {
599
+ order: 2,
600
+ menuItemFactory: SetDrawingAlignRightMenuItemFactory
601
+ },
602
+ [SetDrawingAlignTopOperation.id]: {
603
+ order: 3,
604
+ menuItemFactory: SetDrawingAlignTopMenuItemFactory
605
+ },
606
+ [SetDrawingAlignMiddleOperation.id]: {
607
+ order: 4,
608
+ menuItemFactory: SetDrawingAlignMiddleMenuItemFactory
609
+ },
610
+ [SetDrawingAlignBottomOperation.id]: {
611
+ order: 5,
612
+ menuItemFactory: SetDrawingAlignBottomMenuItemFactory
613
+ },
614
+ [SetDrawingAlignHorizonOperation.id]: {
615
+ order: 6,
616
+ menuItemFactory: SetDrawingAlignHorizonMenuItemFactory
617
+ },
618
+ [SetDrawingAlignVerticalOperation.id]: {
619
+ order: 7,
620
+ menuItemFactory: SetDrawingAlignVerticalMenuItemFactory
621
+ }
622
+ }
623
+ } } };
624
+
625
+ //#endregion
626
+ //#region package.json
627
+ var name = "@univerjs/drawing-ui";
628
+ var version = "1.0.0-alpha.4";
629
+
630
+ //#endregion
631
+ //#region src/config/config.ts
632
+ const DRAWING_UI_PLUGIN_CONFIG_KEY = "drawing-ui.config";
633
+ const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
634
+ const defaultPluginConfig = {};
635
+
636
+ //#endregion
637
+ //#region src/views/image-popup-menu/component-name.ts
627
638
  /**
628
639
  * Copyright 2023-present DreamNum Co., Ltd.
629
640
  *
@@ -639,96 +650,381 @@ function __decorate(decorators, target, key, desc) {
639
650
  * See the License for the specific language governing permissions and
640
651
  * limitations under the License.
641
652
  */
642
- let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
643
- constructor(_componentManager, _iconManager) {
644
- super();
645
- this._componentManager = _componentManager;
646
- this._iconManager = _iconManager;
647
- this._registerComponents();
648
- this._registerIcons();
649
- }
650
- _registerComponents() {
651
- [[COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu]].forEach(([key, component]) => {
652
- this.disposeWithMe(this._componentManager.register(key, component));
653
- });
654
- }
655
- _registerIcons() {
656
- this.disposeWithMe(this._iconManager.register({
657
- BottomIcon: _univerjs_icons.BottomIcon,
658
- GroupIcon: _univerjs_icons.GroupIcon,
659
- MoveDownIcon: _univerjs_icons.MoveDownIcon,
660
- MoveUpIcon: _univerjs_icons.MoveUpIcon,
661
- TopmostIcon: _univerjs_icons.TopmostIcon,
662
- UngroupIcon: _univerjs_icons.UngroupIcon
663
- }));
664
- }
665
- };
666
- ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
667
-
668
- //#endregion
669
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
670
- function _typeof(o) {
671
- "@babel/helpers - typeof";
672
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
673
- return typeof o;
674
- } : function(o) {
675
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
676
- }, _typeof(o);
677
- }
678
-
679
- //#endregion
680
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
681
- function toPrimitive(t, r) {
682
- if ("object" != _typeof(t) || !t) return t;
683
- var e = t[Symbol.toPrimitive];
684
- if (void 0 !== e) {
685
- var i = e.call(t, r || "default");
686
- if ("object" != _typeof(i)) return i;
687
- throw new TypeError("@@toPrimitive must return a primitive value.");
688
- }
689
- return ("string" === r ? String : Number)(t);
690
- }
653
+ const COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
691
654
 
692
655
  //#endregion
693
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
694
- function toPropertyKey(t) {
695
- var i = toPrimitive(t, "string");
696
- return "symbol" == _typeof(i) ? i : i + "";
656
+ //#region src/views/image-popup-menu/ImagePopupMenu.tsx
657
+ function ImagePopupMenu(props) {
658
+ var _popup$extraProps, _popup$extraProps2, _popup$extraProps3;
659
+ const { popup } = props;
660
+ const menuItems = popup === null || popup === void 0 || (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.menuItems;
661
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
662
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
663
+ const [visible, setVisible] = (0, react.useState)(false);
664
+ const [isHovered, setIsHovered] = (0, react.useState)(false);
665
+ if (!menuItems) return null;
666
+ if (((_popup$extraProps2 = popup.extraProps) === null || _popup$extraProps2 === void 0 ? void 0 : _popup$extraProps2.variant) === "doc-floating-toolbar" && popup.extraProps.unitId && popup.extraProps.subUnitId && popup.extraProps.drawingId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocImageFloatingToolbar, {
667
+ menuItems,
668
+ unitId: popup.extraProps.unitId,
669
+ subUnitId: popup.extraProps.subUnitId,
670
+ drawingId: popup.extraProps.drawingId
671
+ });
672
+ if (((_popup$extraProps3 = popup.extraProps) === null || _popup$extraProps3 === void 0 ? void 0 : _popup$extraProps3.variant) === "doc-chart-floating-toolbar") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocChartFloatingToolbar, { menuItems });
673
+ const handleMouseEnter = () => {
674
+ setIsHovered(true);
675
+ };
676
+ const handleMouseLeave = () => {
677
+ setIsHovered(false);
678
+ };
679
+ const onVisibleChange = (visible) => {
680
+ setVisible(visible);
681
+ };
682
+ const handleClick = (item) => {
683
+ commandService.executeCommand(item.commandId, item.commandParams);
684
+ setVisible(false);
685
+ };
686
+ const showMore = visible || isHovered;
687
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
688
+ onMouseEnter: handleMouseEnter,
689
+ onMouseLeave: handleMouseLeave,
690
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
691
+ align: "start",
692
+ items: menuItems.map((item) => ({
693
+ type: "item",
694
+ children: localeService.t(item.label),
695
+ disabled: item.disable,
696
+ onSelect: () => handleClick(item)
697
+ })),
698
+ open: visible,
699
+ onOpenChange: onVisibleChange,
700
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
701
+ className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
702
+ "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
703
+ "univer-bg-white dark:!univer-bg-gray-900": !visible
704
+ }),
705
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-white" })]
706
+ })
707
+ })
708
+ });
709
+ }
710
+ const UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID = "doc.command.update-doc-drawing-wrapping-style";
711
+ function getWrappingStyle(documentDataModel, drawingId) {
712
+ var _documentDataModel$ge;
713
+ const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawingId];
714
+ if (!drawing) return "inline";
715
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE) return drawing.behindDoc === _univerjs_core.BooleanNumber.TRUE ? "behindText" : "inFrontOfText";
716
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_SQUARE) return "wrapSquare";
717
+ if (drawing.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return "wrapTopAndBottom";
718
+ return "inline";
719
+ }
720
+ function ToolbarGroup(props) {
721
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
722
+ className: "univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1",
723
+ children: props.children
724
+ });
725
+ }
726
+ function ToolbarButton(props) {
727
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
728
+ title: (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService).t(props.titleKey),
729
+ placement: "bottom",
730
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
731
+ type: "button",
732
+ disabled: props.disabled,
733
+ onClick: props.onClick,
734
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": props.active }),
735
+ children: props.children
736
+ })
737
+ });
738
+ }
739
+ function ToolbarDropdownButton(props) {
740
+ var _props$options$find;
741
+ const [open, setOpen] = (0, react.useState)(false);
742
+ const activeOption = (_props$options$find = props.options.find((option) => option.value === props.value)) !== null && _props$options$find !== void 0 ? _props$options$find : props.options[0];
743
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
744
+ open,
745
+ onOpenChange: setOpen,
746
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
747
+ className: "univer-min-w-32 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",
748
+ children: props.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
749
+ type: "button",
750
+ onClick: () => {
751
+ props.onChange(option.value);
752
+ setOpen(false);
753
+ },
754
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800", { "univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300": option.value === props.value }),
755
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
756
+ className: "univer-flex univer-size-4 univer-items-center univer-justify-center",
757
+ children: option.icon
758
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
759
+ className: "univer-flex-1",
760
+ children: option.label
761
+ })]
762
+ }, option.value))
763
+ }),
764
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
765
+ title: props.title,
766
+ placement: "bottom",
767
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
768
+ type: "button",
769
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300": open }),
770
+ children: [activeOption.icon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-xs" })]
771
+ })
772
+ }) })
773
+ });
774
+ }
775
+ function DocImageFloatingToolbar(props) {
776
+ var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2;
777
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
778
+ const iconManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.IconManager);
779
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
780
+ const documentDataModel = (_univerInstanceServic = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService).getUnit(props.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
781
+ const [wrappingStyle, setWrappingStyle] = (0, react.useState)(() => getWrappingStyle(documentDataModel, props.drawingId));
782
+ const [hidden, setHidden] = (0, react.useState)(false);
783
+ const actionItems = props.menuItems.filter((item) => item.type !== "select" && item.icon).sort((a, b) => a.index - b.index);
784
+ const wrappingStyleOptions = [
785
+ {
786
+ label: localeService.t("drawing-ui.image-text-wrap.inline"),
787
+ value: "inline",
788
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
789
+ },
790
+ {
791
+ label: localeService.t("drawing-ui.image-text-wrap.square"),
792
+ value: "wrapSquare",
793
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
794
+ },
795
+ {
796
+ label: localeService.t("drawing-ui.image-text-wrap.topAndBottom"),
797
+ value: "wrapTopAndBottom",
798
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
799
+ },
800
+ {
801
+ label: localeService.t("drawing-ui.image-text-wrap.behindText"),
802
+ value: "behindText",
803
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
804
+ },
805
+ {
806
+ label: localeService.t("drawing-ui.image-text-wrap.inFrontText"),
807
+ value: "inFrontOfText",
808
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.TextWrapShapeIcon, {})
809
+ }
810
+ ];
811
+ const executeMenuItem = (item) => {
812
+ if (!item || item.disable) return;
813
+ if (item.hideOnClick) setHidden(true);
814
+ commandService.executeCommand(item.commandId, item.commandParams);
815
+ };
816
+ const updateWrappingStyle = (value) => {
817
+ setWrappingStyle(value);
818
+ commandService.executeCommand(UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID, {
819
+ unitId: props.unitId,
820
+ subUnitId: props.subUnitId,
821
+ drawings: [{
822
+ unitId: props.unitId,
823
+ subUnitId: props.subUnitId,
824
+ drawingId: props.drawingId
825
+ }],
826
+ wrappingStyle: value
827
+ });
828
+ };
829
+ if (hidden) return null;
830
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
831
+ "data-u-comp": "doc-image-floating-toolbar",
832
+ onMouseDown: (event) => {
833
+ event.stopPropagation();
834
+ event.preventDefault();
835
+ },
836
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
837
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownButton, {
838
+ title: (_wrappingStyleOptions = (_wrappingStyleOptions2 = wrappingStyleOptions.find((option) => option.value === wrappingStyle)) === null || _wrappingStyleOptions2 === void 0 ? void 0 : _wrappingStyleOptions2.label) !== null && _wrappingStyleOptions !== void 0 ? _wrappingStyleOptions : localeService.t("drawing-ui.image-text-wrap.inline"),
839
+ value: wrappingStyle,
840
+ options: wrappingStyleOptions,
841
+ onChange: updateWrappingStyle
842
+ }) }), actionItems.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Separator, { orientation: "vertical" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: actionItems.map((item) => {
843
+ const Icon = iconManager.get(item.icon);
844
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
845
+ titleKey: item.label,
846
+ disabled: item.disable,
847
+ onClick: () => executeMenuItem(item),
848
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {})
849
+ }, `${item.commandId}-${item.index}`);
850
+ }) })] })]
851
+ });
852
+ }
853
+ function DocChartFloatingToolbar(props) {
854
+ var _chartTypeItem$option, _ref, _chartTypeItem$value, _chartTypeOptions$;
855
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
856
+ const iconManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.IconManager);
857
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
858
+ const [hidden, setHidden] = (0, react.useState)(false);
859
+ const chartTypeItem = props.menuItems.find((item) => item.type === "select");
860
+ const actionItems = props.menuItems.filter((item) => item.type !== "select" && item.icon).sort((a, b) => a.index - b.index);
861
+ const chartTypeOptions = ((_chartTypeItem$option = chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) !== null && _chartTypeItem$option !== void 0 ? _chartTypeItem$option : []).map((option) => ({
862
+ label: String(option.label),
863
+ value: option.value,
864
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ChartIcon, {})
865
+ }));
866
+ const executeMenuItem = (item) => {
867
+ if (!item || item.disable) return;
868
+ if (item.hideOnClick) setHidden(true);
869
+ commandService.executeCommand(item.commandId, item.commandParams);
870
+ };
871
+ if (hidden) return null;
872
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
873
+ "data-u-comp": "doc-chart-floating-toolbar",
874
+ onMouseDown: (event) => {
875
+ event.stopPropagation();
876
+ event.preventDefault();
877
+ },
878
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-items-center univer-rounded univer-bg-white univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
879
+ children: [chartTypeItem && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarDropdownButton, {
880
+ title: localeService.t(chartTypeItem.label),
881
+ value: (_ref = (_chartTypeItem$value = chartTypeItem.value) !== null && _chartTypeItem$value !== void 0 ? _chartTypeItem$value : (_chartTypeOptions$ = chartTypeOptions[0]) === null || _chartTypeOptions$ === void 0 ? void 0 : _chartTypeOptions$.value) !== null && _ref !== void 0 ? _ref : "",
882
+ options: chartTypeOptions,
883
+ onChange: (value) => {
884
+ if (!chartTypeItem.disable) {
885
+ var _chartTypeItem$comman;
886
+ commandService.executeCommand(chartTypeItem.commandId, (_chartTypeItem$comman = chartTypeItem.commandParamsFactory) === null || _chartTypeItem$comman === void 0 ? void 0 : _chartTypeItem$comman.call(chartTypeItem, value));
887
+ }
888
+ }
889
+ }) }), actionItems.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Separator, { orientation: "vertical" })] }), actionItems.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarGroup, { children: actionItems.map((item) => {
890
+ const Icon = iconManager.get(item.icon);
891
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
892
+ titleKey: item.label,
893
+ disabled: item.disable,
894
+ onClick: () => executeMenuItem(item),
895
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {})
896
+ }, `${item.commandId}-${item.index}`);
897
+ }) })]
898
+ });
697
899
  }
698
900
 
699
901
  //#endregion
700
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
701
- function _defineProperty(e, r, t) {
702
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
703
- value: t,
704
- enumerable: !0,
705
- configurable: !0,
706
- writable: !0
707
- }) : e[r] = t, e;
902
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
903
+ function __decorateParam(paramIndex, decorator) {
904
+ return function(target, key) {
905
+ decorator(target, key, paramIndex);
906
+ };
708
907
  }
709
908
 
710
909
  //#endregion
711
- //#region src/services/drawing-image-clip.service.ts
712
- const IMAGE_CLIP_SHAPE_PICKER_COMPONENT = "sheet.image-clip.shape.picker.component";
910
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
911
+ function __decorate(decorators, target, key, desc) {
912
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
913
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
914
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
915
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
916
+ }
917
+
918
+ //#endregion
919
+ //#region src/controllers/components.controller.ts
713
920
  /**
714
- * Bridge service that enables shape-based image clipping.
715
- * This service lives in the open-source drawing-ui package and delegates
716
- * to a registered clip implementation (provided by pro engine-shape package).
921
+ * Copyright 2023-present DreamNum Co., Ltd.
717
922
  *
718
- * When no delegate is registered, applyShapeClip returns false and images render normally without shape clipping.
923
+ * Licensed under the Apache License, Version 2.0 (the "License");
924
+ * you may not use this file except in compliance with the License.
925
+ * You may obtain a copy of the License at
926
+ *
927
+ * http://www.apache.org/licenses/LICENSE-2.0
928
+ *
929
+ * Unless required by applicable law or agreed to in writing, software
930
+ * distributed under the License is distributed on an "AS IS" BASIS,
931
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
932
+ * See the License for the specific language governing permissions and
933
+ * limitations under the License.
719
934
  */
720
- var DrawingImageClipService = class extends _univerjs_core.Disposable {
721
- constructor() {
935
+ let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
936
+ constructor(_componentManager, _iconManager) {
722
937
  super();
723
- _defineProperty(this, "_clipDelegate", null);
724
- _defineProperty(this, "_canUseShapeClip$", new rxjs.BehaviorSubject(false));
725
- _defineProperty(this, "canUseShapeClip$", this._canUseShapeClip$.asObservable());
726
- }
727
- setCanUseShapeClip(canUse) {
728
- this._canUseShapeClip$.next(canUse);
938
+ this._componentManager = _componentManager;
939
+ this._iconManager = _iconManager;
940
+ this._registerComponents();
941
+ this._registerIcons();
729
942
  }
730
- /**
731
- * Register a clip delegate that knows how to build shape clip paths.
943
+ _registerComponents() {
944
+ [[COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu]].forEach(([key, component]) => {
945
+ this.disposeWithMe(this._componentManager.register(key, component));
946
+ });
947
+ }
948
+ _registerIcons() {
949
+ this.disposeWithMe(this._iconManager.register({
950
+ BottomIcon: _univerjs_icons.BottomIcon,
951
+ DrawingCropIcon: _univerjs_icons.CropIcon,
952
+ DrawingDeleteIcon: _univerjs_icons.DeleteIcon,
953
+ DrawingEditIcon: _univerjs_icons.DocSettingIcon,
954
+ GroupIcon: _univerjs_icons.GroupIcon,
955
+ MoveDownIcon: _univerjs_icons.MoveDownIcon,
956
+ MoveUpIcon: _univerjs_icons.MoveUpIcon,
957
+ TopmostIcon: _univerjs_icons.TopmostIcon,
958
+ UngroupIcon: _univerjs_icons.UngroupIcon
959
+ }));
960
+ }
961
+ };
962
+ ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
963
+
964
+ //#endregion
965
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
966
+ function _typeof(o) {
967
+ "@babel/helpers - typeof";
968
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
969
+ return typeof o;
970
+ } : function(o) {
971
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
972
+ }, _typeof(o);
973
+ }
974
+
975
+ //#endregion
976
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
977
+ function toPrimitive(t, r) {
978
+ if ("object" != _typeof(t) || !t) return t;
979
+ var e = t[Symbol.toPrimitive];
980
+ if (void 0 !== e) {
981
+ var i = e.call(t, r || "default");
982
+ if ("object" != _typeof(i)) return i;
983
+ throw new TypeError("@@toPrimitive must return a primitive value.");
984
+ }
985
+ return ("string" === r ? String : Number)(t);
986
+ }
987
+
988
+ //#endregion
989
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
990
+ function toPropertyKey(t) {
991
+ var i = toPrimitive(t, "string");
992
+ return "symbol" == _typeof(i) ? i : i + "";
993
+ }
994
+
995
+ //#endregion
996
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
997
+ function _defineProperty(e, r, t) {
998
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
999
+ value: t,
1000
+ enumerable: !0,
1001
+ configurable: !0,
1002
+ writable: !0
1003
+ }) : e[r] = t, e;
1004
+ }
1005
+
1006
+ //#endregion
1007
+ //#region src/services/drawing-image-clip.service.ts
1008
+ const IMAGE_CLIP_SHAPE_PICKER_COMPONENT = "sheet.image-clip.shape.picker.component";
1009
+ /**
1010
+ * Bridge service that enables shape-based image clipping.
1011
+ * This service lives in the open-source drawing-ui package and delegates
1012
+ * to a registered clip implementation (provided by pro engine-shape package).
1013
+ *
1014
+ * When no delegate is registered, applyShapeClip returns false and images render normally without shape clipping.
1015
+ */
1016
+ var DrawingImageClipService = class extends _univerjs_core.Disposable {
1017
+ constructor() {
1018
+ super();
1019
+ _defineProperty(this, "_clipDelegate", null);
1020
+ _defineProperty(this, "_canUseShapeClip$", new rxjs.BehaviorSubject(false));
1021
+ _defineProperty(this, "canUseShapeClip$", this._canUseShapeClip$.asObservable());
1022
+ }
1023
+ setCanUseShapeClip(canUse) {
1024
+ this._canUseShapeClip$.next(canUse);
1025
+ }
1026
+ /**
1027
+ * Register a clip delegate that knows how to build shape clip paths.
732
1028
  * Typically called by the pro-side plugin with a ShapeModel-based implementation.
733
1029
  * @returns IDisposable to unregister the delegate
734
1030
  */
@@ -753,7 +1049,7 @@ var DrawingImageClipService = class extends _univerjs_core.Disposable {
753
1049
  //#region src/services/drawing-render.service.ts
754
1050
  const DOC_DRAWING_BEHIND_TEXT_LAYER_INDEX = 1;
755
1051
  function getDrawingRenderLayerIndex(param) {
756
- return param.behindText === true || param.behindText === _univerjs_core.BooleanNumber.TRUE ? 1 : _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX;
1052
+ return param.behindText === true || param.behindText === _univerjs_core.BooleanNumber.TRUE || param.layoutType === _univerjs_core.PositionedObjectLayoutType.WRAP_NONE && param.behindDoc === _univerjs_core.BooleanNumber.TRUE ? 1 : _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX;
757
1053
  }
758
1054
  function ensureDrawingRenderLayer(scene, object, param) {
759
1055
  const layerIndex = getDrawingRenderLayerIndex(param);
@@ -773,12 +1069,12 @@ let DrawingRenderService = class DrawingRenderService {
773
1069
  this._univerInstanceService = _univerInstanceService;
774
1070
  this._drawingImageClipService = _drawingImageClipService;
775
1071
  }
776
- async renderImages(imageParam, scene) {
1072
+ async renderImages(imageParam, scene, options) {
777
1073
  const { transform: singleTransform, drawingType, source, imageSourceType, srcRect, prstGeom, groupId, unitId, subUnitId, drawingId, isMultiTransform, transforms: multiTransforms, adjustValues, hidden } = imageParam;
778
1074
  const { docxHeaderFooterDrawing, layoutType } = imageParam;
779
1075
  if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
780
1076
  if (!this._drawingManagerService.getDrawingVisible()) return;
781
- if (this._univerInstanceService.getUnitType(unitId) === _univerjs_core.UniverInstanceType.UNIVER_SHEET && subUnitId !== this._getActiveSheetId()) return;
1077
+ if (!(options === null || options === void 0 ? void 0 : options.allowInactiveSheet) && this._univerInstanceService.getUnitType(unitId) === _univerjs_core.UniverInstanceType.UNIVER_SHEET && subUnitId !== this._getActiveSheetId()) return;
782
1078
  if (singleTransform == null) return;
783
1079
  const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform];
784
1080
  const images = [];
@@ -818,13 +1114,13 @@ let DrawingRenderService = class DrawingRenderService {
818
1114
  const imageNativeCache = this._imageIoService.getImageSourceCache(source, imageSourceType);
819
1115
  let shouldBeCache = false;
820
1116
  if (isRenderableImageCache(imageNativeCache)) imageConfig.image = imageNativeCache;
821
- else if (imageSourceType === _univerjs_drawing.ImageSourceType.UUID) try {
1117
+ else if (imageSourceType === _univerjs_core.ImageSourceType.UUID) try {
822
1118
  imageConfig.url = await this._imageIoService.getImage(source);
823
1119
  } catch (error) {
824
1120
  console.error(error);
825
1121
  continue;
826
1122
  }
827
- else if (imageSourceType === _univerjs_drawing.ImageSourceType.URL) {
1123
+ else if (imageSourceType === _univerjs_core.ImageSourceType.URL) {
828
1124
  try {
829
1125
  imageConfig.url = await this._urlImageService.getImage(source);
830
1126
  } catch (error) {
@@ -912,11 +1208,11 @@ let DrawingRenderService = class DrawingRenderService {
912
1208
  }
913
1209
  return rects;
914
1210
  }
915
- renderDrawing(param, scene) {
1211
+ renderDrawing(param, scene, options) {
916
1212
  const drawingParam = this._drawingManagerService.getDrawingByParam(param);
917
1213
  if (drawingParam == null) return;
918
1214
  switch (drawingParam.drawingType) {
919
- case _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE: return this.renderImages(drawingParam, scene);
1215
+ case _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE: return this.renderImages(drawingParam, scene, options);
920
1216
  default:
921
1217
  }
922
1218
  }
@@ -944,7 +1240,7 @@ let DrawingRenderService = class DrawingRenderService {
944
1240
  };
945
1241
  DrawingRenderService = __decorate([
946
1242
  __decorateParam(0, _univerjs_drawing.IDrawingManagerService),
947
- __decorateParam(1, _univerjs_drawing.IImageIoService),
1243
+ __decorateParam(1, _univerjs_core.IImageIoService),
948
1244
  __decorateParam(2, _univerjs_ui.IGalleryService),
949
1245
  __decorateParam(3, _univerjs_core.IURLImageService),
950
1246
  __decorateParam(4, _univerjs_core.IUniverInstanceService),
@@ -985,12 +1281,24 @@ function getUpdateParams(objects, drawingManagerService) {
985
1281
  //#endregion
986
1282
  //#region src/controllers/drawing-update.controller.ts
987
1283
  function hasRefreshMetadata(refreshParam) {
988
- return "hidden" in refreshParam || "behindText" in refreshParam;
1284
+ return "hidden" in refreshParam || "behindText" in refreshParam || "selectable" in refreshParam;
989
1285
  }
990
1286
  function syncDrawingHiddenState(shape, drawingParam) {
991
1287
  if (!("hidden" in drawingParam)) return;
992
1288
  drawingParam.hidden === true ? shape.hide() : shape.show();
993
1289
  }
1290
+ function syncDrawingSelectableState(shape, drawingParam, scene, drawingManagerService) {
1291
+ var _scene$getTransformer;
1292
+ const previousDrawing = drawingManagerService.getOldDrawingByParam(drawingParam);
1293
+ if (!("selectable" in drawingParam) && (!previousDrawing || !("selectable" in previousDrawing))) return;
1294
+ const selectable = drawingParam.selectable !== false;
1295
+ shape.evented = selectable;
1296
+ if (selectable) return;
1297
+ (_scene$getTransformer = scene.getTransformer()) === null || _scene$getTransformer === void 0 || _scene$getTransformer.clearControlByIds([shape.oKey]);
1298
+ const focusedDrawings = drawingManagerService.getFocusDrawings();
1299
+ const remainingDrawings = focusedDrawings.filter(({ unitId, subUnitId, drawingId }) => unitId !== drawingParam.unitId || subUnitId !== drawingParam.subUnitId || drawingId !== drawingParam.drawingId);
1300
+ if (remainingDrawings.length !== focusedDrawings.length) drawingManagerService.focusDrawing(remainingDrawings);
1301
+ }
994
1302
  function mergeRefreshMetadata(drawingParam, refreshParam) {
995
1303
  if (!hasRefreshMetadata(refreshParam)) return drawingParam;
996
1304
  return {
@@ -1320,8 +1628,8 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1320
1628
  subUnitId,
1321
1629
  drawingId
1322
1630
  })) {
1323
- var _scene$getTransformer;
1324
- (_scene$getTransformer = scene.getTransformer()) === null || _scene$getTransformer === void 0 || _scene$getTransformer.clearSelectedObjects();
1631
+ var _scene$getTransformer2;
1632
+ (_scene$getTransformer2 = scene.getTransformer()) === null || _scene$getTransformer2 === void 0 || _scene$getTransformer2.clearSelectedObjects();
1325
1633
  }
1326
1634
  });
1327
1635
  }));
@@ -1329,7 +1637,7 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1329
1637
  _drawingUpdateListener() {
1330
1638
  this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
1331
1639
  params.forEach((param) => {
1332
- var _setClipBounds, _scene$getTransformer2;
1640
+ var _setClipBounds, _scene$getTransformer3;
1333
1641
  const { unitId, subUnitId, drawingId } = param;
1334
1642
  const drawingParam = this._drawingManagerService.getDrawingByParam(param);
1335
1643
  if (drawingParam == null) return;
@@ -1344,7 +1652,7 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1344
1652
  subUnitId,
1345
1653
  drawingId
1346
1654
  });
1347
- const drawingShape = scene.getObject(drawingShapeKey);
1655
+ const drawingShape = scene.getObjectIncludeInGroup(drawingShapeKey);
1348
1656
  if (drawingShape == null) return true;
1349
1657
  drawingShape.transformByState({
1350
1658
  left,
@@ -1359,8 +1667,9 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1359
1667
  });
1360
1668
  (_setClipBounds = drawingShape.setClipBounds) === null || _setClipBounds === void 0 || _setClipBounds.call(drawingShape, transform.clipBounds);
1361
1669
  syncDrawingHiddenState(drawingShape, drawingParam);
1670
+ syncDrawingSelectableState(drawingShape, drawingParam, scene, this._drawingManagerService);
1362
1671
  ensureDrawingRenderLayer(scene, drawingShape, drawingParam);
1363
- (_scene$getTransformer2 = scene.getTransformer()) === null || _scene$getTransformer2 === void 0 || _scene$getTransformer2.debounceRefreshControls();
1672
+ (_scene$getTransformer3 = scene.getTransformer()) === null || _scene$getTransformer3 === void 0 || _scene$getTransformer3.debounceRefreshControls();
1364
1673
  });
1365
1674
  }));
1366
1675
  }
@@ -1406,6 +1715,7 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1406
1715
  });
1407
1716
  (_setClipBounds2 = drawingShape.setClipBounds) === null || _setClipBounds2 === void 0 || _setClipBounds2.call(drawingShape, transform.clipBounds);
1408
1717
  syncDrawingHiddenState(drawingShape, drawingParamWithRefreshMetadata);
1718
+ syncDrawingSelectableState(drawingShape, drawingParamWithRefreshMetadata, scene, this._drawingManagerService);
1409
1719
  ensureDrawingRenderLayer(scene, drawingShape, drawingParamWithRefreshMetadata);
1410
1720
  });
1411
1721
  }));
@@ -1422,7 +1732,7 @@ let DrawingUpdateController = class DrawingUpdateController extends _univerjs_co
1422
1732
  subUnitId,
1423
1733
  drawingId
1424
1734
  });
1425
- const drawingShape = scene.getObject(drawingShapeKey);
1735
+ const drawingShape = scene.getObjectIncludeInGroup(drawingShapeKey);
1426
1736
  if (drawingShape == null) return true;
1427
1737
  if (visible) drawingShape.show();
1428
1738
  else drawingShape.hide();
@@ -1980,403 +2290,142 @@ let ImageUpdateController = class ImageUpdateController extends _univerjs_core.D
1980
2290
  _commandExecutedListener() {
1981
2291
  this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
1982
2292
  if (command.id === ImageResetSizeOperation.id) {
1983
- const params = command.params;
1984
- if (params == null) return;
1985
- this._resetImageSize(params);
1986
- }
1987
- }));
1988
- }
1989
- _getSceneAndTransformerByDrawingSearch(unitId) {
1990
- if (unitId == null) return;
1991
- const renderObject = this._renderManagerService.getRenderById(unitId);
1992
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
1993
- if (scene == null) return null;
1994
- return {
1995
- scene,
1996
- transformer: scene.getTransformerByCreate()
1997
- };
1998
- }
1999
- _resetImageSize(params) {
2000
- const updateParams = [];
2001
- const sceneList = [];
2002
- params.forEach((param) => {
2003
- const { unitId, subUnitId, drawingId } = param;
2004
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2005
- if (renderObject == null) return;
2006
- const { scene } = renderObject;
2007
- const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2008
- unitId,
2009
- subUnitId,
2010
- drawingId
2011
- });
2012
- const imageShape = scene.getObject(imageShapeKey);
2013
- if (imageShape == null) return true;
2014
- const imageData = this._drawingManagerService.getDrawingByParam(param);
2015
- if (imageData == null) return true;
2016
- if (imageData.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2017
- imageShape.resetSize();
2018
- const { width, height } = imageShape.getNativeSize();
2019
- if (sceneList.includes(scene) === false) sceneList.push(scene);
2020
- updateParams.push({
2021
- ...imageData,
2022
- transform: {
2023
- ...imageData.transform,
2024
- height,
2025
- width,
2026
- angle: 0
2027
- },
2028
- srcRect: null,
2029
- prstGeom: null
2030
- });
2031
- });
2032
- this._drawingManagerService.featurePluginUpdateNotification(updateParams);
2033
- sceneList.forEach((scene) => {
2034
- scene.getTransformerByCreate().refreshControls().changeNotification();
2035
- });
2036
- this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, params);
2037
- }
2038
- _drawingAddListener() {
2039
- this.disposeWithMe(this._drawingManagerService.add$.pipe((0, rxjs.bufferTime)(33), (0, rxjs.filter)((batches) => batches.length > 0), (0, rxjs.map)((batches) => batches.flat()), (0, rxjs.map)((items) => {
2040
- const map = /* @__PURE__ */ new Map();
2041
- for (const it of items) map.set(`${it.unitId}|${it.subUnitId}|${it.drawingId}`, it);
2042
- return [...map.values()];
2043
- }), (0, rxjs.filter)((items) => items.length > 0)).subscribe((uniqueParams) => {
2044
- this._insertImages(uniqueParams);
2045
- }));
2046
- }
2047
- _insertImages(params) {
2048
- params.forEach(async (param) => {
2049
- var _getCurrentUnitInfo;
2050
- const { unitId, subUnitId } = param;
2051
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2052
- const currentSubUnitId = (_getCurrentUnitInfo = getCurrentUnitInfo(this._currentUniverService, unitId)) === null || _getCurrentUnitInfo === void 0 ? void 0 : _getCurrentUnitInfo.subUnitId;
2053
- if (renderObject == null || currentSubUnitId !== subUnitId) return;
2054
- const imageParam = this._drawingManagerService.getDrawingByParam(param);
2055
- if (imageParam == null) return;
2056
- const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
2057
- this._drawingManagerService.refreshTransform([imageParam]);
2058
- if (images == null || images.length === 0) return;
2059
- for (const image of images) {
2060
- this._addHoverForImage(image);
2061
- this._addDialogForImage(image);
2062
- }
2063
- });
2064
- }
2065
- _imageUpdateListener() {
2066
- this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
2067
- params.forEach((param) => {
2068
- var _setClipBounds;
2069
- const { unitId, subUnitId, drawingId } = param;
2070
- const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2071
- if (drawingParam == null) return;
2072
- const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
2073
- if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2074
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2075
- if (renderObject == null) return;
2076
- const { scene, transformer } = renderObject;
2077
- if (transform == null) return true;
2078
- const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2079
- unitId,
2080
- subUnitId,
2081
- drawingId
2082
- });
2083
- const imageShape = scene.getObject(drawingShapeKey);
2084
- if (imageShape == null) return true;
2085
- imageShape.transformByState(transform);
2086
- (_setClipBounds = imageShape.setClipBounds) === null || _setClipBounds === void 0 || _setClipBounds.call(imageShape, transform.clipBounds);
2087
- ensureDrawingRenderLayer(scene, imageShape, drawingParam);
2088
- imageShape.setSrcRect(srcRect);
2089
- imageShape.setPrstGeom(prstGeom);
2090
- if (source != null && source.length > 0 && (imageSourceType === _univerjs_core.ImageSourceType.BASE64 || imageSourceType === _univerjs_core.ImageSourceType.URL)) imageShape.changeSource(source);
2091
- });
2092
- }));
2093
- }
2094
- _addHoverForImage(o) {
2095
- this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerEnter$.subscribeEvent(() => {
2096
- o.cursor = _univerjs_engine_render.CURSOR_TYPE.GRAB;
2097
- })));
2098
- this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerLeave$.subscribeEvent(() => {
2099
- o.cursor = _univerjs_engine_render.CURSOR_TYPE.DEFAULT;
2100
- })));
2101
- }
2102
- _addDialogForImage(o) {
2103
- this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onDblclick$.subscribeEvent(() => {
2104
- const dialogId = `${o.oKey}-viewer-dialog`;
2105
- this._drawingRenderService.previewImage(dialogId, o.getNative().src, o.getNativeSize().width, o.getNativeSize().height);
2106
- })));
2107
- }
2108
- };
2109
- ImageUpdateController = __decorate([
2110
- __decorateParam(0, _univerjs_core.ICommandService),
2111
- __decorateParam(1, _univerjs_engine_render.IRenderManagerService),
2112
- __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
2113
- __decorateParam(3, _univerjs_ui.IDialogService),
2114
- __decorateParam(4, _univerjs_drawing.IImageIoService),
2115
- __decorateParam(5, _univerjs_core.IUniverInstanceService),
2116
- __decorateParam(6, (0, _univerjs_core.Inject)(DrawingRenderService))
2117
- ], ImageUpdateController);
2118
-
2119
- //#endregion
2120
- //#region src/menu/align.menu.ts
2121
- const getMenuStateByDrawingFocusChangedObservable$$1 = (accessor) => {
2122
- const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
2123
- return new rxjs.Observable((subscriber) => {
2124
- const update = (drawings) => {
2125
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2126
- if (drawings.length < 2) return subscriber.next(true);
2127
- subscriber.next(false);
2128
- };
2129
- const subscription = drawingManagerService.focus$.subscribe((drawings) => {
2130
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2131
- update(drawings);
2132
- });
2133
- update(drawingManagerService.getFocusDrawings());
2134
- return () => subscription.unsubscribe();
2135
- });
2136
- };
2137
- const DRAWING_ALIGN_CONTEXT_MENU_ID = "contextMenu.drawing-align";
2138
- function DrawingAlignContextMenuItemFactory(accessor) {
2139
- return {
2140
- id: DRAWING_ALIGN_CONTEXT_MENU_ID,
2141
- type: _univerjs_ui.MenuItemType.SUBITEMS,
2142
- icon: "HorizontallyIcon",
2143
- title: "drawing-ui.image-panel.align.title",
2144
- hidden$: getMenuStateByDrawingFocusChangedObservable$$1(accessor)
2145
- };
2146
- }
2147
- function SetDrawingAlignLeftMenuItemFactory() {
2148
- return {
2149
- id: SetDrawingAlignLeftOperation.id,
2150
- type: _univerjs_ui.MenuItemType.BUTTON,
2151
- icon: "LeftJustifyingIcon",
2152
- title: "drawing-ui.image-panel.align.left"
2153
- };
2154
- }
2155
- function SetDrawingAlignCenterMenuItemFactory() {
2156
- return {
2157
- id: SetDrawingAlignCenterOperation.id,
2158
- type: _univerjs_ui.MenuItemType.BUTTON,
2159
- icon: "HorizontallyIcon",
2160
- title: "drawing-ui.image-panel.align.center"
2161
- };
2162
- }
2163
- function SetDrawingAlignRightMenuItemFactory() {
2164
- return {
2165
- id: SetDrawingAlignRightOperation.id,
2166
- type: _univerjs_ui.MenuItemType.BUTTON,
2167
- icon: "RightJustifyingIcon",
2168
- title: "drawing-ui.image-panel.align.right"
2169
- };
2170
- }
2171
- function SetDrawingAlignTopMenuItemFactory() {
2172
- return {
2173
- id: SetDrawingAlignTopOperation.id,
2174
- type: _univerjs_ui.MenuItemType.BUTTON,
2175
- icon: "AlignTopIcon",
2176
- title: "drawing-ui.image-panel.align.top"
2177
- };
2178
- }
2179
- function SetDrawingAlignMiddleMenuItemFactory() {
2180
- return {
2181
- id: SetDrawingAlignMiddleOperation.id,
2182
- type: _univerjs_ui.MenuItemType.BUTTON,
2183
- icon: "VerticalCenterIcon",
2184
- title: "drawing-ui.image-panel.align.middle"
2185
- };
2186
- }
2187
- function SetDrawingAlignBottomMenuItemFactory() {
2188
- return {
2189
- id: SetDrawingAlignBottomOperation.id,
2190
- type: _univerjs_ui.MenuItemType.BUTTON,
2191
- icon: "AlignBottomIcon",
2192
- title: "drawing-ui.image-panel.align.bottom"
2193
- };
2194
- }
2195
- function SetDrawingAlignHorizonMenuItemFactory() {
2196
- return {
2197
- id: SetDrawingAlignHorizonOperation.id,
2198
- type: _univerjs_ui.MenuItemType.BUTTON,
2199
- icon: "HorizontallyIcon",
2200
- title: "drawing-ui.image-panel.align.horizon"
2201
- };
2202
- }
2203
- function SetDrawingAlignVerticalMenuItemFactory() {
2204
- return {
2205
- id: SetDrawingAlignVerticalOperation.id,
2206
- type: _univerjs_ui.MenuItemType.BUTTON,
2207
- icon: "VerticalCenterIcon",
2208
- title: "drawing-ui.image-panel.align.vertical"
2209
- };
2210
- }
2211
-
2212
- //#endregion
2213
- //#region src/menu/arrange.menu.ts
2214
- const DRAWING_ARRANGE_CONTEXT_MENU_ID = "contextMenu.drawing-arrange";
2215
- function DrawingArrangeContextMenuItemFactory() {
2216
- return {
2217
- id: DRAWING_ARRANGE_CONTEXT_MENU_ID,
2218
- type: _univerjs_ui.MenuItemType.SUBITEMS,
2219
- icon: "TopmostIcon",
2220
- title: "drawing-ui.image-panel.arrange.title"
2221
- };
2222
- }
2223
- function SetDrawingArrangeFrontMenuItemFactory() {
2224
- return {
2225
- id: SetDrawingArrangeFrontOperation.id,
2226
- type: _univerjs_ui.MenuItemType.BUTTON,
2227
- icon: "TopmostIcon",
2228
- title: "drawing-ui.image-panel.arrange.front"
2229
- };
2230
- }
2231
- function SetDrawingArrangeForwardMenuItemFactory() {
2232
- return {
2233
- id: SetDrawingArrangeForwardOperation.id,
2234
- type: _univerjs_ui.MenuItemType.BUTTON,
2235
- icon: "MoveUpIcon",
2236
- title: "drawing-ui.image-panel.arrange.forward"
2237
- };
2238
- }
2239
- function SetDrawingArrangeBackMenuItemFactory() {
2240
- return {
2241
- id: SetDrawingArrangeBackOperation.id,
2242
- type: _univerjs_ui.MenuItemType.BUTTON,
2243
- icon: "BottomIcon",
2244
- title: "drawing-ui.image-panel.arrange.back"
2245
- };
2246
- }
2247
- function SetDrawingArrangeBackwardMenuItemFactory() {
2248
- return {
2249
- id: SetDrawingArrangeBackwardOperation.id,
2250
- type: _univerjs_ui.MenuItemType.BUTTON,
2251
- icon: "MoveDownIcon",
2252
- title: "drawing-ui.image-panel.arrange.backward"
2253
- };
2254
- }
2255
-
2256
- //#endregion
2257
- //#region src/menu/group.menu.ts
2258
- function getMenuStateByDrawingFocusChangedObservable$(accessor, type) {
2259
- const drawingManagerService = accessor.get(_univerjs_drawing.IDrawingManagerService);
2260
- return new rxjs.Observable((subscriber) => {
2261
- const update = (drawings) => {
2262
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2263
- if (type === "group") {
2264
- if (drawings.length < 2) return subscriber.next(true);
2265
- if (!drawings.every((drawing) => (0, _univerjs_drawing.isGroupableDrawingType)(drawing.drawingType))) return subscriber.next(true);
2266
- } else if (type === "unGroup") {
2267
- if (drawings.filter((drawing) => drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP).length === 0) return subscriber.next(true);
2268
- } else if (!drawings.every((drawing) => (0, _univerjs_drawing.isGroupableDrawingType)(drawing.drawingType))) return subscriber.next(true);
2269
- subscriber.next(false);
2270
- };
2271
- const subscription = drawingManagerService.focus$.subscribe((drawings) => {
2272
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2273
- update(drawings);
2274
- });
2275
- update(drawingManagerService.getFocusDrawings());
2276
- return () => subscription.unsubscribe();
2277
- });
2278
- }
2279
- const DRAWING_GROUP_CONTEXT_MENU_ID = "contextMenu.drawing-group";
2280
- function DrawingGroupContextMenuItemFactory(accessor) {
2281
- return {
2282
- id: DRAWING_GROUP_CONTEXT_MENU_ID,
2283
- type: _univerjs_ui.MenuItemType.SUBITEMS,
2284
- icon: "GroupIcon",
2285
- title: "drawing-ui.image-panel.group.title",
2286
- hidden$: getMenuStateByDrawingFocusChangedObservable$(accessor)
2287
- };
2288
- }
2289
- function SetDrawingGroupMenuItemFactory(accessor) {
2290
- return {
2291
- id: SetDrawingGroupOperation.id,
2292
- type: _univerjs_ui.MenuItemType.BUTTON,
2293
- icon: "GroupIcon",
2294
- title: "drawing-ui.image-panel.group.group",
2295
- disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "group")
2296
- };
2297
- }
2298
- function CancelDrawingGroupMenuItemFactory(accessor) {
2299
- return {
2300
- id: CancelDrawingGroupOperation.id,
2301
- type: _univerjs_ui.MenuItemType.BUTTON,
2302
- icon: "UngroupIcon",
2303
- title: "drawing-ui.image-panel.group.unGroup",
2304
- disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "unGroup")
2305
- };
2306
- }
2307
-
2308
- //#endregion
2309
- //#region src/menu/schema.ts
2310
- const menuSchema = { [_univerjs_ui.ContextMenuPosition.DRAWING]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: {
2311
- [DRAWING_GROUP_CONTEXT_MENU_ID]: {
2312
- order: 1,
2313
- menuItemFactory: DrawingGroupContextMenuItemFactory,
2314
- [SetDrawingGroupOperation.id]: {
2315
- order: 0,
2316
- menuItemFactory: SetDrawingGroupMenuItemFactory
2317
- },
2318
- [CancelDrawingGroupOperation.id]: {
2319
- order: 1,
2320
- menuItemFactory: CancelDrawingGroupMenuItemFactory
2321
- }
2322
- },
2323
- [DRAWING_ARRANGE_CONTEXT_MENU_ID]: {
2324
- order: 2,
2325
- menuItemFactory: DrawingArrangeContextMenuItemFactory,
2326
- [SetDrawingArrangeFrontOperation.id]: {
2327
- order: 0,
2328
- menuItemFactory: SetDrawingArrangeFrontMenuItemFactory
2329
- },
2330
- [SetDrawingArrangeForwardOperation.id]: {
2331
- order: 1,
2332
- menuItemFactory: SetDrawingArrangeForwardMenuItemFactory
2333
- },
2334
- [SetDrawingArrangeBackOperation.id]: {
2335
- order: 2,
2336
- menuItemFactory: SetDrawingArrangeBackMenuItemFactory
2337
- },
2338
- [SetDrawingArrangeBackwardOperation.id]: {
2339
- order: 3,
2340
- menuItemFactory: SetDrawingArrangeBackwardMenuItemFactory
2341
- }
2342
- },
2343
- [DRAWING_ALIGN_CONTEXT_MENU_ID]: {
2344
- order: 3,
2345
- menuItemFactory: DrawingAlignContextMenuItemFactory,
2346
- [SetDrawingAlignLeftOperation.id]: {
2347
- order: 0,
2348
- menuItemFactory: SetDrawingAlignLeftMenuItemFactory
2349
- },
2350
- [SetDrawingAlignCenterOperation.id]: {
2351
- order: 1,
2352
- menuItemFactory: SetDrawingAlignCenterMenuItemFactory
2353
- },
2354
- [SetDrawingAlignRightOperation.id]: {
2355
- order: 2,
2356
- menuItemFactory: SetDrawingAlignRightMenuItemFactory
2357
- },
2358
- [SetDrawingAlignTopOperation.id]: {
2359
- order: 3,
2360
- menuItemFactory: SetDrawingAlignTopMenuItemFactory
2361
- },
2362
- [SetDrawingAlignMiddleOperation.id]: {
2363
- order: 4,
2364
- menuItemFactory: SetDrawingAlignMiddleMenuItemFactory
2365
- },
2366
- [SetDrawingAlignBottomOperation.id]: {
2367
- order: 5,
2368
- menuItemFactory: SetDrawingAlignBottomMenuItemFactory
2369
- },
2370
- [SetDrawingAlignHorizonOperation.id]: {
2371
- order: 6,
2372
- menuItemFactory: SetDrawingAlignHorizonMenuItemFactory
2373
- },
2374
- [SetDrawingAlignVerticalOperation.id]: {
2375
- order: 7,
2376
- menuItemFactory: SetDrawingAlignVerticalMenuItemFactory
2377
- }
2293
+ const params = command.params;
2294
+ if (params == null) return;
2295
+ this._resetImageSize(params);
2296
+ }
2297
+ }));
2378
2298
  }
2379
- } } };
2299
+ _getSceneAndTransformerByDrawingSearch(unitId) {
2300
+ if (unitId == null) return;
2301
+ const renderObject = this._renderManagerService.getRenderById(unitId);
2302
+ const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2303
+ if (scene == null) return null;
2304
+ return {
2305
+ scene,
2306
+ transformer: scene.getTransformerByCreate()
2307
+ };
2308
+ }
2309
+ _resetImageSize(params) {
2310
+ const updateParams = [];
2311
+ const sceneList = [];
2312
+ params.forEach((param) => {
2313
+ const { unitId, subUnitId, drawingId } = param;
2314
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2315
+ if (renderObject == null) return;
2316
+ const { scene } = renderObject;
2317
+ const imageShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2318
+ unitId,
2319
+ subUnitId,
2320
+ drawingId
2321
+ });
2322
+ const imageShape = scene.getObject(imageShapeKey);
2323
+ if (imageShape == null) return true;
2324
+ const imageData = this._drawingManagerService.getDrawingByParam(param);
2325
+ if (imageData == null) return true;
2326
+ if (imageData.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2327
+ imageShape.resetSize();
2328
+ const { width, height } = imageShape.getNativeSize();
2329
+ if (sceneList.includes(scene) === false) sceneList.push(scene);
2330
+ updateParams.push({
2331
+ ...imageData,
2332
+ transform: {
2333
+ ...imageData.transform,
2334
+ height,
2335
+ width,
2336
+ angle: 0
2337
+ },
2338
+ srcRect: null,
2339
+ prstGeom: null
2340
+ });
2341
+ });
2342
+ this._drawingManagerService.featurePluginUpdateNotification(updateParams);
2343
+ sceneList.forEach((scene) => {
2344
+ scene.getTransformerByCreate().refreshControls().changeNotification();
2345
+ });
2346
+ this._commandService.syncExecuteCommand(_univerjs_drawing.SetDrawingSelectedOperation.id, params);
2347
+ }
2348
+ _drawingAddListener() {
2349
+ this.disposeWithMe(this._drawingManagerService.add$.pipe((0, rxjs.bufferTime)(33), (0, rxjs.filter)((batches) => batches.length > 0), (0, rxjs.map)((batches) => batches.flat()), (0, rxjs.map)((items) => {
2350
+ const map = /* @__PURE__ */ new Map();
2351
+ for (const it of items) map.set(`${it.unitId}|${it.subUnitId}|${it.drawingId}`, it);
2352
+ return [...map.values()];
2353
+ }), (0, rxjs.filter)((items) => items.length > 0)).subscribe((uniqueParams) => {
2354
+ this._insertImages(uniqueParams);
2355
+ }));
2356
+ }
2357
+ _insertImages(params) {
2358
+ params.forEach(async (param) => {
2359
+ var _getCurrentUnitInfo;
2360
+ const { unitId, subUnitId } = param;
2361
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2362
+ const currentSubUnitId = (_getCurrentUnitInfo = getCurrentUnitInfo(this._currentUniverService, unitId)) === null || _getCurrentUnitInfo === void 0 ? void 0 : _getCurrentUnitInfo.subUnitId;
2363
+ if (renderObject == null || currentSubUnitId !== subUnitId) return;
2364
+ const imageParam = this._drawingManagerService.getDrawingByParam(param);
2365
+ if (imageParam == null) return;
2366
+ const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
2367
+ const currentImageParam = this._drawingManagerService.getDrawingByParam(param);
2368
+ if (currentImageParam) this._drawingManagerService.refreshTransform([currentImageParam]);
2369
+ if (images == null || images.length === 0) return;
2370
+ for (const image of images) {
2371
+ this._addHoverForImage(image);
2372
+ this._addDialogForImage(image);
2373
+ }
2374
+ });
2375
+ }
2376
+ _imageUpdateListener() {
2377
+ this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
2378
+ params.forEach((param) => {
2379
+ var _setClipBounds;
2380
+ const { unitId, subUnitId, drawingId } = param;
2381
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2382
+ if (drawingParam == null) return;
2383
+ const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
2384
+ if (drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE) return;
2385
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2386
+ if (renderObject == null) return;
2387
+ const { scene, transformer } = renderObject;
2388
+ if (transform == null) return true;
2389
+ const drawingShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2390
+ unitId,
2391
+ subUnitId,
2392
+ drawingId
2393
+ });
2394
+ const imageShape = scene.getObject(drawingShapeKey);
2395
+ if (imageShape == null) return true;
2396
+ imageShape.transformByState(transform);
2397
+ (_setClipBounds = imageShape.setClipBounds) === null || _setClipBounds === void 0 || _setClipBounds.call(imageShape, transform.clipBounds);
2398
+ ensureDrawingRenderLayer(scene, imageShape, drawingParam);
2399
+ imageShape.setSrcRect(srcRect);
2400
+ imageShape.setPrstGeom(prstGeom);
2401
+ if (source != null && source.length > 0 && (imageSourceType === _univerjs_core.ImageSourceType.BASE64 || imageSourceType === _univerjs_core.ImageSourceType.URL)) imageShape.changeSource(source);
2402
+ });
2403
+ }));
2404
+ }
2405
+ _addHoverForImage(o) {
2406
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerEnter$.subscribeEvent(() => {
2407
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.GRAB;
2408
+ })));
2409
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onPointerLeave$.subscribeEvent(() => {
2410
+ o.cursor = _univerjs_engine_render.CURSOR_TYPE.DEFAULT;
2411
+ })));
2412
+ }
2413
+ _addDialogForImage(o) {
2414
+ this.disposeWithMe((0, _univerjs_core.toDisposable)(o.onDblclick$.subscribeEvent(() => {
2415
+ const dialogId = `${o.oKey}-viewer-dialog`;
2416
+ this._drawingRenderService.previewImage(dialogId, o.getNative().src, o.getNativeSize().width, o.getNativeSize().height);
2417
+ })));
2418
+ }
2419
+ };
2420
+ ImageUpdateController = __decorate([
2421
+ __decorateParam(0, _univerjs_core.ICommandService),
2422
+ __decorateParam(1, _univerjs_engine_render.IRenderManagerService),
2423
+ __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
2424
+ __decorateParam(3, _univerjs_ui.IDialogService),
2425
+ __decorateParam(4, _univerjs_core.IImageIoService),
2426
+ __decorateParam(5, _univerjs_core.IUniverInstanceService),
2427
+ __decorateParam(6, (0, _univerjs_core.Inject)(DrawingRenderService))
2428
+ ], ImageUpdateController);
2380
2429
 
2381
2430
  //#endregion
2382
2431
  //#region src/controllers/ui.controller.ts
@@ -2475,6 +2524,482 @@ _defineProperty(UniverDrawingUIPlugin, "packageName", name);
2475
2524
  _defineProperty(UniverDrawingUIPlugin, "version", version);
2476
2525
  UniverDrawingUIPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverDrawingUIPlugin);
2477
2526
 
2527
+ //#endregion
2528
+ //#region src/views/object-list-panel/object-list-panel-layer.ts
2529
+ const OBJECT_LIST_FLOATING_SECTION_ID = "floating";
2530
+ const OBJECT_LIST_CANVAS_SECTION_ID = "canvas";
2531
+ function isFloatingObjectListDrawingType(drawingType) {
2532
+ return drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_CHART || drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_DOM || drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_UNIT;
2533
+ }
2534
+ function getObjectListPanelSectionIdForDrawingType(drawingType) {
2535
+ return isFloatingObjectListDrawingType(drawingType) ? OBJECT_LIST_FLOATING_SECTION_ID : OBJECT_LIST_CANVAS_SECTION_ID;
2536
+ }
2537
+
2538
+ //#endregion
2539
+ //#region src/views/object-list-panel/ObjectListPanelBase.tsx
2540
+ const objectListPanelLabelKeys = {
2541
+ title: "drawing-ui.objectListPanel.title",
2542
+ empty: "drawing-ui.objectListPanel.empty",
2543
+ showAll: "drawing-ui.objectListPanel.showAll",
2544
+ hideAll: "drawing-ui.objectListPanel.hideAll",
2545
+ moveForward: "drawing-ui.objectListPanel.moveForward",
2546
+ moveBackward: "drawing-ui.objectListPanel.moveBackward",
2547
+ close: "drawing-ui.objectListPanel.close",
2548
+ show: "drawing-ui.objectListPanel.show",
2549
+ hide: "drawing-ui.objectListPanel.hide",
2550
+ lock: "drawing-ui.objectListPanel.lock",
2551
+ unlock: "drawing-ui.objectListPanel.unlock",
2552
+ name: "drawing-ui.objectListPanel.name",
2553
+ nameInput: "drawing-ui.objectListPanel.nameInput",
2554
+ description: "drawing-ui.objectListPanel.description",
2555
+ descriptionPlaceholder: "drawing-ui.objectListPanel.descriptionPlaceholder",
2556
+ details: "drawing-ui.objectListPanel.details",
2557
+ noSelection: "drawing-ui.objectListPanel.noSelection",
2558
+ locate: "drawing-ui.objectListPanel.locate",
2559
+ expand: "drawing-ui.objectListPanel.expand",
2560
+ collapse: "drawing-ui.objectListPanel.collapse",
2561
+ dragToReorder: "drawing-ui.objectListPanel.dragToReorder",
2562
+ search: "drawing-ui.objectListPanel.search",
2563
+ filterAll: "drawing-ui.objectListPanel.filterAll",
2564
+ filterHidden: "drawing-ui.objectListPanel.filterHidden",
2565
+ filterLocked: "drawing-ui.objectListPanel.filterLocked",
2566
+ sectionCanvas: "drawing-ui.objectListPanel.sectionCanvas",
2567
+ sectionFloating: "drawing-ui.objectListPanel.sectionFloating"
2568
+ };
2569
+ function getObjectListPanelLabels(localeService) {
2570
+ return Object.fromEntries(Object.entries(objectListPanelLabelKeys).map(([labelKey, localeKey]) => [labelKey, localeService.t(localeKey)]));
2571
+ }
2572
+ function getObjectListPanelTypeName(localeService, typeName) {
2573
+ return localeService.t(`drawing-ui.objectListPanel.typeNames.${typeName}`);
2574
+ }
2575
+ const iconButtonClassName = `
2576
+ univer-flex univer-size-7 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-md
2577
+ univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-colors
2578
+ hover:univer-bg-gray-100 hover:univer-text-gray-900
2579
+ disabled:univer-cursor-not-allowed disabled:univer-opacity-40
2580
+ dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-100
2581
+ `;
2582
+ const sectionOrder = /* @__PURE__ */ new Map([
2583
+ [OBJECT_LIST_FLOATING_SECTION_ID, 0],
2584
+ [OBJECT_LIST_CANVAS_SECTION_ID, 1],
2585
+ ["", 2]
2586
+ ]);
2587
+ function normalizeText(value) {
2588
+ return value.trim();
2589
+ }
2590
+ function hasCapability(panelCapabilities, item, key, fallback = true) {
2591
+ var _ref, _item$capabilities$ke, _item$capabilities;
2592
+ return (_ref = (_item$capabilities$ke = item === null || item === void 0 || (_item$capabilities = item.capabilities) === null || _item$capabilities === void 0 ? void 0 : _item$capabilities[key]) !== null && _item$capabilities$ke !== void 0 ? _item$capabilities$ke : panelCapabilities === null || panelCapabilities === void 0 ? void 0 : panelCapabilities[key]) !== null && _ref !== void 0 ? _ref : fallback;
2593
+ }
2594
+ function ObjectListPanelBase(props) {
2595
+ var _selectedItem$canMove, _selectedItem$canMove2, _capabilities$reorder;
2596
+ const { items, selectedIds, allObjectIds, focusedId, labels, showHeader = true, capabilities, onSelect, onSetVisible, onCommitName, onCommitDescription, onMoveForward, onMoveBackward, onToggleExpanded, onToggleSelectable, onLocate, onReorder } = props;
2597
+ const selectedIdSet = (0, react.useMemo)(() => new Set(selectedIds), [selectedIds]);
2598
+ const [draggingId, setDraggingId] = (0, react.useState)(null);
2599
+ const [searchQuery, setSearchQuery] = (0, react.useState)("");
2600
+ const [filterMode, setFilterMode] = (0, react.useState)("all");
2601
+ const [collapsedSectionIds, setCollapsedSectionIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
2602
+ const selectedItem = (0, react.useMemo)(() => {
2603
+ var _ref2, _items$find;
2604
+ return (_ref2 = (_items$find = items.find((item) => item.id === focusedId)) !== null && _items$find !== void 0 ? _items$find : items.find((item) => selectedIdSet.has(item.id))) !== null && _ref2 !== void 0 ? _ref2 : null;
2605
+ }, [
2606
+ focusedId,
2607
+ items,
2608
+ selectedIdSet
2609
+ ]);
2610
+ const visibleItems = (0, react.useMemo)(() => {
2611
+ const normalizedQuery = normalizeText(searchQuery).toLocaleLowerCase();
2612
+ return items.filter((item) => {
2613
+ var _item$description;
2614
+ if (filterMode === "hidden" && item.visible !== false) return false;
2615
+ if (filterMode === "locked" && item.selectable !== false) return false;
2616
+ if (!normalizedQuery) return true;
2617
+ return item.name.toLocaleLowerCase().includes(normalizedQuery) || ((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : "").toLocaleLowerCase().includes(normalizedQuery);
2618
+ });
2619
+ }, [
2620
+ filterMode,
2621
+ items,
2622
+ searchQuery
2623
+ ]);
2624
+ const visibleItemSections = (0, react.useMemo)(() => {
2625
+ const sectionMap = /* @__PURE__ */ new Map();
2626
+ visibleItems.forEach((item) => {
2627
+ var _item$sectionId, _item$sectionTitle;
2628
+ const sectionId = (_item$sectionId = item.sectionId) !== null && _item$sectionId !== void 0 ? _item$sectionId : "";
2629
+ const existingSection = sectionMap.get(sectionId);
2630
+ if (existingSection) {
2631
+ existingSection.items.push(item);
2632
+ return;
2633
+ }
2634
+ sectionMap.set(sectionId, {
2635
+ id: sectionId,
2636
+ title: (_item$sectionTitle = item.sectionTitle) !== null && _item$sectionTitle !== void 0 ? _item$sectionTitle : "",
2637
+ items: [item]
2638
+ });
2639
+ });
2640
+ return [...sectionMap.values()].sort((a, b) => {
2641
+ var _sectionOrder$get, _sectionOrder$get2;
2642
+ return ((_sectionOrder$get = sectionOrder.get(a.id)) !== null && _sectionOrder$get !== void 0 ? _sectionOrder$get : 3) - ((_sectionOrder$get2 = sectionOrder.get(b.id)) !== null && _sectionOrder$get2 !== void 0 ? _sectionOrder$get2 : 3);
2643
+ });
2644
+ }, [visibleItems]);
2645
+ const showSectionHeaders = visibleItemSections.length > 1 || visibleItemSections.some((section) => section.id === "floating");
2646
+ const allIds = (0, react.useMemo)(() => allObjectIds !== null && allObjectIds !== void 0 ? allObjectIds : items.map((item) => item.id), [allObjectIds, items]);
2647
+ const selectedIndex = selectedItem ? items.findIndex((item) => item.id === selectedItem.id) : -1;
2648
+ const canMoveForward = !!selectedItem && !!onMoveForward && !selectedItem.disabled && ((_selectedItem$canMove = selectedItem.canMoveForward) !== null && _selectedItem$canMove !== void 0 ? _selectedItem$canMove : selectedIndex > 0) && hasCapability(capabilities, selectedItem, "arrange");
2649
+ const canMoveBackward = !!selectedItem && !!onMoveBackward && !selectedItem.disabled && ((_selectedItem$canMove2 = selectedItem.canMoveBackward) !== null && _selectedItem$canMove2 !== void 0 ? _selectedItem$canMove2 : selectedIndex >= 0 && selectedIndex < items.length - 1) && hasCapability(capabilities, selectedItem, "arrange");
2650
+ const showArrangeControls = hasCapability(capabilities, selectedItem, "arrange") && (!!onMoveForward || !!onMoveBackward);
2651
+ const showLocateControl = !!onLocate && hasCapability(capabilities, selectedItem, "locate");
2652
+ const canReorder = !!onReorder && ((_capabilities$reorder = capabilities === null || capabilities === void 0 ? void 0 : capabilities.reorder) !== null && _capabilities$reorder !== void 0 ? _capabilities$reorder : true);
2653
+ const findItem = (objectId) => {
2654
+ var _items$find2;
2655
+ return objectId ? (_items$find2 = items.find((item) => item.id === objectId)) !== null && _items$find2 !== void 0 ? _items$find2 : null : null;
2656
+ };
2657
+ const handleDrop = (targetId) => {
2658
+ var _source$parentId, _target$parentId, _source$sectionId, _target$sectionId;
2659
+ const source = findItem(draggingId);
2660
+ const target = findItem(targetId);
2661
+ setDraggingId(null);
2662
+ if (!source || !target || source.id === target.id || source.disabled || target.disabled) return;
2663
+ if (((_source$parentId = source.parentId) !== null && _source$parentId !== void 0 ? _source$parentId : "") !== ((_target$parentId = target.parentId) !== null && _target$parentId !== void 0 ? _target$parentId : "")) return;
2664
+ if (((_source$sectionId = source.sectionId) !== null && _source$sectionId !== void 0 ? _source$sectionId : "") !== ((_target$sectionId = target.sectionId) !== null && _target$sectionId !== void 0 ? _target$sectionId : "")) return;
2665
+ if (source.canReorder === false || target.canReorder === false) return;
2666
+ onReorder === null || onReorder === void 0 || onReorder(source.id, target.id);
2667
+ };
2668
+ const toggleSectionCollapsed = (sectionId) => {
2669
+ if (!sectionId) return;
2670
+ setCollapsedSectionIds((current) => {
2671
+ const next = new Set(current);
2672
+ if (next.has(sectionId)) next.delete(sectionId);
2673
+ else next.add(sectionId);
2674
+ return next;
2675
+ });
2676
+ };
2677
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2678
+ className: "univer-box-border univer-flex univer-size-full univer-min-w-0 univer-max-w-full univer-flex-col univer-gap-3 univer-overflow-hidden univer-text-gray-700 dark:!univer-text-gray-200",
2679
+ "data-drawing-object-list-panel": "true",
2680
+ children: [
2681
+ showHeader && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2682
+ className: "univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-gap-2",
2683
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2684
+ className: "univer-min-w-0 univer-flex-1 univer-truncate univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100",
2685
+ children: labels.title
2686
+ })
2687
+ }),
2688
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2689
+ className: "univer-flex univer-min-w-0 univer-items-center univer-justify-between univer-gap-2",
2690
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2691
+ className: "univer-flex univer-min-w-0 univer-gap-2",
2692
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
2693
+ size: "small",
2694
+ disabled: items.length === 0,
2695
+ onClick: () => onSetVisible(allIds, true),
2696
+ children: labels.showAll
2697
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
2698
+ size: "small",
2699
+ disabled: items.length === 0,
2700
+ onClick: () => onSetVisible(allIds, false),
2701
+ children: labels.hideAll
2702
+ })]
2703
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2704
+ className: "univer-flex univer-shrink-0 univer-gap-1",
2705
+ children: [showLocateControl && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2706
+ type: "button",
2707
+ className: iconButtonClassName,
2708
+ title: labels.locate,
2709
+ "aria-label": labels.locate,
2710
+ disabled: !(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id),
2711
+ onClick: () => selectedItem && (onLocate === null || onLocate === void 0 ? void 0 : onLocate(selectedItem.id)),
2712
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LocateFixedIcon, {})
2713
+ }), showArrangeControls && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2714
+ type: "button",
2715
+ className: iconButtonClassName,
2716
+ title: labels.moveForward,
2717
+ "aria-label": labels.moveForward,
2718
+ disabled: !canMoveForward,
2719
+ onClick: () => selectedItem && (onMoveForward === null || onMoveForward === void 0 ? void 0 : onMoveForward(selectedItem.id)),
2720
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ArrowUpIcon, {})
2721
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2722
+ type: "button",
2723
+ className: iconButtonClassName,
2724
+ title: labels.moveBackward,
2725
+ "aria-label": labels.moveBackward,
2726
+ disabled: !canMoveBackward,
2727
+ onClick: () => selectedItem && (onMoveBackward === null || onMoveBackward === void 0 ? void 0 : onMoveBackward(selectedItem.id)),
2728
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ArrowDownIcon, {})
2729
+ })] })]
2730
+ })]
2731
+ }),
2732
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2733
+ className: "univer-flex univer-shrink-0 univer-flex-col univer-gap-2",
2734
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
2735
+ value: searchQuery,
2736
+ "aria-label": labels.search,
2737
+ placeholder: labels.search,
2738
+ onChange: setSearchQuery
2739
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2740
+ className: "univer-flex univer-min-w-0 univer-gap-1",
2741
+ children: [
2742
+ ["all", labels.filterAll],
2743
+ ["hidden", labels.filterHidden],
2744
+ ["locked", labels.filterLocked]
2745
+ ].map(([mode, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2746
+ type: "button",
2747
+ className: (0, _univerjs_design.clsx)("univer-h-7 univer-min-w-0 univer-flex-1 univer-rounded-md univer-border univer-border-solid univer-px-2 univer-text-xs univer-outline-none univer-transition-colors dark:!univer-border-gray-700", filterMode === mode ? "dark:!univer-bg-primary-900/30 univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600 dark:!univer-text-primary-200" : "univer-border-gray-200 univer-bg-white univer-text-gray-600 hover:univer-bg-gray-50 dark:!univer-bg-gray-900 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800"),
2748
+ "aria-pressed": filterMode === mode,
2749
+ onClick: () => setFilterMode(mode),
2750
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2751
+ className: "univer-block univer-truncate",
2752
+ children: label
2753
+ })
2754
+ }, mode))
2755
+ })]
2756
+ }),
2757
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2758
+ className: "univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden",
2759
+ children: visibleItems.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2760
+ className: "univer-py-6 univer-text-center univer-text-sm univer-text-gray-500",
2761
+ children: labels.empty
2762
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2763
+ className: "univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5",
2764
+ children: visibleItemSections.map((section) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2765
+ className: "univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5",
2766
+ children: [showSectionHeaders && section.title && (() => {
2767
+ const sectionCollapsed = !!section.id && collapsedSectionIds.has(section.id);
2768
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2769
+ type: "button",
2770
+ className: "univer-box-border univer-flex univer-h-7 univer-w-full univer-items-center univer-gap-1 univer-rounded-md univer-border-0 univer-bg-transparent univer-px-2 univer-pt-1 univer-text-xs univer-font-semibold univer-uppercase univer-text-gray-400 univer-outline-none hover:univer-bg-gray-50 hover:univer-text-gray-600 disabled:univer-cursor-default disabled:hover:univer-bg-transparent dark:!univer-text-gray-500 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300",
2771
+ "aria-label": sectionCollapsed ? labels.expand : labels.collapse,
2772
+ disabled: !section.id,
2773
+ onClick: () => toggleSectionCollapsed(section.id),
2774
+ children: [
2775
+ section.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2776
+ className: "univer-flex univer-size-4 univer-shrink-0 univer-items-center univer-justify-center",
2777
+ children: sectionCollapsed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
2778
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "univer-size-4 univer-shrink-0" }),
2779
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2780
+ className: "univer-min-w-0 univer-flex-1 univer-truncate univer-text-left",
2781
+ children: section.title
2782
+ }),
2783
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2784
+ className: "univer-shrink-0 univer-text-[10px] univer-font-medium univer-text-gray-400 dark:!univer-text-gray-500",
2785
+ children: section.items.length
2786
+ })
2787
+ ]
2788
+ });
2789
+ })(), (!section.id || !collapsedSectionIds.has(section.id)) && section.items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ObjectListRow, {
2790
+ item,
2791
+ selected: selectedIdSet.has(item.id),
2792
+ labels,
2793
+ showLock: !!onToggleSelectable && hasCapability(capabilities, item, "selectable"),
2794
+ showName: hasCapability(capabilities, item, "name"),
2795
+ showVisible: hasCapability(capabilities, item, "visible"),
2796
+ draggable: canReorder && hasCapability(capabilities, item, "reorder") && !item.disabled && item.canReorder !== false,
2797
+ dragging: draggingId === item.id,
2798
+ onSelect: (multiSelect) => onSelect(item.id, multiSelect),
2799
+ onToggleExpanded: () => onToggleExpanded === null || onToggleExpanded === void 0 ? void 0 : onToggleExpanded(item.id),
2800
+ onToggleVisible: () => onSetVisible([item.id], !item.visible),
2801
+ onToggleSelectable: () => onToggleSelectable === null || onToggleSelectable === void 0 ? void 0 : onToggleSelectable(item.id),
2802
+ onCommitName: (value) => onCommitName(item.id, value),
2803
+ onDragStart: () => setDraggingId(item.id),
2804
+ onDragEnd: () => setDraggingId(null),
2805
+ onDrop: () => handleDrop(item.id)
2806
+ }, item.id))]
2807
+ }, section.id || "default"))
2808
+ })
2809
+ }),
2810
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ObjectDetailsEditor, {
2811
+ item: selectedItem,
2812
+ labels,
2813
+ showName: hasCapability(capabilities, selectedItem, "name"),
2814
+ showDescription: hasCapability(capabilities, selectedItem, "description"),
2815
+ onCommitName: (value) => selectedItem && onCommitName(selectedItem.id, value),
2816
+ onCommitDescription: (value) => selectedItem && onCommitDescription(selectedItem.id, value)
2817
+ })
2818
+ ]
2819
+ });
2820
+ }
2821
+ function ObjectListRow(props) {
2822
+ var _item$level;
2823
+ const { item, selected, labels, showLock, showName, showVisible, draggable, dragging, onSelect, onToggleExpanded, onToggleVisible, onToggleSelectable, onCommitName, onDragStart, onDragEnd, onDrop } = props;
2824
+ const [draftName, setDraftName] = (0, react.useState)(item.name);
2825
+ const skipCommitOnBlurRef = (0, react.useRef)(false);
2826
+ const disabled = item.disabled === true;
2827
+ const level = (_item$level = item.level) !== null && _item$level !== void 0 ? _item$level : 0;
2828
+ const locked = item.selectable === false;
2829
+ (0, react.useEffect)(() => {
2830
+ setDraftName(item.name);
2831
+ }, [item.name]);
2832
+ const handleBlur = (event) => {
2833
+ if (disabled) return;
2834
+ if (skipCommitOnBlurRef.current) {
2835
+ skipCommitOnBlurRef.current = false;
2836
+ return;
2837
+ }
2838
+ if (event.currentTarget.value !== item.name) onCommitName(event.currentTarget.value);
2839
+ };
2840
+ const handleKeyDown = (event) => {
2841
+ if (event.key === "Enter") {
2842
+ event.currentTarget.blur();
2843
+ return;
2844
+ }
2845
+ if (event.key === "Escape") {
2846
+ skipCommitOnBlurRef.current = true;
2847
+ setDraftName(item.name);
2848
+ event.currentTarget.blur();
2849
+ }
2850
+ };
2851
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2852
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-min-w-0 univer-max-w-full univer-items-center univer-gap-1.5 univer-overflow-hidden univer-rounded-md univer-pr-1.5 univer-transition-colors", !disabled && "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", selected && "univer-bg-gray-100 dark:!univer-bg-gray-800", disabled && "univer-text-gray-400 dark:!univer-text-gray-500", dragging && "univer-opacity-50"),
2853
+ style: { paddingLeft: level * 14 + 4 },
2854
+ draggable,
2855
+ title: draggable ? labels.dragToReorder : void 0,
2856
+ onClick: disabled ? void 0 : (event) => onSelect(event.ctrlKey || event.metaKey),
2857
+ onDragStart: (event) => {
2858
+ if (!draggable) {
2859
+ event.preventDefault();
2860
+ return;
2861
+ }
2862
+ event.dataTransfer.effectAllowed = "move";
2863
+ event.dataTransfer.setData("text/plain", item.id);
2864
+ onDragStart();
2865
+ },
2866
+ onDragEnd,
2867
+ onDragOver: (event) => {
2868
+ if (draggable) {
2869
+ event.preventDefault();
2870
+ event.dataTransfer.dropEffect = "move";
2871
+ }
2872
+ },
2873
+ onDrop: (event) => {
2874
+ event.preventDefault();
2875
+ onDrop();
2876
+ },
2877
+ children: [
2878
+ item.isGroup ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2879
+ type: "button",
2880
+ className: "univer-flex univer-size-5 univer-shrink-0 univer-items-center univer-justify-center univer-rounded univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-transform hover:univer-bg-gray-100 hover:univer-text-gray-900 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-100",
2881
+ title: item.expanded ? labels.collapse : labels.expand,
2882
+ "aria-label": item.expanded ? labels.collapse : labels.expand,
2883
+ onClick: (event) => {
2884
+ event.stopPropagation();
2885
+ onToggleExpanded();
2886
+ },
2887
+ children: item.expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, {})
2888
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "univer-size-5 univer-shrink-0" }),
2889
+ showName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
2890
+ className: (0, _univerjs_design.clsx)("univer-h-7 univer-w-0 univer-min-w-0 univer-flex-1", disabled && "univer-cursor-not-allowed"),
2891
+ inputClass: (0, _univerjs_design.clsx)("!univer-h-7 univer-min-w-0 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap !univer-rounded !univer-border-transparent !univer-bg-transparent !univer-px-1 univer-text-sm univer-text-gray-900 !univer-shadow-none focus:!univer-border-primary-500 focus:!univer-bg-white focus:!univer-ring-1 focus:!univer-ring-primary-100 disabled:!univer-bg-transparent disabled:univer-opacity-100 dark:!univer-text-gray-100 dark:focus:!univer-bg-gray-900 dark:focus:!univer-ring-primary-900", disabled && "univer-text-gray-400 dark:!univer-text-gray-500"),
2892
+ inputStyle: {
2893
+ maxWidth: "100%",
2894
+ boxSizing: "border-box"
2895
+ },
2896
+ value: draftName,
2897
+ disabled,
2898
+ "aria-label": labels.nameInput,
2899
+ onChange: setDraftName,
2900
+ onBlur: handleBlur,
2901
+ onKeyDown: handleKeyDown,
2902
+ onClick: (event) => {
2903
+ event.stopPropagation();
2904
+ if (!disabled) onSelect(event.ctrlKey || event.metaKey);
2905
+ }
2906
+ }, item.name) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2907
+ className: "univer-min-w-0 univer-flex-1 univer-truncate univer-px-1 univer-text-sm",
2908
+ children: item.name
2909
+ }),
2910
+ showLock && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2911
+ type: "button",
2912
+ className: (0, _univerjs_design.clsx)(iconButtonClassName, !locked && "univer-opacity-70"),
2913
+ disabled,
2914
+ title: locked ? labels.unlock : labels.lock,
2915
+ "aria-label": locked ? labels.unlock : labels.lock,
2916
+ onClick: (event) => {
2917
+ event.stopPropagation();
2918
+ onToggleSelectable();
2919
+ },
2920
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LockIcon, {})
2921
+ }),
2922
+ showVisible && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2923
+ type: "button",
2924
+ className: iconButtonClassName,
2925
+ disabled,
2926
+ title: item.visible ? labels.hide : labels.show,
2927
+ "aria-label": item.visible ? labels.hide : labels.show,
2928
+ onClick: (event) => {
2929
+ event.stopPropagation();
2930
+ onToggleVisible();
2931
+ },
2932
+ children: item.visible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.EyeIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.EyelashIcon, {})
2933
+ })
2934
+ ]
2935
+ });
2936
+ }
2937
+ function ObjectDetailsEditor(props) {
2938
+ var _item$name, _item$description2;
2939
+ const { item, labels, showName, showDescription, onCommitName, onCommitDescription } = props;
2940
+ const [draftName, setDraftName] = (0, react.useState)((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : "");
2941
+ const [draftDescription, setDraftDescription] = (0, react.useState)((_item$description2 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description2 !== void 0 ? _item$description2 : "");
2942
+ const disabled = (item === null || item === void 0 ? void 0 : item.disabled) === true;
2943
+ (0, react.useEffect)(() => {
2944
+ var _item$name2, _item$description3;
2945
+ setDraftName((_item$name2 = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name2 !== void 0 ? _item$name2 : "");
2946
+ setDraftDescription((_item$description3 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description3 !== void 0 ? _item$description3 : "");
2947
+ }, [
2948
+ item === null || item === void 0 ? void 0 : item.description,
2949
+ item === null || item === void 0 ? void 0 : item.id,
2950
+ item === null || item === void 0 ? void 0 : item.name
2951
+ ]);
2952
+ if (!item) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2953
+ className: "univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-p-3 univer-text-sm univer-text-gray-500 dark:!univer-border-gray-700 dark:!univer-text-gray-400",
2954
+ children: labels.noSelection
2955
+ });
2956
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2957
+ className: "univer-flex univer-shrink-0 univer-flex-col univer-gap-2 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-pt-3 dark:!univer-border-gray-700",
2958
+ children: [
2959
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2960
+ className: "univer-text-xs univer-font-semibold univer-uppercase univer-text-gray-500 dark:!univer-text-gray-400",
2961
+ children: labels.details
2962
+ }),
2963
+ showName && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2964
+ className: "univer-flex univer-flex-col univer-gap-1",
2965
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2966
+ className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
2967
+ children: labels.name
2968
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
2969
+ value: draftName,
2970
+ "aria-label": labels.nameInput,
2971
+ disabled,
2972
+ onChange: setDraftName,
2973
+ onBlur: () => {
2974
+ if (!disabled && normalizeText(draftName) !== item.name) onCommitName(draftName);
2975
+ },
2976
+ onKeyDown: (event) => {
2977
+ if (event.key === "Enter") event.currentTarget.blur();
2978
+ }
2979
+ })]
2980
+ }),
2981
+ showDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
2982
+ className: "univer-flex univer-flex-col univer-gap-1",
2983
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2984
+ className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
2985
+ children: labels.description
2986
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
2987
+ className: "univer-box-border univer-min-h-16 univer-w-full univer-resize-none univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-2 univer-text-sm univer-text-gray-900 univer-outline-none focus:univer-border-primary-500 focus:univer-ring-1 focus:univer-ring-primary-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-70 dark:!univer-border-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-gray-100 dark:focus:!univer-ring-primary-900",
2988
+ value: draftDescription,
2989
+ disabled,
2990
+ placeholder: labels.descriptionPlaceholder,
2991
+ "aria-label": labels.description,
2992
+ onChange: (event) => setDraftDescription(event.currentTarget.value),
2993
+ onBlur: () => {
2994
+ var _item$description4;
2995
+ if (!disabled && normalizeText(draftDescription) !== ((_item$description4 = item.description) !== null && _item$description4 !== void 0 ? _item$description4 : "")) onCommitDescription(draftDescription);
2996
+ }
2997
+ })]
2998
+ })
2999
+ ]
3000
+ });
3001
+ }
3002
+
2478
3003
  //#endregion
2479
3004
  //#region src/views/panel/DrawingAlign.tsx
2480
3005
  const DrawingAlign = (props) => {
@@ -2561,15 +3086,7 @@ const DrawingArrange = (props) => {
2561
3086
  const MoveDownIcon = iconManager.get("MoveDownIcon");
2562
3087
  const TopmostIcon = iconManager.get("TopmostIcon");
2563
3088
  const BottomIcon = iconManager.get("BottomIcon");
2564
- const [drawings, setDrawings] = (0, react.useState)(focusDrawings);
2565
- (0, react.useEffect)(() => {
2566
- const focusDispose = drawingManagerService.focus$.subscribe((drawings) => {
2567
- setDrawings(drawings);
2568
- });
2569
- return () => {
2570
- focusDispose.unsubscribe();
2571
- };
2572
- }, []);
3089
+ const drawings = (0, _univerjs_ui.useObservable)(() => drawingManagerService.focus$, focusDrawings, false, [drawingManagerService]);
2573
3090
  const onArrangeBtnClick = (arrangeType) => {
2574
3091
  commandService.syncExecuteCommand(SetDrawingArrangeOperation.id, {
2575
3092
  arrangeType,
@@ -2616,6 +3133,7 @@ const DrawingArrange = (props) => {
2616
3133
  //#endregion
2617
3134
  //#region src/views/panel/DrawingGroup.tsx
2618
3135
  const DrawingGroup = (props) => {
3136
+ var _renderManagerService;
2619
3137
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2620
3138
  const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
2621
3139
  const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
@@ -2624,43 +3142,32 @@ const DrawingGroup = (props) => {
2624
3142
  const { hasGroup, drawings } = props;
2625
3143
  const GroupIcon = iconManager.get("GroupIcon");
2626
3144
  const UngroupIcon = iconManager.get("UngroupIcon");
2627
- const [groupShow, setGroupShow] = (0, react.useState)(false);
2628
- const [groupBtnShow, setGroupBtnShow] = (0, react.useState)(true);
2629
- const [ungroupBtnShow, setUngroupBtnShow] = (0, react.useState)(true);
3145
+ const drawingParam = drawings[0];
3146
+ const transformer = drawingParam ? (_renderManagerService = renderManagerService.getRenderById(drawingParam.unitId)) === null || _renderManagerService === void 0 || (_renderManagerService = _renderManagerService.scene) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.getTransformerByCreate() : void 0;
3147
+ const { groupShow, groupBtnShow, ungroupBtnShow } = (0, _univerjs_ui.useObservable)(transformer ? () => (0, rxjs.merge)(transformer.clearControl$.pipe((0, rxjs.filter)((changeSelf) => changeSelf === true), (0, rxjs.map)(() => ({
3148
+ groupShow: false,
3149
+ groupBtnShow: false,
3150
+ ungroupBtnShow: false
3151
+ }))), transformer.changeStart$.pipe((0, rxjs.map)((state) => {
3152
+ const params = getUpdateParams(state.objects, drawingManagerService);
3153
+ const groupBtnShow = params.length > 1;
3154
+ const ungroupBtnShow = params.some((item) => (item === null || item === void 0 ? void 0 : item.drawingType) === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP);
3155
+ return {
3156
+ groupShow: groupBtnShow || ungroupBtnShow,
3157
+ groupBtnShow,
3158
+ ungroupBtnShow
3159
+ };
3160
+ }))) : null, {
3161
+ groupShow: false,
3162
+ groupBtnShow: true,
3163
+ ungroupBtnShow: true
3164
+ }, false, [drawingManagerService, transformer]);
2630
3165
  const onGroupBtnClick = () => {
2631
3166
  commandService.syncExecuteCommand(SetDrawingGroupOperation.id, { drawings });
2632
3167
  };
2633
3168
  const onUngroupBtnClick = () => {
2634
3169
  commandService.syncExecuteCommand(CancelDrawingGroupOperation.id, { drawings });
2635
3170
  };
2636
- (0, react.useEffect)(() => {
2637
- const drawingParam = drawings[0];
2638
- if (drawingParam == null) return;
2639
- const { unitId } = drawingParam;
2640
- const renderObject = renderManagerService.getRenderById(unitId);
2641
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2642
- if (scene == null) return;
2643
- const transformer = scene.getTransformerByCreate();
2644
- const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
2645
- if (changeSelf === true) setGroupShow(false);
2646
- });
2647
- const onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
2648
- const { objects } = state;
2649
- const params = getUpdateParams(objects, drawingManagerService);
2650
- const groupParams = params.filter((o) => (o === null || o === void 0 ? void 0 : o.drawingType) === _univerjs_core.DrawingTypeEnum.DRAWING_GROUP);
2651
- let groupBtnShow = false;
2652
- let ungroupBtnShow = false;
2653
- if (params.length > 1) groupBtnShow = true;
2654
- if (groupParams.length > 0) ungroupBtnShow = true;
2655
- setGroupShow(groupBtnShow || ungroupBtnShow);
2656
- setGroupBtnShow(groupBtnShow);
2657
- setUngroupBtnShow(ungroupBtnShow);
2658
- });
2659
- return () => {
2660
- onChangeStartObserver.unsubscribe();
2661
- onClearControlObserver.unsubscribe();
2662
- };
2663
- }, []);
2664
3171
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2665
3172
  className: (0, _univerjs_design.clsx)("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400", { "univer-hidden": hasGroup === true && groupShow === false || hasGroup === false }),
2666
3173
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
@@ -2712,21 +3219,24 @@ function createDrawingTransformRotationChangeHandler(options) {
2712
3219
  //#region src/views/panel/DrawingTransform.tsx
2713
3220
  const INPUT_DEBOUNCE_TIME = 300;
2714
3221
  const DrawingTransform = (props) => {
2715
- var _scene$getEngine;
3222
+ var _renderManagerService, _scene$getEngine;
3223
+ const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
3224
+ const drawingParam = props.drawings[0];
3225
+ const scene = drawingParam ? (_renderManagerService = renderManagerService.getRenderById(drawingParam.unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.scene : void 0;
3226
+ const topScene = scene === null || scene === void 0 || (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.activeScene;
3227
+ if (!(drawingParam === null || drawingParam === void 0 ? void 0 : drawingParam.transform) || !scene || !topScene) return null;
3228
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawingTransformContent, { ...props });
3229
+ };
3230
+ function DrawingTransformContent(props) {
2716
3231
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2717
3232
  const drawingManagerService = (0, _univerjs_ui.useDependency)(_univerjs_drawing.IDrawingManagerService);
2718
3233
  const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
2719
3234
  const { drawings, transformShow } = props;
2720
3235
  const drawingParam = drawings[0];
2721
- if (drawingParam == null) return;
2722
3236
  const transform = drawingParam.transform;
2723
- if (transform == null) return;
2724
3237
  const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
2725
- const renderObject = renderManagerService.getRenderById(unitId);
2726
- const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
2727
- if (scene == null) return;
2728
- const topScene = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.activeScene;
2729
- if (topScene == null) return;
3238
+ const scene = renderManagerService.getRenderById(unitId).scene;
3239
+ const topScene = scene.getEngine().activeScene;
2730
3240
  const transformer = scene.getTransformerByCreate();
2731
3241
  const { width: originWidth = 0, height: originHeight = 0, left: originX = 0, top: originY = 0, angle: originRotation = 0 } = transform;
2732
3242
  const [width, setWidth] = (0, react.useState)(originWidth);
@@ -2957,7 +3467,7 @@ const DrawingTransform = (props) => {
2957
3467
  })
2958
3468
  ]
2959
3469
  });
2960
- };
3470
+ }
2961
3471
 
2962
3472
  //#endregion
2963
3473
  //#region src/views/panel/ImageCropper.tsx
@@ -2968,7 +3478,7 @@ const ImageCropper = (props) => {
2968
3478
  const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
2969
3479
  const canUseShapeClip = (0, _univerjs_ui.useObservable)(clipService.canUseShapeClip$, false);
2970
3480
  const { drawings, cropperShow } = props;
2971
- if (drawings[0] == null) return;
3481
+ const drawingParam = drawings[0];
2972
3482
  const [cropValue, setCropValue] = (0, react.useState)("0");
2973
3483
  const cropStateRef = (0, react.useRef)(false);
2974
3484
  const cropOptions = [
@@ -3024,6 +3534,7 @@ const ImageCropper = (props) => {
3024
3534
  onChangeStartObserver === null || onChangeStartObserver === void 0 || onChangeStartObserver.dispose();
3025
3535
  };
3026
3536
  }, []);
3537
+ if (drawingParam == null) return null;
3027
3538
  function handleCropChange(value) {
3028
3539
  setCropValue(value);
3029
3540
  if (cropStateRef.current) commandService.executeCommand(AutoImageCropOperation.id, { cropType: value });
@@ -3091,78 +3602,11 @@ const DrawingCommonPanel = (props) => {
3091
3602
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3092
3603
  const { drawings, hasArrange = true, hasTransform = true, hasAlign = true, hasCropper = true, hasGroup = true } = props;
3093
3604
  const drawingParam = drawings[0];
3094
- if (drawingParam == null) return;
3095
- const { unitId } = drawingParam;
3096
- const renderObject = renderManagerService.getRenderById(unitId);
3605
+ const renderObject = drawingParam ? renderManagerService.getRenderById(drawingParam.unitId) : void 0;
3097
3606
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
3098
- if (scene == null) return;
3099
- const transformer = scene.getTransformerByCreate();
3100
- const initialShowState = getPanelShowState(drawings);
3101
- const [arrangeShow, setArrangeShow] = (0, react.useState)(initialShowState.arrangeShow);
3102
- const [transformShow, setTransformShow] = (0, react.useState)(initialShowState.transformShow);
3103
- const [alignShow, setAlignShow] = (0, react.useState)(initialShowState.alignShow);
3104
- const [cropperShow, setCropperShow] = (0, react.useState)(initialShowState.cropperShow);
3105
- const [nullShow, setNullShow] = (0, react.useState)(initialShowState.nullShow);
3106
- (0, react.useEffect)(() => {
3107
- const clearControlSub = transformer.clearControl$.subscribe((changeSelf) => {
3108
- if (changeSelf === true) {
3109
- setArrangeShow(false);
3110
- setTransformShow(false);
3111
- setAlignShow(false);
3112
- setCropperShow(false);
3113
- setNullShow(true);
3114
- }
3115
- });
3116
- const changeStartSub = transformer.changeStart$.subscribe((state) => {
3117
- const { objects } = state;
3118
- const params = getUpdateParams(objects, drawingManagerService);
3119
- if (params.length === 0) {
3120
- setArrangeShow(false);
3121
- setTransformShow(false);
3122
- setAlignShow(false);
3123
- setCropperShow(false);
3124
- setNullShow(true);
3125
- } else if (params.length === 1) {
3126
- setArrangeShow(true);
3127
- setTransformShow(true);
3128
- setAlignShow(false);
3129
- setCropperShow(true);
3130
- setNullShow(false);
3131
- } else {
3132
- setArrangeShow(true);
3133
- setTransformShow(false);
3134
- setAlignShow(true);
3135
- setCropperShow(false);
3136
- setNullShow(false);
3137
- }
3138
- });
3139
- const focusSub = drawingManagerService.focus$.subscribe((drawings) => {
3140
- if (drawings.length === 0) {
3141
- setArrangeShow(false);
3142
- setTransformShow(false);
3143
- setAlignShow(false);
3144
- setCropperShow(false);
3145
- setNullShow(true);
3146
- } else if (drawings.length === 1) {
3147
- setArrangeShow(true);
3148
- setTransformShow(true);
3149
- setAlignShow(false);
3150
- setCropperShow(true);
3151
- setNullShow(false);
3152
- } else {
3153
- setArrangeShow(true);
3154
- setTransformShow(false);
3155
- setAlignShow(true);
3156
- setCropperShow(false);
3157
- setNullShow(false);
3158
- }
3159
- });
3160
- return () => {
3161
- changeStartSub.unsubscribe();
3162
- clearControlSub.unsubscribe();
3163
- focusSub.unsubscribe();
3164
- };
3165
- }, []);
3607
+ const transformer = scene === null || scene === void 0 ? void 0 : scene.getTransformerByCreate();
3608
+ const { arrangeShow, transformShow, alignShow, cropperShow, nullShow } = (0, _univerjs_ui.useObservable)(() => (0, rxjs.merge)(drawingManagerService.focus$.pipe((0, rxjs.map)(getPanelShowState)), ...transformer ? [transformer.clearControl$.pipe((0, rxjs.filter)((changeSelf) => changeSelf === true), (0, rxjs.map)(() => getPanelShowState([]))), transformer.changeStart$.pipe((0, rxjs.map)((state) => getPanelShowState(getUpdateParams(state.objects, drawingManagerService))))] : []), getPanelShowState(drawings), false, [drawingManagerService, transformer]);
3609
+ if (!drawingParam || !scene || !transformer) return null;
3166
3610
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3167
3611
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3168
3612
  className: (0, _univerjs_design.clsx)("univer-h-full", { "univer-hidden": !nullShow }),
@@ -3208,9 +3652,13 @@ Object.defineProperty(exports, 'DrawingRenderService', {
3208
3652
  return DrawingRenderService;
3209
3653
  }
3210
3654
  });
3655
+ exports.DrawingUIMenuSchema = menuSchema;
3211
3656
  exports.IMAGE_CLIP_SHAPE_PICKER_COMPONENT = IMAGE_CLIP_SHAPE_PICKER_COMPONENT;
3212
3657
  exports.ImageCropperObject = ImageCropperObject;
3213
3658
  exports.ImageResetSizeOperation = ImageResetSizeOperation;
3659
+ exports.OBJECT_LIST_CANVAS_SECTION_ID = OBJECT_LIST_CANVAS_SECTION_ID;
3660
+ exports.OBJECT_LIST_FLOATING_SECTION_ID = OBJECT_LIST_FLOATING_SECTION_ID;
3661
+ exports.ObjectListPanelBase = ObjectListPanelBase;
3214
3662
  exports.OpenImageCropOperation = OpenImageCropOperation;
3215
3663
  exports.SetDrawingAlignOperation = SetDrawingAlignOperation;
3216
3664
  exports.SetDrawingArrangeOperation = SetDrawingArrangeOperation;
@@ -3224,5 +3672,9 @@ Object.defineProperty(exports, 'UniverDrawingUIPlugin', {
3224
3672
  exports.disposeDrawingRenderObject = disposeDrawingRenderObject;
3225
3673
  exports.getCurrentUnitInfo = getCurrentUnitInfo;
3226
3674
  exports.getDrawingRenderObject = getDrawingRenderObject;
3675
+ exports.getObjectListPanelLabels = getObjectListPanelLabels;
3676
+ exports.getObjectListPanelSectionIdForDrawingType = getObjectListPanelSectionIdForDrawingType;
3677
+ exports.getObjectListPanelTypeName = getObjectListPanelTypeName;
3227
3678
  exports.getUpdateParams = getUpdateParams;
3228
- exports.insertGroupObject = insertGroupObject;
3679
+ exports.insertGroupObject = insertGroupObject;
3680
+ exports.isFloatingObjectListDrawingType = isFloatingObjectListDrawingType;