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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/lib/cjs/index.js +1060 -529
  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 +1049 -526
  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 +1049 -526
  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 +10 -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/umd/index.js +7 -1
  70. package/lib/umd/locale/ar-SA.js +1 -1
  71. package/lib/umd/locale/ca-ES.js +1 -1
  72. package/lib/umd/locale/de-DE.js +1 -1
  73. package/lib/umd/locale/en-US.js +1 -1
  74. package/lib/umd/locale/es-ES.js +1 -1
  75. package/lib/umd/locale/fa-IR.js +1 -1
  76. package/lib/umd/locale/fr-FR.js +1 -1
  77. package/lib/umd/locale/id-ID.js +1 -1
  78. package/lib/umd/locale/it-IT.js +1 -1
  79. package/lib/umd/locale/ja-JP.js +1 -1
  80. package/lib/umd/locale/ko-KR.js +1 -1
  81. package/lib/umd/locale/pl-PL.js +1 -1
  82. package/lib/umd/locale/pt-BR.js +1 -1
  83. package/lib/umd/locale/ru-RU.js +1 -1
  84. package/lib/umd/locale/sk-SK.js +1 -1
  85. package/lib/umd/locale/vi-VN.js +1 -1
  86. package/lib/umd/locale/zh-CN.js +1 -1
  87. package/lib/umd/locale/zh-HK.js +1 -1
  88. package/lib/umd/locale/zh-TW.js +1 -1
  89. package/package.json +9 -9
package/lib/es/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { ArrangeTypeEnum, BooleanNumber, CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IURLImageService, IUniverInstanceService, ImageSourceType, Inject, Injector, LocaleService, Plugin, PositionedObjectLayoutType, UniverInstanceType, checkIfMove, debounce, generateRandomId, merge, toDisposable } from "@univerjs/core";
2
- import { DRAWING_GROUPABLE_TYPES, IDrawingManagerService, IImageIoService, ImageSourceType as ImageSourceType$1, SetDrawingSelectedOperation, getDrawingShapeKeyByDrawingSearch, isGroupableDrawingType, resolveDrawingRotateEnabled } from "@univerjs/drawing";
1
+ import { ArrangeTypeEnum, BooleanNumber, CommandType, Disposable, DrawingTypeEnum, ICommandService, IConfigService, IImageIoService, IURLImageService, IUniverInstanceService, ImageSourceType, Inject, Injector, LocaleService, Plugin, PositionedObjectLayoutType, UniverInstanceType, checkIfMove, debounce, generateRandomId, merge, toDisposable } from "@univerjs/core";
2
+ import { DRAWING_GROUPABLE_TYPES, IDrawingManagerService, SetDrawingSelectedOperation, getDrawingShapeKeyByDrawingSearch, isGroupableDrawingType, resolveDrawingRotateEnabled } from "@univerjs/drawing";
3
3
  import { CURSOR_TYPE, Canvas, DRAWING_OBJECT_LAYER_INDEX, DrawingGroupObject, Group, IRenderManagerService, Image, RENDER_CLASS_TYPE, Rect, Shape, Vector2, degToRad, getGroupState, precisionTo, transformObjectOutOfGroup } from "@univerjs/engine-render";
4
- import { AutofillDoubleIcon, BottomIcon, CreateCopyIcon, CropIcon, DeleteIcon, DocSettingIcon, GroupIcon, MoreDownIcon, MoveDownIcon, MoveUpIcon, TextWrapShapeIcon, TopmostIcon, UngroupIcon } from "@univerjs/icons";
5
4
  import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IGalleryService, IMenuManagerService, IMessageService, IconManager, MenuItemType, useDependency, useObservable } from "@univerjs/ui";
6
- import { Button, Checkbox, Dropdown, DropdownMenu, InputNumber, MessageType, Select, Separator, Tooltip, borderClassName, clsx } from "@univerjs/design";
7
- import { useEffect, useRef, useState } from "react";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
5
  import { BehaviorSubject, Observable, bufferTime, filter, map, of, switchMap } from "rxjs";
6
+ import { ArrowDownIcon, ArrowUpIcon, AutofillDoubleIcon, BottomIcon, ChartIcon, CreateCopyIcon, CropIcon, DeleteIcon, DocSettingIcon, EyeIcon, EyelashIcon, GroupIcon, LocateFixedIcon, LockIcon, MoreDownIcon, MoreRightIcon, MoveDownIcon, MoveUpIcon, TextWrapShapeIcon, TopmostIcon, UngroupIcon } from "@univerjs/icons";
7
+ import { Button, Checkbox, Dropdown, DropdownMenu, Input, InputNumber, MessageType, Select, Separator, Tooltip, borderClassName, clsx } from "@univerjs/design";
8
+ import { useEffect, useMemo, useRef, useState } from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
 
11
11
  //#region src/commands/operations/drawing-align.operation.ts
12
12
  /**
@@ -360,195 +360,458 @@ function getCurrentUnitInfo(currentUniverService, propUnitId) {
360
360
  }
361
361
 
362
362
  //#endregion
363
- //#region package.json
364
- var name = "@univerjs/drawing-ui";
365
- var version = "1.0.0-alpha.2";
366
-
367
- //#endregion
368
- //#region src/config/config.ts
369
- const DRAWING_UI_PLUGIN_CONFIG_KEY = "drawing-ui.config";
370
- const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
371
- const defaultPluginConfig = {};
372
-
373
- //#endregion
374
- //#region src/views/image-popup-menu/component-name.ts
375
- /**
376
- * Copyright 2023-present DreamNum Co., Ltd.
377
- *
378
- * Licensed under the Apache License, Version 2.0 (the "License");
379
- * you may not use this file except in compliance with the License.
380
- * You may obtain a copy of the License at
381
- *
382
- * http://www.apache.org/licenses/LICENSE-2.0
383
- *
384
- * Unless required by applicable law or agreed to in writing, software
385
- * distributed under the License is distributed on an "AS IS" BASIS,
386
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
387
- * See the License for the specific language governing permissions and
388
- * limitations under the License.
389
- */
390
- const COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
391
-
392
- //#endregion
393
- //#region src/views/image-popup-menu/ImagePopupMenu.tsx
394
- function ImagePopupMenu(props) {
395
- var _popup$extraProps, _popup$extraProps2;
396
- const { popup } = props;
397
- const menuItems = popup === null || popup === void 0 || (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.menuItems;
398
- if (!menuItems) return null;
399
- 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__ */ jsx(DocImageFloatingToolbar, {
400
- menuItems,
401
- unitId: popup.extraProps.unitId,
402
- subUnitId: popup.extraProps.subUnitId,
403
- drawingId: popup.extraProps.drawingId
363
+ //#region src/menu/align.menu.ts
364
+ const getMenuStateByDrawingFocusChangedObservable$$1 = (accessor) => {
365
+ const drawingManagerService = accessor.get(IDrawingManagerService);
366
+ return new Observable((subscriber) => {
367
+ const update = (drawings) => {
368
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
369
+ if (drawings.length < 2) return subscriber.next(true);
370
+ subscriber.next(false);
371
+ };
372
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
373
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
374
+ update(drawings);
375
+ });
376
+ update(drawingManagerService.getFocusDrawings());
377
+ return () => subscription.unsubscribe();
404
378
  });
405
- const commandService = useDependency(ICommandService);
406
- const localeService = useDependency(LocaleService);
407
- const [visible, setVisible] = useState(false);
408
- const [isHovered, setHovered] = useState(false);
409
- const handleMouseEnter = () => {
410
- setHovered(true);
379
+ };
380
+ const DRAWING_ALIGN_CONTEXT_MENU_ID = "contextMenu.drawing-align";
381
+ function DrawingAlignContextMenuItemFactory(accessor) {
382
+ return {
383
+ id: DRAWING_ALIGN_CONTEXT_MENU_ID,
384
+ type: MenuItemType.SUBITEMS,
385
+ icon: "HorizontallyIcon",
386
+ title: "drawing-ui.image-panel.align.title",
387
+ hidden$: getMenuStateByDrawingFocusChangedObservable$$1(accessor)
411
388
  };
412
- const handleMouseLeave = () => {
413
- setHovered(false);
389
+ }
390
+ function SetDrawingAlignLeftMenuItemFactory() {
391
+ return {
392
+ id: SetDrawingAlignLeftOperation.id,
393
+ type: MenuItemType.BUTTON,
394
+ icon: "LeftJustifyingIcon",
395
+ title: "drawing-ui.image-panel.align.left"
414
396
  };
415
- const onVisibleChange = (visible) => {
416
- setVisible(visible);
397
+ }
398
+ function SetDrawingAlignCenterMenuItemFactory() {
399
+ return {
400
+ id: SetDrawingAlignCenterOperation.id,
401
+ type: MenuItemType.BUTTON,
402
+ icon: "HorizontallyIcon",
403
+ title: "drawing-ui.image-panel.align.center"
417
404
  };
418
- const handleClick = (item) => {
419
- commandService.executeCommand(item.commandId, item.commandParams);
420
- setVisible(false);
405
+ }
406
+ function SetDrawingAlignRightMenuItemFactory() {
407
+ return {
408
+ id: SetDrawingAlignRightOperation.id,
409
+ type: MenuItemType.BUTTON,
410
+ icon: "RightJustifyingIcon",
411
+ title: "drawing-ui.image-panel.align.right"
421
412
  };
422
- const showMore = visible || isHovered;
423
- return /* @__PURE__ */ jsx("div", {
424
- onMouseEnter: handleMouseEnter,
425
- onMouseLeave: handleMouseLeave,
426
- children: /* @__PURE__ */ jsx(DropdownMenu, {
427
- align: "start",
428
- items: menuItems.map((item) => ({
429
- type: "item",
430
- children: localeService.t(item.label),
431
- disabled: item.disable,
432
- onSelect: () => handleClick(item)
433
- })),
434
- open: visible,
435
- onOpenChange: onVisibleChange,
436
- children: /* @__PURE__ */ jsxs("div", {
437
- className: 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", borderClassName, {
438
- "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
439
- "univer-bg-white dark:!univer-bg-gray-900": !visible
440
- }),
441
- children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
442
- })
443
- })
444
- });
445
413
  }
446
- const UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID = "doc.command.update-doc-drawing-wrapping-style";
447
- function getWrappingStyle(documentDataModel, drawingId) {
448
- var _documentDataModel$ge;
449
- const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawingId];
450
- if (!drawing) return "inline";
451
- if (drawing.layoutType === PositionedObjectLayoutType.WRAP_NONE) return drawing.behindDoc === BooleanNumber.TRUE ? "behindText" : "inFrontOfText";
452
- if (drawing.layoutType === PositionedObjectLayoutType.WRAP_SQUARE) return "wrapSquare";
453
- if (drawing.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return "wrapTopAndBottom";
454
- return "inline";
414
+ function SetDrawingAlignTopMenuItemFactory() {
415
+ return {
416
+ id: SetDrawingAlignTopOperation.id,
417
+ type: MenuItemType.BUTTON,
418
+ icon: "AlignTopIcon",
419
+ title: "drawing-ui.image-panel.align.top"
420
+ };
455
421
  }
456
- function ToolbarGroup(props) {
457
- return /* @__PURE__ */ jsx("div", {
458
- className: "univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1",
459
- children: props.children
460
- });
422
+ function SetDrawingAlignMiddleMenuItemFactory() {
423
+ return {
424
+ id: SetDrawingAlignMiddleOperation.id,
425
+ type: MenuItemType.BUTTON,
426
+ icon: "VerticalCenterIcon",
427
+ title: "drawing-ui.image-panel.align.middle"
428
+ };
461
429
  }
462
- function ToolbarButton(props) {
463
- return /* @__PURE__ */ jsx(Tooltip, {
464
- title: props.title,
465
- placement: "bottom",
466
- children: /* @__PURE__ */ jsx("button", {
467
- type: "button",
468
- disabled: props.disabled,
469
- onClick: props.onClick,
470
- className: 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 }),
471
- children: props.children
472
- })
473
- });
430
+ function SetDrawingAlignBottomMenuItemFactory() {
431
+ return {
432
+ id: SetDrawingAlignBottomOperation.id,
433
+ type: MenuItemType.BUTTON,
434
+ icon: "AlignBottomIcon",
435
+ title: "drawing-ui.image-panel.align.bottom"
436
+ };
474
437
  }
475
- function ToolbarDropdownButton(props) {
476
- var _props$options$find;
477
- const [open, setOpen] = useState(false);
478
- 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];
479
- return /* @__PURE__ */ jsx(Dropdown, {
480
- open,
481
- onOpenChange: setOpen,
482
- overlay: /* @__PURE__ */ jsx("div", {
483
- 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",
484
- children: props.options.map((option) => /* @__PURE__ */ jsxs("button", {
485
- type: "button",
486
- onClick: () => {
487
- props.onChange(option.value);
488
- setOpen(false);
489
- },
490
- className: 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 }),
491
- children: [/* @__PURE__ */ jsx("span", {
492
- className: "univer-flex univer-size-4 univer-items-center univer-justify-center",
493
- children: option.icon
494
- }), /* @__PURE__ */ jsx("span", {
495
- className: "univer-flex-1",
496
- children: option.label
497
- })]
498
- }, option.value))
499
- }),
500
- children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Tooltip, {
501
- title: props.title,
502
- placement: "bottom",
503
- children: /* @__PURE__ */ jsxs("button", {
504
- type: "button",
505
- className: 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 }),
506
- children: [activeOption.icon, /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-xs" })]
507
- })
508
- }) })
509
- });
438
+ function SetDrawingAlignHorizonMenuItemFactory() {
439
+ return {
440
+ id: SetDrawingAlignHorizonOperation.id,
441
+ type: MenuItemType.BUTTON,
442
+ icon: "HorizontallyIcon",
443
+ title: "drawing-ui.image-panel.align.horizon"
444
+ };
510
445
  }
511
- function DocImageFloatingToolbar(props) {
512
- var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2;
513
- const commandService = useDependency(ICommandService);
514
- const localeService = useDependency(LocaleService);
515
- const documentDataModel = (_univerInstanceServic = useDependency(IUniverInstanceService).getUnit(props.unitId, UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
516
- const [wrappingStyle, setWrappingStyle] = useState(() => getWrappingStyle(documentDataModel, props.drawingId));
517
- const [hidden, setHidden] = useState(false);
518
- const getMenuItem = (label) => props.menuItems.find((item) => item.label === label);
519
- const editItem = getMenuItem("drawing-ui.image-popup.edit");
520
- const cropItem = getMenuItem("drawing-ui.image-popup.crop");
521
- const deleteItem = getMenuItem("drawing-ui.image-popup.delete");
522
- const wrappingStyleOptions = [
523
- {
524
- label: localeService.t("drawing-ui.image-text-wrap.inline"),
525
- value: "inline",
526
- icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
527
- },
528
- {
529
- label: localeService.t("drawing-ui.image-text-wrap.square"),
530
- value: "wrapSquare",
531
- icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
532
- },
533
- {
534
- label: localeService.t("drawing-ui.image-text-wrap.topAndBottom"),
535
- value: "wrapTopAndBottom",
536
- icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
537
- },
538
- {
539
- label: localeService.t("drawing-ui.image-text-wrap.behindText"),
540
- value: "behindText",
541
- icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
542
- },
543
- {
544
- label: localeService.t("drawing-ui.image-text-wrap.inFrontText"),
545
- value: "inFrontOfText",
546
- icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
547
- }
548
- ];
549
- const executeMenuItem = (item) => {
550
- if (!item || item.disable) return;
551
- commandService.executeCommand(item.commandId, item.commandParams);
446
+ function SetDrawingAlignVerticalMenuItemFactory() {
447
+ return {
448
+ id: SetDrawingAlignVerticalOperation.id,
449
+ type: MenuItemType.BUTTON,
450
+ icon: "VerticalCenterIcon",
451
+ title: "drawing-ui.image-panel.align.vertical"
452
+ };
453
+ }
454
+
455
+ //#endregion
456
+ //#region src/menu/arrange.menu.ts
457
+ const DRAWING_ARRANGE_CONTEXT_MENU_ID = "contextMenu.drawing-arrange";
458
+ function DrawingArrangeContextMenuItemFactory() {
459
+ return {
460
+ id: DRAWING_ARRANGE_CONTEXT_MENU_ID,
461
+ type: MenuItemType.SUBITEMS,
462
+ icon: "TopmostIcon",
463
+ title: "drawing-ui.image-panel.arrange.title"
464
+ };
465
+ }
466
+ function SetDrawingArrangeFrontMenuItemFactory() {
467
+ return {
468
+ id: SetDrawingArrangeFrontOperation.id,
469
+ type: MenuItemType.BUTTON,
470
+ icon: "TopmostIcon",
471
+ title: "drawing-ui.image-panel.arrange.front"
472
+ };
473
+ }
474
+ function SetDrawingArrangeForwardMenuItemFactory() {
475
+ return {
476
+ id: SetDrawingArrangeForwardOperation.id,
477
+ type: MenuItemType.BUTTON,
478
+ icon: "MoveUpIcon",
479
+ title: "drawing-ui.image-panel.arrange.forward"
480
+ };
481
+ }
482
+ function SetDrawingArrangeBackMenuItemFactory() {
483
+ return {
484
+ id: SetDrawingArrangeBackOperation.id,
485
+ type: MenuItemType.BUTTON,
486
+ icon: "BottomIcon",
487
+ title: "drawing-ui.image-panel.arrange.back"
488
+ };
489
+ }
490
+ function SetDrawingArrangeBackwardMenuItemFactory() {
491
+ return {
492
+ id: SetDrawingArrangeBackwardOperation.id,
493
+ type: MenuItemType.BUTTON,
494
+ icon: "MoveDownIcon",
495
+ title: "drawing-ui.image-panel.arrange.backward"
496
+ };
497
+ }
498
+
499
+ //#endregion
500
+ //#region src/menu/group.menu.ts
501
+ function getMenuStateByDrawingFocusChangedObservable$(accessor, type) {
502
+ const drawingManagerService = accessor.get(IDrawingManagerService);
503
+ return new Observable((subscriber) => {
504
+ const update = (drawings) => {
505
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
506
+ if (type === "group") {
507
+ if (drawings.length < 2) return subscriber.next(true);
508
+ if (!drawings.every((drawing) => isGroupableDrawingType(drawing.drawingType))) return subscriber.next(true);
509
+ } else if (type === "unGroup") {
510
+ if (drawings.filter((drawing) => drawing.drawingType === DrawingTypeEnum.DRAWING_GROUP).length === 0) return subscriber.next(true);
511
+ } else if (!drawings.every((drawing) => isGroupableDrawingType(drawing.drawingType))) return subscriber.next(true);
512
+ subscriber.next(false);
513
+ };
514
+ const subscription = drawingManagerService.focus$.subscribe((drawings) => {
515
+ if (!drawings || drawings.length === 0) return subscriber.next(true);
516
+ update(drawings);
517
+ });
518
+ update(drawingManagerService.getFocusDrawings());
519
+ return () => subscription.unsubscribe();
520
+ });
521
+ }
522
+ const DRAWING_GROUP_CONTEXT_MENU_ID = "contextMenu.drawing-group";
523
+ function DrawingGroupContextMenuItemFactory(accessor) {
524
+ return {
525
+ id: DRAWING_GROUP_CONTEXT_MENU_ID,
526
+ type: MenuItemType.SUBITEMS,
527
+ icon: "GroupIcon",
528
+ title: "drawing-ui.image-panel.group.title",
529
+ hidden$: getMenuStateByDrawingFocusChangedObservable$(accessor)
530
+ };
531
+ }
532
+ function SetDrawingGroupMenuItemFactory(accessor) {
533
+ return {
534
+ id: SetDrawingGroupOperation.id,
535
+ type: MenuItemType.BUTTON,
536
+ icon: "GroupIcon",
537
+ title: "drawing-ui.image-panel.group.group",
538
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "group")
539
+ };
540
+ }
541
+ function CancelDrawingGroupMenuItemFactory(accessor) {
542
+ return {
543
+ id: CancelDrawingGroupOperation.id,
544
+ type: MenuItemType.BUTTON,
545
+ icon: "UngroupIcon",
546
+ title: "drawing-ui.image-panel.group.unGroup",
547
+ disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "unGroup")
548
+ };
549
+ }
550
+
551
+ //#endregion
552
+ //#region src/menu/schema.ts
553
+ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]: {
554
+ [DRAWING_GROUP_CONTEXT_MENU_ID]: {
555
+ order: 1,
556
+ menuItemFactory: DrawingGroupContextMenuItemFactory,
557
+ [SetDrawingGroupOperation.id]: {
558
+ order: 0,
559
+ menuItemFactory: SetDrawingGroupMenuItemFactory
560
+ },
561
+ [CancelDrawingGroupOperation.id]: {
562
+ order: 1,
563
+ menuItemFactory: CancelDrawingGroupMenuItemFactory
564
+ }
565
+ },
566
+ [DRAWING_ARRANGE_CONTEXT_MENU_ID]: {
567
+ order: 2,
568
+ menuItemFactory: DrawingArrangeContextMenuItemFactory,
569
+ [SetDrawingArrangeFrontOperation.id]: {
570
+ order: 0,
571
+ menuItemFactory: SetDrawingArrangeFrontMenuItemFactory
572
+ },
573
+ [SetDrawingArrangeForwardOperation.id]: {
574
+ order: 1,
575
+ menuItemFactory: SetDrawingArrangeForwardMenuItemFactory
576
+ },
577
+ [SetDrawingArrangeBackOperation.id]: {
578
+ order: 2,
579
+ menuItemFactory: SetDrawingArrangeBackMenuItemFactory
580
+ },
581
+ [SetDrawingArrangeBackwardOperation.id]: {
582
+ order: 3,
583
+ menuItemFactory: SetDrawingArrangeBackwardMenuItemFactory
584
+ }
585
+ },
586
+ [DRAWING_ALIGN_CONTEXT_MENU_ID]: {
587
+ order: 3,
588
+ menuItemFactory: DrawingAlignContextMenuItemFactory,
589
+ [SetDrawingAlignLeftOperation.id]: {
590
+ order: 0,
591
+ menuItemFactory: SetDrawingAlignLeftMenuItemFactory
592
+ },
593
+ [SetDrawingAlignCenterOperation.id]: {
594
+ order: 1,
595
+ menuItemFactory: SetDrawingAlignCenterMenuItemFactory
596
+ },
597
+ [SetDrawingAlignRightOperation.id]: {
598
+ order: 2,
599
+ menuItemFactory: SetDrawingAlignRightMenuItemFactory
600
+ },
601
+ [SetDrawingAlignTopOperation.id]: {
602
+ order: 3,
603
+ menuItemFactory: SetDrawingAlignTopMenuItemFactory
604
+ },
605
+ [SetDrawingAlignMiddleOperation.id]: {
606
+ order: 4,
607
+ menuItemFactory: SetDrawingAlignMiddleMenuItemFactory
608
+ },
609
+ [SetDrawingAlignBottomOperation.id]: {
610
+ order: 5,
611
+ menuItemFactory: SetDrawingAlignBottomMenuItemFactory
612
+ },
613
+ [SetDrawingAlignHorizonOperation.id]: {
614
+ order: 6,
615
+ menuItemFactory: SetDrawingAlignHorizonMenuItemFactory
616
+ },
617
+ [SetDrawingAlignVerticalOperation.id]: {
618
+ order: 7,
619
+ menuItemFactory: SetDrawingAlignVerticalMenuItemFactory
620
+ }
621
+ }
622
+ } } };
623
+
624
+ //#endregion
625
+ //#region package.json
626
+ var name = "@univerjs/drawing-ui";
627
+ var version = "1.0.0-alpha.3";
628
+
629
+ //#endregion
630
+ //#region src/config/config.ts
631
+ const DRAWING_UI_PLUGIN_CONFIG_KEY = "drawing-ui.config";
632
+ const configSymbol = Symbol(DRAWING_UI_PLUGIN_CONFIG_KEY);
633
+ const defaultPluginConfig = {};
634
+
635
+ //#endregion
636
+ //#region src/views/image-popup-menu/component-name.ts
637
+ /**
638
+ * Copyright 2023-present DreamNum Co., Ltd.
639
+ *
640
+ * Licensed under the Apache License, Version 2.0 (the "License");
641
+ * you may not use this file except in compliance with the License.
642
+ * You may obtain a copy of the License at
643
+ *
644
+ * http://www.apache.org/licenses/LICENSE-2.0
645
+ *
646
+ * Unless required by applicable law or agreed to in writing, software
647
+ * distributed under the License is distributed on an "AS IS" BASIS,
648
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
649
+ * See the License for the specific language governing permissions and
650
+ * limitations under the License.
651
+ */
652
+ const COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
653
+
654
+ //#endregion
655
+ //#region src/views/image-popup-menu/ImagePopupMenu.tsx
656
+ function ImagePopupMenu(props) {
657
+ var _popup$extraProps, _popup$extraProps2, _popup$extraProps3;
658
+ const { popup } = props;
659
+ const menuItems = popup === null || popup === void 0 || (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.menuItems;
660
+ if (!menuItems) return null;
661
+ 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__ */ jsx(DocImageFloatingToolbar, {
662
+ menuItems,
663
+ unitId: popup.extraProps.unitId,
664
+ subUnitId: popup.extraProps.subUnitId,
665
+ drawingId: popup.extraProps.drawingId
666
+ });
667
+ if (((_popup$extraProps3 = popup.extraProps) === null || _popup$extraProps3 === void 0 ? void 0 : _popup$extraProps3.variant) === "doc-chart-floating-toolbar") return /* @__PURE__ */ jsx(DocChartFloatingToolbar, { menuItems });
668
+ const commandService = useDependency(ICommandService);
669
+ const localeService = useDependency(LocaleService);
670
+ const [visible, setVisible] = useState(false);
671
+ const [isHovered, setHovered] = useState(false);
672
+ const handleMouseEnter = () => {
673
+ setHovered(true);
674
+ };
675
+ const handleMouseLeave = () => {
676
+ setHovered(false);
677
+ };
678
+ const onVisibleChange = (visible) => {
679
+ setVisible(visible);
680
+ };
681
+ const handleClick = (item) => {
682
+ commandService.executeCommand(item.commandId, item.commandParams);
683
+ setVisible(false);
684
+ };
685
+ const showMore = visible || isHovered;
686
+ return /* @__PURE__ */ jsx("div", {
687
+ onMouseEnter: handleMouseEnter,
688
+ onMouseLeave: handleMouseLeave,
689
+ children: /* @__PURE__ */ jsx(DropdownMenu, {
690
+ align: "start",
691
+ items: menuItems.map((item) => ({
692
+ type: "item",
693
+ children: localeService.t(item.label),
694
+ disabled: item.disable,
695
+ onSelect: () => handleClick(item)
696
+ })),
697
+ open: visible,
698
+ onOpenChange: onVisibleChange,
699
+ children: /* @__PURE__ */ jsxs("div", {
700
+ className: 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", borderClassName, {
701
+ "univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
702
+ "univer-bg-white dark:!univer-bg-gray-900": !visible
703
+ }),
704
+ children: [/* @__PURE__ */ jsx(AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ jsx(MoreDownIcon, { className: "dark:!univer-text-white" })]
705
+ })
706
+ })
707
+ });
708
+ }
709
+ const UPDATE_DOC_DRAWING_WRAPPING_STYLE_COMMAND_ID = "doc.command.update-doc-drawing-wrapping-style";
710
+ function getWrappingStyle(documentDataModel, drawingId) {
711
+ var _documentDataModel$ge;
712
+ const drawing = documentDataModel === null || documentDataModel === void 0 || (_documentDataModel$ge = documentDataModel.getSnapshot().drawings) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge[drawingId];
713
+ if (!drawing) return "inline";
714
+ if (drawing.layoutType === PositionedObjectLayoutType.WRAP_NONE) return drawing.behindDoc === BooleanNumber.TRUE ? "behindText" : "inFrontOfText";
715
+ if (drawing.layoutType === PositionedObjectLayoutType.WRAP_SQUARE) return "wrapSquare";
716
+ if (drawing.layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) return "wrapTopAndBottom";
717
+ return "inline";
718
+ }
719
+ function ToolbarGroup(props) {
720
+ return /* @__PURE__ */ jsx("div", {
721
+ className: "univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1",
722
+ children: props.children
723
+ });
724
+ }
725
+ function ToolbarButton(props) {
726
+ return /* @__PURE__ */ jsx(Tooltip, {
727
+ title: useDependency(LocaleService).t(props.titleKey),
728
+ placement: "bottom",
729
+ children: /* @__PURE__ */ jsx("button", {
730
+ type: "button",
731
+ disabled: props.disabled,
732
+ onClick: props.onClick,
733
+ className: 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 }),
734
+ children: props.children
735
+ })
736
+ });
737
+ }
738
+ function ToolbarDropdownButton(props) {
739
+ var _props$options$find;
740
+ const [open, setOpen] = useState(false);
741
+ 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];
742
+ return /* @__PURE__ */ jsx(Dropdown, {
743
+ open,
744
+ onOpenChange: setOpen,
745
+ overlay: /* @__PURE__ */ jsx("div", {
746
+ 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",
747
+ children: props.options.map((option) => /* @__PURE__ */ jsxs("button", {
748
+ type: "button",
749
+ onClick: () => {
750
+ props.onChange(option.value);
751
+ setOpen(false);
752
+ },
753
+ className: 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 }),
754
+ children: [/* @__PURE__ */ jsx("span", {
755
+ className: "univer-flex univer-size-4 univer-items-center univer-justify-center",
756
+ children: option.icon
757
+ }), /* @__PURE__ */ jsx("span", {
758
+ className: "univer-flex-1",
759
+ children: option.label
760
+ })]
761
+ }, option.value))
762
+ }),
763
+ children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Tooltip, {
764
+ title: props.title,
765
+ placement: "bottom",
766
+ children: /* @__PURE__ */ jsxs("button", {
767
+ type: "button",
768
+ className: 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 }),
769
+ children: [activeOption.icon, /* @__PURE__ */ jsx(MoreDownIcon, { className: "univer-text-xs" })]
770
+ })
771
+ }) })
772
+ });
773
+ }
774
+ function DocImageFloatingToolbar(props) {
775
+ var _univerInstanceServic, _wrappingStyleOptions, _wrappingStyleOptions2, _editItem$label, _cropItem$label, _deleteItem$label;
776
+ const commandService = useDependency(ICommandService);
777
+ const localeService = useDependency(LocaleService);
778
+ const documentDataModel = (_univerInstanceServic = useDependency(IUniverInstanceService).getUnit(props.unitId, UniverInstanceType.UNIVER_DOC)) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : void 0;
779
+ const [wrappingStyle, setWrappingStyle] = useState(() => getWrappingStyle(documentDataModel, props.drawingId));
780
+ const [hidden, setHidden] = useState(false);
781
+ const getMenuItem = (label) => props.menuItems.find((item) => item.label === label);
782
+ const editItem = getMenuItem("drawing-ui.image-popup.edit");
783
+ const cropItem = getMenuItem("drawing-ui.image-popup.crop");
784
+ const deleteItem = getMenuItem("drawing-ui.image-popup.delete");
785
+ const wrappingStyleOptions = [
786
+ {
787
+ label: localeService.t("drawing-ui.image-text-wrap.inline"),
788
+ value: "inline",
789
+ icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
790
+ },
791
+ {
792
+ label: localeService.t("drawing-ui.image-text-wrap.square"),
793
+ value: "wrapSquare",
794
+ icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
795
+ },
796
+ {
797
+ label: localeService.t("drawing-ui.image-text-wrap.topAndBottom"),
798
+ value: "wrapTopAndBottom",
799
+ icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
800
+ },
801
+ {
802
+ label: localeService.t("drawing-ui.image-text-wrap.behindText"),
803
+ value: "behindText",
804
+ icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
805
+ },
806
+ {
807
+ label: localeService.t("drawing-ui.image-text-wrap.inFrontText"),
808
+ value: "inFrontOfText",
809
+ icon: /* @__PURE__ */ jsx(TextWrapShapeIcon, {})
810
+ }
811
+ ];
812
+ const executeMenuItem = (item) => {
813
+ if (!item || item.disable) return;
814
+ commandService.executeCommand(item.commandId, item.commandParams);
552
815
  };
553
816
  const updateWrappingStyle = (value) => {
554
817
  setWrappingStyle(value);
@@ -580,7 +843,7 @@ function DocImageFloatingToolbar(props) {
580
843
  }) }),
581
844
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical" }),
582
845
  /* @__PURE__ */ jsxs(ToolbarGroup, { children: [/* @__PURE__ */ jsx(ToolbarButton, {
583
- title: editItem ? localeService.t(editItem.label) : localeService.t("drawing-ui.image-popup.edit"),
846
+ titleKey: (_editItem$label = editItem === null || editItem === void 0 ? void 0 : editItem.label) !== null && _editItem$label !== void 0 ? _editItem$label : "drawing-ui.image-popup.edit",
584
847
  disabled: !editItem || editItem.disable,
585
848
  onClick: () => {
586
849
  setHidden(true);
@@ -588,14 +851,14 @@ function DocImageFloatingToolbar(props) {
588
851
  },
589
852
  children: /* @__PURE__ */ jsx(DocSettingIcon, {})
590
853
  }), /* @__PURE__ */ jsx(ToolbarButton, {
591
- title: cropItem ? localeService.t(cropItem.label) : localeService.t("drawing-ui.image-popup.crop"),
854
+ titleKey: (_cropItem$label = cropItem === null || cropItem === void 0 ? void 0 : cropItem.label) !== null && _cropItem$label !== void 0 ? _cropItem$label : "drawing-ui.image-popup.crop",
592
855
  disabled: !cropItem || cropItem.disable,
593
856
  onClick: () => executeMenuItem(cropItem),
594
857
  children: /* @__PURE__ */ jsx(CropIcon, {})
595
858
  })] }),
596
859
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical" }),
597
860
  /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarButton, {
598
- title: deleteItem ? localeService.t(deleteItem.label) : localeService.t("drawing-ui.image-popup.delete"),
861
+ titleKey: (_deleteItem$label = deleteItem === null || deleteItem === void 0 ? void 0 : deleteItem.label) !== null && _deleteItem$label !== void 0 ? _deleteItem$label : "drawing-ui.image-popup.delete",
599
862
  disabled: !deleteItem || deleteItem.disable,
600
863
  onClick: () => executeMenuItem(deleteItem),
601
864
  children: /* @__PURE__ */ jsx(DeleteIcon, {})
@@ -603,6 +866,52 @@ function DocImageFloatingToolbar(props) {
603
866
  ]
604
867
  });
605
868
  }
869
+ function DocChartFloatingToolbar(props) {
870
+ var _chartTypeItem$option, _ref, _chartTypeItem$value, _chartTypeOptions$;
871
+ const commandService = useDependency(ICommandService);
872
+ const localeService = useDependency(LocaleService);
873
+ const chartTypeItem = props.menuItems.find((item) => item.type === "select");
874
+ const editItem = props.menuItems.find((item) => item.icon === "edit");
875
+ const deleteItem = props.menuItems.find((item) => item.icon === "delete");
876
+ const chartTypeOptions = ((_chartTypeItem$option = chartTypeItem === null || chartTypeItem === void 0 ? void 0 : chartTypeItem.options) !== null && _chartTypeItem$option !== void 0 ? _chartTypeItem$option : []).map((option) => ({
877
+ label: String(option.label),
878
+ value: option.value,
879
+ icon: /* @__PURE__ */ jsx(ChartIcon, {})
880
+ }));
881
+ const executeMenuItem = (item) => {
882
+ if (!item || item.disable) return;
883
+ commandService.executeCommand(item.commandId, item.commandParams);
884
+ };
885
+ return /* @__PURE__ */ jsxs("div", {
886
+ "data-u-comp": "doc-chart-floating-toolbar",
887
+ onMouseDown: (event) => {
888
+ event.stopPropagation();
889
+ event.preventDefault();
890
+ },
891
+ className: 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", borderClassName),
892
+ children: [chartTypeItem && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarDropdownButton, {
893
+ title: localeService.t(chartTypeItem.label),
894
+ 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 : "",
895
+ options: chartTypeOptions,
896
+ onChange: (value) => {
897
+ if (!chartTypeItem.disable) {
898
+ var _chartTypeItem$comman;
899
+ commandService.executeCommand(chartTypeItem.commandId, (_chartTypeItem$comman = chartTypeItem.commandParamsFactory) === null || _chartTypeItem$comman === void 0 ? void 0 : _chartTypeItem$comman.call(chartTypeItem, value));
900
+ }
901
+ }
902
+ }) }), (editItem || deleteItem) && /* @__PURE__ */ jsx(Separator, { orientation: "vertical" })] }), (editItem || deleteItem) && /* @__PURE__ */ jsxs(ToolbarGroup, { children: [editItem && /* @__PURE__ */ jsx(ToolbarButton, {
903
+ titleKey: editItem.label,
904
+ disabled: editItem.disable,
905
+ onClick: () => executeMenuItem(editItem),
906
+ children: /* @__PURE__ */ jsx(DocSettingIcon, {})
907
+ }), deleteItem && /* @__PURE__ */ jsx(ToolbarButton, {
908
+ titleKey: deleteItem.label,
909
+ disabled: deleteItem.disable,
910
+ onClick: () => executeMenuItem(deleteItem),
911
+ children: /* @__PURE__ */ jsx(DeleteIcon, {})
912
+ })] })]
913
+ });
914
+ }
606
915
 
607
916
  //#endregion
608
917
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
@@ -752,7 +1061,7 @@ var DrawingImageClipService = class extends Disposable {
752
1061
  //#region src/services/drawing-render.service.ts
753
1062
  const DOC_DRAWING_BEHIND_TEXT_LAYER_INDEX = 1;
754
1063
  function getDrawingRenderLayerIndex(param) {
755
- return param.behindText === true || param.behindText === BooleanNumber.TRUE ? 1 : DRAWING_OBJECT_LAYER_INDEX;
1064
+ return param.behindText === true || param.behindText === BooleanNumber.TRUE || param.layoutType === PositionedObjectLayoutType.WRAP_NONE && param.behindDoc === BooleanNumber.TRUE ? 1 : DRAWING_OBJECT_LAYER_INDEX;
756
1065
  }
757
1066
  function ensureDrawingRenderLayer(scene, object, param) {
758
1067
  const layerIndex = getDrawingRenderLayerIndex(param);
@@ -772,12 +1081,12 @@ let DrawingRenderService = class DrawingRenderService {
772
1081
  this._univerInstanceService = _univerInstanceService;
773
1082
  this._drawingImageClipService = _drawingImageClipService;
774
1083
  }
775
- async renderImages(imageParam, scene) {
1084
+ async renderImages(imageParam, scene, options) {
776
1085
  const { transform: singleTransform, drawingType, source, imageSourceType, srcRect, prstGeom, groupId, unitId, subUnitId, drawingId, isMultiTransform, transforms: multiTransforms, adjustValues, hidden } = imageParam;
777
1086
  const { docxHeaderFooterDrawing, layoutType } = imageParam;
778
1087
  if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE) return;
779
1088
  if (!this._drawingManagerService.getDrawingVisible()) return;
780
- if (this._univerInstanceService.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET && subUnitId !== this._getActiveSheetId()) return;
1089
+ if (!(options === null || options === void 0 ? void 0 : options.allowInactiveSheet) && this._univerInstanceService.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET && subUnitId !== this._getActiveSheetId()) return;
781
1090
  if (singleTransform == null) return;
782
1091
  const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform];
783
1092
  const images = [];
@@ -817,13 +1126,13 @@ let DrawingRenderService = class DrawingRenderService {
817
1126
  const imageNativeCache = this._imageIoService.getImageSourceCache(source, imageSourceType);
818
1127
  let shouldBeCache = false;
819
1128
  if (isRenderableImageCache(imageNativeCache)) imageConfig.image = imageNativeCache;
820
- else if (imageSourceType === ImageSourceType$1.UUID) try {
1129
+ else if (imageSourceType === ImageSourceType.UUID) try {
821
1130
  imageConfig.url = await this._imageIoService.getImage(source);
822
1131
  } catch (error) {
823
1132
  console.error(error);
824
1133
  continue;
825
1134
  }
826
- else if (imageSourceType === ImageSourceType$1.URL) {
1135
+ else if (imageSourceType === ImageSourceType.URL) {
827
1136
  try {
828
1137
  imageConfig.url = await this._urlImageService.getImage(source);
829
1138
  } catch (error) {
@@ -911,11 +1220,11 @@ let DrawingRenderService = class DrawingRenderService {
911
1220
  }
912
1221
  return rects;
913
1222
  }
914
- renderDrawing(param, scene) {
1223
+ renderDrawing(param, scene, options) {
915
1224
  const drawingParam = this._drawingManagerService.getDrawingByParam(param);
916
1225
  if (drawingParam == null) return;
917
1226
  switch (drawingParam.drawingType) {
918
- case DrawingTypeEnum.DRAWING_IMAGE: return this.renderImages(drawingParam, scene);
1227
+ case DrawingTypeEnum.DRAWING_IMAGE: return this.renderImages(drawingParam, scene, options);
919
1228
  default:
920
1229
  }
921
1230
  }
@@ -2044,338 +2353,76 @@ let ImageUpdateController = class ImageUpdateController extends Disposable {
2044
2353
  }));
2045
2354
  }
2046
2355
  _insertImages(params) {
2047
- params.forEach(async (param) => {
2048
- var _getCurrentUnitInfo;
2049
- const { unitId, subUnitId } = param;
2050
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2051
- const currentSubUnitId = (_getCurrentUnitInfo = getCurrentUnitInfo(this._currentUniverService, unitId)) === null || _getCurrentUnitInfo === void 0 ? void 0 : _getCurrentUnitInfo.subUnitId;
2052
- if (renderObject == null || currentSubUnitId !== subUnitId) return;
2053
- const imageParam = this._drawingManagerService.getDrawingByParam(param);
2054
- if (imageParam == null) return;
2055
- const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
2056
- this._drawingManagerService.refreshTransform([imageParam]);
2057
- if (images == null || images.length === 0) return;
2058
- for (const image of images) {
2059
- this._addHoverForImage(image);
2060
- this._addDialogForImage(image);
2061
- }
2062
- });
2063
- }
2064
- _imageUpdateListener() {
2065
- this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
2066
- params.forEach((param) => {
2067
- var _setClipBounds;
2068
- const { unitId, subUnitId, drawingId } = param;
2069
- const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2070
- if (drawingParam == null) return;
2071
- const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
2072
- if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE) return;
2073
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2074
- if (renderObject == null) return;
2075
- const { scene, transformer } = renderObject;
2076
- if (transform == null) return true;
2077
- const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
2078
- unitId,
2079
- subUnitId,
2080
- drawingId
2081
- });
2082
- const imageShape = scene.getObject(drawingShapeKey);
2083
- if (imageShape == null) return true;
2084
- imageShape.transformByState(transform);
2085
- (_setClipBounds = imageShape.setClipBounds) === null || _setClipBounds === void 0 || _setClipBounds.call(imageShape, transform.clipBounds);
2086
- ensureDrawingRenderLayer(scene, imageShape, drawingParam);
2087
- imageShape.setSrcRect(srcRect);
2088
- imageShape.setPrstGeom(prstGeom);
2089
- if (source != null && source.length > 0 && (imageSourceType === ImageSourceType.BASE64 || imageSourceType === ImageSourceType.URL)) imageShape.changeSource(source);
2090
- });
2091
- }));
2092
- }
2093
- _addHoverForImage(o) {
2094
- this.disposeWithMe(toDisposable(o.onPointerEnter$.subscribeEvent(() => {
2095
- o.cursor = CURSOR_TYPE.GRAB;
2096
- })));
2097
- this.disposeWithMe(toDisposable(o.onPointerLeave$.subscribeEvent(() => {
2098
- o.cursor = CURSOR_TYPE.DEFAULT;
2099
- })));
2100
- }
2101
- _addDialogForImage(o) {
2102
- this.disposeWithMe(toDisposable(o.onDblclick$.subscribeEvent(() => {
2103
- const dialogId = `${o.oKey}-viewer-dialog`;
2104
- this._drawingRenderService.previewImage(dialogId, o.getNative().src, o.getNativeSize().width, o.getNativeSize().height);
2105
- })));
2106
- }
2107
- };
2108
- ImageUpdateController = __decorate([
2109
- __decorateParam(0, ICommandService),
2110
- __decorateParam(1, IRenderManagerService),
2111
- __decorateParam(2, IDrawingManagerService),
2112
- __decorateParam(3, IDialogService),
2113
- __decorateParam(4, IImageIoService),
2114
- __decorateParam(5, IUniverInstanceService),
2115
- __decorateParam(6, Inject(DrawingRenderService))
2116
- ], ImageUpdateController);
2117
-
2118
- //#endregion
2119
- //#region src/menu/align.menu.ts
2120
- const getMenuStateByDrawingFocusChangedObservable$$1 = (accessor) => {
2121
- const drawingManagerService = accessor.get(IDrawingManagerService);
2122
- return new Observable((subscriber) => {
2123
- const update = (drawings) => {
2124
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2125
- if (drawings.length < 2) return subscriber.next(true);
2126
- subscriber.next(false);
2127
- };
2128
- const subscription = drawingManagerService.focus$.subscribe((drawings) => {
2129
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2130
- update(drawings);
2131
- });
2132
- update(drawingManagerService.getFocusDrawings());
2133
- return () => subscription.unsubscribe();
2134
- });
2135
- };
2136
- const DRAWING_ALIGN_CONTEXT_MENU_ID = "contextMenu.drawing-align";
2137
- function DrawingAlignContextMenuItemFactory(accessor) {
2138
- return {
2139
- id: DRAWING_ALIGN_CONTEXT_MENU_ID,
2140
- type: MenuItemType.SUBITEMS,
2141
- icon: "HorizontallyIcon",
2142
- title: "drawing-ui.image-panel.align.title",
2143
- hidden$: getMenuStateByDrawingFocusChangedObservable$$1(accessor)
2144
- };
2145
- }
2146
- function SetDrawingAlignLeftMenuItemFactory() {
2147
- return {
2148
- id: SetDrawingAlignLeftOperation.id,
2149
- type: MenuItemType.BUTTON,
2150
- icon: "LeftJustifyingIcon",
2151
- title: "drawing-ui.image-panel.align.left"
2152
- };
2153
- }
2154
- function SetDrawingAlignCenterMenuItemFactory() {
2155
- return {
2156
- id: SetDrawingAlignCenterOperation.id,
2157
- type: MenuItemType.BUTTON,
2158
- icon: "HorizontallyIcon",
2159
- title: "drawing-ui.image-panel.align.center"
2160
- };
2161
- }
2162
- function SetDrawingAlignRightMenuItemFactory() {
2163
- return {
2164
- id: SetDrawingAlignRightOperation.id,
2165
- type: MenuItemType.BUTTON,
2166
- icon: "RightJustifyingIcon",
2167
- title: "drawing-ui.image-panel.align.right"
2168
- };
2169
- }
2170
- function SetDrawingAlignTopMenuItemFactory() {
2171
- return {
2172
- id: SetDrawingAlignTopOperation.id,
2173
- type: MenuItemType.BUTTON,
2174
- icon: "AlignTopIcon",
2175
- title: "drawing-ui.image-panel.align.top"
2176
- };
2177
- }
2178
- function SetDrawingAlignMiddleMenuItemFactory() {
2179
- return {
2180
- id: SetDrawingAlignMiddleOperation.id,
2181
- type: MenuItemType.BUTTON,
2182
- icon: "VerticalCenterIcon",
2183
- title: "drawing-ui.image-panel.align.middle"
2184
- };
2185
- }
2186
- function SetDrawingAlignBottomMenuItemFactory() {
2187
- return {
2188
- id: SetDrawingAlignBottomOperation.id,
2189
- type: MenuItemType.BUTTON,
2190
- icon: "AlignBottomIcon",
2191
- title: "drawing-ui.image-panel.align.bottom"
2192
- };
2193
- }
2194
- function SetDrawingAlignHorizonMenuItemFactory() {
2195
- return {
2196
- id: SetDrawingAlignHorizonOperation.id,
2197
- type: MenuItemType.BUTTON,
2198
- icon: "HorizontallyIcon",
2199
- title: "drawing-ui.image-panel.align.horizon"
2200
- };
2201
- }
2202
- function SetDrawingAlignVerticalMenuItemFactory() {
2203
- return {
2204
- id: SetDrawingAlignVerticalOperation.id,
2205
- type: MenuItemType.BUTTON,
2206
- icon: "VerticalCenterIcon",
2207
- title: "drawing-ui.image-panel.align.vertical"
2208
- };
2209
- }
2210
-
2211
- //#endregion
2212
- //#region src/menu/arrange.menu.ts
2213
- const DRAWING_ARRANGE_CONTEXT_MENU_ID = "contextMenu.drawing-arrange";
2214
- function DrawingArrangeContextMenuItemFactory() {
2215
- return {
2216
- id: DRAWING_ARRANGE_CONTEXT_MENU_ID,
2217
- type: MenuItemType.SUBITEMS,
2218
- icon: "TopmostIcon",
2219
- title: "drawing-ui.image-panel.arrange.title"
2220
- };
2221
- }
2222
- function SetDrawingArrangeFrontMenuItemFactory() {
2223
- return {
2224
- id: SetDrawingArrangeFrontOperation.id,
2225
- type: MenuItemType.BUTTON,
2226
- icon: "TopmostIcon",
2227
- title: "drawing-ui.image-panel.arrange.front"
2228
- };
2229
- }
2230
- function SetDrawingArrangeForwardMenuItemFactory() {
2231
- return {
2232
- id: SetDrawingArrangeForwardOperation.id,
2233
- type: MenuItemType.BUTTON,
2234
- icon: "MoveUpIcon",
2235
- title: "drawing-ui.image-panel.arrange.forward"
2236
- };
2237
- }
2238
- function SetDrawingArrangeBackMenuItemFactory() {
2239
- return {
2240
- id: SetDrawingArrangeBackOperation.id,
2241
- type: MenuItemType.BUTTON,
2242
- icon: "BottomIcon",
2243
- title: "drawing-ui.image-panel.arrange.back"
2244
- };
2245
- }
2246
- function SetDrawingArrangeBackwardMenuItemFactory() {
2247
- return {
2248
- id: SetDrawingArrangeBackwardOperation.id,
2249
- type: MenuItemType.BUTTON,
2250
- icon: "MoveDownIcon",
2251
- title: "drawing-ui.image-panel.arrange.backward"
2252
- };
2253
- }
2254
-
2255
- //#endregion
2256
- //#region src/menu/group.menu.ts
2257
- function getMenuStateByDrawingFocusChangedObservable$(accessor, type) {
2258
- const drawingManagerService = accessor.get(IDrawingManagerService);
2259
- return new Observable((subscriber) => {
2260
- const update = (drawings) => {
2261
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2262
- if (type === "group") {
2263
- if (drawings.length < 2) return subscriber.next(true);
2264
- if (!drawings.every((drawing) => isGroupableDrawingType(drawing.drawingType))) return subscriber.next(true);
2265
- } else if (type === "unGroup") {
2266
- if (drawings.filter((drawing) => drawing.drawingType === DrawingTypeEnum.DRAWING_GROUP).length === 0) return subscriber.next(true);
2267
- } else if (!drawings.every((drawing) => isGroupableDrawingType(drawing.drawingType))) return subscriber.next(true);
2268
- subscriber.next(false);
2269
- };
2270
- const subscription = drawingManagerService.focus$.subscribe((drawings) => {
2271
- if (!drawings || drawings.length === 0) return subscriber.next(true);
2272
- update(drawings);
2356
+ params.forEach(async (param) => {
2357
+ var _getCurrentUnitInfo;
2358
+ const { unitId, subUnitId } = param;
2359
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2360
+ const currentSubUnitId = (_getCurrentUnitInfo = getCurrentUnitInfo(this._currentUniverService, unitId)) === null || _getCurrentUnitInfo === void 0 ? void 0 : _getCurrentUnitInfo.subUnitId;
2361
+ if (renderObject == null || currentSubUnitId !== subUnitId) return;
2362
+ const imageParam = this._drawingManagerService.getDrawingByParam(param);
2363
+ if (imageParam == null) return;
2364
+ const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
2365
+ this._drawingManagerService.refreshTransform([imageParam]);
2366
+ if (images == null || images.length === 0) return;
2367
+ for (const image of images) {
2368
+ this._addHoverForImage(image);
2369
+ this._addDialogForImage(image);
2370
+ }
2273
2371
  });
2274
- update(drawingManagerService.getFocusDrawings());
2275
- return () => subscription.unsubscribe();
2276
- });
2277
- }
2278
- const DRAWING_GROUP_CONTEXT_MENU_ID = "contextMenu.drawing-group";
2279
- function DrawingGroupContextMenuItemFactory(accessor) {
2280
- return {
2281
- id: DRAWING_GROUP_CONTEXT_MENU_ID,
2282
- type: MenuItemType.SUBITEMS,
2283
- icon: "GroupIcon",
2284
- title: "drawing-ui.image-panel.group.title",
2285
- hidden$: getMenuStateByDrawingFocusChangedObservable$(accessor)
2286
- };
2287
- }
2288
- function SetDrawingGroupMenuItemFactory(accessor) {
2289
- return {
2290
- id: SetDrawingGroupOperation.id,
2291
- type: MenuItemType.BUTTON,
2292
- icon: "GroupIcon",
2293
- title: "drawing-ui.image-panel.group.group",
2294
- disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "group")
2295
- };
2296
- }
2297
- function CancelDrawingGroupMenuItemFactory(accessor) {
2298
- return {
2299
- id: CancelDrawingGroupOperation.id,
2300
- type: MenuItemType.BUTTON,
2301
- icon: "UngroupIcon",
2302
- title: "drawing-ui.image-panel.group.unGroup",
2303
- disabled$: getMenuStateByDrawingFocusChangedObservable$(accessor, "unGroup")
2304
- };
2305
- }
2306
-
2307
- //#endregion
2308
- //#region src/menu/schema.ts
2309
- const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]: {
2310
- [DRAWING_GROUP_CONTEXT_MENU_ID]: {
2311
- order: 1,
2312
- menuItemFactory: DrawingGroupContextMenuItemFactory,
2313
- [SetDrawingGroupOperation.id]: {
2314
- order: 0,
2315
- menuItemFactory: SetDrawingGroupMenuItemFactory
2316
- },
2317
- [CancelDrawingGroupOperation.id]: {
2318
- order: 1,
2319
- menuItemFactory: CancelDrawingGroupMenuItemFactory
2320
- }
2321
- },
2322
- [DRAWING_ARRANGE_CONTEXT_MENU_ID]: {
2323
- order: 2,
2324
- menuItemFactory: DrawingArrangeContextMenuItemFactory,
2325
- [SetDrawingArrangeFrontOperation.id]: {
2326
- order: 0,
2327
- menuItemFactory: SetDrawingArrangeFrontMenuItemFactory
2328
- },
2329
- [SetDrawingArrangeForwardOperation.id]: {
2330
- order: 1,
2331
- menuItemFactory: SetDrawingArrangeForwardMenuItemFactory
2332
- },
2333
- [SetDrawingArrangeBackOperation.id]: {
2334
- order: 2,
2335
- menuItemFactory: SetDrawingArrangeBackMenuItemFactory
2336
- },
2337
- [SetDrawingArrangeBackwardOperation.id]: {
2338
- order: 3,
2339
- menuItemFactory: SetDrawingArrangeBackwardMenuItemFactory
2340
- }
2341
- },
2342
- [DRAWING_ALIGN_CONTEXT_MENU_ID]: {
2343
- order: 3,
2344
- menuItemFactory: DrawingAlignContextMenuItemFactory,
2345
- [SetDrawingAlignLeftOperation.id]: {
2346
- order: 0,
2347
- menuItemFactory: SetDrawingAlignLeftMenuItemFactory
2348
- },
2349
- [SetDrawingAlignCenterOperation.id]: {
2350
- order: 1,
2351
- menuItemFactory: SetDrawingAlignCenterMenuItemFactory
2352
- },
2353
- [SetDrawingAlignRightOperation.id]: {
2354
- order: 2,
2355
- menuItemFactory: SetDrawingAlignRightMenuItemFactory
2356
- },
2357
- [SetDrawingAlignTopOperation.id]: {
2358
- order: 3,
2359
- menuItemFactory: SetDrawingAlignTopMenuItemFactory
2360
- },
2361
- [SetDrawingAlignMiddleOperation.id]: {
2362
- order: 4,
2363
- menuItemFactory: SetDrawingAlignMiddleMenuItemFactory
2364
- },
2365
- [SetDrawingAlignBottomOperation.id]: {
2366
- order: 5,
2367
- menuItemFactory: SetDrawingAlignBottomMenuItemFactory
2368
- },
2369
- [SetDrawingAlignHorizonOperation.id]: {
2370
- order: 6,
2371
- menuItemFactory: SetDrawingAlignHorizonMenuItemFactory
2372
- },
2373
- [SetDrawingAlignVerticalOperation.id]: {
2374
- order: 7,
2375
- menuItemFactory: SetDrawingAlignVerticalMenuItemFactory
2376
- }
2377
2372
  }
2378
- } } };
2373
+ _imageUpdateListener() {
2374
+ this.disposeWithMe(this._drawingManagerService.update$.subscribe((params) => {
2375
+ params.forEach((param) => {
2376
+ var _setClipBounds;
2377
+ const { unitId, subUnitId, drawingId } = param;
2378
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
2379
+ if (drawingParam == null) return;
2380
+ const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
2381
+ if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE) return;
2382
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2383
+ if (renderObject == null) return;
2384
+ const { scene, transformer } = renderObject;
2385
+ if (transform == null) return true;
2386
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({
2387
+ unitId,
2388
+ subUnitId,
2389
+ drawingId
2390
+ });
2391
+ const imageShape = scene.getObject(drawingShapeKey);
2392
+ if (imageShape == null) return true;
2393
+ imageShape.transformByState(transform);
2394
+ (_setClipBounds = imageShape.setClipBounds) === null || _setClipBounds === void 0 || _setClipBounds.call(imageShape, transform.clipBounds);
2395
+ ensureDrawingRenderLayer(scene, imageShape, drawingParam);
2396
+ imageShape.setSrcRect(srcRect);
2397
+ imageShape.setPrstGeom(prstGeom);
2398
+ if (source != null && source.length > 0 && (imageSourceType === ImageSourceType.BASE64 || imageSourceType === ImageSourceType.URL)) imageShape.changeSource(source);
2399
+ });
2400
+ }));
2401
+ }
2402
+ _addHoverForImage(o) {
2403
+ this.disposeWithMe(toDisposable(o.onPointerEnter$.subscribeEvent(() => {
2404
+ o.cursor = CURSOR_TYPE.GRAB;
2405
+ })));
2406
+ this.disposeWithMe(toDisposable(o.onPointerLeave$.subscribeEvent(() => {
2407
+ o.cursor = CURSOR_TYPE.DEFAULT;
2408
+ })));
2409
+ }
2410
+ _addDialogForImage(o) {
2411
+ this.disposeWithMe(toDisposable(o.onDblclick$.subscribeEvent(() => {
2412
+ const dialogId = `${o.oKey}-viewer-dialog`;
2413
+ this._drawingRenderService.previewImage(dialogId, o.getNative().src, o.getNativeSize().width, o.getNativeSize().height);
2414
+ })));
2415
+ }
2416
+ };
2417
+ ImageUpdateController = __decorate([
2418
+ __decorateParam(0, ICommandService),
2419
+ __decorateParam(1, IRenderManagerService),
2420
+ __decorateParam(2, IDrawingManagerService),
2421
+ __decorateParam(3, IDialogService),
2422
+ __decorateParam(4, IImageIoService),
2423
+ __decorateParam(5, IUniverInstanceService),
2424
+ __decorateParam(6, Inject(DrawingRenderService))
2425
+ ], ImageUpdateController);
2379
2426
 
2380
2427
  //#endregion
2381
2428
  //#region src/controllers/ui.controller.ts
@@ -2474,6 +2521,482 @@ _defineProperty(UniverDrawingUIPlugin, "packageName", name);
2474
2521
  _defineProperty(UniverDrawingUIPlugin, "version", version);
2475
2522
  UniverDrawingUIPlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverDrawingUIPlugin);
2476
2523
 
2524
+ //#endregion
2525
+ //#region src/views/object-list-panel/object-list-panel-layer.ts
2526
+ const OBJECT_LIST_FLOATING_SECTION_ID = "floating";
2527
+ const OBJECT_LIST_CANVAS_SECTION_ID = "canvas";
2528
+ function isFloatingObjectListDrawingType(drawingType) {
2529
+ return drawingType === DrawingTypeEnum.DRAWING_CHART || drawingType === DrawingTypeEnum.DRAWING_DOM || drawingType === DrawingTypeEnum.DRAWING_UNIT;
2530
+ }
2531
+ function getObjectListPanelSectionIdForDrawingType(drawingType) {
2532
+ return isFloatingObjectListDrawingType(drawingType) ? OBJECT_LIST_FLOATING_SECTION_ID : OBJECT_LIST_CANVAS_SECTION_ID;
2533
+ }
2534
+
2535
+ //#endregion
2536
+ //#region src/views/object-list-panel/ObjectListPanelBase.tsx
2537
+ const objectListPanelLabelKeys = {
2538
+ title: "drawing-ui.objectListPanel.title",
2539
+ empty: "drawing-ui.objectListPanel.empty",
2540
+ showAll: "drawing-ui.objectListPanel.showAll",
2541
+ hideAll: "drawing-ui.objectListPanel.hideAll",
2542
+ moveForward: "drawing-ui.objectListPanel.moveForward",
2543
+ moveBackward: "drawing-ui.objectListPanel.moveBackward",
2544
+ close: "drawing-ui.objectListPanel.close",
2545
+ show: "drawing-ui.objectListPanel.show",
2546
+ hide: "drawing-ui.objectListPanel.hide",
2547
+ lock: "drawing-ui.objectListPanel.lock",
2548
+ unlock: "drawing-ui.objectListPanel.unlock",
2549
+ name: "drawing-ui.objectListPanel.name",
2550
+ nameInput: "drawing-ui.objectListPanel.nameInput",
2551
+ description: "drawing-ui.objectListPanel.description",
2552
+ descriptionPlaceholder: "drawing-ui.objectListPanel.descriptionPlaceholder",
2553
+ details: "drawing-ui.objectListPanel.details",
2554
+ noSelection: "drawing-ui.objectListPanel.noSelection",
2555
+ locate: "drawing-ui.objectListPanel.locate",
2556
+ expand: "drawing-ui.objectListPanel.expand",
2557
+ collapse: "drawing-ui.objectListPanel.collapse",
2558
+ dragToReorder: "drawing-ui.objectListPanel.dragToReorder",
2559
+ search: "drawing-ui.objectListPanel.search",
2560
+ filterAll: "drawing-ui.objectListPanel.filterAll",
2561
+ filterHidden: "drawing-ui.objectListPanel.filterHidden",
2562
+ filterLocked: "drawing-ui.objectListPanel.filterLocked",
2563
+ sectionCanvas: "drawing-ui.objectListPanel.sectionCanvas",
2564
+ sectionFloating: "drawing-ui.objectListPanel.sectionFloating"
2565
+ };
2566
+ function getObjectListPanelLabels(localeService) {
2567
+ return Object.fromEntries(Object.entries(objectListPanelLabelKeys).map(([labelKey, localeKey]) => [labelKey, localeService.t(localeKey)]));
2568
+ }
2569
+ function getObjectListPanelTypeName(localeService, typeName) {
2570
+ return localeService.t(`drawing-ui.objectListPanel.typeNames.${typeName}`);
2571
+ }
2572
+ const iconButtonClassName = `
2573
+ univer-flex univer-size-7 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-md
2574
+ univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-colors
2575
+ hover:univer-bg-gray-100 hover:univer-text-gray-900
2576
+ disabled:univer-cursor-not-allowed disabled:univer-opacity-40
2577
+ dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-100
2578
+ `;
2579
+ const sectionOrder = /* @__PURE__ */ new Map([
2580
+ [OBJECT_LIST_FLOATING_SECTION_ID, 0],
2581
+ [OBJECT_LIST_CANVAS_SECTION_ID, 1],
2582
+ ["", 2]
2583
+ ]);
2584
+ function normalizeText(value) {
2585
+ return value.trim();
2586
+ }
2587
+ function hasCapability(panelCapabilities, item, key, fallback = true) {
2588
+ var _ref, _item$capabilities$ke, _item$capabilities;
2589
+ 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;
2590
+ }
2591
+ function ObjectListPanelBase(props) {
2592
+ var _selectedItem$canMove, _selectedItem$canMove2, _capabilities$reorder;
2593
+ const { items, selectedIds, allObjectIds, focusedId, labels, showHeader = true, capabilities, onSelect, onSetVisible, onCommitName, onCommitDescription, onMoveForward, onMoveBackward, onToggleExpanded, onToggleSelectable, onLocate, onReorder } = props;
2594
+ const selectedIdSet = useMemo(() => new Set(selectedIds), [selectedIds]);
2595
+ const [draggingId, setDraggingId] = useState(null);
2596
+ const [searchQuery, setSearchQuery] = useState("");
2597
+ const [filterMode, setFilterMode] = useState("all");
2598
+ const [collapsedSectionIds, setCollapsedSectionIds] = useState(() => /* @__PURE__ */ new Set());
2599
+ const selectedItem = useMemo(() => {
2600
+ var _ref2, _items$find;
2601
+ 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;
2602
+ }, [
2603
+ focusedId,
2604
+ items,
2605
+ selectedIdSet
2606
+ ]);
2607
+ const visibleItems = useMemo(() => {
2608
+ const normalizedQuery = normalizeText(searchQuery).toLocaleLowerCase();
2609
+ return items.filter((item) => {
2610
+ var _item$description;
2611
+ if (filterMode === "hidden" && item.visible !== false) return false;
2612
+ if (filterMode === "locked" && item.selectable !== false) return false;
2613
+ if (!normalizedQuery) return true;
2614
+ return item.name.toLocaleLowerCase().includes(normalizedQuery) || ((_item$description = item.description) !== null && _item$description !== void 0 ? _item$description : "").toLocaleLowerCase().includes(normalizedQuery);
2615
+ });
2616
+ }, [
2617
+ filterMode,
2618
+ items,
2619
+ searchQuery
2620
+ ]);
2621
+ const visibleItemSections = useMemo(() => {
2622
+ const sectionMap = /* @__PURE__ */ new Map();
2623
+ visibleItems.forEach((item) => {
2624
+ var _item$sectionId, _item$sectionTitle;
2625
+ const sectionId = (_item$sectionId = item.sectionId) !== null && _item$sectionId !== void 0 ? _item$sectionId : "";
2626
+ const existingSection = sectionMap.get(sectionId);
2627
+ if (existingSection) {
2628
+ existingSection.items.push(item);
2629
+ return;
2630
+ }
2631
+ sectionMap.set(sectionId, {
2632
+ id: sectionId,
2633
+ title: (_item$sectionTitle = item.sectionTitle) !== null && _item$sectionTitle !== void 0 ? _item$sectionTitle : "",
2634
+ items: [item]
2635
+ });
2636
+ });
2637
+ return [...sectionMap.values()].sort((a, b) => {
2638
+ var _sectionOrder$get, _sectionOrder$get2;
2639
+ 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);
2640
+ });
2641
+ }, [visibleItems]);
2642
+ const showSectionHeaders = visibleItemSections.length > 1 || visibleItemSections.some((section) => section.id === "floating");
2643
+ const allIds = useMemo(() => allObjectIds !== null && allObjectIds !== void 0 ? allObjectIds : items.map((item) => item.id), [allObjectIds, items]);
2644
+ const selectedIndex = selectedItem ? items.findIndex((item) => item.id === selectedItem.id) : -1;
2645
+ const canMoveForward = !!selectedItem && !!onMoveForward && !selectedItem.disabled && ((_selectedItem$canMove = selectedItem.canMoveForward) !== null && _selectedItem$canMove !== void 0 ? _selectedItem$canMove : selectedIndex > 0) && hasCapability(capabilities, selectedItem, "arrange");
2646
+ 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");
2647
+ const showArrangeControls = hasCapability(capabilities, selectedItem, "arrange") && (!!onMoveForward || !!onMoveBackward);
2648
+ const showLocateControl = !!onLocate && hasCapability(capabilities, selectedItem, "locate");
2649
+ const canReorder = !!onReorder && ((_capabilities$reorder = capabilities === null || capabilities === void 0 ? void 0 : capabilities.reorder) !== null && _capabilities$reorder !== void 0 ? _capabilities$reorder : true);
2650
+ const findItem = (objectId) => {
2651
+ var _items$find2;
2652
+ return objectId ? (_items$find2 = items.find((item) => item.id === objectId)) !== null && _items$find2 !== void 0 ? _items$find2 : null : null;
2653
+ };
2654
+ const handleDrop = (targetId) => {
2655
+ var _source$parentId, _target$parentId, _source$sectionId, _target$sectionId;
2656
+ const source = findItem(draggingId);
2657
+ const target = findItem(targetId);
2658
+ setDraggingId(null);
2659
+ if (!source || !target || source.id === target.id || source.disabled || target.disabled) return;
2660
+ if (((_source$parentId = source.parentId) !== null && _source$parentId !== void 0 ? _source$parentId : "") !== ((_target$parentId = target.parentId) !== null && _target$parentId !== void 0 ? _target$parentId : "")) return;
2661
+ if (((_source$sectionId = source.sectionId) !== null && _source$sectionId !== void 0 ? _source$sectionId : "") !== ((_target$sectionId = target.sectionId) !== null && _target$sectionId !== void 0 ? _target$sectionId : "")) return;
2662
+ if (source.canReorder === false || target.canReorder === false) return;
2663
+ onReorder === null || onReorder === void 0 || onReorder(source.id, target.id);
2664
+ };
2665
+ const toggleSectionCollapsed = (sectionId) => {
2666
+ if (!sectionId) return;
2667
+ setCollapsedSectionIds((current) => {
2668
+ const next = new Set(current);
2669
+ if (next.has(sectionId)) next.delete(sectionId);
2670
+ else next.add(sectionId);
2671
+ return next;
2672
+ });
2673
+ };
2674
+ return /* @__PURE__ */ jsxs("div", {
2675
+ 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",
2676
+ "data-drawing-object-list-panel": "true",
2677
+ children: [
2678
+ showHeader && /* @__PURE__ */ jsx("div", {
2679
+ className: "univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-gap-2",
2680
+ children: /* @__PURE__ */ jsx("div", {
2681
+ 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",
2682
+ children: labels.title
2683
+ })
2684
+ }),
2685
+ /* @__PURE__ */ jsxs("div", {
2686
+ className: "univer-flex univer-min-w-0 univer-items-center univer-justify-between univer-gap-2",
2687
+ children: [/* @__PURE__ */ jsxs("div", {
2688
+ className: "univer-flex univer-min-w-0 univer-gap-2",
2689
+ children: [/* @__PURE__ */ jsx(Button, {
2690
+ size: "small",
2691
+ disabled: items.length === 0,
2692
+ onClick: () => onSetVisible(allIds, true),
2693
+ children: labels.showAll
2694
+ }), /* @__PURE__ */ jsx(Button, {
2695
+ size: "small",
2696
+ disabled: items.length === 0,
2697
+ onClick: () => onSetVisible(allIds, false),
2698
+ children: labels.hideAll
2699
+ })]
2700
+ }), /* @__PURE__ */ jsxs("div", {
2701
+ className: "univer-flex univer-shrink-0 univer-gap-1",
2702
+ children: [showLocateControl && /* @__PURE__ */ jsx("button", {
2703
+ type: "button",
2704
+ className: iconButtonClassName,
2705
+ title: labels.locate,
2706
+ "aria-label": labels.locate,
2707
+ disabled: !(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id),
2708
+ onClick: () => selectedItem && (onLocate === null || onLocate === void 0 ? void 0 : onLocate(selectedItem.id)),
2709
+ children: /* @__PURE__ */ jsx(LocateFixedIcon, {})
2710
+ }), showArrangeControls && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
2711
+ type: "button",
2712
+ className: iconButtonClassName,
2713
+ title: labels.moveForward,
2714
+ "aria-label": labels.moveForward,
2715
+ disabled: !canMoveForward,
2716
+ onClick: () => selectedItem && (onMoveForward === null || onMoveForward === void 0 ? void 0 : onMoveForward(selectedItem.id)),
2717
+ children: /* @__PURE__ */ jsx(ArrowUpIcon, {})
2718
+ }), /* @__PURE__ */ jsx("button", {
2719
+ type: "button",
2720
+ className: iconButtonClassName,
2721
+ title: labels.moveBackward,
2722
+ "aria-label": labels.moveBackward,
2723
+ disabled: !canMoveBackward,
2724
+ onClick: () => selectedItem && (onMoveBackward === null || onMoveBackward === void 0 ? void 0 : onMoveBackward(selectedItem.id)),
2725
+ children: /* @__PURE__ */ jsx(ArrowDownIcon, {})
2726
+ })] })]
2727
+ })]
2728
+ }),
2729
+ /* @__PURE__ */ jsxs("div", {
2730
+ className: "univer-flex univer-shrink-0 univer-flex-col univer-gap-2",
2731
+ children: [/* @__PURE__ */ jsx(Input, {
2732
+ value: searchQuery,
2733
+ "aria-label": labels.search,
2734
+ placeholder: labels.search,
2735
+ onChange: setSearchQuery
2736
+ }), /* @__PURE__ */ jsx("div", {
2737
+ className: "univer-flex univer-min-w-0 univer-gap-1",
2738
+ children: [
2739
+ ["all", labels.filterAll],
2740
+ ["hidden", labels.filterHidden],
2741
+ ["locked", labels.filterLocked]
2742
+ ].map(([mode, label]) => /* @__PURE__ */ jsx("button", {
2743
+ type: "button",
2744
+ className: 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"),
2745
+ "aria-pressed": filterMode === mode,
2746
+ onClick: () => setFilterMode(mode),
2747
+ children: /* @__PURE__ */ jsx("span", {
2748
+ className: "univer-block univer-truncate",
2749
+ children: label
2750
+ })
2751
+ }, mode))
2752
+ })]
2753
+ }),
2754
+ /* @__PURE__ */ jsx("div", {
2755
+ className: "univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden",
2756
+ children: visibleItems.length === 0 ? /* @__PURE__ */ jsx("div", {
2757
+ className: "univer-py-6 univer-text-center univer-text-sm univer-text-gray-500",
2758
+ children: labels.empty
2759
+ }) : /* @__PURE__ */ jsx("div", {
2760
+ className: "univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5",
2761
+ children: visibleItemSections.map((section) => /* @__PURE__ */ jsxs("div", {
2762
+ className: "univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5",
2763
+ children: [showSectionHeaders && section.title && (() => {
2764
+ const sectionCollapsed = !!section.id && collapsedSectionIds.has(section.id);
2765
+ return /* @__PURE__ */ jsxs("button", {
2766
+ type: "button",
2767
+ 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",
2768
+ "aria-label": sectionCollapsed ? labels.expand : labels.collapse,
2769
+ disabled: !section.id,
2770
+ onClick: () => toggleSectionCollapsed(section.id),
2771
+ children: [
2772
+ section.id ? /* @__PURE__ */ jsx("span", {
2773
+ className: "univer-flex univer-size-4 univer-shrink-0 univer-items-center univer-justify-center",
2774
+ children: sectionCollapsed ? /* @__PURE__ */ jsx(MoreRightIcon, {}) : /* @__PURE__ */ jsx(MoreDownIcon, {})
2775
+ }) : /* @__PURE__ */ jsx("span", { className: "univer-size-4 univer-shrink-0" }),
2776
+ /* @__PURE__ */ jsx("span", {
2777
+ className: "univer-min-w-0 univer-flex-1 univer-truncate univer-text-left",
2778
+ children: section.title
2779
+ }),
2780
+ /* @__PURE__ */ jsx("span", {
2781
+ className: "univer-shrink-0 univer-text-[10px] univer-font-medium univer-text-gray-400 dark:!univer-text-gray-500",
2782
+ children: section.items.length
2783
+ })
2784
+ ]
2785
+ });
2786
+ })(), (!section.id || !collapsedSectionIds.has(section.id)) && section.items.map((item) => /* @__PURE__ */ jsx(ObjectListRow, {
2787
+ item,
2788
+ selected: selectedIdSet.has(item.id),
2789
+ labels,
2790
+ showLock: !!onToggleSelectable && hasCapability(capabilities, item, "selectable"),
2791
+ showName: hasCapability(capabilities, item, "name"),
2792
+ showVisible: hasCapability(capabilities, item, "visible"),
2793
+ draggable: canReorder && hasCapability(capabilities, item, "reorder") && !item.disabled && item.canReorder !== false,
2794
+ dragging: draggingId === item.id,
2795
+ onSelect: (multiSelect) => onSelect(item.id, multiSelect),
2796
+ onToggleExpanded: () => onToggleExpanded === null || onToggleExpanded === void 0 ? void 0 : onToggleExpanded(item.id),
2797
+ onToggleVisible: () => onSetVisible([item.id], !item.visible),
2798
+ onToggleSelectable: () => onToggleSelectable === null || onToggleSelectable === void 0 ? void 0 : onToggleSelectable(item.id),
2799
+ onCommitName: (value) => onCommitName(item.id, value),
2800
+ onDragStart: () => setDraggingId(item.id),
2801
+ onDragEnd: () => setDraggingId(null),
2802
+ onDrop: () => handleDrop(item.id)
2803
+ }, item.id))]
2804
+ }, section.id || "default"))
2805
+ })
2806
+ }),
2807
+ /* @__PURE__ */ jsx(ObjectDetailsEditor, {
2808
+ item: selectedItem,
2809
+ labels,
2810
+ showName: hasCapability(capabilities, selectedItem, "name"),
2811
+ showDescription: hasCapability(capabilities, selectedItem, "description"),
2812
+ onCommitName: (value) => selectedItem && onCommitName(selectedItem.id, value),
2813
+ onCommitDescription: (value) => selectedItem && onCommitDescription(selectedItem.id, value)
2814
+ })
2815
+ ]
2816
+ });
2817
+ }
2818
+ function ObjectListRow(props) {
2819
+ var _item$level;
2820
+ const { item, selected, labels, showLock, showName, showVisible, draggable, dragging, onSelect, onToggleExpanded, onToggleVisible, onToggleSelectable, onCommitName, onDragStart, onDragEnd, onDrop } = props;
2821
+ const [draftName, setDraftName] = useState(item.name);
2822
+ const skipCommitOnBlurRef = useRef(false);
2823
+ const disabled = item.disabled === true;
2824
+ const level = (_item$level = item.level) !== null && _item$level !== void 0 ? _item$level : 0;
2825
+ const locked = item.selectable === false;
2826
+ useEffect(() => {
2827
+ setDraftName(item.name);
2828
+ }, [item.name]);
2829
+ const handleBlur = (event) => {
2830
+ if (disabled) return;
2831
+ if (skipCommitOnBlurRef.current) {
2832
+ skipCommitOnBlurRef.current = false;
2833
+ return;
2834
+ }
2835
+ if (event.currentTarget.value !== item.name) onCommitName(event.currentTarget.value);
2836
+ };
2837
+ const handleKeyDown = (event) => {
2838
+ if (event.key === "Enter") {
2839
+ event.currentTarget.blur();
2840
+ return;
2841
+ }
2842
+ if (event.key === "Escape") {
2843
+ skipCommitOnBlurRef.current = true;
2844
+ setDraftName(item.name);
2845
+ event.currentTarget.blur();
2846
+ }
2847
+ };
2848
+ return /* @__PURE__ */ jsxs("div", {
2849
+ className: 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"),
2850
+ style: { paddingLeft: level * 14 + 4 },
2851
+ draggable,
2852
+ title: draggable ? labels.dragToReorder : void 0,
2853
+ onClick: disabled ? void 0 : (event) => onSelect(event.ctrlKey || event.metaKey),
2854
+ onDragStart: (event) => {
2855
+ if (!draggable) {
2856
+ event.preventDefault();
2857
+ return;
2858
+ }
2859
+ event.dataTransfer.effectAllowed = "move";
2860
+ event.dataTransfer.setData("text/plain", item.id);
2861
+ onDragStart();
2862
+ },
2863
+ onDragEnd,
2864
+ onDragOver: (event) => {
2865
+ if (draggable) {
2866
+ event.preventDefault();
2867
+ event.dataTransfer.dropEffect = "move";
2868
+ }
2869
+ },
2870
+ onDrop: (event) => {
2871
+ event.preventDefault();
2872
+ onDrop();
2873
+ },
2874
+ children: [
2875
+ item.isGroup ? /* @__PURE__ */ jsx("button", {
2876
+ type: "button",
2877
+ 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",
2878
+ title: item.expanded ? labels.collapse : labels.expand,
2879
+ "aria-label": item.expanded ? labels.collapse : labels.expand,
2880
+ onClick: (event) => {
2881
+ event.stopPropagation();
2882
+ onToggleExpanded();
2883
+ },
2884
+ children: item.expanded ? /* @__PURE__ */ jsx(MoreDownIcon, {}) : /* @__PURE__ */ jsx(MoreRightIcon, {})
2885
+ }) : /* @__PURE__ */ jsx("span", { className: "univer-size-5 univer-shrink-0" }),
2886
+ showName ? /* @__PURE__ */ jsx(Input, {
2887
+ className: clsx("univer-h-7 univer-w-0 univer-min-w-0 univer-flex-1", disabled && "univer-cursor-not-allowed"),
2888
+ inputClass: 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"),
2889
+ inputStyle: {
2890
+ maxWidth: "100%",
2891
+ boxSizing: "border-box"
2892
+ },
2893
+ value: draftName,
2894
+ disabled,
2895
+ "aria-label": labels.nameInput,
2896
+ onChange: setDraftName,
2897
+ onBlur: handleBlur,
2898
+ onKeyDown: handleKeyDown,
2899
+ onClick: (event) => {
2900
+ event.stopPropagation();
2901
+ if (!disabled) onSelect(event.ctrlKey || event.metaKey);
2902
+ }
2903
+ }, item.name) : /* @__PURE__ */ jsx("span", {
2904
+ className: "univer-min-w-0 univer-flex-1 univer-truncate univer-px-1 univer-text-sm",
2905
+ children: item.name
2906
+ }),
2907
+ showLock && /* @__PURE__ */ jsx("button", {
2908
+ type: "button",
2909
+ className: clsx(iconButtonClassName, !locked && "univer-opacity-70"),
2910
+ disabled,
2911
+ title: locked ? labels.unlock : labels.lock,
2912
+ "aria-label": locked ? labels.unlock : labels.lock,
2913
+ onClick: (event) => {
2914
+ event.stopPropagation();
2915
+ onToggleSelectable();
2916
+ },
2917
+ children: /* @__PURE__ */ jsx(LockIcon, {})
2918
+ }),
2919
+ showVisible && /* @__PURE__ */ jsx("button", {
2920
+ type: "button",
2921
+ className: iconButtonClassName,
2922
+ disabled,
2923
+ title: item.visible ? labels.hide : labels.show,
2924
+ "aria-label": item.visible ? labels.hide : labels.show,
2925
+ onClick: (event) => {
2926
+ event.stopPropagation();
2927
+ onToggleVisible();
2928
+ },
2929
+ children: item.visible ? /* @__PURE__ */ jsx(EyeIcon, {}) : /* @__PURE__ */ jsx(EyelashIcon, {})
2930
+ })
2931
+ ]
2932
+ });
2933
+ }
2934
+ function ObjectDetailsEditor(props) {
2935
+ var _item$name, _item$description2;
2936
+ const { item, labels, showName, showDescription, onCommitName, onCommitDescription } = props;
2937
+ const [draftName, setDraftName] = useState((_item$name = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name !== void 0 ? _item$name : "");
2938
+ const [draftDescription, setDraftDescription] = useState((_item$description2 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description2 !== void 0 ? _item$description2 : "");
2939
+ const disabled = (item === null || item === void 0 ? void 0 : item.disabled) === true;
2940
+ useEffect(() => {
2941
+ var _item$name2, _item$description3;
2942
+ setDraftName((_item$name2 = item === null || item === void 0 ? void 0 : item.name) !== null && _item$name2 !== void 0 ? _item$name2 : "");
2943
+ setDraftDescription((_item$description3 = item === null || item === void 0 ? void 0 : item.description) !== null && _item$description3 !== void 0 ? _item$description3 : "");
2944
+ }, [
2945
+ item === null || item === void 0 ? void 0 : item.description,
2946
+ item === null || item === void 0 ? void 0 : item.id,
2947
+ item === null || item === void 0 ? void 0 : item.name
2948
+ ]);
2949
+ if (!item) return /* @__PURE__ */ jsx("div", {
2950
+ 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",
2951
+ children: labels.noSelection
2952
+ });
2953
+ return /* @__PURE__ */ jsxs("div", {
2954
+ 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",
2955
+ children: [
2956
+ /* @__PURE__ */ jsx("div", {
2957
+ className: "univer-text-xs univer-font-semibold univer-uppercase univer-text-gray-500 dark:!univer-text-gray-400",
2958
+ children: labels.details
2959
+ }),
2960
+ showName && /* @__PURE__ */ jsxs("label", {
2961
+ className: "univer-flex univer-flex-col univer-gap-1",
2962
+ children: [/* @__PURE__ */ jsx("span", {
2963
+ className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
2964
+ children: labels.name
2965
+ }), /* @__PURE__ */ jsx(Input, {
2966
+ value: draftName,
2967
+ "aria-label": labels.nameInput,
2968
+ disabled,
2969
+ onChange: setDraftName,
2970
+ onBlur: () => {
2971
+ if (!disabled && normalizeText(draftName) !== item.name) onCommitName(draftName);
2972
+ },
2973
+ onKeyDown: (event) => {
2974
+ if (event.key === "Enter") event.currentTarget.blur();
2975
+ }
2976
+ })]
2977
+ }),
2978
+ showDescription && /* @__PURE__ */ jsxs("label", {
2979
+ className: "univer-flex univer-flex-col univer-gap-1",
2980
+ children: [/* @__PURE__ */ jsx("span", {
2981
+ className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
2982
+ children: labels.description
2983
+ }), /* @__PURE__ */ jsx("textarea", {
2984
+ 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",
2985
+ value: draftDescription,
2986
+ disabled,
2987
+ placeholder: labels.descriptionPlaceholder,
2988
+ "aria-label": labels.description,
2989
+ onChange: (event) => setDraftDescription(event.currentTarget.value),
2990
+ onBlur: () => {
2991
+ var _item$description4;
2992
+ if (!disabled && normalizeText(draftDescription) !== ((_item$description4 = item.description) !== null && _item$description4 !== void 0 ? _item$description4 : "")) onCommitDescription(draftDescription);
2993
+ }
2994
+ })]
2995
+ })
2996
+ ]
2997
+ });
2998
+ }
2999
+
2477
3000
  //#endregion
2478
3001
  //#region src/views/panel/DrawingAlign.tsx
2479
3002
  const DrawingAlign = (props) => {
@@ -3194,4 +3717,4 @@ const DrawingCommonPanel = (props) => {
3194
3717
  };
3195
3718
 
3196
3719
  //#endregion
3197
- export { AutoImageCropOperation, COMPONENT_IMAGE_POPUP_MENU, CancelDrawingGroupOperation, CloseImageCropOperation, DRAWING_GROUP_TYPES, DrawingCommonPanel, DrawingImageClipService, DrawingRenderService, IMAGE_CLIP_SHAPE_PICKER_COMPONENT, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation, SetDrawingAlignOperation, SetDrawingArrangeOperation, SetDrawingGroupOperation, UniverDrawingUIPlugin, disposeDrawingRenderObject, getCurrentUnitInfo, getDrawingRenderObject, getUpdateParams, insertGroupObject };
3720
+ export { AutoImageCropOperation, COMPONENT_IMAGE_POPUP_MENU, CancelDrawingGroupOperation, CloseImageCropOperation, DRAWING_GROUP_TYPES, DrawingCommonPanel, DrawingImageClipService, DrawingRenderService, menuSchema as DrawingUIMenuSchema, IMAGE_CLIP_SHAPE_PICKER_COMPONENT, ImageCropperObject, ImageResetSizeOperation, OBJECT_LIST_CANVAS_SECTION_ID, OBJECT_LIST_FLOATING_SECTION_ID, ObjectListPanelBase, OpenImageCropOperation, SetDrawingAlignOperation, SetDrawingArrangeOperation, SetDrawingGroupOperation, UniverDrawingUIPlugin, disposeDrawingRenderObject, getCurrentUnitInfo, getDrawingRenderObject, getObjectListPanelLabels, getObjectListPanelSectionIdForDrawingType, getObjectListPanelTypeName, getUpdateParams, insertGroupObject, isFloatingObjectListDrawingType };