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