@univerjs/slides-ui 0.3.0 → 0.4.0-alpha.0

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/es/index.js CHANGED
@@ -2,144 +2,17 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Inject, Injector, RxDisposable, UniverInstanceType, debounce, getColorStyle, IUniverInstanceService, OnLifecycle, LifecycleStages, CommandType, PageElementType, Tools, useDependency, LocaleService, ICommandService, generateRandomId, BasicShapes, createInternalEditorID, createIdentifier, IContextService, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, FOCUSING_UNIVER_EDITOR, EDITOR_ACTIVATED, FORMULA_EDITOR_ACTIVATED, Disposable, connectInjector, DisposableCollection, toDisposable, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, DocumentDataModel, VerticalAlign, HorizontalAlign, WrapStrategy, FOCUSING_EDITOR_BUT_HIDDEN, Direction, IUndoRedoService, Plugin, mergeOverrideWithDependencies, IConfigService } from "@univerjs/core";
6
- import { Viewport, ScrollBar, Slide, Rect, Scene, IRenderManagerService, ObjectType, FIX_ONE_PIXEL_BLUR_OFFSET, DeviceInputEventType, pxToNum, convertTextRotation, fixLineWidthByScale } from "@univerjs/engine-render";
7
- import { ILocalFileService, ISidebarService, useObservable, DISABLE_AUTO_FOCUS_KEY, MenuItemType, getMenuHiddenObservable, KeyCode, MetaKeys, RibbonStartGroup, ComponentManager, BuiltInUIPart, IMenuManagerService, IUIPartsService, IShortcutService, ICanvasPopupService, ILayoutService } from "@univerjs/ui";
5
+ import { Inject, Injector, RxDisposable, UniverInstanceType, debounce, getColorStyle, IUniverInstanceService, CommandType, Tools, useDependency, LocaleService, ICommandService, generateRandomId, PageElementType, BasicShapes, Disposable, DisposableCollection, toDisposable, FOCUSING_COMMON_DRAWINGS, IContextService, createInternalEditorID, createIdentifier, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, DocumentDataModel, VerticalAlign, HorizontalAlign, WrapStrategy, FOCUSING_EDITOR_BUT_HIDDEN, DEFAULT_EMPTY_DOCUMENT_VALUE, Direction, IUndoRedoService, DocumentFlavor, FOCUSING_UNIVER_EDITOR, FORMULA_EDITOR_ACTIVATED, connectInjector, Plugin, mergeOverrideWithDependencies, IConfigService } from "@univerjs/core";
6
+ import { Viewport, ScrollBar, Slide, Rect, Scene, IRenderManagerService, ObjectType, pxToNum, DeviceInputEventType, convertTextRotation, FIX_ONE_PIXEL_BLUR_OFFSET, fixLineWidthByScale } from "@univerjs/engine-render";
8
7
  import { ObjectProvider, SLIDE_KEY } from "@univerjs/slides";
9
- import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, IImageIoService, getImageSize } from "@univerjs/drawing";
8
+ import { ISidebarService, ICanvasPopupService, KeyCode, ILayoutService, ILocalFileService, useObservable, DISABLE_AUTO_FOCUS_KEY, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, MetaKeys, ComponentManager, BuiltInUIPart, IMenuManagerService, IUIPartsService, IShortcutService } from "@univerjs/ui";
10
9
  import React, { forwardRef, useRef, createElement, useState, useEffect, useCallback } from "react";
11
10
  import clsx from "clsx";
12
11
  import { Button, InputNumber, Dropdown, ColorPicker, Scrollbar } from "@univerjs/design";
13
- import { IEditorService, TextEditor, DeleteLeftCommand, DocSelectionRenderService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, MoveSelectionOperation, MoveCursorOperation, DOCS_VIEW_KEY } from "@univerjs/docs-ui";
14
12
  import { BehaviorSubject, Subject, filter, takeUntil } from "rxjs";
15
13
  import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation } from "@univerjs/docs";
16
- var __assign = function() {
17
- return __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
19
- s = arguments[i];
20
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
21
- }
22
- return t;
23
- }, __assign.apply(this, arguments);
24
- }, __rest = function(s, e) {
25
- var t = {};
26
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
27
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
28
- for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
29
- e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
30
- return t;
31
- }, IconBase = forwardRef(function(props, ref) {
32
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
33
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
34
- });
35
- function render(node, id, runtimeProps, rootProps, extend) {
36
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
37
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
38
- }));
39
- }
40
- __name(render, "render");
41
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
42
- var attrs = __assign({}, node.attrs);
43
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
44
- var defIds = runtimeProps.defIds;
45
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a11) {
46
- var key = _a11[0], value = _a11[1];
47
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
48
- })), attrs;
49
- }
50
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
51
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
52
- var _a11, defIds = runtimeProps.defIds;
53
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
54
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
55
- }) }) : node;
56
- }
57
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
58
- function generateShortUuid() {
59
- return Math.random().toString(36).substring(2, 8);
60
- }
61
- __name(generateShortUuid, "generateShortUuid");
62
- IconBase.displayName = "UniverIcon";
63
- var element$9 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
64
- return createElement(IconBase, Object.assign({}, props, {
65
- id: "add-image-single",
66
- ref,
67
- icon: element$9
68
- }));
69
- });
70
- AddImageSingle.displayName = "AddImageSingle";
71
- var element$8 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Autofill = forwardRef(function(props, ref) {
72
- return createElement(IconBase, Object.assign({}, props, {
73
- id: "autofill",
74
- ref,
75
- icon: element$8
76
- }));
77
- });
78
- Autofill.displayName = "Autofill";
79
- var element$7 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, BottomSingle = forwardRef(function(props, ref) {
80
- return createElement(IconBase, Object.assign({}, props, {
81
- id: "bottom-single",
82
- ref,
83
- icon: element$7
84
- }));
85
- });
86
- BottomSingle.displayName = "BottomSingle";
87
- var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { clipPath: "url(#graph-single_clip0_1293_28)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M6.29541 11.1896C3.83208 10.7489 1.9624 8.59552 1.9624 6.00544C1.9624 3.09673 4.32036 0.73877 7.22907 0.73877C9.93483 0.73877 12.164 2.77918 12.4619 5.40527H13.5621C14.998 5.40527 16.1621 6.56933 16.1621 8.00527V12.6719C16.1621 14.1079 14.998 15.2719 13.5621 15.2719H8.89541C7.45947 15.2719 6.29541 14.1079 6.29541 12.6719V11.1896ZM3.1624 6.00544C3.1624 3.75947 4.98311 1.93877 7.22907 1.93877C9.27112 1.93877 10.9616 3.44388 11.2518 5.40527H8.89541C7.45947 5.40527 6.29541 6.56933 6.29541 8.00527V9.96442C4.49946 9.5425 3.1624 7.93012 3.1624 6.00544ZM7.49541 8.00527C7.49541 7.23207 8.12221 6.60527 8.89541 6.60527H13.5621C14.3353 6.60527 14.9621 7.23207 14.9621 8.00527V12.6719C14.9621 13.4451 14.3353 14.0719 13.5621 14.0719H8.89541C8.12221 14.0719 7.49541 13.4451 7.49541 12.6719V8.00527Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "graph-single_clip0_1293_28" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.9)" } }] }] }], defIds: ["graph-single_clip0_1293_28"] }, GraphSingle = forwardRef(function(props, ref) {
88
- return createElement(IconBase, Object.assign({}, props, {
89
- id: "graph-single",
90
- ref,
91
- icon: element$6
92
- }));
93
- });
94
- GraphSingle.displayName = "GraphSingle";
95
- var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreDownSingle = forwardRef(function(props, ref) {
96
- return createElement(IconBase, Object.assign({}, props, {
97
- id: "more-down-single",
98
- ref,
99
- icon: element$5
100
- }));
101
- });
102
- MoreDownSingle.displayName = "MoreDownSingle";
103
- var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, MoveDownSingle = forwardRef(function(props, ref) {
104
- return createElement(IconBase, Object.assign({}, props, {
105
- id: "move-down-single",
106
- ref,
107
- icon: element$4
108
- }));
109
- });
110
- MoveDownSingle.displayName = "MoveDownSingle";
111
- var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, MoveUpSingle = forwardRef(function(props, ref) {
112
- return createElement(IconBase, Object.assign({}, props, {
113
- id: "move-up-single",
114
- ref,
115
- icon: element$3
116
- }));
117
- });
118
- MoveUpSingle.displayName = "MoveUpSingle";
119
- var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_102_1204", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#DCDCDC", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_102_1204)" }, children: [{ tag: "rect", attrs: { width: 12.62, height: 2.79, x: 1.69, y: 12.25, fill: "colorChannel1", rx: 1.4 } }, { tag: "path", attrs: { fill: "currentColor", d: "M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z" } }] }] }, PaintBucket = forwardRef(function(props, ref) {
120
- return createElement(IconBase, Object.assign({}, props, {
121
- id: "paint-bucket",
122
- ref,
123
- icon: element$2
124
- }));
125
- });
126
- PaintBucket.displayName = "PaintBucket";
127
- var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#text-single_clip0_1293_26)" }, children: [{ tag: "path", attrs: { d: "M2.22891 2.07227C1.89754 2.07227 1.62891 2.34089 1.62891 2.67227C1.62891 3.00364 1.89754 3.27227 2.22891 3.27227H6.29541V14.0056C6.29541 14.337 6.56404 14.6056 6.89541 14.6056C7.22678 14.6056 7.49541 14.337 7.49541 14.0056V3.27227H11.5622C11.8936 3.27227 12.1622 3.00364 12.1622 2.67227C12.1622 2.34089 11.8936 2.07227 11.5622 2.07227H2.22891Z" } }, { tag: "path", attrs: { d: "M10.2289 6.40552C9.89754 6.40552 9.62891 6.67415 9.62891 7.00552C9.62891 7.33689 9.89754 7.60552 10.2289 7.60552H12.2954V14.0055C12.2954 14.3369 12.564 14.6055 12.8954 14.6055C13.2268 14.6055 13.4954 14.3369 13.4954 14.0055V7.60552H15.5622C15.8936 7.60552 16.1622 7.33689 16.1622 7.00552C16.1622 6.67415 15.8936 6.40552 15.5622 6.40552H10.2289Z" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "text-single_clip0_1293_26" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.9)" } }] }] }], defIds: ["text-single_clip0_1293_26"] }, TextSingle = forwardRef(function(props, ref) {
128
- return createElement(IconBase, Object.assign({}, props, {
129
- id: "text-single",
130
- ref,
131
- icon: element$1
132
- }));
133
- });
134
- TextSingle.displayName = "TextSingle";
135
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, TopmostSingle = forwardRef(function(props, ref) {
136
- return createElement(IconBase, Object.assign({}, props, {
137
- id: "topmost-single",
138
- ref,
139
- icon: element
140
- }));
141
- });
142
- TopmostSingle.displayName = "TopmostSingle";
14
+ import { IEditorService, DocSelectionRenderService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, MoveSelectionOperation, MoveCursorOperation, DOCS_VIEW_KEY, TextEditor, DeleteLeftCommand } from "@univerjs/docs-ui";
15
+ import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, IImageIoService, getImageSize } from "@univerjs/drawing";
143
16
  var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
144
17
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
145
18
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -420,22 +293,9 @@ let CanvasView = (_a2 = class extends RxDisposable {
420
293
  }
421
294
  }, __name(_a2, "CanvasView"), _a2);
422
295
  CanvasView = __decorateClass$8([
423
- OnLifecycle(LifecycleStages.Ready, CanvasView),
424
296
  __decorateParam$8(0, IRenderManagerService)
425
297
  ], CanvasView);
426
- const ActivateSlidePageOperation = {
427
- id: "slide.operation.activate-slide",
428
- type: CommandType.OPERATION,
429
- handler: /* @__PURE__ */ __name((accessor, params) => {
430
- var _a11, _b;
431
- const unitId = params.unitId, canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).getUnit(unitId), pageId = (_a11 = model == null ? void 0 : model.getActivePage()) == null ? void 0 : _a11.id;
432
- if (!pageId) return !1;
433
- const page = canvasView.getRenderUnitByPageId(pageId, unitId);
434
- if (!page) return !1;
435
- const transformer = (_b = page.scene) == null ? void 0 : _b.getTransformer();
436
- return transformer && transformer.clearControls(), canvasView.activePage(params.id, unitId), !0;
437
- }, "handler")
438
- }, DeleteSlideElementOperation = {
298
+ const PLUGIN_CONFIG_KEY = "slides-ui.config", defaultPluginConfig = {}, DeleteSlideElementOperation = {
439
299
  id: "slide.operation.delete-element",
440
300
  type: CommandType.OPERATION,
441
301
  handler: /* @__PURE__ */ __name((accessor, params) => {
@@ -445,46 +305,6 @@ const ActivateSlidePageOperation = {
445
305
  const activePage = slideData.getActivePage();
446
306
  return delete activePage.pageElements[params.id], slideData.updatePage(activePage.id, activePage), accessor.get(CanvasView).removeObjectById(params.id, activePage.id, unitId), !0;
447
307
  }, "handler")
448
- }, InsertSlideFloatImageCommand = {
449
- id: "slide.command.insert-float-image",
450
- type: CommandType.COMMAND,
451
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
452
- var _a11;
453
- const univerInstanceService = accessor.get(IUniverInstanceService), unitId = (_a11 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) == null ? void 0 : _a11.getUnitId();
454
- if (!unitId) return !1;
455
- const files = await accessor.get(ILocalFileService).openFile({
456
- multiple: !0,
457
- accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image2) => `.${image2.replace("image/", "")}`).join(",")
458
- });
459
- if (files.length !== 1) return !1;
460
- const imageParam = await accessor.get(IImageIoService).saveImage(files[0]);
461
- if (!imageParam) return !1;
462
- const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), slideData = univerInstanceService.getUnit(unitId);
463
- if (!slideData) return !1;
464
- const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
465
- id: imageId,
466
- zIndex: maxIndex + 1,
467
- left: 0,
468
- top: 0,
469
- width,
470
- height,
471
- title: "",
472
- description: "",
473
- type: PageElementType.IMAGE,
474
- image: {
475
- imageProperties: {
476
- contentUrl: base64Cache,
477
- imageSourceType,
478
- source,
479
- base64Cache,
480
- image
481
- }
482
- }
483
- };
484
- activePage.pageElements[imageId] = data, slideData.updatePage(activePage.id, activePage);
485
- const canvasView = accessor.get(CanvasView), sceneObject = canvasView.createObjectToPage(data, activePage.id, unitId);
486
- return sceneObject && canvasView.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
487
- }, "handler")
488
308
  };
489
309
  var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
490
310
  /**
@@ -509,83 +329,209 @@ reactJsxRuntime_production_min.Fragment = l;
509
329
  reactJsxRuntime_production_min.jsx = q;
510
330
  reactJsxRuntime_production_min.jsxs = q;
511
331
  jsxRuntime.exports = reactJsxRuntime_production_min;
512
- var jsxRuntimeExports = jsxRuntime.exports;
513
- const UpdateSlideElementOperation = {
514
- id: "slide.operation.update-element",
515
- type: CommandType.OPERATION,
516
- handler: /* @__PURE__ */ __name((accessor, params) => {
517
- const { oKey, props } = params, univerInstanceService = accessor.get(IUniverInstanceService), unitId = params == null ? void 0 : params.unitId, slideData = univerInstanceService.getUnit(unitId);
518
- if (!slideData) return !1;
519
- const activePage = slideData.getActivePage();
520
- return activePage.pageElements[oKey] = Tools.deepMerge(activePage.pageElements[oKey], props), slideData.updatePage(activePage.id, activePage), !0;
521
- }, "handler")
522
- }, imageCommonPanel$1 = "univer-image-common-panel", imageCommonPanelGrid$1 = "univer-image-common-panel-grid", imageCommonPanelBorder$1 = "univer-image-common-panel-border", imageCommonPanelTitle$1 = "univer-image-common-panel-title", imageCommonPanelSubtitle$1 = "univer-image-common-panel-subtitle", imageCommonPanelRow$1 = "univer-image-common-panel-row", imageCommonPanelRowVertical$1 = "univer-image-common-panel-row-vertical", imageCommonPanelColumn$1 = "univer-image-common-panel-column", imageCommonPanelColumnCenter$1 = "univer-image-common-panel-column-center", imageCommonPanelInline$1 = "univer-image-common-panel-inline", imageCommonPanelSpan2$1 = "univer-image-common-panel-span2", imageCommonPanelSpan3$1 = "univer-image-common-panel-span3", imageCommonPanelInput$1 = "univer-image-common-panel-input", slidePanelColorPicker = "univer-slide-panel-color-picker", styles$4 = {
523
- imageCommonPanel: imageCommonPanel$1,
524
- imageCommonPanelGrid: imageCommonPanelGrid$1,
525
- imageCommonPanelBorder: imageCommonPanelBorder$1,
526
- imageCommonPanelTitle: imageCommonPanelTitle$1,
527
- imageCommonPanelSubtitle: imageCommonPanelSubtitle$1,
528
- imageCommonPanelRow: imageCommonPanelRow$1,
529
- imageCommonPanelRowVertical: imageCommonPanelRowVertical$1,
530
- imageCommonPanelColumn: imageCommonPanelColumn$1,
531
- imageCommonPanelColumnCenter: imageCommonPanelColumnCenter$1,
532
- imageCommonPanelInline: imageCommonPanelInline$1,
533
- imageCommonPanelSpan2: imageCommonPanelSpan2$1,
534
- imageCommonPanelSpan3: imageCommonPanelSpan3$1,
535
- imageCommonPanelInput: imageCommonPanelInput$1,
536
- slidePanelColorPicker
537
- };
538
- function ArrangePanel$1(props) {
539
- const { pageId, unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(pageId, unitId), scene = page == null ? void 0 : page.scene;
540
- if (!scene) return null;
541
- const transformer = scene.getTransformer();
542
- if (!transformer) return null;
543
- const object = transformer.getSelectedObjectMap().values().next().value;
544
- if (!object) return null;
545
- const onArrangeBtnClick = /* @__PURE__ */ __name((arrangeType) => {
546
- const allObjects = scene.getAllObjects(), [minZIndex, maxZIndex] = allObjects.reduce(([min, max], obj) => {
547
- const zIndex2 = obj.zIndex, minZIndex2 = zIndex2 < min ? zIndex2 : min, maxZIndex2 = zIndex2 > max ? zIndex2 : max;
548
- return [minZIndex2, maxZIndex2];
549
- }, [0, 0]);
550
- let zIndex = object.zIndex;
551
- arrangeType === 3 ? zIndex = minZIndex - 1 : arrangeType === 2 ? zIndex = maxZIndex + 1 : arrangeType === 0 ? zIndex = object.zIndex + 1 : arrangeType === 1 && (zIndex = object.zIndex - 1), object.setProps({
552
- zIndex
553
- }), commandService.executeCommand(UpdateSlideElementOperation.id, {
554
- unitId,
555
- oKey: object == null ? void 0 : object.oKey,
556
- props: {
557
- zIndex
558
- }
559
- });
560
- }, "onArrangeBtnClick");
561
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelGrid, children: [
562
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelTitle), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t("image-panel.arrange.title") }) }) }),
563
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelRow, children: [
564
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
565
- onArrangeBtnClick(
566
- 0
567
- /* forward */
568
- );
569
- }, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$4.imageCommonPanelInline, children: [
570
- /* @__PURE__ */ jsxRuntimeExports.jsx(MoveUpSingle, {}),
571
- localeService.t("image-panel.arrange.forward")
572
- ] }) }) }),
573
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
574
- onArrangeBtnClick(
575
- 1
576
- /* backward */
577
- );
578
- }, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$4.imageCommonPanelInline, children: [
579
- /* @__PURE__ */ jsxRuntimeExports.jsx(MoveDownSingle, {}),
580
- localeService.t("image-panel.arrange.backward")
581
- ] }) }) })
582
- ] }),
583
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelRow, children: [
584
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
585
- onArrangeBtnClick(
586
- 2
587
- /* front */
588
- );
332
+ var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
333
+ return __assign = Object.assign || function(t) {
334
+ for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
335
+ s = arguments[i];
336
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
337
+ }
338
+ return t;
339
+ }, __assign.apply(this, arguments);
340
+ }, __rest = function(s, e) {
341
+ var t = {};
342
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
343
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
344
+ for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
345
+ e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
346
+ return t;
347
+ }, IconBase = forwardRef(function(props, ref) {
348
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
349
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
350
+ });
351
+ function render(node, id, runtimeProps, rootProps, extend) {
352
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
353
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
354
+ }));
355
+ }
356
+ __name(render, "render");
357
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
358
+ var attrs = __assign({}, node.attrs);
359
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
360
+ var defIds = runtimeProps.defIds;
361
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a11) {
362
+ var key = _a11[0], value = _a11[1];
363
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
364
+ })), attrs;
365
+ }
366
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
367
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
368
+ var _a11, defIds = runtimeProps.defIds;
369
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
370
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
371
+ }) }) : node;
372
+ }
373
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
374
+ function generateShortUuid() {
375
+ return Math.random().toString(36).substring(2, 8);
376
+ }
377
+ __name(generateShortUuid, "generateShortUuid");
378
+ IconBase.displayName = "UniverIcon";
379
+ var element$9 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
380
+ return createElement(IconBase, Object.assign({}, props, {
381
+ id: "add-image-single",
382
+ ref,
383
+ icon: element$9
384
+ }));
385
+ });
386
+ AddImageSingle.displayName = "AddImageSingle";
387
+ var element$8 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Autofill = forwardRef(function(props, ref) {
388
+ return createElement(IconBase, Object.assign({}, props, {
389
+ id: "autofill",
390
+ ref,
391
+ icon: element$8
392
+ }));
393
+ });
394
+ Autofill.displayName = "Autofill";
395
+ var element$7 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, BottomSingle = forwardRef(function(props, ref) {
396
+ return createElement(IconBase, Object.assign({}, props, {
397
+ id: "bottom-single",
398
+ ref,
399
+ icon: element$7
400
+ }));
401
+ });
402
+ BottomSingle.displayName = "BottomSingle";
403
+ var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { clipPath: "url(#graph-single_clip0_1293_28)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M6.29541 11.1896C3.83208 10.7489 1.9624 8.59552 1.9624 6.00544C1.9624 3.09673 4.32036 0.73877 7.22907 0.73877C9.93483 0.73877 12.164 2.77918 12.4619 5.40527H13.5621C14.998 5.40527 16.1621 6.56933 16.1621 8.00527V12.6719C16.1621 14.1079 14.998 15.2719 13.5621 15.2719H8.89541C7.45947 15.2719 6.29541 14.1079 6.29541 12.6719V11.1896ZM3.1624 6.00544C3.1624 3.75947 4.98311 1.93877 7.22907 1.93877C9.27112 1.93877 10.9616 3.44388 11.2518 5.40527H8.89541C7.45947 5.40527 6.29541 6.56933 6.29541 8.00527V9.96442C4.49946 9.5425 3.1624 7.93012 3.1624 6.00544ZM7.49541 8.00527C7.49541 7.23207 8.12221 6.60527 8.89541 6.60527H13.5621C14.3353 6.60527 14.9621 7.23207 14.9621 8.00527V12.6719C14.9621 13.4451 14.3353 14.0719 13.5621 14.0719H8.89541C8.12221 14.0719 7.49541 13.4451 7.49541 12.6719V8.00527Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "graph-single_clip0_1293_28" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.9)" } }] }] }], defIds: ["graph-single_clip0_1293_28"] }, GraphSingle = forwardRef(function(props, ref) {
404
+ return createElement(IconBase, Object.assign({}, props, {
405
+ id: "graph-single",
406
+ ref,
407
+ icon: element$6
408
+ }));
409
+ });
410
+ GraphSingle.displayName = "GraphSingle";
411
+ var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreDownSingle = forwardRef(function(props, ref) {
412
+ return createElement(IconBase, Object.assign({}, props, {
413
+ id: "more-down-single",
414
+ ref,
415
+ icon: element$5
416
+ }));
417
+ });
418
+ MoreDownSingle.displayName = "MoreDownSingle";
419
+ var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, MoveDownSingle = forwardRef(function(props, ref) {
420
+ return createElement(IconBase, Object.assign({}, props, {
421
+ id: "move-down-single",
422
+ ref,
423
+ icon: element$4
424
+ }));
425
+ });
426
+ MoveDownSingle.displayName = "MoveDownSingle";
427
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, MoveUpSingle = forwardRef(function(props, ref) {
428
+ return createElement(IconBase, Object.assign({}, props, {
429
+ id: "move-up-single",
430
+ ref,
431
+ icon: element$3
432
+ }));
433
+ });
434
+ MoveUpSingle.displayName = "MoveUpSingle";
435
+ var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_102_1204", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#DCDCDC", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_102_1204)" }, children: [{ tag: "rect", attrs: { width: 12.62, height: 2.79, x: 1.69, y: 12.25, fill: "colorChannel1", rx: 1.4 } }, { tag: "path", attrs: { fill: "currentColor", d: "M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z" } }] }] }, PaintBucket = forwardRef(function(props, ref) {
436
+ return createElement(IconBase, Object.assign({}, props, {
437
+ id: "paint-bucket",
438
+ ref,
439
+ icon: element$2
440
+ }));
441
+ });
442
+ PaintBucket.displayName = "PaintBucket";
443
+ var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "g", attrs: { fill: "currentColor", clipPath: "url(#text-single_clip0_1293_26)" }, children: [{ tag: "path", attrs: { d: "M2.22891 2.07227C1.89754 2.07227 1.62891 2.34089 1.62891 2.67227C1.62891 3.00364 1.89754 3.27227 2.22891 3.27227H6.29541V14.0056C6.29541 14.337 6.56404 14.6056 6.89541 14.6056C7.22678 14.6056 7.49541 14.337 7.49541 14.0056V3.27227H11.5622C11.8936 3.27227 12.1622 3.00364 12.1622 2.67227C12.1622 2.34089 11.8936 2.07227 11.5622 2.07227H2.22891Z" } }, { tag: "path", attrs: { d: "M10.2289 6.40552C9.89754 6.40552 9.62891 6.67415 9.62891 7.00552C9.62891 7.33689 9.89754 7.60552 10.2289 7.60552H12.2954V14.0055C12.2954 14.3369 12.564 14.6055 12.8954 14.6055C13.2268 14.6055 13.4954 14.3369 13.4954 14.0055V7.60552H15.5622C15.8936 7.60552 16.1622 7.33689 16.1622 7.00552C16.1622 6.67415 15.8936 6.40552 15.5622 6.40552H10.2289Z" } }] }, { tag: "defs", attrs: {}, children: [{ tag: "clipPath", attrs: { id: "text-single_clip0_1293_26" }, children: [{ tag: "path", attrs: { fill: "#fff", d: "M0 0H16V16H0z", transform: "translate(.9)" } }] }] }], defIds: ["text-single_clip0_1293_26"] }, TextSingle = forwardRef(function(props, ref) {
444
+ return createElement(IconBase, Object.assign({}, props, {
445
+ id: "text-single",
446
+ ref,
447
+ icon: element$1
448
+ }));
449
+ });
450
+ TextSingle.displayName = "TextSingle";
451
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, TopmostSingle = forwardRef(function(props, ref) {
452
+ return createElement(IconBase, Object.assign({}, props, {
453
+ id: "topmost-single",
454
+ ref,
455
+ icon: element
456
+ }));
457
+ });
458
+ TopmostSingle.displayName = "TopmostSingle";
459
+ const UpdateSlideElementOperation = {
460
+ id: "slide.operation.update-element",
461
+ type: CommandType.OPERATION,
462
+ handler: /* @__PURE__ */ __name((accessor, params) => {
463
+ const { oKey, props } = params, univerInstanceService = accessor.get(IUniverInstanceService), unitId = params == null ? void 0 : params.unitId, slideData = univerInstanceService.getUnit(unitId);
464
+ if (!slideData) return !1;
465
+ const activePage = slideData.getActivePage();
466
+ return activePage.pageElements[oKey] = Tools.deepMerge(activePage.pageElements[oKey], props), slideData.updatePage(activePage.id, activePage), !0;
467
+ }, "handler")
468
+ }, imageCommonPanel$1 = "univer-image-common-panel", imageCommonPanelGrid$1 = "univer-image-common-panel-grid", imageCommonPanelBorder$1 = "univer-image-common-panel-border", imageCommonPanelTitle$1 = "univer-image-common-panel-title", imageCommonPanelSubtitle$1 = "univer-image-common-panel-subtitle", imageCommonPanelRow$1 = "univer-image-common-panel-row", imageCommonPanelRowVertical$1 = "univer-image-common-panel-row-vertical", imageCommonPanelColumn$1 = "univer-image-common-panel-column", imageCommonPanelColumnCenter$1 = "univer-image-common-panel-column-center", imageCommonPanelInline$1 = "univer-image-common-panel-inline", imageCommonPanelSpan2$1 = "univer-image-common-panel-span2", imageCommonPanelSpan3$1 = "univer-image-common-panel-span3", imageCommonPanelInput$1 = "univer-image-common-panel-input", slidePanelColorPicker = "univer-slide-panel-color-picker", styles$4 = {
469
+ imageCommonPanel: imageCommonPanel$1,
470
+ imageCommonPanelGrid: imageCommonPanelGrid$1,
471
+ imageCommonPanelBorder: imageCommonPanelBorder$1,
472
+ imageCommonPanelTitle: imageCommonPanelTitle$1,
473
+ imageCommonPanelSubtitle: imageCommonPanelSubtitle$1,
474
+ imageCommonPanelRow: imageCommonPanelRow$1,
475
+ imageCommonPanelRowVertical: imageCommonPanelRowVertical$1,
476
+ imageCommonPanelColumn: imageCommonPanelColumn$1,
477
+ imageCommonPanelColumnCenter: imageCommonPanelColumnCenter$1,
478
+ imageCommonPanelInline: imageCommonPanelInline$1,
479
+ imageCommonPanelSpan2: imageCommonPanelSpan2$1,
480
+ imageCommonPanelSpan3: imageCommonPanelSpan3$1,
481
+ imageCommonPanelInput: imageCommonPanelInput$1,
482
+ slidePanelColorPicker
483
+ };
484
+ function ArrangePanel$1(props) {
485
+ const { pageId, unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(pageId, unitId), scene = page == null ? void 0 : page.scene;
486
+ if (!scene) return null;
487
+ const transformer = scene.getTransformer();
488
+ if (!transformer) return null;
489
+ const object = transformer.getSelectedObjectMap().values().next().value;
490
+ if (!object) return null;
491
+ const onArrangeBtnClick = /* @__PURE__ */ __name((arrangeType) => {
492
+ const allObjects = scene.getAllObjects(), [minZIndex, maxZIndex] = allObjects.reduce(([min, max], obj) => {
493
+ const zIndex2 = obj.zIndex, minZIndex2 = zIndex2 < min ? zIndex2 : min, maxZIndex2 = zIndex2 > max ? zIndex2 : max;
494
+ return [minZIndex2, maxZIndex2];
495
+ }, [0, 0]);
496
+ let zIndex = object.zIndex;
497
+ arrangeType === 3 ? zIndex = minZIndex - 1 : arrangeType === 2 ? zIndex = maxZIndex + 1 : arrangeType === 0 ? zIndex = object.zIndex + 1 : arrangeType === 1 && (zIndex = object.zIndex - 1), object.setProps({
498
+ zIndex
499
+ }), commandService.executeCommand(UpdateSlideElementOperation.id, {
500
+ unitId,
501
+ oKey: object == null ? void 0 : object.oKey,
502
+ props: {
503
+ zIndex
504
+ }
505
+ });
506
+ }, "onArrangeBtnClick");
507
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelGrid, children: [
508
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelTitle), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t("image-panel.arrange.title") }) }) }),
509
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelRow, children: [
510
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
511
+ onArrangeBtnClick(
512
+ 0
513
+ /* forward */
514
+ );
515
+ }, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$4.imageCommonPanelInline, children: [
516
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MoveUpSingle, {}),
517
+ localeService.t("image-panel.arrange.forward")
518
+ ] }) }) }),
519
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
520
+ onArrangeBtnClick(
521
+ 1
522
+ /* backward */
523
+ );
524
+ }, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$4.imageCommonPanelInline, children: [
525
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MoveDownSingle, {}),
526
+ localeService.t("image-panel.arrange.backward")
527
+ ] }) }) })
528
+ ] }),
529
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.imageCommonPanelRow, children: [
530
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$4.imageCommonPanelColumn, styles$4.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
531
+ onArrangeBtnClick(
532
+ 2
533
+ /* front */
534
+ );
589
535
  }, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$4.imageCommonPanelInline, children: [
590
536
  /* @__PURE__ */ jsxRuntimeExports.jsx(TopmostSingle, {}),
591
537
  localeService.t("image-panel.arrange.front")
@@ -912,1020 +858,465 @@ const InsertSlideShapeRectangleCommand = {
912
858
  width: 360
913
859
  }) : sidebarService.close(), !0;
914
860
  }, "handler")
915
- }, SlideAddTextCommand = {
916
- id: "slide.command.add-text",
917
- type: CommandType.COMMAND,
918
- handler: /* @__PURE__ */ __name(async (accessor) => {
919
- var _a11;
920
- const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
921
- return await commandService.executeCommand(SlideAddTextOperation.id, { unitId });
922
- }, "handler")
923
- }, SlideAddTextOperation = {
924
- id: "slide.operation.add-text",
925
- type: CommandType.OPERATION,
926
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
927
- const unitId = params.unitId, elementId = generateRandomId(6), defaultWidth = 220, defaultheight = 40, left = 230, top = 142, textContent = (params == null ? void 0 : params.text) || "A New Text", slideData = accessor.get(IUniverInstanceService).getUnit(unitId);
928
- if (!slideData) return !1;
929
- const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 21, elementData = {
930
- id: elementId,
931
- zIndex: maxIndex + 1,
932
- left,
933
- top,
934
- width: defaultWidth,
935
- height: defaultheight,
936
- title: "text",
937
- description: "",
938
- type: PageElementType.TEXT,
939
- richText: {
940
- text: textContent,
941
- fs: 30,
942
- cl: {
943
- rgb: "rgb(51, 51, 51)"
944
- },
945
- bl: 1
946
- }
861
+ }, COMPONENT_SLIDE_IMAGE_POPUP_MENU = "COMPONENT_SLIDE_IMAGE_POPUP_MENU";
862
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
863
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
864
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
865
+ return kind && result && __defProp$7(target, key, result), result;
866
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7");
867
+ function transformBound2OffsetBound(originBound, scene) {
868
+ const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
869
+ return {
870
+ left: topLeft.x,
871
+ top: topLeft.y,
872
+ right: bottomRight.x,
873
+ bottom: bottomRight.y
874
+ };
875
+ }
876
+ __name(transformBound2OffsetBound, "transformBound2OffsetBound");
877
+ function transformPosition2Offset(x, y, scene) {
878
+ const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SLIDE_KEY.VIEW);
879
+ if (!viewMain)
880
+ return {
881
+ x,
882
+ y
947
883
  };
948
- activePage.pageElements[elementId] = elementData, slideData.updatePage(activePage.id, activePage);
949
- const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(elementData, activePage.id, unitId);
950
- return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
951
- }, "handler")
952
- }, SetSlidePageThumbOperation = {
953
- id: "slide.operation.set-slide-page-thumb",
954
- type: CommandType.OPERATION,
955
- handler: /* @__PURE__ */ __name((accessor, params) => (accessor.get(CanvasView).createThumbs(params.unitId), !0), "handler")
956
- }, SetTextEditArrowOperation = {
957
- id: "slide.operation.edit-arrow",
958
- type: CommandType.OPERATION,
959
- handler: /* @__PURE__ */ __name(() => !0, "handler")
960
- }, imagePopupMenu = "univer-image-popup-menu", imagePopupMenuItem = "univer-image-popup-menu-item", imagePopupMenuItemIcon = "univer-image-popup-menu-item-icon", imagePopupMenuItemTitle = "univer-image-popup-menu-item-title", imagePopupMenuItemHide = "univer-image-popup-menu-item-hide", btnContainer = "univer-btn-container", btnContainerExpand = "univer-btn-container-expand", styles$2 = {
961
- imagePopupMenu,
962
- imagePopupMenuItem,
963
- imagePopupMenuItemIcon,
964
- imagePopupMenuItemTitle,
965
- imagePopupMenuItemHide,
966
- btnContainer,
967
- btnContainerExpand
968
- }, SlideImagePopupMenu = /* @__PURE__ */ __name((props) => {
969
- var _a11, _b;
970
- const menuItems = (_b = (_a11 = props.popup) == null ? void 0 : _a11.extraProps) == null ? void 0 : _b.menuItems;
971
- if (!menuItems)
972
- return null;
973
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
974
- setHovered(!0);
975
- }, "handleMouseEnter"), handleMouseLeave = /* @__PURE__ */ __name(() => {
976
- setHovered(!1);
977
- }, "handleMouseLeave"), onVisibleChange = /* @__PURE__ */ __name((visible2) => {
978
- setVisible(visible2);
979
- }, "onVisibleChange"), handleClick = /* @__PURE__ */ __name((item) => {
980
- commandService.executeCommand(item.commandId, item.commandParams), setVisible(!1);
981
- }, "handleClick"), showMore = visible || isHovered, availableMenu = menuItems.filter((item) => !item.disable);
982
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
983
- "div",
984
- {
985
- onMouseEnter: handleMouseEnter,
986
- onMouseLeave: handleMouseLeave,
987
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
988
- Dropdown,
989
- {
990
- placement: "bottomLeft",
991
- trigger: ["click"],
992
- overlay: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: styles$2.imagePopupMenu, children: availableMenu.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
993
- "li",
994
- {
995
- onClick: /* @__PURE__ */ __name(() => handleClick(item), "onClick"),
996
- className: styles$2.imagePopupMenuItem,
997
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles$2.imagePopupMenuItemTitle, children: localeService.t(item.label) })
998
- },
999
- item.index
1000
- )) }),
1001
- visible,
1002
- onVisibleChange,
1003
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1004
- "div",
1005
- {
1006
- className: clsx(styles$2.btnContainer, {
1007
- [styles$2.btnContainerExpand]: visible
1008
- }),
1009
- children: [
1010
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1011
- Autofill,
1012
- {
1013
- style: { color: "#35322B" },
1014
- extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
1015
- }
1016
- ),
1017
- showMore && /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
1018
- ]
1019
- }
1020
- )
1021
- }
1022
- )
1023
- }
1024
- );
1025
- }, "SlideImagePopupMenu"), COMPONENT_SLIDE_IMAGE_POPUP_MENU = "COMPONENT_SLIDE_IMAGE_POPUP_MENU", SLIDE_EDITOR_ID = createInternalEditorID("SLIDE_EDITOR"), _SlideEditorManagerService = class _SlideEditorManagerService {
1026
- constructor() {
1027
- __publicField(this, "_state", null);
1028
- __publicField(this, "_rect", null);
1029
- __publicField(this, "_state$", new BehaviorSubject(null));
1030
- __publicField(this, "state$", this._state$.asObservable());
1031
- __publicField(this, "_rect$", new BehaviorSubject(null));
1032
- __publicField(this, "rect$", this._rect$.asObservable());
1033
- __publicField(this, "_focus", !1);
1034
- __publicField(this, "_focus$", new BehaviorSubject(this._focus));
1035
- __publicField(this, "focus$", this._focus$.asObservable());
884
+ const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain, offsetX = (x - actualScrollX) * scaleX, offsetY = (y - actualScrollY) * scaleY;
885
+ return {
886
+ x: offsetX,
887
+ y: offsetY
888
+ };
889
+ }
890
+ __name(transformPosition2Offset, "transformPosition2Offset");
891
+ var _a3;
892
+ let SlideCanvasPopMangerService = (_a3 = class extends Disposable {
893
+ constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
894
+ super(), this._globalPopupManagerService = _globalPopupManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService;
1036
895
  }
1037
- dispose() {
1038
- this._state$.complete(), this._state = null, this._rect$.complete(), this._rect = null;
896
+ _createObjectPositionObserver(targetObject, currentRender) {
897
+ const position = (/* @__PURE__ */ __name(() => {
898
+ var _a11, _b, _c, _d;
899
+ const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (_a11 = currentRender.mainComponent) == null ? void 0 : _a11.width) != null ? _b : 0)) / 2, verticalOffset = (scene.height - ((_d = (_c = currentRender.mainComponent) == null ? void 0 : _c.height) != null ? _d : 0)) / 2, bound = {
900
+ left,
901
+ right: left + width,
902
+ top,
903
+ bottom: top + height
904
+ }, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { scaleX, scaleY } = scene.getAncestorScale(), offsetBound = transformBound2OffsetBound(bound, scene), { top: topOffset, left: leftOffset, width: domWidth } = canvasClientRect, scaleAdjust = domWidth / widthOfCanvas;
905
+ return {
906
+ left: offsetBound.left * scaleAdjust * scaleX + leftOffset + horizontalOffset,
907
+ right: offsetBound.right * scaleAdjust * scaleX + leftOffset + horizontalOffset,
908
+ top: offsetBound.top * scaleAdjust * scaleY + topOffset + verticalOffset,
909
+ bottom: offsetBound.bottom * scaleAdjust * scaleY + topOffset + verticalOffset
910
+ };
911
+ }, "calc"))(), position$ = new BehaviorSubject(position), disposable = new DisposableCollection();
912
+ return {
913
+ position,
914
+ position$,
915
+ disposable
916
+ };
1039
917
  }
1040
- setState(param) {
1041
- this._state = param, this._refresh(param);
918
+ attachPopupToObject(targetObject, popup) {
919
+ const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE).getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
920
+ if (!currentRender)
921
+ return {
922
+ dispose: /* @__PURE__ */ __name(() => {
923
+ }, "dispose")
924
+ };
925
+ const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender), id = this._globalPopupManagerService.addPopup({
926
+ ...popup,
927
+ unitId,
928
+ subUnitId: "default",
929
+ anchorRect: position,
930
+ anchorRect$: position$,
931
+ canvasElement: currentRender.engine.getCanvasElement()
932
+ });
933
+ return {
934
+ dispose: /* @__PURE__ */ __name(() => {
935
+ this._globalPopupManagerService.removePopup(id), position$.complete(), disposable.dispose();
936
+ }, "dispose")
937
+ };
1042
938
  }
1043
- getRect() {
1044
- return this._rect;
939
+ }, __name(_a3, "SlideCanvasPopMangerService"), _a3);
940
+ SlideCanvasPopMangerService = __decorateClass$7([
941
+ __decorateParam$7(0, Inject(ICanvasPopupService)),
942
+ __decorateParam$7(1, IRenderManagerService),
943
+ __decorateParam$7(2, IUniverInstanceService),
944
+ __decorateParam$7(3, ICommandService)
945
+ ], SlideCanvasPopMangerService);
946
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
947
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
948
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
949
+ return kind && result && __defProp$6(target, key, result), result;
950
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a4;
951
+ let SlidePopupMenuController = (_a4 = class extends RxDisposable {
952
+ constructor(_canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _canvasView, _sidebarService, _commandService) {
953
+ super();
954
+ __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
955
+ this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._canvasView = _canvasView, this._sidebarService = _sidebarService, this._commandService = _commandService, this._init();
1045
956
  }
1046
- setRect(param) {
1047
- this._rect = param, this._rect$.next(param);
957
+ _init() {
958
+ this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => this._create(slide));
1048
959
  }
1049
- getState() {
1050
- return this._state;
960
+ _create(slide) {
961
+ if (!slide)
962
+ return;
963
+ const unitId = slide.getUnitId();
964
+ this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
1051
965
  }
1052
- setFocus(param = !1) {
1053
- this._focus = param, this._focus$.next(param);
966
+ _hasCropObject(scene) {
1054
967
  }
1055
- _refresh(param) {
1056
- this._state$.next(param);
968
+ // eslint-disable-next-line max-lines-per-function
969
+ _popupMenuListener(unitId) {
970
+ var _a11;
971
+ const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a11 = model == null ? void 0 : model.getPages()) != null ? _a11 : {};
972
+ Object.keys(pages).forEach((pageId) => {
973
+ var _a12;
974
+ const transformer = (_a12 = this._canvasView.getRenderUnitByPageId(pageId, unitId).scene) == null ? void 0 : _a12.getTransformer();
975
+ if (!transformer) return;
976
+ let singletonPopupDisposer;
977
+ this.disposeWithMe(
978
+ toDisposable(
979
+ transformer.createControl$.subscribe(() => {
980
+ const selectedObjects = transformer.getSelectedObjectMap();
981
+ if (selectedObjects.size > 1) {
982
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
983
+ return;
984
+ }
985
+ const object = selectedObjects.values().next().value;
986
+ if (!object)
987
+ return;
988
+ const oKey = object.oKey;
989
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
990
+ componentKey: COMPONENT_SLIDE_IMAGE_POPUP_MENU,
991
+ direction: "horizontal",
992
+ offset: [2, 0],
993
+ extraProps: {
994
+ menuItems: this._getMenuItemsByObjectType(object.objectType, oKey, unitId)
995
+ }
996
+ })), this._sidebarService.visible && this._commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
997
+ visible: !0,
998
+ objectType: object.objectType
999
+ });
1000
+ })
1001
+ )
1002
+ ), this.disposeWithMe(
1003
+ transformer.clearControl$.subscribe(() => {
1004
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1);
1005
+ })
1006
+ ), this.disposeWithMe(
1007
+ transformer.changing$.subscribe(() => {
1008
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1009
+ const selectedObjects = transformer.getSelectedObjectMap();
1010
+ if (selectedObjects.size > 1) {
1011
+ singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1012
+ return;
1013
+ }
1014
+ const object = selectedObjects.values().next().value;
1015
+ object && this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1016
+ unitId,
1017
+ oKey: object.oKey,
1018
+ props: {
1019
+ width: object.width,
1020
+ height: object.height,
1021
+ left: object.left,
1022
+ top: object.top
1023
+ }
1024
+ });
1025
+ })
1026
+ );
1027
+ });
1057
1028
  }
1058
- };
1059
- __name(_SlideEditorManagerService, "SlideEditorManagerService");
1060
- let SlideEditorManagerService = _SlideEditorManagerService;
1061
- const ISlideEditorManagerService = createIdentifier(
1062
- "univer.slide-editor-manager.service"
1063
- ), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
1064
- slideEditorContainer,
1065
- editorInput
1066
- }, HIDDEN_EDITOR_POSITION$1 = -1e3, EDITOR_DEFAULT_POSITION = {
1067
- width: 0,
1068
- height: 0,
1069
- top: HIDDEN_EDITOR_POSITION$1,
1070
- left: HIDDEN_EDITOR_POSITION$1
1071
- }, SlideEditorContainer = /* @__PURE__ */ __name(() => {
1072
- const [state, setState] = useState({
1073
- ...EDITOR_DEFAULT_POSITION
1074
- }), slideEditorManagerService = useDependency(ISlideEditorManagerService), editorService = useDependency(IEditorService), contextService = useDependency(IContextService), disableAutoFocus = useObservable(
1075
- () => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY),
1076
- !1,
1077
- void 0,
1078
- [contextService, DISABLE_AUTO_FOCUS_KEY]
1079
- ), snapshot = {
1080
- id: SLIDE_EDITOR_ID,
1081
- body: {
1082
- dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
1083
- textRuns: [],
1084
- paragraphs: [
1085
- {
1086
- startIndex: 0
1087
- }
1088
- ]
1089
- },
1090
- documentStyle: {
1091
- documentFlavor: DocumentFlavor.MODERN
1092
- }
1093
- };
1094
- return useEffect(() => {
1095
- slideEditorManagerService.state$.subscribe((param) => {
1096
- if (param == null)
1097
- return;
1098
- const {
1099
- startX = HIDDEN_EDITOR_POSITION$1,
1100
- startY = HIDDEN_EDITOR_POSITION$1,
1101
- endX = 0,
1102
- endY = 0,
1103
- show = !1
1104
- } = param;
1105
- if (!show)
1106
- setState({
1107
- ...EDITOR_DEFAULT_POSITION
1108
- });
1109
- else {
1110
- setState({
1111
- width: endX - startX - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
1112
- height: endY - startY - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
1113
- left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
1114
- top: startY + FIX_ONE_PIXEL_BLUR_OFFSET
1115
- });
1116
- const editor = editorService.getEditor(SLIDE_EDITOR_ID);
1117
- if (editor == null)
1118
- return;
1119
- const { left, top, width, height } = editor.getBoundingClientRect();
1120
- slideEditorManagerService.setRect({ left, top, width, height });
1121
- }
1122
- });
1123
- }, []), useEffect(() => {
1124
- disableAutoFocus || slideEditorManagerService.setFocus(!0);
1125
- }, [disableAutoFocus, state]), /* @__PURE__ */ jsxRuntimeExports.jsx(
1126
- "div",
1127
- {
1128
- className: styles$1.slideEditorContainer,
1129
- style: {
1130
- left: state.left,
1131
- top: state.top,
1132
- width: state.width,
1133
- height: state.height
1029
+ _getMenuItemsByObjectType(objectType, oKey, unitId) {
1030
+ return [{
1031
+ label: "slide.popup.edit",
1032
+ index: 0,
1033
+ commandId: ToggleSlideEditSidebarOperation.id,
1034
+ commandParams: {
1035
+ visible: !0,
1036
+ objectType
1134
1037
  },
1135
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1136
- TextEditor,
1137
- {
1138
- id: SLIDE_EDITOR_ID,
1139
- className: styles$1.editorInput,
1140
- snapshot,
1141
- cancelDefaultResizeListener: !1,
1142
- isSheetEditor: !1,
1143
- isSingle: !1
1144
- }
1145
- )
1146
- }
1147
- );
1148
- }, "SlideEditorContainer"), AppendSlideOperation = {
1149
- id: "slide.operation.append-slide",
1038
+ disable: !1
1039
+ }, {
1040
+ label: "slide.popup.delete",
1041
+ index: 5,
1042
+ commandId: DeleteSlideElementOperation.id,
1043
+ commandParams: {
1044
+ id: oKey,
1045
+ unitId
1046
+ },
1047
+ disable: !1
1048
+ }];
1049
+ }
1050
+ }, __name(_a4, "SlidePopupMenuController"), _a4);
1051
+ SlidePopupMenuController = __decorateClass$6([
1052
+ __decorateParam$6(0, Inject(SlideCanvasPopMangerService)),
1053
+ __decorateParam$6(1, IRenderManagerService),
1054
+ __decorateParam$6(2, IUniverInstanceService),
1055
+ __decorateParam$6(3, IContextService),
1056
+ __decorateParam$6(4, Inject(CanvasView)),
1057
+ __decorateParam$6(5, ISidebarService),
1058
+ __decorateParam$6(6, ICommandService)
1059
+ ], SlidePopupMenuController);
1060
+ const SetTextEditArrowOperation = {
1061
+ id: "slide.operation.edit-arrow",
1150
1062
  type: CommandType.OPERATION,
1151
- handler: /* @__PURE__ */ __name((accessor, params) => {
1152
- const unitId = params.unitId;
1153
- return accessor.get(IUniverInstanceService).getUnit(unitId) ? (accessor.get(CanvasView).appendPage(unitId), !0) : !1;
1154
- }, "handler")
1155
- }, slideBar = "univer-slide-bar", slideBarContent = "univer-slide-bar-content", slideBarContentHeader = "univer-slide-bar-content-header", slideBarItem = "univer-slide-bar-item", slideBarBox = "univer-slide-bar-box", slideBarItemActive = "univer-slide-bar-item-active", slideAddButton = "univer-slide-add-button", styles = {
1156
- slideBar,
1157
- slideBarContent,
1158
- slideBarContentHeader,
1159
- slideBarItem,
1160
- slideBarBox,
1161
- slideBarItemActive,
1162
- slideAddButton
1163
- };
1164
- function SlideSideBar() {
1165
- var _a11, _b;
1166
- const univerInstanceService = useDependency(IUniverInstanceService), commandService = useDependency(ICommandService), renderManagerService = useDependency(IRenderManagerService), localeService = useDependency(LocaleService), slideBarRef = useRef(null), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = currentSlide == null ? void 0 : currentSlide.getPages(), pageOrder = currentSlide == null ? void 0 : currentSlide.getPageOrder();
1167
- if (!pages || !pageOrder)
1168
- return null;
1169
- const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (_a11 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a11.id) != null ? _b : null);
1170
- useEffect(() => {
1171
- setDivRefs(slideList.map((_) => React.createRef()));
1172
- }, [slideList.length]), useEffect(() => {
1173
- const subscriber = currentSlide == null ? void 0 : currentSlide.activePage$.subscribe((page) => {
1174
- var _a12;
1175
- const id = (_a12 = page == null ? void 0 : page.id) != null ? _a12 : null;
1176
- id && setActivatePageId(id);
1063
+ handler: /* @__PURE__ */ __name(() => !0, "handler")
1064
+ }, SLIDE_EDITOR_ID = createInternalEditorID("SLIDE_EDITOR");
1065
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1066
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1067
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1068
+ return kind && result && __defProp$5(target, key, result), result;
1069
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
1070
+ const ISlideEditorBridgeService = createIdentifier("univer.slide-editor-bridge.service");
1071
+ var _a5;
1072
+ let SlideEditorBridgeService = (_a5 = class extends Disposable {
1073
+ constructor(_editorService, _contextService, _renderManagerService) {
1074
+ super();
1075
+ __publicField(this, "_editorUnitId", SLIDE_EDITOR_ID);
1076
+ __publicField(this, "_isForceKeepVisible", !1);
1077
+ __publicField(this, "_editorIsDirty", !1);
1078
+ __publicField(this, "_currentEditRectState", null);
1079
+ __publicField(this, "_currentEditRectState$", new BehaviorSubject(null));
1080
+ __publicField(this, "currentEditRectState$", this._currentEditRectState$.asObservable());
1081
+ __publicField(this, "_visibleParam", {
1082
+ visible: !1,
1083
+ eventType: DeviceInputEventType.Dblclick,
1084
+ unitId: ""
1177
1085
  });
1178
- return () => {
1179
- subscriber == null || subscriber.unsubscribe();
1086
+ __publicField(this, "_visible$", new BehaviorSubject(this._visibleParam));
1087
+ __publicField(this, "visible$", this._visible$.asObservable());
1088
+ __publicField(this, "_afterVisible$", new BehaviorSubject(this._visibleParam));
1089
+ __publicField(this, "afterVisible$", this._afterVisible$.asObservable());
1090
+ __publicField(this, "endEditing$", new Subject());
1091
+ __publicField(this, "_currentEditRectInfo");
1092
+ this._editorService = _editorService, this._contextService = _contextService, this._renderManagerService = _renderManagerService;
1093
+ }
1094
+ dispose() {
1095
+ super.dispose();
1096
+ }
1097
+ getEditorRect() {
1098
+ return this._currentEditRectInfo;
1099
+ }
1100
+ /**
1101
+ * 1st part of startEditing.
1102
+ * @editorInfo editorInfo
1103
+ */
1104
+ setEditorRect(editorInfo) {
1105
+ this._currentEditRectInfo = editorInfo, this._editorService.getFocusEditor() || (this._editorService.focus(SLIDE_EDITOR_ID), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !1), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, !1));
1106
+ const editRectState = this.getEditRectState();
1107
+ this._currentEditRectState = editRectState, this._currentEditRectState$.next(editRectState);
1108
+ }
1109
+ changeVisible(param) {
1110
+ this._visibleParam = param, param.visible && (this._editorIsDirty = !1), this._visible$.next(this._visibleParam), this._afterVisible$.next(this._visibleParam);
1111
+ }
1112
+ /**
1113
+ * get info from _currentEditRectInfo
1114
+ *
1115
+ * invoked by slide-editing.render-controller.ts@_handleEditorVisible
1116
+ * && this@setEditorRect
1117
+ */
1118
+ getEditRectState() {
1119
+ const editorUnitId = SLIDE_EDITOR_ID, editorRectInfo = this._currentEditRectInfo, unitId = editorRectInfo.unitId, docData = editorRectInfo.richTextObj.documentData;
1120
+ docData.id = editorUnitId, docData.documentStyle = {
1121
+ ...docData.documentStyle,
1122
+ pageSize: { width: editorRectInfo.richTextObj.width, height: 1 / 0 }
1180
1123
  };
1181
- }, []), useEffect(() => {
1182
- divRefs.forEach((ref, index) => {
1183
- var _a12;
1184
- if (ref.current) {
1185
- const slide = slideList[index];
1186
- (_a12 = renderManagerService.getRenderById(slide.id)) == null || _a12.engine.setContainer(ref.current);
1187
- }
1188
- }), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1189
- }, [divRefs, slideList, renderManagerService, commandService, currentSlide]);
1190
- const activatePage = useCallback((page) => {
1191
- commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page, unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1192
- }, [commandService, currentSlide]), handleAppendSlide = useCallback(() => {
1193
- commandService.syncExecuteCommand(AppendSlideOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1194
- }, [commandService, currentSlide]);
1195
- return /* @__PURE__ */ jsxRuntimeExports.jsx("aside", { className: styles.slideBar, ref: slideBarRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.slideBarContent, children: [
1196
- /* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: styles.slideBarContentHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: handleAppendSlide, children: localeService.t("slide.append") }) }),
1197
- slideList.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1198
- "div",
1199
- {
1200
- className: clsx(styles.slideBarItem, {
1201
- [styles.slideBarItemActive]: item.id === activatePageId
1202
- }),
1203
- onClick: /* @__PURE__ */ __name(() => activatePage(item.id), "onClick"),
1204
- children: [
1205
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: index + 1 }),
1206
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: divRefs[index], className: styles.slideBarBox })
1207
- ]
1124
+ const documentLayoutObject = {
1125
+ documentModel: new DocumentDataModel(docData),
1126
+ fontString: "document",
1127
+ textRotation: { a: 0, v: 0 },
1128
+ wrapStrategy: 0,
1129
+ verticalAlign: VerticalAlign.TOP,
1130
+ horizontalAlign: HorizontalAlign.LEFT,
1131
+ paddingData: { t: 0, b: 1, l: 2, r: 2 }
1132
+ }, editorWidth = editorRectInfo.richTextObj.width, editorHeight = editorRectInfo.richTextObj.height, left = editorRectInfo.richTextObj.left, top = editorRectInfo.richTextObj.top, canvasOffset = {
1133
+ left: 0,
1134
+ top: 0
1135
+ }, renderUnit = this._renderManagerService.getRenderById(unitId), mainScene = renderUnit == null ? void 0 : renderUnit.scene, mainViewport = mainScene == null ? void 0 : mainScene.getViewport(SLIDE_KEY.VIEW), slideMainRect = mainScene == null ? void 0 : mainScene.getObject(SLIDE_KEY.COMPONENT), slidePos = {
1136
+ x: (slideMainRect == null ? void 0 : slideMainRect.left) || 0,
1137
+ y: (slideMainRect == null ? void 0 : slideMainRect.top) || 0
1138
+ }, scrollX = (mainViewport == null ? void 0 : mainViewport.viewportScrollX) || 0, scrollY = (mainViewport == null ? void 0 : mainViewport.viewportScrollY) || 0;
1139
+ return canvasOffset.left = slidePos.x - scrollX, canvasOffset.top = slidePos.y - scrollY, {
1140
+ position: {
1141
+ startX: left,
1142
+ startY: top,
1143
+ endX: left + editorWidth,
1144
+ endY: top + editorHeight
1208
1145
  },
1209
- item.id
1210
- ))
1211
- ] }) }) });
1212
- }
1213
- __name(SlideSideBar, "SlideSideBar");
1214
- const IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "slide.menu.image";
1215
- function SlideImageMenuFactory(accessor) {
1216
- return {
1217
- id: IMAGE_MENU_ID,
1218
- type: MenuItemType.SUBITEMS,
1219
- icon: IMAGE_UPLOAD_ICON,
1220
- tooltip: "slide.image.insert.title",
1221
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
1222
- };
1223
- }
1224
- __name(SlideImageMenuFactory, "SlideImageMenuFactory");
1225
- function UploadSlideFloatImageMenuFactory(_accessor) {
1226
- return {
1227
- id: InsertSlideFloatImageCommand.id,
1228
- title: "slide.image.insert.float",
1229
- type: MenuItemType.BUTTON,
1230
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
1231
- };
1232
- }
1233
- __name(UploadSlideFloatImageMenuFactory, "UploadSlideFloatImageMenuFactory");
1234
- const GRAPH_SINGLE_ICON = "graph-single", SHAPE_MENU_ID = "slide.menu.shape";
1235
- function SlideShapeMenuFactory(accessor) {
1236
- return {
1237
- id: SHAPE_MENU_ID,
1238
- type: MenuItemType.SUBITEMS,
1239
- icon: GRAPH_SINGLE_ICON,
1240
- tooltip: "slide.shape.insert.title",
1241
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
1242
- // disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
1243
- };
1244
- }
1245
- __name(SlideShapeMenuFactory, "SlideShapeMenuFactory");
1246
- function UploadSlideFloatShapeMenuFactory(_accessor) {
1247
- return {
1248
- id: InsertSlideShapeRectangleCommand.id,
1249
- title: "slide.shape.insert.rectangle",
1250
- type: MenuItemType.BUTTON,
1251
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
1252
- };
1253
- }
1254
- __name(UploadSlideFloatShapeMenuFactory, "UploadSlideFloatShapeMenuFactory");
1255
- function whenEditorActivated(contextService) {
1256
- return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED);
1257
- }
1258
- __name(whenEditorActivated, "whenEditorActivated");
1259
- function whenFormulaEditorFocused(contextService) {
1260
- return contextService.getContextValue(FORMULA_EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR);
1261
- }
1262
- __name(whenFormulaEditorFocused, "whenFormulaEditorFocused");
1263
- const ARROW_SELECTION_KEYCODE_LIST = [
1264
- KeyCode.ARROW_DOWN,
1265
- KeyCode.ARROW_UP,
1266
- KeyCode.ARROW_LEFT,
1267
- KeyCode.ARROW_RIGHT
1268
- ];
1269
- [KeyCode.ENTER, KeyCode.TAB, ...ARROW_SELECTION_KEYCODE_LIST];
1270
- function generateArrowSelectionShortCutItem() {
1271
- const shortcutList = [];
1272
- for (const keycode of ARROW_SELECTION_KEYCODE_LIST)
1273
- shortcutList.push({
1274
- id: SetTextEditArrowOperation.id,
1275
- binding: keycode,
1276
- preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
1277
- staticParameters: {
1278
- visible: !1,
1279
- eventType: DeviceInputEventType.Keyboard,
1280
- keycode,
1281
- isShift: !1
1282
- }
1283
- }), shortcutList.push({
1284
- id: SetTextEditArrowOperation.id,
1285
- binding: keycode | MetaKeys.SHIFT,
1286
- preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
1287
- staticParameters: {
1288
- visible: !1,
1289
- eventType: DeviceInputEventType.Keyboard,
1290
- keycode,
1291
- isShift: !0
1292
- }
1293
- });
1294
- return shortcutList;
1295
- }
1296
- __name(generateArrowSelectionShortCutItem, "generateArrowSelectionShortCutItem");
1297
- const EditorDeleteLeftShortcut = {
1298
- id: DeleteLeftCommand.id,
1299
- preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService), "preconditions"),
1300
- binding: KeyCode.BACKSPACE
1301
- }, TEXT_ICON_ID = "text-single";
1302
- function SlideAddTextMenuItemFactory(_accessor) {
1303
- return {
1304
- id: SlideAddTextCommand.id,
1305
- type: MenuItemType.BUTTON,
1306
- icon: TEXT_ICON_ID,
1307
- tooltip: "slide.text.insert.title",
1308
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
1309
- };
1310
- }
1311
- __name(SlideAddTextMenuItemFactory, "SlideAddTextMenuItemFactory");
1312
- const menuSchema = {
1313
- [RibbonStartGroup.FORMAT]: {
1314
- [SlideAddTextCommand.id]: {
1315
- order: 0,
1316
- menuItemFactory: SlideAddTextMenuItemFactory
1317
- },
1318
- [IMAGE_MENU_ID]: {
1319
- order: 0,
1320
- menuItemFactory: SlideImageMenuFactory,
1321
- [InsertSlideFloatImageCommand.id]: {
1322
- order: 0,
1323
- menuItemFactory: UploadSlideFloatImageMenuFactory
1324
- }
1325
- },
1326
- [SHAPE_MENU_ID]: {
1327
- order: 0,
1328
- menuItemFactory: SlideShapeMenuFactory,
1329
- [InsertSlideShapeRectangleCommand.id]: {
1330
- order: 0,
1331
- menuItemFactory: UploadSlideFloatShapeMenuFactory
1332
- }
1333
- }
1334
- }
1335
- };
1336
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1337
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1338
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1339
- return kind && result && __defProp$7(target, key, result), result;
1340
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
1341
- let SlidesUIController = (_a3 = class extends Disposable {
1342
- constructor(_injector, _menuManagerService, _componentManager, _uiPartsService, _commandService, _shortcutService) {
1343
- super(), this._injector = _injector, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._uiPartsService = _uiPartsService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._initCommands(), this._initCustomComponents(), this._initUIComponents(), this._initMenus(), this._initShortcuts();
1344
- }
1345
- _initMenus() {
1346
- this._menuManagerService.mergeMenu(menuSchema);
1146
+ scaleX: 1,
1147
+ scaleY: 1,
1148
+ slideCardOffset: canvasOffset,
1149
+ unitId,
1150
+ editorUnitId,
1151
+ documentLayoutObject
1152
+ };
1347
1153
  }
1348
- _initCustomComponents() {
1349
- const componentManager = this._componentManager;
1350
- this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(TEXT_ICON_ID, TextSingle)), this.disposeWithMe(componentManager.register(GRAPH_SINGLE_ICON, GraphSingle)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_IMAGE_POPUP_MENU, SlideImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_SIDEBAR, RectSidebar));
1154
+ changeEditorDirty(dirtyStatus) {
1155
+ this._editorIsDirty = dirtyStatus;
1351
1156
  }
1352
- _initCommands() {
1353
- [
1354
- AppendSlideOperation,
1355
- ActivateSlidePageOperation,
1356
- SetSlidePageThumbOperation,
1357
- InsertSlideFloatImageCommand,
1358
- SlideAddTextOperation,
1359
- SlideAddTextCommand,
1360
- InsertSlideShapeRectangleOperation,
1361
- InsertSlideShapeRectangleCommand,
1362
- ToggleSlideEditSidebarOperation,
1363
- DeleteSlideElementOperation,
1364
- UpdateSlideElementOperation,
1365
- // commands for editor
1366
- SetTextEditArrowOperation
1367
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1157
+ isVisible() {
1158
+ return this._visibleParam.visible;
1368
1159
  }
1369
- _initUIComponents() {
1370
- this.disposeWithMe(
1371
- this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
1372
- ), this.disposeWithMe(
1373
- this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector))
1374
- );
1160
+ getEditorDirty() {
1161
+ return this._editorIsDirty;
1375
1162
  }
1376
- _initShortcuts() {
1377
- [
1378
- EditorDeleteLeftShortcut,
1379
- ...generateArrowSelectionShortCutItem()
1380
- ].forEach((item) => {
1381
- this.disposeWithMe(this._shortcutService.registerShortcut(item));
1382
- });
1163
+ getCurrentEditorId() {
1164
+ return this._editorUnitId;
1383
1165
  }
1384
- }, __name(_a3, "SlidesUIController"), _a3);
1385
- SlidesUIController = __decorateClass$7([
1386
- OnLifecycle(LifecycleStages.Ready, SlidesUIController),
1387
- __decorateParam$7(0, Inject(Injector)),
1388
- __decorateParam$7(1, IMenuManagerService),
1389
- __decorateParam$7(2, Inject(ComponentManager)),
1390
- __decorateParam$7(3, IUIPartsService),
1391
- __decorateParam$7(4, ICommandService),
1392
- __decorateParam$7(5, IShortcutService)
1393
- ], SlidesUIController);
1394
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1395
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1396
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1397
- return kind && result && __defProp$6(target, key, result), result;
1398
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
1399
- function transformBound2OffsetBound(originBound, scene) {
1400
- const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
1401
- return {
1402
- left: topLeft.x,
1403
- top: topLeft.y,
1404
- right: bottomRight.x,
1405
- bottom: bottomRight.y
1406
- };
1407
- }
1408
- __name(transformBound2OffsetBound, "transformBound2OffsetBound");
1409
- function transformPosition2Offset(x, y, scene) {
1410
- const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SLIDE_KEY.VIEW);
1411
- if (!viewMain)
1166
+ /**
1167
+ * @deprecated
1168
+ */
1169
+ genDocData(target) {
1170
+ const editorUnitId = this.getCurrentEditorId(), content = target.text, fontSize = target.fs;
1412
1171
  return {
1413
- x,
1414
- y
1172
+ id: editorUnitId,
1173
+ body: {
1174
+ dataStream: `${content}\r
1175
+ `,
1176
+ textRuns: [{ st: 0, ed: content.length }],
1177
+ paragraphs: [{
1178
+ paragraphStyle: {
1179
+ // no use
1180
+ // textStyle: { fs: 30 },
1181
+ // horizontalAlign: HorizontalAlign.CENTER,
1182
+ // verticalAlign: VerticalAlign.MIDDLE,
1183
+ },
1184
+ startIndex: content.length + 1
1185
+ }],
1186
+ sectionBreaks: [{ startIndex: content.length + 2 }]
1187
+ },
1188
+ documentStyle: {
1189
+ marginBottom: 0,
1190
+ marginLeft: 0,
1191
+ marginRight: 0,
1192
+ marginTop: 0,
1193
+ pageSize: { width: 1 / 0, height: 1 / 0 },
1194
+ textStyle: { fs: fontSize },
1195
+ renderConfig: {
1196
+ // horizontalAlign: HorizontalAlign.CENTER,
1197
+ verticalAlign: VerticalAlign.MIDDLE,
1198
+ centerAngle: 0,
1199
+ vertexAngle: 0,
1200
+ wrapStrategy: 0
1201
+ }
1202
+ },
1203
+ drawings: {},
1204
+ drawingsOrder: [],
1205
+ settings: { zoomRatio: 1 }
1415
1206
  };
1416
- const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain, offsetX = (x - actualScrollX) * scaleX, offsetY = (y - actualScrollY) * scaleY;
1417
- return {
1418
- x: offsetX,
1419
- y: offsetY
1420
- };
1421
- }
1422
- __name(transformPosition2Offset, "transformPosition2Offset");
1423
- var _a4;
1424
- let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
1425
- constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
1426
- super(), this._globalPopupManagerService = _globalPopupManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService;
1427
1207
  }
1428
- _createObjectPositionObserver(targetObject, currentRender) {
1429
- const position = (/* @__PURE__ */ __name(() => {
1430
- var _a11, _b, _c, _d;
1431
- const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (_a11 = currentRender.mainComponent) == null ? void 0 : _a11.width) != null ? _b : 0)) / 2, verticalOffset = (scene.height - ((_d = (_c = currentRender.mainComponent) == null ? void 0 : _c.height) != null ? _d : 0)) / 2, bound = {
1432
- left,
1433
- right: left + width,
1434
- top,
1435
- bottom: top + height
1436
- }, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { scaleX, scaleY } = scene.getAncestorScale(), offsetBound = transformBound2OffsetBound(bound, scene), { top: topOffset, left: leftOffset, width: domWidth } = canvasClientRect, scaleAdjust = domWidth / widthOfCanvas;
1437
- return {
1438
- left: offsetBound.left * scaleAdjust * scaleX + leftOffset + horizontalOffset,
1439
- right: offsetBound.right * scaleAdjust * scaleX + leftOffset + horizontalOffset,
1440
- top: offsetBound.top * scaleAdjust * scaleY + topOffset + verticalOffset,
1441
- bottom: offsetBound.bottom * scaleAdjust * scaleY + topOffset + verticalOffset
1442
- };
1443
- }, "calc"))(), position$ = new BehaviorSubject(position), disposable = new DisposableCollection();
1444
- return {
1445
- position,
1446
- position$,
1447
- disposable
1448
- };
1208
+ }, __name(_a5, "SlideEditorBridgeService"), _a5);
1209
+ SlideEditorBridgeService = __decorateClass$5([
1210
+ __decorateParam$5(0, IEditorService),
1211
+ __decorateParam$5(1, IContextService),
1212
+ __decorateParam$5(2, IRenderManagerService)
1213
+ ], SlideEditorBridgeService);
1214
+ const _SlideEditorManagerService = class _SlideEditorManagerService {
1215
+ constructor() {
1216
+ __publicField(this, "_state", null);
1217
+ __publicField(this, "_rect", null);
1218
+ __publicField(this, "_state$", new BehaviorSubject(null));
1219
+ __publicField(this, "state$", this._state$.asObservable());
1220
+ __publicField(this, "_rect$", new BehaviorSubject(null));
1221
+ __publicField(this, "rect$", this._rect$.asObservable());
1222
+ __publicField(this, "_focus", !1);
1223
+ __publicField(this, "_focus$", new BehaviorSubject(this._focus));
1224
+ __publicField(this, "focus$", this._focus$.asObservable());
1449
1225
  }
1450
- attachPopupToObject(targetObject, popup) {
1451
- const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE).getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
1452
- if (!currentRender)
1453
- return {
1454
- dispose: /* @__PURE__ */ __name(() => {
1455
- }, "dispose")
1456
- };
1457
- const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender), id = this._globalPopupManagerService.addPopup({
1458
- ...popup,
1459
- unitId,
1460
- subUnitId: "default",
1461
- anchorRect: position,
1462
- anchorRect$: position$,
1463
- canvasElement: currentRender.engine.getCanvasElement()
1464
- });
1465
- return {
1466
- dispose: /* @__PURE__ */ __name(() => {
1467
- this._globalPopupManagerService.removePopup(id), position$.complete(), disposable.dispose();
1468
- }, "dispose")
1469
- };
1226
+ dispose() {
1227
+ this._state$.complete(), this._state = null, this._rect$.complete(), this._rect = null;
1470
1228
  }
1471
- }, __name(_a4, "SlideCanvasPopMangerService"), _a4);
1472
- SlideCanvasPopMangerService = __decorateClass$6([
1473
- __decorateParam$6(0, Inject(ICanvasPopupService)),
1474
- __decorateParam$6(1, IRenderManagerService),
1475
- __decorateParam$6(2, IUniverInstanceService),
1476
- __decorateParam$6(3, ICommandService)
1477
- ], SlideCanvasPopMangerService);
1478
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1479
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1480
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1481
- return kind && result && __defProp$5(target, key, result), result;
1482
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
1483
- let SlidePopupMenuController = (_a5 = class extends RxDisposable {
1484
- constructor(_canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _canvasView, _sidebarService, _commandService) {
1485
- super();
1486
- __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
1487
- this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._canvasView = _canvasView, this._sidebarService = _sidebarService, this._commandService = _commandService, this._init();
1488
- }
1489
- _init() {
1490
- this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => this._create(slide));
1229
+ setState(param) {
1230
+ this._state = param, this._refresh(param);
1491
1231
  }
1492
- _dispose(workbook) {
1232
+ getRect() {
1233
+ return this._rect;
1493
1234
  }
1494
- _create(slide) {
1495
- if (!slide)
1496
- return;
1497
- const unitId = slide.getUnitId();
1498
- this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
1235
+ setRect(param) {
1236
+ this._rect = param, this._rect$.next(param);
1499
1237
  }
1500
- _hasCropObject(scene) {
1238
+ getState() {
1239
+ return this._state;
1501
1240
  }
1502
- // eslint-disable-next-line max-lines-per-function
1503
- _popupMenuListener(unitId) {
1504
- var _a11;
1505
- const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a11 = model == null ? void 0 : model.getPages()) != null ? _a11 : {};
1506
- Object.keys(pages).forEach((pageId) => {
1507
- var _a12;
1508
- const transformer = (_a12 = this._canvasView.getRenderUnitByPageId(pageId, unitId).scene) == null ? void 0 : _a12.getTransformer();
1509
- if (!transformer) return;
1510
- let singletonPopupDisposer;
1511
- this.disposeWithMe(
1512
- toDisposable(
1513
- transformer.createControl$.subscribe(() => {
1514
- const selectedObjects = transformer.getSelectedObjectMap();
1515
- if (selectedObjects.size > 1) {
1516
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1517
- return;
1518
- }
1519
- const object = selectedObjects.values().next().value;
1520
- if (!object)
1521
- return;
1522
- const oKey = object.oKey;
1523
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
1524
- componentKey: COMPONENT_SLIDE_IMAGE_POPUP_MENU,
1525
- direction: "horizontal",
1526
- offset: [2, 0],
1527
- extraProps: {
1528
- menuItems: this._getMenuItemsByObjectType(object.objectType, oKey, unitId)
1529
- }
1530
- })), this._sidebarService.visible && this._commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
1531
- visible: !0,
1532
- objectType: object.objectType
1533
- });
1534
- })
1535
- )
1536
- ), this.disposeWithMe(
1537
- transformer.clearControl$.subscribe(() => {
1538
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1);
1539
- })
1540
- ), this.disposeWithMe(
1541
- transformer.changing$.subscribe(() => {
1542
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1543
- const selectedObjects = transformer.getSelectedObjectMap();
1544
- if (selectedObjects.size > 1) {
1545
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
1546
- return;
1547
- }
1548
- const object = selectedObjects.values().next().value;
1549
- object && this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1550
- unitId,
1551
- oKey: object.oKey,
1552
- props: {
1553
- width: object.width,
1554
- height: object.height,
1555
- left: object.left,
1556
- top: object.top
1557
- }
1558
- });
1559
- })
1560
- );
1561
- });
1241
+ setFocus(param = !1) {
1242
+ this._focus = param, this._focus$.next(param);
1562
1243
  }
1563
- _getMenuItemsByObjectType(objectType, oKey, unitId) {
1564
- return [{
1565
- label: "slide.popup.edit",
1566
- index: 0,
1567
- commandId: ToggleSlideEditSidebarOperation.id,
1568
- commandParams: {
1569
- visible: !0,
1570
- objectType
1571
- },
1572
- disable: !1
1573
- }, {
1574
- label: "slide.popup.delete",
1575
- index: 5,
1576
- commandId: DeleteSlideElementOperation.id,
1577
- commandParams: {
1578
- id: oKey,
1579
- unitId
1580
- },
1581
- disable: !1
1582
- }];
1244
+ _refresh(param) {
1245
+ this._state$.next(param);
1583
1246
  }
1584
- }, __name(_a5, "SlidePopupMenuController"), _a5);
1585
- SlidePopupMenuController = __decorateClass$5([
1586
- OnLifecycle(LifecycleStages.Steady, SlidePopupMenuController),
1587
- __decorateParam$5(0, Inject(SlideCanvasPopMangerService)),
1588
- __decorateParam$5(1, IRenderManagerService),
1589
- __decorateParam$5(2, IUniverInstanceService),
1590
- __decorateParam$5(3, IContextService),
1591
- __decorateParam$5(4, Inject(CanvasView)),
1592
- __decorateParam$5(5, ISidebarService),
1593
- __decorateParam$5(6, ICommandService)
1594
- ], SlidePopupMenuController);
1595
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1247
+ };
1248
+ __name(_SlideEditorManagerService, "SlideEditorManagerService");
1249
+ let SlideEditorManagerService = _SlideEditorManagerService;
1250
+ const ISlideEditorManagerService = createIdentifier(
1251
+ "univer.slide-editor-manager.service"
1252
+ );
1253
+ var CursorChange = /* @__PURE__ */ ((_CursorChange) => (_CursorChange[_CursorChange.InitialState = 0] = "InitialState", _CursorChange[_CursorChange.StartEditor = 1] = "StartEditor", _CursorChange[_CursorChange.CursorChange = 2] = "CursorChange", _CursorChange))(CursorChange || {}), __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1596
1254
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1597
1255
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1598
1256
  return kind && result && __defProp$4(target, key, result), result;
1599
1257
  }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
1600
- const ISlideEditorBridgeService = createIdentifier("univer.slide-editor-bridge.service");
1258
+ const HIDDEN_EDITOR_POSITION$1 = -1e3, EDITOR_INPUT_SELF_EXTEND_GAP = 5, EDITOR_BORDER_SIZE = 2;
1601
1259
  var _a6;
1602
- let SlideEditorBridgeService = (_a6 = class extends Disposable {
1603
- constructor(_editorService, _contextService, _renderManagerService) {
1260
+ let SlideEditingRenderController = (_a6 = class extends Disposable {
1261
+ constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionManagerService, _commandService, _localService, _editorService) {
1604
1262
  super();
1605
- __publicField(this, "_editorUnitId", SLIDE_EDITOR_ID);
1606
- __publicField(this, "_isForceKeepVisible", !1);
1607
- __publicField(this, "_editorIsDirty", !1);
1608
- __publicField(this, "_currentEditRectState", null);
1609
- __publicField(this, "_currentEditRectState$", new BehaviorSubject(null));
1610
- __publicField(this, "currentEditRectState$", this._currentEditRectState$.asObservable());
1611
- __publicField(this, "_visibleParam", {
1612
- visible: !1,
1613
- eventType: DeviceInputEventType.Dblclick,
1614
- unitId: ""
1615
- });
1616
- __publicField(this, "_visible$", new BehaviorSubject(this._visibleParam));
1617
- __publicField(this, "visible$", this._visible$.asObservable());
1618
- __publicField(this, "_afterVisible$", new BehaviorSubject(this._visibleParam));
1619
- __publicField(this, "afterVisible$", this._afterVisible$.asObservable());
1620
- __publicField(this, "endEditing$", new Subject());
1621
- __publicField(this, "_currentEditRectInfo");
1622
- this._editorService = _editorService, this._contextService = _contextService, this._renderManagerService = _renderManagerService;
1263
+ /**
1264
+ * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1265
+ */
1266
+ __publicField(this, "_cursorChange", CursorChange.InitialState);
1267
+ /** If the corresponding unit is active and prepared for editing. */
1268
+ __publicField(this, "_isUnitEditing", !1);
1269
+ __publicField(this, "_d");
1270
+ this._renderContext = _renderContext, this._layoutService = _layoutService, this._undoRedoService = _undoRedoService, this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._editorBridgeService = _editorBridgeService, this._cellEditorManagerService = _cellEditorManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._localService = _localService, this._editorService = _editorService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
1271
+ slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : (this._disposeCurrent(), this._isUnitEditing && (this._handleEditorInvisible({
1272
+ visible: !1,
1273
+ eventType: DeviceInputEventType.Keyboard,
1274
+ keycode: KeyCode.ESC,
1275
+ unitId: this._renderContext.unitId
1276
+ }), this._isUnitEditing = !1));
1277
+ })), this._initEditorVisibilityListener();
1623
1278
  }
1624
1279
  dispose() {
1625
- super.dispose();
1626
- }
1627
- getEditorRect() {
1628
- return this._currentEditRectInfo;
1280
+ super.dispose(), this._disposeCurrent();
1629
1281
  }
1630
- /**
1631
- * 1st part of startEditing.
1632
- * @editorInfo editorInfo
1633
- */
1634
- setEditorRect(editorInfo) {
1635
- this._currentEditRectInfo = editorInfo, this._editorService.getFocusEditor() || (this._editorService.focus(SLIDE_EDITOR_ID), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !1), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, !1));
1636
- const editRectState = this.getEditRectState();
1637
- this._currentEditRectState = editRectState, this._currentEditRectState$.next(editRectState);
1282
+ _disposeCurrent() {
1283
+ var _a11;
1284
+ (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1638
1285
  }
1639
- changeVisible(param) {
1640
- this._visibleParam = param, param.visible && (this._editorIsDirty = !1), this._visible$.next(this._visibleParam), this._afterVisible$.next(this._visibleParam);
1286
+ _init() {
1287
+ const d = new DisposableCollection();
1288
+ return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), setTimeout(() => {
1289
+ this._cursorStateListener(d);
1290
+ }, 1e3), d;
1641
1291
  }
1642
- /**
1643
- * get info from _currentEditRectInfo
1644
- *
1645
- * invoked by slide-editing.render-controller.ts@_handleEditorVisible
1646
- * && this@setEditorRect
1647
- */
1648
- getEditRectState() {
1649
- const editorUnitId = SLIDE_EDITOR_ID, editorRectInfo = this._currentEditRectInfo, unitId = editorRectInfo.unitId, docData = editorRectInfo.richTextObj.documentData;
1650
- docData.id = editorUnitId, docData.documentStyle = {
1651
- ...docData.documentStyle,
1652
- pageSize: { width: editorRectInfo.richTextObj.width, height: 1 / 0 }
1653
- };
1654
- const documentLayoutObject = {
1655
- documentModel: new DocumentDataModel(docData),
1656
- fontString: "document",
1657
- textRotation: { a: 0, v: 0 },
1658
- wrapStrategy: 0,
1659
- verticalAlign: VerticalAlign.TOP,
1660
- horizontalAlign: HorizontalAlign.LEFT,
1661
- paddingData: { t: 0, b: 1, l: 2, r: 2 }
1662
- }, editorWidth = editorRectInfo.richTextObj.width, editorHeight = editorRectInfo.richTextObj.height, left = editorRectInfo.richTextObj.left, top = editorRectInfo.richTextObj.top, canvasOffset = {
1663
- left: 0,
1664
- top: 0
1665
- }, renderUnit = this._renderManagerService.getRenderById(unitId), mainScene = renderUnit == null ? void 0 : renderUnit.scene, mainViewport = mainScene == null ? void 0 : mainScene.getViewport(SLIDE_KEY.VIEW), slideMainRect = mainScene == null ? void 0 : mainScene.getObject(SLIDE_KEY.COMPONENT), slidePos = {
1666
- x: (slideMainRect == null ? void 0 : slideMainRect.left) || 0,
1667
- y: (slideMainRect == null ? void 0 : slideMainRect.top) || 0
1668
- }, scrollX = (mainViewport == null ? void 0 : mainViewport.viewportScrollX) || 0, scrollY = (mainViewport == null ? void 0 : mainViewport.viewportScrollY) || 0;
1669
- return canvasOffset.left = slidePos.x - scrollX, canvasOffset.top = slidePos.y - scrollY, {
1670
- position: {
1671
- startX: left,
1672
- startY: top,
1673
- endX: left + editorWidth,
1674
- endY: top + editorHeight
1675
- },
1676
- scaleX: 1,
1677
- scaleY: 1,
1678
- slideCardOffset: canvasOffset,
1679
- unitId,
1680
- editorUnitId,
1681
- documentLayoutObject
1682
- };
1292
+ _initEditorVisibilityListener() {
1293
+ this.disposeWithMe(this._editorBridgeService.visible$.subscribe((param) => {
1294
+ param.visible ? (this._isUnitEditing = !0, this._handleEditorVisible(param)) : this._isUnitEditing && (this._handleEditorInvisible(param), this._isUnitEditing = !1);
1295
+ }));
1683
1296
  }
1684
- changeEditorDirty(dirtyStatus) {
1685
- this._editorIsDirty = dirtyStatus;
1297
+ _listenEditorFocus(d) {
1298
+ const renderConfig = this._getEditorObject();
1299
+ renderConfig && d.add(renderConfig.document.onPointerDown$.subscribeEvent(() => {
1300
+ }));
1686
1301
  }
1687
- isVisible() {
1688
- return this._visibleParam.visible;
1302
+ _getEditorSkeleton(editorId) {
1303
+ var _a11;
1304
+ return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getSkeleton();
1689
1305
  }
1690
- getEditorDirty() {
1691
- return this._editorIsDirty;
1306
+ _getEditorViewModel(editorId) {
1307
+ var _a11;
1308
+ return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getViewModel();
1692
1309
  }
1693
- getCurrentEditorId() {
1694
- return this._editorUnitId;
1310
+ _initialCursorSync(d) {
1311
+ d.add(this._cellEditorManagerService.focus$.pipe(filter((f2) => !!f2)).subscribe(() => {
1312
+ var _a11;
1313
+ const docSelectionRenderManager = (_a11 = this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a11.with(DocSelectionRenderService);
1314
+ docSelectionRenderManager && docSelectionRenderManager.sync();
1315
+ }));
1695
1316
  }
1696
1317
  /**
1697
- * @deprecated
1698
- */
1699
- genDocData(target) {
1700
- const editorUnitId = this.getCurrentEditorId(), content = target.text, fontSize = target.fs;
1701
- return {
1702
- id: editorUnitId,
1703
- body: {
1704
- dataStream: `${content}\r
1705
- `,
1706
- textRuns: [{ st: 0, ed: content.length }],
1707
- paragraphs: [{
1708
- paragraphStyle: {
1709
- // no use
1710
- // textStyle: { fs: 30 },
1711
- // horizontalAlign: HorizontalAlign.CENTER,
1712
- // verticalAlign: VerticalAlign.MIDDLE,
1713
- },
1714
- startIndex: content.length + 1
1715
- }],
1716
- sectionBreaks: [{ startIndex: content.length + 2 }]
1717
- },
1718
- documentStyle: {
1719
- marginBottom: 0,
1720
- marginLeft: 0,
1721
- marginRight: 0,
1722
- marginTop: 0,
1723
- pageSize: { width: 1 / 0, height: 1 / 0 },
1724
- textStyle: { fs: fontSize },
1725
- renderConfig: {
1726
- // horizontalAlign: HorizontalAlign.CENTER,
1727
- verticalAlign: VerticalAlign.MIDDLE,
1728
- centerAngle: 0,
1729
- vertexAngle: 0,
1730
- wrapStrategy: 0
1731
- }
1732
- },
1733
- drawings: {},
1734
- drawingsOrder: [],
1735
- settings: { zoomRatio: 1 }
1736
- };
1737
- }
1738
- }, __name(_a6, "SlideEditorBridgeService"), _a6);
1739
- SlideEditorBridgeService = __decorateClass$4([
1740
- __decorateParam$4(0, IEditorService),
1741
- __decorateParam$4(1, IContextService),
1742
- __decorateParam$4(2, IRenderManagerService)
1743
- ], SlideEditorBridgeService);
1744
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1745
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1746
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1747
- return kind && result && __defProp$3(target, key, result), result;
1748
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
1749
- let SlideEditorBridgeRenderController = (_a7 = class extends RxDisposable {
1750
- constructor(_renderContext, _instanceSrv, _commandService, _editorBridgeService) {
1751
- super();
1752
- /**
1753
- * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1754
- */
1755
- // private _cursorChange: CursorChange = CursorChange.InitialState;
1756
- /** If the corresponding unit is active and prepared for editing. */
1757
- // private _isUnitEditing = false;
1758
- __publicField(this, "setSlideTextEditor$", new Subject());
1759
- __publicField(this, "_curRichText", null);
1760
- __publicField(this, "_d");
1761
- this._renderContext = _renderContext, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
1762
- slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : this._disposeCurrent();
1763
- }));
1764
- }
1765
- _init() {
1766
- const d = new DisposableCollection();
1767
- return this._initEventListener(d), d;
1768
- }
1769
- _disposeCurrent() {
1770
- var _a11;
1771
- (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1772
- }
1773
- _setEditorRect(pageId, targetObject) {
1774
- this._curRichText = targetObject;
1775
- const { scene, engine } = this._renderContext, unitId = this._renderContext.unitId, setEditorRect = {
1776
- scene,
1777
- engine,
1778
- unitId,
1779
- pageId,
1780
- richTextObj: targetObject
1781
- };
1782
- this._editorBridgeService.setEditorRect(setEditorRect);
1783
- }
1784
- _initEventListener(d) {
1785
- const listenersForPageScene = /* @__PURE__ */ __name((scene) => {
1786
- const transformer = scene.getTransformer();
1787
- transformer && (d.add(transformer.clearControl$.subscribe(() => {
1788
- this.setEditorVisible(!1), this.pickOtherObjects();
1789
- })), d.add(transformer.createControl$.subscribe(() => {
1790
- this.setEditorVisible(!1);
1791
- })), d.add(scene.onDblclick$.subscribeEvent(() => {
1792
- transformer.clearControls();
1793
- const object = transformer.getSelectedObjectMap().values().next().value;
1794
- object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(scene.sceneKey, object));
1795
- })), d.add(this._instanceSrv.focused$.subscribe((fc) => {
1796
- this.endEditing();
1797
- })));
1798
- }, "listenersForPageScene"), { mainComponent } = this._renderContext;
1799
- mainComponent.subSceneChanged$.subscribeEvent((pageScene) => {
1800
- listenersForPageScene(pageScene);
1801
- });
1802
- const pageSceneList = Array.from(mainComponent.getSubScenes().values());
1803
- for (let i = 0; i < pageSceneList.length; i++) {
1804
- const pageScene = pageSceneList[i];
1805
- listenersForPageScene(pageScene);
1806
- }
1807
- }
1808
- pickOtherObjects() {
1809
- this.endEditing();
1810
- }
1811
- /**
1812
- * invoked when picking other object.
1813
- *
1814
- * save editing state to curr richText.
1815
- */
1816
- endEditing() {
1817
- var _a11;
1818
- if (!this._curRichText) return;
1819
- this.setEditorVisible(!1);
1820
- const curRichText = this._curRichText;
1821
- if (!this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) return !1;
1822
- curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._editorBridgeService.endEditing$.next(curRichText);
1823
- const richText = {
1824
- bl: 1,
1825
- fs: curRichText.fs,
1826
- text: curRichText.text
1827
- }, textRuns = (_a11 = curRichText.documentData.body) == null ? void 0 : _a11.textRuns;
1828
- if (textRuns && textRuns.length) {
1829
- const ts = textRuns[0].ts;
1830
- richText.cl = ts == null ? void 0 : ts.cl;
1831
- }
1832
- this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1833
- unitId: this._renderContext.unitId,
1834
- oKey: curRichText == null ? void 0 : curRichText.oKey,
1835
- props: {
1836
- richText
1837
- }
1838
- }), this._curRichText = null;
1839
- }
1840
- /**
1841
- * TODO calling twice ????
1842
- * editingParam derives from RichText object.
1843
- *
1844
- * TODO @lumixraku need scale param
1845
- * @param target
1846
- */
1847
- startEditing(pageId, target) {
1848
- this._setEditorRect(pageId, target), this.setEditorVisible(!0);
1849
- }
1850
- setEditorVisible(visible) {
1851
- var _a11, _b;
1852
- visible ? (_a11 = this._curRichText) == null || _a11.hide() : (_b = this._curRichText) == null || _b.show();
1853
- const { unitId } = this._renderContext;
1854
- this._editorBridgeService.changeVisible({ visible, eventType: DeviceInputEventType.PointerDown, unitId });
1855
- }
1856
- }, __name(_a7, "SlideEditorBridgeRenderController"), _a7);
1857
- SlideEditorBridgeRenderController = __decorateClass$3([
1858
- __decorateParam$3(1, IUniverInstanceService),
1859
- __decorateParam$3(2, ICommandService),
1860
- __decorateParam$3(3, ISlideEditorBridgeService)
1861
- ], SlideEditorBridgeRenderController);
1862
- var CursorChange = /* @__PURE__ */ ((_CursorChange) => (_CursorChange[_CursorChange.InitialState = 0] = "InitialState", _CursorChange[_CursorChange.StartEditor = 1] = "StartEditor", _CursorChange[_CursorChange.CursorChange = 2] = "CursorChange", _CursorChange))(CursorChange || {}), __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1863
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1864
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1865
- return kind && result && __defProp$2(target, key, result), result;
1866
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
1867
- const HIDDEN_EDITOR_POSITION = -1e3, EDITOR_INPUT_SELF_EXTEND_GAP = 5, EDITOR_BORDER_SIZE = 2;
1868
- var _a8;
1869
- let SlideEditingRenderController = (_a8 = class extends Disposable {
1870
- constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionManagerService, _commandService, _localService, _editorService) {
1871
- super();
1872
- /**
1873
- * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1874
- */
1875
- __publicField(this, "_cursorChange", CursorChange.InitialState);
1876
- /** If the corresponding unit is active and prepared for editing. */
1877
- __publicField(this, "_isUnitEditing", !1);
1878
- __publicField(this, "_d");
1879
- this._renderContext = _renderContext, this._layoutService = _layoutService, this._undoRedoService = _undoRedoService, this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._editorBridgeService = _editorBridgeService, this._cellEditorManagerService = _cellEditorManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._localService = _localService, this._editorService = _editorService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
1880
- slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : (this._disposeCurrent(), this._isUnitEditing && (this._handleEditorInvisible({
1881
- visible: !1,
1882
- eventType: DeviceInputEventType.Keyboard,
1883
- keycode: KeyCode.ESC,
1884
- unitId: this._renderContext.unitId
1885
- }), this._isUnitEditing = !1));
1886
- })), this._initEditorVisibilityListener();
1887
- }
1888
- dispose() {
1889
- super.dispose(), this._disposeCurrent();
1890
- }
1891
- _disposeCurrent() {
1892
- var _a11;
1893
- (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1894
- }
1895
- _init() {
1896
- const d = new DisposableCollection();
1897
- return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), setTimeout(() => {
1898
- this._cursorStateListener(d);
1899
- }, 1e3), d;
1900
- }
1901
- _initEditorVisibilityListener() {
1902
- this.disposeWithMe(this._editorBridgeService.visible$.subscribe((param) => {
1903
- param.visible ? (this._isUnitEditing = !0, this._handleEditorVisible(param)) : this._isUnitEditing && (this._handleEditorInvisible(param), this._isUnitEditing = !1);
1904
- }));
1905
- }
1906
- _listenEditorFocus(d) {
1907
- const renderConfig = this._getEditorObject();
1908
- renderConfig && d.add(renderConfig.document.onPointerDown$.subscribeEvent(() => {
1909
- }));
1910
- }
1911
- _getEditorSkeleton(editorId) {
1912
- var _a11;
1913
- return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getSkeleton();
1914
- }
1915
- _getEditorViewModel(editorId) {
1916
- var _a11;
1917
- return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getViewModel();
1918
- }
1919
- _initialCursorSync(d) {
1920
- d.add(this._cellEditorManagerService.focus$.pipe(filter((f2) => !!f2)).subscribe(() => {
1921
- var _a11;
1922
- const docSelectionRenderManager = (_a11 = this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a11.with(DocSelectionRenderService);
1923
- docSelectionRenderManager && docSelectionRenderManager.sync();
1924
- }));
1925
- }
1926
- /**
1927
- * Set editorUnitId to curr doc.
1928
- * @param d DisposableCollection
1318
+ * Set editorUnitId to curr doc.
1319
+ * @param d DisposableCollection
1929
1320
  */
1930
1321
  _subscribeToCurrentCell(d) {
1931
1322
  d.add(this._editorBridgeService.currentEditRectState$.subscribe((editCellState) => {
@@ -1943,7 +1334,7 @@ let SlideEditingRenderController = (_a8 = class extends Disposable {
1943
1334
  endOffset: 0
1944
1335
  }]);
1945
1336
  const docSelectionRenderManager = (_a11 = this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a11.with(DocSelectionRenderService);
1946
- docSelectionRenderManager && docSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION, HIDDEN_EDITOR_POSITION);
1337
+ docSelectionRenderManager && docSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1);
1947
1338
  }));
1948
1339
  }
1949
1340
  /**
@@ -2104,138 +1495,745 @@ let SlideEditingRenderController = (_a8 = class extends Disposable {
2104
1495
  startOffset: cursor,
2105
1496
  endOffset: cursor
2106
1497
  }
2107
- ]), (_b = this._renderManagerService.getRenderById(unitId)) == null || _b.scene.resetCursor();
2108
- }
2109
- _resetBodyStyle(body, removeStyle = !1) {
2110
- body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE, body.textRuns != null && (body.textRuns.length === 1 && !removeStyle ? (body.textRuns[0].st = 0, body.textRuns[0].ed = 1) : body.textRuns = void 0), body.paragraphs != null && (body.paragraphs.length === 1 ? body.paragraphs[0].startIndex = 0 : body.paragraphs = [
2111
- {
2112
- startIndex: 0
1498
+ ]), (_b = this._renderManagerService.getRenderById(unitId)) == null || _b.scene.resetCursor();
1499
+ }
1500
+ _resetBodyStyle(body, removeStyle = !1) {
1501
+ body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE, body.textRuns != null && (body.textRuns.length === 1 && !removeStyle ? (body.textRuns[0].st = 0, body.textRuns[0].ed = 1) : body.textRuns = void 0), body.paragraphs != null && (body.paragraphs.length === 1 ? body.paragraphs[0].startIndex = 0 : body.paragraphs = [
1502
+ {
1503
+ startIndex: 0
1504
+ }
1505
+ ]), body.sectionBreaks != null && (body.sectionBreaks = void 0), body.tables != null && (body.tables = void 0), body.customRanges != null && (body.customRanges = void 0), body.customBlocks != null && (body.customBlocks = void 0);
1506
+ }
1507
+ /**
1508
+ * Should activate the editor when the user inputs text.
1509
+ * @param d DisposableCollection
1510
+ */
1511
+ _initialKeyboardListener(d) {
1512
+ }
1513
+ _showEditorByKeyboard(config) {
1514
+ }
1515
+ _commandExecutedListener(d) {
1516
+ const moveCursorOP = [SetTextEditArrowOperation.id], editedMutations = [RichTextEditingMutation.id];
1517
+ d.add(this._commandService.onCommandExecuted((command) => {
1518
+ this._editorService.getFocusId() === SLIDE_EDITOR_ID && (moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editorBridgeService.isVisible() && this._editingChangedHandler());
1519
+ }));
1520
+ }
1521
+ _moveCursorCmdHandler(command) {
1522
+ const params = command.params, { keycode, isShift } = params;
1523
+ keycode != null && this._cursorChange === CursorChange.CursorChange ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
1524
+ }
1525
+ _editingChangedHandler() {
1526
+ const editRect = this._editorBridgeService.getEditorRect();
1527
+ if (!editRect)
1528
+ return;
1529
+ const editingRichText = editRect.richTextObj;
1530
+ editingRichText.refreshDocumentByDocData(), editingRichText.resizeToContentSize();
1531
+ const { unitId } = this._renderContext;
1532
+ this._handleEditorVisible({ visible: !0, eventType: 3, unitId });
1533
+ }
1534
+ _setOpenForCurrent(unitId, subUnitId) {
1535
+ const editors = this._editorService.getAllEditor();
1536
+ for (const [_, ed] of editors)
1537
+ ed.setOpenForSheetUnitId(unitId), ed.setOpenForSheetSubUnitId(subUnitId);
1538
+ }
1539
+ _getEditorObject() {
1540
+ return getEditorObject(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
1541
+ }
1542
+ async _handleEditorInvisible(param) {
1543
+ const { keycode } = param;
1544
+ if (this._setOpenForCurrent(null, null), this._cursorChange = CursorChange.InitialState, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
1545
+ return;
1546
+ if (this._editorBridgeService.getEditorDirty() === !1) {
1547
+ this._moveCursor(keycode);
1548
+ return;
1549
+ }
1550
+ this._moveCursor(keycode);
1551
+ }
1552
+ _exitInput(param) {
1553
+ this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
1554
+ show: param.visible
1555
+ });
1556
+ const editorUnitId = this._editorBridgeService.getCurrentEditorId();
1557
+ editorUnitId != null && this._undoRedoService.clearUndoRedo(editorUnitId);
1558
+ }
1559
+ _moveCursor(keycode) {
1560
+ if (keycode != null)
1561
+ switch (Direction.LEFT, keycode) {
1562
+ case KeyCode.ENTER:
1563
+ Direction.DOWN;
1564
+ break;
1565
+ case KeyCode.TAB:
1566
+ Direction.RIGHT;
1567
+ break;
1568
+ case KeyCode.ARROW_DOWN:
1569
+ Direction.DOWN;
1570
+ break;
1571
+ case KeyCode.ARROW_UP:
1572
+ Direction.UP;
1573
+ break;
1574
+ case KeyCode.ARROW_LEFT:
1575
+ Direction.LEFT;
1576
+ break;
1577
+ case KeyCode.ARROW_RIGHT:
1578
+ Direction.RIGHT;
1579
+ break;
1580
+ }
1581
+ }
1582
+ /**
1583
+ * The user's operations follow the sequence of opening the editor and then moving the cursor.
1584
+ * The logic here predicts the user's first cursor movement behavior based on this rule
1585
+ */
1586
+ _cursorStateListener(d) {
1587
+ const editorObject = this._getEditorObject(), { document: documentComponent } = editorObject;
1588
+ d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
1589
+ this._cursorChange === CursorChange.StartEditor && (this._cursorChange = CursorChange.CursorChange);
1590
+ })));
1591
+ }
1592
+ // TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
1593
+ _moveInEditor(keycode, isShift) {
1594
+ let direction = Direction.LEFT;
1595
+ keycode === KeyCode.ARROW_DOWN ? direction = Direction.DOWN : keycode === KeyCode.ARROW_UP ? direction = Direction.UP : keycode === KeyCode.ARROW_RIGHT && (direction = Direction.RIGHT), isShift ? this._commandService.executeCommand(MoveSelectionOperation.id, {
1596
+ direction
1597
+ }) : this._commandService.executeCommand(MoveCursorOperation.id, {
1598
+ direction
1599
+ });
1600
+ }
1601
+ }, __name(_a6, "SlideEditingRenderController"), _a6);
1602
+ SlideEditingRenderController = __decorateClass$4([
1603
+ __decorateParam$4(1, ILayoutService),
1604
+ __decorateParam$4(2, IUndoRedoService),
1605
+ __decorateParam$4(3, IContextService),
1606
+ __decorateParam$4(4, IUniverInstanceService),
1607
+ __decorateParam$4(5, IRenderManagerService),
1608
+ __decorateParam$4(6, ISlideEditorBridgeService),
1609
+ __decorateParam$4(7, ISlideEditorManagerService),
1610
+ __decorateParam$4(8, Inject(DocSelectionManagerService)),
1611
+ __decorateParam$4(9, ICommandService),
1612
+ __decorateParam$4(10, Inject(LocaleService)),
1613
+ __decorateParam$4(11, IEditorService)
1614
+ ], SlideEditingRenderController);
1615
+ function getEditorObject(unitId, renderManagerService) {
1616
+ if (unitId == null)
1617
+ return;
1618
+ const currentRender = renderManagerService.getRenderById(unitId);
1619
+ if (currentRender == null)
1620
+ return;
1621
+ const { mainComponent, scene, engine, components } = currentRender, document2 = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
1622
+ return {
1623
+ document: document2,
1624
+ docBackground,
1625
+ scene,
1626
+ engine
1627
+ };
1628
+ }
1629
+ __name(getEditorObject, "getEditorObject");
1630
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1631
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1632
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1633
+ return kind && result && __defProp$3(target, key, result), result;
1634
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
1635
+ let SlideEditorBridgeRenderController = (_a7 = class extends RxDisposable {
1636
+ constructor(_renderContext, _instanceSrv, _commandService, _editorBridgeService) {
1637
+ super();
1638
+ /**
1639
+ * It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
1640
+ */
1641
+ // private _cursorChange: CursorChange = CursorChange.InitialState;
1642
+ /** If the corresponding unit is active and prepared for editing. */
1643
+ // private _isUnitEditing = false;
1644
+ __publicField(this, "setSlideTextEditor$", new Subject());
1645
+ __publicField(this, "_curRichText", null);
1646
+ __publicField(this, "_d");
1647
+ this._renderContext = _renderContext, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
1648
+ slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : this._disposeCurrent();
1649
+ }));
1650
+ }
1651
+ _init() {
1652
+ const d = new DisposableCollection();
1653
+ return this._initEventListener(d), d;
1654
+ }
1655
+ _disposeCurrent() {
1656
+ var _a11;
1657
+ (_a11 = this._d) == null || _a11.dispose(), this._d = null;
1658
+ }
1659
+ _setEditorRect(pageId, targetObject) {
1660
+ this._curRichText = targetObject;
1661
+ const { scene, engine } = this._renderContext, unitId = this._renderContext.unitId, setEditorRect = {
1662
+ scene,
1663
+ engine,
1664
+ unitId,
1665
+ pageId,
1666
+ richTextObj: targetObject
1667
+ };
1668
+ this._editorBridgeService.setEditorRect(setEditorRect);
1669
+ }
1670
+ _initEventListener(d) {
1671
+ const listenersForPageScene = /* @__PURE__ */ __name((scene) => {
1672
+ const transformer = scene.getTransformer();
1673
+ transformer && (d.add(transformer.clearControl$.subscribe(() => {
1674
+ this.setEditorVisible(!1), this.pickOtherObjects();
1675
+ })), d.add(transformer.createControl$.subscribe(() => {
1676
+ this.setEditorVisible(!1);
1677
+ })), d.add(scene.onDblclick$.subscribeEvent(() => {
1678
+ transformer.clearControls();
1679
+ const object = transformer.getSelectedObjectMap().values().next().value;
1680
+ object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(scene.sceneKey, object));
1681
+ })), d.add(this._instanceSrv.focused$.subscribe((fc) => {
1682
+ this.endEditing();
1683
+ })));
1684
+ }, "listenersForPageScene"), { mainComponent } = this._renderContext;
1685
+ mainComponent.subSceneChanged$.subscribeEvent((pageScene) => {
1686
+ listenersForPageScene(pageScene);
1687
+ });
1688
+ const pageSceneList = Array.from(mainComponent.getSubScenes().values());
1689
+ for (let i = 0; i < pageSceneList.length; i++) {
1690
+ const pageScene = pageSceneList[i];
1691
+ listenersForPageScene(pageScene);
1692
+ }
1693
+ }
1694
+ pickOtherObjects() {
1695
+ this.endEditing();
1696
+ }
1697
+ /**
1698
+ * invoked when picking other object.
1699
+ *
1700
+ * save editing state to curr richText.
1701
+ */
1702
+ endEditing() {
1703
+ var _a11;
1704
+ if (!this._curRichText) return;
1705
+ this.setEditorVisible(!1);
1706
+ const curRichText = this._curRichText;
1707
+ if (!this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) return !1;
1708
+ curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._editorBridgeService.endEditing$.next(curRichText);
1709
+ const richText = {
1710
+ bl: 1,
1711
+ fs: curRichText.fs,
1712
+ text: curRichText.text
1713
+ }, textRuns = (_a11 = curRichText.documentData.body) == null ? void 0 : _a11.textRuns;
1714
+ if (textRuns && textRuns.length) {
1715
+ const ts = textRuns[0].ts;
1716
+ richText.cl = ts == null ? void 0 : ts.cl;
1717
+ }
1718
+ this._commandService.executeCommand(UpdateSlideElementOperation.id, {
1719
+ unitId: this._renderContext.unitId,
1720
+ oKey: curRichText == null ? void 0 : curRichText.oKey,
1721
+ props: {
1722
+ richText
1723
+ }
1724
+ }), this._curRichText = null;
1725
+ }
1726
+ /**
1727
+ * TODO calling twice ????
1728
+ * editingParam derives from RichText object.
1729
+ *
1730
+ * TODO @lumixraku need scale param
1731
+ * @param target
1732
+ */
1733
+ startEditing(pageId, target) {
1734
+ this._setEditorRect(pageId, target), this.setEditorVisible(!0);
1735
+ }
1736
+ setEditorVisible(visible) {
1737
+ var _a11, _b;
1738
+ visible ? (_a11 = this._curRichText) == null || _a11.hide() : (_b = this._curRichText) == null || _b.show();
1739
+ const { unitId } = this._renderContext;
1740
+ this._editorBridgeService.changeVisible({ visible, eventType: DeviceInputEventType.PointerDown, unitId });
1741
+ }
1742
+ }, __name(_a7, "SlideEditorBridgeRenderController"), _a7);
1743
+ SlideEditorBridgeRenderController = __decorateClass$3([
1744
+ __decorateParam$3(1, IUniverInstanceService),
1745
+ __decorateParam$3(2, ICommandService),
1746
+ __decorateParam$3(3, ISlideEditorBridgeService)
1747
+ ], SlideEditorBridgeRenderController);
1748
+ const ActivateSlidePageOperation = {
1749
+ id: "slide.operation.activate-slide",
1750
+ type: CommandType.OPERATION,
1751
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1752
+ var _a11, _b;
1753
+ const unitId = params.unitId, canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).getUnit(unitId), pageId = (_a11 = model == null ? void 0 : model.getActivePage()) == null ? void 0 : _a11.id;
1754
+ if (!pageId) return !1;
1755
+ const page = canvasView.getRenderUnitByPageId(pageId, unitId);
1756
+ if (!page) return !1;
1757
+ const transformer = (_b = page.scene) == null ? void 0 : _b.getTransformer();
1758
+ return transformer && transformer.clearControls(), canvasView.activePage(params.id, unitId), !0;
1759
+ }, "handler")
1760
+ }, AppendSlideOperation = {
1761
+ id: "slide.operation.append-slide",
1762
+ type: CommandType.OPERATION,
1763
+ handler: /* @__PURE__ */ __name((accessor, params) => {
1764
+ const unitId = params.unitId;
1765
+ return accessor.get(IUniverInstanceService).getUnit(unitId) ? (accessor.get(CanvasView).appendPage(unitId), !0) : !1;
1766
+ }, "handler")
1767
+ }, InsertSlideFloatImageCommand = {
1768
+ id: "slide.command.insert-float-image",
1769
+ type: CommandType.COMMAND,
1770
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
1771
+ var _a11;
1772
+ const univerInstanceService = accessor.get(IUniverInstanceService), unitId = (_a11 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) == null ? void 0 : _a11.getUnitId();
1773
+ if (!unitId) return !1;
1774
+ const files = await accessor.get(ILocalFileService).openFile({
1775
+ multiple: !0,
1776
+ accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image2) => `.${image2.replace("image/", "")}`).join(",")
1777
+ });
1778
+ if (files.length !== 1) return !1;
1779
+ const imageParam = await accessor.get(IImageIoService).saveImage(files[0]);
1780
+ if (!imageParam) return !1;
1781
+ const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), slideData = univerInstanceService.getUnit(unitId);
1782
+ if (!slideData) return !1;
1783
+ const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
1784
+ id: imageId,
1785
+ zIndex: maxIndex + 1,
1786
+ left: 0,
1787
+ top: 0,
1788
+ width,
1789
+ height,
1790
+ title: "",
1791
+ description: "",
1792
+ type: PageElementType.IMAGE,
1793
+ image: {
1794
+ imageProperties: {
1795
+ contentUrl: base64Cache,
1796
+ imageSourceType,
1797
+ source,
1798
+ base64Cache,
1799
+ image
1800
+ }
1801
+ }
1802
+ };
1803
+ activePage.pageElements[imageId] = data, slideData.updatePage(activePage.id, activePage);
1804
+ const canvasView = accessor.get(CanvasView), sceneObject = canvasView.createObjectToPage(data, activePage.id, unitId);
1805
+ return sceneObject && canvasView.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
1806
+ }, "handler")
1807
+ }, SlideAddTextCommand = {
1808
+ id: "slide.command.add-text",
1809
+ type: CommandType.COMMAND,
1810
+ handler: /* @__PURE__ */ __name(async (accessor) => {
1811
+ var _a11;
1812
+ const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
1813
+ return await commandService.executeCommand(SlideAddTextOperation.id, { unitId });
1814
+ }, "handler")
1815
+ }, SlideAddTextOperation = {
1816
+ id: "slide.operation.add-text",
1817
+ type: CommandType.OPERATION,
1818
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
1819
+ const unitId = params.unitId, elementId = generateRandomId(6), defaultWidth = 220, defaultheight = 40, left = 230, top = 142, textContent = (params == null ? void 0 : params.text) || "A New Text", slideData = accessor.get(IUniverInstanceService).getUnit(unitId);
1820
+ if (!slideData) return !1;
1821
+ const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 21, elementData = {
1822
+ id: elementId,
1823
+ zIndex: maxIndex + 1,
1824
+ left,
1825
+ top,
1826
+ width: defaultWidth,
1827
+ height: defaultheight,
1828
+ title: "text",
1829
+ description: "",
1830
+ type: PageElementType.TEXT,
1831
+ richText: {
1832
+ text: textContent,
1833
+ fs: 30,
1834
+ cl: {
1835
+ rgb: "rgb(51, 51, 51)"
1836
+ },
1837
+ bl: 1
1838
+ }
1839
+ };
1840
+ activePage.pageElements[elementId] = elementData, slideData.updatePage(activePage.id, activePage);
1841
+ const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(elementData, activePage.id, unitId);
1842
+ return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
1843
+ }, "handler")
1844
+ }, SetSlidePageThumbOperation = {
1845
+ id: "slide.operation.set-slide-page-thumb",
1846
+ type: CommandType.OPERATION,
1847
+ handler: /* @__PURE__ */ __name((accessor, params) => (accessor.get(CanvasView).createThumbs(params.unitId), !0), "handler")
1848
+ }, imagePopupMenu = "univer-image-popup-menu", imagePopupMenuItem = "univer-image-popup-menu-item", imagePopupMenuItemIcon = "univer-image-popup-menu-item-icon", imagePopupMenuItemTitle = "univer-image-popup-menu-item-title", imagePopupMenuItemHide = "univer-image-popup-menu-item-hide", btnContainer = "univer-btn-container", btnContainerExpand = "univer-btn-container-expand", styles$2 = {
1849
+ imagePopupMenu,
1850
+ imagePopupMenuItem,
1851
+ imagePopupMenuItemIcon,
1852
+ imagePopupMenuItemTitle,
1853
+ imagePopupMenuItemHide,
1854
+ btnContainer,
1855
+ btnContainerExpand
1856
+ }, SlideImagePopupMenu = /* @__PURE__ */ __name((props) => {
1857
+ var _a11, _b;
1858
+ const menuItems = (_b = (_a11 = props.popup) == null ? void 0 : _a11.extraProps) == null ? void 0 : _b.menuItems;
1859
+ if (!menuItems)
1860
+ return null;
1861
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
1862
+ setHovered(!0);
1863
+ }, "handleMouseEnter"), handleMouseLeave = /* @__PURE__ */ __name(() => {
1864
+ setHovered(!1);
1865
+ }, "handleMouseLeave"), onVisibleChange = /* @__PURE__ */ __name((visible2) => {
1866
+ setVisible(visible2);
1867
+ }, "onVisibleChange"), handleClick = /* @__PURE__ */ __name((item) => {
1868
+ commandService.executeCommand(item.commandId, item.commandParams), setVisible(!1);
1869
+ }, "handleClick"), showMore = visible || isHovered, availableMenu = menuItems.filter((item) => !item.disable);
1870
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1871
+ "div",
1872
+ {
1873
+ onMouseEnter: handleMouseEnter,
1874
+ onMouseLeave: handleMouseLeave,
1875
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1876
+ Dropdown,
1877
+ {
1878
+ placement: "bottomLeft",
1879
+ trigger: ["click"],
1880
+ overlay: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: styles$2.imagePopupMenu, children: availableMenu.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
1881
+ "li",
1882
+ {
1883
+ onClick: /* @__PURE__ */ __name(() => handleClick(item), "onClick"),
1884
+ className: styles$2.imagePopupMenuItem,
1885
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles$2.imagePopupMenuItemTitle, children: localeService.t(item.label) })
1886
+ },
1887
+ item.index
1888
+ )) }),
1889
+ visible,
1890
+ onVisibleChange,
1891
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1892
+ "div",
1893
+ {
1894
+ className: clsx(styles$2.btnContainer, {
1895
+ [styles$2.btnContainerExpand]: visible
1896
+ }),
1897
+ children: [
1898
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1899
+ Autofill,
1900
+ {
1901
+ style: { color: "#35322B" },
1902
+ extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
1903
+ }
1904
+ ),
1905
+ showMore && /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
1906
+ ]
1907
+ }
1908
+ )
1909
+ }
1910
+ )
1911
+ }
1912
+ );
1913
+ }, "SlideImagePopupMenu"), slideBar = "univer-slide-bar", slideBarContent = "univer-slide-bar-content", slideBarContentHeader = "univer-slide-bar-content-header", slideBarItem = "univer-slide-bar-item", slideBarBox = "univer-slide-bar-box", slideBarItemActive = "univer-slide-bar-item-active", slideAddButton = "univer-slide-add-button", styles$1 = {
1914
+ slideBar,
1915
+ slideBarContent,
1916
+ slideBarContentHeader,
1917
+ slideBarItem,
1918
+ slideBarBox,
1919
+ slideBarItemActive,
1920
+ slideAddButton
1921
+ };
1922
+ function SlideSideBar() {
1923
+ var _a11, _b;
1924
+ const univerInstanceService = useDependency(IUniverInstanceService), commandService = useDependency(ICommandService), renderManagerService = useDependency(IRenderManagerService), localeService = useDependency(LocaleService), slideBarRef = useRef(null), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = currentSlide == null ? void 0 : currentSlide.getPages(), pageOrder = currentSlide == null ? void 0 : currentSlide.getPageOrder();
1925
+ if (!pages || !pageOrder)
1926
+ return null;
1927
+ const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (_a11 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a11.id) != null ? _b : null);
1928
+ useEffect(() => {
1929
+ setDivRefs(slideList.map((_) => React.createRef()));
1930
+ }, [slideList.length]), useEffect(() => {
1931
+ const subscriber = currentSlide == null ? void 0 : currentSlide.activePage$.subscribe((page) => {
1932
+ var _a12;
1933
+ const id = (_a12 = page == null ? void 0 : page.id) != null ? _a12 : null;
1934
+ id && setActivatePageId(id);
1935
+ });
1936
+ return () => {
1937
+ subscriber == null || subscriber.unsubscribe();
1938
+ };
1939
+ }, []), useEffect(() => {
1940
+ divRefs.forEach((ref, index) => {
1941
+ var _a12;
1942
+ if (ref.current) {
1943
+ const slide = slideList[index];
1944
+ (_a12 = renderManagerService.getRenderById(slide.id)) == null || _a12.engine.setContainer(ref.current);
1945
+ }
1946
+ }), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1947
+ }, [divRefs, slideList, renderManagerService, commandService, currentSlide]);
1948
+ const activatePage = useCallback((page) => {
1949
+ commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page, unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1950
+ }, [commandService, currentSlide]), handleAppendSlide = useCallback(() => {
1951
+ commandService.syncExecuteCommand(AppendSlideOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
1952
+ }, [commandService, currentSlide]);
1953
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("aside", { className: styles$1.slideBar, ref: slideBarRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.slideBarContent, children: [
1954
+ /* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: styles$1.slideBarContentHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: handleAppendSlide, children: localeService.t("slide.append") }) }),
1955
+ slideList.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1956
+ "div",
1957
+ {
1958
+ className: clsx(styles$1.slideBarItem, {
1959
+ [styles$1.slideBarItemActive]: item.id === activatePageId
1960
+ }),
1961
+ onClick: /* @__PURE__ */ __name(() => activatePage(item.id), "onClick"),
1962
+ children: [
1963
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: index + 1 }),
1964
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: divRefs[index], className: styles$1.slideBarBox })
1965
+ ]
1966
+ },
1967
+ item.id
1968
+ ))
1969
+ ] }) }) });
1970
+ }
1971
+ __name(SlideSideBar, "SlideSideBar");
1972
+ const slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles = {
1973
+ slideEditorContainer,
1974
+ editorInput
1975
+ }, HIDDEN_EDITOR_POSITION = -1e3, EDITOR_DEFAULT_POSITION = {
1976
+ width: 0,
1977
+ height: 0,
1978
+ top: HIDDEN_EDITOR_POSITION,
1979
+ left: HIDDEN_EDITOR_POSITION
1980
+ }, SlideEditorContainer = /* @__PURE__ */ __name(() => {
1981
+ const [state, setState] = useState({
1982
+ ...EDITOR_DEFAULT_POSITION
1983
+ }), slideEditorManagerService = useDependency(ISlideEditorManagerService), editorService = useDependency(IEditorService), contextService = useDependency(IContextService), disableAutoFocus = useObservable(
1984
+ () => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY),
1985
+ !1,
1986
+ void 0,
1987
+ [contextService, DISABLE_AUTO_FOCUS_KEY]
1988
+ ), snapshot = {
1989
+ id: SLIDE_EDITOR_ID,
1990
+ body: {
1991
+ dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
1992
+ textRuns: [],
1993
+ paragraphs: [
1994
+ {
1995
+ startIndex: 0
1996
+ }
1997
+ ]
1998
+ },
1999
+ documentStyle: {
2000
+ documentFlavor: DocumentFlavor.MODERN
2001
+ }
2002
+ };
2003
+ return useEffect(() => {
2004
+ slideEditorManagerService.state$.subscribe((param) => {
2005
+ if (param == null)
2006
+ return;
2007
+ const {
2008
+ startX = HIDDEN_EDITOR_POSITION,
2009
+ startY = HIDDEN_EDITOR_POSITION,
2010
+ endX = 0,
2011
+ endY = 0,
2012
+ show = !1
2013
+ } = param;
2014
+ if (!show)
2015
+ setState({
2016
+ ...EDITOR_DEFAULT_POSITION
2017
+ });
2018
+ else {
2019
+ setState({
2020
+ width: endX - startX - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
2021
+ height: endY - startY - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
2022
+ left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
2023
+ top: startY + FIX_ONE_PIXEL_BLUR_OFFSET
2024
+ });
2025
+ const editor = editorService.getEditor(SLIDE_EDITOR_ID);
2026
+ if (editor == null)
2027
+ return;
2028
+ const { left, top, width, height } = editor.getBoundingClientRect();
2029
+ slideEditorManagerService.setRect({ left, top, width, height });
2030
+ }
2031
+ });
2032
+ }, []), useEffect(() => {
2033
+ disableAutoFocus || slideEditorManagerService.setFocus(!0);
2034
+ }, [disableAutoFocus, state]), /* @__PURE__ */ jsxRuntimeExports.jsx(
2035
+ "div",
2036
+ {
2037
+ className: styles.slideEditorContainer,
2038
+ style: {
2039
+ left: state.left,
2040
+ top: state.top,
2041
+ width: state.width,
2042
+ height: state.height
2043
+ },
2044
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2045
+ TextEditor,
2046
+ {
2047
+ id: SLIDE_EDITOR_ID,
2048
+ className: styles.editorInput,
2049
+ snapshot,
2050
+ cancelDefaultResizeListener: !1,
2051
+ isSheetEditor: !1,
2052
+ isSingle: !1
2053
+ }
2054
+ )
2055
+ }
2056
+ );
2057
+ }, "SlideEditorContainer"), IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "slide.menu.image";
2058
+ function SlideImageMenuFactory(accessor) {
2059
+ return {
2060
+ id: IMAGE_MENU_ID,
2061
+ type: MenuItemType.SUBITEMS,
2062
+ icon: IMAGE_UPLOAD_ICON,
2063
+ tooltip: "slide.image.insert.title",
2064
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
2065
+ };
2066
+ }
2067
+ __name(SlideImageMenuFactory, "SlideImageMenuFactory");
2068
+ function UploadSlideFloatImageMenuFactory(_accessor) {
2069
+ return {
2070
+ id: InsertSlideFloatImageCommand.id,
2071
+ title: "slide.image.insert.float",
2072
+ type: MenuItemType.BUTTON,
2073
+ hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
2074
+ };
2075
+ }
2076
+ __name(UploadSlideFloatImageMenuFactory, "UploadSlideFloatImageMenuFactory");
2077
+ const TEXT_ICON_ID = "text-single";
2078
+ function SlideAddTextMenuItemFactory(_accessor) {
2079
+ return {
2080
+ id: SlideAddTextCommand.id,
2081
+ type: MenuItemType.BUTTON,
2082
+ icon: TEXT_ICON_ID,
2083
+ tooltip: "slide.text.insert.title",
2084
+ hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
2085
+ };
2086
+ }
2087
+ __name(SlideAddTextMenuItemFactory, "SlideAddTextMenuItemFactory");
2088
+ const GRAPH_SINGLE_ICON = "graph-single", SHAPE_MENU_ID = "slide.menu.shape";
2089
+ function SlideShapeMenuFactory(accessor) {
2090
+ return {
2091
+ id: SHAPE_MENU_ID,
2092
+ type: MenuItemType.SUBITEMS,
2093
+ icon: GRAPH_SINGLE_ICON,
2094
+ tooltip: "slide.shape.insert.title",
2095
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
2096
+ // disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
2097
+ };
2098
+ }
2099
+ __name(SlideShapeMenuFactory, "SlideShapeMenuFactory");
2100
+ function UploadSlideFloatShapeMenuFactory(_accessor) {
2101
+ return {
2102
+ id: InsertSlideShapeRectangleCommand.id,
2103
+ title: "slide.shape.insert.rectangle",
2104
+ type: MenuItemType.BUTTON,
2105
+ hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
2106
+ };
2107
+ }
2108
+ __name(UploadSlideFloatShapeMenuFactory, "UploadSlideFloatShapeMenuFactory");
2109
+ const menuSchema = {
2110
+ [RibbonStartGroup.FORMAT]: {
2111
+ [SlideAddTextCommand.id]: {
2112
+ order: 0,
2113
+ menuItemFactory: SlideAddTextMenuItemFactory
2114
+ },
2115
+ [IMAGE_MENU_ID]: {
2116
+ order: 0,
2117
+ menuItemFactory: SlideImageMenuFactory,
2118
+ [InsertSlideFloatImageCommand.id]: {
2119
+ order: 0,
2120
+ menuItemFactory: UploadSlideFloatImageMenuFactory
2121
+ }
2122
+ },
2123
+ [SHAPE_MENU_ID]: {
2124
+ order: 0,
2125
+ menuItemFactory: SlideShapeMenuFactory,
2126
+ [InsertSlideShapeRectangleCommand.id]: {
2127
+ order: 0,
2128
+ menuItemFactory: UploadSlideFloatShapeMenuFactory
2113
2129
  }
2114
- ]), body.sectionBreaks != null && (body.sectionBreaks = void 0), body.tables != null && (body.tables = void 0), body.customRanges != null && (body.customRanges = void 0), body.customBlocks != null && (body.customBlocks = void 0);
2115
- }
2116
- /**
2117
- * Should activate the editor when the user inputs text.
2118
- * @param d DisposableCollection
2119
- */
2120
- _initialKeyboardListener(d) {
2121
- }
2122
- _showEditorByKeyboard(config) {
2123
- }
2124
- _commandExecutedListener(d) {
2125
- const moveCursorOP = [SetTextEditArrowOperation.id], editedMutations = [RichTextEditingMutation.id];
2126
- d.add(this._commandService.onCommandExecuted((command) => {
2127
- this._editorService.getFocusId() === SLIDE_EDITOR_ID && (moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editorBridgeService.isVisible() && this._editingChangedHandler());
2128
- }));
2129
- }
2130
- _moveCursorCmdHandler(command) {
2131
- const params = command.params, { keycode, isShift } = params;
2132
- keycode != null && this._cursorChange === CursorChange.CursorChange ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
2133
- }
2134
- _editingChangedHandler() {
2135
- const editRect = this._editorBridgeService.getEditorRect();
2136
- if (!editRect)
2137
- return;
2138
- const editingRichText = editRect.richTextObj;
2139
- editingRichText.refreshDocumentByDocData(), editingRichText.resizeToContentSize();
2140
- const { unitId } = this._renderContext;
2141
- this._handleEditorVisible({ visible: !0, eventType: 3, unitId });
2142
- }
2143
- _setOpenForCurrent(unitId, subUnitId) {
2144
- const editors = this._editorService.getAllEditor();
2145
- for (const [_, ed] of editors)
2146
- ed.setOpenForSheetUnitId(unitId), ed.setOpenForSheetSubUnitId(subUnitId);
2147
- }
2148
- _getEditorObject() {
2149
- return getEditorObject(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
2150
- }
2151
- async _handleEditorInvisible(param) {
2152
- const { keycode } = param;
2153
- if (this._setOpenForCurrent(null, null), this._cursorChange = CursorChange.InitialState, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
2154
- return;
2155
- if (this._editorBridgeService.getEditorDirty() === !1) {
2156
- this._moveCursor(keycode);
2157
- return;
2158
2130
  }
2159
- this._moveCursor(keycode);
2160
2131
  }
2161
- _exitInput(param) {
2162
- this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
2163
- show: param.visible
2132
+ };
2133
+ function whenEditorActivated(contextService) {
2134
+ return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED);
2135
+ }
2136
+ __name(whenEditorActivated, "whenEditorActivated");
2137
+ function whenFormulaEditorFocused(contextService) {
2138
+ return contextService.getContextValue(FORMULA_EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR);
2139
+ }
2140
+ __name(whenFormulaEditorFocused, "whenFormulaEditorFocused");
2141
+ const ARROW_SELECTION_KEYCODE_LIST = [
2142
+ KeyCode.ARROW_DOWN,
2143
+ KeyCode.ARROW_UP,
2144
+ KeyCode.ARROW_LEFT,
2145
+ KeyCode.ARROW_RIGHT
2146
+ ];
2147
+ [KeyCode.ENTER, KeyCode.TAB, ...ARROW_SELECTION_KEYCODE_LIST];
2148
+ function generateArrowSelectionShortCutItem() {
2149
+ const shortcutList = [];
2150
+ for (const keycode of ARROW_SELECTION_KEYCODE_LIST)
2151
+ shortcutList.push({
2152
+ id: SetTextEditArrowOperation.id,
2153
+ binding: keycode,
2154
+ preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
2155
+ staticParameters: {
2156
+ visible: !1,
2157
+ eventType: DeviceInputEventType.Keyboard,
2158
+ keycode,
2159
+ isShift: !1
2160
+ }
2161
+ }), shortcutList.push({
2162
+ id: SetTextEditArrowOperation.id,
2163
+ binding: keycode | MetaKeys.SHIFT,
2164
+ preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
2165
+ staticParameters: {
2166
+ visible: !1,
2167
+ eventType: DeviceInputEventType.Keyboard,
2168
+ keycode,
2169
+ isShift: !0
2170
+ }
2164
2171
  });
2165
- const editorUnitId = this._editorBridgeService.getCurrentEditorId();
2166
- editorUnitId != null && this._undoRedoService.clearUndoRedo(editorUnitId);
2172
+ return shortcutList;
2173
+ }
2174
+ __name(generateArrowSelectionShortCutItem, "generateArrowSelectionShortCutItem");
2175
+ const EditorDeleteLeftShortcut = {
2176
+ id: DeleteLeftCommand.id,
2177
+ preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService), "preconditions"),
2178
+ binding: KeyCode.BACKSPACE
2179
+ };
2180
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2181
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2182
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2183
+ return kind && result && __defProp$2(target, key, result), result;
2184
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a8;
2185
+ let SlidesUIController = (_a8 = class extends Disposable {
2186
+ constructor(_injector, _menuManagerService, _componentManager, _uiPartsService, _commandService, _shortcutService) {
2187
+ super(), this._injector = _injector, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._uiPartsService = _uiPartsService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._initCommands(), this._initCustomComponents(), this._initUIComponents(), this._initMenus(), this._initShortcuts();
2167
2188
  }
2168
- _moveCursor(keycode) {
2169
- if (keycode != null)
2170
- switch (Direction.LEFT, keycode) {
2171
- case KeyCode.ENTER:
2172
- Direction.DOWN;
2173
- break;
2174
- case KeyCode.TAB:
2175
- Direction.RIGHT;
2176
- break;
2177
- case KeyCode.ARROW_DOWN:
2178
- Direction.DOWN;
2179
- break;
2180
- case KeyCode.ARROW_UP:
2181
- Direction.UP;
2182
- break;
2183
- case KeyCode.ARROW_LEFT:
2184
- Direction.LEFT;
2185
- break;
2186
- case KeyCode.ARROW_RIGHT:
2187
- Direction.RIGHT;
2188
- break;
2189
- }
2189
+ _initMenus() {
2190
+ this._menuManagerService.mergeMenu(menuSchema);
2190
2191
  }
2191
- /**
2192
- * The user's operations follow the sequence of opening the editor and then moving the cursor.
2193
- * The logic here predicts the user's first cursor movement behavior based on this rule
2194
- */
2195
- _cursorStateListener(d) {
2196
- const editorObject = this._getEditorObject(), { document: documentComponent } = editorObject;
2197
- d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
2198
- this._cursorChange === CursorChange.StartEditor && (this._cursorChange = CursorChange.CursorChange);
2199
- })));
2192
+ _initCustomComponents() {
2193
+ const componentManager = this._componentManager;
2194
+ this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(TEXT_ICON_ID, TextSingle)), this.disposeWithMe(componentManager.register(GRAPH_SINGLE_ICON, GraphSingle)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_IMAGE_POPUP_MENU, SlideImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_SIDEBAR, RectSidebar));
2200
2195
  }
2201
- // TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
2202
- _moveInEditor(keycode, isShift) {
2203
- let direction = Direction.LEFT;
2204
- keycode === KeyCode.ARROW_DOWN ? direction = Direction.DOWN : keycode === KeyCode.ARROW_UP ? direction = Direction.UP : keycode === KeyCode.ARROW_RIGHT && (direction = Direction.RIGHT), isShift ? this._commandService.executeCommand(MoveSelectionOperation.id, {
2205
- direction
2206
- }) : this._commandService.executeCommand(MoveCursorOperation.id, {
2207
- direction
2196
+ _initCommands() {
2197
+ [
2198
+ AppendSlideOperation,
2199
+ ActivateSlidePageOperation,
2200
+ SetSlidePageThumbOperation,
2201
+ InsertSlideFloatImageCommand,
2202
+ SlideAddTextOperation,
2203
+ SlideAddTextCommand,
2204
+ InsertSlideShapeRectangleOperation,
2205
+ InsertSlideShapeRectangleCommand,
2206
+ ToggleSlideEditSidebarOperation,
2207
+ DeleteSlideElementOperation,
2208
+ UpdateSlideElementOperation,
2209
+ // commands for editor
2210
+ SetTextEditArrowOperation
2211
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
2212
+ }
2213
+ _initUIComponents() {
2214
+ this.disposeWithMe(
2215
+ this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
2216
+ ), this.disposeWithMe(
2217
+ this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector))
2218
+ );
2219
+ }
2220
+ _initShortcuts() {
2221
+ [
2222
+ EditorDeleteLeftShortcut,
2223
+ ...generateArrowSelectionShortCutItem()
2224
+ ].forEach((item) => {
2225
+ this.disposeWithMe(this._shortcutService.registerShortcut(item));
2208
2226
  });
2209
2227
  }
2210
- }, __name(_a8, "SlideEditingRenderController"), _a8);
2211
- SlideEditingRenderController = __decorateClass$2([
2212
- __decorateParam$2(1, ILayoutService),
2213
- __decorateParam$2(2, IUndoRedoService),
2214
- __decorateParam$2(3, IContextService),
2215
- __decorateParam$2(4, IUniverInstanceService),
2216
- __decorateParam$2(5, IRenderManagerService),
2217
- __decorateParam$2(6, ISlideEditorBridgeService),
2218
- __decorateParam$2(7, ISlideEditorManagerService),
2219
- __decorateParam$2(8, Inject(DocSelectionManagerService)),
2220
- __decorateParam$2(9, ICommandService),
2221
- __decorateParam$2(10, Inject(LocaleService)),
2222
- __decorateParam$2(11, IEditorService)
2223
- ], SlideEditingRenderController);
2224
- function getEditorObject(unitId, renderManagerService) {
2225
- if (unitId == null)
2226
- return;
2227
- const currentRender = renderManagerService.getRenderById(unitId);
2228
- if (currentRender == null)
2229
- return;
2230
- const { mainComponent, scene, engine, components } = currentRender, document2 = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
2231
- return {
2232
- document: document2,
2233
- docBackground,
2234
- scene,
2235
- engine
2236
- };
2237
- }
2238
- __name(getEditorObject, "getEditorObject");
2228
+ }, __name(_a8, "SlidesUIController"), _a8);
2229
+ SlidesUIController = __decorateClass$2([
2230
+ __decorateParam$2(0, Inject(Injector)),
2231
+ __decorateParam$2(1, IMenuManagerService),
2232
+ __decorateParam$2(2, Inject(ComponentManager)),
2233
+ __decorateParam$2(3, IUIPartsService),
2234
+ __decorateParam$2(4, ICommandService),
2235
+ __decorateParam$2(5, IShortcutService)
2236
+ ], SlidesUIController);
2239
2237
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2240
2238
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2241
2239
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -2267,12 +2265,10 @@ let SlideRenderService = (_a9 = class extends RxDisposable {
2267
2265
  }
2268
2266
  }, __name(_a9, "SlideRenderService"), _a9);
2269
2267
  SlideRenderService = __decorateClass$1([
2270
- OnLifecycle(LifecycleStages.Ready, SlideRenderService),
2271
2268
  __decorateParam$1(0, IContextService),
2272
2269
  __decorateParam$1(1, IUniverInstanceService),
2273
2270
  __decorateParam$1(2, IRenderManagerService)
2274
2271
  ], SlideRenderService);
2275
- const PLUGIN_CONFIG_KEY = "slides-ui.config", defaultPluginConfig = {};
2276
2272
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2277
2273
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2278
2274
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -2315,7 +2311,7 @@ let UniverSlidesUIPlugin = (_a10 = class extends Plugin {
2315
2311
  [SlidePopupMenuController]
2316
2312
  ], this._config.override).forEach((m2) => {
2317
2313
  this._injector.add(m2);
2318
- }), this._injector.get(CanvasView);
2314
+ }), this._injector.get(CanvasView), this._injector.get(SlideRenderService);
2319
2315
  }
2320
2316
  onRendered() {
2321
2317
  [
@@ -2325,7 +2321,10 @@ let UniverSlidesUIPlugin = (_a10 = class extends Plugin {
2325
2321
  [SlideEditingRenderController]
2326
2322
  ].forEach((m2) => {
2327
2323
  this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m2));
2328
- }), this._markSlideAsFocused();
2324
+ }), this._markSlideAsFocused(), this._injector.get(SlidesUIController);
2325
+ }
2326
+ onSteady() {
2327
+ this._injector.get(SlidePopupMenuController);
2329
2328
  }
2330
2329
  _markSlideAsFocused() {
2331
2330
  const currentService = this._univerInstanceService;