@univerjs/slides-ui 0.2.4 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +3 -2
- package/lib/es/index.js +1963 -122
- package/lib/index.css +1 -1
- package/lib/locale/en-US.json +33 -3
- package/lib/locale/ru-RU.json +33 -3
- package/lib/locale/vi-VN.json +33 -3
- package/lib/locale/zh-CN.json +33 -3
- package/lib/locale/zh-TW.json +33 -3
- package/lib/types/commands/operations/append-slide.operation.d.ts +3 -0
- package/lib/types/commands/operations/delete-element.operation.d.ts +6 -0
- package/lib/types/commands/operations/insert-image.operation.d.ts +6 -0
- package/lib/types/commands/operations/insert-shape.operation.d.ts +11 -0
- package/lib/types/commands/operations/insert-text.operation.d.ts +6 -0
- package/lib/types/commands/operations/text-edit.operation.d.ts +3 -0
- package/lib/types/commands/operations/update-element.operation.d.ts +7 -0
- package/lib/types/components/image-popup-menu/ImagePopupMenu.d.ts +19 -0
- package/lib/types/components/image-popup-menu/component-name.d.ts +16 -0
- package/lib/types/components/panels/ArrangePanel.d.ts +7 -0
- package/lib/types/components/panels/FillPanel.d.ts +7 -0
- package/lib/types/components/panels/TransformPanel.d.ts +7 -0
- package/lib/types/components/sidebar/Sidebar.d.ts +4 -0
- package/lib/types/components/upload-component/UploadFile.d.ts +9 -0
- package/lib/types/components/upload-component/component-name.d.ts +20 -0
- package/lib/types/controllers/image.menu.d.ts +7 -0
- package/lib/types/controllers/popup-menu.controller.d.ts +23 -0
- package/lib/types/controllers/shape.menu.d.ts +7 -0
- package/lib/types/controllers/shortcuts/editor.shortcuts.d.ts +6 -0
- package/lib/types/controllers/shortcuts/utils.d.ts +35 -0
- package/lib/types/controllers/slide-editing.render-controller.d.ts +108 -0
- package/lib/types/controllers/slide-editor-bridge.render-controller.d.ts +47 -0
- package/lib/types/controllers/slide-ui.controller.d.ts +20 -9
- package/lib/types/controllers/slide.render-controller.d.ts +10 -0
- package/lib/types/controllers/text.menu.d.ts +5 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/locale/zh-CN.d.ts +33 -3
- package/lib/types/services/slide-editor-bridge.service.d.ts +94 -0
- package/lib/types/services/slide-editor-manager.service.d.ts +42 -0
- package/lib/types/services/slide-popup-manager.service.d.ts +22 -0
- package/lib/types/slides-ui-plugin.d.ts +8 -4
- package/lib/types/type.d.ts +31 -0
- package/lib/types/views/editor-container/EditorContainer.d.ts +10 -0
- package/lib/types/views/editor-container/index.d.ts +16 -0
- package/lib/umd/index.js +3 -2
- package/package.json +23 -17
- /package/lib/types/{views → components}/slide-bar/SlideBar.d.ts +0 -0
package/lib/es/index.js
CHANGED
|
@@ -1,16 +1,201 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { CommandType, IUniverInstanceService, UniverInstanceType, PageElementType, Tools, useDependency, LocaleService, ICommandService, generateRandomId, BasicShapes, createIdentifier, IContextService, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, FOCUSING_UNIVER_EDITOR, EDITOR_ACTIVATED, FORMULA_EDITOR_ACTIVATED, Disposable, connectInjector, OnLifecycle, LifecycleStages, Inject, Injector, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, DocumentDataModel, VerticalAlign, HorizontalAlign, RxDisposable, DisposableCollection, toDisposable, FOCUSING_COMMON_DRAWINGS, WrapStrategy, FOCUSING_EDITOR_BUT_HIDDEN, FOCUSING_EDITOR_INPUT_FORMULA, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, Direction, IUndoRedoService, IResourceLoaderService, Plugin, mergeOverrideWithDependencies } from "@univerjs/core";
|
|
6
|
+
import { ObjectType, FIX_ONE_PIXEL_BLUR_OFFSET, IRenderManagerService, DeviceInputEventType, pxToNum, ITextSelectionRenderManager, convertTextRotation, ScrollBar, fixLineWidthByScale, Rect } from "@univerjs/engine-render";
|
|
7
|
+
import { ISidebarService, IEditorService, useObservable, DISABLE_AUTO_FOCUS_KEY, TextEditor, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, MetaKeys, BuiltInUIPart, ComponentManager, IMenuService, IUIPartsService, IShortcutService, ICanvasPopupService, ILayoutService } from "@univerjs/ui";
|
|
8
|
+
import { CanvasView, SLIDE_KEY } from "@univerjs/slides";
|
|
9
|
+
import { IImageIoService, getImageSize, DRAWING_IMAGE_ALLOW_IMAGE_LIST } from "@univerjs/drawing";
|
|
10
|
+
import React, { forwardRef, useRef, createElement, useState, useEffect, useCallback } from "react";
|
|
11
|
+
import clsx from "clsx";
|
|
12
|
+
import { Button, InputNumber, Dropdown, ColorPicker, Scrollbar } from "@univerjs/design";
|
|
13
|
+
import { DeleteLeftCommand, TextSelectionManagerService, DocSkeletonManagerService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, RichTextEditingMutation, MoveSelectionOperation, MoveCursorOperation, DOCS_VIEW_KEY } from "@univerjs/docs";
|
|
14
|
+
import { BehaviorSubject, Subject, filter } from "rxjs";
|
|
15
|
+
var __assign = function() {
|
|
16
|
+
return __assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
}, __assign.apply(this, arguments);
|
|
23
|
+
}, __rest = function(s, e) {
|
|
24
|
+
var t = {};
|
|
25
|
+
for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
|
|
26
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
27
|
+
for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
|
|
28
|
+
e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
|
|
29
|
+
return t;
|
|
30
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
31
|
+
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()));
|
|
32
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
33
|
+
});
|
|
34
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
35
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
36
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
__name(render, "render");
|
|
40
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
41
|
+
var attrs = __assign({}, node.attrs);
|
|
42
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
43
|
+
var defIds = runtimeProps.defIds;
|
|
44
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a9) {
|
|
45
|
+
var key = _a9[0], value = _a9[1];
|
|
46
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
47
|
+
})), attrs;
|
|
48
|
+
}
|
|
49
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
50
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
51
|
+
var _a9, defIds = runtimeProps.defIds;
|
|
52
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a9 = node.children) === null || _a9 === void 0) && _a9.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
53
|
+
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;
|
|
54
|
+
}) }) : node;
|
|
55
|
+
}
|
|
56
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
57
|
+
function generateShortUuid() {
|
|
58
|
+
return Math.random().toString(36).substring(2, 8);
|
|
59
|
+
}
|
|
60
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
61
|
+
IconBase.displayName = "UniverIcon";
|
|
62
|
+
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) {
|
|
63
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
64
|
+
id: "add-image-single",
|
|
65
|
+
ref,
|
|
66
|
+
icon: element$9
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
AddImageSingle.displayName = "AddImageSingle";
|
|
70
|
+
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) {
|
|
71
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
72
|
+
id: "autofill",
|
|
73
|
+
ref,
|
|
74
|
+
icon: element$8
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
Autofill.displayName = "Autofill";
|
|
78
|
+
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) {
|
|
79
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
80
|
+
id: "bottom-single",
|
|
81
|
+
ref,
|
|
82
|
+
icon: element$7
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
BottomSingle.displayName = "BottomSingle";
|
|
86
|
+
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) {
|
|
87
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
88
|
+
id: "graph-single",
|
|
89
|
+
ref,
|
|
90
|
+
icon: element$6
|
|
91
|
+
}));
|
|
92
|
+
});
|
|
93
|
+
GraphSingle.displayName = "GraphSingle";
|
|
94
|
+
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) {
|
|
95
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
96
|
+
id: "more-down-single",
|
|
97
|
+
ref,
|
|
98
|
+
icon: element$5
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
MoreDownSingle.displayName = "MoreDownSingle";
|
|
102
|
+
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) {
|
|
103
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
104
|
+
id: "move-down-single",
|
|
105
|
+
ref,
|
|
106
|
+
icon: element$4
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
MoveDownSingle.displayName = "MoveDownSingle";
|
|
110
|
+
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) {
|
|
111
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
112
|
+
id: "move-up-single",
|
|
113
|
+
ref,
|
|
114
|
+
icon: element$3
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
MoveUpSingle.displayName = "MoveUpSingle";
|
|
118
|
+
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) {
|
|
119
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
120
|
+
id: "paint-bucket",
|
|
121
|
+
ref,
|
|
122
|
+
icon: element$2
|
|
123
|
+
}));
|
|
124
|
+
});
|
|
125
|
+
PaintBucket.displayName = "PaintBucket";
|
|
126
|
+
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) {
|
|
127
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
128
|
+
id: "text-single",
|
|
129
|
+
ref,
|
|
130
|
+
icon: element$1
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
TextSingle.displayName = "TextSingle";
|
|
134
|
+
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) {
|
|
135
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
136
|
+
id: "topmost-single",
|
|
137
|
+
ref,
|
|
138
|
+
icon: element
|
|
139
|
+
}));
|
|
140
|
+
});
|
|
141
|
+
TopmostSingle.displayName = "TopmostSingle";
|
|
142
|
+
const ActivateSlidePageOperation = {
|
|
143
|
+
id: "slide.operation.activate-slide",
|
|
144
|
+
type: CommandType.OPERATION,
|
|
145
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
146
|
+
var _a9, _b;
|
|
147
|
+
const canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), id = (_a9 = model == null ? void 0 : model.getActivePage()) == null ? void 0 : _a9.id;
|
|
148
|
+
if (!id) return !1;
|
|
149
|
+
const transformer = (_b = canvasView.getRenderUnitByPageId(id).scene) == null ? void 0 : _b.getTransformer();
|
|
150
|
+
return transformer && transformer.clearControls(), canvasView.activePage(params.id), !0;
|
|
151
|
+
}, "handler")
|
|
152
|
+
}, DeleteSlideElementOperation = {
|
|
153
|
+
id: "slide.operation.delete-element",
|
|
154
|
+
type: CommandType.OPERATION,
|
|
155
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
156
|
+
if (!(params != null && params.id)) return !1;
|
|
157
|
+
const slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
158
|
+
if (!slideData) return !1;
|
|
159
|
+
const activePage = slideData.getActivePage();
|
|
160
|
+
return delete activePage.pageElements[params.id], slideData.updatePage(activePage.id, activePage), accessor.get(CanvasView).removeObjectById(params.id, activePage.id), !0;
|
|
161
|
+
}, "handler")
|
|
162
|
+
}, InsertSlideFloatImageOperation = {
|
|
163
|
+
id: "slide.operation.insert-float-image",
|
|
164
|
+
type: CommandType.OPERATION,
|
|
165
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
166
|
+
var _a9;
|
|
167
|
+
const imageIoService = accessor.get(IImageIoService);
|
|
168
|
+
if (!((_a9 = params == null ? void 0 : params.files) != null && _a9.length)) return !1;
|
|
169
|
+
const imageParam = await imageIoService.saveImage(params.files[0]);
|
|
170
|
+
if (!imageParam) return !1;
|
|
171
|
+
const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), data = {
|
|
172
|
+
id: imageId,
|
|
173
|
+
zIndex: 20,
|
|
174
|
+
left: 0,
|
|
175
|
+
top: 0,
|
|
176
|
+
width,
|
|
177
|
+
height,
|
|
178
|
+
title: "",
|
|
179
|
+
description: "",
|
|
180
|
+
type: PageElementType.IMAGE,
|
|
181
|
+
image: {
|
|
182
|
+
imageProperties: {
|
|
183
|
+
contentUrl: base64Cache,
|
|
184
|
+
imageSourceType,
|
|
185
|
+
source,
|
|
186
|
+
base64Cache,
|
|
187
|
+
image
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
191
|
+
if (!slideData) return !1;
|
|
192
|
+
const activePage = slideData.getActivePage();
|
|
193
|
+
activePage.pageElements[imageId] = data, slideData.updatePage(activePage.id, activePage);
|
|
194
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id);
|
|
195
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id), !0;
|
|
196
|
+
}, "handler")
|
|
197
|
+
};
|
|
198
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
14
199
|
/**
|
|
15
200
|
* @license React
|
|
16
201
|
* react-jsx-runtime.production.min.js
|
|
@@ -20,137 +205,1793 @@ var N = { exports: {} }, f = {};
|
|
|
20
205
|
* This source code is licensed under the MIT license found in the
|
|
21
206
|
* LICENSE file in the root directory of this source tree.
|
|
22
207
|
*/
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
for (
|
|
28
|
-
if (
|
|
29
|
-
return { $$typeof:
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
208
|
+
var f = React, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
209
|
+
function q(c, a, g) {
|
|
210
|
+
var b, d = {}, e = null, h = null;
|
|
211
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
212
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
213
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
214
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
215
|
+
}
|
|
216
|
+
__name(q, "q");
|
|
217
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
218
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
219
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
220
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
221
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
222
|
+
const UpdateSlideElementOperation = {
|
|
223
|
+
id: "slide.operation.update-element",
|
|
224
|
+
type: CommandType.OPERATION,
|
|
225
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
226
|
+
const { oKey, props } = params, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
227
|
+
if (!slideData) return !1;
|
|
228
|
+
const activePage = slideData.getActivePage();
|
|
229
|
+
return activePage.pageElements[oKey] = Tools.deepMerge(activePage.pageElements[oKey], props), slideData.updatePage(activePage.id, activePage), !0;
|
|
230
|
+
}, "handler")
|
|
231
|
+
}, 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$5 = {
|
|
232
|
+
imageCommonPanel: imageCommonPanel$1,
|
|
233
|
+
imageCommonPanelGrid: imageCommonPanelGrid$1,
|
|
234
|
+
imageCommonPanelBorder: imageCommonPanelBorder$1,
|
|
235
|
+
imageCommonPanelTitle: imageCommonPanelTitle$1,
|
|
236
|
+
imageCommonPanelSubtitle: imageCommonPanelSubtitle$1,
|
|
237
|
+
imageCommonPanelRow: imageCommonPanelRow$1,
|
|
238
|
+
imageCommonPanelRowVertical: imageCommonPanelRowVertical$1,
|
|
239
|
+
imageCommonPanelColumn: imageCommonPanelColumn$1,
|
|
240
|
+
imageCommonPanelColumnCenter: imageCommonPanelColumnCenter$1,
|
|
241
|
+
imageCommonPanelInline: imageCommonPanelInline$1,
|
|
242
|
+
imageCommonPanelSpan2: imageCommonPanelSpan2$1,
|
|
243
|
+
imageCommonPanelSpan3: imageCommonPanelSpan3$1,
|
|
244
|
+
imageCommonPanelInput: imageCommonPanelInput$1,
|
|
245
|
+
slidePanelColorPicker
|
|
51
246
|
};
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
247
|
+
function ArrangePanel$1(props) {
|
|
248
|
+
const { unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(unitId), scene = page == null ? void 0 : page.scene;
|
|
249
|
+
if (!scene) return null;
|
|
250
|
+
const transformer = scene.getTransformer();
|
|
251
|
+
if (!transformer) return null;
|
|
252
|
+
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
253
|
+
if (!object) return null;
|
|
254
|
+
const onArrangeBtnClick = /* @__PURE__ */ __name((arrangeType) => {
|
|
255
|
+
const allObjects = scene.getAllObjects(), [minZIndex, maxZIndex] = allObjects.reduce(([min, max], obj) => {
|
|
256
|
+
const zIndex2 = obj.zIndex, minZIndex2 = zIndex2 < min ? zIndex2 : min, maxZIndex2 = zIndex2 > max ? zIndex2 : max;
|
|
257
|
+
return [minZIndex2, maxZIndex2];
|
|
258
|
+
}, [0, 0]);
|
|
259
|
+
let zIndex = object.zIndex;
|
|
260
|
+
arrangeType === 3 ? zIndex = minZIndex - 1 : arrangeType === 2 ? zIndex = maxZIndex + 1 : arrangeType === 0 ? zIndex = object.zIndex + 1 : arrangeType === 1 && (zIndex = object.zIndex - 1), object.setProps({
|
|
261
|
+
zIndex
|
|
262
|
+
}), commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
263
|
+
oKey: object == null ? void 0 : object.oKey,
|
|
264
|
+
props: {
|
|
265
|
+
zIndex
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}, "onArrangeBtnClick");
|
|
269
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelGrid, children: [
|
|
270
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelTitle), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t("image-panel.arrange.title") }) }) }),
|
|
271
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelRow, children: [
|
|
272
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
|
|
273
|
+
onArrangeBtnClick(
|
|
274
|
+
0
|
|
275
|
+
/* forward */
|
|
276
|
+
);
|
|
277
|
+
}, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$5.imageCommonPanelInline, children: [
|
|
278
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MoveUpSingle, {}),
|
|
279
|
+
localeService.t("image-panel.arrange.forward")
|
|
280
|
+
] }) }) }),
|
|
281
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
|
|
282
|
+
onArrangeBtnClick(
|
|
283
|
+
1
|
|
284
|
+
/* backward */
|
|
285
|
+
);
|
|
286
|
+
}, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$5.imageCommonPanelInline, children: [
|
|
287
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MoveDownSingle, {}),
|
|
288
|
+
localeService.t("image-panel.arrange.backward")
|
|
289
|
+
] }) }) })
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelRow, children: [
|
|
292
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
|
|
293
|
+
onArrangeBtnClick(
|
|
294
|
+
2
|
|
295
|
+
/* front */
|
|
296
|
+
);
|
|
297
|
+
}, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$5.imageCommonPanelInline, children: [
|
|
298
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TopmostSingle, {}),
|
|
299
|
+
localeService.t("image-panel.arrange.front")
|
|
300
|
+
] }) }) }),
|
|
301
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
|
|
302
|
+
onArrangeBtnClick(
|
|
303
|
+
3
|
|
304
|
+
/* back */
|
|
305
|
+
);
|
|
306
|
+
}, "onClick"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles$5.imageCommonPanelInline, children: [
|
|
307
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(BottomSingle, {}),
|
|
308
|
+
localeService.t("image-panel.arrange.back")
|
|
309
|
+
] }) }) })
|
|
310
|
+
] })
|
|
311
|
+
] });
|
|
312
|
+
}
|
|
313
|
+
__name(ArrangePanel$1, "ArrangePanel$1");
|
|
314
|
+
function TransformPanel(props) {
|
|
315
|
+
const { unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(unitId), scene = page == null ? void 0 : page.scene;
|
|
316
|
+
if (!scene) return null;
|
|
317
|
+
const transformer = scene.getTransformer();
|
|
318
|
+
if (!transformer) return null;
|
|
319
|
+
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
320
|
+
if (!object) return null;
|
|
321
|
+
const {
|
|
322
|
+
width: originWidth = 0,
|
|
323
|
+
height: originHeight = 0,
|
|
324
|
+
left: originX = 0,
|
|
325
|
+
top: originY = 0,
|
|
326
|
+
angle: originRotation = 0
|
|
327
|
+
} = object, [width, setWidth] = useState(originWidth), [height, setHeight] = useState(originHeight), [xPosition, setXPosition] = useState(originX), [yPosition, setYPosition] = useState(originY), [rotation, setRotation] = useState(originRotation), changeObs = /* @__PURE__ */ __name((state) => {
|
|
328
|
+
const { objects } = state, object2 = objects.values().next().value, {
|
|
329
|
+
width: originWidth2 = 0,
|
|
330
|
+
height: originHeight2 = 0,
|
|
331
|
+
left: originX2 = 0,
|
|
332
|
+
top: originY2 = 0,
|
|
333
|
+
angle: originRotation2 = 0
|
|
334
|
+
} = object2;
|
|
335
|
+
setWidth(originWidth2), setHeight(originHeight2), setXPosition(originX2), setYPosition(originY2), setRotation(originRotation2);
|
|
336
|
+
}, "changeObs");
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
const changeStartSub = transformer.changeStart$.subscribe((state) => {
|
|
339
|
+
changeObs(state);
|
|
340
|
+
}), changingSub = transformer.changing$.subscribe((state) => {
|
|
341
|
+
changeObs(state);
|
|
67
342
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
343
|
+
return () => {
|
|
344
|
+
changingSub.unsubscribe(), changeStartSub.unsubscribe();
|
|
345
|
+
};
|
|
346
|
+
}, []);
|
|
347
|
+
function handleWidthChange(val) {
|
|
348
|
+
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
349
|
+
oKey: object.oKey,
|
|
350
|
+
props: {
|
|
351
|
+
width: val
|
|
352
|
+
}
|
|
353
|
+
}), object == null || object.resize(val, object.height), setWidth(val), transformer == null || transformer.refreshControls());
|
|
354
|
+
}
|
|
355
|
+
__name(handleWidthChange, "handleWidthChange");
|
|
356
|
+
function handleHeightChange(val) {
|
|
357
|
+
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
358
|
+
oKey: object.oKey,
|
|
359
|
+
props: {
|
|
360
|
+
height: val
|
|
361
|
+
}
|
|
362
|
+
}), object == null || object.resize(object.width, val), setHeight(val), transformer == null || transformer.refreshControls());
|
|
363
|
+
}
|
|
364
|
+
__name(handleHeightChange, "handleHeightChange");
|
|
365
|
+
function handleXChange(val) {
|
|
366
|
+
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
367
|
+
oKey: object.oKey,
|
|
368
|
+
props: {
|
|
369
|
+
left: val
|
|
370
|
+
}
|
|
371
|
+
}), object == null || object.translate(val, object.top), setXPosition(val), transformer == null || transformer.refreshControls());
|
|
372
|
+
}
|
|
373
|
+
__name(handleXChange, "handleXChange");
|
|
374
|
+
function handleYChange(val) {
|
|
375
|
+
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
376
|
+
oKey: object.oKey,
|
|
377
|
+
props: {
|
|
378
|
+
right: val
|
|
379
|
+
}
|
|
380
|
+
}), object == null || object.translate(object.left, val), setYPosition(val), transformer == null || transformer.refreshControls());
|
|
381
|
+
}
|
|
382
|
+
__name(handleYChange, "handleYChange");
|
|
383
|
+
function handleChangeRotation(val) {
|
|
384
|
+
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
385
|
+
oKey: object.oKey,
|
|
386
|
+
props: {
|
|
387
|
+
angle: val
|
|
388
|
+
}
|
|
389
|
+
}), object == null || object.transformByState({
|
|
390
|
+
angle: val
|
|
391
|
+
}), setRotation(val), transformer == null || transformer.refreshControls());
|
|
392
|
+
}
|
|
393
|
+
return __name(handleChangeRotation, "handleChangeRotation"), /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
81
394
|
"div",
|
|
82
395
|
{
|
|
83
|
-
className:
|
|
84
|
-
[d.slideBarItemActive]: a.id === $
|
|
85
|
-
}),
|
|
86
|
-
onClick: () => F(a.id),
|
|
396
|
+
className: clsx(styles$5.imageCommonPanelGrid, styles$5.imageCommonPanelBorder),
|
|
87
397
|
children: [
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelTitle), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t("image-panel.transform.title") }) }) }),
|
|
399
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelRow, children: [
|
|
400
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan3), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
|
|
401
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: localeService.t("image-panel.transform.width") }) }),
|
|
402
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
403
|
+
InputNumber,
|
|
404
|
+
{
|
|
405
|
+
className: styles$5.imageCommonPanelInput,
|
|
406
|
+
min: 1,
|
|
407
|
+
value: width,
|
|
408
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
409
|
+
handleWidthChange(val);
|
|
410
|
+
}, "onChange")
|
|
411
|
+
}
|
|
412
|
+
) }) })
|
|
413
|
+
] }) }),
|
|
414
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan3), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
|
|
415
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: localeService.t("image-panel.transform.height") }) }),
|
|
416
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
417
|
+
InputNumber,
|
|
418
|
+
{
|
|
419
|
+
className: styles$5.imageCommonPanelInput,
|
|
420
|
+
min: 1,
|
|
421
|
+
value: height,
|
|
422
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
423
|
+
handleHeightChange(val);
|
|
424
|
+
}, "onChange")
|
|
425
|
+
}
|
|
426
|
+
) }) })
|
|
427
|
+
] }) })
|
|
428
|
+
] }),
|
|
429
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelRow, children: [
|
|
430
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan3), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
|
|
431
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: localeService.t("image-panel.transform.x") }) }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
433
|
+
InputNumber,
|
|
434
|
+
{
|
|
435
|
+
className: styles$5.imageCommonPanelInput,
|
|
436
|
+
precision: 1,
|
|
437
|
+
min: 0,
|
|
438
|
+
value: xPosition,
|
|
439
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
440
|
+
handleXChange(val);
|
|
441
|
+
}, "onChange")
|
|
442
|
+
}
|
|
443
|
+
) }) })
|
|
444
|
+
] }) }),
|
|
445
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan3), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
|
|
446
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: localeService.t("image-panel.transform.y") }) }),
|
|
447
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
448
|
+
InputNumber,
|
|
449
|
+
{
|
|
450
|
+
className: styles$5.imageCommonPanelInput,
|
|
451
|
+
precision: 1,
|
|
452
|
+
min: 0,
|
|
453
|
+
value: yPosition,
|
|
454
|
+
onChange: /* @__PURE__ */ __name((val) => {
|
|
455
|
+
handleYChange(val);
|
|
456
|
+
}, "onChange")
|
|
457
|
+
}
|
|
458
|
+
) }) })
|
|
459
|
+
] }) }),
|
|
460
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan3), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
|
|
461
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: localeService.t("image-panel.transform.rotate") }) }),
|
|
462
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelColumn, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
463
|
+
InputNumber,
|
|
464
|
+
{
|
|
465
|
+
className: styles$5.imageCommonPanelInput,
|
|
466
|
+
precision: 1,
|
|
467
|
+
value: rotation,
|
|
468
|
+
onChange: handleChangeRotation
|
|
469
|
+
}
|
|
470
|
+
) }) })
|
|
471
|
+
] }) })
|
|
472
|
+
] })
|
|
90
473
|
]
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
__name(TransformPanel, "TransformPanel");
|
|
478
|
+
function ArrangePanel(props) {
|
|
479
|
+
var _a9, _b;
|
|
480
|
+
const { unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(unitId), scene = page == null ? void 0 : page.scene;
|
|
481
|
+
if (!scene) return null;
|
|
482
|
+
const transformer = scene.getTransformer();
|
|
483
|
+
if (!transformer) return null;
|
|
484
|
+
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
485
|
+
if (!object) return null;
|
|
486
|
+
const [color, setColor] = React.useState((_b = (_a9 = object.fill) == null ? void 0 : _a9.toString()) != null ? _b : "");
|
|
487
|
+
function handleChangeColor(color2) {
|
|
488
|
+
object == null || object.setProps({
|
|
489
|
+
fill: color2
|
|
490
|
+
}), commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
491
|
+
oKey: object == null ? void 0 : object.oKey,
|
|
492
|
+
props: {
|
|
493
|
+
shape: {
|
|
494
|
+
shapeProperties: {
|
|
495
|
+
shapeBackgroundFill: {
|
|
496
|
+
rgb: color2
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}), setColor(color2);
|
|
502
|
+
}
|
|
503
|
+
return __name(handleChangeColor, "handleChangeColor"), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
504
|
+
"div",
|
|
505
|
+
{
|
|
506
|
+
className: clsx(styles$5.imageCommonPanelGrid, styles$5.imageCommonPanelBorder),
|
|
507
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.imageCommonPanelGrid, children: [
|
|
508
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelTitle), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t("slide.panel.fill.title") }) }) }),
|
|
509
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.imageCommonPanelRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: clsx(styles$5.imageCommonPanelColumn, styles$5.imageCommonPanelSpan2), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
510
|
+
Dropdown,
|
|
511
|
+
{
|
|
512
|
+
align: {
|
|
513
|
+
offset: [0, 18]
|
|
514
|
+
},
|
|
515
|
+
overlay: /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: styles$5.slidePanelColorPicker, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
516
|
+
ColorPicker,
|
|
517
|
+
{
|
|
518
|
+
color: "#fff",
|
|
519
|
+
onChange: handleChangeColor
|
|
520
|
+
}
|
|
521
|
+
) }),
|
|
522
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { className: styles$5.uiPluginSheetsBorderPanelButton, children: [
|
|
523
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(PaintBucket, { extend: { colorChannel1: color != null ? color : "rgb(var(--primary-color))" } }),
|
|
524
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles$5.uiPluginSheetsBorderPanelMoreIcon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, {}) })
|
|
525
|
+
] })
|
|
526
|
+
}
|
|
527
|
+
) }) })
|
|
528
|
+
] })
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
__name(ArrangePanel, "ArrangePanel");
|
|
533
|
+
const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", styles$4 = {
|
|
534
|
+
imageCommonPanel,
|
|
535
|
+
imageCommonPanelGrid,
|
|
536
|
+
imageCommonPanelBorder,
|
|
537
|
+
imageCommonPanelTitle,
|
|
538
|
+
imageCommonPanelSubtitle,
|
|
539
|
+
imageCommonPanelRow,
|
|
540
|
+
imageCommonPanelRowVertical,
|
|
541
|
+
imageCommonPanelColumn,
|
|
542
|
+
imageCommonPanelColumnCenter,
|
|
543
|
+
imageCommonPanelInline,
|
|
544
|
+
imageCommonPanelSpan2,
|
|
545
|
+
imageCommonPanelSpan3,
|
|
546
|
+
imageCommonPanelInput
|
|
547
|
+
}, COMPONENT_SLIDE_SIDEBAR = "COMPONENT_SLIDE_SIDEBAR";
|
|
548
|
+
function RectSidebar() {
|
|
549
|
+
var _a9, _b;
|
|
550
|
+
const univerInstanceService = useDependency(IUniverInstanceService), canvasView = useDependency(CanvasView), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pageId = (_a9 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a9.id;
|
|
551
|
+
if (!pageId) return null;
|
|
552
|
+
const transformer = (_b = canvasView.getRenderUnitByPageId(pageId).scene) == null ? void 0 : _b.getTransformer();
|
|
553
|
+
if (!transformer) return null;
|
|
554
|
+
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
555
|
+
return object ? /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: styles$4.imageCommonPanel, children: [
|
|
556
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel$1, { unitId: pageId }),
|
|
557
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TransformPanel, { unitId: pageId }),
|
|
558
|
+
object.objectType === ObjectType.RECT && /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel, { unitId: pageId })
|
|
559
|
+
] }) : null;
|
|
560
|
+
}
|
|
561
|
+
__name(RectSidebar, "RectSidebar");
|
|
562
|
+
const InsertSlideShapeRectangleOperation = {
|
|
563
|
+
id: "slide.operation.insert-float-shape",
|
|
564
|
+
type: CommandType.OPERATION,
|
|
565
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
566
|
+
const id = generateRandomId(6), data = {
|
|
567
|
+
id,
|
|
568
|
+
zIndex: 20,
|
|
569
|
+
left: 378,
|
|
570
|
+
top: 142,
|
|
571
|
+
width: 250,
|
|
572
|
+
height: 250,
|
|
573
|
+
title: id,
|
|
574
|
+
description: "",
|
|
575
|
+
type: PageElementType.SHAPE,
|
|
576
|
+
shape: {
|
|
577
|
+
shapeType: BasicShapes.Rect,
|
|
578
|
+
text: "",
|
|
579
|
+
shapeProperties: {
|
|
580
|
+
shapeBackgroundFill: {
|
|
581
|
+
rgb: "rgb(0,0,255)"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
586
|
+
if (!slideData) return !1;
|
|
587
|
+
const activePage = slideData.getActivePage();
|
|
588
|
+
activePage.pageElements[id] = data, slideData.updatePage(activePage.id, activePage);
|
|
589
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id);
|
|
590
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id), !0;
|
|
591
|
+
}, "handler")
|
|
592
|
+
}, ToggleSlideEditSidebarOperation = {
|
|
593
|
+
id: "sidebar.operation.slide-shape",
|
|
594
|
+
type: CommandType.COMMAND,
|
|
595
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
596
|
+
const { visible, objectType } = params, sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService);
|
|
597
|
+
let title = "", children = "";
|
|
598
|
+
return objectType === ObjectType.RECT ? (title = "slide.sidebar.shape", children = COMPONENT_SLIDE_SIDEBAR) : objectType === ObjectType.IMAGE ? (title = "slide.sidebar.image", children = COMPONENT_SLIDE_SIDEBAR) : objectType === ObjectType.RICH_TEXT && (title = "slide.sidebar.text", children = COMPONENT_SLIDE_SIDEBAR), visible ? sidebarService.open({
|
|
599
|
+
header: { title: localeService.t(title) },
|
|
600
|
+
children: { label: children },
|
|
601
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
602
|
+
}, "onClose"),
|
|
603
|
+
width: 360
|
|
604
|
+
}) : sidebarService.close(), !0;
|
|
605
|
+
}, "handler")
|
|
606
|
+
}, SlideAddTextOperation = {
|
|
607
|
+
id: "slide.operation.add-text",
|
|
608
|
+
type: CommandType.OPERATION,
|
|
609
|
+
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
610
|
+
const elementId = Tools.generateRandomId(6), defaultWidth = 220, defaultheight = 40, left = 230, top = 142, textContent = (params == null ? void 0 : params.text) || "A New Text", elementData = {
|
|
611
|
+
id: elementId,
|
|
612
|
+
zIndex: 2,
|
|
613
|
+
left,
|
|
614
|
+
top,
|
|
615
|
+
width: defaultWidth,
|
|
616
|
+
height: defaultheight,
|
|
617
|
+
title: "text",
|
|
618
|
+
description: "",
|
|
619
|
+
type: PageElementType.TEXT,
|
|
620
|
+
richText: {
|
|
621
|
+
text: textContent,
|
|
622
|
+
fs: 30,
|
|
623
|
+
cl: {
|
|
624
|
+
rgb: "rgb(51, 51, 51)"
|
|
625
|
+
},
|
|
626
|
+
bl: 1
|
|
627
|
+
}
|
|
628
|
+
}, slideData = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
629
|
+
if (!slideData) return !1;
|
|
630
|
+
const activePage = slideData.getActivePage();
|
|
631
|
+
activePage.pageElements[elementId] = elementData, slideData.updatePage(activePage.id, activePage);
|
|
632
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(elementData, activePage.id);
|
|
633
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id), !0;
|
|
634
|
+
}, "handler")
|
|
635
|
+
}, SetSlidePageThumbOperation = {
|
|
636
|
+
id: "slide.operation.set-slide-page-thumb",
|
|
637
|
+
type: CommandType.OPERATION,
|
|
638
|
+
handler: /* @__PURE__ */ __name((accessor) => (accessor.get(CanvasView).createThumbs(), !0), "handler")
|
|
639
|
+
}, SetTextEditArrowOperation = {
|
|
640
|
+
id: "slide.operation.edit-arrow",
|
|
641
|
+
type: CommandType.OPERATION,
|
|
642
|
+
handler: /* @__PURE__ */ __name(() => !0, "handler")
|
|
643
|
+
}, 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$3 = {
|
|
644
|
+
imagePopupMenu,
|
|
645
|
+
imagePopupMenuItem,
|
|
646
|
+
imagePopupMenuItemIcon,
|
|
647
|
+
imagePopupMenuItemTitle,
|
|
648
|
+
imagePopupMenuItemHide,
|
|
649
|
+
btnContainer,
|
|
650
|
+
btnContainerExpand
|
|
651
|
+
}, SlideImagePopupMenu = /* @__PURE__ */ __name((props) => {
|
|
652
|
+
var _a9, _b;
|
|
653
|
+
const menuItems = (_b = (_a9 = props.popup) == null ? void 0 : _a9.extraProps) == null ? void 0 : _b.menuItems;
|
|
654
|
+
if (!menuItems)
|
|
655
|
+
return null;
|
|
656
|
+
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
|
|
657
|
+
setHovered(!0);
|
|
658
|
+
}, "handleMouseEnter"), handleMouseLeave = /* @__PURE__ */ __name(() => {
|
|
659
|
+
setHovered(!1);
|
|
660
|
+
}, "handleMouseLeave"), onVisibleChange = /* @__PURE__ */ __name((visible2) => {
|
|
661
|
+
setVisible(visible2);
|
|
662
|
+
}, "onVisibleChange"), handleClick = /* @__PURE__ */ __name((item) => {
|
|
663
|
+
commandService.executeCommand(item.commandId, item.commandParams), setVisible(!1);
|
|
664
|
+
}, "handleClick"), showMore = visible || isHovered, availableMenu = menuItems.filter((item) => !item.disable);
|
|
665
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
666
|
+
"div",
|
|
667
|
+
{
|
|
668
|
+
onMouseEnter: handleMouseEnter,
|
|
669
|
+
onMouseLeave: handleMouseLeave,
|
|
670
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
671
|
+
Dropdown,
|
|
672
|
+
{
|
|
673
|
+
placement: "bottomLeft",
|
|
674
|
+
trigger: ["click"],
|
|
675
|
+
overlay: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: styles$3.imagePopupMenu, children: availableMenu.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
676
|
+
"li",
|
|
677
|
+
{
|
|
678
|
+
onClick: /* @__PURE__ */ __name(() => handleClick(item), "onClick"),
|
|
679
|
+
className: styles$3.imagePopupMenuItem,
|
|
680
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: styles$3.imagePopupMenuItemTitle, children: localeService.t(item.label) })
|
|
681
|
+
},
|
|
682
|
+
item.index
|
|
683
|
+
)) }),
|
|
684
|
+
visible,
|
|
685
|
+
onVisibleChange,
|
|
686
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
className: clsx(styles$3.btnContainer, {
|
|
690
|
+
[styles$3.btnContainerExpand]: visible
|
|
691
|
+
}),
|
|
692
|
+
children: [
|
|
693
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
694
|
+
Autofill,
|
|
695
|
+
{
|
|
696
|
+
style: { color: "#35322B" },
|
|
697
|
+
extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
showMore && /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
|
|
701
|
+
]
|
|
702
|
+
}
|
|
703
|
+
)
|
|
704
|
+
}
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
}, "SlideImagePopupMenu"), COMPONENT_SLIDE_IMAGE_POPUP_MENU = "COMPONENT_SLIDE_IMAGE_POPUP_MENU", uploadFileMenu = "univer-upload-file-menu", uploadFileMenuInput = "univer-upload-file-menu-input", styles$2 = {
|
|
709
|
+
uploadFileMenu,
|
|
710
|
+
uploadFileMenuInput
|
|
711
|
+
}, COMPONENT_UPLOAD_FILE_MENU = "COMPONENT_UPLOAD_FILE_MENU";
|
|
712
|
+
var UploadFileType = /* @__PURE__ */ ((UploadFileType2) => (UploadFileType2[UploadFileType2.cellImage = 0] = "cellImage", UploadFileType2[UploadFileType2.floatImage = 1] = "floatImage", UploadFileType2))(UploadFileType || {});
|
|
713
|
+
const UploadFileMenu = /* @__PURE__ */ __name((props) => {
|
|
714
|
+
const { type } = props, commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
|
|
715
|
+
var _a9;
|
|
716
|
+
(_a9 = fileInputRef.current) == null || _a9.click();
|
|
717
|
+
}, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
|
|
718
|
+
const fileList = event.target.files;
|
|
719
|
+
if (fileList == null)
|
|
720
|
+
return;
|
|
721
|
+
const files = Array.from(fileList);
|
|
722
|
+
type === UploadFileType.floatImage && commandService.executeCommand(InsertSlideFloatImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
|
|
723
|
+
}, "handleFileChange");
|
|
724
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: handleButtonClick, className: styles$2.uploadFileMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
725
|
+
"input",
|
|
726
|
+
{
|
|
727
|
+
type: "file",
|
|
728
|
+
className: styles$2.uploadFileMenuInput,
|
|
729
|
+
ref: fileInputRef,
|
|
730
|
+
onChange: handleFileChange,
|
|
731
|
+
accept: imageAccept,
|
|
732
|
+
multiple: !0
|
|
733
|
+
}
|
|
734
|
+
) });
|
|
735
|
+
}, "UploadFileMenu"), _SlideEditorManagerService = class _SlideEditorManagerService {
|
|
736
|
+
constructor() {
|
|
737
|
+
__publicField(this, "_state", null);
|
|
738
|
+
__publicField(this, "_rect", null);
|
|
739
|
+
__publicField(this, "_state$", new BehaviorSubject(null));
|
|
740
|
+
__publicField(this, "state$", this._state$.asObservable());
|
|
741
|
+
__publicField(this, "_rect$", new BehaviorSubject(null));
|
|
742
|
+
__publicField(this, "rect$", this._rect$.asObservable());
|
|
743
|
+
__publicField(this, "_focus", !1);
|
|
744
|
+
__publicField(this, "_focus$", new BehaviorSubject(this._focus));
|
|
745
|
+
__publicField(this, "focus$", this._focus$.asObservable());
|
|
746
|
+
}
|
|
747
|
+
dispose() {
|
|
748
|
+
this._state$.complete(), this._state = null, this._rect$.complete(), this._rect = null;
|
|
749
|
+
}
|
|
750
|
+
setState(param) {
|
|
751
|
+
this._state = param, this._refresh(param);
|
|
752
|
+
}
|
|
753
|
+
getRect() {
|
|
754
|
+
return this._rect;
|
|
755
|
+
}
|
|
756
|
+
setRect(param) {
|
|
757
|
+
this._rect = param, this._rect$.next(param);
|
|
758
|
+
}
|
|
759
|
+
getState() {
|
|
760
|
+
return this._state;
|
|
761
|
+
}
|
|
762
|
+
setFocus(param = !1) {
|
|
763
|
+
this._focus = param, this._focus$.next(param);
|
|
764
|
+
}
|
|
765
|
+
_refresh(param) {
|
|
766
|
+
this._state$.next(param);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
__name(_SlideEditorManagerService, "SlideEditorManagerService");
|
|
770
|
+
let SlideEditorManagerService = _SlideEditorManagerService;
|
|
771
|
+
const ISlideEditorManagerService = createIdentifier(
|
|
772
|
+
"univer.slide-editor-manager.service"
|
|
773
|
+
), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
|
|
774
|
+
slideEditorContainer,
|
|
775
|
+
editorInput
|
|
776
|
+
}, HIDDEN_EDITOR_POSITION$1 = -1e3, EDITOR_DEFAULT_POSITION = {
|
|
777
|
+
width: 0,
|
|
778
|
+
height: 0,
|
|
779
|
+
top: HIDDEN_EDITOR_POSITION$1,
|
|
780
|
+
left: HIDDEN_EDITOR_POSITION$1
|
|
781
|
+
}, EditorContainer = /* @__PURE__ */ __name(() => {
|
|
782
|
+
const [state, setState] = useState({
|
|
783
|
+
...EDITOR_DEFAULT_POSITION
|
|
784
|
+
}), slideEditorManagerService = useDependency(ISlideEditorManagerService), editorService = useDependency(IEditorService), contextService = useDependency(IContextService), disableAutoFocus = useObservable(
|
|
785
|
+
() => contextService.subscribeContextValue$(DISABLE_AUTO_FOCUS_KEY),
|
|
786
|
+
!1,
|
|
787
|
+
void 0,
|
|
788
|
+
[contextService, DISABLE_AUTO_FOCUS_KEY]
|
|
789
|
+
), snapshot = {
|
|
790
|
+
id: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
|
|
791
|
+
body: {
|
|
792
|
+
dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
|
|
793
|
+
textRuns: [],
|
|
794
|
+
paragraphs: [
|
|
795
|
+
{
|
|
796
|
+
startIndex: 0
|
|
797
|
+
}
|
|
798
|
+
]
|
|
799
|
+
},
|
|
800
|
+
documentStyle: {
|
|
801
|
+
documentFlavor: DocumentFlavor.MODERN
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
return useEffect(() => {
|
|
805
|
+
slideEditorManagerService.state$.subscribe((param) => {
|
|
806
|
+
if (param == null)
|
|
807
|
+
return;
|
|
808
|
+
const {
|
|
809
|
+
startX = HIDDEN_EDITOR_POSITION$1,
|
|
810
|
+
startY = HIDDEN_EDITOR_POSITION$1,
|
|
811
|
+
endX = 0,
|
|
812
|
+
endY = 0,
|
|
813
|
+
show = !1
|
|
814
|
+
} = param;
|
|
815
|
+
if (!show)
|
|
816
|
+
setState({
|
|
817
|
+
...EDITOR_DEFAULT_POSITION
|
|
818
|
+
});
|
|
819
|
+
else {
|
|
820
|
+
setState({
|
|
821
|
+
width: endX - startX - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
|
|
822
|
+
height: endY - startY - FIX_ONE_PIXEL_BLUR_OFFSET + 2,
|
|
823
|
+
left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
|
|
824
|
+
top: startY + FIX_ONE_PIXEL_BLUR_OFFSET
|
|
825
|
+
});
|
|
826
|
+
const editor = editorService.getEditor(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
827
|
+
if (editor == null)
|
|
828
|
+
return;
|
|
829
|
+
const { left, top, width, height } = editor.getBoundingClientRect();
|
|
830
|
+
slideEditorManagerService.setRect({ left, top, width, height });
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}, []), useEffect(() => {
|
|
834
|
+
disableAutoFocus || slideEditorManagerService.setFocus(!0);
|
|
835
|
+
}, [disableAutoFocus, state]), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
836
|
+
"div",
|
|
837
|
+
{
|
|
838
|
+
className: styles$1.slideEditorContainer,
|
|
839
|
+
style: {
|
|
840
|
+
left: state.left,
|
|
841
|
+
top: state.top,
|
|
842
|
+
width: state.width,
|
|
843
|
+
height: state.height
|
|
844
|
+
},
|
|
845
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
846
|
+
TextEditor,
|
|
847
|
+
{
|
|
848
|
+
id: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
|
|
849
|
+
className: styles$1.editorInput,
|
|
850
|
+
snapshot,
|
|
851
|
+
cancelDefaultResizeListener: !1,
|
|
852
|
+
isSheetEditor: !1,
|
|
853
|
+
isSingle: !1
|
|
854
|
+
}
|
|
855
|
+
)
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
}, "EditorContainer"), AppendSlideOperation = {
|
|
859
|
+
id: "slide.operation.append-slide",
|
|
860
|
+
type: CommandType.OPERATION,
|
|
861
|
+
handler: /* @__PURE__ */ __name((accessor) => {
|
|
862
|
+
const univerInstanceService = accessor.get(IUniverInstanceService), canvasView = accessor.get(CanvasView);
|
|
863
|
+
return univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE) ? (canvasView.appendPage(), !0) : !1;
|
|
864
|
+
}, "handler")
|
|
865
|
+
}, 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 = {
|
|
866
|
+
slideBar,
|
|
867
|
+
slideBarContent,
|
|
868
|
+
slideBarContentHeader,
|
|
869
|
+
slideBarItem,
|
|
870
|
+
slideBarBox,
|
|
871
|
+
slideBarItemActive,
|
|
872
|
+
slideAddButton
|
|
873
|
+
};
|
|
874
|
+
function SlideSideBar() {
|
|
875
|
+
var _a9, _b;
|
|
876
|
+
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();
|
|
877
|
+
if (!pages || !pageOrder)
|
|
878
|
+
return null;
|
|
879
|
+
const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (_a9 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a9.id) != null ? _b : null);
|
|
880
|
+
useEffect(() => {
|
|
881
|
+
setDivRefs(slideList.map((_) => React.createRef()));
|
|
882
|
+
}, [slideList.length]), useEffect(() => {
|
|
883
|
+
const subscriber = currentSlide == null ? void 0 : currentSlide.activePage$.subscribe((page) => {
|
|
884
|
+
var _a10;
|
|
885
|
+
const id = (_a10 = page == null ? void 0 : page.id) != null ? _a10 : null;
|
|
886
|
+
id && setActivatePageId(id);
|
|
887
|
+
});
|
|
888
|
+
return () => {
|
|
889
|
+
subscriber == null || subscriber.unsubscribe();
|
|
890
|
+
};
|
|
891
|
+
}, []), useEffect(() => {
|
|
892
|
+
divRefs.forEach((ref, index) => {
|
|
893
|
+
var _a10;
|
|
894
|
+
if (ref.current) {
|
|
895
|
+
const slide = slideList[index];
|
|
896
|
+
(_a10 = renderManagerService.getRenderById(slide.id)) == null || _a10.engine.setContainer(ref.current);
|
|
897
|
+
}
|
|
898
|
+
}), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id);
|
|
899
|
+
}, [divRefs]);
|
|
900
|
+
const activatePage = useCallback((page) => {
|
|
901
|
+
commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page });
|
|
902
|
+
}, [commandService]), handleAppendSlide = useCallback(() => {
|
|
903
|
+
commandService.syncExecuteCommand(AppendSlideOperation.id);
|
|
904
|
+
}, [commandService]);
|
|
905
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("aside", { className: styles.slideBar, ref: slideBarRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.slideBarContent, children: [
|
|
906
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: styles.slideBarContentHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: handleAppendSlide, children: localeService.t("slide.append") }) }),
|
|
907
|
+
slideList.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
908
|
+
"div",
|
|
909
|
+
{
|
|
910
|
+
className: clsx(styles.slideBarItem, {
|
|
911
|
+
[styles.slideBarItemActive]: item.id === activatePageId
|
|
912
|
+
}),
|
|
913
|
+
onClick: /* @__PURE__ */ __name(() => activatePage(item.id), "onClick"),
|
|
914
|
+
children: [
|
|
915
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: index + 1 }),
|
|
916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: divRefs[index], className: styles.slideBarBox })
|
|
917
|
+
]
|
|
918
|
+
},
|
|
919
|
+
item.id
|
|
920
|
+
))
|
|
921
|
+
] }) }) });
|
|
922
|
+
}
|
|
923
|
+
__name(SlideSideBar, "SlideSideBar");
|
|
924
|
+
const IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "slide.menu.image";
|
|
925
|
+
function SlideImageMenuFactory(accessor) {
|
|
926
|
+
return {
|
|
927
|
+
id: IMAGE_MENU_ID,
|
|
928
|
+
type: MenuItemType.SUBITEMS,
|
|
929
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
930
|
+
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
931
|
+
icon: IMAGE_UPLOAD_ICON,
|
|
932
|
+
tooltip: "slide.image.insert.title",
|
|
933
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
|
|
934
|
+
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
__name(SlideImageMenuFactory, "SlideImageMenuFactory");
|
|
938
|
+
function UploadSlideFloatImageMenuFactory(_accessor) {
|
|
939
|
+
return {
|
|
940
|
+
id: InsertSlideFloatImageOperation.id,
|
|
941
|
+
title: "slide.image.insert.float",
|
|
942
|
+
type: MenuItemType.SELECTOR,
|
|
943
|
+
label: {
|
|
944
|
+
name: COMPONENT_UPLOAD_FILE_MENU,
|
|
945
|
+
props: {
|
|
946
|
+
type: UploadFileType.floatImage
|
|
947
|
+
}
|
|
91
948
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
949
|
+
positions: [IMAGE_MENU_ID],
|
|
950
|
+
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
__name(UploadSlideFloatImageMenuFactory, "UploadSlideFloatImageMenuFactory");
|
|
954
|
+
const GRAPH_SINGLE_ICON = "graph-single", SHAPE_MENU_ID = "slide.menu.shape";
|
|
955
|
+
function SlideShapeMenuFactory(accessor) {
|
|
956
|
+
return {
|
|
957
|
+
id: SHAPE_MENU_ID,
|
|
958
|
+
type: MenuItemType.SUBITEMS,
|
|
959
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
960
|
+
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
961
|
+
icon: GRAPH_SINGLE_ICON,
|
|
962
|
+
tooltip: "slide.shape.insert.title",
|
|
963
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SLIDE)
|
|
964
|
+
// disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
__name(SlideShapeMenuFactory, "SlideShapeMenuFactory");
|
|
968
|
+
function UploadSlideFloatShapeMenuFactory(_accessor) {
|
|
969
|
+
return {
|
|
970
|
+
id: InsertSlideShapeRectangleOperation.id,
|
|
971
|
+
title: "slide.shape.insert.rectangle",
|
|
972
|
+
type: MenuItemType.BUTTON,
|
|
973
|
+
positions: [SHAPE_MENU_ID],
|
|
974
|
+
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
__name(UploadSlideFloatShapeMenuFactory, "UploadSlideFloatShapeMenuFactory");
|
|
978
|
+
function whenEditorActivated(contextService) {
|
|
979
|
+
return contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED);
|
|
980
|
+
}
|
|
981
|
+
__name(whenEditorActivated, "whenEditorActivated");
|
|
982
|
+
function whenFormulaEditorFocused(contextService) {
|
|
983
|
+
return contextService.getContextValue(FORMULA_EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR);
|
|
984
|
+
}
|
|
985
|
+
__name(whenFormulaEditorFocused, "whenFormulaEditorFocused");
|
|
986
|
+
const ARROW_SELECTION_KEYCODE_LIST = [
|
|
987
|
+
KeyCode.ARROW_DOWN,
|
|
988
|
+
KeyCode.ARROW_UP,
|
|
989
|
+
KeyCode.ARROW_LEFT,
|
|
990
|
+
KeyCode.ARROW_RIGHT
|
|
991
|
+
];
|
|
992
|
+
[KeyCode.ENTER, KeyCode.TAB, ...ARROW_SELECTION_KEYCODE_LIST];
|
|
993
|
+
function generateArrowSelectionShortCutItem() {
|
|
994
|
+
const shortcutList = [];
|
|
995
|
+
for (const keycode of ARROW_SELECTION_KEYCODE_LIST)
|
|
996
|
+
shortcutList.push({
|
|
997
|
+
id: SetTextEditArrowOperation.id,
|
|
998
|
+
binding: keycode,
|
|
999
|
+
preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
|
|
1000
|
+
staticParameters: {
|
|
1001
|
+
visible: !1,
|
|
1002
|
+
eventType: DeviceInputEventType.Keyboard,
|
|
1003
|
+
keycode,
|
|
1004
|
+
isShift: !1
|
|
1005
|
+
}
|
|
1006
|
+
}), shortcutList.push({
|
|
1007
|
+
id: SetTextEditArrowOperation.id,
|
|
1008
|
+
binding: keycode | MetaKeys.SHIFT,
|
|
1009
|
+
preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService), "preconditions"),
|
|
1010
|
+
staticParameters: {
|
|
1011
|
+
visible: !1,
|
|
1012
|
+
eventType: DeviceInputEventType.Keyboard,
|
|
1013
|
+
keycode,
|
|
1014
|
+
isShift: !0
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
return shortcutList;
|
|
1018
|
+
}
|
|
1019
|
+
__name(generateArrowSelectionShortCutItem, "generateArrowSelectionShortCutItem");
|
|
1020
|
+
const EditorDeleteLeftShortcut = {
|
|
1021
|
+
id: DeleteLeftCommand.id,
|
|
1022
|
+
preconditions: /* @__PURE__ */ __name((contextService) => whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService), "preconditions"),
|
|
1023
|
+
binding: KeyCode.BACKSPACE
|
|
1024
|
+
}, TEXT_ICON_ID = "text-single";
|
|
1025
|
+
function SlideAddTextMenuItemFactory(_accessor) {
|
|
1026
|
+
return {
|
|
1027
|
+
id: SlideAddTextOperation.id,
|
|
1028
|
+
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1029
|
+
type: MenuItemType.BUTTON,
|
|
1030
|
+
icon: TEXT_ICON_ID,
|
|
1031
|
+
tooltip: "slide.text.insert.title",
|
|
1032
|
+
positions: [MenuPosition.TOOLBAR_START],
|
|
1033
|
+
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SLIDE)
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
__name(SlideAddTextMenuItemFactory, "SlideAddTextMenuItemFactory");
|
|
1037
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1038
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1039
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1040
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
1041
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a;
|
|
1042
|
+
let SlidesUIController = (_a = class extends Disposable {
|
|
1043
|
+
constructor(_config, _injector, _menuService, _componentManager, _uiPartsService, _commandService, _shortcutService) {
|
|
1044
|
+
super(), this._config = _config, this._injector = _injector, this._menuService = _menuService, this._componentManager = _componentManager, this._uiPartsService = _uiPartsService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._initCommands(), this._initCustomComponents(), this._initUIComponents(), this._initMenus(), this._initShortcuts();
|
|
1045
|
+
}
|
|
1046
|
+
_initMenus() {
|
|
1047
|
+
const { menu = {} } = this._config || {};
|
|
1048
|
+
[
|
|
1049
|
+
SlideAddTextMenuItemFactory,
|
|
1050
|
+
SlideImageMenuFactory,
|
|
1051
|
+
UploadSlideFloatImageMenuFactory,
|
|
1052
|
+
SlideShapeMenuFactory,
|
|
1053
|
+
UploadSlideFloatShapeMenuFactory
|
|
1054
|
+
].forEach((menuFactory) => {
|
|
1055
|
+
this._menuService.addMenuItem(menuFactory(this._injector), menu);
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
_initCustomComponents() {
|
|
1059
|
+
const componentManager = this._componentManager;
|
|
1060
|
+
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_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_IMAGE_POPUP_MENU, SlideImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_SLIDE_SIDEBAR, RectSidebar));
|
|
103
1061
|
}
|
|
104
1062
|
_initCommands() {
|
|
105
1063
|
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1064
|
+
AppendSlideOperation,
|
|
1065
|
+
ActivateSlidePageOperation,
|
|
1066
|
+
SetSlidePageThumbOperation,
|
|
1067
|
+
InsertSlideFloatImageOperation,
|
|
1068
|
+
SlideAddTextOperation,
|
|
1069
|
+
InsertSlideShapeRectangleOperation,
|
|
1070
|
+
ToggleSlideEditSidebarOperation,
|
|
1071
|
+
DeleteSlideElementOperation,
|
|
1072
|
+
UpdateSlideElementOperation,
|
|
1073
|
+
// commands for editor
|
|
1074
|
+
SetTextEditArrowOperation
|
|
1075
|
+
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
109
1076
|
}
|
|
110
1077
|
_initUIComponents() {
|
|
111
1078
|
this.disposeWithMe(
|
|
112
|
-
this._uiPartsService.registerComponent(
|
|
1079
|
+
this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
|
|
1080
|
+
), this.disposeWithMe(
|
|
1081
|
+
this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(EditorContainer, this._injector))
|
|
113
1082
|
);
|
|
114
1083
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
1084
|
+
_initShortcuts() {
|
|
1085
|
+
[
|
|
1086
|
+
EditorDeleteLeftShortcut,
|
|
1087
|
+
...generateArrowSelectionShortCutItem()
|
|
1088
|
+
].forEach((item) => {
|
|
1089
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(item));
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}, __name(_a, "SlidesUIController"), _a);
|
|
1093
|
+
SlidesUIController = __decorateClass$7([
|
|
1094
|
+
OnLifecycle(LifecycleStages.Ready, SlidesUIController),
|
|
1095
|
+
__decorateParam$7(1, Inject(Injector)),
|
|
1096
|
+
__decorateParam$7(2, IMenuService),
|
|
1097
|
+
__decorateParam$7(3, Inject(ComponentManager)),
|
|
1098
|
+
__decorateParam$7(4, IUIPartsService),
|
|
1099
|
+
__decorateParam$7(5, ICommandService),
|
|
1100
|
+
__decorateParam$7(6, IShortcutService)
|
|
1101
|
+
], SlidesUIController);
|
|
1102
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1103
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1104
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1105
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
1106
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
|
|
1107
|
+
const ISlideEditorBridgeService = createIdentifier("univer.slide-editor-bridge.service");
|
|
1108
|
+
var _a2;
|
|
1109
|
+
let SlideEditorBridgeService = (_a2 = class extends Disposable {
|
|
1110
|
+
constructor(_editorService, _contextService, _renderManagerService) {
|
|
1111
|
+
super();
|
|
1112
|
+
__publicField(this, "_editorUnitId", DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
1113
|
+
__publicField(this, "_isForceKeepVisible", !1);
|
|
1114
|
+
__publicField(this, "_editorIsDirty", !1);
|
|
1115
|
+
__publicField(this, "_currentEditRectState", null);
|
|
1116
|
+
__publicField(this, "_currentEditRectState$", new BehaviorSubject(null));
|
|
1117
|
+
__publicField(this, "currentEditRectState$", this._currentEditRectState$.asObservable());
|
|
1118
|
+
__publicField(this, "_visible", {
|
|
1119
|
+
visible: !1,
|
|
1120
|
+
eventType: DeviceInputEventType.Dblclick,
|
|
1121
|
+
unitId: ""
|
|
1122
|
+
});
|
|
1123
|
+
__publicField(this, "_visible$", new BehaviorSubject(this._visible));
|
|
1124
|
+
__publicField(this, "visible$", this._visible$.asObservable());
|
|
1125
|
+
__publicField(this, "_afterVisible$", new BehaviorSubject(this._visible));
|
|
1126
|
+
__publicField(this, "afterVisible$", this._afterVisible$.asObservable());
|
|
1127
|
+
__publicField(this, "_currentEditRectInfo");
|
|
1128
|
+
this._editorService = _editorService, this._contextService = _contextService, this._renderManagerService = _renderManagerService;
|
|
1129
|
+
}
|
|
1130
|
+
dispose() {
|
|
1131
|
+
super.dispose();
|
|
1132
|
+
}
|
|
1133
|
+
getEditorRect() {
|
|
1134
|
+
return this._currentEditRectInfo;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* 1st part of startEditing.
|
|
1138
|
+
* editorBridgeRenderController@startEditing ---> editorBridgeRenderController@_updateEditor
|
|
1139
|
+
* @editorInfo editorInfo
|
|
1140
|
+
*/
|
|
1141
|
+
setEditorRect(editorInfo) {
|
|
1142
|
+
this._currentEditRectInfo = editorInfo, this._editorService.getFocusEditor() || (this._editorService.focus(DOCS_NORMAL_EDITOR_UNIT_ID_KEY), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !1), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, !1));
|
|
1143
|
+
const editRectState = this.getEditRectState();
|
|
1144
|
+
this._currentEditRectState = editRectState, this._currentEditRectState$.next(editRectState);
|
|
1145
|
+
}
|
|
1146
|
+
changeVisible(param) {
|
|
1147
|
+
this._visible = param, param.visible && (this._editorIsDirty = !1), this._visible$.next(this._visible), this._afterVisible$.next(this._visible);
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* get info from _currentEditRectInfo
|
|
1151
|
+
*
|
|
1152
|
+
* invoked by slide-editing.render-controller.ts@_handleEditorVisible
|
|
1153
|
+
* && this@setEditorRect
|
|
1154
|
+
*/
|
|
1155
|
+
getEditRectState() {
|
|
1156
|
+
const editorUnitId = DOCS_NORMAL_EDITOR_UNIT_ID_KEY, editorRectInfo = this._currentEditRectInfo, unitId = editorRectInfo.unitId, docData = editorRectInfo.richTextObj.documentData;
|
|
1157
|
+
docData.id = editorUnitId, docData.documentStyle = {
|
|
1158
|
+
...docData.documentStyle,
|
|
1159
|
+
pageSize: { width: editorRectInfo.richTextObj.width, height: 1 / 0 }
|
|
1160
|
+
};
|
|
1161
|
+
const documentLayoutObject = {
|
|
1162
|
+
documentModel: new DocumentDataModel(docData),
|
|
1163
|
+
fontString: "document",
|
|
1164
|
+
textRotation: { a: 0, v: 0 },
|
|
1165
|
+
wrapStrategy: 0,
|
|
1166
|
+
verticalAlign: VerticalAlign.TOP,
|
|
1167
|
+
horizontalAlign: HorizontalAlign.LEFT,
|
|
1168
|
+
paddingData: { t: 0, b: 1, l: 2, r: 2 }
|
|
1169
|
+
}, editorWidth = editorRectInfo.richTextObj.width, editorHeight = editorRectInfo.richTextObj.height, left = editorRectInfo.richTextObj.left, top = editorRectInfo.richTextObj.top, canvasOffset = {
|
|
1170
|
+
left: 0,
|
|
1171
|
+
top: 0
|
|
1172
|
+
}, 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 = {
|
|
1173
|
+
x: (slideMainRect == null ? void 0 : slideMainRect.left) || 0,
|
|
1174
|
+
y: (slideMainRect == null ? void 0 : slideMainRect.top) || 0
|
|
1175
|
+
}, scrollX = (mainViewport == null ? void 0 : mainViewport.viewportScrollX) || 0, scrollY = (mainViewport == null ? void 0 : mainViewport.viewportScrollY) || 0;
|
|
1176
|
+
return canvasOffset.left = slidePos.x - scrollX, canvasOffset.top = slidePos.y - scrollY, {
|
|
1177
|
+
position: {
|
|
1178
|
+
startX: left,
|
|
1179
|
+
startY: top,
|
|
1180
|
+
endX: left + editorWidth,
|
|
1181
|
+
endY: top + editorHeight
|
|
1182
|
+
},
|
|
1183
|
+
scaleX: 1,
|
|
1184
|
+
scaleY: 1,
|
|
1185
|
+
slideCardOffset: canvasOffset,
|
|
1186
|
+
unitId,
|
|
1187
|
+
editorUnitId,
|
|
1188
|
+
documentLayoutObject
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
changeEditorDirty(dirtyStatus) {
|
|
1192
|
+
this._editorIsDirty = dirtyStatus;
|
|
1193
|
+
}
|
|
1194
|
+
isVisible() {
|
|
1195
|
+
return this._visible;
|
|
1196
|
+
}
|
|
1197
|
+
getEditorDirty() {
|
|
1198
|
+
return this._editorIsDirty;
|
|
1199
|
+
}
|
|
1200
|
+
getCurrentEditorId() {
|
|
1201
|
+
return this._editorUnitId;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* @deprecated
|
|
1205
|
+
*/
|
|
1206
|
+
genDocData(target) {
|
|
1207
|
+
const editorUnitId = this.getCurrentEditorId(), content = target.text, fontSize = target.fs;
|
|
1208
|
+
return {
|
|
1209
|
+
id: editorUnitId,
|
|
1210
|
+
body: {
|
|
1211
|
+
dataStream: `${content}\r
|
|
1212
|
+
`,
|
|
1213
|
+
textRuns: [{ st: 0, ed: content.length }],
|
|
1214
|
+
paragraphs: [{
|
|
1215
|
+
paragraphStyle: {
|
|
1216
|
+
// no use
|
|
1217
|
+
// textStyle: { fs: 30 },
|
|
1218
|
+
// horizontalAlign: HorizontalAlign.CENTER,
|
|
1219
|
+
// verticalAlign: VerticalAlign.MIDDLE,
|
|
1220
|
+
},
|
|
1221
|
+
startIndex: content.length + 1
|
|
1222
|
+
}],
|
|
1223
|
+
sectionBreaks: [{ startIndex: content.length + 2 }]
|
|
1224
|
+
},
|
|
1225
|
+
documentStyle: {
|
|
1226
|
+
marginBottom: 0,
|
|
1227
|
+
marginLeft: 0,
|
|
1228
|
+
marginRight: 0,
|
|
1229
|
+
marginTop: 0,
|
|
1230
|
+
pageSize: { width: 1 / 0, height: 1 / 0 },
|
|
1231
|
+
textStyle: { fs: fontSize },
|
|
1232
|
+
renderConfig: {
|
|
1233
|
+
// horizontalAlign: HorizontalAlign.CENTER,
|
|
1234
|
+
verticalAlign: VerticalAlign.MIDDLE,
|
|
1235
|
+
centerAngle: 0,
|
|
1236
|
+
vertexAngle: 0,
|
|
1237
|
+
wrapStrategy: 0
|
|
1238
|
+
}
|
|
1239
|
+
},
|
|
1240
|
+
drawings: {},
|
|
1241
|
+
drawingsOrder: [],
|
|
1242
|
+
settings: { zoomRatio: 1 }
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
}, __name(_a2, "SlideEditorBridgeService"), _a2);
|
|
1246
|
+
SlideEditorBridgeService = __decorateClass$6([
|
|
1247
|
+
__decorateParam$6(0, IEditorService),
|
|
1248
|
+
__decorateParam$6(1, IContextService),
|
|
1249
|
+
__decorateParam$6(2, IRenderManagerService)
|
|
1250
|
+
], SlideEditorBridgeService);
|
|
1251
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1252
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1253
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1254
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1255
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a3;
|
|
1256
|
+
let SlideRenderController = (_a3 = class extends RxDisposable {
|
|
1257
|
+
constructor(_context, _editorBridgeService) {
|
|
1258
|
+
super(), this._context = _context, this._editorBridgeService = _editorBridgeService;
|
|
1259
|
+
}
|
|
1260
|
+
dispose() {
|
|
1261
|
+
}
|
|
1262
|
+
}, __name(_a3, "SlideRenderController"), _a3);
|
|
1263
|
+
SlideRenderController = __decorateClass$5([
|
|
1264
|
+
__decorateParam$5(1, Inject(ISlideEditorBridgeService))
|
|
1265
|
+
], SlideRenderController);
|
|
1266
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1267
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1268
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1269
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1270
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
|
|
1271
|
+
function transformBound2OffsetBound(originBound, scene) {
|
|
1272
|
+
const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
|
|
1273
|
+
return {
|
|
1274
|
+
left: topLeft.x,
|
|
1275
|
+
top: topLeft.y,
|
|
1276
|
+
right: bottomRight.x,
|
|
1277
|
+
bottom: bottomRight.y
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
__name(transformBound2OffsetBound, "transformBound2OffsetBound");
|
|
1281
|
+
function transformPosition2Offset(x, y, scene) {
|
|
1282
|
+
const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SLIDE_KEY.VIEW);
|
|
1283
|
+
if (!viewMain)
|
|
1284
|
+
return {
|
|
1285
|
+
x,
|
|
1286
|
+
y
|
|
1287
|
+
};
|
|
1288
|
+
const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain, offsetX = (x - actualScrollX) * scaleX, offsetY = (y - actualScrollY) * scaleY;
|
|
1289
|
+
return {
|
|
1290
|
+
x: offsetX,
|
|
1291
|
+
y: offsetY
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
__name(transformPosition2Offset, "transformPosition2Offset");
|
|
1295
|
+
var _a4;
|
|
1296
|
+
let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
|
|
1297
|
+
constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
|
|
1298
|
+
super(), this._globalPopupManagerService = _globalPopupManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService;
|
|
1299
|
+
}
|
|
1300
|
+
_createObjectPositionObserver(targetObject, currentRender) {
|
|
1301
|
+
const position = (/* @__PURE__ */ __name(() => {
|
|
1302
|
+
var _a9, _b, _c, _d;
|
|
1303
|
+
const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (_a9 = currentRender.mainComponent) == null ? void 0 : _a9.width) != null ? _b : 0)) / 2, verticalOffset = (scene.height - ((_d = (_c = currentRender.mainComponent) == null ? void 0 : _c.height) != null ? _d : 0)) / 2, bound = {
|
|
1304
|
+
left,
|
|
1305
|
+
right: left + width,
|
|
1306
|
+
top,
|
|
1307
|
+
bottom: top + height
|
|
1308
|
+
}, 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;
|
|
1309
|
+
return {
|
|
1310
|
+
left: offsetBound.left * scaleAdjust * scaleX + leftOffset + horizontalOffset,
|
|
1311
|
+
right: offsetBound.right * scaleAdjust * scaleX + leftOffset + horizontalOffset,
|
|
1312
|
+
top: offsetBound.top * scaleAdjust * scaleY + topOffset + verticalOffset,
|
|
1313
|
+
bottom: offsetBound.bottom * scaleAdjust * scaleY + topOffset + verticalOffset
|
|
1314
|
+
};
|
|
1315
|
+
}, "calc"))(), position$ = new BehaviorSubject(position), disposable = new DisposableCollection();
|
|
1316
|
+
return {
|
|
1317
|
+
position,
|
|
1318
|
+
position$,
|
|
1319
|
+
disposable
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
attachPopupToObject(targetObject, popup) {
|
|
1323
|
+
const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE).getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
|
|
1324
|
+
if (!currentRender)
|
|
1325
|
+
return {
|
|
1326
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
1327
|
+
}, "dispose")
|
|
1328
|
+
};
|
|
1329
|
+
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender), id = this._globalPopupManagerService.addPopup({
|
|
1330
|
+
...popup,
|
|
1331
|
+
unitId,
|
|
1332
|
+
subUnitId: "default",
|
|
1333
|
+
anchorRect: position,
|
|
1334
|
+
anchorRect$: position$
|
|
1335
|
+
});
|
|
1336
|
+
return {
|
|
1337
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
1338
|
+
this._globalPopupManagerService.removePopup(id), position$.complete(), disposable.dispose();
|
|
1339
|
+
}, "dispose")
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
}, __name(_a4, "SlideCanvasPopMangerService"), _a4);
|
|
1343
|
+
SlideCanvasPopMangerService = __decorateClass$4([
|
|
1344
|
+
__decorateParam$4(0, Inject(ICanvasPopupService)),
|
|
1345
|
+
__decorateParam$4(1, IRenderManagerService),
|
|
1346
|
+
__decorateParam$4(2, IUniverInstanceService),
|
|
1347
|
+
__decorateParam$4(3, ICommandService)
|
|
1348
|
+
], SlideCanvasPopMangerService);
|
|
1349
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1350
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1351
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1352
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1353
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a5;
|
|
1354
|
+
let SlidePopupMenuController = (_a5 = class extends RxDisposable {
|
|
1355
|
+
constructor(_canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _canvasView, _sidebarService, _commandService) {
|
|
1356
|
+
super();
|
|
1357
|
+
__publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
|
|
1358
|
+
this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._canvasView = _canvasView, this._sidebarService = _sidebarService, this._commandService = _commandService, this._init();
|
|
1359
|
+
}
|
|
1360
|
+
_init() {
|
|
1361
|
+
this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => this._create(slide));
|
|
1362
|
+
}
|
|
1363
|
+
_dispose(workbook) {
|
|
1364
|
+
}
|
|
1365
|
+
_create(slide) {
|
|
1366
|
+
if (!slide)
|
|
1367
|
+
return;
|
|
1368
|
+
const unitId = slide.getUnitId();
|
|
1369
|
+
this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
|
|
1370
|
+
}
|
|
1371
|
+
_hasCropObject(scene) {
|
|
1372
|
+
}
|
|
1373
|
+
_popupMenuListener(unitId) {
|
|
1374
|
+
var _a9;
|
|
1375
|
+
const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a9 = model == null ? void 0 : model.getPages()) != null ? _a9 : {};
|
|
1376
|
+
Object.keys(pages).forEach((pageId) => {
|
|
1377
|
+
var _a10;
|
|
1378
|
+
const transformer = (_a10 = this._canvasView.getRenderUnitByPageId(pageId).scene) == null ? void 0 : _a10.getTransformer();
|
|
1379
|
+
if (!transformer) return;
|
|
1380
|
+
let singletonPopupDisposer;
|
|
1381
|
+
this.disposeWithMe(
|
|
1382
|
+
toDisposable(
|
|
1383
|
+
transformer.createControl$.subscribe(() => {
|
|
1384
|
+
const selectedObjects = transformer.getSelectedObjectMap();
|
|
1385
|
+
if (selectedObjects.size > 1) {
|
|
1386
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
const object = selectedObjects.values().next().value;
|
|
1390
|
+
if (!object)
|
|
1391
|
+
return;
|
|
1392
|
+
const oKey = object.oKey;
|
|
1393
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
|
|
1394
|
+
componentKey: COMPONENT_SLIDE_IMAGE_POPUP_MENU,
|
|
1395
|
+
direction: "horizontal",
|
|
1396
|
+
offset: [2, 0],
|
|
1397
|
+
extraProps: {
|
|
1398
|
+
menuItems: this._getMenuItemsByObjectType(object.objectType, oKey, unitId)
|
|
1399
|
+
}
|
|
1400
|
+
})), this._sidebarService.visible && this._commandService.executeCommand(ToggleSlideEditSidebarOperation.id, {
|
|
1401
|
+
visible: !0,
|
|
1402
|
+
objectType: object.objectType
|
|
1403
|
+
});
|
|
1404
|
+
})
|
|
1405
|
+
)
|
|
1406
|
+
), this.disposeWithMe(
|
|
1407
|
+
transformer.clearControl$.subscribe(() => {
|
|
1408
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1);
|
|
1409
|
+
})
|
|
1410
|
+
), this.disposeWithMe(
|
|
1411
|
+
transformer.changing$.subscribe(() => {
|
|
1412
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
1413
|
+
})
|
|
1414
|
+
);
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
_getMenuItemsByObjectType(objectType, oKey, unitId) {
|
|
1418
|
+
return [{
|
|
1419
|
+
label: "slide.popup.edit",
|
|
1420
|
+
index: 0,
|
|
1421
|
+
commandId: ToggleSlideEditSidebarOperation.id,
|
|
1422
|
+
commandParams: {
|
|
1423
|
+
visible: !0,
|
|
1424
|
+
objectType
|
|
1425
|
+
},
|
|
1426
|
+
disable: !1
|
|
1427
|
+
}, {
|
|
1428
|
+
label: "slide.popup.delete",
|
|
1429
|
+
index: 5,
|
|
1430
|
+
commandId: DeleteSlideElementOperation.id,
|
|
1431
|
+
commandParams: {
|
|
1432
|
+
id: oKey
|
|
1433
|
+
},
|
|
1434
|
+
disable: !1
|
|
1435
|
+
}];
|
|
1436
|
+
}
|
|
1437
|
+
}, __name(_a5, "SlidePopupMenuController"), _a5);
|
|
1438
|
+
SlidePopupMenuController = __decorateClass$3([
|
|
1439
|
+
OnLifecycle(LifecycleStages.Steady, SlidePopupMenuController),
|
|
1440
|
+
__decorateParam$3(0, Inject(SlideCanvasPopMangerService)),
|
|
1441
|
+
__decorateParam$3(1, IRenderManagerService),
|
|
1442
|
+
__decorateParam$3(2, IUniverInstanceService),
|
|
1443
|
+
__decorateParam$3(3, IContextService),
|
|
1444
|
+
__decorateParam$3(4, Inject(CanvasView)),
|
|
1445
|
+
__decorateParam$3(5, ISidebarService),
|
|
1446
|
+
__decorateParam$3(6, ICommandService)
|
|
1447
|
+
], SlidePopupMenuController);
|
|
1448
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1449
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1450
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1451
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
1452
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a6;
|
|
1453
|
+
let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
|
|
1454
|
+
constructor(_renderContext, _contextService, _instanceSrv, _commandService, _editorBridgeService, _textSelectionManagerService, _textSelectionRenderManager, _canvasView) {
|
|
1455
|
+
super();
|
|
1456
|
+
/**
|
|
1457
|
+
* It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
|
|
1458
|
+
*/
|
|
1459
|
+
__publicField(this, "_cursorChange", 0);
|
|
1460
|
+
/** If the corresponding unit is active and prepared for editing. */
|
|
1461
|
+
__publicField(this, "_isUnitEditing", !1);
|
|
1462
|
+
__publicField(this, "setSlideTextEditor$", new Subject());
|
|
1463
|
+
__publicField(this, "_curRichText", null);
|
|
1464
|
+
this._renderContext = _renderContext, this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this._textSelectionManagerService = _textSelectionManagerService, this._textSelectionRenderManager = _textSelectionRenderManager, this._canvasView = _canvasView, Promise.resolve().then(() => this._init());
|
|
1465
|
+
}
|
|
1466
|
+
_init() {
|
|
1467
|
+
const d = new DisposableCollection();
|
|
1468
|
+
return this._initSubjectListener(d), this._initEventListener(d), d;
|
|
1469
|
+
}
|
|
1470
|
+
_initSubjectListener(d) {
|
|
1471
|
+
}
|
|
1472
|
+
_setEditorRect(targetObject) {
|
|
1473
|
+
this._curRichText = targetObject;
|
|
1474
|
+
const { scene, engine } = this._renderContext, unitId = this._renderContext.unitId, setEditorRect = {
|
|
1475
|
+
scene,
|
|
1476
|
+
engine,
|
|
1477
|
+
unitId,
|
|
1478
|
+
pageId: "",
|
|
1479
|
+
richTextObj: targetObject
|
|
1480
|
+
};
|
|
1481
|
+
this._editorBridgeService.setEditorRect(setEditorRect);
|
|
1482
|
+
}
|
|
1483
|
+
_initEventListener(d) {
|
|
1484
|
+
var _a9;
|
|
1485
|
+
const model = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pagesMap = (_a9 = model == null ? void 0 : model.getPages()) != null ? _a9 : {}, pages = Object.values(pagesMap);
|
|
1486
|
+
for (let i = 0; i < pages.length; i++) {
|
|
1487
|
+
const page = pages[i], { scene } = this._canvasView.getRenderUnitByPageId(page.id);
|
|
1488
|
+
if (!scene) break;
|
|
1489
|
+
const transformer = scene.getTransformer();
|
|
1490
|
+
if (!transformer) break;
|
|
1491
|
+
d.add(transformer.clearControl$.subscribe(() => {
|
|
1492
|
+
this.setEditorVisible(!1);
|
|
1493
|
+
})), d.add(transformer.createControl$.subscribe(() => {
|
|
1494
|
+
this.setEditorVisible(!1);
|
|
1495
|
+
})), d.add(transformer.changeStart$.subscribe((param) => {
|
|
1496
|
+
const target = param.target;
|
|
1497
|
+
target && (target === this._curRichText || this.pickOtherObjects());
|
|
1498
|
+
})), d.add(scene.onDblclick$.subscribeEvent(() => {
|
|
1499
|
+
transformer.clearControls();
|
|
1500
|
+
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
1501
|
+
object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(object));
|
|
1502
|
+
}));
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
pickOtherObjects() {
|
|
1506
|
+
this.setEditorVisible(!1), this.endEditing();
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* invoked when picking other object.
|
|
1510
|
+
*
|
|
1511
|
+
* save editing state to curr richText.
|
|
1512
|
+
*/
|
|
1513
|
+
endEditing() {
|
|
1514
|
+
if (!this._curRichText) return;
|
|
1515
|
+
const curRichText = this._curRichText;
|
|
1516
|
+
if (!this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) return !1;
|
|
1517
|
+
curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._curRichText = null;
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* TODO calling twice ????
|
|
1521
|
+
* editingParam derives from RichText object.
|
|
1522
|
+
*
|
|
1523
|
+
* TODO @lumixraku need scale param
|
|
1524
|
+
* @param target
|
|
1525
|
+
*/
|
|
1526
|
+
startEditing(target) {
|
|
1527
|
+
this._setEditorRect(target), this.setEditorVisible(!0);
|
|
1528
|
+
}
|
|
1529
|
+
setEditorVisible(visible) {
|
|
1530
|
+
var _a9, _b;
|
|
1531
|
+
visible ? (_a9 = this._curRichText) == null || _a9.hide() : (_b = this._curRichText) == null || _b.show();
|
|
1532
|
+
const { unitId } = this._renderContext;
|
|
1533
|
+
this._editorBridgeService.changeVisible({ visible, eventType: 3, unitId });
|
|
1534
|
+
}
|
|
1535
|
+
}, __name(_a6, "SlideEditorBridgeRenderController"), _a6);
|
|
1536
|
+
SlideEditorBridgeRenderController = __decorateClass$2([
|
|
1537
|
+
__decorateParam$2(1, IContextService),
|
|
1538
|
+
__decorateParam$2(2, IUniverInstanceService),
|
|
1539
|
+
__decorateParam$2(3, ICommandService),
|
|
1540
|
+
__decorateParam$2(4, Inject(ISlideEditorBridgeService)),
|
|
1541
|
+
__decorateParam$2(5, Inject(TextSelectionManagerService)),
|
|
1542
|
+
__decorateParam$2(6, ITextSelectionRenderManager),
|
|
1543
|
+
__decorateParam$2(7, Inject(CanvasView))
|
|
1544
|
+
], SlideEditorBridgeRenderController);
|
|
1545
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1546
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1547
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1548
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
1549
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
|
|
1550
|
+
const HIDDEN_EDITOR_POSITION = -1e3, EDITOR_INPUT_SELF_EXTEND_GAP = 5, EDITOR_BORDER_SIZE = 2;
|
|
1551
|
+
var _a7;
|
|
1552
|
+
let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
1553
|
+
constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionRenderManager, _textSelectionManagerService, _commandService, _localService, _editorService, _resourceLoaderService) {
|
|
1554
|
+
super();
|
|
1555
|
+
/**
|
|
1556
|
+
* It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
|
|
1557
|
+
*/
|
|
1558
|
+
__publicField(this, "_cursorChange", 0);
|
|
1559
|
+
/** If the corresponding unit is active and prepared for editing. */
|
|
1560
|
+
__publicField(this, "_isUnitEditing", !1);
|
|
1561
|
+
// private _workbookSelections: WorkbookSelections;
|
|
1562
|
+
__publicField(this, "_d");
|
|
1563
|
+
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._textSelectionRenderManager = _textSelectionRenderManager, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, this._localService = _localService, this._editorService = _editorService, this._resourceLoaderService = _resourceLoaderService, this._d = this._init(), this._initEditorVisibilityListener();
|
|
1564
|
+
}
|
|
1565
|
+
dispose() {
|
|
1566
|
+
super.dispose(), this._disposeCurrent();
|
|
1567
|
+
}
|
|
1568
|
+
_disposeCurrent() {
|
|
1569
|
+
var _a9;
|
|
1570
|
+
(_a9 = this._d) == null || _a9.dispose(), this._d = null;
|
|
1571
|
+
}
|
|
1572
|
+
_init() {
|
|
1573
|
+
const d = new DisposableCollection();
|
|
1574
|
+
return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), this._cursorStateListener(d), d;
|
|
1575
|
+
}
|
|
1576
|
+
_initEditorVisibilityListener() {
|
|
1577
|
+
this.disposeWithMe(this._editorBridgeService.visible$.subscribe((param) => {
|
|
1578
|
+
param.visible ? (this._isUnitEditing = !0, this._handleEditorVisible(param)) : this._isUnitEditing && (this._handleEditorInvisible(param), this._isUnitEditing = !1);
|
|
1579
|
+
}));
|
|
1580
|
+
}
|
|
1581
|
+
_listenEditorFocus(d) {
|
|
1582
|
+
const renderConfig = this._getEditorObject();
|
|
1583
|
+
renderConfig && d.add(renderConfig.document.onPointerDown$.subscribeEvent(() => {
|
|
1584
|
+
}));
|
|
1585
|
+
}
|
|
1586
|
+
_getEditorSkeleton(editorId) {
|
|
1587
|
+
var _a9;
|
|
1588
|
+
return (_a9 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a9.with(DocSkeletonManagerService).getSkeleton();
|
|
1589
|
+
}
|
|
1590
|
+
_getEditorViewModel(editorId) {
|
|
1591
|
+
var _a9;
|
|
1592
|
+
return (_a9 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a9.with(DocSkeletonManagerService).getViewModel();
|
|
1593
|
+
}
|
|
1594
|
+
_initialCursorSync(d) {
|
|
1595
|
+
d.add(this._cellEditorManagerService.focus$.pipe(filter((f2) => !!f2)).subscribe(() => {
|
|
1596
|
+
this._textSelectionRenderManager.sync();
|
|
1597
|
+
}));
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Set editorUnitId to curr doc.
|
|
1601
|
+
* @param d DisposableCollection
|
|
1602
|
+
*/
|
|
1603
|
+
_subscribeToCurrentCell(d) {
|
|
1604
|
+
d.add(this._editorBridgeService.currentEditRectState$.subscribe((editCellState) => {
|
|
1605
|
+
if (editCellState == null || this._contextService.getContextValue(FOCUSING_EDITOR_STANDALONE) || this._contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE))
|
|
1606
|
+
return;
|
|
1607
|
+
const {
|
|
1608
|
+
position: { startX, endX },
|
|
1609
|
+
documentLayoutObject: { textRotation, wrapStrategy, documentModel },
|
|
1610
|
+
scaleX,
|
|
1611
|
+
editorUnitId
|
|
1612
|
+
} = editCellState, { vertexAngle: angle } = convertTextRotation(textRotation);
|
|
1613
|
+
documentModel.updateDocumentId(editorUnitId), wrapStrategy === WrapStrategy.WRAP && angle === 0 && documentModel.updateDocumentDataPageSize((endX - startX) / scaleX), this._instanceSrv.changeDoc(editorUnitId, documentModel), this._contextService.setContextValue(FOCUSING_EDITOR_BUT_HIDDEN, !0), this._textSelectionManagerService.replaceTextRanges([{
|
|
1614
|
+
startOffset: 0,
|
|
1615
|
+
endOffset: 0
|
|
1616
|
+
}]), this._textSelectionRenderManager.activate(HIDDEN_EDITOR_POSITION, HIDDEN_EDITOR_POSITION);
|
|
1617
|
+
}));
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* set size and pos of editing area
|
|
1621
|
+
* invoked by _handleEditorVisible
|
|
1622
|
+
*
|
|
1623
|
+
* size & pos derives from slide-editor-bridge.service.ts@getEditRectState.position
|
|
1624
|
+
*
|
|
1625
|
+
* set pos of editing area
|
|
1626
|
+
* EditorContainer.tsx cellEditorManagerService.setFocus(true) -->
|
|
1627
|
+
* _focus$.next --> editingRenderController -->
|
|
1628
|
+
* _textSelectionRenderManager.sync() --> _updateInputPosition --> activate(left, top)
|
|
1629
|
+
*
|
|
1630
|
+
* @param positionFromEditRectState
|
|
1631
|
+
* @param canvasOffset
|
|
1632
|
+
* @param documentSkeleton
|
|
1633
|
+
* @param documentLayoutObject
|
|
1634
|
+
* @param scaleX
|
|
1635
|
+
* @param scaleY
|
|
1636
|
+
*/
|
|
1637
|
+
_fitTextSize(positionFromEditRectState, canvasOffset, documentSkeleton, documentLayoutObject, scaleX = 1, scaleY = 1) {
|
|
1638
|
+
const { startX, startY, endX, endY } = positionFromEditRectState, documentDataModel = documentLayoutObject.documentModel;
|
|
1639
|
+
if (documentDataModel == null)
|
|
1640
|
+
return;
|
|
1641
|
+
const { actualWidth, actualHeight } = this._predictingSize(
|
|
1642
|
+
positionFromEditRectState,
|
|
1643
|
+
canvasOffset,
|
|
1644
|
+
documentSkeleton,
|
|
1645
|
+
documentLayoutObject,
|
|
1646
|
+
scaleX,
|
|
1647
|
+
scaleY
|
|
1648
|
+
), { verticalAlign, paddingData, fill } = documentLayoutObject;
|
|
1649
|
+
let editorWidth = endX - startX, editorHeight = endY - startY;
|
|
1650
|
+
if (editorWidth < actualWidth && (editorWidth = actualWidth), editorHeight < actualHeight)
|
|
1651
|
+
editorHeight = actualHeight, documentDataModel.updateDocumentDataMargin(paddingData);
|
|
1652
|
+
else {
|
|
1653
|
+
let offsetTop = 0;
|
|
1654
|
+
verticalAlign === VerticalAlign.MIDDLE ? offsetTop = (editorHeight - actualHeight) / 2 / scaleY : verticalAlign === VerticalAlign.TOP ? offsetTop = paddingData.t || 0 : offsetTop = (editorHeight - actualHeight) / scaleY - (paddingData.b || 0), offsetTop = offsetTop < (paddingData.t || 0) ? paddingData.t || 0 : offsetTop, documentDataModel.updateDocumentDataMargin({
|
|
1655
|
+
t: offsetTop
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
documentSkeleton.calculate(), this._editAreaProcessing(editorWidth, editorHeight, positionFromEditRectState, canvasOffset, fill, scaleX, scaleY);
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Mainly used to pre-calculate the width of the editor,
|
|
1662
|
+
* to determine whether it needs to be automatically widened.
|
|
1663
|
+
*/
|
|
1664
|
+
_predictingSize(actualRangeWithCoord, canvasOffset, documentSkeleton, documentLayoutObject, scaleX = 1, scaleY = 1) {
|
|
1665
|
+
const { startX, endX } = actualRangeWithCoord, { textRotation, wrapStrategy } = documentLayoutObject, documentDataModel = documentLayoutObject.documentModel, { vertexAngle: angle } = convertTextRotation(textRotation), clientWidth = document.body.clientWidth;
|
|
1666
|
+
if (wrapStrategy === WrapStrategy.WRAP && angle === 0) {
|
|
1667
|
+
const { actualWidth, actualHeight } = documentSkeleton.getActualSize();
|
|
1668
|
+
return {
|
|
1669
|
+
actualWidth: actualWidth * scaleX,
|
|
1670
|
+
actualHeight: actualHeight * scaleY
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
documentDataModel == null || documentDataModel.updateDocumentDataPageSize((clientWidth - startX - canvasOffset.left) / scaleX), documentSkeleton.calculate();
|
|
1674
|
+
const size = documentSkeleton.getActualSize();
|
|
1675
|
+
let editorWidth = endX - startX;
|
|
1676
|
+
return editorWidth < size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX && (editorWidth = size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX), documentDataModel == null || documentDataModel.updateDocumentDataPageSize(editorWidth / scaleX), documentDataModel == null || documentDataModel.updateDocumentRenderConfig({
|
|
1677
|
+
horizontalAlign: HorizontalAlign.UNSPECIFIED,
|
|
1678
|
+
cellValueType: void 0
|
|
1679
|
+
}), {
|
|
1680
|
+
actualWidth: editorWidth,
|
|
1681
|
+
actualHeight: size.actualHeight * scaleY
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* control the size of editing area
|
|
1686
|
+
*/
|
|
1687
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1688
|
+
_editAreaProcessing(editorWidth, editorHeight, positionFromEditRectState, canvasOffset, fill, scaleX = 1, scaleY = 1) {
|
|
1689
|
+
var _a9;
|
|
1690
|
+
const editorObject = this._getEditorObject();
|
|
1691
|
+
if (editorObject == null)
|
|
1692
|
+
return;
|
|
1693
|
+
function pxToNum2(width2) {
|
|
1694
|
+
return Number.parseInt(width2.replace("px", ""));
|
|
1695
|
+
}
|
|
1696
|
+
__name(pxToNum2, "pxToNum");
|
|
1697
|
+
const canvasElement = this._renderContext.engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum2(canvasElement.style.width), { top, left, width } = canvasClientRect, scaleAdjust = width / widthOfCanvas;
|
|
1698
|
+
let { startX, startY } = positionFromEditRectState;
|
|
1699
|
+
startX += canvasOffset.left, startY += canvasOffset.top;
|
|
1700
|
+
const { document: documentComponent, scene: editorScene, engine: docEngine } = editorObject, viewportMain = editorScene.getViewport(VIEWPORT_KEY.VIEW_MAIN), clientHeight = document.body.clientHeight - startY - canvasOffset.top - EDITOR_BORDER_SIZE * 2, clientWidth = document.body.clientWidth - startX - canvasOffset.left;
|
|
1701
|
+
let physicHeight = editorHeight, scrollBar = viewportMain == null ? void 0 : viewportMain.getScrollBar();
|
|
1702
|
+
physicHeight > clientHeight ? (physicHeight = clientHeight, scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll()) : (scrollBar = null, (_a9 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _a9.dispose()), editorWidth += (scrollBar == null ? void 0 : scrollBar.barSize) || 0, editorWidth = Math.min(editorWidth, clientWidth), startX -= FIX_ONE_PIXEL_BLUR_OFFSET, startY -= FIX_ONE_PIXEL_BLUR_OFFSET, this._addBackground(editorScene, editorWidth / scaleX, editorHeight / scaleY, fill);
|
|
1703
|
+
const { scaleX: precisionScaleX, scaleY: precisionScaleY } = editorScene.getPrecisionScale();
|
|
1704
|
+
editorScene.transformByState({
|
|
1705
|
+
width: editorWidth * scaleAdjust / scaleX,
|
|
1706
|
+
height: editorHeight * scaleAdjust / scaleY,
|
|
1707
|
+
scaleX: scaleX * scaleAdjust,
|
|
1708
|
+
scaleY: scaleY * scaleAdjust
|
|
1709
|
+
}), documentComponent.resize(editorWidth / scaleX, editorHeight / scaleY), setTimeout(() => {
|
|
1710
|
+
docEngine.resizeBySize(
|
|
1711
|
+
fixLineWidthByScale(editorWidth, precisionScaleX),
|
|
1712
|
+
fixLineWidthByScale(physicHeight, precisionScaleY)
|
|
1713
|
+
);
|
|
1714
|
+
}, 0);
|
|
1715
|
+
const contentBoundingRect = this._layoutService.getContentElement().getBoundingClientRect(), canvasBoundingRect = canvasElement.getBoundingClientRect();
|
|
1716
|
+
startX = startX * scaleAdjust + (canvasBoundingRect.left - contentBoundingRect.left), startY = startY * scaleAdjust + (canvasBoundingRect.top - contentBoundingRect.top), this._cellEditorManagerService.setState({
|
|
1717
|
+
startX,
|
|
1718
|
+
startY,
|
|
1719
|
+
endX: editorWidth * scaleAdjust + startX,
|
|
1720
|
+
endY: physicHeight * scaleAdjust + startY,
|
|
1721
|
+
show: !0
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Since the document does not support cell background color, an additional rect needs to be added.
|
|
1726
|
+
*/
|
|
1727
|
+
_addBackground(scene, editorWidth, editorHeight, fill) {
|
|
1728
|
+
const fillRectKey = "_backgroundRectHelperColor_", rect = scene.getObject(fillRectKey);
|
|
1729
|
+
rect == null && fill == null || (rect == null ? scene.addObjects(
|
|
1730
|
+
[
|
|
1731
|
+
new Rect(fillRectKey, {
|
|
1732
|
+
width: editorWidth,
|
|
1733
|
+
height: editorHeight,
|
|
1734
|
+
fill,
|
|
1735
|
+
evented: !1
|
|
1736
|
+
})
|
|
1737
|
+
],
|
|
1738
|
+
DOCS_COMPONENT_MAIN_LAYER_INDEX
|
|
1739
|
+
) : fill == null ? rect.dispose() : (rect.setProps({
|
|
1740
|
+
fill
|
|
1741
|
+
}), rect.transformByState({
|
|
1742
|
+
width: editorWidth,
|
|
1743
|
+
height: editorHeight
|
|
1744
|
+
})));
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* show input area, resize input area and then place input to right place.
|
|
1748
|
+
* invoked when this._editorBridgeService.visible$ param.visible = true
|
|
1749
|
+
*
|
|
1750
|
+
* handleVisible is the 2nd part of editing.
|
|
1751
|
+
* startEditing --> _updateEditor
|
|
1752
|
+
* startEditing --> changeVisible --> slide-editor-bridge.render-controller.ts@changeVisible --> _editorBridgeService.changeVisible
|
|
1753
|
+
* @param param
|
|
1754
|
+
*/
|
|
1755
|
+
_handleEditorVisible(param) {
|
|
1756
|
+
var _a9, _b;
|
|
1757
|
+
const { eventType, keycode } = param;
|
|
1758
|
+
this._cursorChange = [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType) ? 2 : 1;
|
|
1759
|
+
const editCellState = this._editorBridgeService.getEditRectState();
|
|
1760
|
+
if (editCellState == null)
|
|
1761
|
+
return;
|
|
1762
|
+
const {
|
|
1763
|
+
position,
|
|
1764
|
+
documentLayoutObject,
|
|
1765
|
+
slideCardOffset: canvasOffset,
|
|
1766
|
+
scaleX,
|
|
1767
|
+
scaleY,
|
|
1768
|
+
editorUnitId,
|
|
1769
|
+
unitId
|
|
1770
|
+
} = editCellState, editorObject = this._getEditorObject();
|
|
1771
|
+
if (editorObject == null)
|
|
1772
|
+
return;
|
|
1773
|
+
const { scene } = editorObject;
|
|
1774
|
+
this._contextService.setContextValue(EDITOR_ACTIVATED, !0);
|
|
1775
|
+
const { documentModel: documentDataModel } = documentLayoutObject, skeleton = this._getEditorSkeleton(editorUnitId);
|
|
1776
|
+
if (!skeleton || !documentDataModel)
|
|
1777
|
+
return;
|
|
1778
|
+
this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);
|
|
1779
|
+
const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
|
|
1780
|
+
(_a9 = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) == null || _a9.scrollToViewportPos({
|
|
1781
|
+
viewportScrollX: Number.POSITIVE_INFINITY
|
|
1782
|
+
}), this._textSelectionManagerService.replaceTextRanges([
|
|
1783
|
+
{
|
|
1784
|
+
startOffset: cursor,
|
|
1785
|
+
endOffset: cursor
|
|
1786
|
+
}
|
|
1787
|
+
]), (_b = this._renderManagerService.getRenderById(unitId)) == null || _b.scene.resetCursor();
|
|
1788
|
+
}
|
|
1789
|
+
_resetBodyStyle(body, removeStyle = !1) {
|
|
1790
|
+
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 = [
|
|
1791
|
+
{
|
|
1792
|
+
startIndex: 0
|
|
1793
|
+
}
|
|
1794
|
+
]), 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);
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Should activate the editor when the user inputs text.
|
|
1798
|
+
* @param d DisposableCollection
|
|
1799
|
+
*/
|
|
1800
|
+
_initialKeyboardListener(d) {
|
|
1801
|
+
d.add(this._textSelectionRenderManager.onInputBefore$.subscribe((config) => {
|
|
1802
|
+
}));
|
|
1803
|
+
}
|
|
1804
|
+
_showEditorByKeyboard(config) {
|
|
1805
|
+
}
|
|
1806
|
+
_commandExecutedListener(d) {
|
|
1807
|
+
const moveCursorOP = [SetTextEditArrowOperation.id], editedMutations = [RichTextEditingMutation.id];
|
|
1808
|
+
d.add(this._commandService.onCommandExecuted((command) => {
|
|
1809
|
+
moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editingChangedHandler();
|
|
1810
|
+
}));
|
|
1811
|
+
}
|
|
1812
|
+
_moveCursorCmdHandler(command) {
|
|
1813
|
+
const params = command.params, { keycode, isShift } = params;
|
|
1814
|
+
keycode != null && this._cursorChange === 2 ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
|
|
1815
|
+
}
|
|
1816
|
+
_editingChangedHandler() {
|
|
1817
|
+
const editRect = this._editorBridgeService.getEditorRect();
|
|
1818
|
+
if (!editRect)
|
|
1819
|
+
return;
|
|
1820
|
+
const editingRichText = editRect.richTextObj;
|
|
1821
|
+
editingRichText.refreshDocumentByDocData(), editingRichText.resizeToContentSize();
|
|
1822
|
+
const { unitId } = this._renderContext;
|
|
1823
|
+
this._handleEditorVisible({ visible: !0, eventType: 3, unitId });
|
|
1824
|
+
}
|
|
1825
|
+
_setOpenForCurrent(unitId, subUnitId) {
|
|
1826
|
+
const editors = this._editorService.getAllEditor();
|
|
1827
|
+
for (const [_, ed] of editors)
|
|
1828
|
+
ed.setOpenForSheetUnitId(unitId), ed.setOpenForSheetSubUnitId(subUnitId);
|
|
1829
|
+
}
|
|
1830
|
+
_getEditorObject() {
|
|
1831
|
+
return getEditorObject(this._editorBridgeService.getCurrentEditorId(), this._renderManagerService);
|
|
1832
|
+
}
|
|
1833
|
+
async _handleEditorInvisible(param) {
|
|
1834
|
+
const { keycode } = param;
|
|
1835
|
+
if (this._setOpenForCurrent(null, null), this._cursorChange = 0, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
|
|
1836
|
+
return;
|
|
1837
|
+
if (this._editorBridgeService.getEditorDirty() === !1) {
|
|
1838
|
+
this._moveCursor(keycode);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
this._moveCursor(keycode);
|
|
1842
|
+
}
|
|
1843
|
+
_exitInput(param) {
|
|
1844
|
+
this._contextService.setContextValue(FOCUSING_EDITOR_INPUT_FORMULA, !1), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_BUT_HIDDEN, !1), this._contextService.setContextValue(FORMULA_EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
|
|
1845
|
+
show: param.visible
|
|
1846
|
+
});
|
|
1847
|
+
const editorUnitId = this._editorBridgeService.getCurrentEditorId();
|
|
1848
|
+
editorUnitId != null && (this._undoRedoService.clearUndoRedo(editorUnitId), this._undoRedoService.clearUndoRedo(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY));
|
|
1849
|
+
}
|
|
1850
|
+
_moveCursor(keycode) {
|
|
1851
|
+
if (keycode != null)
|
|
1852
|
+
switch (Direction.LEFT, keycode) {
|
|
1853
|
+
case KeyCode.ENTER:
|
|
1854
|
+
Direction.DOWN;
|
|
1855
|
+
break;
|
|
1856
|
+
case KeyCode.TAB:
|
|
1857
|
+
Direction.RIGHT;
|
|
1858
|
+
break;
|
|
1859
|
+
case KeyCode.ARROW_DOWN:
|
|
1860
|
+
Direction.DOWN;
|
|
1861
|
+
break;
|
|
1862
|
+
case KeyCode.ARROW_UP:
|
|
1863
|
+
Direction.UP;
|
|
1864
|
+
break;
|
|
1865
|
+
case KeyCode.ARROW_LEFT:
|
|
1866
|
+
Direction.LEFT;
|
|
1867
|
+
break;
|
|
1868
|
+
case KeyCode.ARROW_RIGHT:
|
|
1869
|
+
Direction.RIGHT;
|
|
1870
|
+
break;
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* The user's operations follow the sequence of opening the editor and then moving the cursor.
|
|
1875
|
+
* The logic here predicts the user's first cursor movement behavior based on this rule
|
|
1876
|
+
*/
|
|
1877
|
+
_cursorStateListener(d) {
|
|
1878
|
+
const editorObject = this._getEditorObject(), { document: documentComponent } = editorObject;
|
|
1879
|
+
d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
|
|
1880
|
+
this._cursorChange === 1 && (this._cursorChange = 2);
|
|
1881
|
+
})));
|
|
1882
|
+
}
|
|
1883
|
+
// TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
|
|
1884
|
+
_moveInEditor(keycode, isShift) {
|
|
1885
|
+
let direction = Direction.LEFT;
|
|
1886
|
+
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, {
|
|
1887
|
+
direction
|
|
1888
|
+
}) : this._commandService.executeCommand(MoveCursorOperation.id, {
|
|
1889
|
+
direction
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
}, __name(_a7, "SlideEditingRenderController"), _a7);
|
|
1893
|
+
SlideEditingRenderController = __decorateClass$1([
|
|
1894
|
+
__decorateParam$1(1, ILayoutService),
|
|
1895
|
+
__decorateParam$1(2, IUndoRedoService),
|
|
1896
|
+
__decorateParam$1(3, IContextService),
|
|
1897
|
+
__decorateParam$1(4, IUniverInstanceService),
|
|
1898
|
+
__decorateParam$1(5, IRenderManagerService),
|
|
1899
|
+
__decorateParam$1(6, ISlideEditorBridgeService),
|
|
1900
|
+
__decorateParam$1(7, ISlideEditorManagerService),
|
|
1901
|
+
__decorateParam$1(8, ITextSelectionRenderManager),
|
|
1902
|
+
__decorateParam$1(9, Inject(TextSelectionManagerService)),
|
|
1903
|
+
__decorateParam$1(10, ICommandService),
|
|
1904
|
+
__decorateParam$1(11, Inject(LocaleService)),
|
|
1905
|
+
__decorateParam$1(12, IEditorService),
|
|
1906
|
+
__decorateParam$1(13, IResourceLoaderService)
|
|
1907
|
+
], SlideEditingRenderController);
|
|
1908
|
+
function getEditorObject(unitId, renderManagerService) {
|
|
1909
|
+
if (unitId == null)
|
|
1910
|
+
return;
|
|
1911
|
+
const currentRender = renderManagerService.getRenderById(unitId);
|
|
1912
|
+
if (currentRender == null)
|
|
1913
|
+
return;
|
|
1914
|
+
const { mainComponent, scene, engine, components } = currentRender, document2 = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND);
|
|
1915
|
+
return {
|
|
1916
|
+
document: document2,
|
|
1917
|
+
docBackground,
|
|
1918
|
+
scene,
|
|
1919
|
+
engine
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
__name(getEditorObject, "getEditorObject");
|
|
1923
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1924
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1925
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1926
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
1927
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
1928
|
+
const SLIDE_UI_PLUGIN_NAME = "SLIDE_UI";
|
|
1929
|
+
var _a8;
|
|
1930
|
+
let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
|
|
1931
|
+
constructor(_config = {}, _injector, _renderManagerService, _univerInstanceService) {
|
|
1932
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService;
|
|
1933
|
+
}
|
|
1934
|
+
onStarting() {
|
|
1935
|
+
mergeOverrideWithDependencies([
|
|
1936
|
+
[ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
|
|
1937
|
+
// used by SlideUIController --> EditorContainer
|
|
1938
|
+
[ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
|
|
1939
|
+
[SlideCanvasPopMangerService]
|
|
1940
|
+
], this._config.override).forEach((d) => this._injector.add(d));
|
|
1941
|
+
}
|
|
1942
|
+
onReady() {
|
|
1943
|
+
mergeOverrideWithDependencies([
|
|
1944
|
+
// cannot register in _renderManagerService now.
|
|
1945
|
+
// [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
|
|
1946
|
+
// // used by SlideUIController --> EditorContainer
|
|
1947
|
+
// [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
|
|
1948
|
+
// This controller should be registered in Ready stage.
|
|
1949
|
+
// this controller would add a new RenderUnit (__INTERNAL_EDITOR__DOCS_NORMAL)
|
|
1950
|
+
// so this new RenderUnit does not have ISlideEditorBridgeService & ISlideEditorManagerService if
|
|
1951
|
+
[SlidesUIController, {
|
|
1952
|
+
useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SlidesUIController, this._config), "useFactory")
|
|
1953
|
+
}],
|
|
1954
|
+
// editor service were create in renderManagerService
|
|
1955
|
+
[SlideRenderController],
|
|
1956
|
+
[SlidePopupMenuController]
|
|
1957
|
+
], this._config.override).forEach((m2) => {
|
|
1958
|
+
this._injector.add(m2);
|
|
1959
|
+
});
|
|
135
1960
|
}
|
|
136
1961
|
onRendered() {
|
|
137
|
-
|
|
1962
|
+
[
|
|
1963
|
+
// need slideEditorBridgeService
|
|
1964
|
+
// need TextSelectionRenderService which init by EditorContainer
|
|
1965
|
+
[SlideEditorBridgeRenderController],
|
|
1966
|
+
[SlideEditingRenderController]
|
|
1967
|
+
].forEach((m2) => {
|
|
1968
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m2));
|
|
1969
|
+
}), this._markSlideAsFocused();
|
|
138
1970
|
}
|
|
139
1971
|
_markSlideAsFocused() {
|
|
140
|
-
const
|
|
1972
|
+
const currentService = this._univerInstanceService;
|
|
141
1973
|
try {
|
|
142
|
-
const
|
|
143
|
-
|
|
1974
|
+
const slide = currentService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
1975
|
+
currentService.focusUnit(slide.getUnitId());
|
|
144
1976
|
} catch {
|
|
145
1977
|
}
|
|
146
1978
|
}
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1979
|
+
}, __name(_a8, "UniverSlidesUIPlugin"), __publicField(_a8, "pluginName", SLIDE_UI_PLUGIN_NAME), __publicField(_a8, "type", UniverInstanceType.UNIVER_SLIDE), _a8);
|
|
1980
|
+
UniverSlidesUIPlugin = __decorateClass([
|
|
1981
|
+
__decorateParam(1, Inject(Injector)),
|
|
1982
|
+
__decorateParam(2, IRenderManagerService),
|
|
1983
|
+
__decorateParam(3, IUniverInstanceService)
|
|
1984
|
+
], UniverSlidesUIPlugin);
|
|
152
1985
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
1986
|
+
ActivateSlidePageOperation,
|
|
1987
|
+
AppendSlideOperation,
|
|
1988
|
+
EditorContainer,
|
|
1989
|
+
IMAGE_MENU_ID,
|
|
1990
|
+
SHAPE_MENU_ID,
|
|
1991
|
+
SetSlidePageThumbOperation,
|
|
1992
|
+
SlideAddTextOperation,
|
|
1993
|
+
SlideCanvasPopMangerService,
|
|
1994
|
+
SlideSideBar,
|
|
1995
|
+
SlidesUIController,
|
|
1996
|
+
UniverSlidesUIPlugin
|
|
156
1997
|
};
|