@univerjs/slides-ui 0.2.7 → 0.2.8
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 -3
- package/lib/es/index.js +792 -379
- package/lib/types/commands/operations/activate.operation.d.ts +1 -1
- package/lib/types/commands/operations/append-slide.operation.d.ts +5 -3
- package/lib/types/commands/operations/delete-element.operation.d.ts +1 -1
- package/lib/types/commands/operations/insert-image.operation.d.ts +1 -1
- package/lib/types/commands/operations/insert-shape.operation.d.ts +2 -1
- package/lib/types/commands/operations/insert-text.operation.d.ts +2 -1
- package/lib/types/commands/operations/set-thumb.operation.d.ts +3 -1
- package/lib/types/commands/operations/text-edit.operation.d.ts +0 -1
- package/lib/types/commands/operations/update-element.operation.d.ts +1 -1
- package/lib/types/components/image-popup-menu/ImagePopupMenu.d.ts +0 -1
- package/lib/types/components/panels/ArrangePanel.d.ts +1 -1
- package/lib/types/components/panels/FillPanel.d.ts +1 -1
- package/lib/types/components/panels/TransformPanel.d.ts +1 -1
- package/lib/types/components/sidebar/Sidebar.d.ts +0 -1
- package/lib/types/components/slide-bar/SlideBar.d.ts +0 -1
- package/lib/types/components/upload-component/UploadFile.d.ts +0 -1
- package/lib/types/components/upload-component/component-name.d.ts +1 -1
- package/lib/types/const.d.ts +16 -0
- package/lib/types/controllers/canvas-view.d.ts +22 -0
- package/lib/types/controllers/image.menu.d.ts +0 -1
- package/lib/types/controllers/popup-menu.controller.d.ts +1 -2
- package/lib/types/controllers/shape.menu.d.ts +0 -1
- package/lib/types/controllers/shortcuts/editor.shortcuts.d.ts +0 -1
- package/lib/types/controllers/shortcuts/utils.d.ts +0 -1
- package/lib/types/controllers/slide-editing.render-controller.d.ts +2 -4
- package/lib/types/controllers/slide-editor-bridge.render-controller.d.ts +6 -14
- package/lib/types/controllers/slide-ui.controller.d.ts +0 -1
- package/lib/types/controllers/slide.render-controller.d.ts +69 -8
- package/lib/types/controllers/text.menu.d.ts +0 -1
- package/lib/types/index.d.ts +9 -2
- package/lib/types/locale/en-US.d.ts +0 -1
- package/lib/types/locale/ru-RU.d.ts +0 -1
- package/lib/types/locale/vi-VN.d.ts +0 -1
- package/lib/types/locale/zh-TW.d.ts +0 -1
- package/lib/types/services/slide-editor-bridge.service.d.ts +10 -4
- package/lib/types/services/slide-editor-manager.service.d.ts +0 -1
- package/lib/types/services/slide-popup-manager.service.d.ts +1 -2
- package/lib/types/services/slide-render.service.d.ts +16 -0
- package/lib/types/slides-ui-plugin.d.ts +0 -1
- package/lib/types/type.d.ts +6 -0
- package/lib/types/views/editor-container/EditorContainer.d.ts +1 -2
- package/lib/umd/index.js +3 -3
- package/package.json +18 -18
package/lib/es/index.js
CHANGED
|
@@ -2,16 +2,16 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ISidebarService,
|
|
8
|
-
import {
|
|
5
|
+
import { RxDisposable, UniverInstanceType, debounce, getColorStyle, Inject, Injector, IUniverInstanceService, OnLifecycle, LifecycleStages, CommandType, PageElementType, Tools, useDependency, LocaleService, ICommandService, generateRandomId, BasicShapes, createIdentifier, createInternalEditorID, IContextService, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, FOCUSING_UNIVER_EDITOR, EDITOR_ACTIVATED, FORMULA_EDITOR_ACTIVATED, Disposable, connectInjector, DisposableCollection, toDisposable, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, DocumentDataModel, VerticalAlign, HorizontalAlign, WrapStrategy, FOCUSING_EDITOR_BUT_HIDDEN, Direction, IUndoRedoService, Plugin, mergeOverrideWithDependencies } from "@univerjs/core";
|
|
6
|
+
import { Viewport, ScrollBar, Slide, Rect, Scene, IRenderManagerService, ObjectType, FIX_ONE_PIXEL_BLUR_OFFSET, DeviceInputEventType, pxToNum, convertTextRotation, fixLineWidthByScale, ITextSelectionRenderManager } from "@univerjs/engine-render";
|
|
7
|
+
import { ISidebarService, useObservable, IEditorService, DISABLE_AUTO_FOCUS_KEY, TextEditor, MenuItemType, MenuPosition, MenuGroup, getMenuHiddenObservable, KeyCode, MetaKeys, BuiltInUIPart, ComponentManager, IMenuService, IUIPartsService, IShortcutService, ICanvasPopupService, ILayoutService } from "@univerjs/ui";
|
|
8
|
+
import { ObjectProvider, SLIDE_KEY } from "@univerjs/slides";
|
|
9
9
|
import { IImageIoService, getImageSize, DRAWING_IMAGE_ALLOW_IMAGE_LIST } from "@univerjs/drawing";
|
|
10
10
|
import React, { forwardRef, useRef, createElement, useState, useEffect, useCallback } from "react";
|
|
11
11
|
import clsx from "clsx";
|
|
12
12
|
import { Button, InputNumber, Dropdown, ColorPicker, Scrollbar } from "@univerjs/design";
|
|
13
|
-
import { DeleteLeftCommand,
|
|
14
|
-
import { BehaviorSubject, Subject, filter } from "rxjs";
|
|
13
|
+
import { DeleteLeftCommand, DocSkeletonManagerService, VIEWPORT_KEY, DOCS_COMPONENT_MAIN_LAYER_INDEX, RichTextEditingMutation, MoveSelectionOperation, MoveCursorOperation, TextSelectionManagerService, DOCS_VIEW_KEY } from "@univerjs/docs";
|
|
14
|
+
import { BehaviorSubject, Subject, filter, takeUntil } from "rxjs";
|
|
15
15
|
var __assign = function() {
|
|
16
16
|
return __assign = Object.assign || function(t) {
|
|
17
17
|
for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
|
|
@@ -41,15 +41,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
|
41
41
|
var attrs = __assign({}, node.attrs);
|
|
42
42
|
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
43
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(
|
|
45
|
-
var key =
|
|
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(_a11) {
|
|
45
|
+
var key = _a11[0], value = _a11[1];
|
|
46
46
|
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
47
47
|
})), attrs;
|
|
48
48
|
}
|
|
49
49
|
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
50
50
|
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
51
|
-
var
|
|
52
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((
|
|
51
|
+
var _a11, defIds = runtimeProps.defIds;
|
|
52
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
53
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
54
|
}) }) : node;
|
|
55
55
|
}
|
|
@@ -139,38 +139,341 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width:
|
|
|
139
139
|
}));
|
|
140
140
|
});
|
|
141
141
|
TopmostSingle.displayName = "TopmostSingle";
|
|
142
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
143
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
144
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
145
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
146
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a;
|
|
147
|
+
let SlideRenderController = (_a = class extends RxDisposable {
|
|
148
|
+
/**
|
|
149
|
+
* As a dep of UNIVER_SLIDE, init by RenderManagerService@createRender --> injector.get(dep)
|
|
150
|
+
* @param _renderContext
|
|
151
|
+
* @param _injector
|
|
152
|
+
* @param _univerInstanceService
|
|
153
|
+
* @param _renderManagerService
|
|
154
|
+
*/
|
|
155
|
+
constructor(_renderContext, _injector, _univerInstanceService, _renderManagerService) {
|
|
156
|
+
super();
|
|
157
|
+
__publicField(this, "_objectProvider", null);
|
|
158
|
+
__publicField(this, "_refreshThumb", debounce(() => {
|
|
159
|
+
this.createThumbs();
|
|
160
|
+
}, 300));
|
|
161
|
+
this._renderContext = _renderContext, this._injector = _injector, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._objectProvider = this._injector.createInstance(ObjectProvider), this._addNewRender();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* _initialize --> _create --> _addNewRender
|
|
165
|
+
*/
|
|
166
|
+
_addNewRender() {
|
|
167
|
+
const { unitId, engine, scene } = this._renderContext, slideDataModel = this._getCurrUnitModel();
|
|
168
|
+
if (!slideDataModel) return;
|
|
169
|
+
const observer = engine.onTransformChange$.subscribeEvent(() => {
|
|
170
|
+
this._scrollToCenter(), observer == null || observer.unsubscribe();
|
|
171
|
+
});
|
|
172
|
+
engine.onTransformChange$.subscribeEvent(() => {
|
|
173
|
+
setTimeout(() => {
|
|
174
|
+
this.createThumbs();
|
|
175
|
+
}, 300);
|
|
176
|
+
});
|
|
177
|
+
const viewMain = new Viewport(SLIDE_KEY.VIEW, scene, {
|
|
178
|
+
left: 0,
|
|
179
|
+
top: 0,
|
|
180
|
+
bottom: 0,
|
|
181
|
+
right: 0,
|
|
182
|
+
isRelativeX: !0,
|
|
183
|
+
isRelativeY: !0,
|
|
184
|
+
isWheelPreventDefaultX: !0
|
|
185
|
+
});
|
|
186
|
+
scene.attachControl(), scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
187
|
+
const e = evt;
|
|
188
|
+
if (e.ctrlKey) {
|
|
189
|
+
const deltaFactor = Math.abs(e.deltaX);
|
|
190
|
+
let scrollNum = deltaFactor < 40 ? 0.2 : deltaFactor < 80 ? 0.4 : 0.2;
|
|
191
|
+
scrollNum *= e.deltaY > 0 ? -1 : 1, scene.scaleX < 1 && (scrollNum /= 2), scene.scaleX + scrollNum > 4 ? scene.scale(4, 4) : scene.scaleX + scrollNum < 0.1 ? scene.scale(0.1, 0.1) : (e.deltaY > 0, e.preventDefault());
|
|
192
|
+
} else
|
|
193
|
+
viewMain.onMouseWheel(e, state);
|
|
194
|
+
}), scene.onFileLoaded$.subscribeEvent(() => {
|
|
195
|
+
this._refreshThumb();
|
|
196
|
+
}), ScrollBar.attachTo(viewMain), this._renderManagerService.setCurrent(unitId);
|
|
197
|
+
const slide = this._createSlide(scene);
|
|
198
|
+
this._renderContext.mainComponent = slide, this._createSlidePages(slideDataModel, slide), this.createThumbs(), engine.runRenderLoop(() => {
|
|
199
|
+
scene.render();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
_scrollToCenter() {
|
|
203
|
+
var _a11;
|
|
204
|
+
const mainScene = (_a11 = this._currentRender()) == null ? void 0 : _a11.scene, viewMain = mainScene == null ? void 0 : mainScene.getViewport(SLIDE_KEY.VIEW), getCenterPositionViewPort = this._getCenterPositionViewPort(mainScene);
|
|
205
|
+
if (!viewMain || !getCenterPositionViewPort) return;
|
|
206
|
+
const { left: viewPortLeft, top: viewPortTop } = getCenterPositionViewPort, { x, y } = viewMain.transViewportScroll2ScrollValue(viewPortLeft, viewPortTop);
|
|
207
|
+
viewMain.scrollToBarPos({
|
|
208
|
+
x,
|
|
209
|
+
y
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
_currentRender() {
|
|
213
|
+
return this._renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SLIDE);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* init --> _addNewRender
|
|
217
|
+
* @param mainScene
|
|
218
|
+
*/
|
|
219
|
+
_createSlide(mainScene) {
|
|
220
|
+
const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), { width: sceneWidth, height: sceneHeight } = mainScene, pageSize = model.getPageSize(), { width = 100, height = 100 } = pageSize, slideComponent = new Slide(SLIDE_KEY.COMPONENT, {
|
|
221
|
+
left: (sceneWidth - width) / 2,
|
|
222
|
+
top: (sceneHeight - height) / 2,
|
|
223
|
+
width,
|
|
224
|
+
height,
|
|
225
|
+
zIndex: 10
|
|
226
|
+
});
|
|
227
|
+
return slideComponent.enableSelectedClipElement(), mainScene.addObject(slideComponent), slideComponent;
|
|
228
|
+
}
|
|
229
|
+
_addBackgroundRect(scene, fill) {
|
|
230
|
+
const pageSize = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE).getPageSize(), { width: pageWidth = 0, height: pageHeight = 0 } = pageSize, page = new Rect("canvas", {
|
|
231
|
+
left: 0,
|
|
232
|
+
top: 0,
|
|
233
|
+
width: pageWidth,
|
|
234
|
+
height: pageHeight,
|
|
235
|
+
strokeWidth: 1,
|
|
236
|
+
stroke: "rgba(198,198,198,1)",
|
|
237
|
+
fill: getColorStyle(fill) || "rgba(255,255,255,1)",
|
|
238
|
+
zIndex: 0,
|
|
239
|
+
evented: !1
|
|
240
|
+
});
|
|
241
|
+
scene.addObject(page, 0);
|
|
242
|
+
}
|
|
243
|
+
_getCenterPositionViewPort(mainScene) {
|
|
244
|
+
if (!mainScene) return { left: 0, top: 0 };
|
|
245
|
+
const { width, height } = mainScene, engine = mainScene.getEngine(), canvasWidth = (engine == null ? void 0 : engine.width) || 0, canvasHeight = (engine == null ? void 0 : engine.height) || 0;
|
|
246
|
+
return {
|
|
247
|
+
left: (width - canvasWidth) / 2,
|
|
248
|
+
top: (height - canvasHeight) / 2
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
_thumbSceneRender(pageId, slide) {
|
|
252
|
+
const render2 = this._renderManagerService.getRenderById(pageId);
|
|
253
|
+
if (render2 == null)
|
|
254
|
+
return;
|
|
255
|
+
const { engine: thumbEngine } = render2;
|
|
256
|
+
if (thumbEngine == null)
|
|
257
|
+
return;
|
|
258
|
+
const { width, height } = slide, { width: pageWidth = width, height: pageHeight = height } = thumbEngine, thumbContext = thumbEngine.getCanvas().getContext();
|
|
259
|
+
slide.renderToThumb(thumbContext, pageId, pageWidth / width, pageHeight / height);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* _createScene by pages, createScene --> set sceneMap
|
|
263
|
+
* invoked stack: initialize --> _create --> _addNewRender --> _createSlidePages
|
|
264
|
+
* @param slideDataModel
|
|
265
|
+
* @param slide
|
|
266
|
+
*/
|
|
267
|
+
_createSlidePages(slideDataModel, slide) {
|
|
268
|
+
const pages = slideDataModel.getPages(), pageOrder = slideDataModel.getPageOrder();
|
|
269
|
+
if (!(!pages || !pageOrder) && pageOrder.length !== 0) {
|
|
270
|
+
for (let i = 0, len = pageOrder.length; i < len; i++) {
|
|
271
|
+
const pageId = pageOrder[i];
|
|
272
|
+
this.createPageScene(pageId, pages[pageId]), this._createThumb(pageId);
|
|
273
|
+
}
|
|
274
|
+
slide.activeFirstPage();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
_createThumb(pageId) {
|
|
278
|
+
this._renderManagerService.createRender(pageId);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* SlideDataModel is UnitModel
|
|
282
|
+
*/
|
|
283
|
+
_getCurrUnitModel() {
|
|
284
|
+
return this._renderContext.unit;
|
|
285
|
+
}
|
|
286
|
+
activePage(_pageId) {
|
|
287
|
+
let pageId = _pageId;
|
|
288
|
+
const model = this._getCurrUnitModel();
|
|
289
|
+
let page;
|
|
290
|
+
if (pageId)
|
|
291
|
+
page = model.getPage(pageId);
|
|
292
|
+
else {
|
|
293
|
+
const pageElements = model.getPages(), pageOrder = model.getPageOrder();
|
|
294
|
+
if (pageOrder == null || pageElements == null)
|
|
295
|
+
return;
|
|
296
|
+
page = pageElements[pageOrder[0]], pageId = page.id;
|
|
297
|
+
}
|
|
298
|
+
const render2 = this._currentRender();
|
|
299
|
+
if (page == null || render2 == null || render2.mainComponent == null)
|
|
300
|
+
return;
|
|
301
|
+
const { id } = page, slide = render2.mainComponent;
|
|
302
|
+
if (model.setActivePage(page), slide != null && slide.hasPage(id)) {
|
|
303
|
+
slide.changePage(id);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
this.createPageScene(id, page);
|
|
307
|
+
}
|
|
308
|
+
createThumbs() {
|
|
309
|
+
const pageOrder = this._getCurrUnitModel().getPageOrder(), render2 = this._currentRender();
|
|
310
|
+
if (!(!pageOrder || !render2) && pageOrder.length !== 0)
|
|
311
|
+
for (let i = 0, len = pageOrder.length; i < len; i++) {
|
|
312
|
+
const pageId = pageOrder[i];
|
|
313
|
+
this._thumbSceneRender(pageId, render2.mainComponent);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* _initialize --> _create --> _addNewRender --> _createSlidePages --> page forEach --> createPageScene
|
|
318
|
+
* _sceneMap.set(pageId, pageScene);
|
|
319
|
+
*
|
|
320
|
+
* @param pageId
|
|
321
|
+
* @param page
|
|
322
|
+
* @returns pageScene: Scene
|
|
323
|
+
*/
|
|
324
|
+
createPageScene(pageId, page) {
|
|
325
|
+
const render2 = this._renderContext;
|
|
326
|
+
if (!render2 || !this._objectProvider)
|
|
327
|
+
return;
|
|
328
|
+
const { scene: mainScene, mainComponent } = render2, slide = mainComponent, { width, height } = slide, pageScene = new Scene(pageId, slide, {
|
|
329
|
+
width,
|
|
330
|
+
height
|
|
331
|
+
});
|
|
332
|
+
new Viewport(`PageViewer_${pageId}`, pageScene, {
|
|
333
|
+
left: 0,
|
|
334
|
+
top: 0,
|
|
335
|
+
bottom: 0,
|
|
336
|
+
right: 0,
|
|
337
|
+
isRelativeX: !0,
|
|
338
|
+
isRelativeY: !0
|
|
339
|
+
}).closeClip();
|
|
340
|
+
const { pageElements, pageBackgroundFill } = page, objects = this._objectProvider.convertToRenderObjects(pageElements, mainScene);
|
|
341
|
+
if (!objects || !slide) return;
|
|
342
|
+
this._addBackgroundRect(pageScene, pageBackgroundFill), pageScene.addObjects(objects), pageScene.initTransformer(), objects.forEach((object) => {
|
|
343
|
+
pageScene.attachTransformerTo(object);
|
|
344
|
+
});
|
|
345
|
+
const transformer = pageScene.getTransformer();
|
|
346
|
+
return transformer == null || transformer.changeEnd$.subscribe(() => {
|
|
347
|
+
this._thumbSceneRender(pageId, slide);
|
|
348
|
+
}), transformer == null || transformer.clearControl$.subscribe(() => {
|
|
349
|
+
this._thumbSceneRender(pageId, slide);
|
|
350
|
+
}), slide.addPageScene(pageScene), pageScene;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* get pageScene from Slide
|
|
354
|
+
* pageScene was added to the mainComponent(Slide) in createPageScene --> slide.addPageScene
|
|
355
|
+
* @param pageId
|
|
356
|
+
* @returns {Scene, Engine, UnitModel}
|
|
357
|
+
*/
|
|
358
|
+
getPageRenderUnit(pageId) {
|
|
359
|
+
const pageScene = this._renderContext.mainComponent.getSubScenes().get(pageId), { engine, unit } = this._renderContext;
|
|
360
|
+
return {
|
|
361
|
+
scene: pageScene,
|
|
362
|
+
engine,
|
|
363
|
+
unit
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
createObjectToPage(element2, pageID) {
|
|
367
|
+
const { scene } = this.getPageRenderUnit(pageID);
|
|
368
|
+
if (!scene || !this._objectProvider)
|
|
369
|
+
return;
|
|
370
|
+
const object = this._objectProvider.convertToRenderObject(element2, scene);
|
|
371
|
+
if (object)
|
|
372
|
+
return scene.addObject(object), scene.attachTransformerTo(object), scene.getLayer().makeDirty(), object;
|
|
373
|
+
}
|
|
374
|
+
setObjectActiveByPage(obj, pageID) {
|
|
375
|
+
const { scene } = this.getPageRenderUnit(pageID);
|
|
376
|
+
if (!scene) return;
|
|
377
|
+
const transformer = scene.getTransformer();
|
|
378
|
+
transformer == null || transformer.activeAnObject(obj);
|
|
379
|
+
}
|
|
380
|
+
removeObjectById(id, pageID) {
|
|
381
|
+
const { scene } = this.getPageRenderUnit(pageID);
|
|
382
|
+
if (!scene) return;
|
|
383
|
+
scene.removeObject(id);
|
|
384
|
+
const transformer = scene.getTransformer();
|
|
385
|
+
transformer == null || transformer.clearControls();
|
|
386
|
+
}
|
|
387
|
+
appendPage() {
|
|
388
|
+
const model = this._getCurrUnitModel(), page = model.getBlankPage(), render2 = this._currentRender();
|
|
389
|
+
if (page == null || render2 == null || render2.mainComponent == null)
|
|
390
|
+
return;
|
|
391
|
+
const { id: pageId } = page, slide = render2.mainComponent, scene = this.createPageScene(pageId, page);
|
|
392
|
+
slide && scene && slide.addPageScene(scene), model.appendPage(page), model.setActivePage(page);
|
|
393
|
+
}
|
|
394
|
+
}, __name(_a, "SlideRenderController"), _a);
|
|
395
|
+
SlideRenderController = __decorateClass$9([
|
|
396
|
+
__decorateParam$9(1, Inject(Injector)),
|
|
397
|
+
__decorateParam$9(2, IUniverInstanceService),
|
|
398
|
+
__decorateParam$9(3, IRenderManagerService)
|
|
399
|
+
], SlideRenderController);
|
|
400
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
401
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
402
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
403
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
404
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a2;
|
|
405
|
+
let CanvasView = (_a2 = class extends RxDisposable {
|
|
406
|
+
constructor(_renderManagerService) {
|
|
407
|
+
super(), this._renderManagerService = _renderManagerService;
|
|
408
|
+
}
|
|
409
|
+
_getSlideRenderControllerFromRenderUnit(unitId) {
|
|
410
|
+
return this._renderManagerService.getRenderById(unitId).with(SlideRenderController);
|
|
411
|
+
}
|
|
412
|
+
createThumbs(unitId) {
|
|
413
|
+
this._getSlideRenderControllerFromRenderUnit(unitId).createThumbs();
|
|
414
|
+
}
|
|
415
|
+
activePage(pageId, unitId) {
|
|
416
|
+
this._getSlideRenderControllerFromRenderUnit(unitId).activePage(pageId);
|
|
417
|
+
}
|
|
418
|
+
getRenderUnitByPageId(pageId, unitId) {
|
|
419
|
+
return this._getSlideRenderControllerFromRenderUnit(unitId).getPageRenderUnit(pageId);
|
|
420
|
+
}
|
|
421
|
+
createObjectToPage(element2, pageID, unitId) {
|
|
422
|
+
return this._getSlideRenderControllerFromRenderUnit(unitId).createObjectToPage(element2, pageID);
|
|
423
|
+
}
|
|
424
|
+
setObjectActiveByPage(obj, pageID, unitId) {
|
|
425
|
+
return this._getSlideRenderControllerFromRenderUnit(unitId).setObjectActiveByPage(obj, pageID);
|
|
426
|
+
}
|
|
427
|
+
removeObjectById(id, pageID, unitId) {
|
|
428
|
+
this._getSlideRenderControllerFromRenderUnit(unitId).removeObjectById(id, pageID);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* append blank page
|
|
432
|
+
*/
|
|
433
|
+
appendPage(unitId) {
|
|
434
|
+
this._getSlideRenderControllerFromRenderUnit(unitId).appendPage();
|
|
435
|
+
}
|
|
436
|
+
}, __name(_a2, "CanvasView"), _a2);
|
|
437
|
+
CanvasView = __decorateClass$8([
|
|
438
|
+
OnLifecycle(LifecycleStages.Ready, CanvasView),
|
|
439
|
+
__decorateParam$8(0, IRenderManagerService)
|
|
440
|
+
], CanvasView);
|
|
142
441
|
const ActivateSlidePageOperation = {
|
|
143
442
|
id: "slide.operation.activate-slide",
|
|
144
443
|
type: CommandType.OPERATION,
|
|
145
444
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
146
|
-
var
|
|
147
|
-
const canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).
|
|
148
|
-
if (!
|
|
149
|
-
const
|
|
150
|
-
|
|
445
|
+
var _a11, _b;
|
|
446
|
+
const unitId = params.unitId, canvasView = accessor.get(CanvasView), model = accessor.get(IUniverInstanceService).getUnit(unitId), pageId = (_a11 = model == null ? void 0 : model.getActivePage()) == null ? void 0 : _a11.id;
|
|
447
|
+
if (!pageId) return !1;
|
|
448
|
+
const page = canvasView.getRenderUnitByPageId(pageId, unitId);
|
|
449
|
+
if (!page) return !1;
|
|
450
|
+
const transformer = (_b = page.scene) == null ? void 0 : _b.getTransformer();
|
|
451
|
+
return transformer && transformer.clearControls(), canvasView.activePage(params.id, unitId), !0;
|
|
151
452
|
}, "handler")
|
|
152
453
|
}, DeleteSlideElementOperation = {
|
|
153
454
|
id: "slide.operation.delete-element",
|
|
154
455
|
type: CommandType.OPERATION,
|
|
155
456
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
156
457
|
if (!(params != null && params.id)) return !1;
|
|
157
|
-
const slideData = accessor.get(IUniverInstanceService).
|
|
458
|
+
const unitId = params.unitId, slideData = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
158
459
|
if (!slideData) return !1;
|
|
159
460
|
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;
|
|
461
|
+
return delete activePage.pageElements[params.id], slideData.updatePage(activePage.id, activePage), accessor.get(CanvasView).removeObjectById(params.id, activePage.id, unitId), !0;
|
|
161
462
|
}, "handler")
|
|
162
463
|
}, InsertSlideFloatImageOperation = {
|
|
163
464
|
id: "slide.operation.insert-float-image",
|
|
164
465
|
type: CommandType.OPERATION,
|
|
165
466
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
166
|
-
var
|
|
467
|
+
var _a11;
|
|
167
468
|
const imageIoService = accessor.get(IImageIoService);
|
|
168
|
-
if (!((
|
|
469
|
+
if (!((_a11 = params == null ? void 0 : params.files) != null && _a11.length)) return !1;
|
|
169
470
|
const imageParam = await imageIoService.saveImage(params.files[0]);
|
|
170
471
|
if (!imageParam) return !1;
|
|
171
|
-
const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""),
|
|
472
|
+
const { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), univerInstanceService = accessor.get(IUniverInstanceService), unitId = params.unitId, slideData = univerInstanceService.getUnit(unitId);
|
|
473
|
+
if (!slideData) return !1;
|
|
474
|
+
const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
|
|
172
475
|
id: imageId,
|
|
173
|
-
zIndex:
|
|
476
|
+
zIndex: maxIndex + 1,
|
|
174
477
|
left: 0,
|
|
175
478
|
top: 0,
|
|
176
479
|
width,
|
|
@@ -187,12 +490,10 @@ const ActivateSlidePageOperation = {
|
|
|
187
490
|
image
|
|
188
491
|
}
|
|
189
492
|
}
|
|
190
|
-
}
|
|
191
|
-
if (!slideData) return !1;
|
|
192
|
-
const activePage = slideData.getActivePage();
|
|
493
|
+
};
|
|
193
494
|
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;
|
|
495
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
|
|
496
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
|
|
196
497
|
}, "handler")
|
|
197
498
|
};
|
|
198
499
|
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
@@ -223,7 +524,7 @@ const UpdateSlideElementOperation = {
|
|
|
223
524
|
id: "slide.operation.update-element",
|
|
224
525
|
type: CommandType.OPERATION,
|
|
225
526
|
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
226
|
-
const { oKey, props } = params,
|
|
527
|
+
const { oKey, props } = params, univerInstanceService = accessor.get(IUniverInstanceService), unitId = params == null ? void 0 : params.unitId, slideData = univerInstanceService.getUnit(unitId);
|
|
227
528
|
if (!slideData) return !1;
|
|
228
529
|
const activePage = slideData.getActivePage();
|
|
229
530
|
return activePage.pageElements[oKey] = Tools.deepMerge(activePage.pageElements[oKey], props), slideData.updatePage(activePage.id, activePage), !0;
|
|
@@ -245,7 +546,7 @@ const UpdateSlideElementOperation = {
|
|
|
245
546
|
slidePanelColorPicker
|
|
246
547
|
};
|
|
247
548
|
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;
|
|
549
|
+
const { pageId, unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(pageId, unitId), scene = page == null ? void 0 : page.scene;
|
|
249
550
|
if (!scene) return null;
|
|
250
551
|
const transformer = scene.getTransformer();
|
|
251
552
|
if (!transformer) return null;
|
|
@@ -260,6 +561,7 @@ function ArrangePanel$1(props) {
|
|
|
260
561
|
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
562
|
zIndex
|
|
262
563
|
}), commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
564
|
+
unitId,
|
|
263
565
|
oKey: object == null ? void 0 : object.oKey,
|
|
264
566
|
props: {
|
|
265
567
|
zIndex
|
|
@@ -312,7 +614,7 @@ function ArrangePanel$1(props) {
|
|
|
312
614
|
}
|
|
313
615
|
__name(ArrangePanel$1, "ArrangePanel$1");
|
|
314
616
|
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;
|
|
617
|
+
const { pageId, unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(pageId, unitId), scene = page == null ? void 0 : page.scene;
|
|
316
618
|
if (!scene) return null;
|
|
317
619
|
const transformer = scene.getTransformer();
|
|
318
620
|
if (!transformer) return null;
|
|
@@ -346,6 +648,7 @@ function TransformPanel(props) {
|
|
|
346
648
|
}, []);
|
|
347
649
|
function handleWidthChange(val) {
|
|
348
650
|
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
651
|
+
pageId,
|
|
349
652
|
oKey: object.oKey,
|
|
350
653
|
props: {
|
|
351
654
|
width: val
|
|
@@ -355,6 +658,7 @@ function TransformPanel(props) {
|
|
|
355
658
|
__name(handleWidthChange, "handleWidthChange");
|
|
356
659
|
function handleHeightChange(val) {
|
|
357
660
|
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
661
|
+
pageId,
|
|
358
662
|
oKey: object.oKey,
|
|
359
663
|
props: {
|
|
360
664
|
height: val
|
|
@@ -364,6 +668,7 @@ function TransformPanel(props) {
|
|
|
364
668
|
__name(handleHeightChange, "handleHeightChange");
|
|
365
669
|
function handleXChange(val) {
|
|
366
670
|
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
671
|
+
pageId,
|
|
367
672
|
oKey: object.oKey,
|
|
368
673
|
props: {
|
|
369
674
|
left: val
|
|
@@ -373,6 +678,7 @@ function TransformPanel(props) {
|
|
|
373
678
|
__name(handleXChange, "handleXChange");
|
|
374
679
|
function handleYChange(val) {
|
|
375
680
|
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
681
|
+
pageId,
|
|
376
682
|
oKey: object.oKey,
|
|
377
683
|
props: {
|
|
378
684
|
right: val
|
|
@@ -382,6 +688,7 @@ function TransformPanel(props) {
|
|
|
382
688
|
__name(handleYChange, "handleYChange");
|
|
383
689
|
function handleChangeRotation(val) {
|
|
384
690
|
!val || !object || (commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
691
|
+
pageId,
|
|
385
692
|
oKey: object.oKey,
|
|
386
693
|
props: {
|
|
387
694
|
angle: val
|
|
@@ -476,18 +783,19 @@ function TransformPanel(props) {
|
|
|
476
783
|
}
|
|
477
784
|
__name(TransformPanel, "TransformPanel");
|
|
478
785
|
function ArrangePanel(props) {
|
|
479
|
-
var
|
|
480
|
-
const { unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(unitId), scene = page == null ? void 0 : page.scene;
|
|
786
|
+
var _a11, _b;
|
|
787
|
+
const { pageId, unitId } = props, localeService = useDependency(LocaleService), canvasView = useDependency(CanvasView), commandService = useDependency(ICommandService), page = canvasView.getRenderUnitByPageId(pageId, unitId), scene = page == null ? void 0 : page.scene;
|
|
481
788
|
if (!scene) return null;
|
|
482
789
|
const transformer = scene.getTransformer();
|
|
483
790
|
if (!transformer) return null;
|
|
484
791
|
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
485
792
|
if (!object) return null;
|
|
486
|
-
const [color, setColor] = React.useState((_b = (
|
|
793
|
+
const [color, setColor] = React.useState((_b = (_a11 = object.fill) == null ? void 0 : _a11.toString()) != null ? _b : "");
|
|
487
794
|
function handleChangeColor(color2) {
|
|
488
795
|
object == null || object.setProps({
|
|
489
796
|
fill: color2
|
|
490
797
|
}), commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
798
|
+
unitId,
|
|
491
799
|
oKey: object == null ? void 0 : object.oKey,
|
|
492
800
|
props: {
|
|
493
801
|
shape: {
|
|
@@ -546,26 +854,39 @@ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "un
|
|
|
546
854
|
imageCommonPanelInput
|
|
547
855
|
}, COMPONENT_SLIDE_SIDEBAR = "COMPONENT_SLIDE_SIDEBAR";
|
|
548
856
|
function RectSidebar() {
|
|
549
|
-
var
|
|
550
|
-
const univerInstanceService = useDependency(IUniverInstanceService), canvasView = useDependency(CanvasView), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pageId = (
|
|
857
|
+
var _a11, _b, _c;
|
|
858
|
+
const univerInstanceService = useDependency(IUniverInstanceService), canvasView = useDependency(CanvasView), currentSlide = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pageId = (_a11 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a11.id;
|
|
551
859
|
if (!pageId) return null;
|
|
552
|
-
const transformer = (_b = canvasView.getRenderUnitByPageId(pageId).scene) == null ? void 0 : _b.getTransformer();
|
|
860
|
+
const transformer = (_b = canvasView.getRenderUnitByPageId(pageId, pageId).scene) == null ? void 0 : _b.getTransformer();
|
|
553
861
|
if (!transformer) return null;
|
|
554
862
|
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
863
|
+
if (!object)
|
|
864
|
+
return null;
|
|
865
|
+
const unitId = ((_c = univerInstanceService.getFocusedUnit()) == null ? void 0 : _c.getUnitId()) || "";
|
|
866
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: styles$4.imageCommonPanel, children: [
|
|
867
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel$1, { pageId, unitId }),
|
|
868
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TransformPanel, { pageId, unitId }),
|
|
869
|
+
object.objectType === ObjectType.RECT && /* @__PURE__ */ jsxRuntimeExports.jsx(ArrangePanel, { pageId, unitId })
|
|
870
|
+
] });
|
|
560
871
|
}
|
|
561
872
|
__name(RectSidebar, "RectSidebar");
|
|
562
|
-
const
|
|
873
|
+
const InsertSlideShapeRectangleCommand = {
|
|
874
|
+
id: "slide.command.insert-float-shape",
|
|
875
|
+
type: CommandType.COMMAND,
|
|
876
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
877
|
+
var _a11;
|
|
878
|
+
const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
|
|
879
|
+
return commandService.executeCommand(InsertSlideShapeRectangleOperation.id, { unitId });
|
|
880
|
+
}, "handler")
|
|
881
|
+
}, InsertSlideShapeRectangleOperation = {
|
|
563
882
|
id: "slide.operation.insert-float-shape",
|
|
564
883
|
type: CommandType.OPERATION,
|
|
565
884
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
566
|
-
const id = generateRandomId(6),
|
|
885
|
+
const id = generateRandomId(6), univerInstanceService = accessor.get(IUniverInstanceService), unitId = params.unitId, slideData = univerInstanceService.getUnit(unitId);
|
|
886
|
+
if (!slideData) return !1;
|
|
887
|
+
const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 20, data = {
|
|
567
888
|
id,
|
|
568
|
-
zIndex:
|
|
889
|
+
zIndex: maxIndex + 1,
|
|
569
890
|
left: 378,
|
|
570
891
|
top: 142,
|
|
571
892
|
width: 250,
|
|
@@ -582,12 +903,10 @@ const InsertSlideShapeRectangleOperation = {
|
|
|
582
903
|
}
|
|
583
904
|
}
|
|
584
905
|
}
|
|
585
|
-
}
|
|
586
|
-
if (!slideData) return !1;
|
|
587
|
-
const activePage = slideData.getActivePage();
|
|
906
|
+
};
|
|
588
907
|
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;
|
|
908
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(data, activePage.id, unitId);
|
|
909
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
|
|
591
910
|
}, "handler")
|
|
592
911
|
}, ToggleSlideEditSidebarOperation = {
|
|
593
912
|
id: "sidebar.operation.slide-shape",
|
|
@@ -603,13 +922,23 @@ const InsertSlideShapeRectangleOperation = {
|
|
|
603
922
|
width: 360
|
|
604
923
|
}) : sidebarService.close(), !0;
|
|
605
924
|
}, "handler")
|
|
925
|
+
}, SlideAddTextCommand = {
|
|
926
|
+
id: "slide.command.add-text",
|
|
927
|
+
type: CommandType.COMMAND,
|
|
928
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
929
|
+
var _a11;
|
|
930
|
+
const commandService = accessor.get(ICommandService), unitId = (_a11 = accessor.get(IUniverInstanceService).getFocusedUnit()) == null ? void 0 : _a11.getUnitId();
|
|
931
|
+
return await commandService.executeCommand(SlideAddTextOperation.id, { unitId });
|
|
932
|
+
}, "handler")
|
|
606
933
|
}, SlideAddTextOperation = {
|
|
607
934
|
id: "slide.operation.add-text",
|
|
608
935
|
type: CommandType.OPERATION,
|
|
609
936
|
handler: /* @__PURE__ */ __name(async (accessor, params) => {
|
|
610
|
-
const elementId =
|
|
937
|
+
const unitId = params.unitId, elementId = generateRandomId(6), defaultWidth = 220, defaultheight = 40, left = 230, top = 142, textContent = (params == null ? void 0 : params.text) || "A New Text", slideData = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
938
|
+
if (!slideData) return !1;
|
|
939
|
+
const activePage = slideData.getActivePage(), elements = Object.values(activePage.pageElements), maxIndex = elements != null && elements.length ? Math.max(...elements.map((element2) => element2.zIndex)) : 21, elementData = {
|
|
611
940
|
id: elementId,
|
|
612
|
-
zIndex:
|
|
941
|
+
zIndex: maxIndex + 1,
|
|
613
942
|
left,
|
|
614
943
|
top,
|
|
615
944
|
width: defaultWidth,
|
|
@@ -625,17 +954,15 @@ const InsertSlideShapeRectangleOperation = {
|
|
|
625
954
|
},
|
|
626
955
|
bl: 1
|
|
627
956
|
}
|
|
628
|
-
}
|
|
629
|
-
if (!slideData) return !1;
|
|
630
|
-
const activePage = slideData.getActivePage();
|
|
957
|
+
};
|
|
631
958
|
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;
|
|
959
|
+
const canvasview = accessor.get(CanvasView), sceneObject = canvasview.createObjectToPage(elementData, activePage.id, unitId);
|
|
960
|
+
return sceneObject && canvasview.setObjectActiveByPage(sceneObject, activePage.id, unitId), !0;
|
|
634
961
|
}, "handler")
|
|
635
962
|
}, SetSlidePageThumbOperation = {
|
|
636
963
|
id: "slide.operation.set-slide-page-thumb",
|
|
637
964
|
type: CommandType.OPERATION,
|
|
638
|
-
handler: /* @__PURE__ */ __name((accessor) => (accessor.get(CanvasView).createThumbs(), !0), "handler")
|
|
965
|
+
handler: /* @__PURE__ */ __name((accessor, params) => (accessor.get(CanvasView).createThumbs(params.unitId), !0), "handler")
|
|
639
966
|
}, SetTextEditArrowOperation = {
|
|
640
967
|
id: "slide.operation.edit-arrow",
|
|
641
968
|
type: CommandType.OPERATION,
|
|
@@ -649,8 +976,8 @@ const InsertSlideShapeRectangleOperation = {
|
|
|
649
976
|
btnContainer,
|
|
650
977
|
btnContainerExpand
|
|
651
978
|
}, SlideImagePopupMenu = /* @__PURE__ */ __name((props) => {
|
|
652
|
-
var
|
|
653
|
-
const menuItems = (_b = (
|
|
979
|
+
var _a11, _b;
|
|
980
|
+
const menuItems = (_b = (_a11 = props.popup) == null ? void 0 : _a11.extraProps) == null ? void 0 : _b.menuItems;
|
|
654
981
|
if (!menuItems)
|
|
655
982
|
return null;
|
|
656
983
|
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
|
|
@@ -708,18 +1035,18 @@ const InsertSlideShapeRectangleOperation = {
|
|
|
708
1035
|
}, "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
1036
|
uploadFileMenu,
|
|
710
1037
|
uploadFileMenuInput
|
|
711
|
-
}, COMPONENT_UPLOAD_FILE_MENU = "
|
|
1038
|
+
}, COMPONENT_UPLOAD_FILE_MENU = "SLIDE_COMPONENT_UPLOAD_FILE_MENU";
|
|
712
1039
|
var UploadFileType = /* @__PURE__ */ ((UploadFileType2) => (UploadFileType2[UploadFileType2.cellImage = 0] = "cellImage", UploadFileType2[UploadFileType2.floatImage = 1] = "floatImage", UploadFileType2))(UploadFileType || {});
|
|
713
1040
|
const UploadFileMenu = /* @__PURE__ */ __name((props) => {
|
|
714
|
-
const { type } = props, commandService = useDependency(ICommandService), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
|
|
715
|
-
var
|
|
716
|
-
(
|
|
1041
|
+
const { type } = props, commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), focused = useObservable(univerInstanceService.focused$), fileInputRef = useRef(null), handleButtonClick = /* @__PURE__ */ __name(() => {
|
|
1042
|
+
var _a11;
|
|
1043
|
+
(_a11 = fileInputRef.current) == null || _a11.click();
|
|
717
1044
|
}, "handleButtonClick"), imageAccept = DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(","), handleFileChange = /* @__PURE__ */ __name((event) => {
|
|
718
1045
|
const fileList = event.target.files;
|
|
719
1046
|
if (fileList == null)
|
|
720
1047
|
return;
|
|
721
1048
|
const files = Array.from(fileList);
|
|
722
|
-
type === UploadFileType.floatImage && commandService.executeCommand(InsertSlideFloatImageOperation.id, { files }), fileInputRef.current && (fileInputRef.current.value = "");
|
|
1049
|
+
type === UploadFileType.floatImage && commandService.executeCommand(InsertSlideFloatImageOperation.id, { files, unitId: focused }), fileInputRef.current && (fileInputRef.current.value = "");
|
|
723
1050
|
}, "handleFileChange");
|
|
724
1051
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { onClick: handleButtonClick, className: styles$2.uploadFileMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
725
1052
|
"input",
|
|
@@ -770,7 +1097,7 @@ __name(_SlideEditorManagerService, "SlideEditorManagerService");
|
|
|
770
1097
|
let SlideEditorManagerService = _SlideEditorManagerService;
|
|
771
1098
|
const ISlideEditorManagerService = createIdentifier(
|
|
772
1099
|
"univer.slide-editor-manager.service"
|
|
773
|
-
), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
|
|
1100
|
+
), SLIDE_EDITOR_ID = createInternalEditorID("SLIDE_EDITOR"), slideEditorContainer = "univer-slide-editor-container", editorInput = "univer-editor-input", styles$1 = {
|
|
774
1101
|
slideEditorContainer,
|
|
775
1102
|
editorInput
|
|
776
1103
|
}, HIDDEN_EDITOR_POSITION$1 = -1e3, EDITOR_DEFAULT_POSITION = {
|
|
@@ -778,7 +1105,7 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
778
1105
|
height: 0,
|
|
779
1106
|
top: HIDDEN_EDITOR_POSITION$1,
|
|
780
1107
|
left: HIDDEN_EDITOR_POSITION$1
|
|
781
|
-
},
|
|
1108
|
+
}, SlideEditorContainer = /* @__PURE__ */ __name(() => {
|
|
782
1109
|
const [state, setState] = useState({
|
|
783
1110
|
...EDITOR_DEFAULT_POSITION
|
|
784
1111
|
}), slideEditorManagerService = useDependency(ISlideEditorManagerService), editorService = useDependency(IEditorService), contextService = useDependency(IContextService), disableAutoFocus = useObservable(
|
|
@@ -787,7 +1114,7 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
787
1114
|
void 0,
|
|
788
1115
|
[contextService, DISABLE_AUTO_FOCUS_KEY]
|
|
789
1116
|
), snapshot = {
|
|
790
|
-
id:
|
|
1117
|
+
id: SLIDE_EDITOR_ID,
|
|
791
1118
|
body: {
|
|
792
1119
|
dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
|
|
793
1120
|
textRuns: [],
|
|
@@ -823,7 +1150,7 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
823
1150
|
left: startX + FIX_ONE_PIXEL_BLUR_OFFSET,
|
|
824
1151
|
top: startY + FIX_ONE_PIXEL_BLUR_OFFSET
|
|
825
1152
|
});
|
|
826
|
-
const editor = editorService.getEditor(
|
|
1153
|
+
const editor = editorService.getEditor(SLIDE_EDITOR_ID);
|
|
827
1154
|
if (editor == null)
|
|
828
1155
|
return;
|
|
829
1156
|
const { left, top, width, height } = editor.getBoundingClientRect();
|
|
@@ -845,7 +1172,7 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
845
1172
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
846
1173
|
TextEditor,
|
|
847
1174
|
{
|
|
848
|
-
id:
|
|
1175
|
+
id: SLIDE_EDITOR_ID,
|
|
849
1176
|
className: styles$1.editorInput,
|
|
850
1177
|
snapshot,
|
|
851
1178
|
cancelDefaultResizeListener: !1,
|
|
@@ -855,12 +1182,12 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
855
1182
|
)
|
|
856
1183
|
}
|
|
857
1184
|
);
|
|
858
|
-
}, "
|
|
1185
|
+
}, "SlideEditorContainer"), AppendSlideOperation = {
|
|
859
1186
|
id: "slide.operation.append-slide",
|
|
860
1187
|
type: CommandType.OPERATION,
|
|
861
|
-
handler: /* @__PURE__ */ __name((accessor) => {
|
|
862
|
-
const
|
|
863
|
-
return
|
|
1188
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1189
|
+
const unitId = params.unitId;
|
|
1190
|
+
return accessor.get(IUniverInstanceService).getUnit(unitId) ? (accessor.get(CanvasView).appendPage(unitId), !0) : !1;
|
|
864
1191
|
}, "handler")
|
|
865
1192
|
}, 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
1193
|
slideBar,
|
|
@@ -872,17 +1199,17 @@ const ISlideEditorManagerService = createIdentifier(
|
|
|
872
1199
|
slideAddButton
|
|
873
1200
|
};
|
|
874
1201
|
function SlideSideBar() {
|
|
875
|
-
var
|
|
1202
|
+
var _a11, _b;
|
|
876
1203
|
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
1204
|
if (!pages || !pageOrder)
|
|
878
1205
|
return null;
|
|
879
|
-
const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (
|
|
1206
|
+
const slideList = pageOrder.map((id) => pages[id]), [divRefs, setDivRefs] = useState([]), [activatePageId, setActivatePageId] = useState((_b = (_a11 = currentSlide == null ? void 0 : currentSlide.getActivePage()) == null ? void 0 : _a11.id) != null ? _b : null);
|
|
880
1207
|
useEffect(() => {
|
|
881
1208
|
setDivRefs(slideList.map((_) => React.createRef()));
|
|
882
1209
|
}, [slideList.length]), useEffect(() => {
|
|
883
1210
|
const subscriber = currentSlide == null ? void 0 : currentSlide.activePage$.subscribe((page) => {
|
|
884
|
-
var
|
|
885
|
-
const id = (
|
|
1211
|
+
var _a12;
|
|
1212
|
+
const id = (_a12 = page == null ? void 0 : page.id) != null ? _a12 : null;
|
|
886
1213
|
id && setActivatePageId(id);
|
|
887
1214
|
});
|
|
888
1215
|
return () => {
|
|
@@ -890,18 +1217,18 @@ function SlideSideBar() {
|
|
|
890
1217
|
};
|
|
891
1218
|
}, []), useEffect(() => {
|
|
892
1219
|
divRefs.forEach((ref, index) => {
|
|
893
|
-
var
|
|
1220
|
+
var _a12;
|
|
894
1221
|
if (ref.current) {
|
|
895
1222
|
const slide = slideList[index];
|
|
896
|
-
(
|
|
1223
|
+
(_a12 = renderManagerService.getRenderById(slide.id)) == null || _a12.engine.setContainer(ref.current);
|
|
897
1224
|
}
|
|
898
|
-
}), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id);
|
|
899
|
-
}, [divRefs]);
|
|
1225
|
+
}), divRefs.length > 0 && commandService.syncExecuteCommand(SetSlidePageThumbOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
|
|
1226
|
+
}, [divRefs, slideList, renderManagerService, commandService, currentSlide]);
|
|
900
1227
|
const activatePage = useCallback((page) => {
|
|
901
|
-
commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page });
|
|
902
|
-
}, [commandService]), handleAppendSlide = useCallback(() => {
|
|
903
|
-
commandService.syncExecuteCommand(AppendSlideOperation.id);
|
|
904
|
-
}, [commandService]);
|
|
1228
|
+
commandService.syncExecuteCommand(ActivateSlidePageOperation.id, { id: page, unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
|
|
1229
|
+
}, [commandService, currentSlide]), handleAppendSlide = useCallback(() => {
|
|
1230
|
+
commandService.syncExecuteCommand(AppendSlideOperation.id, { unitId: currentSlide == null ? void 0 : currentSlide.getUnitId() });
|
|
1231
|
+
}, [commandService, currentSlide]);
|
|
905
1232
|
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
1233
|
/* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: styles.slideBarContentHeader, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: handleAppendSlide, children: localeService.t("slide.append") }) }),
|
|
907
1234
|
slideList.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -967,7 +1294,7 @@ function SlideShapeMenuFactory(accessor) {
|
|
|
967
1294
|
__name(SlideShapeMenuFactory, "SlideShapeMenuFactory");
|
|
968
1295
|
function UploadSlideFloatShapeMenuFactory(_accessor) {
|
|
969
1296
|
return {
|
|
970
|
-
id:
|
|
1297
|
+
id: InsertSlideShapeRectangleCommand.id,
|
|
971
1298
|
title: "slide.shape.insert.rectangle",
|
|
972
1299
|
type: MenuItemType.BUTTON,
|
|
973
1300
|
positions: [SHAPE_MENU_ID],
|
|
@@ -1024,7 +1351,7 @@ const EditorDeleteLeftShortcut = {
|
|
|
1024
1351
|
}, TEXT_ICON_ID = "text-single";
|
|
1025
1352
|
function SlideAddTextMenuItemFactory(_accessor) {
|
|
1026
1353
|
return {
|
|
1027
|
-
id:
|
|
1354
|
+
id: SlideAddTextCommand.id,
|
|
1028
1355
|
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1029
1356
|
type: MenuItemType.BUTTON,
|
|
1030
1357
|
icon: TEXT_ICON_ID,
|
|
@@ -1038,8 +1365,8 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
|
|
|
1038
1365
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1039
1366
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1040
1367
|
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"),
|
|
1042
|
-
let SlidesUIController = (
|
|
1368
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
|
|
1369
|
+
let SlidesUIController = (_a3 = class extends Disposable {
|
|
1043
1370
|
constructor(_config, _injector, _menuService, _componentManager, _uiPartsService, _commandService, _shortcutService) {
|
|
1044
1371
|
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
1372
|
}
|
|
@@ -1066,7 +1393,9 @@ let SlidesUIController = (_a = class extends Disposable {
|
|
|
1066
1393
|
SetSlidePageThumbOperation,
|
|
1067
1394
|
InsertSlideFloatImageOperation,
|
|
1068
1395
|
SlideAddTextOperation,
|
|
1396
|
+
SlideAddTextCommand,
|
|
1069
1397
|
InsertSlideShapeRectangleOperation,
|
|
1398
|
+
InsertSlideShapeRectangleCommand,
|
|
1070
1399
|
ToggleSlideEditSidebarOperation,
|
|
1071
1400
|
DeleteSlideElementOperation,
|
|
1072
1401
|
UpdateSlideElementOperation,
|
|
@@ -1078,7 +1407,7 @@ let SlidesUIController = (_a = class extends Disposable {
|
|
|
1078
1407
|
this.disposeWithMe(
|
|
1079
1408
|
this._uiPartsService.registerComponent(BuiltInUIPart.LEFT_SIDEBAR, () => connectInjector(SlideSideBar, this._injector))
|
|
1080
1409
|
), this.disposeWithMe(
|
|
1081
|
-
this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(
|
|
1410
|
+
this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(SlideEditorContainer, this._injector))
|
|
1082
1411
|
);
|
|
1083
1412
|
}
|
|
1084
1413
|
_initShortcuts() {
|
|
@@ -1089,7 +1418,7 @@ let SlidesUIController = (_a = class extends Disposable {
|
|
|
1089
1418
|
this.disposeWithMe(this._shortcutService.registerShortcut(item));
|
|
1090
1419
|
});
|
|
1091
1420
|
}
|
|
1092
|
-
}, __name(
|
|
1421
|
+
}, __name(_a3, "SlidesUIController"), _a3);
|
|
1093
1422
|
SlidesUIController = __decorateClass$7([
|
|
1094
1423
|
OnLifecycle(LifecycleStages.Ready, SlidesUIController),
|
|
1095
1424
|
__decorateParam$7(1, Inject(Injector)),
|
|
@@ -1104,170 +1433,6 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
|
|
|
1104
1433
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1105
1434
|
return kind && result && __defProp$6(target, key, result), result;
|
|
1106
1435
|
}, "__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
1436
|
function transformBound2OffsetBound(originBound, scene) {
|
|
1272
1437
|
const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
|
|
1273
1438
|
return {
|
|
@@ -1299,8 +1464,8 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
|
|
|
1299
1464
|
}
|
|
1300
1465
|
_createObjectPositionObserver(targetObject, currentRender) {
|
|
1301
1466
|
const position = (/* @__PURE__ */ __name(() => {
|
|
1302
|
-
var
|
|
1303
|
-
const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (
|
|
1467
|
+
var _a11, _b, _c, _d;
|
|
1468
|
+
const { scene, engine } = currentRender, { left, top, width, height } = targetObject, horizontalOffset = (scene.width - ((_b = (_a11 = currentRender.mainComponent) == null ? void 0 : _a11.width) != null ? _b : 0)) / 2, verticalOffset = (scene.height - ((_d = (_c = currentRender.mainComponent) == null ? void 0 : _c.height) != null ? _d : 0)) / 2, bound = {
|
|
1304
1469
|
left,
|
|
1305
1470
|
right: left + width,
|
|
1306
1471
|
top,
|
|
@@ -1331,7 +1496,8 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
|
|
|
1331
1496
|
unitId,
|
|
1332
1497
|
subUnitId: "default",
|
|
1333
1498
|
anchorRect: position,
|
|
1334
|
-
anchorRect$: position
|
|
1499
|
+
anchorRect$: position$,
|
|
1500
|
+
canvasElement: currentRender.engine.getCanvasElement()
|
|
1335
1501
|
});
|
|
1336
1502
|
return {
|
|
1337
1503
|
dispose: /* @__PURE__ */ __name(() => {
|
|
@@ -1340,17 +1506,17 @@ let SlideCanvasPopMangerService = (_a4 = class extends Disposable {
|
|
|
1340
1506
|
};
|
|
1341
1507
|
}
|
|
1342
1508
|
}, __name(_a4, "SlideCanvasPopMangerService"), _a4);
|
|
1343
|
-
SlideCanvasPopMangerService = __decorateClass$
|
|
1344
|
-
__decorateParam$
|
|
1345
|
-
__decorateParam$
|
|
1346
|
-
__decorateParam$
|
|
1347
|
-
__decorateParam$
|
|
1509
|
+
SlideCanvasPopMangerService = __decorateClass$6([
|
|
1510
|
+
__decorateParam$6(0, Inject(ICanvasPopupService)),
|
|
1511
|
+
__decorateParam$6(1, IRenderManagerService),
|
|
1512
|
+
__decorateParam$6(2, IUniverInstanceService),
|
|
1513
|
+
__decorateParam$6(3, ICommandService)
|
|
1348
1514
|
], SlideCanvasPopMangerService);
|
|
1349
|
-
var __defProp$
|
|
1350
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1515
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1516
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1351
1517
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1352
|
-
return kind && result && __defProp$
|
|
1353
|
-
}, "__decorateClass$
|
|
1518
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1519
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
|
|
1354
1520
|
let SlidePopupMenuController = (_a5 = class extends RxDisposable {
|
|
1355
1521
|
constructor(_canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _canvasView, _sidebarService, _commandService) {
|
|
1356
1522
|
super();
|
|
@@ -1370,12 +1536,13 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
|
|
|
1370
1536
|
}
|
|
1371
1537
|
_hasCropObject(scene) {
|
|
1372
1538
|
}
|
|
1539
|
+
// eslint-disable-next-line max-lines-per-function
|
|
1373
1540
|
_popupMenuListener(unitId) {
|
|
1374
|
-
var
|
|
1375
|
-
const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (
|
|
1541
|
+
var _a11;
|
|
1542
|
+
const model = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE), pages = (_a11 = model == null ? void 0 : model.getPages()) != null ? _a11 : {};
|
|
1376
1543
|
Object.keys(pages).forEach((pageId) => {
|
|
1377
|
-
var
|
|
1378
|
-
const transformer = (
|
|
1544
|
+
var _a12;
|
|
1545
|
+
const transformer = (_a12 = this._canvasView.getRenderUnitByPageId(pageId, unitId).scene) == null ? void 0 : _a12.getTransformer();
|
|
1379
1546
|
if (!transformer) return;
|
|
1380
1547
|
let singletonPopupDisposer;
|
|
1381
1548
|
this.disposeWithMe(
|
|
@@ -1410,6 +1577,22 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
|
|
|
1410
1577
|
), this.disposeWithMe(
|
|
1411
1578
|
transformer.changing$.subscribe(() => {
|
|
1412
1579
|
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
1580
|
+
const selectedObjects = transformer.getSelectedObjectMap();
|
|
1581
|
+
if (selectedObjects.size > 1) {
|
|
1582
|
+
singletonPopupDisposer == null || singletonPopupDisposer.dispose();
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
const object = selectedObjects.values().next().value;
|
|
1586
|
+
object && this._commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
1587
|
+
unitId,
|
|
1588
|
+
oKey: object.oKey,
|
|
1589
|
+
props: {
|
|
1590
|
+
width: object.width,
|
|
1591
|
+
height: object.height,
|
|
1592
|
+
left: object.left,
|
|
1593
|
+
top: object.top
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1413
1596
|
})
|
|
1414
1597
|
);
|
|
1415
1598
|
});
|
|
@@ -1429,81 +1612,239 @@ let SlidePopupMenuController = (_a5 = class extends RxDisposable {
|
|
|
1429
1612
|
index: 5,
|
|
1430
1613
|
commandId: DeleteSlideElementOperation.id,
|
|
1431
1614
|
commandParams: {
|
|
1432
|
-
id: oKey
|
|
1615
|
+
id: oKey,
|
|
1616
|
+
unitId
|
|
1433
1617
|
},
|
|
1434
1618
|
disable: !1
|
|
1435
1619
|
}];
|
|
1436
1620
|
}
|
|
1437
1621
|
}, __name(_a5, "SlidePopupMenuController"), _a5);
|
|
1438
|
-
SlidePopupMenuController = __decorateClass$
|
|
1622
|
+
SlidePopupMenuController = __decorateClass$5([
|
|
1439
1623
|
OnLifecycle(LifecycleStages.Steady, SlidePopupMenuController),
|
|
1440
|
-
__decorateParam$
|
|
1441
|
-
__decorateParam$
|
|
1442
|
-
__decorateParam$
|
|
1443
|
-
__decorateParam$
|
|
1444
|
-
__decorateParam$
|
|
1445
|
-
__decorateParam$
|
|
1446
|
-
__decorateParam$
|
|
1624
|
+
__decorateParam$5(0, Inject(SlideCanvasPopMangerService)),
|
|
1625
|
+
__decorateParam$5(1, IRenderManagerService),
|
|
1626
|
+
__decorateParam$5(2, IUniverInstanceService),
|
|
1627
|
+
__decorateParam$5(3, IContextService),
|
|
1628
|
+
__decorateParam$5(4, Inject(CanvasView)),
|
|
1629
|
+
__decorateParam$5(5, ISidebarService),
|
|
1630
|
+
__decorateParam$5(6, ICommandService)
|
|
1447
1631
|
], SlidePopupMenuController);
|
|
1448
|
-
var __defProp$
|
|
1449
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1632
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1633
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1450
1634
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1451
|
-
return kind && result && __defProp$
|
|
1452
|
-
}, "__decorateClass$
|
|
1453
|
-
|
|
1454
|
-
|
|
1635
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1636
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
|
|
1637
|
+
const ISlideEditorBridgeService = createIdentifier("univer.slide-editor-bridge.service");
|
|
1638
|
+
var _a6;
|
|
1639
|
+
let SlideEditorBridgeService = (_a6 = class extends Disposable {
|
|
1640
|
+
constructor(_editorService, _contextService, _renderManagerService) {
|
|
1641
|
+
super();
|
|
1642
|
+
__publicField(this, "_editorUnitId", SLIDE_EDITOR_ID);
|
|
1643
|
+
__publicField(this, "_isForceKeepVisible", !1);
|
|
1644
|
+
__publicField(this, "_editorIsDirty", !1);
|
|
1645
|
+
__publicField(this, "_currentEditRectState", null);
|
|
1646
|
+
__publicField(this, "_currentEditRectState$", new BehaviorSubject(null));
|
|
1647
|
+
__publicField(this, "currentEditRectState$", this._currentEditRectState$.asObservable());
|
|
1648
|
+
__publicField(this, "_visibleParam", {
|
|
1649
|
+
visible: !1,
|
|
1650
|
+
eventType: DeviceInputEventType.Dblclick,
|
|
1651
|
+
unitId: ""
|
|
1652
|
+
});
|
|
1653
|
+
__publicField(this, "_visible$", new BehaviorSubject(this._visibleParam));
|
|
1654
|
+
__publicField(this, "visible$", this._visible$.asObservable());
|
|
1655
|
+
__publicField(this, "_afterVisible$", new BehaviorSubject(this._visibleParam));
|
|
1656
|
+
__publicField(this, "afterVisible$", this._afterVisible$.asObservable());
|
|
1657
|
+
__publicField(this, "endEditing$", new Subject());
|
|
1658
|
+
__publicField(this, "_currentEditRectInfo");
|
|
1659
|
+
this._editorService = _editorService, this._contextService = _contextService, this._renderManagerService = _renderManagerService;
|
|
1660
|
+
}
|
|
1661
|
+
dispose() {
|
|
1662
|
+
super.dispose();
|
|
1663
|
+
}
|
|
1664
|
+
getEditorRect() {
|
|
1665
|
+
return this._currentEditRectInfo;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* 1st part of startEditing.
|
|
1669
|
+
* editorBridgeRenderController@startEditing ---> editorBridgeRenderController@_updateEditor
|
|
1670
|
+
* @editorInfo editorInfo
|
|
1671
|
+
*/
|
|
1672
|
+
setEditorRect(editorInfo) {
|
|
1673
|
+
this._currentEditRectInfo = editorInfo, this._editorService.getFocusEditor() || (this._editorService.focus(SLIDE_EDITOR_ID), this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, !1), this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, !1));
|
|
1674
|
+
const editRectState = this.getEditRectState();
|
|
1675
|
+
this._currentEditRectState = editRectState, this._currentEditRectState$.next(editRectState);
|
|
1676
|
+
}
|
|
1677
|
+
changeVisible(param) {
|
|
1678
|
+
this._visibleParam = param, param.visible && (this._editorIsDirty = !1), this._visible$.next(this._visibleParam), this._afterVisible$.next(this._visibleParam);
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* get info from _currentEditRectInfo
|
|
1682
|
+
*
|
|
1683
|
+
* invoked by slide-editing.render-controller.ts@_handleEditorVisible
|
|
1684
|
+
* && this@setEditorRect
|
|
1685
|
+
*/
|
|
1686
|
+
getEditRectState() {
|
|
1687
|
+
const editorUnitId = SLIDE_EDITOR_ID, editorRectInfo = this._currentEditRectInfo, unitId = editorRectInfo.unitId, docData = editorRectInfo.richTextObj.documentData;
|
|
1688
|
+
docData.id = editorUnitId, docData.documentStyle = {
|
|
1689
|
+
...docData.documentStyle,
|
|
1690
|
+
pageSize: { width: editorRectInfo.richTextObj.width, height: 1 / 0 }
|
|
1691
|
+
};
|
|
1692
|
+
const documentLayoutObject = {
|
|
1693
|
+
documentModel: new DocumentDataModel(docData),
|
|
1694
|
+
fontString: "document",
|
|
1695
|
+
textRotation: { a: 0, v: 0 },
|
|
1696
|
+
wrapStrategy: 0,
|
|
1697
|
+
verticalAlign: VerticalAlign.TOP,
|
|
1698
|
+
horizontalAlign: HorizontalAlign.LEFT,
|
|
1699
|
+
paddingData: { t: 0, b: 1, l: 2, r: 2 }
|
|
1700
|
+
}, editorWidth = editorRectInfo.richTextObj.width, editorHeight = editorRectInfo.richTextObj.height, left = editorRectInfo.richTextObj.left, top = editorRectInfo.richTextObj.top, canvasOffset = {
|
|
1701
|
+
left: 0,
|
|
1702
|
+
top: 0
|
|
1703
|
+
}, 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 = {
|
|
1704
|
+
x: (slideMainRect == null ? void 0 : slideMainRect.left) || 0,
|
|
1705
|
+
y: (slideMainRect == null ? void 0 : slideMainRect.top) || 0
|
|
1706
|
+
}, scrollX = (mainViewport == null ? void 0 : mainViewport.viewportScrollX) || 0, scrollY = (mainViewport == null ? void 0 : mainViewport.viewportScrollY) || 0;
|
|
1707
|
+
return canvasOffset.left = slidePos.x - scrollX, canvasOffset.top = slidePos.y - scrollY, {
|
|
1708
|
+
position: {
|
|
1709
|
+
startX: left,
|
|
1710
|
+
startY: top,
|
|
1711
|
+
endX: left + editorWidth,
|
|
1712
|
+
endY: top + editorHeight
|
|
1713
|
+
},
|
|
1714
|
+
scaleX: 1,
|
|
1715
|
+
scaleY: 1,
|
|
1716
|
+
slideCardOffset: canvasOffset,
|
|
1717
|
+
unitId,
|
|
1718
|
+
editorUnitId,
|
|
1719
|
+
documentLayoutObject
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
changeEditorDirty(dirtyStatus) {
|
|
1723
|
+
this._editorIsDirty = dirtyStatus;
|
|
1724
|
+
}
|
|
1725
|
+
isVisible() {
|
|
1726
|
+
return this._visibleParam.visible;
|
|
1727
|
+
}
|
|
1728
|
+
getEditorDirty() {
|
|
1729
|
+
return this._editorIsDirty;
|
|
1730
|
+
}
|
|
1731
|
+
getCurrentEditorId() {
|
|
1732
|
+
return this._editorUnitId;
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* @deprecated
|
|
1736
|
+
*/
|
|
1737
|
+
genDocData(target) {
|
|
1738
|
+
const editorUnitId = this.getCurrentEditorId(), content = target.text, fontSize = target.fs;
|
|
1739
|
+
return {
|
|
1740
|
+
id: editorUnitId,
|
|
1741
|
+
body: {
|
|
1742
|
+
dataStream: `${content}\r
|
|
1743
|
+
`,
|
|
1744
|
+
textRuns: [{ st: 0, ed: content.length }],
|
|
1745
|
+
paragraphs: [{
|
|
1746
|
+
paragraphStyle: {
|
|
1747
|
+
// no use
|
|
1748
|
+
// textStyle: { fs: 30 },
|
|
1749
|
+
// horizontalAlign: HorizontalAlign.CENTER,
|
|
1750
|
+
// verticalAlign: VerticalAlign.MIDDLE,
|
|
1751
|
+
},
|
|
1752
|
+
startIndex: content.length + 1
|
|
1753
|
+
}],
|
|
1754
|
+
sectionBreaks: [{ startIndex: content.length + 2 }]
|
|
1755
|
+
},
|
|
1756
|
+
documentStyle: {
|
|
1757
|
+
marginBottom: 0,
|
|
1758
|
+
marginLeft: 0,
|
|
1759
|
+
marginRight: 0,
|
|
1760
|
+
marginTop: 0,
|
|
1761
|
+
pageSize: { width: 1 / 0, height: 1 / 0 },
|
|
1762
|
+
textStyle: { fs: fontSize },
|
|
1763
|
+
renderConfig: {
|
|
1764
|
+
// horizontalAlign: HorizontalAlign.CENTER,
|
|
1765
|
+
verticalAlign: VerticalAlign.MIDDLE,
|
|
1766
|
+
centerAngle: 0,
|
|
1767
|
+
vertexAngle: 0,
|
|
1768
|
+
wrapStrategy: 0
|
|
1769
|
+
}
|
|
1770
|
+
},
|
|
1771
|
+
drawings: {},
|
|
1772
|
+
drawingsOrder: [],
|
|
1773
|
+
settings: { zoomRatio: 1 }
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
}, __name(_a6, "SlideEditorBridgeService"), _a6);
|
|
1777
|
+
SlideEditorBridgeService = __decorateClass$4([
|
|
1778
|
+
__decorateParam$4(0, IEditorService),
|
|
1779
|
+
__decorateParam$4(1, IContextService),
|
|
1780
|
+
__decorateParam$4(2, IRenderManagerService)
|
|
1781
|
+
], SlideEditorBridgeService);
|
|
1782
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1783
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1784
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1785
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1786
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
|
|
1787
|
+
let SlideEditorBridgeRenderController = (_a7 = class extends RxDisposable {
|
|
1788
|
+
constructor(_renderContext, _instanceSrv, _commandService, _editorBridgeService) {
|
|
1455
1789
|
super();
|
|
1456
1790
|
/**
|
|
1457
1791
|
* It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
|
|
1458
1792
|
*/
|
|
1459
|
-
|
|
1793
|
+
// private _cursorChange: CursorChange = CursorChange.InitialState;
|
|
1460
1794
|
/** If the corresponding unit is active and prepared for editing. */
|
|
1461
|
-
|
|
1795
|
+
// private _isUnitEditing = false;
|
|
1462
1796
|
__publicField(this, "setSlideTextEditor$", new Subject());
|
|
1463
1797
|
__publicField(this, "_curRichText", null);
|
|
1464
|
-
this
|
|
1798
|
+
__publicField(this, "_d");
|
|
1799
|
+
this._renderContext = _renderContext, this._instanceSrv = _instanceSrv, this._commandService = _commandService, this._editorBridgeService = _editorBridgeService, this.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
|
|
1800
|
+
slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : this._disposeCurrent();
|
|
1801
|
+
}));
|
|
1465
1802
|
}
|
|
1466
1803
|
_init() {
|
|
1467
1804
|
const d = new DisposableCollection();
|
|
1468
|
-
return this.
|
|
1805
|
+
return this._initEventListener(d), d;
|
|
1469
1806
|
}
|
|
1470
|
-
|
|
1807
|
+
_disposeCurrent() {
|
|
1808
|
+
var _a11;
|
|
1809
|
+
(_a11 = this._d) == null || _a11.dispose(), this._d = null;
|
|
1471
1810
|
}
|
|
1472
|
-
_setEditorRect(targetObject) {
|
|
1811
|
+
_setEditorRect(pageId, targetObject) {
|
|
1473
1812
|
this._curRichText = targetObject;
|
|
1474
1813
|
const { scene, engine } = this._renderContext, unitId = this._renderContext.unitId, setEditorRect = {
|
|
1475
1814
|
scene,
|
|
1476
1815
|
engine,
|
|
1477
1816
|
unitId,
|
|
1478
|
-
pageId
|
|
1817
|
+
pageId,
|
|
1479
1818
|
richTextObj: targetObject
|
|
1480
1819
|
};
|
|
1481
1820
|
this._editorBridgeService.setEditorRect(setEditorRect);
|
|
1482
1821
|
}
|
|
1483
1822
|
_initEventListener(d) {
|
|
1484
|
-
|
|
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;
|
|
1823
|
+
const listenersForPageScene = /* @__PURE__ */ __name((scene) => {
|
|
1489
1824
|
const transformer = scene.getTransformer();
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
this.setEditorVisible(!1);
|
|
1825
|
+
transformer && (d.add(transformer.clearControl$.subscribe(() => {
|
|
1826
|
+
this.setEditorVisible(!1), this.pickOtherObjects();
|
|
1493
1827
|
})), d.add(transformer.createControl$.subscribe(() => {
|
|
1494
1828
|
this.setEditorVisible(!1);
|
|
1495
|
-
})), d.add(transformer.changeStart$.subscribe((param) => {
|
|
1496
|
-
const target = param.target;
|
|
1497
|
-
target && (target === this._curRichText || this.pickOtherObjects());
|
|
1498
1829
|
})), d.add(scene.onDblclick$.subscribeEvent(() => {
|
|
1499
1830
|
transformer.clearControls();
|
|
1500
1831
|
const object = transformer.getSelectedObjectMap().values().next().value;
|
|
1501
|
-
object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(object));
|
|
1502
|
-
}))
|
|
1832
|
+
object && (object.objectType !== ObjectType.RICH_TEXT ? this.pickOtherObjects() : this.startEditing(scene.sceneKey, object));
|
|
1833
|
+
})), d.add(this._instanceSrv.focused$.subscribe((fc) => {
|
|
1834
|
+
this.endEditing();
|
|
1835
|
+
})));
|
|
1836
|
+
}, "listenersForPageScene"), { mainComponent } = this._renderContext;
|
|
1837
|
+
mainComponent.subSceneChanged$.subscribeEvent((pageScene) => {
|
|
1838
|
+
listenersForPageScene(pageScene);
|
|
1839
|
+
});
|
|
1840
|
+
const pageSceneList = Array.from(mainComponent.getSubScenes().values());
|
|
1841
|
+
for (let i = 0; i < pageSceneList.length; i++) {
|
|
1842
|
+
const pageScene = pageSceneList[i];
|
|
1843
|
+
listenersForPageScene(pageScene);
|
|
1503
1844
|
}
|
|
1504
1845
|
}
|
|
1505
1846
|
pickOtherObjects() {
|
|
1506
|
-
this.
|
|
1847
|
+
this.endEditing();
|
|
1507
1848
|
}
|
|
1508
1849
|
/**
|
|
1509
1850
|
* invoked when picking other object.
|
|
@@ -1511,10 +1852,28 @@ let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
|
|
|
1511
1852
|
* save editing state to curr richText.
|
|
1512
1853
|
*/
|
|
1513
1854
|
endEditing() {
|
|
1855
|
+
var _a11;
|
|
1514
1856
|
if (!this._curRichText) return;
|
|
1857
|
+
this.setEditorVisible(!1);
|
|
1515
1858
|
const curRichText = this._curRichText;
|
|
1516
1859
|
if (!this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE)) return !1;
|
|
1517
|
-
curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this.
|
|
1860
|
+
curRichText.refreshDocumentByDocData(), curRichText.resizeToContentSize(), this._editorBridgeService.endEditing$.next(curRichText);
|
|
1861
|
+
const richText = {
|
|
1862
|
+
bl: 1,
|
|
1863
|
+
fs: curRichText.fs,
|
|
1864
|
+
text: curRichText.text
|
|
1865
|
+
}, textRuns = (_a11 = curRichText.documentData.body) == null ? void 0 : _a11.textRuns;
|
|
1866
|
+
if (textRuns && textRuns.length) {
|
|
1867
|
+
const ts = textRuns[0].ts;
|
|
1868
|
+
richText.cl = ts == null ? void 0 : ts.cl;
|
|
1869
|
+
}
|
|
1870
|
+
this._commandService.executeCommand(UpdateSlideElementOperation.id, {
|
|
1871
|
+
unitId: this._renderContext.unitId,
|
|
1872
|
+
oKey: curRichText == null ? void 0 : curRichText.oKey,
|
|
1873
|
+
props: {
|
|
1874
|
+
richText
|
|
1875
|
+
}
|
|
1876
|
+
}), this._curRichText = null;
|
|
1518
1877
|
}
|
|
1519
1878
|
/**
|
|
1520
1879
|
* TODO calling twice ????
|
|
@@ -1523,55 +1882,59 @@ let SlideEditorBridgeRenderController = (_a6 = class extends RxDisposable {
|
|
|
1523
1882
|
* TODO @lumixraku need scale param
|
|
1524
1883
|
* @param target
|
|
1525
1884
|
*/
|
|
1526
|
-
startEditing(target) {
|
|
1527
|
-
this._setEditorRect(target), this.setEditorVisible(!0);
|
|
1885
|
+
startEditing(pageId, target) {
|
|
1886
|
+
this._setEditorRect(pageId, target), this.setEditorVisible(!0);
|
|
1528
1887
|
}
|
|
1529
1888
|
setEditorVisible(visible) {
|
|
1530
|
-
var
|
|
1531
|
-
visible ? (
|
|
1889
|
+
var _a11, _b;
|
|
1890
|
+
visible ? (_a11 = this._curRichText) == null || _a11.hide() : (_b = this._curRichText) == null || _b.show();
|
|
1532
1891
|
const { unitId } = this._renderContext;
|
|
1533
|
-
this._editorBridgeService.changeVisible({ visible, eventType:
|
|
1534
|
-
}
|
|
1535
|
-
}, __name(
|
|
1536
|
-
SlideEditorBridgeRenderController = __decorateClass$
|
|
1537
|
-
__decorateParam$
|
|
1538
|
-
__decorateParam$
|
|
1539
|
-
__decorateParam$
|
|
1540
|
-
__decorateParam$2(4, Inject(ISlideEditorBridgeService)),
|
|
1541
|
-
__decorateParam$2(5, Inject(TextSelectionManagerService)),
|
|
1542
|
-
__decorateParam$2(6, ITextSelectionRenderManager),
|
|
1543
|
-
__decorateParam$2(7, Inject(CanvasView))
|
|
1892
|
+
this._editorBridgeService.changeVisible({ visible, eventType: DeviceInputEventType.PointerDown, unitId });
|
|
1893
|
+
}
|
|
1894
|
+
}, __name(_a7, "SlideEditorBridgeRenderController"), _a7);
|
|
1895
|
+
SlideEditorBridgeRenderController = __decorateClass$3([
|
|
1896
|
+
__decorateParam$3(1, IUniverInstanceService),
|
|
1897
|
+
__decorateParam$3(2, ICommandService),
|
|
1898
|
+
__decorateParam$3(3, ISlideEditorBridgeService)
|
|
1544
1899
|
], SlideEditorBridgeRenderController);
|
|
1545
|
-
var __defProp$
|
|
1546
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1900
|
+
var CursorChange = /* @__PURE__ */ ((_CursorChange) => (_CursorChange[_CursorChange.InitialState = 0] = "InitialState", _CursorChange[_CursorChange.StartEditor = 1] = "StartEditor", _CursorChange[_CursorChange.CursorChange = 2] = "CursorChange", _CursorChange))(CursorChange || {}), __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1901
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1547
1902
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1548
|
-
return kind && result && __defProp$
|
|
1549
|
-
}, "__decorateClass$
|
|
1903
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
1904
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
|
|
1550
1905
|
const HIDDEN_EDITOR_POSITION = -1e3, EDITOR_INPUT_SELF_EXTEND_GAP = 5, EDITOR_BORDER_SIZE = 2;
|
|
1551
|
-
var
|
|
1552
|
-
let SlideEditingRenderController = (
|
|
1553
|
-
constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionRenderManager, _textSelectionManagerService, _commandService, _localService, _editorService
|
|
1906
|
+
var _a8;
|
|
1907
|
+
let SlideEditingRenderController = (_a8 = class extends Disposable {
|
|
1908
|
+
constructor(_renderContext, _layoutService, _undoRedoService, _contextService, _instanceSrv, _renderManagerService, _editorBridgeService, _cellEditorManagerService, _textSelectionRenderManager, _textSelectionManagerService, _commandService, _localService, _editorService) {
|
|
1554
1909
|
super();
|
|
1555
1910
|
/**
|
|
1556
1911
|
* It is used to distinguish whether the user has actively moved the cursor in the editor, mainly through mouse clicks.
|
|
1557
1912
|
*/
|
|
1558
|
-
__publicField(this, "_cursorChange",
|
|
1913
|
+
__publicField(this, "_cursorChange", CursorChange.InitialState);
|
|
1559
1914
|
/** If the corresponding unit is active and prepared for editing. */
|
|
1560
1915
|
__publicField(this, "_isUnitEditing", !1);
|
|
1561
|
-
// private _workbookSelections: WorkbookSelections;
|
|
1562
1916
|
__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.
|
|
1917
|
+
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.disposeWithMe(this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SLIDE).subscribe((slideDataModel) => {
|
|
1918
|
+
slideDataModel && slideDataModel.getUnitId() === this._renderContext.unitId ? this._d = this._init() : (this._disposeCurrent(), this._isUnitEditing && (this._handleEditorInvisible({
|
|
1919
|
+
visible: !1,
|
|
1920
|
+
eventType: DeviceInputEventType.Keyboard,
|
|
1921
|
+
keycode: KeyCode.ESC,
|
|
1922
|
+
unitId: this._renderContext.unitId
|
|
1923
|
+
}), this._isUnitEditing = !1));
|
|
1924
|
+
})), this._initEditorVisibilityListener();
|
|
1564
1925
|
}
|
|
1565
1926
|
dispose() {
|
|
1566
1927
|
super.dispose(), this._disposeCurrent();
|
|
1567
1928
|
}
|
|
1568
1929
|
_disposeCurrent() {
|
|
1569
|
-
var
|
|
1570
|
-
(
|
|
1930
|
+
var _a11;
|
|
1931
|
+
(_a11 = this._d) == null || _a11.dispose(), this._d = null;
|
|
1571
1932
|
}
|
|
1572
1933
|
_init() {
|
|
1573
1934
|
const d = new DisposableCollection();
|
|
1574
|
-
return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d),
|
|
1935
|
+
return this._subscribeToCurrentCell(d), this._initialKeyboardListener(d), this._initialCursorSync(d), this._listenEditorFocus(d), this._commandExecutedListener(d), setTimeout(() => {
|
|
1936
|
+
this._cursorStateListener(d);
|
|
1937
|
+
}, 1e3), d;
|
|
1575
1938
|
}
|
|
1576
1939
|
_initEditorVisibilityListener() {
|
|
1577
1940
|
this.disposeWithMe(this._editorBridgeService.visible$.subscribe((param) => {
|
|
@@ -1584,12 +1947,12 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1584
1947
|
}));
|
|
1585
1948
|
}
|
|
1586
1949
|
_getEditorSkeleton(editorId) {
|
|
1587
|
-
var
|
|
1588
|
-
return (
|
|
1950
|
+
var _a11;
|
|
1951
|
+
return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getSkeleton();
|
|
1589
1952
|
}
|
|
1590
1953
|
_getEditorViewModel(editorId) {
|
|
1591
|
-
var
|
|
1592
|
-
return (
|
|
1954
|
+
var _a11;
|
|
1955
|
+
return (_a11 = this._renderManagerService.getRenderById(editorId)) == null ? void 0 : _a11.with(DocSkeletonManagerService).getViewModel();
|
|
1593
1956
|
}
|
|
1594
1957
|
_initialCursorSync(d) {
|
|
1595
1958
|
d.add(this._cellEditorManagerService.focus$.pipe(filter((f2) => !!f2)).subscribe(() => {
|
|
@@ -1686,7 +2049,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1686
2049
|
*/
|
|
1687
2050
|
// eslint-disable-next-line max-lines-per-function
|
|
1688
2051
|
_editAreaProcessing(editorWidth, editorHeight, positionFromEditRectState, canvasOffset, fill, scaleX = 1, scaleY = 1) {
|
|
1689
|
-
var
|
|
2052
|
+
var _a11;
|
|
1690
2053
|
const editorObject = this._getEditorObject();
|
|
1691
2054
|
if (editorObject == null)
|
|
1692
2055
|
return;
|
|
@@ -1699,7 +2062,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1699
2062
|
startX += canvasOffset.left, startY += canvasOffset.top;
|
|
1700
2063
|
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
2064
|
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, (
|
|
2065
|
+
physicHeight > clientHeight ? (physicHeight = clientHeight, scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { enableHorizontal: !1, barSize: 8 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll()) : (scrollBar = null, (_a11 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _a11.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
2066
|
const { scaleX: precisionScaleX, scaleY: precisionScaleY } = editorScene.getPrecisionScale();
|
|
1704
2067
|
editorScene.transformByState({
|
|
1705
2068
|
width: editorWidth * scaleAdjust / scaleX,
|
|
@@ -1753,9 +2116,9 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1753
2116
|
* @param param
|
|
1754
2117
|
*/
|
|
1755
2118
|
_handleEditorVisible(param) {
|
|
1756
|
-
var
|
|
1757
|
-
const { eventType
|
|
1758
|
-
this._cursorChange = [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType) ?
|
|
2119
|
+
var _a11, _b;
|
|
2120
|
+
const { eventType } = param;
|
|
2121
|
+
this._cursorChange = [DeviceInputEventType.PointerDown, DeviceInputEventType.Dblclick].includes(eventType) ? CursorChange.CursorChange : CursorChange.StartEditor;
|
|
1759
2122
|
const editCellState = this._editorBridgeService.getEditRectState();
|
|
1760
2123
|
if (editCellState == null)
|
|
1761
2124
|
return;
|
|
@@ -1777,7 +2140,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1777
2140
|
return;
|
|
1778
2141
|
this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);
|
|
1779
2142
|
const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
|
|
1780
|
-
(
|
|
2143
|
+
(_a11 = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) == null || _a11.scrollToViewportPos({
|
|
1781
2144
|
viewportScrollX: Number.POSITIVE_INFINITY
|
|
1782
2145
|
}), this._textSelectionManagerService.replaceTextRanges([
|
|
1783
2146
|
{
|
|
@@ -1806,12 +2169,12 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1806
2169
|
_commandExecutedListener(d) {
|
|
1807
2170
|
const moveCursorOP = [SetTextEditArrowOperation.id], editedMutations = [RichTextEditingMutation.id];
|
|
1808
2171
|
d.add(this._commandService.onCommandExecuted((command) => {
|
|
1809
|
-
moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editingChangedHandler();
|
|
2172
|
+
this._editorService.getFocusId() === SLIDE_EDITOR_ID && (moveCursorOP.includes(command.id) && this._moveCursorCmdHandler(command), editedMutations.includes(command.id) && this._editorBridgeService.isVisible() && this._editingChangedHandler());
|
|
1810
2173
|
}));
|
|
1811
2174
|
}
|
|
1812
2175
|
_moveCursorCmdHandler(command) {
|
|
1813
2176
|
const params = command.params, { keycode, isShift } = params;
|
|
1814
|
-
keycode != null && this._cursorChange ===
|
|
2177
|
+
keycode != null && this._cursorChange === CursorChange.CursorChange ? this._moveInEditor(keycode, isShift) : this._editorBridgeService.changeVisible(params);
|
|
1815
2178
|
}
|
|
1816
2179
|
_editingChangedHandler() {
|
|
1817
2180
|
const editRect = this._editorBridgeService.getEditorRect();
|
|
@@ -1832,7 +2195,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1832
2195
|
}
|
|
1833
2196
|
async _handleEditorInvisible(param) {
|
|
1834
2197
|
const { keycode } = param;
|
|
1835
|
-
if (this._setOpenForCurrent(null, null), this._cursorChange =
|
|
2198
|
+
if (this._setOpenForCurrent(null, null), this._cursorChange = CursorChange.InitialState, this._exitInput(param), this._editorBridgeService.getEditRectState() == null)
|
|
1836
2199
|
return;
|
|
1837
2200
|
if (this._editorBridgeService.getEditorDirty() === !1) {
|
|
1838
2201
|
this._moveCursor(keycode);
|
|
@@ -1841,11 +2204,11 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1841
2204
|
this._moveCursor(keycode);
|
|
1842
2205
|
}
|
|
1843
2206
|
_exitInput(param) {
|
|
1844
|
-
this._contextService.setContextValue(
|
|
2207
|
+
this._contextService.setContextValue(EDITOR_ACTIVATED, !1), this._cellEditorManagerService.setState({
|
|
1845
2208
|
show: param.visible
|
|
1846
2209
|
});
|
|
1847
2210
|
const editorUnitId = this._editorBridgeService.getCurrentEditorId();
|
|
1848
|
-
editorUnitId != null &&
|
|
2211
|
+
editorUnitId != null && this._undoRedoService.clearUndoRedo(editorUnitId);
|
|
1849
2212
|
}
|
|
1850
2213
|
_moveCursor(keycode) {
|
|
1851
2214
|
if (keycode != null)
|
|
@@ -1877,7 +2240,7 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1877
2240
|
_cursorStateListener(d) {
|
|
1878
2241
|
const editorObject = this._getEditorObject(), { document: documentComponent } = editorObject;
|
|
1879
2242
|
d.add(toDisposable(documentComponent.onPointerDown$.subscribeEvent(() => {
|
|
1880
|
-
this._cursorChange ===
|
|
2243
|
+
this._cursorChange === CursorChange.StartEditor && (this._cursorChange = CursorChange.CursorChange);
|
|
1881
2244
|
})));
|
|
1882
2245
|
}
|
|
1883
2246
|
// TODO: @JOCS, is it necessary to move these commands MoveSelectionOperation\MoveCursorOperation to shortcut? and use multi-commands?
|
|
@@ -1889,21 +2252,20 @@ let SlideEditingRenderController = (_a7 = class extends Disposable {
|
|
|
1889
2252
|
direction
|
|
1890
2253
|
});
|
|
1891
2254
|
}
|
|
1892
|
-
}, __name(
|
|
1893
|
-
SlideEditingRenderController = __decorateClass$
|
|
1894
|
-
__decorateParam$
|
|
1895
|
-
__decorateParam$
|
|
1896
|
-
__decorateParam$
|
|
1897
|
-
__decorateParam$
|
|
1898
|
-
__decorateParam$
|
|
1899
|
-
__decorateParam$
|
|
1900
|
-
__decorateParam$
|
|
1901
|
-
__decorateParam$
|
|
1902
|
-
__decorateParam$
|
|
1903
|
-
__decorateParam$
|
|
1904
|
-
__decorateParam$
|
|
1905
|
-
__decorateParam$
|
|
1906
|
-
__decorateParam$1(13, IResourceLoaderService)
|
|
2255
|
+
}, __name(_a8, "SlideEditingRenderController"), _a8);
|
|
2256
|
+
SlideEditingRenderController = __decorateClass$2([
|
|
2257
|
+
__decorateParam$2(1, ILayoutService),
|
|
2258
|
+
__decorateParam$2(2, IUndoRedoService),
|
|
2259
|
+
__decorateParam$2(3, IContextService),
|
|
2260
|
+
__decorateParam$2(4, IUniverInstanceService),
|
|
2261
|
+
__decorateParam$2(5, IRenderManagerService),
|
|
2262
|
+
__decorateParam$2(6, ISlideEditorBridgeService),
|
|
2263
|
+
__decorateParam$2(7, ISlideEditorManagerService),
|
|
2264
|
+
__decorateParam$2(8, ITextSelectionRenderManager),
|
|
2265
|
+
__decorateParam$2(9, Inject(TextSelectionManagerService)),
|
|
2266
|
+
__decorateParam$2(10, ICommandService),
|
|
2267
|
+
__decorateParam$2(11, Inject(LocaleService)),
|
|
2268
|
+
__decorateParam$2(12, IEditorService)
|
|
1907
2269
|
], SlideEditingRenderController);
|
|
1908
2270
|
function getEditorObject(unitId, renderManagerService) {
|
|
1909
2271
|
if (unitId == null)
|
|
@@ -1920,19 +2282,56 @@ function getEditorObject(unitId, renderManagerService) {
|
|
|
1920
2282
|
};
|
|
1921
2283
|
}
|
|
1922
2284
|
__name(getEditorObject, "getEditorObject");
|
|
2285
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2286
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2287
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2288
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
2289
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a9;
|
|
2290
|
+
let SlideRenderService = (_a9 = class extends RxDisposable {
|
|
2291
|
+
// private _skeletonChangeMutations = new Set<string>();
|
|
2292
|
+
constructor(_contextService, _instanceSrv, _renderManagerService) {
|
|
2293
|
+
super(), this._contextService = _contextService, this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, Promise.resolve().then(() => this._init());
|
|
2294
|
+
}
|
|
2295
|
+
_init() {
|
|
2296
|
+
this._initSlideDataListener(), this._initContextListener();
|
|
2297
|
+
}
|
|
2298
|
+
_initSlideDataListener() {
|
|
2299
|
+
this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SLIDE).pipe(takeUntil(this.dispose$)).subscribe((slideModel) => {
|
|
2300
|
+
this._createRenderer(slideModel == null ? void 0 : slideModel.getUnitId());
|
|
2301
|
+
}), this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SLIDE).forEach((slideModel) => {
|
|
2302
|
+
this._createRenderer(slideModel.getUnitId());
|
|
2303
|
+
}), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SLIDE).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
|
|
2304
|
+
}
|
|
2305
|
+
_createRenderer(unitId) {
|
|
2306
|
+
unitId == null || this._instanceSrv.getUnit(unitId, UniverInstanceType.UNIVER_SLIDE) == null || (this._renderManagerService.createRender(unitId), this._renderManagerService.setCurrent(unitId));
|
|
2307
|
+
}
|
|
2308
|
+
_disposeRenderer(workbook) {
|
|
2309
|
+
const unitId = workbook.getUnitId();
|
|
2310
|
+
this._renderManagerService.removeRender(unitId);
|
|
2311
|
+
}
|
|
2312
|
+
_initContextListener() {
|
|
2313
|
+
}
|
|
2314
|
+
}, __name(_a9, "SlideRenderService"), _a9);
|
|
2315
|
+
SlideRenderService = __decorateClass$1([
|
|
2316
|
+
OnLifecycle(LifecycleStages.Ready, SlideRenderService),
|
|
2317
|
+
__decorateParam$1(0, IContextService),
|
|
2318
|
+
__decorateParam$1(1, IUniverInstanceService),
|
|
2319
|
+
__decorateParam$1(2, IRenderManagerService)
|
|
2320
|
+
], SlideRenderService);
|
|
1923
2321
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1924
2322
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1925
2323
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1926
2324
|
return kind && result && __defProp2(target, key, result), result;
|
|
1927
2325
|
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
|
|
1928
2326
|
const SLIDE_UI_PLUGIN_NAME = "SLIDE_UI";
|
|
1929
|
-
var
|
|
1930
|
-
let UniverSlidesUIPlugin = (
|
|
2327
|
+
var _a10;
|
|
2328
|
+
let UniverSlidesUIPlugin = (_a10 = class extends Plugin {
|
|
1931
2329
|
constructor(_config = {}, _injector, _renderManagerService, _univerInstanceService) {
|
|
1932
2330
|
super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService;
|
|
1933
2331
|
}
|
|
1934
2332
|
onStarting() {
|
|
1935
2333
|
mergeOverrideWithDependencies([
|
|
2334
|
+
[SlideRenderService],
|
|
1936
2335
|
[ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
|
|
1937
2336
|
// used by SlideUIController --> EditorContainer
|
|
1938
2337
|
[ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
|
|
@@ -1940,23 +2339,28 @@ let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
|
|
|
1940
2339
|
], this._config.override).forEach((d) => this._injector.add(d));
|
|
1941
2340
|
}
|
|
1942
2341
|
onReady() {
|
|
1943
|
-
|
|
2342
|
+
[
|
|
2343
|
+
// SlideRenderService will be init in ready stage, and then calling RenderManagerService@createRender --> init all deps in this rendering register block.
|
|
2344
|
+
[SlideRenderController]
|
|
2345
|
+
].forEach((m2) => {
|
|
2346
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m2));
|
|
2347
|
+
}), mergeOverrideWithDependencies([
|
|
2348
|
+
[CanvasView],
|
|
1944
2349
|
// cannot register in _renderManagerService now.
|
|
1945
2350
|
// [ISlideEditorBridgeService, { useClass: SlideEditorBridgeService }],
|
|
1946
2351
|
// // used by SlideUIController --> EditorContainer
|
|
1947
2352
|
// [ISlideEditorManagerService, { useClass: SlideEditorManagerService }],
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
// so this new RenderUnit does not have ISlideEditorBridgeService & ISlideEditorManagerService if
|
|
2353
|
+
// SlidesUIController controller should be registered in Ready stage.
|
|
2354
|
+
// SlidesUIController controller would add a new RenderUnit (__INTERNAL_EDITOR__DOCS_NORMAL)
|
|
1951
2355
|
[SlidesUIController, {
|
|
1952
2356
|
useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SlidesUIController, this._config), "useFactory")
|
|
1953
2357
|
}],
|
|
1954
|
-
// editor service
|
|
2358
|
+
// editor service was create in renderManagerService
|
|
1955
2359
|
[SlideRenderController],
|
|
1956
2360
|
[SlidePopupMenuController]
|
|
1957
2361
|
], this._config.override).forEach((m2) => {
|
|
1958
2362
|
this._injector.add(m2);
|
|
1959
|
-
});
|
|
2363
|
+
}), this._injector.get(CanvasView);
|
|
1960
2364
|
}
|
|
1961
2365
|
onRendered() {
|
|
1962
2366
|
[
|
|
@@ -1971,12 +2375,12 @@ let UniverSlidesUIPlugin = (_a8 = class extends Plugin {
|
|
|
1971
2375
|
_markSlideAsFocused() {
|
|
1972
2376
|
const currentService = this._univerInstanceService;
|
|
1973
2377
|
try {
|
|
1974
|
-
const
|
|
1975
|
-
currentService.focusUnit(
|
|
2378
|
+
const slideDataModel = currentService.getCurrentUnitForType(UniverInstanceType.UNIVER_SLIDE);
|
|
2379
|
+
currentService.focusUnit(slideDataModel.getUnitId());
|
|
1976
2380
|
} catch {
|
|
1977
2381
|
}
|
|
1978
2382
|
}
|
|
1979
|
-
}, __name(
|
|
2383
|
+
}, __name(_a10, "UniverSlidesUIPlugin"), __publicField(_a10, "pluginName", SLIDE_UI_PLUGIN_NAME), __publicField(_a10, "type", UniverInstanceType.UNIVER_SLIDE), _a10);
|
|
1980
2384
|
UniverSlidesUIPlugin = __decorateClass([
|
|
1981
2385
|
__decorateParam(1, Inject(Injector)),
|
|
1982
2386
|
__decorateParam(2, IRenderManagerService),
|
|
@@ -1985,13 +2389,22 @@ UniverSlidesUIPlugin = __decorateClass([
|
|
|
1985
2389
|
export {
|
|
1986
2390
|
ActivateSlidePageOperation,
|
|
1987
2391
|
AppendSlideOperation,
|
|
1988
|
-
|
|
2392
|
+
CanvasView,
|
|
2393
|
+
DeleteSlideElementOperation,
|
|
1989
2394
|
IMAGE_MENU_ID,
|
|
2395
|
+
ISlideEditorBridgeService,
|
|
2396
|
+
InsertSlideFloatImageOperation,
|
|
2397
|
+
InsertSlideShapeRectangleCommand,
|
|
2398
|
+
InsertSlideShapeRectangleOperation,
|
|
1990
2399
|
SHAPE_MENU_ID,
|
|
2400
|
+
SLIDE_EDITOR_ID,
|
|
1991
2401
|
SetSlidePageThumbOperation,
|
|
2402
|
+
SlideAddTextCommand,
|
|
1992
2403
|
SlideAddTextOperation,
|
|
1993
2404
|
SlideCanvasPopMangerService,
|
|
2405
|
+
SlideEditorContainer,
|
|
1994
2406
|
SlideSideBar,
|
|
1995
2407
|
SlidesUIController,
|
|
1996
|
-
UniverSlidesUIPlugin
|
|
2408
|
+
UniverSlidesUIPlugin,
|
|
2409
|
+
UpdateSlideElementOperation
|
|
1997
2410
|
};
|